# Makefile for the registry daemon regd
# Written by Joshua Rowe

#
# REGDB is the location of the system registry
# I recommend placing it in /var/registry.
#

SHARED=1
INSTALLDIR=/usr

#
# Nothing after here should need editing
#

VERNUM=0.0.1
CFLAGS=-DVERNUM=\"$(VERNUM)\"
LDFLAGS=
OBJS=connect.o trans.o
LOBJS=connect.o trans.o
LIBS=

ifeq ($(SHARED),1)
	LIBD=libreg.so.$(VERNUM)
else
	LIBD=libreg.a
endif

all:		$(LIBD) test

install:	lib
	cp $(LIBD) $(INSTALLDIR)/lib
	cp reglib.h $(INSTALLDIR)/include

clean:
		rm -f *.o *.d *.a

test:	test.o lib
	$(CC) -g -o test test.o -L./ -lreg

lib:	$(LIBD)

libreg.so.$(VERNUM):	$(LOBJS)
	$(CC) -shared -o $@ $(LOBJS)

libreg.a:	$(LOBJS)
	rm -f libreg.a
	ar r libreg.a $(LOBJS)

%.o:	%.c
	$(CC) $(CFLAGS) -c $<

%.d: %.c
	$(SHELL) -ec '$(CC) -M $(CFLAGS) $< \
		| sed '\''s/$*\\.o[ :]*/& $@/g'\'' > $@'

include $(OBJS:.o=.d)
