# @(#)makefile	2.3 1/16/96
# the following can be added to CFLAGS for various things
#
# add -DNOVOID		If your compiler can not handle the void keyword.
# add -DBSD		For BSD4.[23] UNIX Systems.
# add -DDOS		For MS-DOS/PC-DOS Systems, Micro-Soft C 4.0, Turbo C
#				Use the ANSI option.
# add -DNOGETOPT	If your library doesn't have getopt().
#				Another routine will be used in its place.
# add -DNOVARARGS	If you have neither <stdarg.h> (ANSI C) or
#				<varargs.h> (pre-ANSI C).
#				Another method will be compiled instead.
# add -Ddodebug		To compile in debugging trace statements.
# add -Ddoyydebug	To compile in yacc trace statements.
#
# add -DUSE_READLINE	To compile in support for the GNU readline library.

CFLAGS= -s -O2 -DUSE_READLINE -I.
CC= gcc
LIBS= -lreadline
ALLFILES= makefile cdgram.y cdlex.l cdecl.c cdecl.1 testset testsetxx
BINDIR= $(DJDIR)/bin
MANDIR= $(DJDIR)/info
CATDIR= /usr/man/cat1
INSTALL= cp
INSTALL_DATA= cp

all : cdecl.exe cxxdecl.exe

cdecl.exe: cdgram.c cdlex.c cdecl.c 
	$(CC) $(CFLAGS) -o cdecl.exe cdecl.c $(LIBS)

cxxdecl.exe : cdecl.exe
	ln -sf cdecl.exe cxxdecl.exe

cdlex.c: cdlex.l
	flex -l cdlex.l
	mv lexyy.c cdlex.c

cdgram.c: cdgram.y
	bison -y cdgram.y
	mv y_tab.c cdgram.c

test:
	./cdecl < testset
	./cxxdecl < testsetxx

install: cdecl.exe
	$(INSTALL) cdecl.exe $(BINDIR)
	ln -sf $(BINDIR)/cdecl.exe $(BINDIR)/cxxdecl.exe
	$(INSTALL_DATA) cdecl.1 $(MANDIR)
#	$(INSTALL_DATA) cxxdecl.1 $(MANDIR)

clean:
	rm -f cdgram.c cdlex.c cdecl.exe y.output cxxdecl.exe y_tab.c lexyy.c

clobber: clean
	rm -f $(BINDIR)/cdecl $(BINDIR)/cxxdecl
	rm -f $(MANDIR)/cdecl.1 $(MANDIR)/cxxdecl.1
	rm -f $(CATDIR)/cdecl.1.gz

cdecl.cpio: $(ALLFILES)
	ls $(ALLFILES) | cpio -ocv > cdecl.cpio

cdecl.shar: $(ALLFILES)
	shar $(ALLFILES) > cdecl.shar

cdecl25s.zip: $(ALLFILES)
	zip cdecl25s.zip $(ALLFILES)
