src = moocallstack.c
header = moocallstack.h
objs = $(src:.c=.o)

include ../makeinfo

LIB=libmoocallstack.so
SONAME=1

CFLAGS += -O3 -g -fPIC -DPIC -Wall -DRUNDIR="\"$(rundir)\""

$(LIB): $(objs)
	$(CC) $(CFLAGS) -lc -shared -Wl,-soname -Wl,$(LIB).$(SONAME) $(objs) -o $(LIB).$(SONAME)
	rm -f $(LIB)
	$(LN_S) $(LIB).$(SONAME) $(LIB)

install:
	$(INSTALL) -d $(PREFIX)/$(libdir)
	$(INSTALL) $(LIB).$(SONAME) $(PREFIX)/$(libdir)
ifndef $(NO_SOLINKS)
	$(LN_S) $(LIB).$(SONAME) $(PREFIX)/$(libdir)/$(LIB)
endif
	$(INSTALL) -d $(PREFIX)/$(includedir)
	$(INSTALL) -m 0644 $(header) $(PREFIX)/$(includedir)

uninstall:
	rm -f $(PREFIX)/$(libdir)/$(LIB).$(SONAME)
	rm -f $(PREFIX)/$(libdir)/$(LIB)
	rm -f $(PREFIX)/$(includedir)/$(header)
	-rmdir -p $(PREFIX)/$(libdir) $(PREFIX)/$(includedir)

clean:
	rm -f *~ $(objs) $(LIB) $(LIB).$(SONAME) core catstack

realclean: clean
	rm -f .depend

test:
	# None yet.

catstack: $(LIB) catstack.c
	$(CC) -g catstack.c -o catstack -lmoocallstack -L .

.depend: *.c *.h
	cc -MM *.c > .depend

-include .depend
