We can build our first C file.

This commit is contained in:
David Given 2016-08-07 21:56:53 +02:00
parent b50dc4214a
commit 0d77cb8279
16 changed files with 258 additions and 38 deletions

View file

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

View file

@ -415,7 +415,7 @@ loadtarget = function(targetname)
target = targets[targetname]
if not target then
error(string.format("build file '%s' contains no rule '%s'",
error(string.format("build file '%s' contains no target '%s'",
filename, targetpart))
end
end

0
lang/build.lua Normal file
View file

View file

@ -1,4 +1,5 @@
include("util/LLgen/build.lua")
include("util/cmisc/build.lua")
normalrule {
name = "parameters",
@ -50,12 +51,24 @@ clibrary {
}
normalrule {
name = "tokenname-g",
name = "tokenfile-g",
ins = {
"./make.tokfile",
"./tokenname.c",
},
outleaves = { "tokenname.g" },
outleaves = { "tokenfile.g" },
commands = {
"sh %{ins[1]} < %{ins[2]} > %{outs}",
}
}
normalrule {
name = "symbol2str-c",
ins = {
"./make.tokcase",
"./tokenname.c",
},
outleaves = { "symbol2str.c" },
commands = {
"sh %{ins[1]} < %{ins[2]} > %{outs}",
}
@ -64,14 +77,23 @@ normalrule {
llgen {
name = "llgen",
srcs = {
"+tokenname-g", -- must be first
"+tokenfile-g", -- must be first
"./*.g",
},
}
tabgen {
name = "tabgen",
srcs = { "./char.tab" }
}
cprogram {
name = "cemcom",
srcs = {
"./LLlex.c",
"./LLmessage.c",
"./arith.c",
"./blocks.c",
"./ch3.c",
"./ch3bin.c",
"./ch3mon.c",
@ -111,17 +133,24 @@ cprogram {
"./tokenname.c",
"./type.c",
"./util.c",
"+symbol2str-c",
"+tabgen",
matching(filenamesof("+llgen"), "%.c$"),
},
deps = {
"./*.h",
"+parameters",
"+nextlib",
"+llgen",
"h+emheaders",
"modules/src/alloc+lib",
"modules/src/em_code+lib_k",
"modules/src/em_mes+lib",
"modules/src/flt_arith+lib",
"modules/src/idf+lib",
"modules/src/input+lib",
"modules/src/print+lib",
"modules/src/string+lib",
"modules/src/system+lib",
"modules+headers",
"util/data+em_data",

View file

@ -1,6 +1,4 @@
%
hdrs = { "./src/system/system.h" },
hdrs = { "./src/system/system.h" },
% CHARACTER CLASSES
%
% some general settings:

View file

@ -0,0 +1,29 @@
for _, plat in ipairs(vars.plats) do
acklibrary {
name = "lib_"..plat,
srcs = {
"./assert/*.c",
},
hdrs = {
},
vars = { plat = plat }
}
ackfile {
name = "crt_"..plat,
srcs = { "./head_ac.e" },
vars = { plat = plat },
deps = {
"h+emheaders"
}
}
installable {
name = "pkg_"..plat,
map = {
["$(PLATIND)/"..plat.."/c-ansi.o"] = "+crt_"..plat,
--["$(PLATIND)/"..plat.."/libc.a"] = "+lib_"..plat,
}
}
end

8
mach/i86/libem/build.lua Normal file
View file

@ -0,0 +1,8 @@
for _, plat in ipairs(vars.plats) do
acklibrary {
name = "lib_"..plat,
srcs = { "./*.s" },
vars = { plat = plat },
}
end

View file

@ -0,0 +1,8 @@
for _, plat in ipairs(vars.plats) do
acklibrary {
name = "lib_"..plat,
srcs = { "./*.s" },
vars = { plat = plat },
}
end

View file

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

View file

@ -0,0 +1,11 @@
clibrary {
name = "lib",
srcs = { "./*.c" },
deps = {
"h+emheaders",
"modules+headers",
"modules/src/em_code+em_code_ek_h",
"util/data+em_data",
}
}

View file

@ -1,6 +1,22 @@
clibrary {
name = "lib",
srcs = { "./*.c" },
srcs = {
"./flt_ar2flt.c",
"./flt_div.c",
"./flt_flt2ar.c",
"./flt_modf.c",
"./flt_str2fl.c",
"./flt_cmp.c",
"./flt_add.c",
"./b64_add.c",
"./flt_mul.c",
"./flt_nrm.c",
"./b64_sft.c",
"./flt_umin.c",
"./flt_chk.c",
"./split.c",
"./ucmp.c",
},
hdrs = { "./flt_arith.h" },
deps = {
"modules+headers"

View file

@ -25,14 +25,16 @@ normalrule {
}
}
clibrary {
name = "lib_ev",
local function variant(name, cflags)
clibrary {
name = name,
vars = {
["+cflags"] = {
"-DPRIVATE=static",
"-DEXPORT=",
"-DNDEBUG",
"-DCHECKING"
"-DCHECKING",
unpack(cflags)
},
},
srcs = {
@ -53,6 +55,9 @@ clibrary {
"modules/src/system+lib",
"util/data+em_data",
}
}
}
end
variant("lib_ev", {})
variant("lib_kv", { "-DCOMPACT" })

View file

@ -13,9 +13,10 @@ definerule("ackfile",
name = e.name,
srcs = e.srcs,
deps = {
"lang/cem/cpp.ansi+pkg",
"plat/"..plat.."+tools",
"util/ack+pkg",
"lang/cem/cpp.ansi+pkg",
"util/misc+pkg",
e.deps
},
commands = {
@ -43,7 +44,7 @@ definerule("acklibrary",
_cfile = ackfile,
commands = {
"rm -f %{outs[1]}",
"ACKDIR=$(INSDIR) $(INSDIR)/bin/aal q %{outs[1]} %{ins}"
"ACKDIR=$(INSDIR) $(INSDIR)/bin/aal qc %{outs[1]} %{ins}"
}
}
end
@ -73,6 +74,7 @@ definerule("build_plat_tools",
["$(PLATDEP)/"..e.plat.."/as"] = as,
["$(PLATDEP)/"..e.plat.."/ncg"] = ncg,
["$(PLATIND)/descr/"..e.plat] = descr,
"util/opt+pkg",
}
}
end
@ -87,7 +89,10 @@ definerule("build_plat_libs",
return installable {
name = e.name,
map = {
["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat
["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat,
["$(PLATIND)/"..e.plat.."/libem.a"] = "mach/"..e.arch.."/libem+lib_"..e.plat,
["$(PLATIND)/"..e.plat.."/libsys.a"] = "mach/"..e.arch.."/libsys+lib_"..e.plat,
"lang/cem/libcc.ansi+pkg_"..e.plat,
}
}
end

View file

@ -1,4 +1,5 @@
include("plat/build.lua")
include("lang/build.lua")
build_plat_tools {
name = "tools",

View file

@ -19,10 +19,27 @@ cprogram {
}
}
cprogram {
name = "decode",
srcs = { "./convert.c" },
deps = {
"h+emheaders",
"modules+headers",
"modules/src/alloc+lib",
"modules/src/em_code+lib_k",
"modules/src/print+lib",
"modules/src/read_em+lib_kv",
"modules/src/string+lib",
"modules/src/system+lib",
"util/data+em_data",
}
}
installable {
name = "pkg",
map = {
["$(PLATDEP)/em_encode"] = "+encode",
["$(PLATDEP)/em_decode"] = "+decode",
["$(INSDIR)/bin/esize"] = "+esize",
["$(PLATIND)/man/man1/esize.1"] = "./esize.1",
["$(PLATIND)/man/man6/em_decode.6"] = "./em_decode.6"

85
util/opt/build.lua Normal file
View file

@ -0,0 +1,85 @@
include("first/yacc.lua")
yacc {
name = "yacc",
srcs = { "./mktab.y" }
}
flex {
name = "flex",
srcs = { "./scan.l" }
}
cprogram {
name = "mktab",
srcs = {
matching(filenamesof("+yacc"), "%.c$"),
matching(filenamesof("+flex"), "%.c$"),
},
deps = {
"+flex",
"+yacc",
"util/data+em_data",
}
}
normalrule {
name = "pattern_c",
ins = {
"+mktab",
"./patterns",
"lang/cem/cpp.ansi+cpp"
},
outleaves = { "pattern.c" },
commands = {
"%{ins[3]} < %{ins[2]} | %{ins[1]} > %{outs}"
}
}
normalrule {
name = "pop_push_c",
ins = {
"./pop_push.awk",
"h/em_table"
},
outleaves = { "pop_push.c" },
commands = {
"awk -f %{ins[1]} < %{ins[2]} > %{outs}"
}
}
local function variant(name, cflags)
cprogram {
name = name,
srcs = {
"+pattern_c",
"+pop_push_c",
"./*.c",
},
deps = {
"./*.h",
"h+emheaders",
"modules/src/alloc+lib",
"modules/src/print+lib",
"modules/src/string+lib",
"modules/src/system+lib",
"util/data+em_data",
},
vars = {
["+cflags"] = cflags
}
}
end
variant("em_opt", {})
variant("em_opt2", {"-DGLOBAL_OPT"})
installable {
name = "pkg",
map = {
["$(PLATDEP)/em_opt"] = "+em_opt",
["$(PLATDEP)/em_opt2"] = "+em_opt2",
["$(INSDIR)/share/man/man6/em_opt.6"] = "./em_opt.6",
}
}