From: David Given Date: Sat, 3 Sep 2016 20:55:02 +0000 (+0200) Subject: Skeleton of a linuxarm pcc-based plat. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=67257d255b41f74271f200af124f12450562eff9;p=ack.git Skeleton of a linuxarm pcc-based plat. --HG-- branch : default-branch --- diff --git a/build.lua b/build.lua index b0edce05e..424682e03 100644 --- a/build.lua +++ b/build.lua @@ -11,11 +11,17 @@ vars.emplats = { "pc86", "rpi", } +vars.pccplats = { + "linuxarm" +} local plat_packages = {} for _, p in ipairs(vars.emplats) do plat_packages[#plat_packages+1] = "plat/"..p.."+pkg" end +for _, p in ipairs(vars.pccplats) do + plat_packages[#plat_packages+1] = "plat/"..p.."+pkg" +end installable { name = "ack", @@ -24,7 +30,6 @@ installable { "lang/cem/cemcom.ansi+pkg", "lang/m2/comp+pkg", "lang/pc/comp+pkg", - "lang/pcc+pkg", "util/ack+pkg", "util/amisc+pkg", "util/arch+pkg", diff --git a/lang/pcc/build.lua b/lang/pcc/build.lua index 77a9fe317..9dc68124e 100644 --- a/lang/pcc/build.lua +++ b/lang/pcc/build.lua @@ -1,52 +1,5 @@ include("first/yacc.lua") -local pccarch = "arm" - -local pcc_cflags = { - "-D_DEFAULT_SOURCE", - "-DGCC_COMPAT", - "-DPCC_DEBUG", - "-DNATIVE_FLOATING_POINT", - "-D_ISOC99_SOURCE", - "-Dos_ack", - "-Dmach_"..pccarch -} - -clibrary { - name = "headers", - srcs = {}, - hdrs = { - "./pcc/arch/"..pccarch.."/macdefs.h", - "./pcc/cc/ccom/pass1.h", - "./pcc/common/*.h", - "./pcc/mip/*.h", - } -} - -cprogram { - name = "mkext", - srcs = { - "./pcc/mip/mkext.c", - "./pcc/mip/common.c", - "./pcc/arch/"..pccarch.."/table.c" - }, - deps = { - "+headers" - }, - vars = { - ["+cflags"] = { "-DMKEXT", unpack(pcc_cflags) } - } -} - -normalrule { - name = "external", - ins = { "+mkext" }, - outleaves = { "external.h", "external.c" }, - commands = { - "(cd %{dir} && %{ins})" - } -} - flex { name = "flex", srcs = { "./pcc/cc/ccom/scan.l" } @@ -66,34 +19,89 @@ normalrule { } } -cprogram { - name = "pcc_ccom", - srcs = { - matching(filenamesof("+external"), "%.c$"), - matching(filenamesof("+yacc", "+flex"), "%.c$"), - "./pcc/arch/"..pccarch.."/*.c", - "./pcc/cc/ccom/*.c", - "./pcc/common/*.c", - "./pcc/mip/common.c", - "./pcc/mip/match.c", - "./pcc/mip/optim2.c", - "./pcc/mip/reader.c", - "./pcc/mip/regs.c", - }, - deps = { - "+headers", - "+external", - "+cgram_h", - }, - vars = { - ["+cflags"] = pcc_cflags - } +clibrary { + name = "config_h", + srcs = {}, + hdrs = { "./config.h" } } -installable { - name = "pkg", - map = { - ["$(PLATDEP)/pcc_ccom"] = "+pcc_ccom", - } -} +definerule("build_pcc", + { + pccarch = { type="string" } + }, + function(e) + local pccarch = e.pccarch + + local pcc_cflags = { + "-D_DEFAULT_SOURCE", + "-DGCC_COMPAT", + "-DPCC_DEBUG", + "-DNATIVE_FLOATING_POINT", + "-D_ISOC99_SOURCE", + "-Dos_ack", + "-Dmach_"..pccarch + } + + local headers = clibrary { + name = e.name.."/headers", + srcs = {}, + hdrs = { + "lang/pcc/pcc/arch/"..pccarch.."/macdefs.h", + "lang/pcc/pcc/cc/ccom/pass1.h", + "lang/pcc/pcc/common/*.h", + "lang/pcc/pcc/mip/*.h", + } + } + + local mkext = cprogram { + name = e.name.."/mkext", + srcs = { + "lang/pcc/pcc/mip/mkext.c", + "lang/pcc/pcc/mip/common.c", + "lang/pcc/pcc/arch/"..pccarch.."/table.c" + }, + deps = { + headers, + "lang/pcc+config_h", + }, + vars = { + ["+cflags"] = { "-DMKEXT", unpack(pcc_cflags) } + } + } + + local external = normalrule { + name = e.name.."/external", + ins = { mkext }, + outleaves = { "external.h", "external.c" }, + commands = { + "(cd %{dir} && %{ins})" + } + } + + return cprogram { + name = e.name, + srcs = { + matching(filenamesof(external), "%.c$"), + matching(filenamesof("lang/pcc+yacc", "lang/pcc+flex"), "%.c$"), + "lang/pcc/pcc/arch/"..pccarch.."/*.c", + "lang/pcc/pcc/cc/ccom/*.c", + "lang/pcc/pcc/common/*.c", + "lang/pcc/pcc/mip/common.c", + "lang/pcc/pcc/mip/match.c", + "lang/pcc/pcc/mip/optim2.c", + "lang/pcc/pcc/mip/reader.c", + "lang/pcc/pcc/mip/regs.c", + }, + deps = { + headers, + external, + "lang/pcc+cgram_h", + "lang/pcc+config_h", + }, + vars = { + ["+cflags"] = pcc_cflags + } + } + end +) diff --git a/lang/pcc/build.mk b/lang/pcc/build.mk deleted file mode 100644 index 03b91ba29..000000000 --- a/lang/pcc/build.mk +++ /dev/null @@ -1,95 +0,0 @@ -D := lang/pcc - -define pcc-cfile-impl - $(call cfile, $1) - $(call dependson, $(OBJDIR)/$D/pcc/external.h) -endef -pcc-cfile = $(eval $(pcc-cfile-impl)) - -define build-pcc-impl - -$(eval E := $(OBJDIR)/$D/pcc) - -$(eval pcc-cflags = \ - -Ilang/pcc \ - -I$E \ - -Ilang/pcc/pcc/common \ - -Ilang/pcc/pcc/mip \ - -Ilang/pcc/pcc/cc/ccom \ - -Ilang/pcc/pcc/arch/$(PCCARCH) \ - -D_DEFAULT_SOURCE \ - -DGCC_COMPAT \ - -DPCC_DEBUG \ - -DNATIVE_FLOATING_POINT \ - -D_ISOC99_SOURCE \ - -Dos_ack \ - -Dmach_$(PCCARCH) \ -) - -$(call reset) -$(eval cflags += $(pcc-cflags)) - -$(call pcc-cfile, $E/external.c) -$(call pcc-cfile, lang/pcc/pcc/arch/$(PCCARCH)/code.c) -$(call pcc-cfile, lang/pcc/pcc/arch/$(PCCARCH)/local.c) -$(call pcc-cfile, lang/pcc/pcc/arch/$(PCCARCH)/local2.c) -$(call pcc-cfile, lang/pcc/pcc/arch/$(PCCARCH)/order.c) -$(call pcc-cfile, lang/pcc/pcc/arch/$(PCCARCH)/table.c) -$(call pcc-cfile, lang/pcc/pcc/cc/ccom/builtins.c) -$(call pcc-cfile, lang/pcc/pcc/cc/ccom/dwarf.c) -$(call pcc-cfile, lang/pcc/pcc/cc/ccom/init.c) -$(call pcc-cfile, lang/pcc/pcc/cc/ccom/inline.c) -$(call pcc-cfile, lang/pcc/pcc/cc/ccom/main.c) -$(call pcc-cfile, lang/pcc/pcc/cc/ccom/optim.c) -$(call pcc-cfile, lang/pcc/pcc/cc/ccom/stabs.c) -$(call pcc-cfile, lang/pcc/pcc/cc/ccom/symtabs.c) -$(call pcc-cfile, lang/pcc/pcc/cc/ccom/trees.c) -$(call pcc-cfile, lang/pcc/pcc/common/compat.c) -$(call pcc-cfile, lang/pcc/pcc/common/unicode.c) -$(call pcc-cfile, lang/pcc/pcc/mip/common.c) -$(call pcc-cfile, lang/pcc/pcc/mip/match.c) -$(call pcc-cfile, lang/pcc/pcc/mip/optim2.c) -$(call pcc-cfile, lang/pcc/pcc/mip/reader.c) -$(call pcc-cfile, lang/pcc/pcc/mip/regs.c) - -$(call pcc-cfile, lang/pcc/pcc/cc/ccom/gcc_compat.c) -$(call dependson, $E/cgram.h) - -$(call pcc-cfile, lang/pcc/pcc/cc/ccom/pftn.c) -$(call dependson, $E/cgram.h) - -$(call yacc, $E, lang/pcc/pcc/cc/ccom/cgram.y) - -$(call flex, $E, lang/pcc/pcc/cc/ccom/scan.l) -$(call dependson, $E/cgram.h) - -$(call cprogram, $(BINDIR)/$(PLATFORM)/pcc_ccom) -$(call installto, $(PLATDEP)/$(PLATFORM)/pcc_ccom) - - -$(call reset) -$(call rawfile, $E/y.tab.h) -$(call dependson, $E/y.tab.c) -$(call installto, $E/cgram.h) - - -$(call reset) -$(eval objdir := mkext) -$(eval cflags += $(pcc-cflags) -DMKEXT) -$(call cfile, lang/pcc/pcc/mip/mkext.c) -$(call cfile, lang/pcc/pcc/mip/common.c) -$(call cfile, lang/pcc/pcc/arch/$(PCCARCH)/table.c) -$(call cprogram, $E/mkext) -$(eval pcc_mkext := $o) - -$E/external.h: $E/external.c -$E/external.c: $(pcc_mkext) - @echo MKEXT - @mkdir -p $$(dir $$@) - $(hide) (cd $$(dir $$@) && $(pcc_mkext)) - -endef - - -build-pcc = $(eval $(build-pcc-impl)) - diff --git a/mach/arm/libend/build.lua b/mach/arm/libend/build.lua new file mode 100644 index 000000000..79587543e --- /dev/null +++ b/mach/arm/libend/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(concat(vars.emplats, vars.pccplats)) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/plat/build.lua b/plat/build.lua index dc0e87c5e..771f92411 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -82,18 +82,39 @@ definerule("build_plat_libs", { arch = { type="string" }, plat = { type="string" }, + libraries = { type="table", default={ + libbasic = true, + libc = true, + libm2 = true, + libpc = true, + libem = true, + libend = true, + }} }, function(e) + local map = {} + if e.libraries.libbasic then + map[#map+1] = "lang/basic/lib+pkg_"..e.plat + end + if e.libraries.libc then + map[#map+1] = "lang/cem/libcc.ansi+pkg_"..e.plat + end + if e.libraries.libm2 then + map[#map+1] = "lang/m2/libm2+pkg_"..e.plat + end + if e.libraries.libpc then + map[#map+1] = "lang/pc/libpc+pkg_"..e.plat + end + if e.libraries.libem then + map["$(PLATIND)/"..e.plat.."/libem.a"] = "mach/"..e.arch.."/libem+lib_"..e.plat + end + if e.libraries.libend then + map["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat + end + return installable { name = e.name, - map = { - "lang/basic/lib+pkg_"..e.plat, - "lang/cem/libcc.ansi+pkg_"..e.plat, - "lang/m2/libm2+pkg_"..e.plat, - "lang/pc/libpc+pkg_"..e.plat, - ["$(PLATIND)/"..e.plat.."/libem.a"] = "mach/"..e.arch.."/libem+lib_"..e.plat, - ["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat, - } + map = map } end ) diff --git a/plat/linuxarm/build-pkg.lua b/plat/linuxarm/build-pkg.lua new file mode 100644 index 000000000..5bb107f55 --- /dev/null +++ b/plat/linuxarm/build-pkg.lua @@ -0,0 +1,27 @@ +include("plat/build.lua") + +ackfile { + name = "boot", + srcs = { "./boot.s" }, + vars = { plat = "linuxarm" } +} + +build_plat_libs { + name = "libs", + arch = "arm", + plat = "linuxarm", + libraries = { + libend = true + } +} + +installable { + name = "pkg", + map = { + "+tools", + "+libs", + "./include+pkg", + ["$(PLATIND)/linuxarm/boot.o"] = "+boot", + --["$(PLATIND)/linuxarm/libsys.a"] = "./libsys+lib", + } +} diff --git a/plat/linuxarm/build-tools.lua b/plat/linuxarm/build-tools.lua new file mode 100644 index 000000000..766aef133 --- /dev/null +++ b/plat/linuxarm/build-tools.lua @@ -0,0 +1,21 @@ +include("plat/build.lua") +include("lang/pcc/build.lua") + +build_as { + name = "as", + arch = "arm", +} + +build_pcc { + name = "pcc_ccom", + pccarch = "arm", +} + +return installable { + name = "tools", + map = { + ["$(PLATDEP)/linuxarm/as"] = "+as", + ["$(PLATDEP)/linuxarm/pcc_ccom"] = "+pcc_ccom", + ["$(PLATIND)/descr/linuxarm"] = "./descr", + } +} diff --git a/plat/linuxarm/include/build.lua b/plat/linuxarm/include/build.lua new file mode 100644 index 000000000..61a1ed5c1 --- /dev/null +++ b/plat/linuxarm/include/build.lua @@ -0,0 +1,23 @@ +include("plat/build.lua") + +headermap = {} +packagemap = {} + +local function addheader(h) + headermap[h] = "./"..h + packagemap["$(PLATIND)/linuxarm/include/"..h] = "./"..h +end + +addheader("ack/config.h") +addheader("unistd.h") + +acklibrary { + name = "headers", + hdrs = headermap +} + +installable { + name = "pkg", + map = packagemap +} +