
#  "LOG", the circuit editing and simulation system, 5.10
#  "DigLOG", the digital simulator for LOG.
#  Copyright (C) 1985, 1990 David Gillespie.
#  Author's address: daveg@synaptics.edu

#  "AnaLOG", the analog simulator for LOG, 5.10
#  Copyright (C) 1985, 1990 John Lazzaro.
#  Author's address: lazzaro@cs.berkeley.edu; 

# 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 (any 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; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

## comment blocks in this Makefile point to possible changes that need
## to be made for different systems. Its a good idea to look over each
## block and make necessary changes before doing a "make install"

##
## (1) The "cd" problem
## ---------------------
##
## If you have aliased "cd" to some other command in your .cshrc,
## change the following definition to:
##
## CD = chdir
##
## or specify the complete command path.

CD = cd

LOGLIBDIR = `$(CD) ../../log/lib; pwd`
LIBDIR = `$(CD) ../../lib; pwd`

LOCINC = ../../psys/include
XINCLUDEDIR = .

BINDIR = ../../bin
LIBP2C = ../../psys/src/libp2c.a
LIBX11 = -lX11

##
## (2) Library additions
## ---------------------
##
## on some systems, -ldl must be added to the following line

OTHERLIBS= -lm


##
##  (3) Choosing your compiler
##  ---------------------------
##
## For Sun SPARC, HP series 300/400, Apple AU/X,  gcc is recommended, 
## preferably version 1.40 but most 2.XX and 1.XX work well.
##
## For DEC MIPS-based Ultrix, gcc 2.2.2 is recommended; hcc 2.2.3 is NOT,
##  because of a <varargs.h> bug.
##
## For HP series 700/800 (extra-cost) ANSI cc is recommended (see below for
##  options). HP's non-ANSI cc will not work, and gcc presently has some
##  problems with <varargs.h>. For version 8.05 (and earlier) of HP ANSI cc
##  you will need a patch tape from HP to fix compiler bugs; alternatively,
##  you can get around the problem by compile the file math.c 
##  with the gcc 2.XX compiler. 
##
## For IBM RS/6000, xlc is recommended (see below for options)
##
## For Linux, gcc 2.3.3 is recommended (see below for options)


CHIPMUNKCC = gcc

CC = $(CHIPMUNKCC) 

##
## (4) Adding appropriate flags
## -----------------------------
##
## for HP series 800 (using cc) add these flags to CFLAGS
## CFLAGS = -w -Aa -D_HPUX_SOURCE -DF_OK=0
##
## for IBM RS/6000 (using xlc) add these flags to CFLAGS
## CFLAGS =  -DBSD=0
##
## for AU/X, add this flags to CFLAGS
## CFLAGS =  -Daux
##
## for linux gcc 2.3.3 using xfree1.1 Xserver, add these flags to CFLAGS 
## 
##
## -DBSD -Dlinux -DF_OK=0 
##
## also add the flag
##
## -m486 
##
## if you are running on a 486-compatable CPU. For maximum speed, try the
## flags -fomit-frame-pointer -O6; however, the former flag will make it
## difficult for you to track down any bugs that occur while using the
## tools, and the latter will expose you to possible optimizer bugs. However,
## our alpha-testers have reported no problems using these two flags.
##


CFLAGS =  -DBSD -Dlinux -DF_OK=0 -m486 -fomit-frame-pointer -O6 -I$(LOCINC) -I$(XINCLUDEDIR) -DLOGLIB=\"$(LOGLIBDIR)\" -DF_OK=0

DIGOBJ = logsim.o logdig.o logsimasm.o logsimed.o diggates.o \
         loghier.o logsimh.o swap.o
ANAOBJ = ana/globals.o ana/nsolver.o ana/main.o ana/inter.o \
         ana/numbers.o ana/mmeter.o ana/iscope.o \
	 ana/vdiff.o ana/vswitch.o ana/stairs.o \
	 ana/idiff.o ana/iswitch1.o ana/iswitch2.o \
	 ana/resfloat.o ana/capfloat.o ana/nfet4.o ana/pfet4.o \
	 ana/nfet5.o ana/pfet5.o ana/pfet6.o ana/pspc1.o ana/nspc1.o\
	 ana/tc.o ana/moscap.o ana/ganglion.o ana/hres.o \
	 ana/npn1.o ana/pnp1.o ana/diode1.o ana/pwl.o ana/rtd.o

