# Where to find things and to put things
P_BINARIES= UNDEFINED
P_INC	= -I../../../include
A_INC	= -Iarchie_src
INCS	= ${P_INC} ${A_INC}

# libraries should be relative to this dir, not SRC
DBS_LIB	= libpsarchie.a


# args to cc, etc.
CC	= gcc
F_CC	= -O2 -c -DMMAP -DSTRFIND -DCLEANUP
F_CPP	= ${INCS} ${MACHDEF} 

CFILES = \
	arch_dsdb.c \
	arch_prioritize.c \
	prarch_match.c \
	prarch_host.c \
	atopdate.c \
	atoplink.c 

OBJECTS	= \
	arch_dsdb.o \
	arch_prioritize.o \
	prarch_match.o \
	prarch_host.o \
	atopdate.o \
	atoplink.o 

ARC_LIB = \
	oper.o \
	database.o \
	misc.o \
	error.o \
	net.o

ARC_LIBSRC = \
	oper.c \
	database.c \
	misc.c \
	error.c \
	net.c


CODE	= ${CFILES} Makefile

all:	${DBS_LIB}

install:
	cp ${DBS_LIB} ${INSTDIR}/${SRV_LIB}
	ranlib ${INSTDIR}/${DBS_LIB}

clean:
	rm -f a.out core *~ tags TAGS
	rm -f ${OBJECTS} ${DBS_LIB} 

cleandb:
	\rm -f db/* /usr/tmp/archie.lock
	\cp /dev/null db/file-list
	\cp /dev/null db/strings-list

src:	${CODE}

${CODE}:
	co -q $@

${OBJECTS}:
	${CC} ${F_CC} ${F_CPP} $*.c

${ARC_LIB}:	Makefile 
	${CC} ${F_CC} ${F_CPP} $*.c

${ARC_LIBSRC}:
	ln -s archie_src/$@

${DBS_LIB}: ${OBJECTS} ${ARC_LIB}
	rm -f ${DBS_LIB}
	ar rv ${DBS_LIB} ${OBJECTS} ${ARC_LIB}
	ranlib ${DBS_LIB}

# Dependencies
atoplink.o: prarch.h
atoplink.o: archie_src/database.h
atoplink.o: archie_src/defines.h
atoplink.o: ../../../include/pfs.h
atoplink.o: ../../../include/psite.h
atoplink.o: archie_src/structs.h
prarch_host.o: prarch.h
prarch_host.o: archie_src/archie_defs.h
prarch_host.o: archie_src/database.h
prarch_host.o: archie_src/defines.h
prarch_host.o: ../../../include/perrno.h
prarch_host.o: ../../../include/pfs.h
prarch_host.o: archie_src/structs.h
