1#Makefile for Gforth
2
3#Copyright (C) 1995,1996,1997,1998,2000,2003,2004,2005,2006,2007,2008 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 3
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, see http://www.gnu.org/licenses/.
19
20# To change the values of `make' variables: instead of editing Makefiles,
21# (1) if the variable is set in `config.status', edit `config.status'
22#     (which will cause the Makefiles to be regenerated when you run `make');
23# (2) otherwise, pass the desired values on the `make' command line.
24
25# Warning:
26# For some stupid reason setting SHELL to bash does not work properly with
27# DOS. If you want to use shell-specific things that must run with DOS make
28# an external batch file and call it with bash (see versions.bsh).
29
30# ------------- gforth version
31
32VERSION	= 0.5.9
33DOSVERSION=`echo $(VERSION)|sed 's/\.//g'|sed 's/-.*//g'`
34
35# -------------	System specific variables
36
37machine=386
38kernel_fi=kernl32l.fi
39EXE=.exe
40
41# this is the type of machine
42# used to extend the include path with ./arch/$machine
43# so we can include a machine specific
44# machine.h file
45
46PATHSEP = ;
47
48EC = @EC@
49
50# -------------	Utility programs
51
52SHELL	= bash
53RM	= del
54RMTREE	= del -rf
55CP	= copy -p
56MV	= mv
57TAR	= tar cf -
58INSTALL	= install-sh -c
59INSTALL_PROGRAM = ${INSTALL}
60MASSAGE_EXE = @MASSAGE_EXE@
61INSTALL_SCRIPT = @INSTALL_SCRIPT@
62INSTALL_DATA = ${INSTALL} -m 644
63INSTALL_INFO = @INSTALL_INFO@
64LN_S	= ln -s
65M4      = @M4@
66GCC	= gcc
67EMACS   = emacs
68LIBTOOL = @GNU_LIBTOOL@
69PREFORTH	= ./preforth -p ".$(PATHSEP)~+$(PATHSEP)$(srcdir)"
70CC	= $(GCC)
71FORTHPATH = .$(PATHSEP)$(libdir)/gforth/site-forth$(PATHSEP)$(siteforthdir)$(PATHSEP)$(libdir)/gforth/$(VERSION)$(PATHSEP)$(datadir)/gforth/$(VERSION)
72FORTHSIZES =
73FORTHS_ARGS =  -p "$(srcdir)"
74FORTH_ARGS = --die-on-signal $(FORTHS_ARGS)
75ENGINE = ./gforth
76FORTH	= $(ENGINE) $(FORTH_ARGS)
77FORTHS	= $(ENGINE) $(FORTHS_ARGS)
78# the (existing) forth system to use for cross compiling and primitives tables
79# per default we use the one in this directory for a rebuild. It is also
80# possible to override this variable at the command line for an initial build (jaw)
81BUILDFORTH = $(ENGINE) --die-on-signal -m 4M -p ".$(PATHSEP)~+$(PATHSEP)$(srcdir)" -i $(kernel_fi)
82# the forth system plus flags we use to build
83FORTHB = $(BUILDFORTH) exboot.fs -e 'fpath= .|~+|$(srcdir)'
84# the Forth system for running prims2x.fs
85FORTHP = $(FORTH)
86ENGINE_FAST = ./gforth-fast
87FORTH_FAST	= $(ENGINE_FAST) $(FORTH_ARGS)
88FORTHKFLAGS= --die-on-signal -p ".$(PATHSEP)~+$(PATHSEP)$(srcdir)" -i $(kernel_fi)
89FORTHK	= $(ENGINE) $(FORTHKFLAGS)
90#FORTHP	= $(ENGINE) --die-on-signal -i ./$(kernel_fi)
91#the "-2 image-included-files +!" undoes the change to image-included-files
92# in exboot.fs
93STARTUP	= exboot.fs startup.fs @asm_fs@ @disasm_fs@
94STRIP	= strip
95TEXI2DVI = @TEXI2DVI@
96TEXI2PDF = @TEXI2DVI@ --pdf
97DVI2PS	= dvips -t letterSize -Z
98#you can get texi2html from http://wwwcn.cern.ch/dci/texi2html/
99MAKEINFO = makeinfo
100TEXI2HTML = texi2html
101
102# -------------	Compiler Flags
103
104XCFLAGS	=
105XDEFINES = -DHAVE_CONFIG_H
106SWITCHES = $(XCFLAGS) $(XDEFINES) $(OPTDEFINES) #-DNDEBUG #turn off assertions
107ENGINE_FLAGS =  -fno-defer-pop -fcaller-saves
108DEBUGFLAG =
109CFLAGS	= $(DEBUGFLAG) -I$(srcdir)/engine -I$(srcdir)/arch/$(machine) -O3 -Wall $(SWITCHES) -DDEFAULTPATH='"~+\""
110CPPFLAGS =
111
112#John Wavrik should use -Xlinker -N to get a writable text (executable)
113XLDFLAGS =
114LDFLAGS	=  $(DEBUGFLAG) $(XLDFLAGS)
115LDLIBS	= -lm
116
117STACK_CACHE_REGS = @STACK_CACHE_REGS@
118STACK_CACHE_DEFAULT_FAST = @STACK_CACHE_DEFAULT_FAST@
119
120# ------------	Install Directories
121
122VPATH = .
123prefix = /usr/local
124exec_prefix = ${prefix}
125srcdir = .
126bindir = ${exec_prefix}/bin
127#read-only architecture-independent files
128datarootdir = @datarootdir@
129datadir = ${prefix}/share
130#read-only architecture-dependent non-ascii files
131libdir = ${exec_prefix}/lib
132libccdir = $(libdir)/gforth/$(VERSION)/libcc-named/
133includedir = ${prefix}/include
134infodir = ${prefix}/info
135htmldir = @htmldir@
136mandir = ${prefix}/man
137man1dir= $(mandir)/man1
138man1ext= .1
139#older emacses have their site-lisp in $(libdir)/emacs/
140emacssitelispdir=@lispdir@
141siteforthdir=$(datadir)/gforth/site-forth
142
143PROFOBJS = @PROFOBJS@
144PROFEXES = @PROFEXES@
145
146INSTALLDIRS = . engine kernel doc asm ec test \
147	compat unix \
148	arch arch/generic arch/m68k arch/mips \
149	arch/386 arch/hppa arch/sparc arch/power \
150	arch/alpha arch/4stack arch/misc arch/6502 \
151	arch/8086 arch/avr arch/c165 arch/h8 \
152	arch/shboom arch/sharc arch/ia64 arch/amd64 \
153	arch/arm arch/r8c vmgen-ex
154
155INCLUDES = engine/forth.h engine/threaded.h engine/io.h engine/longlong.h
156
157KERN_SRC = \
158	mach16b.fs mach16l.fs mach32b.fs mach32l.fs mach64b.fs mach64l.fs \
159	machpc.fs.in \
160	kernel/aliases0.fs \
161	kernel/aliases.fs \
162	kernel/args.fs \
163	kernel/cbr.fs \
164	kernel/cloop.fs \
165	kernel/cond.fs \
166	kernel/cond-old.fs \
167	cross.fs \
168	kernel/errore.fs \
169	kernel/files.fs \
170	kernel/require.fs \
171	kernel/paths.fs \
172	kernel/kernel.fs \
173	kernel/main.fs \
174	kernel/prim0.fs \
175	search.fs \
176	kernel/quotes.fs \
177	kernel/tools.fs \
178	kernel/toolsext.fs \
179	kernel/vars.fs \
180	kernel/accept.fs \
181	kernel/basics.fs \
182	kernel/int.fs \
183	kernel/comp.fs \
184	kernel/io.fs \
185	kernel/input.fs \
186	kernel/license.fs \
187	kernel/nio.fs \
188	kernel/saccept.fs \
189	kernel/doers.fs \
190	kernel/getdoers.fs \
191	kernel/pass.fs \
192	kernel/xchars.fs
193
194EC_SRC = \
195	asm/README \
196	asm/bitmask.fs \
197	asm/numref.fs \
198	chains.fs \
199	asm/basic.fs \
200	asm/generic.fs \
201	asm/target.fs \
202	ec/README \
203	ec/mirror.fs \
204	ec/shex.fs \
205	ec/builttag.fs \
206	ec/dotx.fs \
207	ec/nesting.fs \
208	build-ec.in
209
210GFORTH_FI_SRC = \
211	assert.fs \
212	backtrac.fs \
213	blocked.fb \
214	blocks.fs \
215	bufio.fs \
216	code.fs \
217	debug.fs \
218	debugs.fs \
219	dis-gdb.fs \
220	ekey.fs \
221	envos.fs \
222	savesys.fs \
223	environ.fs \
224	errors.fs \
225	exboot.fs \
226	except.fs \
227	extend.fs \
228	float.fs \
229	glocals.fs \
230	hash.fs \
231	history.fs \
232	intcomp.fs \
233	mkdir.fs \
234	libcc.fs \
235	locals.fs \
236	look.fs \
237	mkdir.fs \
238	quotes.fs \
239	search.fs \
240	see.fs \
241	see-ext.fs \
242	simp-see.fs \
243	source.fs \
244	startup.fs \
245	struct.fs \
246	struct0x.fs \
247	stuff.fs \
248	tasker.fs \
249	termsize.fs \
250	utf-8.fs \
251	vt100.fs \
252	vt100key.fs \
253	wordinfo.fs \
254	arch/386/asm.fs arch/386/disasm.fs \
255	arch/amd64/asm.fs arch/amd64/disasm.fs \
256	arch/alpha/asm.fs arch/alpha/disasm.fs arch/alpha/testasm.fs\
257	arch/mips/asm.fs arch/mips/disasm.fs arch/mips/insts.fs \
258	arch/mips/testasm.fs arch/mips/testdisasm.fs \
259	arch/power/asm.fs arch/power/disasm.fs arch/power/inst.fs
260
261LIBCC_SRC = cstr.fs unix/socket.fs
262
263LIBCC_DIST_SRC = libffi.fs fflib.fs $(LIBCC_SRC)
264
265LIBCC_BUILD_SRC = @LIBCC_BUILD_SRC@ $(LIBCC_SRC)
266
267FORTH_SRC = $(KERN_SRC) $(GFORTH_FI_SRC) $(EC_SRC) $(LIBCC_DIST_SRC) \
268	ans-report.fs ansi.fs answords.fs \
269	colorize.fs comp-i.fs complex.fs \
270	depth-changes.fs dosekey.fs doskey.fs ds2texi.fs \
271	envos.dos envos.os2 etags.fs fft.fs filedump.fs fi2c.fs \
272	fsl-util.4th glosgen.fs gray.fs httpd.fs install-tags.fs \
273	make-app.fs doc/makedoc.fs locate.fs more.fs onebench.fs \
274	other.fs prims2x.fs prims2x0.6.2.fs proxy.fs random.fs \
275	regexp.fs sokoban.fs string.fs table.fs tags.fs \
276	tt.fs \
277	unbuffer.fs wordsets.fs xwords.fs \
278	test/tester.fs test/ttester.fs \
279	test/coretest.fs test/postpone.fs test/dbltest.fs \
280	test/string.fs test/float.fs test/search.fs test/gforth.fs \
281	test/other.fs test/signals.fs test/checkans.fs \
282	test/primtest.fs test/coreext.fs test/deferred.fs \
283	test/coremore.fs test/gforth-nofast.fs test/libcc.fs \
284	bubble.fs siev.fs matrix.fs fib.fs \
285	oof.fs oofsampl.fs objects.fs objexamp.fs mini-oof.fs moof-exm.fs \
286	moofglos.fs fixpath.fs \
287	add.fs lib.fs oldlib.fs sieve.fs \
288	endtry-iferror.fs recover-endtry.fs
289
290COMPAT = compat/README \
291	compat/anslocal.fs \
292	compat/assert.fs \
293	compat/control.fs \
294	compat/defer.fs \
295	compat/exception.fs \
296	compat/execute-parsing.fs \
297	compat/loops.fs \
298	compat/required.fs \
299	compat/strcomp.fs \
300	compat/struct.fs \
301	compat/vocabulary.fs
302
303GFORTH_TEXI =  doc/gforth.texi doc/version.texi
304
305VMGEN_TEXI = doc/vmgen.texi doc/version.texi doc/fdl.texi
306
307ALLSUBDIRS = engine
308
309ARCHS =	\
310	arch/generic/machine.h \
311	arch/m68k/machine.h \
312	arch/mips/machine.h \
313	arch/386/machine.h \
314	arch/hppa/machine.h \
315	arch/hppa/cache.c \
316	arch/sparc/machine.h \
317	arch/power/machine.h \
318	arch/power/_sync_cache_range.c \
319	arch/alpha/machine.h \
320	arch/arm/machine.h \
321	arch/arm/cacheflush0.c \
322	arch/arm/cacheflush-linux.c \
323	arch/ia64/machine.h \
324	arch/ia64/flush_icache_block.c \
325	arch/amd64/machine.h \
326	arch/4stack/README \
327	arch/4stack/asm.fs \
328	arch/4stack/mach.fs \
329	arch/4stack/prim.fs \
330	arch/4stack/mach.sh \
331	arch/4stack/relocate.fs \
332	arch/misc/README \
333	arch/misc/asm.fs \
334	arch/misc/mach.fs \
335	arch/misc/optcmove.fs \
336	arch/misc/prim.fs \
337	arch/misc/sim.fs \
338	arch/misc/sokoban.fs \
339	arch/misc/tt.fs \
340	arch/6502/prim.fs \
341	arch/6502/mach.fs \
342	arch/shboom/asm.fs \
343	arch/shboom/compiler.fs \
344	arch/shboom/dis.fs \
345	arch/shboom/mach.fs \
346	arch/shboom/prim.fs \
347	arch/shboom/dis2.fs \
348	arch/shboom/sh.p \
349	arch/shboom/doers.fs \
350	arch/sharc/mach.fs \
351	arch/sharc/machine.h \
352	arch/sharc/compile.sharc \
353	arch/sharc/systypes.h \
354	arch/sharc/types.h \
355	arch/sharc/g21k-3.3.4-bp1.diff \
356	arch/r8c/asm.fs \
357	arch/r8c/mach.fs \
358	arch/r8c/prim.fs
359
360#not included in distribution until distribution terms are included:
361ARCHS_NO_DIST = \
362	arch/6502/asm.fs \
363	arch/6502/cold.fs \
364	arch/6502/softuart.fs \
365	arch/6502/zero.fs \
366	arch/8086/asm.fs \
367	arch/8086/mach.fs \
368	arch/8086/mach.sh \
369	arch/8086/prim.fs \
370	arch/avr/asm.fs \
371	arch/c165/asm.fs \
372	arch/c165/mach.fs \
373	arch/c165/prim.fs \
374	arch/h8/asm.fs \
375	arch/r8c/asm-test.fs \
376	arch/r8c/errors.fs \
377	arch/r8c/lauflicht.fs \
378	arch/r8c/tasker.fs \
379	arch/r8c/terminal.fs \
380	arch/r8c/tt.fs \
381	arch/sharc/unistd.h
382
383VMGEN_EX = vmgen-ex/Makefile vmgen-ex/README vmgen-ex/disasm.c \
384	vmgen-ex/engine.c vmgen-ex/fib.mini \
385	vmgen-ex/mini-inst.vmg vmgen-ex/mini-super.vmg vmgen-ex/mini.h \
386	vmgen-ex/mini.l vmgen-ex/mini.y vmgen-ex/peephole-blacklist \
387	vmgen-ex/peephole.c vmgen-ex/profile.c vmgen-ex/seq2rule.awk \
388	vmgen-ex/simple.mini vmgen-ex/stat.awk vmgen-ex/support.c \
389	vmgen-ex/test.mini vmgen-ex/test.out
390
391VMGEN_EX2 = $(VMGEN_EX:vmgen-ex/%=vmgen-ex2/%)
392
393ENGINE_SOURCES = engine/Makefile.in engine/config.h.in \
394	engine/engine.c engine/main.c \
395	engine/io.c engine/support.c engine/signals.c engine/libcc.h.in \
396	engine/profile.c engine/128bit.h \
397	engine/getopt.c engine/getopt1.c engine/getopt.h engine/select.c \
398	engine/ecvt.c engine/memcmp.c engine/rint.c \
399	engine/strtol.c engine/strtoul.c \
400	engine/ansidecl.h engine/memmove.c \
401	engine/pow10.c engine/atanh.c engine/cleanalign.c \
402	engine/strerror.c engine/strsignal.c engine/dblsub.c \
403	engine/fnmatch.h engine/fnmatch.c \
404	engine/makefile.dos engine/makefile.os2
405
406SOURCES	= $(ENGINE_SOURCES) compat Makefile.in Makedist.in \
407	gforthmi.in vmgen.in preforth.in gfgen README.vmgen NEWS.vmgen \
408	autogen.sh configure.in configure config.sub config.guess \
409	elisp-comp missing stamp-h.in envos.fs.in \
410	iss.sh install-sh INSTALL INSTALL.BINDIST NEWS README ToDo BUGS \
411	BUILD-FROM-SCRATCH model \
412	COPYING COPYING.LIB COPYING.DOC AUTHORS ChangeLog Benchres aclocal.m4 \
413	doc/gforth.ds doc/gforth.1 doc/version.texi.in \
414	doc/vmgen.texi doc/fdl.texi doc/gpl.texi \
415	gforth.el \
416	$(ARCHS) \
417	INSTALL.DOS makefile.dos mkdosmf.sed config.bat \
418	dosconf.h gforthmi.bat mkinstalldirs siteinit.fs \
419	versions.bsh \
420	configure.cmd mkos2mf.sed os2conf.h makefile.os2 \
421	gforthmi.cmd glosgen.glo doc/glossaries.doc \
422	$(INCLUDES) $(FORTH_SRC) $(COMPAT) $(VMGEN_EX) $(VMGEN_EX2) \
423	timings.sc \
424	test/coretest.out test/checkans.out test/gforth.out \
425	cache*.vmg peeprules.vmg prim
426
427RCS_FILES =  ToDo model high-level
428
429ENGINES = gforth$(EC)$(EXE) gforth-ditc$(EC)$(EXE) gforth-itc$(EC)$(EXE) $(PROFEXES)
430
431ENGINES_FAST = gforth-fast$(OPT)$(EC)$(EXE) #gforth-native$(OPT)$(EC)$(EXE)
432
433GEN = $(ENGINES) $(ENGINES_FAST) gforth.elc
434
435# things that need a working forth system to be generated
436FORTH_GEN_ENGINE=engine/prim.i engine/prim_lab.i engine/prim_names.i \
437	engine/prim_superend.i engine/profile.i \
438	engine/prim_num.i engine/prim_grp.i \
439	engine/costs.i engine/super2.i
440FORTH_GEN_ENGINE_FAST= \
441	engine/prim-fast.i engine/prim_lab-fast.i engine/prim_names-fast.i \
442	engine/prim_superend-fast.i engine/profile-fast.i \
443	engine/prim_num-fast.i engine/prim_grp-fast.i \
444	engine/costs-fast.i engine/super2-fast.i
445FORTH_GEN_PRIMB = $(FORTH_GEN_ENGINE) kernel/aliases.fs kernel/prim.fs
446FORTH_GEN0 = prim.b $(FORTH_GEN_PRIMB)
447FORTH_GEN =  $(FORTH_GEN0) kernl16l.fi kernl16b.fi kernl32l.fi kernl32b.fi kernl64l.fi kernl64b.fi gforth.fi
448# this is used for antidependences,
449FORTH_GEN1 = $(FORTH_GEN0) kernl32l.fi build-ec
450
451#kernel dependencies
452KERN_DEPS = $(KERN_SRC) kernel/version.fs machpc.fs $(FORTH_GEN0) compat/strcomp.fs
453
454#distributed documentation
455DOCDIST = doc/gforth.info doc/gforth.info-* doc/gforth.ps \
456	  doc/vmgen.info doc/vmgen.ps
457
458BKERNLS = kernl16b$(EC).fi kernl16l$(EC).fi \
459	  kernl32b$(EC).fi kernl32l$(EC).fi \
460	  kernl64b$(EC).fi kernl64l$(EC).fi
461
462KERNLS = kernl16b$(EC).fi- kernl16l$(EC).fi- \
463	 kernl32b$(EC).fi- kernl32l$(EC).fi- \
464	 kernl64b$(EC).fi- kernl64l$(EC).fi-
465
466# -------------        Make forth images
467GEN_PRECIOUS = $(FORTH_GEN) $(KERNLS) \
468	doc/gforth.texi doc/gforth.dvi doc/gforth.ps \
469	doc/vmgen.dvi doc/vmgen.ps \
470	Makefile Makedist engine/Makefile configure
471
472#standards.info recommends this:
473.SUFFIXES:
474.SUFFIXES: .c .o
475
476all: kernel/version.fs more @NO_CHECK@check
477
478# use this dependency for phony targets just as mostlyclean,...
479FORCE: ;
480
481#this rule avoids remaking everything after minor changes in Makefile.in
482version:	Makefile.in configure.in
483		echo $(VERSION) > $@
484
485# With dos we use normal dos echo
486# we cannot pipe the output to engine/version.h directly because
487# of the "/ and \" problem. Copying works because we use the
488# shell und file utilities.
489
490kernel/version.fs:	version
491
492
493more:	$(ENGINES) $(FORTH_GEN) $(GEN) @build_libcc_named@
494
495#from the gcc Makefile:
496#"Deletion of files made during compilation.
497# There are four levels of this:
498#   `mostlyclean', `clean', `distclean' and `realclean'.
499# `mostlyclean' is useful while working on a particular type of machine.
500# It deletes most, but not all, of the files made by compilation.
501# It does not delete libgcc.a or its parts, so it won't have to be recompiled.
502# `clean' deletes everything made by running `make all'.
503# `distclean' also deletes the files made by config.
504# `realclean' also deletes everything that could be regenerated automatically."
505
506mostlyclean:	FORCE
507		-$(RM) -rf engine/*.s gforth.fi *.fi~ *.fi- kernel/version.fs \
508		*TAGS gforth~ \
509		doc/crossdoc.fd doc/doc.fd doc/gforth.texi doc/gforth.fns \
510		doc/gforth.aux doc/gforth.cp doc/gforth.cps \
511		doc/gforth.dvi doc/gforth.fn doc/gforth.ky doc/gforth.log \
512		doc/gforth.pg \
513		doc/gforth.toc doc/gforth.tp doc/gforth.vr html \
514		gforth-$(VERSION).tar.gz
515
516# Just the stuff needed to rebuild the documentation nac03feb1999
517docclean:	FORCE
518		-$(RM) -rf doc/crossdoc.fd doc/doc.fd doc/gforth.texi doc/gforth.fns \
519		doc/gforth.aux doc/gforth.cp doc/gforth.cps \
520		doc/gforth.dvi doc/gforth.fn doc/gforth.ky doc/gforth.log \
521		doc/gforth.pg \
522		doc/gforth.toc doc/gforth.tp doc/gforth.vr html
523
524clean:		mostlyclean
525	-$(RM) -rf $(GEN) *.o engine/*.o arch/*/*.o version \
526	gforth-itc-noll$(EC)$(EXE)  engine/gforth-itc-noll$(EC)$(EXE)  \
527	gforth-ditc-noll$(EC)$(EXE) engine/gforth-ditc-noll$(EC)$(EXE) \
528	gforth-prof-noll$(EC)$(EXE) engine/gforth-prof-noll$(EC)$(EXE) \
529	engine/prim-s.i
530	for i in gforth gforth-fast gforth-native; do for j in $(OPTS); do del -f engine/$$i$${j}$(EC)$(EXE) $$i$${j}$(EC)$(EXE); done; done
531
532distclean:	clean
533		-$(RM) -rf config.cache config.log config.status \
534		engine/config.h Makefile Makedist engine/Makefile \
535		stamp-h engine/stamp-h \
536		doc/version.texi gforthmi vmgen preforth \
537		prim-fast.b $(FORTH_GEN_ENGINE_FAST)
538
539#realclean is useless, but dangerous, so it's commented out
540realclean:	distclean
541		-$(RM) -rf $(GEN_PRECIOUS) `cat .cvsignore`
542
543#mostlyclean, but also remove some of the stuff that is distributed
544virtualclean:	mostlyclean
545		-$(RM) -rf gforth.fns gforth.texi gforth.ps gforth.info* \
546		gforth-$(VERSION).tar.gz config.cache *~ */*~
547
548maintainer-clean: realclean
549
550#Some makes (Ultrix, SunOS, IRIX) are so broken, they cannot read the
551#Makefile if it contains our dist rules.  Therefore we have put these
552#rules in Makedist (you can use them with GNU make on these systems).
553
554dist:		Makedist FORCE
555		$(MAKE) -f Makedist d$@
556
557dosdist:	Makedist FORCE
558		$(MAKE) -f Makedist d$@
559
560srcdist:	Makedist FORCE
561		$(MAKE) -f Makedist d$@
562
563srconlydist:	Makedist FORCE
564		$(MAKE) -f Makedist d$@
565
566docdist:	Makedist FORCE
567		$(MAKE) -f Makedist d$@
568
569htmldist:	Makedist FORCE
570		$(MAKE) -f Makedist d$@
571
572bindist:	Makedist FORCE
573		$(MAKE) -f Makedist d$@
574
575binonlydist:	Makedist FORCE
576		$(MAKE) -f Makedist d$@
577
578#HPUX make breaks the cycle differently when the dates are equal, so
579# touch some of the files if it acts up
580hpux-workaround:
581	touch $(FORTH_GEN_PRIMB)
582
583#strip gforth, because the debugging stuff is hardly useful once
584# gforth manages to execute more than a few primitives.
585
586#install does not depend on gforth.info, because that would require
587#supplying a lot of files that can be easily generated (only info is
588#hard to generate).
589#we rebuild gforth.fi, because it contains some path names.
590#we delete $build/gforth.fi and $build/install.TAGS after installation because of ownership.
591install:	gforth$(EC)$(EXE) $(FORTH_SRC) $(kernel_fi) gforth.fi gforthmi vmgen doc/gforth.1 prim install.TAGS installdirs
592		$(NORMAL_INSTALL)
593		touch $(DESTDIR)$(siteforthdir)/siteinit.fs
594		-$(RM) $(DESTDIR)$(bindir)/gforth$(EC)$(EXE) $(DESTDIR)$(bindir)/gforth-$(VERSION)$(EC)$(EXE) $(DESTDIR)$(bindir)/gforthmi $(DESTDIR)$(bindir)/vmgen
595		-$(RM) $(DESTDIR)$(bindir)/gforth-fast$(EC)$(EXE) $(DESTDIR)$(bindir)/gforth-fast-$(VERSION)$(EC)$(EXE)
596		-$(RM) $(DESTDIR)$(bindir)/gforth-itc$(EC)$(EXE) $(DESTDIR)$(bindir)/gforth-itc-$(VERSION)$(EC)$(EXE)
597		$(INSTALL_PROGRAM) gforth$(EC)$(EXE) $(DESTDIR)$(bindir)/gforth-$(VERSION)$(EC)$(EXE)
598		-$(MASSAGE_EXE) $(DESTDIR)$(bindir)/gforth-$(VERSION)$(EC)$(EXE)
599		(cd $(DESTDIR)$(bindir) && $(LN_S) gforth-$(VERSION)$(EC)$(EXE) gforth$(EC)$(EXE))
600		$(INSTALL_PROGRAM) gforth-fast$(EC)$(EXE) $(DESTDIR)$(bindir)/gforth-fast-$(VERSION)$(EC)$(EXE)
601		-$(MASSAGE_EXE) $(DESTDIR)$(bindir)/gforth-fast-$(VERSION)$(EC)$(EXE)
602		(cd $(DESTDIR)$(bindir) && $(LN_S) gforth-fast-$(VERSION)$(EC)$(EXE) gforth-fast$(EC)$(EXE))
603		$(INSTALL_PROGRAM) gforth-itc$(EC)$(EXE) $(DESTDIR)$(bindir)/gforth-itc-$(VERSION)$(EC)$(EXE)
604		(cd $(DESTDIR)$(bindir) && $(LN_S) gforth-itc-$(VERSION)$(EC)$(EXE) gforth-itc$(EC)$(EXE))
605		$(INSTALL_SCRIPT) gforthmi $(DESTDIR)$(bindir)/gforthmi-$(VERSION)
606		$(INSTALL_SCRIPT) vmgen $(DESTDIR)$(bindir)/vmgen-$(VERSION)
607		$(INSTALL_PROGRAM) gforth-ditc $(DESTDIR)$(libdir)/gforth/$(VERSION)
608		(cd $(DESTDIR)$(bindir) && $(LN_S) gforthmi-$(VERSION) gforthmi)
609		(cd $(DESTDIR)$(bindir) && $(LN_S) vmgen-$(VERSION) vmgen)
610		-$(INSTALL_DATA) $(srcdir)/doc/gforth.1 $(DESTDIR)$(man1dir)
611		-for i in $(srcdir)/doc/gforth.info* $(srcdir)/doc/vmgen.info*; do $(INSTALL_DATA) $$i $(DESTDIR)$(infodir); done
612		for i in $(FORTH_SRC) $(COMPAT) prim; do \
613			$(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(datadir)/gforth/$(VERSION)/$$i; \
614		done
615		$(INSTALL_DATA) $(kernel_fi) $(DESTDIR)$(datadir)/gforth/$(VERSION)
616		@if test -d "$(DESTDIR)$(emacssitelispdir)"; then \
617			$(INSTALL_DATA) gforth.el $(DESTDIR)$(emacssitelispdir); \
618			$(INSTALL_DATA) gforth.elc $(DESTDIR)$(emacssitelispdir); \
619		else \
620			echo '>>>>>Please install gforth.{el,elc} in your .../emacs/site-lisp directory'; \
621		fi
622		$(INSTALL_DATA) gforth.fi $(DESTDIR)$(libdir)/gforth/$(VERSION)
623		$(INSTALL_DATA) install.TAGS $(DESTDIR)$(datadir)/gforth/$(VERSION)/TAGS
624		$(INSTALL_DATA) include/gforth/$(VERSION)/* $(DESTDIR)$(includedir)/gforth/$(VERSION)
625		if test -n "$(LIBTOOL)"; then for i in $(LIBCC_BUILD_SRC); do \
626		   $(LIBTOOL) --silent --mode=install $(INSTALL) lib/gforth/$(VERSION)/libcc-named/`basename $$i .fs`.la $(DESTDIR)$(libccdir)`basename $$i .fs`.la; \
627		done; fi
628		$(POST_INSTALL)
629		$(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/gforth.info
630		$(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/vmgen.info
631
632install-strip:	install
633
634installdirs:	mkinstalldirs
635		$(NORMAL_INSTALL)
636		for i in $(bindir) $(man1dir) $(infodir) $(libdir)/gforth/$(VERSION) $(datadir)/gforth/$(VERSION) $(libdir)/gforth/site-forth $(siteforthdir) $(includedir)/gforth/$(VERSION) $(libccdir); do \
637			$(srcdir)/mkinstalldirs $(DESTDIR)$$i; \
638		done
639		for i in $(INSTALLDIRS); do \
640			$(srcdir)/mkinstalldirs $(DESTDIR)$(datadir)/gforth/$(VERSION)/$$i; \
641		done
642		$(RM) -rf $(DESTDIR)$(datadir)/gforth/$(VERSION)/engine
643
644#deinstall all files specific to this version of gforth
645#to uninstall version foo, type `make uninstall VERSION=foo'
646uninstall:	FORCE
647		$(NORMAL_UNINSTALL)
648		-$(RM) -rf $(DESTDIR)$(libdir)/gforth/$(VERSION) $(DESTDIR)$(datadir)/gforth/$(VERSION) $(DESTDIR)$(bindir)/gforth-$(VERSION)$(EC)$(EXE) $(DESTDIR)$(bindir)/gforth-fast-$(VERSION)$(EC)$(EXE) $(DESTDIR)$(bindir)/gforth-itc-$(VERSION)$(EC)$(EXE) $(DESTDIR)$(bindir)/gforthmi-$(VERSION) $(DESTDIR)(bindir)/vmgen-$(VERSION) $(DESTDIR)$(includedir)/gforth/$(VERSION)
649		@echo -e "To remove Gforth completely, type\n$(RM) -rf $(DESTDIR)$(bindir)/gforth$(EC)$(EXE) $(DESTDIR)$(bindir)/gforth-fast$(EC)$(EXE) $(DESTDIR)$(bindir)/gforth-itc$(EC)$(EXE) $(DESTDIR)$(bindir)/gforthmi $(DESTDIR)$(bindir)/vmgen $(DESTDIR)$(man1dir)/gforth.1 $(DESTDIR)$(infodir)/gforth.info* $(DESTDIR)$(datadir)/gforth $(DESTDIR)$(libdir)/gforth"
650
651build-libcc-named: $(LIBCC_BUILD_SRC) $(FORTH_GEN) $(GEN) FORCE
652		$(RMTREE) lib/gforth/$(VERSION)/libcc-named/
653		for i in $(LIBCC_BUILD_SRC); do gforth -e "s\" `pwd`/lib/gforth/$(VERSION)/libcc-named/\" libcc-named-dir-v 2! libcc-path clear-path libcc-named-dir libcc-path also-path :noname 2drop s\" $(libccdir)\" ; is replace-rpath" $(srcdir)/$$i -e bye; done
654
655check:		gforths	gforth.fi
656		$(MAKE) checkone check-nofast ENGINE="./gforth --no-dynamic" >/dev/null 2>&1
657		$(MAKE) checkone check-nofast ENGINE="./gforth-itc" >/dev/null 2>&1
658		$(MAKE) checkone check-nofast ENGINE="./gforth-ditc" >/dev/null 2>&1
659		$(MAKE) checkone ENGINE="./gforth-fast --no-dynamic" >/dev/null 2>&1
660		$(MAKE) checkone check-nofast ENGINE="./gforth" >/dev/null 2>&1
661		$(MAKE) checkone ENGINE="./gforth-fast" >/dev/null 2>&1
662		@echo "*** Check successful ***"
663		./gforth-fast --diag -e bye
664
665checkone test: gforth.fi engine/prim-s.i
666		$(FORTH) test/tester.fs test/coretest.fs test/postpone.fs test/dbltest.fs test/string.fs test/float.fs test/deferred.fs test/coreext.fs test/search.fs -e bye 2>&1 | tr -d '\015' | diff -c - $(srcdir)/test/coretest.out
667		$(FORTH) test/other.fs -e bye
668		$(FORTHS) test/signals.fs -e bye
669		$(FORTHS) test/coremore.fs test/gforth.fs -e bye 2>&1 | tr -d '\015' | diff -c - $(srcdir)/test/gforth.out
670		$(FORTH) code.fs test/checkans.fs -e bye | tr -d '\015' | diff -c - $(srcdir)/test/checkans.out
671		$(FORTH) prims2x.fs -e \
672		  "c-flag on s\" prim.i\" out-filename 2! s\" $(srcdir)/prim.b\" ' output-c ' output-c-combined process-file bye"| \
673		  tr -d '\015' | grep -v '^#line '|diff -c - engine/prim-s.i
674
675check-nofast: gforth.fi
676		$(FORTHS) test/gforth-nofast.fs -e bye
677
678test/primtest.fi: test/primtest.fs mach32l.fs cross.fs
679		$(FORTHB) -e "s\" mach32l.fs\"" $(srcdir)/test/primtest.fs -e "save-cross $@ $(bindir)/gforth-$(VERSION) bye"
680
681primtest:	gforth gforth-native test/primtest.fi FORCE
682		(echo rs|ENVVAR=bla gforth -i test/primtest.fi) && (echo rs|ENVVAR=bla ./gforth-native -i test/primtest.fi); echo $$?
683
684bench:		gforth-fast$(EC)$(EXE) gforth.fi
685		@echo 'Each benchmark takes about 30s on a 486-66 (gcc-2.6.3 -DFORCE_REG)'
686		time $(FORTH_FAST) siev.fs -e "main bye"
687		time $(FORTH_FAST) bubble.fs -e "main bye"
688		time $(FORTH_FAST) matrix.fs -e "main bye"
689		time $(FORTH_FAST) fib.fs -e "main bye"
690
691onebench one-bench:
692	$(FORTH_FAST) onebench.fs
693
694all-bench allbench:
695	./gforth-fast --dynamic onebench.fs
696	./gforth-fast --no-dynamic onebench.fs
697	./gforth --dynamic onebench.fs
698	./gforth --no-dynamic onebench.fs
699	./gforth-itc onebench.fs
700	./gforth-ditc onebench.fs
701
702# -------------	Make forth images
703
704# How to make new images:
705# 1. Produce an image called kernlXYZ.fi-
706#    the original kernel.fi is not touched because it's needed for creation
707# 2. copy old kernlXYZ.fi to kernlXYZ.fi~
708#    that's a backup copy in case the new kernels don't work
709# 3. copy new kernels to kernlXYZ.fi
710#    these are the ones we want to use now
711
712kernl16l$(EC).fi-:	$(KERN_DEPS) mach16l.fs
713		$(PREFORTH) -e "s\" mach16l.fs\"" $(srcdir)/kernel/main.fs -e "save-cross kernl16l$(EC).fi- $(bindir)/gforth-$(VERSION) bye"
714
715kernl16b$(EC).fi-:	$(KERN_DEPS) mach16b.fs
716		$(PREFORTH) -e "s\" mach16b.fs\"" $(srcdir)/kernel/main.fs -e "save-cross kernl16b$(EC).fi- $(bindir)/gforth-$(VERSION) bye"
717
718kernl32l$(EC).fi-:	$(KERN_DEPS) mach32l.fs
719		$(PREFORTH) -e "s\" mach32l.fs\"" $(srcdir)/kernel/main.fs -e "save-cross kernl32l$(EC).fi- $(bindir)/gforth-$(VERSION) bye"
720
721kernl32b$(EC).fi-:	$(KERN_DEPS) mach32b.fs
722		$(PREFORTH) -e "s\" mach32b.fs\"" $(srcdir)/kernel/main.fs -e "save-cross kernl32b$(EC).fi- $(bindir)/gforth-$(VERSION) bye"
723
724kernl64l$(EC).fi-:	$(KERN_DEPS) mach64l.fs
725		$(PREFORTH) -e "s\" mach64l.fs\"" $(srcdir)/kernel/main.fs -e "save-cross kernl64l$(EC).fi- $(bindir)/gforth-$(VERSION) bye"
726
727kernl64b$(EC).fi-:	$(KERN_DEPS) mach64b.fs
728		$(PREFORTH) -e "s\" mach64b.fs\"" $(srcdir)/kernel/main.fs -e "save-cross kernl64b$(EC).fi- $(bindir)/gforth-$(VERSION) bye"
729
730#Solaris make does not like that:
731@GNUMAKE@kernl-%.fi:	arch/%/mach.fs arch/%/prim.fs arch/%/asm.fs $(KERN_SRC) kernel/version.fs $(FORTH_GEN0)
732@GNUMAKE@		$(PREFORTH) -e "s\" $<\"" $(srcdir)/kernel/main.fs -e "save-cross $@- $(bindir)/gforth-$(VERSION) bye"
733@GNUMAKE@		if [ -f `echo $< | sed s/fs/sh/` ]; \
734@GNUMAKE@		then sh `echo $< | sed s/fs/sh/` $@; \
735@GNUMAKE@		else $(CP) $@- $@; \
736@GNUMAKE@		fi
737
738#SunOS make does not like that
739#arch/%/mach.fs:	arch/%/prim.fs arch/%/asm.fs
740
741kernl16b$(EC).fi:	$(KERNLS)
742		-$(CP) kernl16b$(EC).fi kernl16b$(EC).fi~
743		-$(CP) kernl16b$(EC).fi- kernl16b$(EC).fi
744
745kernl16l$(EC).fi:	$(KERNLS)
746		-$(CP) kernl16l$(EC).fi kernl16l$(EC).fi~
747		-$(CP) kernl16l$(EC).fi- kernl16l$(EC).fi
748
749kernl32b$(EC).fi:	$(KERNLS)
750		-$(CP) kernl32b$(EC).fi kernl32b$(EC).fi~
751		-$(CP) kernl32b$(EC).fi- kernl32b$(EC).fi
752
753kernl32l$(EC).fi:	$(KERNLS)
754		-$(CP) kernl32l$(EC).fi kernl32l$(EC).fi~
755		-$(CP) kernl32l$(EC).fi- kernl32l$(EC).fi
756
757kernl64b$(EC).fi:	$(KERNLS)
758		-$(CP) kernl64b$(EC).fi kernl64b$(EC).fi~
759		-$(CP) kernl64b$(EC).fi- kernl64b$(EC).fi
760
761kernl64l$(EC).fi:	$(KERNLS)
762		-$(CP) kernl64l$(EC).fi kernl64l$(EC).fi~
763		-$(CP) kernl64l$(EC).fi- kernl64l$(EC).fi
764
765#kernl%.fi:	kernl%.fi- $(KERNLS)
766#		-$(CP) $@ $@~
767#		-$(CP) $< $@
768
769gforth.fi:	$(kernel_fi) gforthmi gforth-ditc$(EC)$(EXE) $(GFORTH_FI_SRC) comp-i.fs
770		GFORTHD="./gforth-ditc -p .$(PATHSEP)$(srcdir)" GFORTH="./gforth-ditc --die-on-signal -p .$(PATHSEP)$(srcdir) -i $(kernel_fi) $(STARTUP)" includedir=`pwd`/include bindir=`pwd` libccdir=`pwd`/lib/gforth/$(VERSION)/libcc-named/ ./gforthmi gforth.fi $(FORTHSIZES) $(FORTHKFLAGS) $(STARTUP)
771
772# -------------	Make c-engine
773
774prim.b:		prim cache0.vmg
775		(cd $(srcdir) && $(M4) -Dcondbranch_opt=0 prim) >$@
776		sleep 1 #should make hpux-workaround unnecessary
777
778prim-fast.b:	prim cache-fast$(STACK_CACHE_DEFAULT_FAST).vmg cache-regs$(STACK_CACHE_REGS).vmg peeprules.vmg Makefile
779		(cd $(srcdir) && $(M4) -Dcondbranch_opt=@condbranch_opt@ -DSTACK_CACHE_FILE=cache-fast$(STACK_CACHE_DEFAULT_FAST).vmg -DSTACK_CACHE_REGS=cache-regs$(STACK_CACHE_REGS).vmg prim) >$@
780		sleep 1 #should make hpux-workaround unnecessary
781
782$(FORTH_GEN_ENGINE_FAST): prim-fast.b prims2x.fs
783		GFORTH="$(PREFORTH)" $(srcdir)/gfgen -fast
784
785$(FORTH_GEN_ENGINE): prim.b prims2x.fs
786		GFORTH="$(PREFORTH)" $(srcdir)/gfgen
787
788engine/prim-s.i: engine/prim.i
789	grep -v '^#line ' $(srcdir)/engine/prim.i >$@
790
791kernel/aliases.fs:	prim.b prims2x.fs kernel/aliases0.fs
792		$(CP) kernel/aliases0.fs $@-
793		$(PREFORTH) prims2x.fs -e "forth-flag on s\" prim.b\" ' output-alias ' noop process-file bye" >>$@-
794		$(CP) $@- $@
795		$(RM) $@-
796
797kernel/prim.fs:	prim.b prims2x.fs kernel/prim0.fs
798		$(CP) kernel/prim0.fs kernel/prim.fs-
799		$(PREFORTH) prims2x.fs -e "forth-flag on s\" prim.b\" ' output-forth ' output-forth-combined process-file bye" >>$@-
800		$(CP) $@- $@
801		$(RM) $@-
802
803
804OPTS = @OPTS@
805
806MAKELINE-ll-reg   = OPT=-ll-reg OPTDEFINES="-DFORCE_LL -DFORCE_REG" OPTOBJECTS=
807MAKELINE-noll-reg = OPT=-noll-reg OPTDEFINES=-DFORCE_REG OPTOBJECTS=dblsub.o
808MAKELINE-ll       = OPT=-ll OPTDEFINES=-DFORCE_LL OPTOBJECTS=
809MAKELINE-noll     = OPT=-noll OPTDEFINES= OPTOBJECTS=dblsub.o
810
811gforth$(OPT)$(EC)$(EXE): $(ENGINE_SOURCES) $(FORTH_GEN_ENGINE) engine/config.h @kernel_anti_dependence@
812	if test -z "$(OPT)"; then \
813		for i in $(OPTS); do $(MAKE) optgforth OPT=$$i && $(CP) gforth$${i}$(EC)$(EXE) $@ && break; done; \
814	else \
815		( cd engine && $(MAKE) $@ ) && \
816		$(CP) engine\$@ $@ && \
817		$(MASSAGE_EXE) $@; \
818
819gforth:		gforth.exe; \
820		@NO_CHECK@$(MAKE) checkone check-nofast ENGINE=./engine\$@; \
821	fi
822
823optgforth.exe:
824	$(MAKE) gforth$(OPT)$(EC)$(EXE) $(MAKELINE$(OPT))
825
826gforth-fast$(OPT)$(EC)$(EXE): $(ENGINE_SOURCES) $(FORTH_GEN_ENGINE_FAST) engine/config.h
827	if test -z "$(OPT)"; then \
828		for i in $(OPTS); do $(MAKE) optgforth-fast OPT=$$i && $(CP) gforth-fast$${i}$(EC)$(EXE) $@ && break; done; \
829	else \
830		( cd engine && $(MAKE) $@ ) && \
831		$(CP) engine\$@ $@ && \
832		$(MASSAGE_EXE) $@; \
833		@GFORTHFAST_EXE@; \
834		@NO_CHECK@$(MAKE) checkone ENGINE=./engine\$@; \
835	fi
836
837optgforth-fast:
838	$(MAKE) gforth-fast$(OPT)$(EC)$(EXE) $(MAKELINE$(OPT))
839
840gforth-native$(OPT)$(EC)$(EXE):	engines-fast
841		$(CP) engine\$@ $@
842		-$(MASSAGE_EXE) $@
843#@GFORTHX_EXE@
844
845gforth-itc$(EC)$(EXE): $(ENGINE_SOURCES) $(FORTH_GEN_ENGINE) engine/Makefile engine/config.h
846		cd engine && $(MAKE) gforth-itc-noll$(EC)$(EXE) $(MAKELINE-noll)
847		$(CP) engine/gforth-itc-noll$(EC)$(EXE) $@
848		@GFORTHITC_EXE@
849
850gforth-ditc$(EC)$(EXE): $(ENGINE_SOURCES) $(FORTH_GEN_ENGINE) engine/Makefile engine/config.h
851		cd engine && $(MAKE) gforth-ditc-noll$(EC)$(EXE) $(MAKELINE-noll)
852		$(CP) engine/gforth-ditc-noll$(EC)$(EXE) $@
853
854gforth-ditc:		gforth-ditc.exe
855
856gforth-prof$(EC)$(EXE): $(ENGINE_SOURCES) $(FORTH_GEN_ENGINE) engine/Makefile engine/config.h
857		cd engine && $(MAKE) gforth-prof-noll$(EC)$(EXE) $(MAKELINE-noll)
858		$(CP) engine/gforth-prof-noll$(EC)$(EXE) $@
859
860gforths: $(ENGINES) $(ENGINES_FAST)
861
862# ------------- additional C primitives
863
864.SUFFIXES:	.c .pri
865
866.pri.c:		$< prim2cl.fs
867		$(FORTHK) prim2cl.fs -e "file $< altogether bye" >$@
868
869.c.so:		$<
870		$(GCC) -shared $(CFLAGS) $(CPPFLAGS) $< -o $@
871
872# -------------	Make Documentation
873
874#TAGS is a GNU standard target
875TAGS:		gforth.TAGS
876		$(CP) gforth.TAGS $@
877
878tags:		gforth.tags
879		$(CP) gforth.tags $@
880
881install.TAGS:	TAGS install-tags.fs
882		sed 's;^\$(srcdir)/;;' TAGS|./gforth -e "s\" '$(datadir)/gforth/$(VERSION)/'\"" $(srcdir)/install-tags.fs -e bye >install.TAGS
883
884gforth.TAGS:	kernl32l.fi gforth$(EC)$(EXE) $(GFORTH_FI_SRC) prim.TAGS kernel.TAGS
885		$(FORTHK) etags.fs except.fs startup.fs -e bye
886		cat TAGS prim.TAGS kernel.TAGS >gforth.TAGS
887		rm TAGS
888
889gforth.tags:	kernl32l.fi gforth$(EC)$(EXE) $(GFORTH_FI_SRC) prim.tags kernel.tags
890		$(FORTHK) tags.fs except.fs startup.fs -e bye
891		cat tags prim.tags kernel.tags >gforth.tags
892		rm tags
893
894prim.TAGS: 	prim.b prims2x.fs
895		$(PREFORTH) prims2x.fs -e "s\" $(srcdir)/prim.b\" ' output-tag dup process-file bye"|sed 's#^./prim#prim#' >$@-
896		$(CP) $@- $@
897		$(RM) $@-
898
899prim.tags: 	prim.b prims2x.fs
900		#echo '2c\' >prim.TAGS.sed
901		#echo $(srcdir)/prim >>prim.TAGS.sed
902		#$(PREFORTH) prims2x.fs -e "s\" $(srcdir)/prim.b\" ' output-tag dup process-file bye" | sed -f prim.TAGS.sed >$@-
903		$(PREFORTH) prims2x.fs -e "s\" $(srcdir)/prim.b\" ' output-vi-tag dup process-file bye" >$@-
904		$(CP) $@- $@
905		$(RM) $@-
906
907kernel.TAGS:
908		$(RM) kernl16l$(EC).fi-; $(MAKE) kernl32l.fi
909
910kernel.tags:
911		$(RM) kernl16l$(EC).fi-; $(MAKE) kernl32l.fi
912
913#elc files
914gforth.elc:	gforth.el
915		-$(EMACS) -batch -f batch-byte-compile gforth.el
916
917#Documentation
918
919doc/doc.fd:	doc/makedoc.fs $(GFORTH_FI_SRC) code.fs objects.fs oof.fs moofglos.fs
920		$(FORTHK) -e "s\" doc/doc.fd\"" doc/makedoc.fs except.fs startup.fs code.fs objects.fs oof.fs moofglos.fs regexp.fs fft.fs -e bye
921
922doc/crossdoc.fd:	$(KERN_SRC) kernel/version.fs $(FORTH_GEN0)
923		$(FORTHK) -e "s\" mach32l.fs\"" kernel/main.fs -e bye
924
925doc/gforth.texi: doc/gforth.ds prim.b ds2texi.fs prims2x.fs \
926		doc/doc.fd doc/crossdoc.fd
927		$(PREFORTH) ds2texi.fs prims2x.fs -e "s\" $(srcdir)/prim.b\" ' register-doc ' noop process-file" doc/crossdoc.fd doc/doc.fd -e "s\" $(srcdir)/doc/gforth.ds\" r/o open-file throw ds2texi bye" >$@-
928		$(CP) $@- $@
929		$(RM) $@-
930
931checkdoc:	doc/gforth.ds prim.b ds2texi.fs prims2x.fs doc/doc.fd doc/crossdoc.fd answords.fs doc/gforth.texi
932		$(FORTH) ds2texi.fs prims2x.fs -e "s\" $(srcdir)/prim.b\" ' register-doc ' noop process-file" doc/crossdoc.fd doc/doc.fd answords.fs -e bye
933		-grep unknown doc/gforth.texi
934		-grep doc- doc/gforth.texi| grep -v '^@c'
935
936dvi:		doc/gforth.dvi doc/vmgen.dvi
937
938pdf:		doc/gforth.pdf doc/vmgen.pdf
939
940doc/gforth.dvi doc/gforth.fns:	$(GFORTH_TEXI)
941		cd doc; $(TEXI2DVI) gforth.texi
942
943doc/gforth.pdf:	$(GFORTH_TEXI)
944		cd doc; $(TEXI2PDF) gforth.texi
945
946doc/vmgen.dvi:	$(VMGEN_TEXI)
947		cd doc; $(TEXI2DVI) vmgen.texi
948
949doc/vmgen.pdf:	$(VMGEN_TEXI)
950		cd doc; $(TEXI2PDF) vmgen.texi
951
952doc/gforth.ps:	doc/gforth.dvi
953		$(DVI2PS) doc/gforth.dvi -o $@
954
955doc/vmgen.ps:	doc/vmgen.dvi
956		$(DVI2PS) doc/vmgen.dvi -o $@
957
958info:		doc/gforth.info doc/vmgen.info
959
960doc/gforth.info: $(GFORTH_TEXI)
961		cd doc; $(MAKEINFO) gforth.texi
962
963doc/vmgen.info: $(VMGEN_TEXI)
964		cd doc; $(MAKEINFO) vmgen.texi
965
966
967### need makeinfo 4.2 to generate html with these rules
968doc/gforth.exe: $(GFORTH_TEXI)
969	cd doc; $(MAKEINFO) --html gforth.texi
970
971doc/vmgen: $(VMGEN_TEXI)
972	cd doc; $(MAKEINFO) --html vmgen.texi
973
974doc/gforth.txt:	$(GFORTH_TEXI)
975		-cd doc; $(MAKEINFO) --no-headers --no-split gforth.texi >gforth.txt
976
977doc/vmgen.txt:	$(VMGEN_TEXI)
978		-cd doc; $(MAKEINFO) --no-headers --no-split vmgen.texi >vmgen.txt
979
980doc:		gforth.fi info doc/gforth doc/vmgen doc/gforth.ps doc/vmgen.ps doc/gforth.txt doc/vmgen.txt TAGS
981
982# For an explanation of the following Makefile rules, see node
983# `Automatic Remaking' in GNU Autoconf documentation.
984
985#Note: no target "$(srcdir)/configure", because that does not trigger
986#unless $(srcdir)!="."
987configure: configure.in aclocal.m4
988	cd $(srcdir) && autoconf
989
990aclocal.m4:	configure.in
991		aclocal
992
993# autoheader might not change config.h.in, so touch a stamp file.
994engine/config.h.in: stamp-h.in
995stamp-h.in: configure.in aclocal.m4
996	cd $(srcdir) && autoheader
997	echo timestamp > $(srcdir)/stamp-h.in
998
999engine/config.h: stamp-h
1000stamp-h: engine/config.h.in config.status stamp-h.in
1001	./config.status
1002
1003Makefile Makedist engine/Makefile gforthmi vmgen preforth machpc.fs doc/version.texi envos.fs build-ec:	Makefile.in Makedist.in engine/Makefile.in gforthmi.in vmgen.in preforth.in machpc.fs.in doc/version.texi.in config.status configure.in envos.fs.in build-ec.in engine/libcc.h.in
1004	./config.status
1005
1006config.status: configure
1007	./config.status --recheck
1008
1009#create files for DOS, because DOS cannot do it itself
1010makefile.dos engine/makefile.dos: mkdosmf.sed Makefile.in engine/Makefile.in
1011	sed -f mkdosmf.sed <Makefile.in >makefile.dos
1012	sed -f mkdosmf.sed <engine/Makefile.in >engine/makefile.dos
1013
1014makefile.os2 engine/makefile.os2: mkos2mf.sed Makefile.in engine/Makefile.in
1015	sed -f mkos2mf.sed <Makefile.in >makefile.os2
1016	sed -f mkos2mf.sed <engine/Makefile.in >engine/makefile.os2
1017	echo '%.o:	%.c' >>makefile.os2
1018	echo '		$$(GCC) $$(CFLAGS) $$(CPPFLAGS) -c $$<' >>makefile.os2
1019	echo '%.o:	%.c' >>engine/makefile.os2
1020	echo '		$$(GCC) $$(CFLAGS) $$(CPPFLAGS) -c $$<' >>engine/makefile.os2
1021%.o:	%.c
1022		$(GCC) $(CFLAGS) $(CPPFLAGS) -c $<
1023