SIMOBJ = logcom.o $(DIGOBJ) $(ANAOBJ)
TOOLOBJ = $(SIMOBJ) lplot.o logspc.o logntk.o

main: log

##
## (5) Saving space during linking
## -------------------------------
##
##  The hard links made by the line:
##
##  -ln $(BINDIR)/diglog $(BINDIR)/analog
##
##  can be changed to make symbolic links; on some systems (Linux)
##  this can save lots of disk space, although caution is necessary
##  when using symbolic links, see the man page for "ln" for details.
##

install: makeana all
	cp log $(BINDIR)/diglog
	-rm $(BINDIR)/analog
	-ln -s $(BINDIR)/diglog $(BINDIR)/analog
	cp loged $(BINDIR)/loged
	cp fixfet7 $(BINDIR)/fixfet7

clean:
	-rm -f *.o ana/*.o log loged

all:  log  loged


makeana:
	($(CD) ana; make $(MFLAGS) grab all)



LOGOBJ = log.o $(TOOLOBJ) logstuff.o logdef.o

log: $(LOGOBJ) tooldir.o $(LIBP2C) makeana
	$(CC) $(CFLAGS) tooldir.o $(LOGOBJ) $(LIBP2C) $(LIBX11)  \
	$(OTHERLIBS) -o log


# The following, if it works on your system, will enable the "linklog"
# script to work.

#log: log.a tooldir.o $(LIBP2C)
#	$(CC) $(CFLAGS) tooldir.o log.a $(LIBP2C) -lX11 -lm -o log
#
#log.a: $(LOGOBJ)
#	ar r log.a $(LOGOBJ)



LOGEDOBJ = loged.o simdir.o $(SIMOBJ) logstuff.o

loged: $(LOGEDOBJ) simdir.o $(LIBP2C)
	$(CC) $(CFLAGS) $(LOGEDOBJ) $(LIBP2C) $(LIBX11) $(OTHERLIBS) -o loged


#loged: loged.a simdir.o $(LIBP2C)
#	$(CC) $(CFLAGS) loged.a $(LIBP2C) -lX11 -lm -o loged
#
#loged.a: $(LOGEDOBJ)
#	ar r loged.a $(LOGEDOBJ)



tooldir.o: tooldir.c

tooldir.c: $(TOOLOBJ)
	chmod +x munch
	./munch 'Log_[a-zA-Z0-9_]*' $(TOOLOBJ) > tooldir.c



simdir.o: simdir.c

simdir.c: $(SIMOBJ)
	chmod +x munch
	./munch 'Log_[0-9]*_proc' $(SIMOBJ) > simdir.c

 
## The following part of the Makefile is for making a tar file of the
## original parts of the log distribution. Most users have no need for it.


VERSION = 5.10

dist: distrib
distrib:
	-rm -rf dist
	mkdir dist
	mkdir dist/src
	mkdir dist/src/ana
	cp log.cnf log.gate COPYING LNOTES dist/src
	cp munch* fixfet7 dist/src
	sed -e "s;5.10;$(VERSION);" Makefile > dist/src/Makefile
	sed -e "s;5.10;$(VERSION);" ana/Makefile > dist/src/ana/Makefile
	sed -e "s;5.10;$(VERSION);" dist.INSTALL > dist/README
	cp *.c *.h dist/src
	sed -e "s;5.10;$(VERSION);"  logdef.h > dist/src/logdef.h
	cp ana/*.c ana/*.h dist/src/ana
	cp -r $(LOGLIBDIR) dist/lib
	echo >dist/lib/stupid~
	-rm dist/lib/*~ dist/lib/*.ogte
	sed -e "s;5.10;$(VERSION);" ../lib/log.doc > dist/lib/log.doc


tardist:
	-rm -rf logdist
	mkdir logdist
	mv dist logdist/log
	tar cvf log.tar -C logdist log
	mv logdist/log dist
	-rm -f log.tar.Z
	compress log.tar
	
create: dist tardist 







