include ../Makefile.inc

TOOLSCFLAGS = $(CFLAGS) -DHAVE_CONFIG_H
INCLUDES = -I.. -I../keeper/ -I../adns/

KP_SOURCES= kp_exp.c kp_imp.c kptool.c
KP_OBJECTS= kp_exp.o kp_imp.o kptool.o
KEEPER_OBJS= ../keeper/kp_cache.o ../keeper/kp_dir.o ../keeper/kp_enum.o ../keeper/kp_get.o \
			../keeper/kp_iface.o ../keeper/kp_recur.o ../keeper/kp_set.o ../keeper/kp_sort.o \
			../keeper/kp_util.o
all:	kptool @build_configtool@

utils:  kptool @build_configtool@

.c.o:
	$(CC) $(TOOLSCFLAGS) $(INCLUDES) -c $<
kptool:	$(KP_OBJECTS)
	$(CC) $(KP_OBJECTS) $(KEEPER_OBJS) -o $@

configtool:
	(cd cfgtool; $(MAKE) $@)

clean:
	(cd cfgtool; $(MAKE) $@)
	$(RM) *.o *.lo *.so *.a kptool Makefile *.exe

distclean:
	(cd cfgtool; $(MAKE) $@)
	$(RM) *.o *.lo *.so *.a kptool Makefile *.exe

install: 
	$(INSTALL_PROGRAM) kptool @prefix@
	$(INSTALL_DATA) README.kptool @prefix@
	@if test "X@build_configtool@" = "Xconfigtool"; then \
		echo "Installing ConfigTool"; \
		$(INSTALL) -m 755 cfgtool/configtool @prefix@; \
		$(INSTALL_DATA) cfgtool/README.configtool @prefix@; \
	fi

DISTFILES = *.c *.h Makefile.in \
		README* cfgtool/README* \
		cfgtool/*.h cfgtool/*.c cfgtool/pixmaps/*.xpm cfgtool/Makefile \
		sqlphp/*.php sqlphp/README

TOOLDIRS = cfgtool cfgtool/pixmaps sqlphp

dist:
	@for subdir in $(TOOLDIRS); do \
		mkdir $(DISTDIR)/$$subdir; \
		chmod 777 $(DISTDIR)/$$subdir; \
	done
	@for file in $(DISTFILES); do \
		cp -pr $$file $(DISTDIR)/$$file; \
	done

$(OBJS): Makefile ../Makefile.inc
kp_exp.o: kp_exp.c kptool.h ../config.h ../keeper/keeper.h
kp_imp.o: kp_imp.c kptool.h ../config.h ../keeper/keeper.h
kptool.o: kptool.c kptool.h ../config.h ../keeper/keeper.h
