# Generated automatically from Makefile.in by configure.
# Master Makefile for GNU Smalltalk
# Generated automatically from Makefile.in by configure.
# Copyright (C) 1994, 1995 Free Software Foundation, Inc.
# Written by Steve Byrne

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

# $Revision: 1.11 $

SHELL = /bin/sh

#### Start of system configuration section. ####

srcdir = .

PROGS = gst

# Last Validated: 9/10/95
MAINTAINER = 'bug-gnu-smalltalk@gnu.ai.mit.edu'

COMPILE_TYPE = # Normal case
#COMPILE_TYPE = -DOPTIMIZE
#COMPILE_TYPE = -DPROFILE

# If you use gcc, you should either run the fixincludes script that
# comes with it or else use gcc with the -traditional option.  Otherwise
# ioctl calls will be compiled incorrectly on some systems.
CC = cc
# Older makes don't set $(MAKE), so we set it for them.


BISON = bison

# Use cp if you don't have install.
INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644
AR = ar
RANLIB = ranlib
ALLOCA = 

DEFS = -DHAVE_CONFIG_H
LIBS =  -lm $(USER_LIBS)

# This controls the distribution version (not completely yet)
VERSION= 1.2.alpha5

# Other version related definitions (mostly for DOS) 
ST_MAJOR_VERSION = 1
ST_MINOR_VERSION = 2
ST_EDIT_VERSION  = 5
ST_EDIT_PREFIX   = alpha

# other definitions
RM=rm -f
MAKE_LIBRARY_COMMAND=cd lib; $(MAKE) all
COMPLETE_MAKE=

# optimization flag -- may become host dependent
OPT_FLAG = -O
CDEBUG = -g
USER_OBJECTS = @USER_OBJECTS@

#INCLUDES = @includeopt@
CPPFLAGS = 
CFLAGS =  # $(INCLUDES)
LDPATH =  
LDFLAGS = 
GCC_EXTRA_FLAGS = -Wimplicit -Wreturn-type -Wunused 

prefix = /usr/local
exec_prefix = ${prefix}

# Where to install the executables.
bindir = $(exec_prefix)/bin

# Where to put the system-wide image file
libdir = $(prefix)/lib
smlibdir = $(libdir)/smalltalk
stdir = $(prefix)/smalltalk

## Where to put the manual pages.
#mandir = $(prefix)/man

# Where to put the info pages
infodir = $(prefix)/info

#### End of system configuration section. ####

MDEFINES = bindir='$(bindir)' libdir='$(libdir)' mandir='$(mandir)' \
       INSTALL='$(INSTALL)' INSTALLDATA='$(INSTALLDATA)' \
       LIBS='$(LIBS)' LDPATH='$(LDPATH)' MAKE='$(MAKE)' \
       AR='$(AR)' RANLIB='$(RANLIB)' \
       BISON='$(BISON)' CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' \
       CC='$(CC)' INCLUDES='$(INCLUDES)' DEFS='$(DEFS)' CDEBUG='$(CDEBUG)'

MAIN_FILES = main.c cfuncs.c 
SMALLTALK_KERNEL = Array.st ArrayColl.st Association.st Autoload.st \
    Bag.st Behavior.st BlkContext.st Boolean.st Browser.st \
    ByteArray.st ByteMemory.st CFuncs.st CObject.st CStruct.st CType.st \
    Character.st Class.st ClassDescr.st Collection.st CompildMeth.st \
    DLD.st Date.st Delay.st Dictionary.st False.st FileSegment.st \
    FileStream.st Float.st Fraction.st IOCtl.st IdentDict.st \
    Integer.st Interval.st Link.st LinkedList.st LookupKey.st Magnitude.st \
    MappedColl.st Memory.st Message.st Metaclass.st MthContext.st \
    MethodInfo.st Number.st Object.st OrderColl.st \
    PosStream.st Process.st ProcSched.st Random.st \
    ReadStream.st RWStream.st Semaphore.st SeqCollect.st \
    Set.st SharedQueue.st SortCollect.st Stream.st String.st SymLink.st \
    Symbol.st SysDict.st Time.st TokenStream.st True.st \
    UndefObject.st UnixStream.st WordMemory.st WriteStream.st \
    builtins.st initialize.st changes.st 
