# DO NOT MODIFY THIS MAKEFILE.
# It was generated automatically by fixmake
# from input file makefile.gen and writing to makefile.
#
# Makefile for wrapgen.
#
#   Copyright 1992 Bristol-Myers Squibb Company
#   
#   Permission to use, copy, modify, and distribute this software
#   and its documentation for any purpose and without fee is hereby
#   granted, provided that the above copyright notice and this
#   permission notice and warranty disclaimer appear in all
#   copies.
#   
#   BRISTOL-MYERS SQUIBB COMPANY DISCLAIMS, AND THE USER WAIVES, ALL
#   REPRESENTATIONS AND WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO
#   THIS SOFTWARE, INCLUDING WITHOUT LIMITATION ALL IMPLIED WARRANTIES
#   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR USE OR PURPOSE.
#   BRISTOL-MYERS SQUIBB COMPANY MAKES NO REPRESENTATION OR WARRANTY,
#   EXPRESS OR IMPLIED, AS TO WHETHER THE USE OF THIS SOFTWARE
#   INFRINGES ANY PATENT, COPYRIGHT, OR OTHER INTELLECTUAL PROPERTY
#   RIGHT OF ANY THIRD PARTY. IN NO EVENT SHALL BRISTOL-MYERS SQUIBB
#   COMPANY BE LIABLE, AND BY USING THIS SOFTWARE USER AGREES THAT
#   BRISTOL-MYERS SQUIBB SHALL NOT BE LIABLE, FOR ANY SPECIAL, DIRECT,
#   INDIRECT, INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR ANY
#   OTHER DAMAGES OF ANY NATURE WHATSOEVER, THAT MAY BE INCURRED BY
#   THE USER OR ANY THIRD PARTY ARISING OUT OF OR IN CONNECTION WITH
#   ANY USE OF PERFORMANCE OF THIS SOFTWARE, INCLUDING WITHOUT
#   LIMITATION LOST PROFITS OR DAMAGES RESULTING FROM ANY LOSS OR USE
#   OF DATA.
#
#   Author: Robert E. Bruccoleri, 
#           Bristol-Myers Squibb Pharmaceutical Research Institute
# 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)

SHELL = /bin/sh

SOURCES = wrapgen.c parse.c lex.c parse.h wrapgen.h parse.y lex.l wrapgen.1 descrip.mms \
          makefile.gen README INSTALL MANIFEST \
	  test.ch test.cout test.fh test.fout test.inp test.stderr_c test.stderr_f

OBJS = wrapgen.o parse.o lex.o

DOCS = wrapgen.man wrapgen.ps

all:	wrapgen $(DOCS)

wrapgen: $(OBJS)
	 $(CC) $(OBJS) -o wrapgen $(LDFLAGS)

wrapgen.o: wrapgen.c parse.h wrapgen.h
	 $(CC) $(CFLAGS) $(CPPFLAGS) -c wrapgen.c

parse.h: parse.c
	 ( : )

parse.c: parse.y
	 $(YACC) -dt parse.y 
	 mv y.tab.h parse.h
	 grep -v "# line" y.tab.c | grep -v "#ident" >parse.c

parse.o: parse.c wrapgen.h
	 $(CC) $(CFLAGS) $(CPPFLAGS) -c parse.c

lex.c: lex.l
	 $(LEX) -cv lex.l
	 grep -v "# line" lex.yy.c | grep -v "#ident" | sed 's/"stdio.h"/<stdio.h>/' | \
         sed '/{stdin}/d' >lex.c

lex.o: lex.c parse.h
	 $(CC) $(CFLAGS) $(CPPFLAGS) -c lex.c

print:	wrapgen.ps
	enscript -p foo.out -r Makefile wrapgen.c parse.y lex.l test.inp test.out
	pssend foo.out
	pssend wrapgen.ps

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

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

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

prepare clean:
	-rm -f *.o wrapgen $(DOCS) lex.c lex.yy.c parse.c parse.h \
	       y.* foo.*

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

test:	wrapgen test.inp test.fout test.fh test.stderr_f \
                test.cout test.ch test.stderr_c
	-./wrapgen -i test.inp -f -o foo.out.f -h foo.f.h 2>foo.err.f
	-diff foo.out.f test.fout
	-sed 's/foo_f_h/test_fh/' <foo.f.h | diff - test.fh
	-diff foo.err.f test.stderr_f
	-./wrapgen -i test.inp -c -o foo.out.c -h foo.c.h 2>foo.err.c
	-diff foo.out.c test.cout
	-diff foo.c.h test.ch
	-diff foo.err.c test.stderr_c

testout: wrapgen
	-./wrapgen -i test.inp -f -o test.fout -h test.fh 2>test.stderr_f
	-./wrapgen -i test.inp -c -o test.cout -h test.ch 2>test.stderr_c

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

# Get all pieces into a shar file.
# N.B. Make sure we get all the pieces of fcpp.
wrapgen.shar: wrapgen01

wrapgen01: all makefile $(SOURCES) paper/wrapgen_paper.ps.gz.uu ../fcpp/fcpp01
	( set +e; \
	  makes=`cd $(CG); /bin/ls *.make`; \
	  includes='macros.h config.h'; \
	  defdir=`pwd`; \
	  (cd $(CG); cp $$makes $$defdir); \
	  cp ../fcpp/fcpp0? .; \
	  cp paper/wrapgen_paper.ps.gz.uu wrapgen_paper.ps.gz.uu; \
	  makekit -s 70k -n wrapgen -o MANIFEST \
	          $(SOURCES) wrapgen_paper.ps.gz.uu \
		  fcpp0? $$makes $$includes wrapgen.ps ; \
	  rm -f $$makes fcpp0? wrapgen_paper.ps.gz.uu )

# Get all pieces into a tar file.
wrapgen.tar: all makefile $(SOURCES) ../fcpp/fcpp.tar paper/wrapgen.ps
	( set +e; \
	  makes=`cd $(CG); /bin/ls *.make`; \
	  includes='macros.h config.h'; \
	  defdir=`pwd`; \
	  (cd $(CG); cp $$makes $$defdir); \
	  cp ../fcpp/fcpp.tar .; \
	  cp paper/wrapgen.ps wrapgen_paper.ps; \
	  tar cvLf wrapgen.tar \
	       $(SOURCES) fcpp.tar $$makes $$includes $(DOCS) wrapgen_paper.ps ; \
	  rm -f $$makes fcpp.shar)

.DEFAULT:
	co $<


