# DO NOT MODIFY THIS MAKEFILE.
# It was generated automatically by fixmake
# from input file makefile.gen and writing to makefile.
#
# Makefile for fcpp -- A Fortran Compatible PreProcessor
# which is derived from the C Compatible Compiler Preprocessor 
# from GNU emacs distribution.
# Copyright (C) 1986 Free Software Foundation
# Modifications made by Robert E. Bruccoleri,
# Squibb Institute for Medical Research.
# Makefile macros for a Linux machine running gfortran and gcc.

# Flags -- note that common flags go on the binary definitions

CFLAGS        = -g
COPTFLAGS     = -g -O2 
CSPECOPTFLAGS = -g -O0
CPPFLAGS      = -DLANGUAGE_C -Dlinux -Dunix
FFLAGS        = -g
FOPTFLAGS     = -g -O2 
FSPECOPTFLAGS = -g -O0
FCPPFLAGS     = -Dlinux -Dunix 
ARFLAGS       = qs
LDFLAGS       = 
MAXPROCS      = 20

# Binaries

CC            = gcc44 -ffloat-store -pthread
CPP	      = gcc44 -E
FC            = gfortran44 -std=gnu -fno-second-underscore -fno-f2c -ffloat-store -pthread -fdump-core -fbacktrace 
FLECS         = $(CGBIN)/flecs
FCPP          = $(CGBIN)/fcpp -F
YACC          = $(CGBIN)/myacc
LEX           = flex
INSTALL	      = $(CGBIN)/install
MKPROTO	      = $(CGBIN)/mkproto
SHELL	      = /bin/sh


BIN = $(CGBIN)
MAN = $(CGD)/cat1
PSMAN = $(CGD)

CSRCS = fcpp.c alloca.c y_tab.c

SOURCES = fcpp.c fcpp.h alloca.c y_tab.c makefile.gen cexp.y descrip.mms \
	  fcpp.1 fcpp.h_proto test.inp test.ref testexp.c README INSTALL MANIFEST

DOCS = fcpp.man fcpp.ps

all: fcpp $(DOCS)

fcpp: fcpp.o alloca.o y.tab.o
	$(CC) $(CFLAGS) $(CPPFLAGS) -o fcpp fcpp.o alloca.o y.tab.o $(LDFLAGS)

install: all
	$(INSTALL) -m 555 -c fcpp $(BIN) 
	-$(INSTALL) -m 444 -c fcpp.man $(MAN)
	-$(INSTALL) -m 444 -c fcpp.ps $(PSMAN)

testexp: y.tab.c testexp.c
	$(CC) $(CFLAGS) $(CPPFLAGS) testexp.c y.tab.c -o testexp

y.tab.c: cexp.y
	echo expect 40 shift/reduce conflicts
	$(YACC) -l cexp.y
	mv y.tab.c foo.y.tab.c
	grep -v '^#ident' foo.y.tab.c >y.tab.c
	rm -f foo.y.tab.c

lint:	y.tab.c
	lint -p y.tab.c fcpp.c

y_tab.c: y.tab.c
	cp y.tab.c y_tab.c

fcpp.h_proto: fcpp.c y.tab.c alloca.c
	case "$(CGPLATFORM)" in \
	  sgi*) $(MKPROTO) -i fcpp_h_proto -l 50 fcpp.c y.tab.c | sed -e 's/int YYPARSE_PARAM_ARG/void/' >fcpp.h_proto ;; \
	  linux*) $(MKPROTO) -i fcpp_h_proto -l 50 fcpp.c y.tab.c | sed -e 's/int YYPARSE_PARAM_ARG/void/' >fcpp.h_proto ;; \
	  *)    $(MKPROTO) -i fcpp_h_proto -l 50 fcpp.c y.tab.c alloca.c | sed -e 's/YYPARSE_PARAM_ARG/arg/' >fcpp.h_proto ;; \
	esac

fcpp.man: fcpp.1
	-tbl fcpp.1 | nroff -man | col >fcpp.man

fcpp.ps: fcpp.1
	-tbl fcpp.1 | groff -T ps -man >fcpp.ps

test: test.dif

test.dif: test.inp test.ref test.out
	-diff test.out test.ref >test.dif

test.out: test.inp fcpp
	-./fcpp -F -DTEST=10 test.inp >test.out

tovax:	tovax.time

tovax.time: $(SOURCES)
	for f in $? ; do \
	    lcf=`echo $${f} | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` ; \
	    cp $${f} dino/$${lcf} ; \
	    chmod u+w dino/$${lcf} ; \
 	done
	touch tovax.time

clean:	
	-rm -f fcpp *.o y_tab.c y.tab.c foo.* $(DOCS) fcpp.h_proto \
	       test.out test.dif testexp

prepare: clean
	-rm -f makefile
	$(MAKE) -f makefile.gen makefile

makefile: makefile.gen $(CG)/$(CGPLATFORM).make
	$(CGBIN)/fixmake $(CG)/$(CGPLATFORM) makefile.gen makefile

# Get all pieces into a shar file.
# N.B. Make sure you get all the pieces of mkproto.
fcpp.shar: fcpp01

fcpp01:	all makefile $(SOURCES) ../mkproto/mkproto01 
	( set +e; \
	  makes=`cd $(CG); /bin/ls *.make`; \
	  defdir=`pwd`; \
	  (cd $(CG); cp $$makes $$defdir); \
	  cp ../mkproto/mkproto0? .; \
	  makekit -s70k -n fcpp -o MANIFEST $(SOURCES) fcpp.ps mkproto0? $$makes ; \
	  rm -f $$makes mkproto0? )

# Get all pieces into a tar file.
fcpp.tar: all makefile $(SOURCES) ../mkproto/mkproto.tar
	( set +e; \
	  makes=`cd $(CG); /bin/ls *.make`; \
	  defdir=`pwd`; \
	  (cd $(CG); cp $$makes $$defdir); \
	  cp ../mkproto/mkproto.tar .; \
	  tar cvf fcpp.tar \
	       $(SOURCES) $(DOCS) mkproto.tar $$makes ; \
	  rm -f $$makes mkproto.tar )

.c.o:
	$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c

.DEFAULT:
	co $<

depend:
	cp makefile.gen makefile.gen.BAK
	mkdepend -e '/\/usr\/include/d' -e 's%./%%' makefile.gen \
		 fcpp.c alloca.c y.tab.c
	$(MAKE) makefile

# DO NOT DELETE THIS LINE -- make depend uses it
alloca.o:	alloca.c	fcpp.h	fcpp.h_proto
fcpp.o:	fcpp.c	fcpp.h	fcpp.h_proto
y.tab.o:	fcpp.h	fcpp.h_proto	y.tab.c
# DO NOT DELETE THIS 2nd LINE -- make depend uses it
