##1##########################################################################
#  The first section here is automatically generated. Do not change here; 
#  instead change ...smart/install/makebin.templ
#############################################################################

SRCDIR = /amd/beyla/d/smart.11.0/src
INSTALLBIN = /amd/beyla/d/smart.11.0/src/bin
INDEXED = /amd/beyla/d/smart.11.0/indexed_colls
TLIBDIR = /amd/beyla/d/smart.11.0/lib
TMPDIR = /tmp

# Flags normally set in top level makefile.  Make sure you want these
# defaults if you compile locally in this directory
PREFIX = /amd/beyla/d/smart.11.0/src
BIN = $(PREFIX)/bin
LIB = $(PREFIX)/lib
H   = -I$(SRCDIR)/h

# Static libraries with gcc
CC       = gcc
CFLAGS   = $H -L$(LIB) -g -Wall

# Static libraries with cc
#cc CC       = cc
#cc CFLAGS   = $H -L$(LIB) -g -Bstatic

# Other macros used in some or all makefiles
INSTALL = /bin/mv

#############################################################################
#  The second section starting here is directory-dependent instructions
##2##########################################################################
##3##########################################################################

# Order of LDLIBS is important.  Libraries on preceding lines must be
# loaded first.
# Order of LDLIBS is important.  Libraries on preceding lines must be
# loaded first.
LDLIBS = -lproc \
         -linter \
         -lindexing -lretrieve -lfeedback -levaluate \
         -lprint -lconvert -lobsolete\
         -lexp -lfile -lgeneral \
         -llproc -llinter -llindexing -llretrieve \
         -llconvert -llprint \
         -llfile \
         -lm

install all: $(BIN)/smart
	touch install all

$(BIN)/smart: smart.c version.c $(LIB)/lib*
	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) \
        -o smart smart.c version.c $(LDLIBS) 
	if [ -f $@ ]; then $(INSTALL) $@ $@.old; fi;
	$(INSTALL) smart $@

smart_malloc: 
	$(CC) -DDEBUG2  $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) \
        -o smart_malloc smart.c version.c /usr/lib/debug/malloc.o $(LDLIBS) 

##4##########################################################################
##5##########################################################################
#  All code below this line (except for automatically created dependencies)
#  is independent of this particular makefile, and should not be changed!
#############################################################################

#########################################################################
# Odds and ends                                                         #
#########################################################################
clean semiclean:
	/bin/rm -f *.o *.BAK install all *~ makefile.old

makelint:

lint: 
	for f in *.c ;\
                do echo $$f; $(LINT) -I../h $$f $(LIB)/llib* -lm;\
        done

bfly: makefile.bfly
	gnumake -k -f makefile.bfly "LDLIBS=$(LDLIBS) -lus"

makefile.bfly: makefile ../makebin.bfly.templ
	awk '/All code below this line/ {exit} {print}' \
                    < makefile > makefile.bfly.new
	awk '/START BFLY STUFF/, /END BFLY STUFF/ {print}' \
                    < makefile.bfly >> makefile.bfly.new
	cat ../makebin.bfly.templ >> makefile.bfly.new
	mv makefile.bfly makefile.bfly.old
	mv makefile.bfly.new makefile.bfly

#########################################################################
# Determining program dependencies                                      #
#########################################################################
depend:
	grep '^#[ ]*include' *.c \
		| sed -e 's?:[^"]*"\([^"]*\)".*?: \$H/\1?' \
			-e '/</d' \
			-e '/functions.h/d' \
		        -e 's/\.c/.o/' \
		        -e 's/\.y/.o/' \
		        -e 's/\.l/.o/' \
		> makedep
	echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
	echo '$$r makedep' >>eddep
	echo 'w' >>eddep
	cp makefile makefile.bak
	ed - makefile < eddep
	/bin/rm eddep makedep
	echo '# DEPENDENCIES MUST END AT END OF FILE' >> makefile
	echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> makefile
	echo '# see make depend above' >> makefile

# DO NOT DELETE THIS LINE -- make depend uses it


# DEPENDENCIES MUST END AT END OF FILE
# IF YOU PUT STUFF HERE IT WILL GO AWAY
# see make depend 
##6##########################################################################
