Commits

dtrg  committed 609aeed

Made a start on building the runtimes for each platform and language; the
Linuxes all build.

  • Participants
  • Parent commits 7f0b1e3
  • Branches dtrg-buildsystem

Comments (0)

Files changed (23)

 include modules/src/flt_arith/build.mk
 include modules/src/em_code/build.mk
 include modules/src/em_mes/build.mk
+include modules/src/read_em/build.mk
 
 include util/amisc/build.mk
 include util/cmisc/build.mk
 include util/opt/build.mk
 include util/ncgg/build.mk
 include util/arch/build.mk
+include util/misc/build.mk
 
 include lang/cem/build.mk
 
 include mach/proto/as/build.mk
 include mach/proto/ncg/build.mk
 
+include plat/linux/liblinux/build.mk
+
 include plat/build.mk
 include plat/pc86/build.mk
 include plat/cpm/build.mk
+include plat/linux386/build.mk
+include plat/linux68k/build.mk
+include plat/linuxppc/build.mk
 
 .PHONY: installables
 installables: $(INSTALLABLES)

File first/core.mk

 		$(PLATIND)/descr/$(PLATFORM) \
 		$(PLATDEP)/$(PLATFORM)/as \
 		$(CCOMPILER) \
-		$(PLATFORM_$(PLATFORM))
+		$(PLATFORM_$(PLATFORM)) \
+		$(EM_ENCODE)
 	@echo ACK $o
 	@mkdir -p $(dir $o)
 	$(hide) ACKDIR=$(INSDIR) $(ACK) $(ACKFLAGS) $(ackflags) -m$(PLATFORM) -c -o $o $s
 
 define ackfile
 	$(eval s := $1)
-	$(eval o := $(OBJDIR)/$(basename $1).o)
-	$(eval d := $(OBJDIR)/$(basename $1).d)
+	$(eval o := $(OBJDIR)/$(objdir)/$(basename $1).o)
+	$(eval d := $(OBJDIR)/$(objdir)/$(basename $1).d)
 	$(eval DEPENDS += $d)
 	$(eval CLEANABLES += $o $d)
 	$(eval q += $o)

File lang/cem/libcc.ansi/build.mk

 		assert.h \
 		ctype.h \
 		errno.h \
+		fcntl.h \
 		float.h \
 		limits.h \
 		math.h \
 endef
 
 $(eval $(build-libcc-ansi-headers-impl))
