Top, topgen, aelflod. Moved the libraries back into the platform-specific

directories --- wrangling descr files was too hard. C programs can be built
for cpm, pc86, linux386, linux68k!

--HG--
branch : dtrg-buildsystem
rename : util/ack/build.mk => util/led/build.mk
rename : util/LLgen/build.mk => util/topgen/build.mk
This commit is contained in:
David Given 2013-05-13 23:26:15 +01:00
parent 442306d557
commit 07453d184a
27 changed files with 398 additions and 55 deletions

View file

@ -50,15 +50,17 @@ include util/opt/build.mk
include util/ncgg/build.mk
include util/arch/build.mk
include util/misc/build.mk
include util/led/build.mk
include util/topgen/build.mk
include lang/cem/build.mk
include mach/proto/as/build.mk
include mach/proto/ncg/build.mk
include mach/proto/top/build.mk
include plat/linux/liblinux/build.mk
include mach/build.mk
include mach/i80/build.mk
include mach/i386/build.mk
include mach/i86/build.mk

View file

@ -254,6 +254,14 @@ $(call ackfile, lang/cem/libcc.ansi/time/misc.c)
$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libc.a)
$(call installto, $(PLATIND)/$(PLATFORM)/libc.a)
# CRT
$(call reset)
$(eval objdir := $(PLATFORM))
$(eval ackflags += -Ih)
$(call ackfile, lang/cem/libcc.ansi/head_ac.e)
$(call installto, $(PLATIND)/$(PLATFORM)/c-ansi.o)
endef
build-runtime-libcc-ansi = $(eval $(build-runtime-libcc-ansi-impl))

View file

@ -1,12 +0,0 @@
define build-architecture-impl
$(eval ARCHITECTURE_$(ARCH) := \
$(PLATDEP)/$(ARCH)/as \
$(PLATDEP)/$(ARCH)/ncg)
$(eval PLATFORM := $(ARCH))
$(call build-as)
$(call build-ncg)
endef
build-architecture = $(eval $(build-architecture-impl))

View file

@ -1,8 +1,53 @@
ARCH := i386
OPTIMISATION := -O
arch-libem-i386 = \
adi.s \
and.s \
blm.s \
cii.s \
cms.s \
com.s \
csa4.s \
csb4.s \
cuu.s \
dup.s \
dvi.s \
dvu.s \
error.s \
exg.s \
fp8087.s \
fat.s \
gto.s \
iaar.s \
ilar.s \
inn.s \
ior.s \
isar.s \
lar4.s \
loi.s \
mli.s \
mon.s \
ngi.s \
nop.s \
print.s \
rck.s \
rmi.s \
rmu.s \
rol.s \
ror.s \
sar4.s \
sbi.s \
set.s \
sli.s \
sri.s \
sti.s \
strhp.s \
trp.s \
unknown.s \
xor.s
D := mach/i386
$(eval $(call build-architecture))
arch-libend-i386 = \
edata.s \
em_end.s \
end.s \
etext.s

View file

@ -1,8 +1,47 @@
ARCH := i80
OPTIMISATION := -O
arch-libem-i80 = \
aar2.s \
adi4.s \
and.s \
blm.s \
cii.s \
cmi4.s \
cms.s \
com.s \
csa.s \
csb.s \
dup.s \
dvi2.s \
exg.s \
flp.s \
inn.s \
ior.s \
lar2.s \
mli2.s \
mli4.s \
mlu2.s \
ngi4.s \
nop.s \
rol4.s \
ror4.s \
sar2.s \
sbi4.s \
set.s \
set2.s \
sli2.s \
sli4.s \
sri2.s \
sri4.s \
xor.s \
loi.s \
sti.s \
dvi4.s \
rck.s
D := mach/i80
$(eval $(call build-architecture))
arch-libend-i80 = \
edata.s \
em_end.s \
end.s \
etext.s
arch-top-i80 = yes

View file

@ -1,8 +1,68 @@
ARCH := i86
OPTIMISATION := -O
arch-libem-i86 := \
adi.s \
and.s \
cii.s \
cms.s \
cmi4.s \
cmu4.s \
com.s \
csa2.s \
csb2.s \
csa4.s \
csb4.s \
cuu.s \
dup.s \
dvi.s \
dvi4.s \
dvu.s \
dvu4.s \
exg.s \
fp8087.s \
gto.s \
iaar.s \
ilar.s \
inn.s \
ior.s \
isar.s \
lar2.s \
loi.s \
mli.s \
mli4.s \
mon.s \
ngi.s \
nop.s \
rck.s \
rmi.s \
rmi4.s \
rmu.s \
rmu4.s \
rol.s \
ror.s \
sar2.s \
sbi.s \
set.s \
sli.s \
sri.s \
sti.s \
strhp.s \
xor.s \
error.s \
unknown.s \
fat.s \
trp.s \
print.s \
ret6.s \
ret8.s \
lfr6.s \
lfr8.s \
retarea.s \
blm.s \
return.s
D := mach/i86
$(eval $(call build-architecture))
arch-libend-i86 = \
edata.s \
em_end.s \
end.s \
etext.s

