diff --git a/build.lua b/build.lua index 028e6f0ab..30da3e902 100644 --- a/build.lua +++ b/build.lua @@ -14,6 +14,7 @@ installable { "lang/basic/src+pkg", "lang/cem/cemcom.ansi+pkg", "lang/m2/comp+pkg", + "lang/pc/comp+pkg", "plat/pc86+pkg", "util/ack+pkg", "util/amisc+pkg", diff --git a/lang/m2/comp/build.lua b/lang/m2/comp/build.lua index b17eb31ff..fde8442ae 100644 --- a/lang/m2/comp/build.lua +++ b/lang/m2/comp/build.lua @@ -66,6 +66,7 @@ normalrule { ins = { "./make.next", "./*.H", + "./*.C", }, outleaves = { "next.c" }, commands = { diff --git a/lang/pc/comp/build.lua b/lang/pc/comp/build.lua new file mode 100644 index 000000000..8b058345b --- /dev/null +++ b/lang/pc/comp/build.lua @@ -0,0 +1,137 @@ +normalrule { + name = "tokenfile_g", + ins = { + "./make.tokfile", + "./tokenname.c" + }, + outleaves = { "tokenfile.g" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +llgen { + name = "llgen", + srcs = { + -- order here is important + "+tokenfile_g", + "./*.g", + } +} + +normalrule { + name = "parameters_h", + ins = { + "./make.parameters", + "./Parameters", + }, + outleaves = { "parameters.h" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +for _, f in ipairs(filenamesof("./*.H")) do + local name = replace(basename(f), "%.H$", "") + normalrule { + name = name.."_h", + ins = { + "./make.allocd", + f + }, + outleaves = { name..".h" }, + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } + } +end + +for _, f in ipairs(filenamesof("./*.C")) do + local name = replace(basename(f), "%.C$", "") + normalrule { + name = name.."_c", + ins = { + "./make.allocd", + f + }, + outleaves = { name..".c" }, + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } + } +end + +normalrule { + name = "next_c", + ins = { + "./make.next", + "./*.H", + "./*.C", + }, + outleaves = { "next.c" }, + commands = { + "sh %{ins} > %{outs}" + } +} + +normalrule { + name = "symbol2str_c", + ins = { + "./make.tokcase", + "./tokenname.c", + }, + outleaves = { "symbol2str.c" }, + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } +} + +tabgen { + name = "chartab_c", + srcs = { "./char.tab" }, +} + +cprogram { + name = "em_pc", + srcs = { + "./*.c", + "+casestat_c", + "+chartab_c", + "+next_c", + "+symbol2str_c", + "+tmpvar_c", + matching(filenamesof("+llgen"), "%.c$"), + }, + deps = { + "+def_h", + "+desig_h", + "+llgen", + "+node_h", + "+parameters_h", + "+scope_h", + "+type_h", + "h+emheaders", + "modules+headers", + "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/string+lib", + "modules/src/system+lib", + "modules/src/print+lib", + "modules/src/em_mes+lib", + "util/data+em_data", + }, + vars = { + ["+cflags"] = "-DSTATIC=static" + } +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/em_pc"] = "+em_pc", + ["$(INSDIR)/share/man/man6/em_pc.6"] = "./em_pc.6" + } +} diff --git a/lang/pc/comp/make.parameters b/lang/pc/comp/make.parameters new file mode 100755 index 000000000..3c9a515c5 --- /dev/null +++ b/lang/pc/comp/make.parameters @@ -0,0 +1,7 @@ +#!/bin/sh + +echo '#ifndef PARAMETERS_H' +echo '#define PARAMETERS_H' +grep -v '^!' +echo '#endif' + diff --git a/plat/build.lua b/plat/build.lua index 64bccf89d..8802ce636 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -16,6 +16,7 @@ definerule("ackfile", "lang/cem/cemcom.ansi+pkg", "lang/cem/cpp.ansi+pkg", "lang/m2/comp+pkg", + "lang/pc/comp+pkg", "plat/"..plat.."+tools", "util/ack+pkg", "util/misc+pkg",