cemcom.ansi now builds.

This commit is contained in:
David Given 2016-07-19 23:43:14 +02:00
parent 05e3cf286f
commit 1fdc69fb97
6 changed files with 161 additions and 83 deletions

View file

@ -60,21 +60,21 @@ $(MAKECMDGOALS): $(BUILDDIR)/build.ninja $(BUILDDIR)/rules.ninja
$(BUILDDIR)/build.ninja: Makefile
@mkdir -p $(BUILDDIR)
echo "OBJDIR = $(OBJDIR)" > $@
echo "BINDIR = $(BINDIR)" >> $@
echo "LIBDIR = $(LIBDIR)" >> $@
echo "INCDIR = $(INCDIR)" >> $@
echo "INSDIR = $(INSDIR)" >> $@
echo "PLATIND = $(PLATIND)" >> $@
echo "PLATDEP = $(PLATDEP)" >> $@
echo "AR = $(AR)" >> $@
echo "CC = $(CC)" >> $@
echo "subninja $(BUILDDIR)/rules.ninja" >> $@
@echo "OBJDIR = $(OBJDIR)" > $@
@echo "BINDIR = $(BINDIR)" >> $@
@echo "LIBDIR = $(LIBDIR)" >> $@
@echo "INCDIR = $(INCDIR)" >> $@
@echo "INSDIR = $(INSDIR)" >> $@
@echo "PLATIND = $(PLATIND)" >> $@
@echo "PLATDEP = $(PLATDEP)" >> $@
@echo "AR = $(AR)" >> $@
@echo "CC = $(CC)" >> $@
@echo "subninja $(BUILDDIR)/rules.ninja" >> $@
else
$(MAKECMDGOALS): $(BUILDDIR)/rules.mk
make -r -f $(BUILDDIR)/rules.mk $@ \
@make -r -f $(BUILDDIR)/rules.mk $@ \
$(MAKEFLAGS) \
OBJDIR=$(OBJDIR) \
BINDIR=$(BINDIR) \

View file

@ -9,17 +9,6 @@ normalrule {
}
}
bundle {
name = "emheaders",
srcs = {
"./em_*.h",
"./arch.h",
"./out.h",
"./ranlib.h",
"+em_path",
}
}
normalrule {
name = "local",
ins = {},
@ -32,3 +21,12 @@ normalrule {
}
}
clibrary {
name = "emheaders",
hdrs = {
"./*.h",
"+em_path",
"+local",
}
}

View file

@ -119,10 +119,13 @@ cprogram {
"+llgen",
"h+emheaders",
"modules+alloc",
"modules+em_code_k",
"modules+flt_arith",
"modules+idf",
"modules+input",
"modules+headers",
"modules+system",
"util/data+libem",
},
}

View file

@ -1,6 +1,8 @@
bundle {
clibrary {
name = "headers",
srcs = { "./h/*.h" }
hdrs = {
"./h/*.h"
}
}
clibrary {
@ -35,6 +37,14 @@ clibrary {
hdrs = { "./src/idf/idf_pkg.*" },
}
clibrary {
name = "input",
srcs = {
"./src/input/*.c"
},
hdrs = { "./src/input/inp_pkg.*" }
}
clibrary {
name = "string",
srcs = { "./src/string/*.c" },
@ -51,3 +61,93 @@ clibrary {
},
}
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

@ -36,62 +36,3 @@ definerule("llgen",
}
end
)
--[[
D := util/LLgen
# Rule to build LLgen.
define build-llgen-impl
$(call reset)
$(eval cflags += -DNON_CORRECTING -DLIBDIR=\"$(abspath $D/lib)\")
$(call cfile, $D/src/main.c)
$(call cfile, $D/src/gencode.c)
$(call cfile, $D/src/compute.c)
$(call cfile, $D/src/check.c)
$(call cfile, $D/src/reach.c)
$(call cfile, $D/src/global.c)
$(call cfile, $D/src/name.c)
$(call cfile, $D/src/sets.c)
$(call cfile, $D/src/alloc.c)
$(call cfile, $D/src/machdep.c)
$(call cfile, $D/src/cclass.c)
$(call cfile, $D/src/savegram.c)
# These use pre-LLgen'd version of the files. If LLgen.g gets updated,
# they need rebuilding. Use the bootstrap script to do this.
$(call cfile, $D/src/LLgen.c)
$(call cfile, $D/src/Lpars.c)
$(call cfile, $D/src/tokens.c)
$(call cprogram, $(BINDIR)/LLgen)
LLGEN := $o
endef
$(eval $(build-llgen-impl))
# Rule to invoke to *use* LLgen.
#
# $1: directory to put output files
# $2: input files
#
# Output files are compiled via cfile and queued.
define llgen-impl
$(eval o := $1/Lpars.c $(patsubst %.g, $(strip $1)/%.c, $(notdir $2)))
$(eval CLEANABLES += $o $1/Lpars.h)
$o: $1/Lpars.h
$1/Lpars.h: $2 $(LLGEN)
@echo LLGEN $1/Lpars.c
@mkdir -p $1
$(hide) $(RM) $o $1/Lpars.h
$(hide) cd $1 && $(LLGEN) $(abspath $2)
$(foreach f,$o,$(call cfile,$f))
endef
llgen = $(eval $(call llgen-impl,$1,$2))
--]]

36
util/data/build.lua Normal file
View file

@ -0,0 +1,36 @@
normalrule {
name = "generated",
ins = {
"./new_table",
"h/em_table", -- relative to root, which is a bit evil
},
outleaves = {
"em_flag.c",
"em_pseu.c",
"em_mnem.c",
"em_spec.h",
"em_pseu.h",
"em_mnem.h",
},
deps = {
"h+emheaders"
},
commands = {
"%{ins[1]} %{ins[2]} %{dir} %{dir}"
}
}
clibrary {
name = "libem",
srcs = {
"./em_ptyp.c",
"+generated", -- so we build the C files
},
hdrs = {
"+generated" -- so we export the H files
},
deps = {
"+generated", -- so we can see the H files
"h+emheaders"
}
}