View file

@ -1,8 +1,33 @@
ARCH := m68020
OPTIMISATION := -O6
arch-libem-m68020 = \
fp68881.s \
aar.s \
lar.s \
sar.s \
csa.s \
csb.s \
shp.s \
set.s \
inn.s \
fat.s \
trp.s \
trpstr.c \
mon.s \
nop.s \
dia.s \
cii.s \
cuu.s \
cmi.s \
cms.s \
cmu.s \
cvf.s \
exg.s \
los.s \
sts.s
D := mach/m68020
$(eval $(call build-architecture))
arch-libend-m68020 = \
edata.s \
em_end.s \
end.s \
etext.s

View file

@ -1,8 +0,0 @@
ARCH := powerpc
OPTIMISATION := -O
D := mach/powerpc
$(eval $(call build-architecture))

View file

@ -35,8 +35,8 @@ $(OBJDIR)/$D/preprocessed-comm2.y: mach/proto/as/comm2.y $(CPPANSI)
mach/proto/as/comm2.y > $$@
$(call file, $(LIBOBJECT))
$(call cprogram, $(BINDIR)/$(ARCH)/as)
$(call installto, $(PLATDEP)/$(ARCH)/as)
$(call cprogram, $(BINDIR)/$(PLATFORM)/as)
$(call installto, $(PLATDEP)/$(PLATFORM)/as)
endef
build-as = $(eval $(build-as-impl))

View file

@ -37,8 +37,8 @@ $(call cfile, $(OBJDIR)/$D/tables.c)
$(call file, $(LIBEM_DATA))
$(call file, $(LIBFLT_ARITH))
$(call cprogram, $(BINDIR)/$(ARCH)/ncg)
$(call installto, $(PLATDEP)/$(ARCH)/ncg)
$(call cprogram, $(BINDIR)/$(PLATFORM)/ncg)
$(call installto, $(PLATDEP)/$(PLATFORM)/ncg)
endef

15
mach/proto/top/build.mk Normal file
View file

@ -0,0 +1,15 @@
define build-top-impl
$(call reset)
$(eval cflags += -I$(OBJDIR)/$(PLATFORM)/top)
$(call cfile, mach/proto/top/queue.c)
$(call cfile, mach/proto/top/top.c)
$(eval $q: $(OBJDIR)/$(PLATFORM)/top/gen.h)
$(call topgen, $(OBJDIR)/$(PLATFORM)/top, mach/$(ARCH)/top/table)
$(call cprogram, $(OBJDIR)/$(PLATFORM)/top/top)
$(call installto, $(PLATDEP)/$(PLATFORM)/top)
endef
build-top = $(eval $(build-top-impl))

View file

@ -14,15 +14,48 @@ define build-platform-impl
$(eval PLATFORM_$(PLATFORM) := \
$(PLATIND)/descr/$(PLATFORM) \
$(PLATFORM_HEADERS_$(PLATFORM)) \
$(PLATDEP)/$(PLATFORM)/as \
$(PLATDEP)/$(PLATFORM)/ncg \
$(ARCHITECTURE_$(ARCH)))
$(foreach f, $(platform-headers), $(call build-platform-headers, $f))
# libsys
$(call reset)
$(foreach f, $(platform-libsys), $(call ackfile, $D/libsys/$f))
$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libsys.a)
$(call installto, $(PLATIND)/$(PLATFORM)/libsys.a)
# libem
$(call reset)
$(eval objdir := $(PLATFORM))
$(eval ackflags += -Ih)
$(foreach f, $(arch-libem-$(ARCH)), $(call ackfile, mach/$(ARCH)/libem/$f))
$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libem.a)
$(call installto, $(PLATIND)/$(PLATFORM)/libem.a)
# libend
$(call reset)
$(eval objdir := $(PLATFORM))
$(eval ackflags += -Ih)
$(foreach f, $(arch-libend-$(ARCH)), $(call ackfile, mach/$(ARCH)/libend/$f))
$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libend.a)
$(call installto, $(PLATIND)/$(PLATFORM)/libend.a)
# The tools themselves
$(call build-as)
$(call build-ncg)
# Build top only if the architecture asks for it.
$(if $(arch-top-$(ARCH)), $(call build-top))
# Language runtimes
$(foreach runtime, $(RUNTIMES), $(build-runtime-$(runtime)))
endef

