diff --git a/build.lua b/build.lua index b446dbd5e..86641357d 100644 --- a/build.lua +++ b/build.lua @@ -1,9 +1,11 @@ installable { name = "ack", map = { - "util/ack+ack-pkg", - "util/amisc+pkg", "lang/cem/cemcom.ansi+pkg", + "util/ack+pkg", + "util/amisc+pkg", + "util/arch+pkg", + "util/misc+pkg", } } diff --git a/first/build.lua b/first/build.lua index 9a35c36a6..dcddaae90 100644 --- a/first/build.lua +++ b/first/build.lua @@ -180,7 +180,7 @@ definerule("cprogram", commands = { type="strings", default={ - "$(CC) -o %{outs[1]} %{ins} %{ins}" + "$(CC) -o %{outs[1]} -Wl,--start-group %{ins} -Wl,--end-group" }, } }, diff --git a/lang/cem/cemcom.ansi/build.lua b/lang/cem/cemcom.ansi/build.lua index e330eded9..ff07e4b36 100644 --- a/lang/cem/cemcom.ansi/build.lua +++ b/lang/cem/cemcom.ansi/build.lua @@ -118,14 +118,14 @@ cprogram { "+nextlib", "+llgen", "h+emheaders", - "modules+alloc", - "modules+em_code_k", - "modules+flt_arith", - "modules+idf", - "modules+input", + "modules/src/alloc+lib", + "modules/src/em_code+lib_k", + "modules/src/flt_arith+lib", + "modules/src/idf+lib", + "modules/src/input+lib", + "modules/src/system+lib", "modules+headers", - "modules+system", - "util/data+libem", + "util/data+em_data", }, } diff --git a/modules/build.lua b/modules/build.lua index cbf72d0ba..a2228f2a8 100644 --- a/modules/build.lua +++ b/modules/build.lua @@ -5,149 +5,3 @@ clibrary { } } -clibrary { - name = "system", - srcs = { "./src/system/*.c" }, - hdrs = { "./src/system/system.h" }, - deps = { "+headers" }, -} - -clibrary { - name = "alloc", - srcs = { "./src/alloc/*.c" }, - hdrs = { "./src/alloc/alloc.h" }, - deps = { - "+headers", - "+system" - }, -} - -clibrary { - name = "flt_arith", - srcs = { "./src/flt_arith/*.c" }, - hdrs = { "./src/flt_arith/flt_arith.h" }, - deps = { - "+headers" - } -} - -clibrary { - name = "idf", - srcs = {}, - hdrs = { "./src/idf/idf_pkg.*" }, -} - -clibrary { - name = "input", - srcs = { - "./src/input/*.c" - }, - hdrs = { "./src/input/inp_pkg.*" } -} - -clibrary { - name = "string", - srcs = { "./src/string/*.c" }, - deps = { "+headers" }, -} - -clibrary { - name = "object", - srcs = { "./src/object/*.c" }, - deps = { - "+headers", - "h+local", - "h+emheaders", - }, -} - -normalrule { - name = "em_code_ek_h", - ins = { - "./src/em_code/make.em.gen", - "./src/em_code/em.nogen", - "h/em_table" - }, - outleaves = { "em_codeEK.h" }, - commands = { - "%{ins[1]} %{ins[3]} > %{outs}", - "cat %{ins[2]} >> %{outs}" - } -} - -for _, variant in ipairs { - { "e", "-DREADABLE_EM" }, - { "k", "" } -} do - local code = variant[1] - local cflags = variant[2] - - clibrary { - name = "em_code_"..code, - srcs = { - "./src/em_code/C_out.c", - "./src/em_code/bhcst.c", - "./src/em_code/bhdlb.c", - "./src/em_code/bhdnam.c", - "./src/em_code/bhfcon.c", - "./src/em_code/bhicon.c", - "./src/em_code/bhilb.c", - "./src/em_code/bhpnam.c", - "./src/em_code/bhucon.c", - "./src/em_code/crcst.c", - "./src/em_code/crdlb.c", - "./src/em_code/crdnam.c", - "./src/em_code/crilb.c", - "./src/em_code/crpnam.c", - "./src/em_code/crscon.c", - "./src/em_code/crxcon.c", - "./src/em_code/cst.c", - "./src/em_code/dfdlb.c", - "./src/em_code/dfdnam.c", - "./src/em_code/dfilb.c", - "./src/em_code/dlb.c", - "./src/em_code/dnam.c", - "./src/em_code/em.c", - "./src/em_code/end.c", - "./src/em_code/endarg.c", - "./src/em_code/exc.c", - "./src/em_code/failed.c", - "./src/em_code/fcon.c", - "./src/em_code/getid.c", - "./src/em_code/icon.c", - "./src/em_code/ilb.c", - "./src/em_code/insert.c", - "./src/em_code/internerr.c", - "./src/em_code/msend.c", - "./src/em_code/msstart.c", - "./src/em_code/op.c", - "./src/em_code/opcst.c", - "./src/em_code/opdlb.c", - "./src/em_code/opdnam.c", - "./src/em_code/opilb.c", - "./src/em_code/opnarg.c", - "./src/em_code/oppnam.c", - "./src/em_code/pnam.c", - "./src/em_code/pro.c", - "./src/em_code/pronarg.c", - "./src/em_code/psdlb.c", - "./src/em_code/psdnam.c", - "./src/em_code/pspnam.c", - "./src/em_code/scon.c", - "./src/em_code/ucon.c", - }, - hdrs = { - "+em_code_ek_h" - }, - deps = { - "+alloc", - "+em_code_ek_h", - "+headers", - "+system", - "h+emheaders", - "h+local", - "util/data+libem", - }, - cflags = { cflags } - } -end diff --git a/modules/src/alloc/build.lua b/modules/src/alloc/build.lua new file mode 100644 index 000000000..a274c390e --- /dev/null +++ b/modules/src/alloc/build.lua @@ -0,0 +1,10 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + hdrs = { "./alloc.h" }, + deps = { + "modules+headers", + "modules/src/system+lib" + }, +} + diff --git a/modules/src/em_code/build.lua b/modules/src/em_code/build.lua new file mode 100644 index 000000000..80ea28a8b --- /dev/null +++ b/modules/src/em_code/build.lua @@ -0,0 +1,88 @@ +normalrule { + name = "em_code_ek_h", + ins = { + "./make.em.gen", + "./em.nogen", + "h/em_table" + }, + outleaves = { "em_codeEK.h" }, + commands = { + "%{ins[1]} %{ins[3]} > %{outs}", + "cat %{ins[2]} >> %{outs}" + } +} + +local function build_variant(code, cflags) + clibrary { + name = "lib_"..code, + srcs = { + "./C_out.c", + "./bhcst.c", + "./bhdlb.c", + "./bhdnam.c", + "./bhfcon.c", + "./bhicon.c", + "./bhilb.c", + "./bhpnam.c", + "./bhucon.c", + "./crcst.c", + "./crdlb.c", + "./crdnam.c", + "./crilb.c", + "./crpnam.c", + "./crscon.c", + "./crxcon.c", + "./cst.c", + "./dfdlb.c", + "./dfdnam.c", + "./dfilb.c", + "./dlb.c", + "./dnam.c", + "./em.c", + "./end.c", + "./endarg.c", + "./exc.c", + "./failed.c", + "./fcon.c", + "./getid.c", + "./icon.c", + "./ilb.c", + "./insert.c", + "./internerr.c", + "./msend.c", + "./msstart.c", + "./op.c", + "./opcst.c", + "./opdlb.c", + "./opdnam.c", + "./opilb.c", + "./opnarg.c", + "./oppnam.c", + "./pnam.c", + "./pro.c", + "./pronarg.c", + "./psdlb.c", + "./psdnam.c", + "./pspnam.c", + "./scon.c", + "./ucon.c", + }, + hdrs = { + "+em_code_ek_h" + }, + deps = { + "+em_code_ek_h", + "h+emheaders", + "h+local", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/system+lib", + "util/data+em_data", + }, + cflags = { cflags } + } +end + +build_variant("e", "-DREADABLE_EM") +build_variant("k", "") + diff --git a/modules/src/flt_arith/build.lua b/modules/src/flt_arith/build.lua new file mode 100644 index 000000000..10ce7b8ce --- /dev/null +++ b/modules/src/flt_arith/build.lua @@ -0,0 +1,10 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + hdrs = { "./flt_arith.h" }, + deps = { + "modules+headers" + } +} + + diff --git a/modules/src/idf/build.lua b/modules/src/idf/build.lua new file mode 100644 index 000000000..ac30ac54e --- /dev/null +++ b/modules/src/idf/build.lua @@ -0,0 +1,7 @@ +clibrary { + name = "lib", + srcs = {}, + hdrs = { "./idf_pkg.*" }, +} + + diff --git a/modules/src/input/build.lua b/modules/src/input/build.lua new file mode 100644 index 000000000..7f59455e0 --- /dev/null +++ b/modules/src/input/build.lua @@ -0,0 +1,9 @@ +clibrary { + name = "lib", + srcs = { + "./*.c" + }, + hdrs = { "./inp_pkg.*" } +} + + diff --git a/modules/src/object/build.lua b/modules/src/object/build.lua new file mode 100644 index 000000000..61a9907f1 --- /dev/null +++ b/modules/src/object/build.lua @@ -0,0 +1,11 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + deps = { + "modules+headers", + "h+local", + "h+emheaders", + }, +} + + diff --git a/modules/src/print/build.lua b/modules/src/print/build.lua new file mode 100644 index 000000000..a3bc48b06 --- /dev/null +++ b/modules/src/print/build.lua @@ -0,0 +1,11 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + hdrs = { "./print.h" }, + deps = { + "modules+headers", + "modules/src/system+lib" + } +} + + diff --git a/modules/src/read_em/build.lua b/modules/src/read_em/build.lua new file mode 100644 index 000000000..860f29df1 --- /dev/null +++ b/modules/src/read_em/build.lua @@ -0,0 +1,56 @@ + +normalrule { + name = "c_mnem_narg_h", + ins = { + "./m_C_mnem_na", + "h/em_table", + "./argtype" + }, + outleaves = "C_mnem_narg.h", + commands = { + "%{ins} > %{outs}" + } +} + +normalrule { + name = "c_mnem_h", + ins = { + "./m_C_mnem", + "h/em_table", + "./argtype" + }, + outleaves = "C_mnem.h", + commands = { + "%{ins} > %{outs}" + } +} + +clibrary { + name = "lib_ev", + cflags = { + "-DPRIVATE=static", + "-DEXPORT=", + "-DNDEBUG", + "-DCHECKING" + }, + srcs = { + "./EM_vars.c", + "./read_em.c", + "./mkcalls.c", + }, + hdrs = { + "./em_comp.h", + }, + deps = { + "+c_mnem_h", + "+c_mnem_narg_h", + "h+emheaders", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/em_code+em_code_ek_h", + "modules/src/system+lib", + "util/data+em_data", + } +} + + diff --git a/modules/src/read_em/m_C_mnem b/modules/src/read_em/m_C_mnem index 70152f5c4..67b6056b5 100755 --- a/modules/src/read_em/m_C_mnem +++ b/modules/src/read_em/m_C_mnem @@ -1,10 +1,11 @@ #!/bin/sh EM_TABLE=$1 +ARGTYPE=$2 echo "switch(p->em_opcode) {" for i in - cdflnorswz p b do - list=`./argtype $i $EM_TABLE` + list=`$ARGTYPE $i $EM_TABLE` case $i in -) args='()' echo " /* no arguments */" @@ -34,7 +35,7 @@ do EOF done done -list=`./argtype g $EM_TABLE` +list=`$ARGTYPE g $EM_TABLE` cat << 'EOF' default: /* a "g" argument */ diff --git a/modules/src/read_em/m_C_mnem_na b/modules/src/read_em/m_C_mnem_na index 535ea0831..07e80daad 100755 --- a/modules/src/read_em/m_C_mnem_na +++ b/modules/src/read_em/m_C_mnem_na @@ -1,5 +1,6 @@ EM_TABLE=$1 -list=`./argtype w $EM_TABLE` +ARGTYPE=$2 +list=`$ARGTYPE w $EM_TABLE` echo "switch(p->em_opcode) {" for i in $list do diff --git a/modules/src/string/build.lua b/modules/src/string/build.lua new file mode 100644 index 000000000..c45a84577 --- /dev/null +++ b/modules/src/string/build.lua @@ -0,0 +1,7 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + deps = { "modules+headers" }, +} + + diff --git a/modules/src/system/build.lua b/modules/src/system/build.lua new file mode 100644 index 000000000..47587e122 --- /dev/null +++ b/modules/src/system/build.lua @@ -0,0 +1,8 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + hdrs = { "./system.h" }, + deps = { "modules+headers" }, +} + + diff --git a/util/ack/build.lua b/util/ack/build.lua index f30eedf4a..dc46d44a8 100644 --- a/util/ack/build.lua +++ b/util/ack/build.lua @@ -29,7 +29,7 @@ cprogram { } installable { - name = "ack-pkg", + name = "pkg", map = { ["$(INSDIR)/bin/ack"] = "+ack", ["$(INSDIR)/share/man/man1/ack.1"] = "./ack.1.X", @@ -37,62 +37,3 @@ installable { } } ---[[ -D := util/ack - -define util-ack-makeheaders-rule -$(eval g := $(OBJDIR)/$D/dmach.c $(OBJDIR)/$D/intable.c) -$(wordlist 2, $(words $g), $g): $(firstword $g) -$(firstword $g): $(util-ack-mktables) - @echo MKTABLES - @mkdir -p $(OBJDIR)/$D - $(hide) cd $(OBJDIR)/$D && $(util-ack-mktables) $(INSDIR)/share - -$(eval CLEANABLES += $g) -endef - -define build-ack-impl - $(call reset) - $(call cfile, $D/mktables.c) - $(call cprogram, $(OBJDIR)/$D/mktables) - $(eval util-ack-mktables := $o) - - $(call reset) - $(eval cflags += -I$D) - $(call cfile, $D/list.c) - $(call cfile, $D/data.c) - $(call cfile, $D/main.c) - $(call cfile, $D/scan.c) - $(call cfile, $D/svars.c) - $(call cfile, $D/trans.c) - $(call cfile, $D/util.c) - - $(call cfile, $D/rmach.c) - $(call dependson, $(INCDIR)/em_path.h) - - $(call cfile, $D/run.c) - $(call cfile, $D/grows.c) - - $(call cfile, $D/files.c) - $(call dependson, $(INCDIR)/em_path.h) - - $(eval $(util-ack-makeheaders-rule)) - $(call cfile, $(OBJDIR)/$D/dmach.c) - $(call cfile, $(OBJDIR)/$D/intable.c) - - $(call cprogram, $(BINDIR)/ack) - $(call installto, $(INSDIR)/bin/ack) - $(eval ACK := $o) - - $(call reset) - $(eval q := lib/descr/fe) - $(call installto, $(PLATIND)/descr/fe) - $(eval $(ACK): $o) - - $(call reset) - $(eval q := $D/ack.1.X) - $(call installto, $(INSDIR)/share/man/man1/ack.1) -endef - -$(eval $(build-ack-impl)) ---]] diff --git a/util/amisc/build.lua b/util/amisc/build.lua index 099e51a82..d1b8a3356 100644 --- a/util/amisc/build.lua +++ b/util/amisc/build.lua @@ -4,7 +4,7 @@ local function simpleprogram(name) srcs = { "./"..name..".c" }, deps = { "h+emheaders", - "modules+object", + "modules/src/object+lib", } } diff --git a/util/arch/build.lua b/util/arch/build.lua new file mode 100644 index 000000000..ad207c60e --- /dev/null +++ b/util/arch/build.lua @@ -0,0 +1,19 @@ +cprogram { + name = "aal", + srcs = { "./archiver.c" }, + deps = { + "h+emheaders", + "modules/src/object+lib", + "modules/src/print+lib", + "modules/src/string+lib", + "modules/src/system+lib" + } +} + +installable { + name = "pkg", + map = { + ["$(INSDIR)/bin/aal"] = "+aal", + ["$(PLATIND)/man/man1/aal.1"] = "./aal.1" + } +} diff --git a/util/data/build.lua b/util/data/build.lua index 7ed75e280..784e1d6ac 100644 --- a/util/data/build.lua +++ b/util/data/build.lua @@ -21,7 +21,7 @@ normalrule { } clibrary { - name = "libem", + name = "em_data", srcs = { "./em_ptyp.c", "+generated", -- so we build the C files