#   This file, ./AMIGA/SMakefile, is NOT part of the standard distribution
#   of the Stanford GraphBase.

#   The following copyright notice extends to this file only, not to any
#   part of the standard distribution of the Stanford GraphBase (which is
#   copyright (c) 1993 by Stanford University).

#   Copyright (c) 1994 Andreas Scherer

#   Permission is granted to make and distribute verbatim copies of this
#   document provided that the copyright notice and this permission notice
#   are preserved on all copies.

#   Permission is granted to copy and distribute modified versions of this
#   document under the conditions for verbatim copying, provided that the
#   entire resulting derived work is distributed under the terms of a
#   permission notice identical to this one.

#   This file is a Makefile for installing the Stanford GraphBase on the
#   Commodore AMIGA using SAS/C++ 6.56 with SAS/SMake 6.55.

#   Be sure that CWEB version 3.0 or greater is installed before proceeding!

#   Change SGBDIR to the directory where all GraphBase files will go:
SGBDIR = Local:sgb

#   Change DATADIR to the directory where GraphBase data files will go:
DATADIR = $(SGBDIR)/data

#   Change INCLUDEDIR to the directory where GraphBase header files will go:
INCLUDEDIR = $(SGBDIR)/include

#   Change LIBDIR to the directory where GraphBase library routines will go:
LIBDIR = $(SGBDIR)/lib

#   Change BINDIR to the directory where installdemos will put demo programs:
BINDIR = $(SGBDIR)/demos

#   Change CWEBINPUTS to the directory where CWEB include files will go:
CWEBINPUTS = $(SGBDIR)/cwebinputs

#   Uncomment the next line if your C uses <string.h> but not <strings.h>:
SYS = DEFINE=SYSV

#   If you prefer optimization to debugging, change DEBUG=full to OPTIMIZE.
#   Adapt CPU and MATH to your system's hardware, e.g., CPU=68030 and
#   MATH=68882 in connection with MATHLIB=LIB:scm881.lib:
CFLAGS = DEBUG=full INCLUDEDIR=$(SGBDIR) INCLUDEDIR=$(INCLUDEDIR) $(SYS) \
	CPU=any MATH=standard IGNORE=85+93+100+132+154+161 NOICONS
MATHLIB = LIB:scm.lib

MAKE=SMake

########## You shouldn't have to change anything after this point ##########
# (Well, this is NOT true, when you do this for the first time.
# SMake is totally different compared to UNIX make, especially most
# default productions and rules are missing, so the implicit dependencies
# have to be resolved by hand.  Also the compilation and linkage stages are
# different compared to those of UNIX cc.  Maybe it would be a good idea to
# use GNU cc and GNU make?)

LIBS = LIB $(LIBDIR)/libgb.lib $(MATHLIB)

.SUFFIXES: .dvi .tex .w

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

.tex.dvi:
	tex &plain "\language=\USenglish \input " $*.tex

.w.c:
	ctangle $*.w

.w.tex:
	cweave $*.w

.w.o:
	$(MAKE) $*.c
	$(MAKE) $*.o

.w:
	$(MAKE) $*.c
	$(MAKE) $*

.w.dvi:
	$(MAKE) $*.tex
	$(MAKE) $*.dvi

PATCH = README.AMIGA SMakefile

DATAFILES = anna.dat david.dat econ.dat games.dat homer.dat huck.dat \
        jean.dat lisa.dat miles.dat roget.dat words.dat
KERNELFILES = gb_flip.w gb_graph.w gb_io.w gb_sort.w
KERNELOBJECTS = gb_flip.o gb_graph.o gb_io.o gb_sort.o
KERNELHEADERS = gb_flip.h gb_graph.h gb_io.h gb_sort.h
GENERATORFILES = gb_basic.w gb_books.w gb_econ.w gb_games.w gb_gates.w \
        gb_lisa.w gb_miles.w gb_plane.w gb_raman.w gb_rand.w gb_roget.w \
        gb_words.w
GENERATOROBJECTS = gb_basic.o gb_books.o gb_econ.o gb_games.o gb_gates.o \
	gb_lisa.o gb_miles.o gb_plane.o gb_raman.o gb_rand.o gb_roget.o \
	gb_words.o
