1: #Makefile for Gforth
2:
3: #Copyright (C) 1995, 1996 Free Software Foundation, Inc.
4:
5: #This file is part of Gforth.
6:
7: #Gforth is free software; you can redistribute it and/or
8: #modify it under the terms of the GNU General Public License
9: #as published by the Free Software Foundation; either version 2
10: #of the License, or (at your option) any later version.
11:
12: #This program is distributed in the hope that it will be useful,
13: #but WITHOUT ANY WARRANTY; without even the implied warranty of
14: #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.#See the
15: #GNU General Public License for more details.
16:
17: #You should have received a copy of the GNU General Public License
18: #along with this program; if not, write to the Free Software
19: #Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20:
21: # To change the values of `make' variables: instead of editing Makefiles,
22: # (1) if the variable is set in `config.status', edit `config.status'
23: # (which will cause the Makefiles to be regenerated when you run `make');
24: # (2) otherwise, pass the desired values on the `make' command line.
25:
26: #To do:
27: #use $(srcdir) to make compilation in a non-srcdir possible
28:
29: VERSION =0.2.0#gforth version
30: SHELL = /bin/sh
31: RM = rm
32: CP = cp
33: INSTALL = @INSTALL@
34: INSTALL_PROGRAM = @INSTALL_PROGRAM@
35: INSTALL_DATA = @INSTALL_DATA@
36: INSTALL_DIR = $(srcdir)/install-sh -d
37: LN_S = @LN_S@
38: GCC = @CC@
39: CC = $(GCC)
40: FORTHPATH = $(libdir)/gforth/site-forth:$(datadir)/gforth/site-forth:$(libdir)/gforth/$(VERSION):$(datadir)/gforth/$(VERSION):.
41: FORTH = ./gforth -p $(FORTHPATH):$(srcdir)
42: FORTHK = $(FORTH) -p .:$(srcdir) -i ./kernel.fi
43: FORTHP = ./gforth -i ./kernel.fi
44: STRIP = strip
45: TEXI2DVI = texi2dvi
46: DVI2PS = dvips -D300
47: #you can get texi2html from http://asis01.cern.ch/infohtml/texi2html.html
48: TEXI2HTML = texi2html
49: MAKEINFO = makeinfo
50: XCFLAGS = @CFLAGS@
51: XDEFINES = @DEFS@
52: SWITCHES = $(XCFLAGS) $(XDEFINES) #-DNDEBUG #turn off assertions
53: ENGINE_FLAGS = @ENGINE_FLAGS@ -fno-defer-pop -fcaller-saves
54: DEBUGFLAG = @DEBUGFLAG@
55: CFLAGS = $(DEBUGFLAG) -I. -I$(srcdir) -O4 -Wall $(SWITCHES) -DDEFAULTPATH=\"$(FORTHPATH)\"
56:
57: #John Wavrik should use -Xlinker -N to get a writable text (executable)
58: XLDFLAGS = @LDFLAGS@
59: GCCLDFLAGS = @GCCLDFLAGS@
60: LDFLAGS = $(DEBUGFLAG) $(XLDFLAGS) $(GCCLDFLAGS)
61: LDLIBS = @LIBS@
62:
63: VPATH = @srcdir@
64: prefix = @prefix@
65: exec_prefix = @exec_prefix@
66: srcdir = @srcdir@
67: bindir = $(exec_prefix)/bin
68: #read-only architecture-independent files
69: datadir = $(prefix)/share
70: #read-only architecture-dependent non-ascii files
71: libdir = $(prefix)/lib
72: infodir = $(prefix)/info
73: mandir = $(prefix)/man
74: man1dir= $(mandir)/man1
75: man1ext= .1
76: #older emacses have their site-lisp in $(libdir)/emacs/
77: emacssitelispdir=$(datadir)/emacs/site-lisp
78:
79: INCLUDES = forth.h threading.h io.h
80:
81: KERN_SRC = \
82: add.fs \
83: aliases.fs \
84: cross.fs \
85: errore.fs \
86: extend.fs \
87: kernel.fs \
88: main.fs \
89: search-order.fs \
90: special.fs \
91: tools.fs \
92: toolsext.fs \
93: vars.fs
94:
95: GFORTH_FI_SRC = \
96: assert.fs \
97: blockedit.fb \
98: blocks.fs \
99: bufio.fs \
100: debug.fs \
101: debugging.fs \
102: dumpimage.fs \
103: environ.fs \
104: float.fs \
105: glocals.fs \
106: hash.fs \
107: history.fs \
108: intcomp.fs \
109: look.fs \
110: search-order.fs \
111: see.fs \
112: source.fs \
113: startup.fs \
114: struct.fs \
115: stuff.fs \
116: tasker.fs \
117: termsize.fs \
118: vt100.fs \
119: vt100key.fs \
120: wordinfo.fs
121:
122: FORTH_SRC = $(KERN_SRC) $(GFORTH_FI_SRC) \
123: ansi.fs answords.fs \
124: checkans.fs \
125: code.fs colorize.fs \
126: doskey.fs ds2texi.fs \
127: etags.fs filedump.fs \
128: glosgen.fs gray.fs \
129: makedoc.fs \
130: mach16b.fs mach16l.fs mach32b.fs mach32l.fs mach64b.fs mach64l.fs \
131: more.fs other.fs prims2x.fs random.fs \
132: sieve.fs \
133: site-init.fs \
134: tt.fs sokoban.fs \
135: wordsets.fs \
136: tester.fs coretest.fs postponetest.fs dbltest.fs \
137: bubble.fs siev.fs matrix.fs fib.fs \
138: oof.fs oofsampl.fs
139:
140: SOURCES = CVS compat Makefile.in configure.in configure config.sub config.guess \
141: acconfig.h config.h.in stamp-h.in \
142: install-sh INSTALL README ToDo BUGS model COPYING Benchres \
143: gforth.ds texinfo.tex gforth.1 gforth.el \
144: primitives engine.c main.c io.c memcasecmp.c \
145: m68k.h mips.h 386.h hppa.h cache.c sparc.h power.h alpha.h 32bit.h \
146: getopt.c getopt1.c getopt.h select.c \
147: ecvt.c memcmp.c strtol.c strtoul.c ansidecl.h memmove.c pow10.c \
148: strerror.c strsignal.c dblsub.c \
149: INSTALL.DOS makefile.dos mkdosmf.sed configure.bat dosconf.h \
150: startup.dos history.dos \
151: glosgen.glo glossaries.doc \
152: $(INCLUDES) $(FORTH_SRC)
153:
154: RCS_FILES = ToDo model high-level
155:
156: GEN = gforth version.fs
157:
158: OBJECTS = engine.o io.o main.o memcasecmp.o @LIBOBJS@ @getopt_long@
159:
160: # things that need a working forth system to be generated
161: FORTH_GEN0 = primitives.b primitives.i prim_labels.i aliases.fs
162: FORTH_GEN = $(FORTH_GEN0) @KERNEL@ gforth.fi
163: # this is used for antidependences,
164: FORTH_GEN1 = $(FORTH_GEN0) @kernel_fi@
165:
166: #distributed documentation
167: DOCDIST = gforth.ps gforth.info*
168:
169: KERNLS = kernl16b.fi- kernl16l.fi- \
170: kernl32b.fi- kernl32l.fi- \
171: kernl64b.fi- kernl64l.fi-
172:
173: GEN_PRECIOUS = $(FORTH_GEN) $(KERNLS) gforth.texi gforth.dvi gforth.ps Makefile configure
174:
175: #standards.info recommends this:
176: .SUFFIXES:
177: .SUFFIXES: .c .o
178:
179: all: version.fs more
180:
181: version.c: Makefile.in
182: echo "char gforth_version[]=\"$(VERSION)\" ;" >$@
183:
184: version.fs: Makefile.in
185: $(MAKE) gforth
186: echo ": version-string s\" $(VERSION)\" ;" >$@
187:
188: more: $(FORTH_GEN) gforth
189:
190: #from the gcc Makefile:
191: #"Deletion of files made during compilation.
192: # There are four levels of this:
193: # `mostlyclean', `clean', `distclean' and `realclean'.
194: # `mostlyclean' is useful while working on a particular type of machine.
195: # It deletes most, but not all, of the files made by compilation.
196: # It does not delete libgcc.a or its parts, so it won't have to be recompiled.
197: # `clean' deletes everything made by running `make all'.
198: # `distclean' also deletes the files made by config.
199: # `realclean' also deletes everything that could be regenerated automatically."
200:
201: mostlyclean:
202: -$(RM) -rf *.s gforth.fi *.fi~ *.fi- version.fs *TAGS \
203: crossdoc.fd doc.fd gforth.texi gforth.fns gforth.aux gforth.cp gforth.cps \
204: gforth.dvi gforth.fn gforth.ky gforth.log gforth.pg \
205: gforth.toc gforth.tp gforth.vr html
206:
207: clean: mostlyclean
208: -$(RM) -rf $(GEN) *.o
209:
210: distclean: clean
211: -$(RM) machine.h kernel.fi config.cache config.log config.status config.h Makefile
212:
213: #realclean is useless, but dangerous, so it's commented out
214: #realclean: distclean
215: # -$(RM) $(GEN_PRECIOUS)
216:
217: #mostlyclean, but also remove some of the stuff that is distributed
218: virtualclean: mostlyclean
219: -$(RM) -rf gforth.fns gforth.texi gforth.ps gforth.info* \
220: gforth-$(VERSION).tar.gz config.cache *~ */*~
221:
222: #use dist targets only when srcdir=.
223: dist: $(SOURCES) $(FORTH_GEN) $(DOCDIST)
224: -rm -rf gforth-$(VERSION)
225: mkdir gforth-$(VERSION)
226: $(CP) -rp $(SOURCES) $(FORTH_GEN0) @KERNEL@ $(DOCDIST) gforth-$(VERSION)
227: tar cvf - gforth-$(VERSION)|gzip -9 >gforth-$(VERSION).tar.gz
228: -rm -rf gforth-$(VERSION)
229:
230: #a binary distribution contains the complete source distribution,
231: # the objects, the executable and the links. the objects are there for making
232: # make happy.
233: bindist: $(SOURCES) $(FORTH_GEN) gforth $(OBJECTS) config.status Makefile
234: -rm -rf gforth-$(VERSION)
235: mkdir gforth-$(VERSION)
236: $(CP) -rp -d $(SOURCES) config.status Makefile $(FORTH_GEN) gforth $(OBJECTS) machine.h kernel.fi gforth-$(VERSION)
237: strip gforth-$(VERSION)/gforth
238: tar cvf - gforth-$(VERSION)|gzip -9 >gforth-$(VERSION)-@host@.tar.gz
239:
240: #makes a package with only the stuff not present in the source
241: #package. For installation the source package is still needed!
242: #This is useful if you want to distribute many binary versions in
243: #little space (e.g., on floppy disk): Put the source package and
244: #all the binonly packages you are interested in on the disk. The user
245: #then just has to unpack the source and his favourite binonly into the
246: #same directory and has a full binary distribution.
247: binonlydist: $(SOURCES) $(FORTH_GEN) gforth $(OBJECTS)
248: -rm -rf gforth-$(VERSION)
249: mkdir gforth-$(VERSION)
250: $(CP) -p -d config.status Makefile gforth $(OBJECTS) machine.h kernel.fi gforth-$(VERSION)
251: strip gforth-$(VERSION)/gforth
252: tar cvf - gforth-$(VERSION)|gzip -9 >gforth-$(VERSION)-binonly-@host@.tar.gz
253:
254:
255:
256: #strip gforth, because the debugging stuff is hardly useful once
257: # gforth manages to execute more than a few primitives
258:
259: install: gforth $(FORTH_SRC) kernel.fi gforth.fi gforth.1 gforth.info primitives gforth.TAGS
260: for i in $(bindir) $(mandir) $(infodir) $(libdir)/gforth/$(VERSION) $(datadir)/gforth/$(VERSION) $(libdir)/gforth/site-forth $(datadir)/gforth/site-forth; do \
261: $(INSTALL_DIR) $$i; \
262: done
263: touch $(datadir)/gforth/site-forth/site-init.fs
264: -$(RM) $(bindir)/gforth $(bindir)/gforth-$(VERSION)
265: $(INSTALL_PROGRAM) -s gforth $(bindir)
266: ln $(bindir)/gforth $(bindir)/gforth-$(VERSION)
267: $(INSTALL_DATA) $(srcdir)/gforth.1 $(mandir)
268: for i in $(srcdir)/gforth.info*; do $(INSTALL_DATA) $$i $(infodir); done
269: for i in $(FORTH_SRC) primitives; do \
270: $(INSTALL_DATA) $(srcdir)/$$i $(datadir)/gforth/$(VERSION); \
271: done
272: $(INSTALL_DATA) kernel.fi $(libdir)/gforth/$(VERSION)
273: $(FORTHP) startup.fs -e "savesystem $(libdir)/gforth/$(VERSION)/gforth.fi bye" #gforth.fi contains some path names
274: sed s:$(srcdir)/:$(datadir)/gforth/$(VERSION)/: gforth.TAGS >TAGS; $(INSTALL_DATA) TAGS $(datadir)/gforth/$(VERSION)
275: if test -d $(emacssitelispdir); then \
276: $(INSTALL_DATA) $(srcdir)/gforth.el $(emacssitelispdir); \
277: else \
278: echo ">>>>>Please install $(srcdir)/gforth.el in your .../emacs/site-lisp directory"; \
279: fi
280:
281: install-strip: install
282:
283: #deinstall all files specific to this version of gforth
284: #to uninstall version foo, type `make uninstall VERSION=foo'
285: uninstall:
286: -$(RM) -rf $(libdir)/gforth/$(VERSION) $(datadir)/gforth/$(VERSION) $(bindir)/gforth-$(VERSION)
287: @echo -e "Type\n$(RM) -rf $(bindir)/gforth $(mandir)/gforth.1 $(infodir)/gforth.info* $(datadir)/gforth $(libdir)/gforth\nto remove Gforth completely"
288:
289: check: test
290: touch test
291:
292: test: gforth gforth.fi
293: $(FORTH) tester.fs coretest.fs postponetest.fs dbltest.fs -e bye
294: $(FORTH) code.fs checkans.fs -e bye
295: @echo 'Expect no differences'
296: $(FORTH) prims2x.fs -e "s\" $(srcdir)/primitives.b\" ' output-c process-file bye"| diff -c - $(srcdir)/primitives.i
297:
298: bench: gforth gforth.fi
299: @echo 'Each benchmark takes about 30s on a 486-66 (gcc-2.6.3 -DFORCE_REG)'
300: time $(FORTH) siev.fs -e "main bye"
301: time $(FORTH) bubble.fs -e "main bye"
302: time $(FORTH) -m 160000 matrix.fs -e "main bye"
303: time $(FORTH) fib.fs -e "main bye"
304:
305: dvi: gforth.dvi
306:
307: gforth: $(OBJECTS)
308: -$(CP) gforth gforth~
309: $(GCC) $(LDFLAGS) $(OBJECTS) $(LDLIBS) -o $@
310: @MAKE_EXE@
311:
312: kernl16l.fi-: $(KERN_SRC) version.fs mach16l.fs $(FORTH_GEN0)
313: $(FORTHK) -e 's" mach16l.fs"' main.fs -e "save-cross kernl16l.fi- $(bindir)/gforth-$(VERSION) bye"
314:
315: kernl16b.fi-: $(KERN_SRC) version.fs mach16b.fs $(FORTH_GEN0)
316: $(FORTHK) -e 's" mach16b.fs"' main.fs -e "save-cross kernl16b.fi- $(bindir)/gforth-$(VERSION) bye"
317:
318: kernl32l.fi-: $(KERN_SRC) version.fs mach32l.fs $(FORTH_GEN0)
319: $(FORTHK) -e 's" mach32l.fs"' main.fs -e "save-cross kernl32l.fi- $(bindir)/gforth-$(VERSION) bye"
320:
321: kernl32b.fi-: $(KERN_SRC) version.fs mach32b.fs $(FORTH_GEN0)
322: $(FORTHK) -e 's" mach32b.fs"' main.fs -e "save-cross kernl32b.fi- $(bindir)/gforth-$(VERSION) bye"
323:
324: kernl64l.fi-: $(KERN_SRC) version.fs mach64l.fs $(FORTH_GEN0)
325: $(FORTHK) -e 's" mach64l.fs"' main.fs -e "save-cross kernl64l.fi- $(bindir)/gforth-$(VERSION) bye"
326:
327: kernl64b.fi-: $(KERN_SRC) version.fs mach64b.fs $(FORTH_GEN0)
328: $(FORTHK) -e 's" mach64b.fs"' main.fs -e "save-cross kernl64b.fi- $(bindir)/gforth-$(VERSION) bye"
329:
330: kernl16b.fi: $(KERNLS)
331: -$(CP) kernl16b.fi kernl16b.fi~
332: -$(CP) kernl16b.fi- kernl16b.fi
333: @LINK_KERNL16B@
334:
335: kernl16l.fi: $(KERNLS)
336: -$(CP) kernl16l.fi kernl16l.fi~
337: -$(CP) kernl16l.fi- kernl16l.fi
338: @LINK_KERNL16L@
339:
340: kernl32b.fi: $(KERNLS)
341: -$(CP) kernl32b.fi kernl32b.fi~
342: -$(CP) kernl32b.fi- kernl32b.fi
343: @LINK_KERNL32B@
344:
345: kernl32l.fi: $(KERNLS)
346: -$(CP) kernl32l.fi kernl32l.fi~
347: -$(CP) kernl32l.fi- kernl32l.fi
348: @LINK_KERNL32L@
349:
350: kernl64b.fi: $(KERNLS)
351: -$(CP) kernl64b.fi kernl64b.fi~
352: -$(CP) kernl64b.fi- kernl64b.fi
353: @LINK_KERNL64B@
354:
355: kernl64l.fi: $(KERNLS)
356: -$(CP) kernl64l.fi kernl64l.fi~
357: -$(CP) kernl64l.fi- kernl64l.fi
358: @LINK_KERNL64L@
359:
360: gforth.fi: @kernel_fi@ gforth $(GFORTH_FI_SRC)
361: $(FORTHK) startup.fs -e "savesystem gforth.fi bye"
362:
363: gforth.TAGS: @kernel_fi@ gforth $(GFORTH_FI_SRC) primitives.TAGS
364: $(FORTHK) etags.fs startup.fs -e bye
365: cat TAGS primitives.TAGS kernel.TAGS >gforth.TAGS
366:
367: engine.s: engine.c primitives.i prim_labels.i machine.h threading.h $(INCLUDES) config.h
368: $(GCC) $(CFLAGS) $(ENGINE_FLAGS) -S $(srcdir)/engine.c
369:
370: engine.o: engine.c primitives.i prim_labels.i machine.h threading.h $(INCLUDES) config.h
371: $(GCC) $(CFLAGS) $(ENGINE_FLAGS) -c $(srcdir)/engine.c
372:
373: main.o: main.c machine.h threading.h $(INCLUDES) config.h
374: $(GCC) $(CFLAGS) $(ENGINE_FLAGS) -c $(srcdir)/main.c
375:
376: strtoul.o: strtoul.c strtol.c
377:
378: primitives.b: primitives
379: m4 -s $(srcdir)/primitives >$@
380:
381: primitives.i : primitives.b prims2x.fs
382: $(FORTHK) prims2x.fs -e "s\" primitives.b\" ' output-c process-file bye" >$@
383:
384: prim_labels.i : primitives.b prims2x.fs
385: $(FORTHK) prims2x.fs -e "s\" primitives.b\" ' output-label process-file bye" >$@
386:
387: aliases.fs: primitives.b prims2x.fs
388: $(FORTHK) prims2x.fs -e "s\" primitives.b\" ' output-alias process-file bye" >$@
389:
390: primitives.fs: primitives.b prims2x.fs
391: $(FORTHK) prims2x.fs -e "s\" primitives.b\" ' output-forth process-file bye" >$@
392:
393: primitives.TAGS: primitives.b prims2x.fs
394: $(FORTHK) prims2x.fs -e "s\" $(srcdir)/primitives.b\" ' output-tag process-file bye" >$@
395:
396: doc.fd: makedoc.fs float.fs search-order.fs glocals.fs environ.fs \
397: toolsext.fs wordinfo.fs \
398: vt100.fs colorize.fs see.fs bufio.fs debug.fs history.fs \
399: doskey.fs vt100key.fs startup.fs assert.fs debugging.fs code.fs
400: $(FORTHK) -e "s\" doc.fd\"" makedoc.fs startup.fs code.fs -e bye
401:
402: crossdoc.fd: $(KERN_SRC) version.fs $(FORTH_GEN0)
403: $(FORTHK) -e 's" mach32l.fs"' main.fs -e bye
404:
405: gforth.texi: gforth.ds primitives.b ds2texi.fs prims2x.fs doc.fd crossdoc.fd
406: $(FORTHK) ds2texi.fs prims2x.fs -e "s\" $(srcdir)/primitives.b\" ' register-doc process-file" crossdoc.fd doc.fd -e "s\" $(srcdir)/gforth.ds\" r/o open-file throw ds2texi bye" >$@
407:
408: checkdoc: gforth.ds primitives.b ds2texi.fs prims2x.fs doc.fd crossdoc.fd answords.fs
409: $(FORTHK) ds2texi.fs answords.fs -e bye
410:
411: dvi: gforth.dvi
412:
413: gforth.dvi gforth.fns: gforth.texi
414: $(TEXI2DVI) $(srcdir)/gforth.texi
415:
416: gforth.ps: gforth.dvi
417: $(DVI2PS) gforth.dvi -o $@
418:
419: info: gforth.info
420:
421: gforth.info: gforth.texi
422: -$(MAKEINFO) gforth.texi
423:
424: html: gforth.texi
425: -$(RM) html/*
426: -mkdir html
427: cd html; $(TEXI2HTML) -menu -split_node ../gforth.texi
428:
429: doc: gforth.ps html
430:
431: # For an explanation of the following Makefile rules, see node
432: # `Automatic Remaking' in GNU Autoconf documentation.
433: ${srcdir}/configure: configure.in
434: cd ${srcdir} && autoconf
435:
436: # autoheader might not change config.h.in, so touch a stamp file.
437: ${srcdir}/config.h.in: stamp-h.in
438: ${srcdir}/stamp-h.in: configure.in acconfig.h
439: cd ${srcdir} && autoheader
440: echo timestamp > ${srcdir}/stamp-h.in
441:
442: config.h: stamp-h
443: stamp-h: config.h.in config.status
444: CONFIG_FILES=$@ CONFIG_HEADERS=config.h ./config.status
445: echo > stamp-h
446: Makefile: Makefile.in config.status
447: CONFIG_FILES=$@ CONFIG_HEADERS=config.h ./config.status
448:
449: config.status: configure
450: ./config.status --recheck
451:
452:
453: #create files for DOS, because DOS cannot do it itself
454: makefile.dos: mkdosmf.sed Makefile.in
455: sed -f mkdosmf.sed <Makefile.in >makefile.dos
456:
457: history.dos: history.fs Makefile.in
458: sed -e "s,~/\.gforth-history,/gforth.his,g" <history.fs >history.dos
459:
460: startup.dos: startup.fs Makefile.in
461: sed -e "s/\\\\ include doskey/include doskey/g" \
462: -e "s/include vt100key/\\\\ include vt100key/g" <startup.fs >startup.dos
463:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>