View file

@ -30,5 +30,13 @@ platform-libsys := \
$(eval $(call build-platform))
define build-cpm-boot-impl
$(call reset)
$(call ackfile, $D/boot.s)
$(call installto, $(PLATIND)/$(PLATFORM)/boot.o)
endef
$(eval $(build-cpm-boot-impl))

View file

@ -10,7 +10,7 @@ var f=4
var d=8
var ARCH=i80
var PLATFORM=cpm
var PLATFORMDIR={EM}/lib/ack/{PLATFORM}
var PLATFORMDIR={EM}/share/ack/{PLATFORM}
var CPP_F=-D__unix
var ALIGN=-a0:1 -a1:1 -a2:1 -a3:1 -b0:0x0100
var MACHOPT_F=-m8
@ -23,7 +23,7 @@ var C_INCLUDES=-I{EM}/share/ack/{PLATFORM}/include -I{EM}/share/ack/include/ansi
name be
from .m.g
to .s
program {EM}/lib/ack/{ARCH}/ncg
program {EM}/lib/ack/{PLATFORM}/ncg
args <
stdout
need .e
@ -31,7 +31,7 @@ end
name asopt
from .s
to .so
program {EM}/lib/ack/{ARCH}/top
program {EM}/lib/ack/{PLATFORM}/top
args
optimizer
stdin
@ -40,7 +40,7 @@ end
name as
from .s.so
to .o
program {EM}/lib/ack/{ARCH}/as
program {EM}/lib/ack/{PLATFORM}/as
args - -o > <
prep cond
end

View file

@ -15,3 +15,14 @@ platform-libsys := \
$(eval $(call build-platform))
$(eval $(call build-liblinux))
define build-linux386-boot-impl
$(call reset)
$(call ackfile, $D/boot.s)
$(call installto, $(PLATIND)/$(PLATFORM)/boot.o)
endef
$(eval $(build-linux386-boot-impl))

View file

@ -27,7 +27,7 @@ var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi
name be
from .m.g
to .s
program {EM}/lib/ack/{ARCH}/ncg
program {EM}/lib/ack/{PLATFORM}/ncg
mapflag -gdb GF=-gdb
args {GF?} <
stdout
@ -36,7 +36,7 @@ end
name as
from .s.so
to .o
program {EM}/lib/ack/{ARCH}/as
program {EM}/lib/ack/{PLATFORM}/as
args - -o > <
prep cond
end

View file

@ -15,4 +15,11 @@ platform-libsys := \
$(eval $(call build-platform))
$(eval $(call build-liblinux))
define build-linux68k-boot-impl
$(call reset)
$(call ackfile, $D/boot.s)
$(call installto, $(PLATIND)/$(PLATFORM)/boot.o)
endef
$(eval $(build-linux68k-boot-impl))

View file

@ -27,7 +27,7 @@ var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi
name be
from .m.g
to .s
program {EM}/lib/ack/{ARCH}/ncg
program {EM}/lib/ack/{PLATFORM}/ncg
mapflag -gdb GF=-gdb
args {GF?} <
stdout
@ -36,7 +36,7 @@ end
name as
from .s.so
to .o
program {EM}/lib/ack/{ARCH}/as
program {EM}/lib/ack/{PLATFORM}/as
args - -o > <
prep cond
end

View file

@ -16,4 +16,16 @@ platform-libsys := \
$(eval $(call build-platform))
$(eval $(call build-liblinux))
define build-linuxppc-boot-impl
$(call reset)
$(call ackfile, $D/boot.s)
$(call installto, $(PLATIND)/$(PLATFORM)/boot.o)
endef
$(eval $(build-linuxppc-boot-impl))

View file

@ -28,4 +28,11 @@ platform-libsys := \
$(eval $(call build-platform))
define build-pc86-boot-impl
$(call reset)
$(call ackfile, $D/boot.s)
$(call installto, $(PLATIND)/$(PLATFORM)/boot.o)
endef
$(eval $(build-pc86-boot-impl))

View file

@ -23,7 +23,7 @@ var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi
name be
from .m.g
to .s
program {EM}/lib/ack/{ARCH}/ncg
program {EM}/lib/ack/{PLATFORM}/ncg
args <
stdout
need .e
@ -31,7 +31,7 @@ end
name as
from .s.so
to .o
program {EM}/lib/ack/{ARCH}/as
program {EM}/lib/ack/{PLATFORM}/as
args - -o > <
prep cond
end

