#  Dynamic Host Configuration Client manager D-BUS Daemon  
#	Makefile  
#  Jason Vas Dias <jvdias@redhat.com>, Red Hat Inc., 2005
CC     ?= gcc
LD     = ${CC}
CFLAGS ?= -g -Wall
LDFLAGS ?= -g
DESTDIR ?= /
LIBDIR  ?= lib
DBUS_INCLUDES ?= -I/usr/$(LIBDIR)/dbus-1.0/include -I/usr/include/dbus-1.0
DBUS_LIBS     ?= -ldbus-1
OBJS   =  dbus_service.o dhcdbd.o dhcp_options.o main.o
SRCS   =  dbus_service.c dhcdbd.c dhcp_options.c main.c
INCS   =  dbus_service.h dhcdbd.h dhcp_options.h includes.h 

all:	dhcdbd tests

.c.o:
	${CC} ${CFLAGS} -c $<

.SUFFIXES: .c .o

dbus_service.o: dbus_service.c dbus_service.h
	$(CC) $(CFLAGS) $(DBUS_INCLUDES) -c dbus_service.c

dhcdbd.o: $(INCS) dhcdbd.c

dhcp_options.o: dhcp_options.c dhcp_options.h

dhcdbd: $(OBJS) $(SRCS) $(INCS)
	$(LD) $(LDFLAGS) -o $@ $(OBJS) $(DBUS_LIBS) 

tests:	dhcdbd
	(cd tests; make)

clean:
	/bin/rm -f dhcdbd *.o core.* *.list *~ system.d/*~ service/*~;
	(cd tests; make clean);
	if [ -d RedHat ]; then  cd RedHat; make clean; fi;

install:
	mkdir -p        $(DESTDIR)/sbin
	mkdir -p        $(DESTDIR)/usr/share/dbus-1/services
	mkdir -p        $(DESTDIR)/etc/dbus-1/system.d
	cp -fp dhcdbd   $(DESTDIR)/sbin
	if [ `whoami` = 'root' ]; then \
		chown root:root $(DESTDIR)/sbin/dhcdbd;	\
	        chmod 6755      $(DESTDIR)/sbin/dhcdbd;	\
        fi;
	cp -fp system.d/dhcdbd.conf   $(DESTDIR)/etc/dbus-1/system.d
	cp -fp service/dhcdbd.service $(DESTDIR)/usr/share/dbus-1/services
