Root/gforth/Makefile

Source at commit 23955b4887f6ae2c38cf27c7603d7b1acc048893 created 10 years 8 months ago.
By David Kühling, fixed various major and minor build problems. Host forth build dependency now fixed? Added comments about what we're actually doing
1# Makefile for OpenWRT for cross-compiling GForth
2#
3# Copyright (C) 2010 David Kühling. License: GPLv2+
4
5include $(TOPDIR)/rules.mk
6
7PKG_NAME:=gforth
8PKG_VERSION:=0.7.0-20100725
9PKG_RELEASE:=4
10
11PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
12PKG_SOURCE_URL:=http://mosquito.dyndns.tv/~spock/
13PKG_MD5SUM:=f030bdfe42a9be32889d5b4c8cb37856
14
15PKG_BUILD_DEPENDS:= gforth/host libltdl/host
16PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
17
18include $(INCLUDE_DIR)/host-build.mk
19include $(INCLUDE_DIR)/package.mk
20
21# for now: override download and use local gforth sources
22# remove the prepare.stamp if updating tgz
23# define Build/Prepare
24# mkdir -p $(PKG_BUILD_DIR)
25# (cd $(PKG_BUILD_DIR)/.. && tar -xzvf -) < ~/forth/gforth/$(PKG_SOURCE)
26# endef
27# define Host/Prepare
28# mkdir -p $(HOST_BUILD_DIR)
29# (cd $(HOST_BUILD_DIR)/.. && tar -xzvf -) < ~/forth/gforth/$(PKG_SOURCE)
30# endef
31
32define Package/gforth
33  SECTION:=lang
34  CATEGORY:=Languages
35  TITLE:=GForth
36  DEPENDS:= +libltdl
37  URL:=http://www.gnu.org/software/gforth/
38endef
39
40define Package/gforth/description
41  Gforth is a fast and portable implementation of the ANS Forth
42  language.
43endef
44
45HOST_CONFIGURE_VARS += LTDL_LIBRARY_PATH=$(STAGING_DIR_HOST)/lib
46
47## The host-GForth uses -ltdl to link against the staging dir version of
48## libltdl. However, when the host-GForth runs, it won't find that library,
49## as no library path is encoded into the ltdl dependency (why?). So here we
50## override LD_LIBRARY_PATH for all the build steps that might run the
51## host-GForth.
52
53define Host/Configure
54    export LD_LIBRARY_PATH=$(STAGING_DIR_HOST)/lib; \
55    $(call Host/Configure/Default)
56endef
57
58define Host/Compile
59    export LD_LIBRARY_PATH=$(STAGING_DIR_HOST)/lib; \
60    $(call Host/Compile/Default)
61endef
62
63define Host/Install
64    export LD_LIBRARY_PATH=$(STAGING_DIR_HOST)/lib; \
65    $(call Host/Install/Default)
66endef
67
68# todo: skipcode=
69# todo: compiler options / tuning (openwrt sets bad defaults?)
70# todo: either gcc 3.4 or -Os makes primitives use doubly-indirect dispatch :(
71
72CROSS_PREFORTH=$(PKG_BUILD_DIR)/preforth
73
74## here we call configure, then patch the cross-GForth source tree to replace
75## the 'preforth' script with a script that calls our host-compiled GForth
76define Build/Configure
77    $(call Build/Configure/Default,)
78    echo "#!/bin/sh" > $(CROSS_PREFORTH)
79    echo "export LD_LIBRARY_PATH=$(STAGING_DIR_HOST)/lib;" >> $(CROSS_PREFORTH)
80    echo '$(STAGING_DIR_HOST)/bin/gforth -i $(STAGING_DIR_HOST)/lib/gforth/$(PKG_VERSION)/gforth.fi "$$$$@"' >> $(CROSS_PREFORTH)
81    chmod a+x $(PKG_BUILD_DIR)/preforth
82endef
83
84## Compilation is pretty manual to only build the parts we need. By default
85## the GForth Makefile attempts to auto-tune by recursively calling itself for
86## compilation, then running the GForth binary through unit-tests. This won't
87## work with a cross-compile environment
88define Build/Compile
89    $(MAKE) -C $(PKG_BUILD_DIR) kernel/version.fs gforth-ditc \
90        engine/prim-fast.i engine/prim_lab-fast.i engine/prim_names-fast.i \
91        engine/prim_superend-fast.i engine/profile-fast.i \
92        engine/prim_num-fast.i engine/prim_grp-fast.i \
93        engine/costs-fast.i engine/super2-fast.i
94    $(MAKE) -C $(PKG_BUILD_DIR)/engine gforth-fast-ll-reg gforth-ll-reg \
95        OPT=-ll-reg OPTDEFINES="-DFORCE_LL -DFORCE_REG" OPTOBJECTS=
96    cd $(PKG_BUILD_DIR) && \
97            cp engine/gforth-ll-reg ./gforth && \
98        cp engine/gforth-fast-ll-reg ./gforth-fast
99endef
100
101##
102## define lists of GForth's sources to package for loading in the target system
103##
104
105STARTUP = exboot.fs startup.fs arch/mips/asm.fs arch/mips/disasm.fs
106
107GFORTH_FI_SRC = \
108    assert.fs \
109    backtrac.fs \
110    blocked.fb \
111    blocks.fs \
112    bufio.fs \
113    code.fs \
114    debug.fs \
115    debugs.fs \
116    dis-gdb.fs \
117    ekey.fs \
118    envos.fs \
119    savesys.fs \
120    environ.fs \
121    errors.fs \
122    exboot.fs \
123    except.fs \
124    extend.fs \
125    float.fs \
126    glocals.fs \
127    hash.fs \
128    history.fs \
129    intcomp.fs \
130    mkdir.fs \
131    libcc.fs \
132    locals.fs \
133    look.fs \
134    mkdir.fs \
135    prelude.fs \
136    quotes.fs \
137    search.fs \
138    see.fs \
139    see-ext.fs \
140    simp-see.fs \
141    source.fs \
142    startup.fs \
143    struct.fs \
144    struct0x.fs \
145    stuff.fs \
146    tasker.fs \
147    termsize.fs \
148    utf-8.fs \
149    vt100.fs \
150    vt100key.fs \
151    wordinfo.fs \
152    arch/mips/asm.fs arch/mips/disasm.fs arch/mips/insts.fs \
153    arch/mips/testasm.fs arch/mips/testdisasm.fs
154
155LIBCC_SRC = cstr.fs unix/socket.fs
156LIBCC_DIST_SRC = libffi.fs fflib.fs $(LIBCC_SRC)
157
158# todo: strip down
159FORTH_SRC = $(GFORTH_FI_SRC) $(LIBCC_DIST_SRC) \
160    ans-report.fs ansi.fs answords.fs \
161    colorize.fs comp-i.fs complex.fs \
162    depth-changes.fs dosekey.fs doskey.fs ds2texi.fs \
163    envos.dos envos.os2 etags.fs fft.fs filedump.fs fi2c.fs \
164    fsl-util.4th glosgen.fs gray.fs httpd.fs install-tags.fs \
165    make-app.fs doc/makedoc.fs locate.fs more.fs onebench.fs \
166    other.fs prims2x.fs prims2x0.6.2.fs proxy.fs random.fs \
167    regexp.fs sokoban.fs string.fs table.fs tags.fs \
168    tt.fs \
169    unbuffer.fs wordsets.fs xwords.fs \
170    test/tester.fs test/ttester.fs \
171    test/coretest.fs test/postpone.fs test/dbltest.fs \
172    test/string.fs test/float.fs test/search.fs test/gforth.fs \
173    test/other.fs test/signals.fs test/checkans.fs \
174    test/primtest.fs test/coreext.fs test/deferred.fs \
175    test/coremore.fs test/gforth-nofast.fs test/libcc.fs \
176    test/macros.fs \
177    compat/strcomp.fs \
178    bubble.fs siev.fs matrix.fs fib.fs \
179    oof.fs oofsampl.fs objects.fs objexamp.fs mini-oof.fs moof-exm.fs \
180    moofglos.fs fixpath.fs \
181    add.fs lib.fs oldlib.fs sieve.fs \
182    endtry-iferror.fs recover-endtry.fs
183
184FS_INSTALL_DIR=/usr/share/gforth/$(PKG_VERSION)
185
186define Package/gforth/install
187    $(INSTALL_DIR) $(1)/usr/bin
188    $(INSTALL_DIR) $(1)/usr/lib/gforth
189    $(INSTALL_DIR) $(1)/$(FS_INSTALL_DIR)
190    $(INSTALL_DIR) $(1)/usr/share/gforth/site-forth
191    $(INSTALL_BIN) $(PKG_BUILD_DIR)/gforth-fast $(1)/usr/bin/gforth-fast-bin
192    $(INSTALL_BIN) $(PKG_BUILD_DIR)/gforth $(1)/usr/bin/gforth-bin
193    $(INSTALL_BIN) files/gforth $(1)/usr/bin/gforth
194    $(INSTALL_BIN) files/gforth $(1)/usr/bin/gforth-fast
195    $(INSTALL_DATA) $(PKG_BUILD_DIR)/kernl32l.fi $(1)/$(FS_INSTALL_DIR)
196    $(INSTALL_DATA) $(PKG_BUILD_DIR)/siteinit.fs $(1)/usr/share/gforth/site-forth
197    $(call pkg_install_files,$(FORTH_SRC),$(PKG_BUILD_DIR),$(1)/$(FS_INSTALL_DIR))
198endef
199
200$(eval $(call HostBuild))
201$(eval $(call BuildPackage,gforth))
202

Archive Download this file



interactive