+
+define build-runtime-libcc-ansi-impl
+
+$(call reset)
+$(eval objdir := $(PLATFORM))
+
+# Assert
+
+$(call ackfile, lang/cem/libcc.ansi/assert/assert.c)
+
+# CType
+
+$(call ackfile, lang/cem/libcc.ansi/ctype/tolower.c)
+$(call ackfile, lang/cem/libcc.ansi/ctype/toupper.c)
+$(call acktabgen, lang/cem/libcc.ansi/ctype/char.tab)
+
+$(eval g := \
+	isalnum.c \
+	isalpha.c \
+	iscntrl.c \
+	isdigit.c \
+	isgraph.c \
+	islower.c \
+	isprint.c \
+	ispunct.c \
+	isspace.c \
+	isupper.c \
+	isxdigit.c \
+	isascii.c)
+$(eval g := $(addprefix $(OBJDIR)/$(objdir)/ctype/, $g))
+
+$(wordlist 2, $(words $g), $g): $(firstword $g)
+$(firstword $g): lang/cem/libcc.ansi/ctype/genfiles
+	@echo GENFILES $$@
+	@mkdir -p $$(dir $$@)
+	$(hide) cd $$(dir $$@) && sh $$(abspath $$^)
+
+$(eval CLEANABLES += $g)
+$(foreach f, $g, $(call ackfile, $f))
+
+# errno
+
+$(call ackfile, lang/cem/libcc.ansi/errno/errlist.c)
+
+# locale
+
+$(call ackfile, lang/cem/libcc.ansi/locale/localeconv.c)
+$(call ackfile, lang/cem/libcc.ansi/locale/setlocale.c)
+
+# math
+
+$(call ackfile, lang/cem/libcc.ansi/math/asin.c)
+$(call ackfile, lang/cem/libcc.ansi/math/atan2.c)
+$(call ackfile, lang/cem/libcc.ansi/math/atan.c)
+$(call ackfile, lang/cem/libcc.ansi/math/ceil.c)
+$(call ackfile, lang/cem/libcc.ansi/math/fabs.c)
+$(call ackfile, lang/cem/libcc.ansi/math/pow.c)
+$(call ackfile, lang/cem/libcc.ansi/math/log10.c)
+$(call ackfile, lang/cem/libcc.ansi/math/log.c)
+$(call ackfile, lang/cem/libcc.ansi/math/sin.c)
+$(call ackfile, lang/cem/libcc.ansi/math/sinh.c)
+$(call ackfile, lang/cem/libcc.ansi/math/sqrt.c)
+$(call ackfile, lang/cem/libcc.ansi/math/tan.c)
+$(call ackfile, lang/cem/libcc.ansi/math/tanh.c)
+$(call ackfile, lang/cem/libcc.ansi/math/exp.c)
+$(call ackfile, lang/cem/libcc.ansi/math/ldexp.c)
+$(call ackfile, lang/cem/libcc.ansi/math/fmod.c)
+$(call ackfile, lang/cem/libcc.ansi/math/floor.c)
+$(call ackfile, lang/cem/libcc.ansi/math/hugeval.c)
+$(call ackfile, lang/cem/libcc.ansi/math/frexp.e)
+$(call ackfile, lang/cem/libcc.ansi/math/modf.e)
+$(call ackfile, lang/cem/libcc.ansi/math/isnan.c)
+
+# Misc
+
+$(call ackfile, lang/cem/libcc.ansi/misc/environ.c)
+# (lots of stuff missing here, as not being appropriate on modern systems)
+
+# setjmp
+
+$(call ackfile, lang/cem/libcc.ansi/setjmp/setjmp.e)
+
+# signal
+
+$(call ackfile, lang/cem/libcc.ansi/signal/raise.c)
+
+# stdio
+
+$(call ackfile, lang/cem/libcc.ansi/stdio/tmpfile.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/tmpnam.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/fopen.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/freopen.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/setbuf.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/setvbuf.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/perror.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/fprintf.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/printf.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/sprintf.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/vfprintf.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/vprintf.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/vsprintf.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/doprnt.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/icompute.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/fscanf.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/scanf.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/sscanf.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/doscan.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/fgetc.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/fgets.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/getc.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/getchar.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/gets.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/putc.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/putchar.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/fputc.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/puts.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/fputs.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/ungetc.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/fread.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/fwrite.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/fgetpos.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/fsetpos.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/rewind.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/fseek.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/ftell.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/clearerr.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/feof.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/ferror.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/fileno.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/fltpr.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/ecvt.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/fillbuf.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/fclose.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/flushbuf.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/fflush.c)
+$(call ackfile, lang/cem/libcc.ansi/stdio/data.c)
+
+# stdlib
+
+$(call ackfile, lang/cem/libcc.ansi/stdlib/abort.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/abs.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/atof.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/atoi.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/atol.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/bsearch.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/div.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/atexit.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/exit.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/getenv.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/labs.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/ldiv.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/mblen.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/mbstowcs.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/mbtowc.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/qsort.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/rand.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/strtod.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/strtol.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/wcstombs.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/wctomb.c)
+$(call ackfile, lang/cem/libcc.ansi/stdlib/ext_comp.c)
+
+$(eval g := $(OBJDIR)/$(objdir)/malloc.c)
+$(eval CLEANABLES += $g)
+$(eval srcs := \
+	READ_ME size_type.h param.h impl.h check.h \
+	log.h phys.h mal.c log.c phys.c check.c)
+$(eval srcs := $(addprefix lang/cem/libcc.ansi/stdlib/malloc/, $(srcs)))
+
+$g: lang/cem/libcc.ansi/stdlib/malloc/add_file $(srcs)
+	@echo MALLOC $g
+	@mkdir -p $(dir $g)
+	$(hide) $(RM) $g && for i in $(srcs); do \
+		lang/cem/libcc.ansi/stdlib/malloc/add_file $$$$i >> $g; done
+
+$(call ackfile, $g)
+
+# String
+
+$(call ackfile, lang/cem/libcc.ansi/string/memchr.c)
+$(call ackfile, lang/cem/libcc.ansi/string/memcmp.c)
+$(call ackfile, lang/cem/libcc.ansi/string/memcpy.c)
+$(call ackfile, lang/cem/libcc.ansi/string/memmove.c)
+$(call ackfile, lang/cem/libcc.ansi/string/memset.c)
+$(call ackfile, lang/cem/libcc.ansi/string/strcat.c)
+$(call ackfile, lang/cem/libcc.ansi/string/strchr.c)
+$(call ackfile, lang/cem/libcc.ansi/string/strcmp.c)
+$(call ackfile, lang/cem/libcc.ansi/string/strcoll.c)
+$(call ackfile, lang/cem/libcc.ansi/string/strcpy.c)
+$(call ackfile, lang/cem/libcc.ansi/string/strcspn.c)
+$(call ackfile, lang/cem/libcc.ansi/string/strerror.c)
+$(call ackfile, lang/cem/libcc.ansi/string/strncat.c)
+$(call ackfile, lang/cem/libcc.ansi/string/strncpy.c)
+$(call ackfile, lang/cem/libcc.ansi/string/strrchr.c)
+$(call ackfile, lang/cem/libcc.ansi/string/strstr.c)
+$(call ackfile, lang/cem/libcc.ansi/string/strlen.c)
+$(call ackfile, lang/cem/libcc.ansi/string/strtok.c)
+$(call ackfile, lang/cem/libcc.ansi/string/strpbrk.c)
+$(call ackfile, lang/cem/libcc.ansi/string/strspn.c)
+$(call ackfile, lang/cem/libcc.ansi/string/strncmp.c)
+$(call ackfile, lang/cem/libcc.ansi/string/strxfrm.c)
+
+# Time
+
+$(call ackfile, lang/cem/libcc.ansi/time/ctime.c)
+$(call ackfile, lang/cem/libcc.ansi/time/asctime.c)
+$(call ackfile, lang/cem/libcc.ansi/time/localtime.c)
+$(call ackfile, lang/cem/libcc.ansi/time/clock.c)
+$(call ackfile, lang/cem/libcc.ansi/time/difftime.c)
+$(call ackfile, lang/cem/libcc.ansi/time/gmtime.c)
+$(call ackfile, lang/cem/libcc.ansi/time/mktime.c)
+$(call ackfile, lang/cem/libcc.ansi/time/strftime.c)
+$(call ackfile, lang/cem/libcc.ansi/time/time.c)
+$(call ackfile, lang/cem/libcc.ansi/time/tzset.c)
+$(call ackfile, lang/cem/libcc.ansi/time/misc.c)
+
+$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libc.a)
+$(call installto, $(PLATIND)/$(PLATFORM)/libc.a)
+
+endef
+
+build-runtime-libcc-ansi = $(eval $(build-runtime-libcc-ansi-impl))
+
+$(eval RUNTIMES += libcc-ansi)
+