GENERATORHEADERS = gb_basic.h gb_books.h gb_econ.h gb_games.h gb_gates.h \
	gb_lisa.h gb_miles.h gb_plane.h gb_raman.h gb_rand.h gb_roget.h \
	gb_words.h
DEMOFILES = assign_lisa.w book_components.w econ_order.w football.w \
        girth.w ladders.w miles_span.w multiply.w queen.w roget_components.w \
        take_risc.w word_components.w
DEMOPROGS = assign_lisa book_components econ_order football \
	girth ladders miles_span multiply queen roget_components \
	take_risc word_components
MISCWEBS = boilerplate.w gb_dijk.w gb_save.w gb_types.w test_sample.w
CHANGEFILES = queen_wrap.ch word_giant.ch
MISCFILES = Makefile README abstract.plaintex cities.texmap blank.w \
        sample.correct test.correct test.dat +The+Stanford+GraphBase+
ALL = $(DATAFILES) $(KERNELFILES) $(KERNELOBJECTS) \
	$(GENERATORFILES) $(GENERATOROBJECTS) \
	$(DEMOFILES) $(DEMOPROGS) \
        $(MISCWEBS) $(CHANGEFILES) $(MISCFILES)

OBJS = $(KERNELOBJECTS) $(GENERATOROBJECTS) gb_dijk.o gb_save.o
HEADERS = $(KERNELHEADERS) $(GENERATORHEADERS) gb_dijk.h gb_save.h
DEMOS = $(DEMOPROGS)

help:
	@echo "First 'make tests';"
	@echo "then 'make install';"
	@echo "then (optionally) 'make installdemos';"
	@echo "then (optionally) 'make clean'."

lib: libgb.lib

libgb.lib: $(OBJS)
	#delete certified force
	oml libgb.lib R $(OBJS)

gb_graph.o: gb_graph.c
gb_flip.o: gb_flip.c
gb_sort.o: gb_sort.c
gb_graph.dvi: gb_graph.tex
gb_flip.dvi: gb_flip.tex
gb_sort.dvi: gb_sort.tex

gb_basic.o: gb_basic.c
gb_books.o: gb_books.c
gb_econ.o: gb_econ.c
gb_games.o: gb_games.c
gb_gates.o: gb_gates.c
gb_lisa.o: gb_lisa.c
gb_miles.o: gb_miles.c
gb_plane.o: gb_plane.c
gb_raman.o: gb_raman.c
gb_rand.o: gb_rand.c
gb_roget.o: gb_roget.c
gb_words.o: gb_words.c
gb_basic.dvi: gb_basic.tex
gb_books.dvi: gb_books.tex
gb_econ.dvi: gb_econ.tex
gb_games.dvi: gb_games.tex
gb_gates.dvi: gb_gates.tex
gb_lisa.dvi: gb_lisa.tex
gb_miles.dvi: gb_miles.tex
gb_plane.dvi: gb_plane.tex
gb_raman.dvi: gb_raman.tex
gb_rand.dvi: gb_rand.tex
gb_roget.dvi: gb_roget.tex
gb_words.dvi: gb_words.tex

assign_lisa: assign_lisa.o
	$(CC) $(CFLAGS) LINK FROM $? TO $@ $(LIBS)
assign_lisa.o: assign_lisa.c
assign_lisa.dvi: assign_lisa.tex
book_components: book_components.o
	$(CC) $(CFLAGS) LINK FROM $? TO $@ $(LIBS)
book_components.o: book_components.c
book_components.dvi: book_components.tex
econ_order: econ_order.o
	$(CC) $(CFLAGS) LINK FROM $? TO $@ $(LIBS)
econ_order.o: econ_order.c
	$(CC) $(CFLAGS) DATA=far $?
econ_order.dvi: econ_order.tex
football: football.o
	$(CC) $(CFLAGS) LINK FROM $? TO $@ $(LIBS)
football.o: football.c
football.dvi: football.tex
girth: girth.o
	$(CC) $(CFLAGS) LINK FROM $? TO $@ $(LIBS)
