#
# Makefile for nocol lib
#

## SET THIS
# Directories needed by the Makefile
TOP = 		/usr/nocol
SRCDIR =	$(TOP)/src

BINDIR = 	$(TOP)/bin
ETCDIR = 	$(TOP)/etc
INCLUDEDIR = 	$(SRCDIR)/include
LIBDIR =	$(SRCDIR)/lib

## SET THIS
# 	NLOG_HOST		host where the noclogd logging daemon runs
#
NLOG_HOST =	noclog.jvnc.net

## SET THIS
# Set the various defines for compile time defines:
#
SYSDEFS =
AR	=  ar r
RANLIB  =  ranlib
INSTALL	=  install

####
#### Can leave the rest alone #######
####

##
# The various directories that are needed in the program. Should NOT
# have trailing '/'.
DIRDEFS =	-DETCDIR=\"$(ETCDIR)\" \
		-DDATADIR=\"$(DATADIR)\" \
		-DNLOG_HOST=\"$(NLOG_HOST)\"


# Compilation definitions
CC = 		cc
YACC =		yacc
CDEFS =		$(DIRDEFS) $(SYSDEFS)
CFLAGS = 	-g -I$(INCLUDEDIR) -I../include

TARG =	libnocol.a
OBJS=	$(NEEDOBJS) bsdsignal.o eventlog.o event_utils.o misc.o \
	fgetline.o getdate.o 

$(TARG):    $(OBJS)
	/bin/rm -f $(TARG)
	$(AR) $(TARG) $(OBJS)
	$(RANLIB)  $(TARG)
	@echo "Created $(TARG) in `pwd`"

## For testing, to make a standalone version using -DTEST
getdate:  getdate.y
	@/bin/rm -f y.tab.c
	$(YACC) getdate.y
	$(CC) $(CFLAGS) -DTEST y.tab.c -o $@
	@/bin/rm -f y.tab.c

## Putting this rule here just to be able to print out a message about
## the 8 shift/reduce conflicts from yacc.
getdate.o: getdate.y 
	@/bin/rm -f y.tab.c
	@echo -n "Expect 9 shift/reduce conflicts from $(YACC) : "
	$(YACC) $<
	$(CC) $(CFLAGS) -c $(CDEFS) y.tab.c -o $@
	@/bin/rm -f y.tab.c

.c.o:
	$(CC) $(CFLAGS) -c  $(CDEFS) $<

## The dependencies in case 'mkdep' not used
#
$(OBJS): $(INCLUDEDIR)/nocol.h $(INCLUDEDIR)/noclogd.h

install: $(TARG)
	
clean:
	rm -f $(OBJS) $(TARG) core a.out getdate