File mach/m68020/as/mach0.c

 #define	THREE_PASS		/* branch and offset optimization */
 #define	BYTES_REVERSED		/* high order byte has lowest address */
 #define	WORDS_REVERSED		/* high order word has lowest address */
-/*#define	LISTING			/* enable listing facilities */
+/*#define	LISTING	*/		/* enable listing facilities */
 #define RELOCATION		/* generate relocatable code */
 #define DEBUG 0
 

File mach/proto/as/build.mk

     $(call reset)
 
     $(eval cflags += -Imach/$(ARCH)/as -I$(OBJDIR)/$D)
-    $(eval objdir := $D)
+    $(eval objdir := $(PLATFORM))
 
     $(call cfile, mach/proto/as/comm3.c)
     $(call dependson, $(OBJDIR)/$D/y.tab.h)

File mach/proto/ncg/build.mk

 $(call reset)
 
 $(eval cflags += -Imach/$(ARCH)/ncg -I$(OBJDIR)/$D -Imach/proto/ncg)
-$(eval objdir := $D/ncg)
+$(eval objdir := $(PLATFORM))
 
 $(call cfile, mach/proto/ncg/codegen.c)
 $(call cfile, mach/proto/ncg/compute.c)
 	@echo NCGG $$@
 	@mkdir -p $$(dir $$@)
 	$(hide) cd $$(dir $$@) && \
