From e9233b471260d849ac8ef2fb57754bb7a4b7a9ea Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 15 May 2013 21:14:06 +0100 Subject: [PATCH] Build ego. --HG-- branch : dtrg-buildsystem rename : util/arch/build.mk => util/ego/build.mk --- Makefile | 1 + config.pm | 2 +- lib/descr/fe | 6 +- plat/build.mk | 4 + util/ego/build.mk | 205 +++++++++++++++++++++++++++++++++++++++ util/ego/cf/cf_loop.c | 1 + util/ego/cs/cs_alloc.c | 1 + util/ego/il/il1_aux.c | 1 + util/ego/il/il2_aux.c | 1 + util/ego/il/il3_change.c | 1 + util/ego/il/il_aux.c | 1 + util/ego/ra/ra_interv.c | 1 + util/ego/ra/ra_pack.c | 1 + util/ego/share/locals.c | 1 + util/ego/share/lset.c | 1 + util/ego/share/put.c | 1 + util/ego/sr/sr_reduce.c | 1 + 17 files changed, 226 insertions(+), 4 deletions(-) create mode 100644 util/ego/build.mk diff --git a/Makefile b/Makefile index 4188b584e..2d78f03d9 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,7 @@ include util/arch/build.mk include util/misc/build.mk include util/led/build.mk include util/topgen/build.mk +include util/ego/build.mk include lang/cem/build.mk include lang/basic/build.mk diff --git a/config.pm b/config.pm index 1d59b7f0c..79dc7c55a 100644 --- a/config.pm +++ b/config.pm @@ -13,7 +13,7 @@ ACK_TEMP_DIR = "/tmp" -- Where is the ACK going to be installed, eventually? -PREFIX = "/usr/local" +PREFIX = "/tmp/ack-temp/staging" -- ======================================================================= -- -- BROKEN ACK CONFIGURATION -- diff --git a/lib/descr/fe b/lib/descr/fe index 96a03ee8f..a8d610362 100644 --- a/lib/descr/fe +++ b/lib/descr/fe @@ -172,7 +172,7 @@ var A68INIT={EM}/lib/ack/em_a68s_init name a68s from .8.a68 to .k - program {EM}/lib.bin/em_a68s{w}{p} + program {EM}/lib/ack/em_a68s{w}{p} mapflag -PA* A68INIT=* args < > {SOURCE}.lst {A68INIT}{w}{p} /dev/null prep cond @@ -226,8 +226,8 @@ name ego mapflag -a EGO_F={EGO_F?} -a mapflag -O* EGO_F={EGO_F?} -O* args \ - {EGO_F?} -P {EM}/lib.bin/ego \ - -M{EM}/lib.bin/ego/{ARCH}descr < + {EGO_F?} -P {EM}/lib/ack/ego \ + -M{EM}/share/ack/ego/{ARCH}.descr < optimizer 2 stdout combiner diff --git a/plat/build.mk b/plat/build.mk index 89acb8c2e..aff84c04c 100644 --- a/plat/build.mk +++ b/plat/build.mk @@ -57,6 +57,10 @@ define build-platform-impl # Language runtimes $(foreach runtime, $(RUNTIMES), $(build-runtime-$(runtime))) + + # Install the ego descr file for this architecture + + $(call build-ego-descr) endef build-platform = $(eval $(call build-platform-impl, $1)) diff --git a/util/ego/build.mk b/util/ego/build.mk new file mode 100644 index 000000000..ee1e7f865 --- /dev/null +++ b/util/ego/build.mk @@ -0,0 +1,205 @@ +D := util/ego + +define build-ego-backend-impl + +$(call reset) +$(eval cflags += -DVERBOSE -DNOTCOMPACT) +$(eval cflags += -I$D/share -I$(OBJDIR)/$D) +$(foreach f, $2, $(call cfile, $f)) +$(call file, $(LIBDIR)/libegocore.a) +$(call file, $(LIBEM_DATA)) +$(call cprogram, $(BINDIR)/ego/$(strip $1)) +$(call installto, $(PLATDEP)/ego/$(strip $1)) +$(eval EGO_MODULES += $q) + +endef + +define build-ego-impl + +# Generated files that egocore needs. + +$(call reset) +$(call cfile, $D/share/makecldef.c) +$(call cprogram, $(OBJDIR)/$D/makecldef) + +$(eval g := $(OBJDIR)/$D/classdefs.h) +$(eval CLEANABLES += $g) +$g: $(OBJDIR)/$D/makecldef $(INCDIR)/em_mnem.h $D/share/cldefs.src + @echo MAKECLDEF $g + @mkdir -p $(dir $g) + $(hide) $$^ > $g + +$(eval g := $(OBJDIR)/$D/pop_push.h) +$(eval CLEANABLES += $g) +$g: $D/share/pop_push.awk h/em_table + @echo POP_PUSH $g + @mkdir -p $(dir $g) + $(hide) awk -f $D/share/pop_push.awk < h/em_table > $g + +# Build the egocore library. + +$(call reset) +$(eval cflags += -I$D/share -I$(OBJDIR)/$D) +$(eval cflags += -DVERBOSE -DNOTCOMPACT) + +$(call cfile, $D/share/debug.c) +$(call cfile, $D/share/global.c) +$(call cfile, $D/share/files.c) +$(call cfile, $D/share/go.c) +$(call cfile, $D/share/map.c) +$(call cfile, $D/share/aux.c) +$(call cfile, $D/share/get.c) +$(call cfile, $D/share/put.c) +$(call cfile, $D/share/alloc.c) +$(call cfile, $D/share/lset.c) +$(call cfile, $D/share/cset.c) +$(call cfile, $D/share/parser.c) +$(call cfile, $D/share/stack_chg.c) +$(call cfile, $D/share/locals.c) +$(call cfile, $D/share/init_glob.c) +$(eval $q: $(OBJDIR)/$D/classdefs.h $(OBJDIR)/$D/pop_push.h) + +$(call clibrary, $(LIBDIR)/libegocore.a) +$(eval CLEANABLES += $q) + +# Now build each of the back ends. + +$(call build-ego-backend-impl, bo, \ + $D/bo/bo.c) + +$(call build-ego-backend-impl, ca, \ + $D/ca/ca.c \ + $D/ca/ca_put.c) + +$(call build-ego-backend-impl, cf, \ + $D/cf/cf.c \ + $D/cf/cf_idom.c \ + $D/cf/cf_loop.c \ + $D/cf/cf_succ.c) + +$(call build-ego-backend-impl, cj, \ + $D/cj/cj.c) + +$(call build-ego-backend-impl, cs, \ + $D/cs/cs.c \ + $D/cs/cs_alloc.c \ + $D/cs/cs_aux.c \ + $D/cs/cs_avail.c \ + $D/cs/cs_debug.c \ + $D/cs/cs_elim.c \ + $D/cs/cs_entity.c \ + $D/cs/cs_getent.c \ + $D/cs/cs_kill.c \ + $D/cs/cs_partit.c \ + $D/cs/cs_profit.c \ + $D/cs/cs_stack.c \ + $D/cs/cs_vnm.c) + +$(call build-ego-backend-impl, ic, \ + $D/ic/ic.c \ + $D/ic/ic_aux.c \ + $D/ic/ic_io.c \ + $D/ic/ic_lib.c \ + $D/ic/ic_lookup.c) + +$(call build-ego-backend-impl, il, \ + $D/il/il.c \ + $D/il/il1_anal.c \ + $D/il/il1_aux.c \ + $D/il/il1_cal.c \ + $D/il/il1_formal.c \ + $D/il/il2_aux.c \ + $D/il/il3_aux.c \ + $D/il/il3_change.c \ + $D/il/il3_subst.c \ + $D/il/il_aux.c) + +$(call build-ego-backend-impl, lv, \ + $D/lv/lv.c) + +$(call build-ego-backend-impl, ra, \ + $D/ra/ra.c \ + $D/ra/ra_allocl.c \ + $D/ra/ra_aux.c \ + $D/ra/ra_interv.c \ + $D/ra/ra_lifet.c \ + $D/ra/ra_pack.c \ + $D/ra/ra_profits.c \ + $D/ra/ra_xform.c \ + $D/ra/ra_items.c) + +$(eval g := $(OBJDIR)/$D/itemtab.h) +$(eval CLEANABLES += $g) +$D/ra/ra_items.c: $g +$g: $(OBJDIR)/$D/makeitems $(INCDIR)/em_mnem.h $D/ra/itemtab.src + @echo MAKEITEMS $g + @mkdir -p $(dir $g) + $(hide) $$^ > $g + +$(call reset) +$(call cfile, $D/ra/makeitems.c) +$(call cprogram, $(OBJDIR)/$D/makeitems) + +$(call build-ego-backend-impl, sp, \ + $D/sp/sp.c) + +$(call build-ego-backend-impl, sr, \ + $D/sr/sr.c \ + $D/sr/sr_aux.c \ + $D/sr/sr_cand.c \ + $D/sr/sr_expr.c \ + $D/sr/sr_iv.c \ + $D/sr/sr_reduce.c \ + $D/sr/sr_xform.c) + +$(call build-ego-backend-impl, ud, \ + $D/ud/ud.c \ + $D/ud/ud_aux.c \ + $D/ud/ud_const.c \ + $D/ud/ud_copy.c \ + $D/ud/ud_defs.c) + +# ...and now the front end, which depends on all the backends. + +$(call reset) +$(call cfile, $D/em_ego/em_ego.c) +$(eval $q: $(INCDIR)/print.h $(INCDIR)/system.h) +$(eval $q: $(INCDIR)/em_path.h) + +$(call file, $(LIBPRINT)) +$(call file, $(LIBSTRING)) +$(call file, $(LIBSYSTEM)) + +$(call cprogram, $(BINDIR)/em_ego) +$(call installto, $(PLATDEP)/em_ego) +$(eval EM_EGO := $q) +$(eval $q: $(EGO_MODULES)) +$(eval ACK_CORE_TOOLS += $q) + +endef + +$(eval $(build-ego-impl)) + +# Install the ego descr file for the current architecture, if one exists. +# This is a bit annoying because it's called by each platform, so we need +# to protect against the architecture being seen more than once. And some +# architectures don't get descr files. + +define build-ego-descr-impl + +$(eval EGO_DESCR_$(ARCH) := 1) + +$(eval g := $(PLATIND)/ego/$(ARCH).descr) +$(eval CLEANABLES += $g) +$(eval $(EM_EGO): $g) +$g: util/ego/descr/descr.sed util/ego/descr/$(ARCH).descr $(CPPANSI) \ + $(INCDIR)/em_mnem.h + @echo EGODESCR $g + @mkdir -p $(dir $g) + $(hide) $(CPPANSI) -P -I$(INCDIR) util/ego/descr/$(ARCH).descr | sed -f util/ego/descr/descr.sed > $g + +endef + +build-ego-descr = $(if $(EGO_DESCR_$(ARCH)),, \ + $(if $(wildcard util/ego/descr/$(ARCH).descr), \ + $(eval $(call build-ego-descr-impl, $1)))) \ No newline at end of file diff --git a/util/ego/cf/cf_loop.c b/util/ego/cf/cf_loop.c index 6f27288ce..c14bdba3f 100644 --- a/util/ego/cf/cf_loop.c +++ b/util/ego/cf/cf_loop.c @@ -9,6 +9,7 @@ */ +#include #include "../share/types.h" #include "../share/debug.h" #include "../share/lset.h" diff --git a/util/ego/cs/cs_alloc.c b/util/ego/cs/cs_alloc.c index f1cfe209d..6a1128286 100644 --- a/util/ego/cs/cs_alloc.c +++ b/util/ego/cs/cs_alloc.c @@ -3,6 +3,7 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ +#include #include "../share/types.h" #include "../share/alloc.h" #include "cs.h" diff --git a/util/ego/il/il1_aux.c b/util/ego/il/il1_aux.c index 8ef4923e2..76e8ae2f3 100644 --- a/util/ego/il/il1_aux.c +++ b/util/ego/il/il1_aux.c @@ -8,6 +8,7 @@ * I L 1 _ A U X . C */ +#include #include #include "../share/types.h" #include "il.h" diff --git a/util/ego/il/il2_aux.c b/util/ego/il/il2_aux.c index 54d950156..01a13f0fc 100644 --- a/util/ego/il/il2_aux.c +++ b/util/ego/il/il2_aux.c @@ -8,6 +8,7 @@ * I L 2 _ A U X . C */ +#include #include #include #include diff --git a/util/ego/il/il3_change.c b/util/ego/il/il3_change.c index 8f8fd393c..6347167c3 100644 --- a/util/ego/il/il3_change.c +++ b/util/ego/il/il3_change.c @@ -9,6 +9,7 @@ */ +#include #include #include #include diff --git a/util/ego/il/il_aux.c b/util/ego/il/il_aux.c index beff6f4dd..2bb5e4564 100644 --- a/util/ego/il/il_aux.c +++ b/util/ego/il/il_aux.c @@ -9,6 +9,7 @@ * I L _ A U X . C */ +#include #include #include #include diff --git a/util/ego/ra/ra_interv.c b/util/ego/ra/ra_interv.c index a6c6b7c1d..b333124ad 100644 --- a/util/ego/ra/ra_interv.c +++ b/util/ego/ra/ra_interv.c @@ -9,6 +9,7 @@ */ +#include #include #include "../share/types.h" #include "../share/debug.h" diff --git a/util/ego/ra/ra_pack.c b/util/ego/ra/ra_pack.c index 3687b44de..373191b90 100644 --- a/util/ego/ra/ra_pack.c +++ b/util/ego/ra/ra_pack.c @@ -8,6 +8,7 @@ * R A _ P A C K . C */ +#include #include #include "../share/types.h" #include "../share/debug.h" diff --git a/util/ego/share/locals.c b/util/ego/share/locals.c index f8d4ba268..b8b92f253 100644 --- a/util/ego/share/locals.c +++ b/util/ego/share/locals.c @@ -7,6 +7,7 @@ * L O C A L S . C */ +#include #include #include #include diff --git a/util/ego/share/lset.c b/util/ego/share/lset.c index d95d256b7..682494a77 100644 --- a/util/ego/share/lset.c +++ b/util/ego/share/lset.c @@ -9,6 +9,7 @@ */ +#include #include "types.h" #include "lset.h" #include "alloc.h" diff --git a/util/ego/share/put.c b/util/ego/share/put.c index 473443a99..bbb4aedd6 100644 --- a/util/ego/share/put.c +++ b/util/ego/share/put.c @@ -5,6 +5,7 @@ */ /* P U T . C */ +#include #include #include #include diff --git a/util/ego/sr/sr_reduce.c b/util/ego/sr/sr_reduce.c index c656dcecb..5b8e78295 100644 --- a/util/ego/sr/sr_reduce.c +++ b/util/ego/sr/sr_reduce.c @@ -10,6 +10,7 @@ */ +#include #include #include #include