SMALLTALK = $(SMALLTALK_KERNEL) \
    BypassStream.st \
    CDeclNode.st CExpressionNode.st \
    CPP.st CPStrConc.st CPStrUnq.st CParseType.st \
    CSymbol.st CSymbolTable.st CTok.st CToken.st CTreeBuilder.st \
    CTypeParser.st \
    CompilerTokens.st Debugger.st \
    ExpansionStream.st ExpansionStreamStack.st \
    Host.st \
    IndentedStream.st \
    LineStream.st LineToTokenStream.st LineTokenStream.st \
    ParseNodes.st Parser.st Point.st \
    PushBackStream.st \
    RParseNodes.st Rectangle.st \
    StreamStack.st Token.st Variable.st fileout-ps.st t.st tdl.st \
    testCPT.st tstdl2.st large-expr.st eval.st dldtst.st testXParse.st \
    tok.st tpars.st mt.st mt2.st tstCPT.st dev-t.st cpt.st \
    int.st it.st testcompile.st \
    STCompLit.st STCompiler.st STSymTable.st STVarDefn.st


EXTRA_FILES = bison.el browse.el hilit-st.el st.el install-sh buildgst.bat \
    st-changelog.el

DISTFILES = COPYING ChangeLog INSTALL Makefile.in README README-1.2 configure \
    Makefile.defs.in Makefile.rules createMake \
    README-$(VERSION) README.DOS \
    config.h.in stamp-h.in configure.in getcppsyms.c mkinstalldirs acconfig.h \
    $(SMALLTALK) \
    $(MAIN_FILES) \
    $(EXTRA_FILES)

CONFIG_INPUT = lib/Makefile.in \
    info/gst.txi.in \
    Makefile.defs.in Makefile.rules \
    blox/Makefile.body \
    stix/Makefile.body tcp/Makefile.body test/Makefile.body  \
    cxtnsn/Makefile.body examples/Makefile.body contrib/Makefile.body \
    info/Makefile.body


# Subdirectories to run make in for the primary targets.
SUBDIRS = lib stix blox info examples contrib cxtnsn test tcp

# Only make TAGS/tags files in these directories, in this order
###TSUBDIRS= src lib

OBJECTS = main.o cfuncs.o

SOURCES = main.c cfuncs.c

# keeping this to ensure we continue to provide for user libs
# LIBS =  $(DEFAULT_LIBRARIES) $(USER_LIBS) $(READLINELIB) $(DLDLIB)




.c.o: 
	$(CC) -c $(CPPFLAGS) $(DEFS) -I$(srcdir) -I$(srcdir)/lib $(GCC_EXTRA_FLAGS) $(CFLAGS) $(CDEBUG) $<

all: $(PROGS)

# close but not yet
#	for dir in $(SUBDIRS); do \
#	  echo making $@ in $$dir ; \
#	  (cd $$dir; $(MAKE) $(TARGET) CFLAGS=$(CFLAGS) CDEBUG=$(CDEBUG) $@) ; \
#	done
     
gst: $(OBJECTS) libgst.a
# some lame systems (and not-so-lame, like Linux), don't deal with replacing
# an executable while it's in use (at least Solaris has that going for it!)
	$(RM) gst
	$(CC) $(LDFLAGS) $(LDPATH) $(BINDING) -o $@ $(CFLAGS) $(CDEBUG) \
		$(OBJECTS) lib/libgst.a $(LIBS)
	$(COMPLETE_MAKE)

# A hack to force this directory to be reevaluated.
libgst.a:
	$(MAKE_LIBRARY_COMMAND)

info_file:
	cd info; make all

$(OBJECTS): config.h


optimize:
	echo $(CFLAGS)
	$(MAKE) CFLAGS="-DOPTIMIZE $(OPT_FLAG) $(CFLAGS)" CDEBUG= TARGET=optimize

clean::
	$(RM) *.o core
	$(RM) gst gst.im
#	$(RM) junk.c xmakefile

installdirs:
	$(SHELL) $(srcdir)/mkinstalldirs $(bindir) $(smlibdir) $(infodir) \
		 $(stdir)

install:: installdirs all 
	$(INSTALL_PROGRAM) gst $(bindir)/$(binprefix)gst
	

#install uninstall TAGS clean mostlyclean distclean realclean::
install uninstall clean mostlyclean distclean realclean::
	for dir in $(SUBDIRS); do \
	  echo making $@ in $$dir ; \
	  (cd $$dir; $(MAKE) $@) ; \
	done


# !!! figure out how to make this work
##if defined(SUNOS40) && defined(OPTIMIZE)
#mstinterp.o: mstinterp.c
#	$(CC) -O2 -DOPTIMIZE $(EXTRA_PACKAGES) -c mstinterp.c
##endif

# !!! Clean these up in the future 


#
# Install the files into the proper place
#