-		$(abspath $(CPPANSI)) $(abspath mach/$(ARCH)/ncg/table) | $(abspath $(NCGG))
+		$(abspath $(CPPANSI)) -I$(abspath mach/$(ARCH)/ncg) $(abspath mach/$(ARCH)/ncg/table) | $(abspath $(NCGG))
 	$(hide) mv $(OBJDIR)/$D/tables.H $(OBJDIR)/$D/tables.h
 
 $(call cfile, $(OBJDIR)/$D/tables.c)

File modules/src/em_code/build.mk

 define build-em_code-impl
 	$(call reset)
 	$(eval cflags += $3)
-	$(eval objdir := $D/$1)
+	$(eval objdir := $1)
 	$(call cfile, $D/bhcst.c)
 	$(call cfile, $D/bhdlb.c)
 	$(call cfile, $D/bhdnam.c)

File modules/src/read_em/build.mk

+D := modules/src/read_em
+
+define build-read_em-headers-impl
+
+$(eval g := $(OBJDIR)/$D/C_mnem_narg.h)
+$(eval CLEANABLES += $g)
+$g: $D/m_C_mnem_na h/em_table
+	@echo M_C_MNEM_NA $g
+	@mkdir -p $(dir $g)
+	$(hide) cd $D && $(abspath $D/m_C_mnem_na) $(abspath h/em_table) > $(abspath $g)
+
+$(eval g := $(OBJDIR)/$D/C_mnem.h)
+$(eval CLEANABLES += $g)
+$g: $D/m_C_mnem h/em_table
+	@echo M_C_MNEM $g
+	@mkdir -p $(dir $g)
+	$(hide) cd $D && $(abspath $D/m_C_mnem) $(abspath h/em_table) > $(abspath $g)
+
+endef
+
+define build-read_em-impl
+
+$(call reset)
+$(eval objdir := emev)
+$(eval cflags += -I$(OBJDIR)/$D -DPRIVATE=static -DEXPORT= -DNDEBUG -DCHECKING)
+$(call cfile, $D/EM_vars.c)
+$(call cfile, $D/read_em.c)
+$(call cfile, $D/mkcalls.c)
+$(eval $q: $(OBJDIR)/$D/C_mnem_narg.h)
+$(eval $q: $(OBJDIR)/$D/C_mnem.h)
+$(call clibrary, $(LIBDIR)/lib_read_emeV.a)
+$(eval LIBREAD_EMEV := $q)
+
+$(call reset)
+$(eval objdir := emkv)
+$(eval cflags += -I$(OBJDIR)/$D -DPRIVATE=static -DEXPORT= -DNDEBUG -DCHECKING -DCOMPACT)
+$(call cfile, $D/EM_vars.c)
+$(call cfile, $D/read_em.c)
+$(call cfile, $D/mkcalls.c)
+$(eval $q: $(OBJDIR)/$D/C_mnem_narg.h)
+$(eval $q: $(OBJDIR)/$D/C_mnem.h)
+$(call clibrary, $(LIBDIR)/lib_read_emkV.a)
+$(eval LIBREAD_EMKV := $q)
+
+$(call reset)
+$(eval q := $D/em_comp.h)
+$(call installto, $(INCDIR)/em_comp.h)
+
+endef
+
+$(eval $(call build-read_em-headers-impl))
+$(eval $(call build-read_em-impl))
+
+