girth.o: girth.c
girth.dvi: girth.tex
ladders: ladders.o
	$(CC) $(CFLAGS) LINK FROM $? TO $@ $(LIBS)
ladders.o: ladders.c
ladders.dvi: ladders.tex
miles_span: miles_span.o
	$(CC) $(CFLAGS) LINK FROM $? TO $@ $(LIBS)
miles_span.o: miles_span.c
miles_span.dvi: miles_span.tex
multiply: multiply.o
	$(CC) $(CFLAGS) LINK FROM $? TO $@ $(LIBS)
multiply.o: multiply.c
multiply.dvi: multiply.tex
queen: queen.o
	$(CC) $(CFLAGS) LINK FROM $? TO $@ $(LIBS)
queen.o: queen.c
queen.dvi: queen.tex
roget_components: roget_components.o
	$(CC) $(CFLAGS) LINK FROM $? TO $@ $(LIBS)
roget_components.o: roget_components.c
roget_components.dvi: roget_components.tex
take_risc: take_risc.o
	$(CC) $(CFLAGS) LINK FROM $? TO $@ $(LIBS)
take_risc.o: take_risc.c
take_risc.dvi: take_risc.tex
word_components: word_components.o
	$(CC) $(CFLAGS) LINK FROM $? TO $@ $(LIBS)
word_components.o: word_components.c
word_components.dvi: word_components.tex

gb_dijk.o: gb_dijk.c
gb_save.o: gb_save.c
gb_types.o: gb_types.c
gb_dijk.dvi: gb_dijk.tex
gb_save.dvi: gb_save.tex
gb_types.dvi: gb_types.tex

gb_io.o: gb_io.c
	$(CC) $(CFLAGS) DEFINE=DATA_DIRECTORY="$(DATADIR)/" gb_io.c
gb_io.dvi: gb_io.tex

test_io: gb_io.o
	$(CC) $(CFLAGS) LINK FROM test_io.c gb_io.o TO test_io

test_graph: gb_graph.o
	$(CC) $(CFLAGS) LINK FROM test_graph.c gb_graph.o TO test_graph

test_flip: gb_flip.o
	$(CC) $(CFLAGS) LINK FROM test_flip.c gb_flip.o TO test_flip

test_sample: test_sample.o
	$(CC) $(CFLAGS) LINK FROM $? TO $@ LIB libgb.lib $(MATHLIB)
test_sample.o: test_sample.c
test_sample.dvi: test_sample.tex

tests: test_io test_graph test_flip
	test_io
	test_graph
	test_flip
	$(MAKE) gb_sort.o
	$(MAKE) lib
	$(MAKE) test_sample
	- test_sample > sample.out
	diff test.gb test.correct
	diff sample.out sample.correct
	delete test.gb sample.out test_io test_graph test_flip test_sample
	@echo "Congratulations --- the tests have all been passed."
	# touch certified

install: lib
	#if test ! -r certified; then echo "Please run 'make tests' first!"; fi
	#test -r certified
	$(MAKE) installdata
	- makedir $(LIBDIR)
	- copy libgb.lib $(LIBDIR)
	- makedir $(CWEBINPUTS)
	- copy boilerplate.w gb_types.w $(CWEBINPUTS)
	- makedir $(INCLUDEDIR)
	- copy $(HEADERS) Makefile $(INCLUDEDIR)

installdata: $(DATAFILES)
	- makedir $(SGBDIR)
	- makedir $(DATADIR)
	- copy $(DATAFILES) $(DATADIR)

installdemos: $(DEMOS)
	- makedir $(BINDIR)
	- copy $(DEMOPROGS) $(BINDIR)
	- delete $(DEMOPROGS)

uninstalldemos:
	- delete $(BINDIR)/$(DEMOPROGS) force

doc:
	tex &plain "\language=\USenglish \input " abstract.plaintex

clean:
	- delete \#?.(o|c|h|tex|log|dvi|toc|idx|scn|bak|lnk) libgb.lib certified

veryclean: clean
	- delete $(DEMOPROGS) $(PATCH) force


syntax highlighted by Code2HTML, v. 0.9.1