View file

@ -46,6 +46,7 @@ $o: $1/Lpars.h
$1/Lpars.h: $2 $(LLGEN)
@echo LLGEN $1/Lpars.c
@mkdir -p $(dir $o)
$(hide) $(RM) $o $1/Lpars.h
$(hide) cd $(dir $o) && $(LLGEN) $(abspath $2)
$(foreach f,$o,$(call cfile,$f))

View file

@ -19,4 +19,5 @@ $(call build-simple-tool,ashow)
$(call build-simple-tool,asize)
$(call build-simple-tool,aslod)
$(call build-simple-tool,astrip)
$(call build-simple-tool,aelflod)

View file

@ -22,6 +22,9 @@ $(call cfile, $(OBJDIR)/$D/em_flag.c)
$(call cfile, $(OBJDIR)/$D/em_pseu.c)
$(call cfile, $(OBJDIR)/$D/em_mnem.c)
$(call cfile, $D/em_ptyp.c)
$(eval $q: $g)
$(call clibrary, $(LIBDIR)/libem_data.a)
$(eval LIBEM_DATA := $q)

34
util/led/build.mk Normal file
View file

@ -0,0 +1,34 @@
D := util/led
define build-led-impl
$(call reset)
$(call cfile, $D/archive.c)
$(call cfile, $D/error.c)
$(call cfile, $D/extract.c)
$(call cfile, $D/finish.c)
$(call cfile, $D/main.c)
$(call cfile, $D/memory.c)
$(call cfile, $D/output.c)
$(call cfile, $D/read.c)
$(call cfile, $D/relocate.c)
$(call cfile, $D/save.c)
$(call cfile, $D/scan.c)
$(call cfile, $D/sym.c)
$(call cfile, $D/write.c)
$(call file, $(LIBSTRING))
$(call file, $(LIBOBJECT))
$(call cprogram, $(BINDIR)/em_led)
$(call installto, $(PLATDEP)/em_led)
$(call reset)
$(eval q := $D/ack.out.5)
$(call installto, $(INSDIR)/share/man/man5/ack.out.5)
$(call reset)
$(eval q := $D/led.6)
$(call installto, $(INSDIR)/share/man/man6/led.6)
endef
$(eval $(build-led-impl))

View file

@ -32,6 +32,8 @@ $(OBJDIR)/$D/enterkeyw.c: $D/cvtkeywords $D/keywords
$(hide) cd $$(dir $$@) && sh $(abspath $D/cvtkeywords) $(abspath $D/keywords)
$(call cfile, $(OBJDIR)/$D/enterkeyw.c)
$(eval $q: $(INCDIR)/em_spec.h)
$(call file, $(LIBEM_DATA))
$(call cprogram, $(BINDIR)/ncgg)
$(eval NCGG := $o)

50
util/topgen/build.mk Normal file
View file

@ -0,0 +1,50 @@
D := util/topgen
# Rule to build topgen.
define build-topgen-impl
$(call reset)
$(eval cflags += -I$(OBJDIR)/$D -I$D)
$(call cfile, $D/LLlex.c)
$(call cfile, $D/hash.c)
$(call cfile, $D/main.c)
$(call cfile, $D/pattern.c)
$(call cfile, $D/symtab.c)
$(eval $q: $(OBJDIR)/$D/Lpars.h)
$(call llgen, $(OBJDIR)/$D, $D/topgen.g)
$(call file, $(LIBASSERT))
$(call file, $(LIBPRINT))
$(call file, $(LIBALLOC))
$(call file, $(LIBSYSTEM))
$(call file, $(LIBSTRING))
$(call cprogram, $(BINDIR)/topgen)
TOPGEN := $o
endef
$(eval $(build-topgen-impl))
# Rule to invoke to *use* LLgen.
#
# $1: directory to put output files
# $2: input files
#
# Output files are *not* compiled (gen.c is expected to be included by
# something).
define topgen-impl
$(eval CLEANABLES += $1/gen.h $1/gen.c)
$1/gen.h: $1/gen.c
$1/gen.c: $2 $(TOPGEN)
@echo TOPGEN $$@
@mkdir -p $$(dir $$@)
$(hide) $(RM) $1/gen.h $1/gen.c
$(hide) cd $$(dir $$@) && $(abspath $(TOPGEN)) $(abspath $2)
endef
topgen = $(eval $(call topgen-impl,$1,$2))