File plat/build.mk

 	$(eval q := $D/descr)
 	$(call installto, $(PLATIND)/descr/$(PLATFORM))
 
-	$(foreach f, $1, $(call build-platform-headers, $f))
-
 	$(eval PLATFORM_$(PLATFORM) := \
 			$(PLATFORM_HEADERS_$(PLATFORM)) \
 			$(PLATDEP)/$(PLATFORM)/ncg)
 
+	$(foreach f, $(platform-headers), $(call build-platform-headers, $f))
+
+	$(call reset)
+	$(foreach f, $(platform-libsys), $(call ackfile, $D/libsys/$f))
+	$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libsys.a)
+	$(call installto, $(PLATIND)/$(PLATFORM)/libsys.a)
+
     $(call build-as)
     $(call build-ncg)
+
+    $(foreach runtime, $(RUNTIMES), $(build-runtime-$(runtime)))
 endef
 
 build-platform = $(eval $(call build-platform-impl, $1))

File plat/cpm/build.mk

 
 D := plat/cpm
 
-$(eval $(call build-platform, \
+platform-headers := \
 	ack/config.h \
 	cpm.h \
-	unistd.h \
-))
+	unistd.h
 
-include plat/cpm/libsys/build.mk
+platform-libsys := \
+	_bdos.s \
+	_hol0.s \
+	_inn2.s \
+	_trap.s \
+	brk.c \
+	close.c \
+	creat.c \
+	errno.s \
+	getpid.c \
+	isatty.c \
+	kill.c \
+	lseek.c \
+	open.c \
+	read.c \
+	signal.c \
+	time.c \
+	write.c
 
+$(eval $(call build-platform))
+
+
+

File plat/cpm/libsys/build.mk

-D := plat/cpm/libsys
-
-define build-cpm-libsys-impl
-	$(call reset)
-	$(call ackfile, $D/_bdos.s)
-	$(call ackfile, $D/_hol0.s)
-	$(call ackfile, $D/_inn2.s)
-	$(call ackfile, $D/_trap.s)
-	$(call ackfile, $D/brk.c)
-	$(call ackfile, $D/close.c)
-	$(call ackfile, $D/creat.c)
-	$(call ackfile, $D/errno.s)
-	$(call ackfile, $D/getpid.c)
-	$(call ackfile, $D/isatty.c)
-	$(call ackfile, $D/kill.c)
-	$(call ackfile, $D/lseek.c)
-	$(call ackfile, $D/open.c)
-	$(call ackfile, $D/read.c)
-	$(call ackfile, $D/signal.c)
-	$(call ackfile, $D/time.c)
-	$(call ackfile, $D/write.c)
-
-	$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libsys.a)
-	$(call installto, $(PLATIND)/$(PLATFORM)/libsys.a)
-endef
-
-$(eval $(build-cpm-libsys-impl))
-

File plat/linux/liblinux/build.mk