#install: all
#	echo "install not ready"
#	if test ! -d KERNEL_PATH ; then      \
#	    mkdir -p KERNEL_PATH ;           \
#	fi
#	cp *.st KERNEL_PATH
#	(cd KERNEL_PATH; chmod +r *.st)
#	if test ! -d IMAGE_PATH ; then      \
#	    mkdir -p IMAGE_PATH ;           \
#	fi
#	(x=`pwd`; cd IMAGE_PATH; $$x/gst -Vi)




#configure: configure.in config.h.in Makefile.in
#	autoconf
#
#config.h.in: acconfig.h
#	autoheader
##ensure that this is marked as changed.
#	touch config.h.in


regress:
	(cd ./test; run-regression-tests)

dist: ${srcdir}/configure info_file
	echo $${TARGET_BASE_NAME:-smalltalk-$(VERSION)} > .fname
	rm -rf `cat .fname`
	mkdir `cat .fname`
	ln $(DISTFILES) `cat .fname`
#	# Ensure that the configuration stuff goes out for the time being
#	mkdir `cat .fname`/config
#	-ln $(srcdir)/config/* `cat .fname`/config
	for dir in $(SUBDIRS); do \
	    mkdir `cat .fname`/$$dir; \
	    cd $$dir; \
	    $(MAKE) dist_target=../`cat ../.fname`/$$dir $@; \
	    cd ..; \
	done
	tar cvzf `cat .fname`.tar.gz `cat .fname`
	rm -rf `cat .fname` .fname

dist_dos: ${srcdir}/configure info_file
	echo $(ST_MAJOR_VERSION)$(ST_MINOR_VERSION)`echo $(ST_EDIT_PREFIX)|sed -e 's/\(.\).*/\1/'`$(ST_EDIT_VERSION) > .dos_vers_stamp
	echo gst`cat .dos_vers_stamp`  > .dos_fname
	$(MAKE) TARGET_BASE_NAME=`cat .dos_fname` dist
# note that removal of the test directory below is temporary	
### still need to hack the config, make the texinfo, etc
	rm -rf dos-workdir
	mkdir dos-workdir
	(   \
	    STAMP=`cat .dos_vers_stamp` FNAME=`cat .dos_fname` ; \
	    cd dos-workdir ; \
		tar xzf ../$$FNAME.tar.gz ; \
		rm -f ../$$FNAME.tar.gz ; \
		cd $$FNAME ; \
		    rm -f config.status dos-config.cache ; \
		    KERNEL_PATH=/$$FNAME ${srcdir}/configure --cache-file=dos-config.cache --target=dos  ; \
		    rm -rf stix config test ; \
		    rm -f config.status dos-config.cache ; \
		    rm -f install-sh stamp-h ; \
		    mv  README-$(VERSION) RDME$$STAMP.DOC ; \
                    find . -name "*.in" -exec rm {} ";" ; \
                    echo "fixing line termination" ; \
                    for file in `find . -type f -print` ; \
		    do \
		        sed -e 's/$$//' < $$file > $$file.tmp ; \
			mv $$file.tmp $$file ; \
		    done ; \
                    mv lib/gst.tab.c lib/gst_tab.c ; \
                    mv lib/gst.tab.h lib/gst_tab.h ; \
		cd .. ; \
		tar cvzf ../$$FNAME.tgz $$FNAME ; \
	    )
	rm -rf dos-workdir	
	rm -f .dos_fname .dos_vers_stamp

# preserved just in case...
#		    cat config.h | \
#		    sed -e '/HAVE_ALLOCA_H/s/^.*$$/#undef HAVE_ALLOCA_H/' > config.tmpfile ; \
#		    mv config.tmpfile config.h ; \
#

dist_nt: ${srcdir}/configure info_file
	echo smalltalk-nt-$(VERSION) > .nt_fname
	$(MAKE) TARGET_BASE_NAME=`cat .nt_fname` dist
