# Makefile
# $Id: Makefile,v 1.4 2007/11/06 12:27:17 sendan Exp $
# masashi shimakura
#
CC = gcc
PGFLAGS = -L/usr/local/pgsql/lib -lpq
RM = rm

#####  for gcc-4.*  ##### 
#CFLAGS = -Wall -Wextra -Wformat=2 -O2 -ftrapv -fmudflap -g
#CFLAGS = -Wall -Wextra -Wformat=2 -O2 -Wstrict-aliasing=2 -D_FORTIFY_SOURCE=2 -g
#####  for FedraCore7  ##### 
CFLAGS = -Wall -Wextra -Wformat=2 -O2 -Wstrict-aliasing=2 -D_FORTIFY_SOURCE=2 -g
#####  for Turbo Linux 10  ##### 
#CFLAGS = -Wall -Wformat=2 -O2 -D_FORTIFY_SOURCE=2 -g
#####  for FreeBSD  ##### 
#CFLAGS = -Wall -O2 -g


CPPFLAGS = -lpthread -D_THREAD_SAFE


TARGET = zither
CTL_TARGET = zitherctl
SET_TARGET = zitherset
ALMEMSYS = almemsys.a almemsys.h
OBJS = zither.o zither_subst.o tcp.o malloc_set.o opt.o neg.o times.o \
	file.o confset.o mail.o filestat.o life.o fileset.o \
        almemsys.a

INCLUDE = zither.h prototype.h jpreturn.h almemsys.h


all: ${ALMEMSYS} ${TARGET} ${CTL_TARGET} ${SET_TARGET} 


almemsys.h: ../almemsys/almemsys.h 

	ln -s ../almemsys/almemsys.h ./

almemsys.a: ../almemsys/almemsys.a

	ln -s ../almemsys/almemsys.a ./

${TARGET}: ${OBJS} ${INCLUDE} 

	${CC} ${CFLAGS} ${CPPFLAGS} ${PGFLAGS} -o $@ ${OBJS}  

${CTL_TARGET}: zitherctl.o mail.o times.o initdaemon.o almemsys.a ${INCLUDE}

	${CC} ${CFLAGS} ${CPPFLAGS} -o zitherctl zitherctl.o mail.o times.o initdaemon.o almemsys.a 

zitherctl.o: zitherctl.c ${INCLUDE}

	${CC} ${CFLAGS} -c zitherctl.c

${SET_TARGET}: zitherset.o almemsys.a

	${CC} ${CFLAGS} ${CPPFLAGS} -o zitherset zitherset.o tcp.o almemsys.a

zitherset.o: zitherset.c ${INCLUDE}

	${CC} ${CFLAGS} -c zitherset.c

zither.o: zither.c ${INCLUDE}

	${CC} ${CFLAGS} -c zither.c 

zither_subst.o: zither_subst.c ${INCLUDE}

	${CC} ${CFLAGS} -c zither_subst.c

malloc_set.o: malloc_set.c ${INCLUDE}

	${CC} ${CFLAGS} -c malloc_set.c

opt.o: opt.c ${INCLUDE}

	${CC} ${CFLAGS} -c opt.c

initdaemon.o: initdaemon.c ${INCLUDE}

	${CC} ${CFLAGS} -c initdaemon.c

confset.o: confset.c ${INCLUDE}

	${CC} ${CFLAGS} -c confset.c

neg.o: neg.c ${INCLUDE}

	${CC} ${CFLAGS} -c neg.c

times.o: times.c ${INCLUDE}

	${CC} ${CFLAGS} -c times.c

file.o: file.c ${INCLUDE}

	${CC} ${CFLAGS} -c file.c

mail.o: mail.c ${INCLUDE}

	${CC} ${CFLAGS} -c mail.c

filestat.o: filestat.c ${INCLUDE}

	${CC} ${CFLAGS} -c filestat.c

life.o: life.c ${INCLUDE}

	${CC} ${CFLAGS} -c life.c

fileset.o: fileset.c ${INCLUDE}

	${CC} ${CFLAGS} -c fileset.c

tcp.o: tcp.c ${INCLUDE}

	${CC} ${CFLAGS} -c tcp.c



clean:
	${RM} -f ${TARGET} ${CTL_TARGET} ${SET_TARGET} *.o *.core *.bak ${ALMEMSYS} 