+define build-liblinux-impl
+
+$(call reset)
+$(eval objdir := $(PLATFORM))
+$(call ackfile, plat/linux/liblinux/_exit.c)
+$(call ackfile, plat/linux/liblinux/_hol0.s)
+$(call ackfile, plat/linux/liblinux/brk.c)
+$(call ackfile, plat/linux/liblinux/close.c)
+$(call ackfile, plat/linux/liblinux/creat.c)
+$(call ackfile, plat/linux/liblinux/errno.s)
+$(call ackfile, plat/linux/liblinux/getpid.c)
+$(call ackfile, plat/linux/liblinux/gettimeofday.c)
+$(call ackfile, plat/linux/liblinux/isatty.c)
+$(call ackfile, plat/linux/liblinux/kill.c)
+$(call ackfile, plat/linux/liblinux/lseek.c)
+$(call ackfile, plat/linux/liblinux/open.c)
+$(call ackfile, plat/linux/liblinux/read.c)
+$(call ackfile, plat/linux/liblinux/sbrk.c)
+$(call ackfile, plat/linux/liblinux/signal.c)
+$(call ackfile, plat/linux/liblinux/write.c)
+
+$(call acklibrary, $(OBJDIR)/$D/liblinux.a)
+$(call installto, $(PLATIND)/$(PLATFORM)/liblinux.a)
+
+endef
+
+build-liblinux = $(eval $(build-liblinux-impl))

File plat/linux386/build.mk

+ARCH := i386
+PLATFORM := linux386
+OPTIMISATION := -O
+
+D := plat/linux386/
+
+platform-headers := \
+	ack/config.h \
+	sys/ioctl.h \
+	unistd.h
+
+platform-libsys := \
+	_syscall.s
+
+$(eval $(call build-platform))
+$(eval $(call build-liblinux))
+

File plat/linux386/descr

 var d=8
 var ARCH=i386
 var PLATFORM=linux386
-var PLATFORMDIR={EM}/lib/{PLATFORM}
+var PLATFORMDIR={EM}/share/ack/{PLATFORM}
 var CPP_F=-D__unix
 var ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 -b0:0x08048054
 var C_LIB={PLATFORMDIR}/libc-ansi.a
 # Override the setting in fe so that files compiled for linux386 can see
 # the platform-specific headers.
 
-var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/include/ansi
+var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi
 
 name be
 	from .m.g
 	to .s
-	program {EM}/lib.bin/{PLATFORM}/ncg
+	program {EM}/lib/ack/{PLATFORM}/ncg
 	mapflag -gdb GF=-gdb
 	args {GF?} <
 	stdout
 name as
 	from .s.so
 	to .o
-	program {EM}/lib.bin/{PLATFORM}/as
+	program {EM}/lib/ack/{PLATFORM}/as
 	args - -o > <
 	prep cond
 end
 name led
 	from .o.a
 	to .out
-	program {EM}/lib.bin/em_led
+	program {EM}/lib/ack/em_led
 	mapflag -l* LNAME={PLATFORMDIR}/lib*
 	mapflag -fp FLOATS={EM}/{LIB}fp
 	args {ALIGN} {SEPID?} \

File plat/linux68k/build.mk

+ARCH := m68020
+PLATFORM := linux68k
+OPTIMISATION := -O6
+
+D := plat/linux68k/
+
+platform-headers := \
+	ack/config.h \
+	sys/ioctl.h \
+	unistd.h
+
+platform-libsys := \
+	_syscall.s
+
+$(eval $(call build-platform))
+$(eval $(call build-liblinux))
+
+

File plat/linux68k/descr

 var d=8
 var ARCH=m68020
 var PLATFORM=linux68k
-var PLATFORMDIR={EM}/lib/{PLATFORM}
+var PLATFORMDIR={EM}/share/ack/{PLATFORM}
 var CPP_F=-D__unix -D__mc68020 -D__m68k -D__mc68000 -D__M68020
 var ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 -b0:0x08000054
 var C_LIB={PLATFORMDIR}/libc-ansi.a
 # Override the setting in fe so that files compiled for linux68k can see
 # the platform-specific headers.
 
-var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/include/ansi
+var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi
 
 name be
 	from .m.g
 	to .s
