#####################################################################
#
#   Makefile for the GNU cfengine  (C) Mark Burgess 1994
#
#####################################################################

HEADERS = cf.defs.h
PARSER = cf.y cf.l

OBJ = cfengine.o             \
      process.o              \
      ifconf.o               \
      image.o                \
      item.o                 \
      2Dlist.o               \
      globals.o              \
      classes.o              \
      misc.o                 \
      parse.o                \
      edittools.o            \
      patches.o              \
      link.o                 \
      tidy.o                 \
      filedir.o              \
      eval.o                 \
      modes.o                \
      mount.o                \
      macro.o                \
      varstring.o            \
      wildcard.o             \
      y.tab.o                \
      lex.yy.o

SCI_CC = -cckr

#
# Note that if you are compiling with gcc -- you will almost certainly
# need the ADDITIONAL CFLAGS  -w
#



CC=gcc
YACC=bison -y
LEX=flex
LDFLAGS=-lpub -L../pub -L/usr/lib -L/usr/local/lib -lfl
CFLAGS=-DLINUX -O2  -DDEBIAN
prefix=/usr
exec-prefix=${prefix}
MASTERDIR=/home/bcwhite/build/cfengine-1.3.8
bindir=${prefix}/bin
VPATH=/home/bcwhite/build/cfengine-1.3.8

cfbindir=$(MASTERDIR)/bin

#####################################################################
# Rules
######################################################################

all: cfengine

cfengine: ${OBJ} ../pub/libpub.a
	${CC} -o $@ ${OBJ} ${LDFLAGS}
	./cfengine -V > .cfversion

lex.yy.c: cf.l
	${LEX} $?

y.tab.c: cf.y
	${YACC} -d $?

${OBJ}: ${HEADERS}

#######################################################################
# Suffix rule
#######################################################################

.c.o: 
	${CC} -c ${CFLAGS} $(DBGFLAG) ${INCLUDE} $<

#######################################################################

tidy: mostlyclean

mostlyclean:
	rm -f ${OBJ}
	rm -f y.tab.c lex.yy.c y.tab.h
	rm -f y.tab lex.yy
	rm -f *% *~ *.o ../pub/*.o
	rm -f *.tab.c *.tab.h a.out
	rm -f cfengine.dvi cfengine.aux cfengine.log cfengine.toc
	rm -f *.tar.* #*
	rm -f ../bin/*~ ../bin/cfwrap ../bin/cfdaily ../bin/noseyparker ../bin/cfbg
	( cd ../pub; make mostlyclean )
	( cd ../doc; make mostlyclean )

distclean: tidy
	rm -f cfengine
	rm -f ../bin/cfengine
	rm -f Makefile
	rm -f ../Makefile
	rm -f ../*~ ../pub/*.a
	(cd ../doc; make distclean)
	(cd ../pub; make distclean)

install:
	../bin/Install $(prefix)

uninstall:
	../bin/Uninstall $(prefix)

dist: distclean
	../bin/MakeDist





