More programs, more libraries. src/modules build files are now saner.

This commit is contained in:
David Given 2016-07-23 00:30:31 +02:00
parent 1fdc69fb97
commit 2770a83837
20 changed files with 256 additions and 221 deletions

View file

@ -1,9 +1,11 @@
installable { installable {
name = "ack", name = "ack",
map = { map = {
"util/ack+ack-pkg",
"util/amisc+pkg",
"lang/cem/cemcom.ansi+pkg", "lang/cem/cemcom.ansi+pkg",
"util/ack+pkg",
"util/amisc+pkg",
"util/arch+pkg",
"util/misc+pkg",
} }
} }

View file

@ -180,7 +180,7 @@ definerule("cprogram",
commands = { commands = {
type="strings", type="strings",
default={ default={
"$(CC) -o %{outs[1]} %{ins} %{ins}" "$(CC) -o %{outs[1]} -Wl,--start-group %{ins} -Wl,--end-group"
}, },
} }
}, },

View file

@ -118,14 +118,14 @@ cprogram {
"+nextlib", "+nextlib",
"+llgen", "+llgen",
"h+emheaders", "h+emheaders",
"modules+alloc", "modules/src/alloc+lib",
"modules+em_code_k", "modules/src/em_code+lib_k",
"modules+flt_arith", "modules/src/flt_arith+lib",
"modules+idf", "modules/src/idf+lib",
"modules+input", "modules/src/input+lib",
"modules/src/system+lib",
"modules+headers", "modules+headers",
"modules+system", "util/data+em_data",
"util/data+libem",
}, },
} }

View file

@ -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

View file

@ -0,0 +1,10 @@
clibrary {
name = "lib",
srcs = { "./*.c" },
hdrs = { "./alloc.h" },
deps = {
"modules+headers",
"modules/src/system+lib"
},
}

View file

@ -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", "")

View file

@ -0,0 +1,10 @@
clibrary {
name = "lib",
srcs = { "./*.c" },
hdrs = { "./flt_arith.h" },
deps = {
"modules+headers"
}
}

View file

@ -0,0 +1,7 @@
clibrary {
name = "lib",
srcs = {},
hdrs = { "./idf_pkg.*" },
}

View file

@ -0,0 +1,9 @@
clibrary {
name = "lib",
srcs = {
"./*.c"
},
hdrs = { "./inp_pkg.*" }
}

View file

@ -0,0 +1,11 @@
clibrary {
name = "lib",
srcs = { "./*.c" },
deps = {
"modules+headers",
"h+local",
"h+emheaders",
},
}

View file

@ -0,0 +1,11 @@
clibrary {
name = "lib",
srcs = { "./*.c" },
hdrs = { "./print.h" },
deps = {
"modules+headers",
"modules/src/system+lib"
}
}

View file

@ -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",
}
}

View file

@ -1,10 +1,11 @@
#!/bin/sh #!/bin/sh
EM_TABLE=$1 EM_TABLE=$1
ARGTYPE=$2
echo "switch(p->em_opcode) {" echo "switch(p->em_opcode) {"
for i in - cdflnorswz p b for i in - cdflnorswz p b
do do
list=`./argtype $i $EM_TABLE` list=`$ARGTYPE $i $EM_TABLE`
case $i in case $i in
-) args='()' -) args='()'
echo " /* no arguments */" echo " /* no arguments */"
@ -34,7 +35,7 @@ do
EOF EOF
done done
done done
list=`./argtype g $EM_TABLE` list=`$ARGTYPE g $EM_TABLE`
cat << 'EOF' cat << 'EOF'
default: default:
/* a "g" argument */ /* a "g" argument */

View file

@ -1,5 +1,6 @@
EM_TABLE=$1 EM_TABLE=$1
list=`./argtype w $EM_TABLE` ARGTYPE=$2
list=`$ARGTYPE w $EM_TABLE`
echo "switch(p->em_opcode) {" echo "switch(p->em_opcode) {"
for i in $list for i in $list
do do

View file

@ -0,0 +1,7 @@
clibrary {
name = "lib",
srcs = { "./*.c" },
deps = { "modules+headers" },
}

View file

@ -0,0 +1,8 @@
clibrary {
name = "lib",
srcs = { "./*.c" },
hdrs = { "./system.h" },
deps = { "modules+headers" },
}

View file

@ -29,7 +29,7 @@ cprogram {
} }
installable { installable {
name = "ack-pkg", name = "pkg",
map = { map = {
["$(INSDIR)/bin/ack"] = "+ack", ["$(INSDIR)/bin/ack"] = "+ack",
["$(INSDIR)/share/man/man1/ack.1"] = "./ack.1.X", ["$(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))
--]]

View file

@ -4,7 +4,7 @@ local function simpleprogram(name)
srcs = { "./"..name..".c" }, srcs = { "./"..name..".c" },
deps = { deps = {
"h+emheaders", "h+emheaders",
"modules+object", "modules/src/object+lib",
} }
} }

19
util/arch/build.lua Normal file
View file

@ -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"
}
}

View file

@ -21,7 +21,7 @@ normalrule {
} }
clibrary { clibrary {
name = "libem", name = "em_data",
srcs = { srcs = {
"./em_ptyp.c", "./em_ptyp.c",
"+generated", -- so we build the C files "+generated", -- so we build the C files