1#Makefile for the C part of Gforth 2 3#Copyright (C) 1995,1996,1997,1998,2000,2003,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# ------------- gforth version 21 22VERSION =@PACKAGE_VERSION@ 23DOSVERSION=`echo $VERSION|sed 's/\.//g'` 24EXE=@EXEEXT@ 25 26# ------------- System specific variables 27 28machine=@machine@ 29kernel_fi = @kernel_fi@ 30include_fi = @include_fi@ 31# this is the type of machine 32# used to extend the include path with ./arch/$machine 33# so we could include a machine specific 34# machine.h file 35 36PATHSEP = @PATHSEP@ 37 38osclass = @OSCLASS@ 39 40EC = @EC@ 41 42# ------------- Utility programs 43 44SHELL = /bin/sh 45RM = rm 46RMTREE = rm -rf 47CP = cp -p 48TAR = tar cf - 49GCC = @CC@ 50BOOTFORTH = ../preforth 51CC = $(GCC) 52LD = $(GCC:gcc=ld) 53AS = $(GCC:gcc=as) 54STRIP = strip 55GCCLD = @GCC_LD@ 56 57FORTHPATH = .$(PATHSEP)$(libdir)/gforth/site-forth$(PATHSEP)$(datadir)/gforth/site-forth$(PATHSEP)$(libdir)/gforth/$(VERSION)$(PATHSEP)$(datadir)/gforth/$(VERSION) 58 59# ------------ Source and Build directories 60 61top_srcdir = @top_srcdir@ 62top_builddir = @top_builddir@ 63 64# ------------ Install directories 65 66VPATH = @srcdir@ 67prefix = @prefix@ 68exec_prefix = @exec_prefix@ 69srcdir = @srcdir@ 70bindir = @bindir@ 71#read-only architecture-independent files 72datadir = @datadir@ 73#read-only architecture-dependent non-ascii files 74libdir = @libdir@ 75infodir = @infodir@ 76mandir = @mandir@ 77man1dir= $(mandir)/man1 78man1ext= .1 79 80# ------------- ltdl variables 81 82LTDLDEPS = @LTDLDEPS@ 83LTDLINCL = @LTDLINCL@ 84LIBLTDL = @LIBLTDL@ 85 86# ------------- Compiler Flags 87 88XCFLAGS = @CFLAGS@ 89XDEFINES = @DEFS@ 90SWITCHES = $(XCFLAGS) $(XDEFINES) $(OPTDEFINES) 91#use -fno-inline to avoid register problems with asinh, atanh on gcc-3.3 on 386 92ENGINE_FLAGS = @ENGINE_FLAGS@ -fno-defer-pop -fcaller-saves -fno-inline -fno-reorder-blocks 93DEBUGFLAG = @DEBUGFLAG@ 94CFLAGS = $(DEBUGFLAG) -I$(srcdir)/../arch/$(machine) -I. -Wall $(SWITCHES) -DDEFAULTPATH='"$(FORTHPATH)"' $(LTDLINCL) 95CFLAGS2 = $(DEBUGFLAG) -I$(srcdir)/../arch/$(machine) -I. -Wall $(SWITCHES) -DDEFAULTPATH='"$(FORTHPATH)"' $(LTDLINCL) 96CPPFLAGS=@CPPFLAGS@ 97FORTHKFLAGS= --die-on-signal -p "..$(PATHSEP)$(srcdir)" -i ../$(kernel_fi) 98FORTHK = ../gforth $(FORTHKFLAGS) 99FORTH = $(BOOTFORTH) --die-on-signal 100 101#John Wavrik should use -Xlinker -N to get a writable text (executable) 102XLDFLAGS = @LDFLAGS@ 103LDFLAGS = $(DEBUGFLAG) $(XLDFLAGS) 104LDLIBS = @LIBS@ @LTDL_LDLIBS@ 105 106AOBJECTS = @signals_o@ support$(OPT).o @LIBOBJS@ $(OPTOBJECTS) 107 108@MAKEINC@ 109 110OBJECTS = engine$(OPT).o @engine2@ main$(OPT).o 111OBJECTS_NATIVE = engine-native$(OPT).o engine-native2$(OPT).o engine-native3$(OPT).o main-native$(OPT).o 112OBJECTS_FAST = engine-fast$(OPT).o @engine_fast2@ main-fast$(OPT).o 113OBJECTS_ITC = engine-itc$(OPT).o main-itc$(OPT).o 114OBJECTS_DITC = engine-ditc$(OPT).o main-ditc$(OPT).o 115OBJECTS_PROF = engine-prof$(OPT).o main-prof$(OPT).o 116OBJECTS_FI = engine$(OPT).o main-fi$(OPT).o 117 118# In engine subdirectory there are (or should be) only files that belong to 119# our engine, so we can make life easy 120DEPS = config.h forth.h io.h $(srcdir)/../arch/$(machine)/*.[h] 121ENGINE_DEPS = engine.c $(DEPS) prim_lab.i prim.i @image_i@ fnmatch.h threaded.h 122MAIN_DEPS = main.c $(DEPS) prim_superend.i prim_num.i prim_grp.i costs.i super2.i 123ENGINE_FAST_DEPS = engine.c $(DEPS) prim_lab-fast.i prim-fast.i fnmatch.h threaded.h 124MAIN_FAST_DEPS = main.c $(DEPS) prim_superend-fast.i prim_num-fast.i prim_grp-fast.i costs-fast.i super2-fast.i 125 126#some makes don't do the -o $@ correctly, so we help them 127.c.o: 128 $(GCC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< 129 130.s.o: 131 $(GCC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< 132 133support$(OPT).o: support.c config.h forth.h longlong.h 134 $(GCC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $(srcdir)/support.c 135 136strtol.o: strtol.c ansidecl.h 137 138fnmatch.o: fnmatch.c fnmatch.h 139 140getopt1.o: getopt1.c getopt.h 141 142getopt.o: getopt.c getopt.h 143 144gforth$(OPT)$(EC)$(EXE): $(OBJECTS) $(AOBJECTS) $(LTDLDEPS) 145 $(GCCLD) $(LDFLAGS) $(OBJECTS) $(AOBJECTS) $(LDLIBS) -o $@ 146 147gforth-native$(OPT)$(EC)$(EXE): $(OBJECTS_NATIVE) $(AOBJECTS) $(LTDLDEPS) 148 $(GCCLD) $(LDFLAGS) $(OBJECTS_NATIVE) $(AOBJECTS) $(LDLIBS) -o $@ 149 150gforth-fast$(OPT)$(EC)$(EXE): $(OBJECTS_FAST) $(AOBJECTS) $(LTDLDEPS) 151 $(GCCLD) $(LDFLAGS) $(OBJECTS_FAST) $(AOBJECTS) $(LDLIBS) -o $@ 152 153gforth-itc$(OPT)$(EC)$(EXE): $(OBJECTS_ITC) $(AOBJECTS) $(LTDLDEPS) 154 $(GCCLD) $(LDFLAGS) $(OBJECTS_ITC) $(AOBJECTS) $(LDLIBS) -o $@ 155 156gforth-ditc$(OPT)$(EC)$(EXE): $(OBJECTS_DITC) $(AOBJECTS) $(LTDLDEPS) 157 $(GCCLD) $(LDFLAGS) $(OBJECTS_DITC) $(AOBJECTS) $(LDLIBS) -o $@ 158 159gforth-prof$(OPT)$(EC)$(EXE): $(OBJECTS_PROF) $(AOBJECTS) $(LTDLDEPS) profile$(OPT).o 160 $(GCCLD) $(LDFLAGS) $(OBJECTS_PROF) $(AOBJECTS) profile$(OPT).o $(LDLIBS) -o $@ 161 162gforth-fi$(OPT)$(EC)$(EXE): $(OBJECTS_FI) $(AOBJECTS) $(LTDLDEPS) 163 $(GCCLD) $(LDFLAGS) $(OBJECTS_FI) $(AOBJECTS) $(LDLIBS) -o $@ 164 165engine.s: $(ENGINE_FAST_DEPS) 166 $(GCC) $(CFLAGS2) $(CPPFLAGS) $(ENGINE_FLAGS) -S $(srcdir)/engine.c 167 168engine$(OPT).o: $(ENGINE_DEPS) 169 $(GCC) $(CFLAGS2) $(CPPFLAGS) $(ENGINE_FLAGS) -DGFORTH_DEBUGGING -o $@ -c $(srcdir)/engine.c 170 171engine2$(OPT).o: $(ENGINE_DEPS) 172 $(GCC) $(CFLAGS2) $(CPPFLAGS) $(ENGINE_FLAGS) -DGFORTH_DEBUGGING -DENGINE=2 -o $@ -c $(srcdir)/engine.c 173 174engine-native$(OPT).o:$(ENGINE_FAST_DEPS) 175 $(GCC) $(CFLAGS2) $(CPPFLAGS) $(ENGINE_FLAGS) -DNO_IP -o $@ -c $(srcdir)/engine.c 176 177engine-native2$(OPT).o:$(ENGINE_FAST_DEPS) 178 $(GCC) $(CFLAGS2) $(CPPFLAGS) $(ENGINE_FLAGS) -DNO_IP -DENGINE=2 -o $@ -c $(srcdir)/engine.c 179 180engine-native3$(OPT).o:$(ENGINE_FAST_DEPS) 181 $(GCC) $(CFLAGS2) $(CPPFLAGS) $(ENGINE_FLAGS) -DNO_IP -DENGINE=3 -o $@ -c $(srcdir)/engine.c 182 183engine-fast$(OPT).o: $(ENGINE_FAST_DEPS) 184 $(GCC) $(CFLAGS2) $(CPPFLAGS) $(ENGINE_FLAGS) -o $@ -c $(srcdir)/engine.c 185 186engine-fast2$(OPT).o: $(ENGINE_FAST_DEPS) 187 $(GCC) $(CFLAGS2) $(CPPFLAGS) $(ENGINE_FLAGS) -DENGINE=2 -o $@ -c $(srcdir)/engine.c 188 189engine-itc$(OPT).o: $(ENGINE_DEPS) 190 $(GCC) $(CFLAGS2) $(CPPFLAGS) $(ENGINE_FLAGS) -DINDIRECT_THREADED -DGFORTH_DEBUGGING -o $@ -c $(srcdir)/engine.c 191 192engine-ditc$(OPT).o: $(ENGINE_DEPS) 193 $(GCC) $(CFLAGS2) $(CPPFLAGS) $(ENGINE_FLAGS) -DDOUBLY_INDIRECT -o $@ -c $(srcdir)/engine.c 194 195engine-prof$(OPT).o: $(ENGINE_DEPS) 196 $(GCC) $(CFLAGS2) $(CPPFLAGS) $(ENGINE_FLAGS) -DVM_PROFILING -o $@ -c $(srcdir)/engine.c 197 198main$(OPT).o: $(MAIN_DEPS) 199 $(GCC) $(CFLAGS) $(CPPFLAGS) -DGFORTH_DEBUGGING @no_dynamic@ -o $@ -c $(srcdir)/main.c 200 201main-native$(OPT).o: $(MAIN_FAST_DEPS) 202 $(GCC) $(CFLAGS) $(CPPFLAGS) -DNO_IP -o $@ -c $(srcdir)/main.c 203 204main-fast$(OPT).o: $(MAIN_FAST_DEPS) 205 $(GCC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $(srcdir)/main.c 206 207main-itc$(OPT).o: $(MAIN_DEPS) 208 $(GCC) $(CFLAGS) $(CPPFLAGS) -DINDIRECT_THREADED -DGFORTH_DEBUGGING -o $@ -c $(srcdir)/main.c 209 210main-ditc$(OPT).o: $(MAIN_DEPS) 211 $(GCC) $(CFLAGS) $(CPPFLAGS) -DDOUBLY_INDIRECT -o $@ -c $(srcdir)/main.c 212 213main-prof$(OPT).o: $(MAIN_DEPS) 214 $(GCC) $(CFLAGS) $(CPPFLAGS) -DVM_PROFILING -o $@ -c $(srcdir)/main.c 215 216main-fi$(OPT).o: $(MAIN_DEPS) 217 $(GCC) $(CFLAGS) $(CPPFLAGS) -DINCLUDE_IMAGE -o $@ -c $(srcdir)/main.c 218 219peephole$(OPT).o: peephole.c peephole.i $(DEPS) 220 $(GCC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $(srcdir)/peephole.c 221 222profile$(OPT).o: profile.c profile.i $(DEPS) 223 $(GCC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $(srcdir)/profile.c 224 225#The next two rules seem to be superfluous: 226 227# engine: $(OBJECTS) $(OBJECTS0) ; 228 229# engine_ditc: $(OBJECTS_DITC) $(OBJECTS0) ; 230 231#NeXTstep hack 232 233termios.o: /usr/lib/libposix.a 234 ar x /usr/lib/libposix.a termios.o 235 236#duplicated rules to avoid too many recursive make invocations 237# !! No any forth stuff should be done in ../Makefile. 238# !! I added the dependencies on prim.i and prim_lab.i in the main Makefile, jens 239 240#I commented out the following rules because they are no longer up-to-date. - anton 241 242#prim.i: ../prim.b ../prims2x.fs 243# $(FORTHK) prims2x.fs -e "s\" ../prim.b\" ' output-c process-file bye" >$@- 244# $(CP) $@- $@ 245# $(RM) $@- 246# 247#prim_lab.i: ../prim.b ../prims2x.fs 248# $(FORTHK) prims2x.fs -e "s\" ../prim.b\" ' output-label process-file bye" >$@- 249# $(CP) $@- $@ 250# $(RM) $@- 251 252config.h: stamp-h 253stamp-h: config.h.in ../config.status ../stamp-h.in 254 cd .. && CONFIG_FILES=$@ CONFIG_HEADERS=engine/config.h ./config.status 255 echo timestamp > stamp-h 256 257Makefile: Makefile.in ../config.status ../configure.in 258 cd .. && $(MAKE) engine/Makefile.in 259 260image.i: ../fi2c.fs ../$(include_fi) 261 $(BOOTFORTH) ../fi2c.fs -e "s\" ../$(include_fi)\" fi2c bye" >$@ 262 263../$(include_fi): FORCE 264 cd .. && $(MAKE) $(include_fi) 265 266#phony targets depend on FORCE; this is more portable than .PHONY 267FORCE: 268 269