# note that removal of the test directory below is temporary	
### still need to hack the config, make the texinfo, etc
	rm -rf nt-workdir
	mkdir nt-workdir
	(   \
	    FNAME=`cat .nt_fname` ; \
	    cd nt-workdir ; \
		tar xzf ../$$FNAME.tar.gz ; \
		rm -f ../$$FNAME.tar.gz ; \
		cd $$FNAME ; \
		    rm -f config.status nt-config.cache ; \
		    KERNEL_PATH=/$$FNAME ${srcdir}/configure --cache-file=nt-config.cache --target=winnt  ; \
		    rm -rf stix test ; \
		    rm -f config.status nt-config.cache ; \
		    rm -f install-sh stamp-h ; \
                    echo "fixing line termination" ; \
                    for file in `find . -type f -print` ; \
		    do \
		        sed -e 's/$$//' < $$file > $$file.tmp ; \
			mv $$file.tmp $$file ; \
		    done ; \
                    mv lib/gst.tab.c lib/gst_tab.c ; \
                    mv lib/gst.tab.h lib/gst_tab.h ; \
		    (cd ../../nt-makes; tar cvf - .) | tar xvf - ; \
		cd .. ; \
		tar cvzf ../$$FNAME.tar.gz $$FNAME ; \
	    )
	rm -rf nt-workdir	
	rm -f .nt_fname

# preserved just in case...
#		    cat config.h | \
#		    sed -e '/HAVE_ALLOCA_H/s/^.*$$/#undef HAVE_ALLOCA_H/' > config.tmpfile ; \
#		    mv config.tmpfile config.h ; \
#


dist_os2: ${srcdir}/configure info_file
	echo "OS/2 distribution not supported yet"


dist_missing:
	@test -f .ok-nodist-files || touch .ok-nodist-files
	@rlog -R RCS/* | sed -e 's;RCS/\(.*\),v;\1;' | sort > .rcs-files
	@for file in $(DISTFILES); do \
	    echo $$file  ; \
	done | \
	sort | comm -23 .rcs-files - | \
	    comm -23 - .ok-nodist-files
	
dist_missingr:
	for dir in . $(SUBDIRS); do \
	    (cd $$dir; \
	    $(MAKE) dist_missing ); \
	done

dist_ci:
	@echo -n "Version name? "; read version ; echo "Release-$$version" > .ci-version
	-ci -l -mVersioning -N`cat .ci-version` RCS/*
	-for dir in $(SUBDIRS); do \
	    cd $$dir; \
	    $(MAKE) ci_version=`cat ../.ci-version` ci_r; \
	    cd ..; \
	done
	rm -f .ci-version

ci_r:
	@echo -n "RCS Version tag? "; read version ; echo "$$version" > .ci-version
	-ci -l -mVersioning -N`cat .ci-version` RCS/*
	-for dir in $(SUBDIRS); do \
	    cd $$dir; \
	    $(MAKE) ci_version=`cat ../.ci-version` ci_r; \
	    cd ..; \
	done
	rm -f .ci-version

echo_subdirs:
	@echo $(SUBDIRS) > gst-subdirs

#----------- THE BARRIER ---------------
# Stuff below has not be integrated into the makefile yet

profile:
	make CFLAGS='$(CFLAGS) -pg -Dprofiling'


#tags:
#	@for dir in $(TSUBDIRS); do echo making $@ in $$dir; cd $$dir; $(MAKE) $(MDEFINES) $@ || exit 1; cd ..; done
#	@echo making $@ in .
#	@ctags `for i in \`$(MAKE) SUBDIRS="$(TSUBDIRS)" ls\` ; do echo $(srcdir)/$$i ; done`
.PHONY: tags

#TAGS:
#	@for dir in $(TSUBDIRS); do echo making $@ in $$dir; cd $$dir; $(MAKE) $(MDEFINES) $@ || exit 1; cd ..; done
#	@echo making $@ in .
#	@etags `for i in \`$(MAKE) SUBDIRS="$(TSUBDIRS)" ls\` ; do echo $(srcdir)/$$i ; done`

ls:
###	@echo $(DISTFILES)
###	@for dir in $(SUBDIRS); do \
###		for i in `cd $$dir; $(MAKE) $(MDEFINES) $@` ; do \
###			echo $$dir/$$i ; \
###		done ; \
###	done
.PHONY: ls

#clean:
#	@for dir in $(SUBDIRS); do echo making $@ in $$dir; cd $$dir; $(MAKE) $(MDEFINES) $@ || exit 1; cd ..; done
#.PHONY: clean

distclean::
	@for dir in $(SUBDIRS); do echo making $@ in $$dir; cd $$dir; $(MAKE) $(MDEFINES) $@ || exit 1; cd ..; done
	$(RM) Makefile config.status tags TAGS config.log config.cache
.PHONY: distclean

realclean::
	@for dir in $(SUBDIRS); do echo making $@ in $$dir; cd $$dir; $(MAKE) $(MDEFINES) $@ || exit 1; cd ..; done
	$(RM) Makefile config.status tags TAGS
.PHONY: realclean


# Tell versions [3.59, 3.63) of GNU make not to export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