-	program {EM}/lib.bin/{PLATFORM}/ncg
+	program {EM}/lib/ack/{PLATFORM}/ncg
 	mapflag -gdb GF=-gdb
 	args {GF?} <
 	stdout
 name as
 	from .s.so
 	to .o
-	program {EM}/lib.bin/{PLATFORM}/as
+	program {EM}/lib/ack/{PLATFORM}/as
 	args - -o > <
 	prep cond
 end
 name led
 	from .o.a
 	to .out
-	program {EM}/lib.bin/em_led
+	program {EM}/lib/ack/em_led
 	mapflag -l* LNAME={PLATFORMDIR}/lib*
 	mapflag -fp FLOATS={EM}/{LIB}fp
 	args {ALIGN} {SEPID?} \

File plat/linuxppc/build.mk

+ARCH := powerpc
+PLATFORM := linuxppc
+OPTIMISATION := -O6
+
+D := plat/linuxppc/
+
+platform-headers := \
+	ack/config.h \
+	sys/ioctl.h \
+	unistd.h
+
+platform-libsys := \
+	_syscall.s \
+	trap.s
+
+$(eval $(call build-platform))
+$(eval $(call build-liblinux))
+
+

File plat/linuxppc/descr

 var d=8
 var ARCH=powerpc
 var PLATFORM=linuxppc
-var PLATFORMDIR={EM}/lib/{PLATFORM}
+var PLATFORMDIR={EM}/share/ack/{PLATFORM}
 var CPP_F=-D__unix -D__POWERPC
 var ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 -b0:0x80000054
 var C_LIB={PLATFORMDIR}/libc-ansi.a
 # Override the setting in fe so that files compiled for linuxppc can see
 # the platform-specific headers.
 
-var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/include/ansi
+var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi
 
 name be
 	from .m.g
 	to .s
-	program {EM}/lib.bin/{PLATFORM}/ncg
+	program {EM}/lib/ack/{PLATFORM}/ncg
 	mapflag -gdb GF=-gdb
 	args {GF?} <
 	stdout
 name asopt
 	from .s
 	to .so
-	program {EM}/lib.bin/{PLATFORM}/top
+	program {EM}/lib/ack/{PLATFORM}/top
 	args
 	optimizer
 	stdin
 name as
 	from .s.so
 	to .o
-	program {EM}/lib.bin/{PLATFORM}/as
+	program {EM}/lib/ack/{PLATFORM}/as
 	args - -o > <
 	prep cond
 end
 name led
 	from .o.a
 	to .out
-	program {EM}/lib.bin/em_led
+	program {EM}/lib/ack/em_led
 	mapflag -l* LNAME={PLATFORMDIR}/lib*
 	mapflag -fp FLOATS={EM}/{LIB}fp
 	args {ALIGN} {SEPID?} \

File plat/pc86/build.mk

 
 D := plat/pc86/
 
-$(eval $(call build-platform, \
+platform-headers := \
 	ack/config.h \
-	unistd.h \
-))
+	unistd.h
 
-include plat/pc86/libsys/build.mk
+platform-libsys := \
+	errno.s \
+	_hol0.s \
+	_sys_rawread.s \
+	_sys_rawwrite.s \
+	open.c \
+	creat.c \
+	close.c \
+	read.c \
+	write.c \
+	brk.c \
+	getpid.c \
+	kill.c \
+	isatty.c \
+	lseek.c \
+	time.c \
+	signal.c
 
+$(eval $(call build-platform))
 
+

File plat/pc86/libsys/build.mk

