
# $Id: Makefile,v 1.9 2005/03/26 10:30:53 alien-science Exp $

objs=checksum.o crypt.o read_buf.o common.o cipher.o file.o murk.o \
      compress.o header.o pipe.o getopt_long.o prog_config.o passfile.o \
      base64.o

include make.inc

.SUFFIXES: .c .o

.MAIN : all

all : murk

####### The final program 
murk : ${objs}
	${CC} ${STATIC} -o $@ ${LIBS} ${LIB_CRYPTO} ${objs} \
		${BZ2LIB} ${STATIC_CRYPTO} ${EXTRA_STATICS} 
	-ctags *.c 

####### Test of bzip2 used to set compression header
compress.h : config/bzip_vars compress.h.tmpl
	config/bzip_vars | config/set_template.sh compress.h.tmpl

config/bzip_vars : config/bzip_vars.c
	@echo "[make] Making bzip2 test program"
	${CC} -o $@ ${CFLAGS} config/bzip_vars.c ${BZ2LIB}

###### Tests of provided functions
config.h : config/flockfile
	@echo "[make] Building config.h"
	touch config.h
	-config/flockfile

config/flockfile : config/flockfile.c
	@echo "[make] Building flockfile test program"
	-${CC} -o $@ ${CFLAGS} config/flockfile.c
	@touch $@

###### Getopt from OpenBSD 3.5
getopt_long.o : getopt/getopt_long.c getopt/getopt.h
	${CC} -c ${CFLAGS} getopt/getopt_long.c

###### Base64 from Kerberos
base64.o : base64/base64.c base64/base64.h
	${CC} -c ${CFLAGS} base64/base64.c

#######  Standard c objects
checksum.o : common.h checksum.h prog_config.h
crypt.o : common.h read_buf.h checksum.h cipher.h
read_buf.o : common.h read_buf.h
common.o : common.h
cipher.o : common.h cipher.h prog_config.h
file.o : common.h read_buf.h file.h crypt.h header.h prog_config.h pipe.h checksum.h
murk.o : common.h prog_config.h cipher.h checksum.h getopt/getopt.h
compress.o : common.h
header.o : common.h header.h prog_config.h compress.h file.h
pipe.o : common.h pipe.h crypt.h compress.h prog_config.h
prog_config.o : common.h cipher.h prog_config.h passfile.h
passfile.o : passfile.h cipher.h common.h base64/base64.h config.h

######  Testing
test check : murk
	tests/test.sh

####### Start from fresh
clean :
	rm -f *.core *.o *.a tags config/bzip_vars config/flockfile \
		compress.h config.h
	@echo "You now need to rerun configure before building"


