gforth/Makefile |
2 | 2 | # |
3 | 3 | # Copyright (C) 2010 David Kühling. License: GPLv2+ |
4 | 4 | |
| 5 | ## Note for tuning: In theory you could strip down the resulting packages size |
| 6 | ## a lot, if you removed gforth and gforth-fast executables and only included |
| 7 | ## the (somewhat slower) gforth-itc and/or gforth-ditc interpreter binary that |
| 8 | ## rely on classic indirect threaded code without the (code-bloating) engine |
| 9 | ## optimizations. |
| 10 | ## |
| 11 | ## Also we could create multiple packages here 'gforth-minimal' and 'gforth'? |
| 12 | |
5 | 13 | include $(TOPDIR)/rules.mk |
6 | 14 | |
7 | 15 | PKG_NAME:=gforth |
8 | 16 | PKG_VERSION:=0.7.0-20100725 |
9 | | PKG_RELEASE:=4 |
| 17 | PKG_RELEASE:=5 |
10 | 18 | |
11 | 19 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz |
12 | 20 | PKG_SOURCE_URL:=http://mosquito.dyndns.tv/~spock/ |
... | ... | |
69 | 77 | # todo: compiler options / tuning (openwrt sets bad defaults?) |
70 | 78 | # todo: either gcc 3.4 or -Os makes primitives use doubly-indirect dispatch :( |
71 | 79 | |
72 | | CROSS_PREFORTH=$(PKG_BUILD_DIR)/preforth |
| 80 | ## Configuration of the target gforth |
| 81 | FORTHSIZES=--dictionary-size=1M \ |
| 82 | --data-stack-size=16k \ |
| 83 | --fp-stack-size=16k \ |
| 84 | --return-stack-size=16k \ |
| 85 | --locals-stack-size=16k |
| 86 | |
| 87 | CROSS_CONFIGURE_VARS += FORTHSIZES="$(FORTHSIZES)" \ |
| 88 | skipcode=".skip 16" |
73 | 89 | |
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 |
| 90 | CROSS_PREFORTH = $(PKG_BUILD_DIR)/preforth |
| 91 | |
| 92 | ## Here we call configure, then patch the cross-GForth source tree to replace |
| 93 | ## the 'preforth' script with a script that calls our host-compiled GForth. |
| 94 | ## We also extract the name of the GForth kernel image used for the target |
| 95 | ## architecture. |
76 | 96 | define Build/Configure |
77 | 97 | $(call Build/Configure/Default,) |
| 98 | echo "@kernel_fi@" > $(PKG_BUILD_DIR)/kernel_fi.in |
| 99 | cd $(PKG_BUILD_DIR) && ./config.status --file kernel_fi |
78 | 100 | echo "#!/bin/sh" > $(CROSS_PREFORTH) |
79 | 101 | echo "export LD_LIBRARY_PATH=$(STAGING_DIR_HOST)/lib;" >> $(CROSS_PREFORTH) |
80 | 102 | echo '$(STAGING_DIR_HOST)/bin/gforth -i $(STAGING_DIR_HOST)/lib/gforth/$(PKG_VERSION)/gforth.fi "$$$$@"' >> $(CROSS_PREFORTH) |
... | ... | |
84 | 106 | ## Compilation is pretty manual to only build the parts we need. By default |
85 | 107 | ## the GForth Makefile attempts to auto-tune by recursively calling itself for |
86 | 108 | ## compilation, then running the GForth binary through unit-tests. This won't |
87 | | ## work with a cross-compile environment |
| 109 | ## work with a cross-compile environment. |
| 110 | ## |
| 111 | ## todo: find out the correct kernel image and rename it 'kernel.fi', so we |
| 112 | ## can find it without adapting postinst script. |
88 | 113 | define Build/Compile |
89 | 114 | $(MAKE) -C $(PKG_BUILD_DIR) kernel/version.fs gforth-ditc \ |
90 | 115 | engine/prim-fast.i engine/prim_lab-fast.i engine/prim_names-fast.i \ |
... | ... | |
155 | 180 | LIBCC_SRC = cstr.fs unix/socket.fs |
156 | 181 | LIBCC_DIST_SRC = libffi.fs fflib.fs $(LIBCC_SRC) |
157 | 182 | |
158 | | # todo: strip down |
159 | | FORTH_SRC = $(GFORTH_FI_SRC) $(LIBCC_DIST_SRC) \ |
| 183 | # todo: strip down (really?) |
| 184 | GFORTH_SRC = $(GFORTH_FI_SRC) $(LIBCC_DIST_SRC) \ |
160 | 185 | ans-report.fs ansi.fs answords.fs \ |
161 | 186 | colorize.fs comp-i.fs complex.fs \ |
162 | 187 | depth-changes.fs dosekey.fs doskey.fs ds2texi.fs \ |
... | ... | |
181 | 206 | add.fs lib.fs oldlib.fs sieve.fs \ |
182 | 207 | endtry-iferror.fs recover-endtry.fs |
183 | 208 | |
184 | | FS_INSTALL_DIR=/usr/share/gforth/$(PKG_VERSION) |
| 209 | GFORTH_BIN = gforth gforth-fast gforthmi |
| 210 | |
| 211 | GFORTH_SHARE_DIR = /usr/share/gforth/$(PKG_VERSION) |
| 212 | GFORTH_LIB_DIR = /usr/lib/gforth/$(PKG_VERSION) |
| 213 | GFORTH_BIN_DIR = /usr/bin |
185 | 214 | |
| 215 | ## Select files for package. Note how we rename the GForth kernel image to |
| 216 | ## 'kernel.fi' here, so that 'postinst' can refer to it without depending on |
| 217 | ## architecture-specific naming. |
186 | 218 | define 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)) |
| 219 | $(INSTALL_DIR) $(1)/$(GFORTH_BIN_DIR) |
| 220 | $(INSTALL_DIR) $(1)/$(GFORTH_SHARE_DIR) |
| 221 | $(INSTALL_DIR) $(1)/$(GFORTH_LIB_DIR) |
| 222 | $(INSTALL_DIR) $(1)/$(GFORTH_SHARE_DIR)/../site-forth |
| 223 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/$$$$(cat $(PKG_BUILD_DIR)/kernel_fi) $(1)/$(GFORTH_SHARE_DIR)/kernel.fi |
| 224 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/gforth-ditc $(1)/$(GFORTH_LIB_DIR)/ |
| 225 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/siteinit.fs $(1)/$(GFORTH_SHARE_DIR)/../site-forth/ |
| 226 | $(call pkg_install_bin,$(GFORTH_BIN),$(PKG_BUILD_DIR),$(1)/$(GFORTH_BIN_DIR)) |
| 227 | $(call pkg_install_files,$(GFORTH_SRC),$(PKG_BUILD_DIR),$(1)/$(GFORTH_SHARE_DIR)) |
| 228 | endef |
| 229 | |
| 230 | FORTHKFLAGS= --die-on-signal -i kernel.fi |
| 231 | |
| 232 | ## Directly after installation load the source once and generate a |
| 233 | ## corresponding interpreter image. GForth needs that for quick startup. |
| 234 | define Package/gforth/postinst |
| 235 | #! /bin/sh |
| 236 | echo "Creating GForth interpreter image..." |
| 237 | export GFORTH="$(GFORTH_BIN_DIR)/gforth $(FORTHSIZES) $(FORTHKFLAGS) $(STARTUP)" |
| 238 | gforthmi $(GFORTH_LIB_DIR)/gforth.fi $(FORTHSIZES) $(FORTHKFLAGS) $(STARTUP) |
| 239 | endef |
| 240 | |
| 241 | define Package/gforth/prerm |
| 242 | #! /bin/sh |
| 243 | rm -f $(GFORTH_LIB_DIR)/gforth.fi |
198 | 244 | endef |
199 | 245 | |
200 | 246 | $(eval $(call HostBuild)) |