-D := plat/pc86/libsys
-
-define build-pc86-libsys-impl
-	$(call reset)
-	$(call ackfile, $D/errno.s)
-	$(call ackfile, $D/_hol0.s)
-	$(call ackfile, $D/_sys_rawread.s)
-	$(call ackfile, $D/_sys_rawwrite.s)
-	$(call ackfile, $D/open.c)
-	$(call ackfile, $D/creat.c)
-	$(call ackfile, $D/close.c)
-	$(call ackfile, $D/read.c)
-	$(call ackfile, $D/write.c)
-	$(call ackfile, $D/brk.c)
-	$(call ackfile, $D/getpid.c)
-	$(call ackfile, $D/kill.c)
-	$(call ackfile, $D/isatty.c)
-	$(call ackfile, $D/lseek.c)
-	$(call ackfile, $D/time.c)
-	$(call ackfile, $D/signal.c)
-	$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libsys.a)
-	$(call installto, $(PLATIND)/$(PLATFORM)/libsys.a)
-endef
-
-$(eval $(build-pc86-libsys-impl))
-

File util/cmisc/build.mk

 # Output file is compiled with cfile and queued.
 
 define tabgen-impl
-$(eval g := $(OBJDIR)/$(strip $1).c)
+$(eval g := $(OBJDIR)/$(objdir)/$(strip $1).c)
 
 $g: $1 $(TABGEN)
 	@echo TABGEN $g
 	$(hide) $(TABGEN) -f$(strip $1) > $g || $(RM) $g
 
 $(eval CLEANABLES += $g)
-$(call cfile,$g)
+$(call $2,$g)
 endef
 
-tabgen = $(eval $(call tabgen-impl,$1))
+tabgen = $(eval $(call tabgen-impl,$1,cfile))
+acktabgen = $(eval $(call tabgen-impl,$1,ackfile))
 

File util/data/build.mk

 	$(OBJDIR)/$D/em_mnem.c)
 
 $(eval CLEANABLES += $g)
-$g: $D/new_table h/em_table
+$(wordlist 2, $(words $g), $g): $(firstword $g)
+$(firstword $g): $D/new_table h/em_table
 	@echo DATA
 	@mkdir -p $(dir $g)
 	$(hide) $D/new_table h/em_table $(INCDIR) $(OBJDIR)/$D

File util/misc/build.mk

+D := util/misc
+
+define build-misc-impl
+	$(call reset)
+	$(call cfile, $D/esize.c)
+	$(call cprogram, $(BINDIR)/esize)
+	$(call installto, $(INSDIR)/bin/esize)
+
+	$(call reset)
+	$(eval q := $D/esize.1)
+	$(call installto, $(INSDIR)/share/man/man1/esize.1)
+
+	$(call reset)
+	$(eval objdir := encode)
+	$(call cfile, $D/convert.c)
+	$(eval $q: $(INCDIR)/em_comp.h $(INCDIR)/em_codeEK.h)
+	$(call file, $(LIBREAD_EMEV))
+	$(call file, $(LIBEMK))
+	$(call file, $(LIBEM_DATA))
+	$(call file, $(LIBALLOC))
+	$(call file, $(LIBPRINT))
+	$(call file, $(LIBSTRING))
+	$(call file, $(LIBSYSTEM))
+	$(call cprogram, $(BINDIR)/em_encode)
+	$(call installto, $(PLATDEP)/em_encode)
+	$(eval EM_ENCODE := $o)
+
+	$(call reset)
+	$(eval objdir := decode)
+	$(call cfile, $D/convert.c)
+	$(eval $q: $(INCDIR)/em_comp.h $(INCDIR)/em_codeEK.h)
+	$(call file, $(LIBREAD_EMKV))
+	$(call file, $(LIBEME))
+	$(call file, $(LIBEM_DATA))
+	$(call file, $(LIBALLOC))
+	$(call file, $(LIBPRINT))
+	$(call file, $(LIBSTRING))
+	$(call file, $(LIBSYSTEM))
+	$(call cprogram, $(BINDIR)/em_decode)
+	$(call installto, $(PLATDEP)/em_decode)
+	$(eval EM_DECODE := $o)
+
+	$(call reset)
+	$(eval q := $D/em_decode.6)
+	$(call installto, $(INSDIR)/share/man/man6/em_decode.6)
+endef
+
+$(eval $(build-misc-impl))