diff --git a/Makefile b/Makefile index 637e8baaf..98f36bef3 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/lang/cem/libcc.ansi/build.mk b/lang/cem/libcc.ansi/build.mk index 727d04718..a9434ceb4 100644 --- a/lang/cem/libcc.ansi/build.mk +++ b/lang/cem/libcc.ansi/build.mk @@ -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)) diff --git a/mach/build.mk b/mach/build.mk deleted file mode 100644 index 368e6b0ca..000000000 --- a/mach/build.mk +++ /dev/null @@ -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)) - diff --git a/mach/i386/build.mk b/mach/i386/build.mk index f4670cc2f..acd5e51eb 100644 --- a/mach/i386/build.mk +++ b/mach/i386/build.mk @@ -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 diff --git a/mach/i80/build.mk b/mach/i80/build.mk index bd3cfc2b3..ce9b07c67 100644 --- a/mach/i80/build.mk +++ b/mach/i80/build.mk @@ -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 diff --git a/mach/i86/build.mk b/mach/i86/build.mk index 2f999023d..1613b651f 100644 --- a/mach/i86/build.mk +++ b/mach/i86/build.mk @@ -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 diff --git a/mach/m68020/build.mk b/mach/m68020/build.mk index 2ddaf85a0..5dac37653 100644 --- a/mach/m68020/build.mk +++ b/mach/m68020/build.mk @@ -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 diff --git a/mach/powerpc/build.mk b/mach/powerpc/build.mk index 75cbeb5d0..e69de29bb 100644 --- a/mach/powerpc/build.mk +++ b/mach/powerpc/build.mk @@ -1,8 +0,0 @@ -ARCH := powerpc -OPTIMISATION := -O - -D := mach/powerpc - -$(eval $(call build-architecture)) - - diff --git a/mach/proto/as/build.mk b/mach/proto/as/build.mk index f7b56ca66..039630f75 100644 --- a/mach/proto/as/build.mk +++ b/mach/proto/as/build.mk @@ -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)) diff --git a/mach/proto/ncg/build.mk b/mach/proto/ncg/build.mk index f3782322b..d37c623d4 100644 --- a/mach/proto/ncg/build.mk +++ b/mach/proto/ncg/build.mk @@ -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 diff --git a/mach/proto/top/build.mk b/mach/proto/top/build.mk new file mode 100644 index 000000000..56f41c276 --- /dev/null +++ b/mach/proto/top/build.mk @@ -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)) diff --git a/plat/build.mk b/plat/build.mk index 3a80c438d..3f8994fc9 100644 --- a/plat/build.mk +++ b/plat/build.mk @@ -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 diff --git a/plat/cpm/build.mk b/plat/cpm/build.mk index 2f8836956..54ed3d839 100644 --- a/plat/cpm/build.mk +++ b/plat/cpm/build.mk @@ -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)) + diff --git a/plat/cpm/descr b/plat/cpm/descr index 436dc40cc..a72f50276 100644 --- a/plat/cpm/descr +++ b/plat/cpm/descr @@ -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 diff --git a/plat/linux386/build.mk b/plat/linux386/build.mk index 760cc69f6..f35fa6be7 100644 --- a/plat/linux386/build.mk +++ b/plat/linux386/build.mk @@ -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)) + + + + diff --git a/plat/linux386/descr b/plat/linux386/descr index a0d23ad3b..ff2b26dfb 100644 --- a/plat/linux386/descr +++ b/plat/linux386/descr @@ -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 diff --git a/plat/linux68k/build.mk b/plat/linux68k/build.mk index b230b2500..7a1e7223b 100644 --- a/plat/linux68k/build.mk +++ b/plat/linux68k/build.mk @@ -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)) diff --git a/plat/linux68k/descr b/plat/linux68k/descr index 124955b55..14f973d52 100644 --- a/plat/linux68k/descr +++ b/plat/linux68k/descr @@ -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 diff --git a/plat/linuxppc/build.mk b/plat/linuxppc/build.mk index 515d498a6..d19fa5aa3 100644 --- a/plat/linuxppc/build.mk +++ b/plat/linuxppc/build.mk @@ -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)) + + + + + diff --git a/plat/pc86/build.mk b/plat/pc86/build.mk index 8a7ec92f1..1ae9e5f49 100644 --- a/plat/pc86/build.mk +++ b/plat/pc86/build.mk @@ -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)) diff --git a/plat/pc86/descr b/plat/pc86/descr index f02ab3eed..a3f11fc4f 100644 --- a/plat/pc86/descr +++ b/plat/pc86/descr @@ -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 diff --git a/util/LLgen/build.mk b/util/LLgen/build.mk index 44b63f891..3c40d1886 100644 --- a/util/LLgen/build.mk +++ b/util/LLgen/build.mk @@ -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)) diff --git a/util/amisc/build.mk b/util/amisc/build.mk index e7f71e33f..03f44b5e9 100644 --- a/util/amisc/build.mk +++ b/util/amisc/build.mk @@ -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) diff --git a/util/data/build.mk b/util/data/build.mk index c9b601da1..424712956 100644 --- a/util/data/build.mk +++ b/util/data/build.mk @@ -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) diff --git a/util/led/build.mk b/util/led/build.mk new file mode 100644 index 000000000..d96dd35c6 --- /dev/null +++ b/util/led/build.mk @@ -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)) diff --git a/util/ncgg/build.mk b/util/ncgg/build.mk index 97576794d..c3a7f31fa 100644 --- a/util/ncgg/build.mk +++ b/util/ncgg/build.mk @@ -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) diff --git a/util/topgen/build.mk b/util/topgen/build.mk new file mode 100644 index 000000000..4ef15c278 --- /dev/null +++ b/util/topgen/build.mk @@ -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))