scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 7a03077ea6e8f3c3e87495764e51756970c12fea
parent 0e247b5f4f5742e31b8d57e30fd582e867533b9f
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon,  3 May 2021 19:27:06 +0200

build: Improve build system

This commits increases the separation between the different elements
that can affect the build system and add rules that can be used in
the future.

Diffstat:
MMakefile | 24++++++------------------
Dconfig/conf/amd64-dragonfly.mk | 3---
Dconfig/conf/amd64-linux.mk | 3---
Dconfig/conf/amd64-netbsd.mk | 3---
Dconfig/conf/amd64-openbsd.mk | 3---
Dconfig/conf/arm32-linux.mk | 3---
Dconfig/conf/arm64-linux.mk | 3---
Dconfig/conf/ppc32-linux.mk | 3---
Dconfig/host/bsd.mk | 3---
Dconfig/host/plan9.mk | 3---
Dconfig/host/unix.mk | 3---
Dconfig/tool/clang.mk | 8--------
Dconfig/tool/gnu-darwin.mk | 3---
Dconfig/tool/gnu.mk | 12------------
Dconfig/tool/pcc.mk | 3---
Rconfig/conf/amd64-darwin.mk -> scripts/build/conf/amd64-darwin.mk | 0
Ascripts/build/conf/amd64-dragonfly.mk | 3+++
Ascripts/build/conf/amd64-linux.mk | 3+++
Ascripts/build/conf/amd64-netbsd.mk | 3+++
Ascripts/build/conf/amd64-openbsd.mk | 3+++
Rconfig/conf/amd64-posix.mk -> scripts/build/conf/amd64-posix.mk | 0
Ascripts/build/conf/arm32-linux.mk | 3+++
Rconfig/conf/arm32-posix.mk -> scripts/build/conf/arm32-posix.mk | 0
Ascripts/build/conf/arm64-linux.mk | 3+++
Rconfig/conf/arm64-posix.mk -> scripts/build/conf/arm64-posix.mk | 0
Ascripts/build/conf/ppc32-linux.mk | 3+++
Rconfig/conf/ppc32-posix.mk -> scripts/build/conf/ppc32-posix.mk | 0
Ascripts/build/host/bsd.mk | 3+++
Ascripts/build/host/linux.mk | 3+++
Ascripts/build/host/plan9.mk | 3+++
Ascripts/build/host/posix.mk | 3+++
Ascripts/build/tool/clang.mk | 9+++++++++
Ascripts/build/tool/gnu-darwin.mk | 3+++
Ascripts/build/tool/gnu.mk | 12++++++++++++
Ascripts/build/tool/pcc.mk | 3+++
Rconfig/tool/unix.mk -> scripts/build/tool/unix.mk | 0
Mscripts/config | 7+++++--
Dscripts/mklib | 43-------------------------------------------
Mscripts/rules.mk | 231++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------
Msrc/Makefile | 15+++++++++------
Msrc/cmd/Makefile | 29+++++++++++++----------------
Msrc/cmd/as/Makefile | 16++++++++--------
Msrc/cmd/as/target/powerpc/powerpc.mk | 4++--
Msrc/cmd/as/target/powerpc/powerpc64.mk | 4++--
Msrc/cmd/as/target/x80/z80.mk | 4++--
Msrc/cmd/as/target/x86/amd64.mk | 4++--
Msrc/cmd/as/target/x86/i286.mk | 4++--
Msrc/cmd/as/target/x86/i386.mk | 4++--
Msrc/cmd/cc/Makefile | 10+++++-----
Msrc/cmd/cc/cc1/Makefile | 6+++---
Msrc/cmd/cc/cc2/Makefile | 30++++++++++++++++--------------
Msrc/cmd/cc/cc2/target/amd64-sysv/target.mk | 4++--
Msrc/cmd/cc/cc2/target/i386-sysv/target.mk | 4++--
Msrc/cmd/cc/cc2/target/qbe_amd64-sysv/target.mk | 4++--
Msrc/cmd/cc/cc2/target/z80-scc/target.mk | 4++--
Msrc/cmd/cc/posix/Makefile | 6+++---
Msrc/cmd/ld/Makefile | 4++--
Msrc/libc/Makefile | 14+++++++-------
Msrc/libc/arch/Makefile | 10+++++-----
Msrc/libc/arch/amd64/Makefile | 18++++++++----------
Msrc/libc/arch/amd64/darwin/Makefile | 3++-
Msrc/libc/arch/amd64/dragonfly/Makefile | 3++-
Msrc/libc/arch/amd64/linux/Makefile | 3++-
Msrc/libc/arch/amd64/netbsd/Makefile | 3++-
Msrc/libc/arch/amd64/openbsd/Makefile | 3++-
Msrc/libc/arch/arm/Makefile | 9++++-----
Msrc/libc/arch/arm/linux/Makefile | 3++-
Msrc/libc/arch/arm64/Makefile | 9++++-----
Msrc/libc/arch/arm64/linux/Makefile | 3++-
Msrc/libc/arch/i386/Makefile | 9++++-----
Msrc/libc/arch/i386/linux/Makefile | 3++-
Msrc/libc/arch/ppc/Makefile | 9++++-----
Msrc/libc/arch/ppc/linux/Makefile | 3++-
Msrc/libc/rules.mk | 26+++++++++++++-------------
Msrc/libc/string/Makefile | 1+
Msrc/libcrt/Makefile | 1+
Msrc/libcrt/amd64/Makefile | 4+++-
Msrc/libcrt/arm/Makefile | 4+++-
Msrc/libcrt/arm64/Makefile | 4+++-
Msrc/libcrt/i386/Makefile | 11+++++++----
Msrc/libcrt/ppc/Makefile | 4+++-
Msrc/libmach/Makefile | 13++++++-------
Msrc/libmach/Makefile.mach | 5+++--
Msrc/libmach/coff32/Makefile | 34++++++++++++++++++----------------
Msrc/libscc/Makefile | 26++++++++++++++------------
Mtests/Makefile | 19++++++++++---------
Mtests/as/execute/Makefile | 1+
Mtests/nm/execute/Makefile | 1+
Mtests/size/execute/Makefile | 1+
Mtests/strip/execute/Makefile | 1+
90 files changed, 469 insertions(+), 369 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,10 +1,15 @@ .POSIX: +DIRS =\ + src\ + src/libc\ + include/scc/scc\ + tests\ + PROJECTDIR = . include $(PROJECTDIR)/scripts/rules.mk PREFIX= /usr/local -DIRS = src src/libc include/scc/scc tests all: +@$(MAKE) `$(SCRIPTDIR)/config` toolchain @@ -23,23 +28,6 @@ dirs: $(SCRIPTDIR)/libc-proto xargs mkdir -p < $(SCRIPTDIR)/libc-proto touch dirs -$(DIRS): $(ENVIRON) FORCE - +@. $(ENVIRON) && cd $@ && $(MAKE) - -$(ENVIRON): - @rm -f $@; \ - trap 'r=$?;rm -f $$$$.tmp;exit $r' EXIT HUP INT QUIT TERM; \ - echo PATH=$$PATH:$$PWD/$(SCRIPTDIR):. > $$$$.tmp && \ - echo PREFIX=\"$(PREFIX)\" >> $$$$.tmp && \ - echo NM=\"$(NM)\" >> $$$$.tmp && \ - echo AR=\"$(AR)\" >> $$$$.tmp && \ - echo RL=\"$(RL)\" >> $$$$.tmp && \ - echo STD=\"$(STD)\" >> $$$$.tmp && \ - echo ARFLAGS=\"$(ARFLAGS)\" >> $$$$.tmp && \ - echo RLFLAGS=\"$(RLFLAGS)\" >> $$$$.tmp && \ - echo export PATH STD ARFLAGS RLFLAGS NM AR RL >> $$$$.tmp && \ - mv $$$$.tmp $@ - dep: $(FORALL) diff --git a/config/conf/amd64-dragonfly.mk b/config/conf/amd64-dragonfly.mk @@ -1,3 +0,0 @@ -include $(PROJECTDIR)/config/conf/amd64-posix.mk - -SYS = dragonfly diff --git a/config/conf/amd64-linux.mk b/config/conf/amd64-linux.mk @@ -1,3 +0,0 @@ -include $(PROJECTDIR)/config/conf/amd64-posix.mk - -SYS = linux diff --git a/config/conf/amd64-netbsd.mk b/config/conf/amd64-netbsd.mk @@ -1,3 +0,0 @@ -include $(PROJECTDIR)/config/conf/amd64-posix.mk - -SYS = netbsd diff --git a/config/conf/amd64-openbsd.mk b/config/conf/amd64-openbsd.mk @@ -1,3 +0,0 @@ -include $(PROJECTDIR)/config/conf/amd64-posix.mk - -SYS = openbsd diff --git a/config/conf/arm32-linux.mk b/config/conf/arm32-linux.mk @@ -1,3 +0,0 @@ -include $(PROJECTDIR)/config/conf/arm32-posix.mk - -SYS = linux diff --git a/config/conf/arm64-linux.mk b/config/conf/arm64-linux.mk @@ -1,3 +0,0 @@ -include $(PROJECTDIR)/config/conf/arm64-posix.mk - -SYS = linux diff --git a/config/conf/ppc32-linux.mk b/config/conf/ppc32-linux.mk @@ -1,3 +0,0 @@ -include $(PROJECTDIR)/config/conf/ppc32-posix.mk - -SYS = linux diff --git a/config/host/bsd.mk b/config/host/bsd.mk @@ -1,3 +0,0 @@ -include $(PROJECTDIR)/config/host/unix.mk - -HOSTCFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE diff --git a/config/host/plan9.mk b/config/host/plan9.mk @@ -1,3 +0,0 @@ -include $(PROJECTDIR)/config/host/unix.mk - -HOSTCFLAGS = -D_SUSV2_SOURCE diff --git a/config/host/unix.mk b/config/host/unix.mk @@ -1,3 +0,0 @@ -DRIVER = posix - -HOSTCFLAGS = -D_POSIX_C_SOURCE diff --git a/config/tool/clang.mk b/config/tool/clang.mk @@ -1,8 +0,0 @@ -include $(PROJECTDIR)/config/tool/gnu.mk - -COMP = clang -ASM = clang -TOOLASFLAGS = -c -LINKER = ld.lld -OBJCOPY = llvm-objcopy -OBJDUMP = llvm-objdump diff --git a/config/tool/gnu-darwin.mk b/config/tool/gnu-darwin.mk @@ -1,3 +0,0 @@ -include $(PROJECTDIR)/config/tool/gnu.mk - -RANLIBFLAGS = -c diff --git a/config/tool/gnu.mk b/config/tool/gnu.mk @@ -1,12 +0,0 @@ -TOOLCFLAGS = -std=c99 - -COMP = gcc -ASM = as -LINKER = ld -RANLIB = ranlib -ARCHIVE = ar - -ARCHIVEFLAGS = -U -NOPIE_CFLAGS = -nopie -NOPIE_LDFLAGS = -nopie -TOOLCFLAGS = -std=c99 -fno-stack-protector -static diff --git a/config/tool/pcc.mk b/config/tool/pcc.mk @@ -1,3 +0,0 @@ -include $(PROJECTDIR)/config/tool/gnu.mk - -COMP = pcc diff --git a/config/conf/amd64-darwin.mk b/scripts/build/conf/amd64-darwin.mk diff --git a/scripts/build/conf/amd64-dragonfly.mk b/scripts/build/conf/amd64-dragonfly.mk @@ -0,0 +1,3 @@ +include $(BUILDDIR)/conf/amd64-posix.mk + +SYS = dragonfly diff --git a/scripts/build/conf/amd64-linux.mk b/scripts/build/conf/amd64-linux.mk @@ -0,0 +1,3 @@ +include $(BUILDDIR)/conf/amd64-posix.mk + +SYS = linux diff --git a/scripts/build/conf/amd64-netbsd.mk b/scripts/build/conf/amd64-netbsd.mk @@ -0,0 +1,3 @@ +include $(BUILDDIR)/conf/amd64-posix.mk + +SYS = netbsd diff --git a/scripts/build/conf/amd64-openbsd.mk b/scripts/build/conf/amd64-openbsd.mk @@ -0,0 +1,3 @@ +include $(BUILDDIR)/conf/amd64-posix.mk + +SYS = openbsd diff --git a/config/conf/amd64-posix.mk b/scripts/build/conf/amd64-posix.mk diff --git a/scripts/build/conf/arm32-linux.mk b/scripts/build/conf/arm32-linux.mk @@ -0,0 +1,3 @@ +include $(BUILDDIR)/conf/arm32-posix.mk + +SYS = linux diff --git a/config/conf/arm32-posix.mk b/scripts/build/conf/arm32-posix.mk diff --git a/scripts/build/conf/arm64-linux.mk b/scripts/build/conf/arm64-linux.mk @@ -0,0 +1,3 @@ +include $(BUILDDIR)/conf/arm64-posix.mk + +SYS = linux diff --git a/config/conf/arm64-posix.mk b/scripts/build/conf/arm64-posix.mk diff --git a/scripts/build/conf/ppc32-linux.mk b/scripts/build/conf/ppc32-linux.mk @@ -0,0 +1,3 @@ +include $(BUILDDIR)/conf/ppc32-posix.mk + +SYS = linux diff --git a/config/conf/ppc32-posix.mk b/scripts/build/conf/ppc32-posix.mk diff --git a/scripts/build/host/bsd.mk b/scripts/build/host/bsd.mk @@ -0,0 +1,3 @@ +DRIVER = posix + +HOST_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE diff --git a/scripts/build/host/linux.mk b/scripts/build/host/linux.mk @@ -0,0 +1,3 @@ +DRIVER = posix + +HOST_CFLAGS = -D_ISOC99_SOURCE -D__STRICT_ANSI__ diff --git a/scripts/build/host/plan9.mk b/scripts/build/host/plan9.mk @@ -0,0 +1,3 @@ +DRIVER = posix + +HOST_CFLAGS = -D_SUSV2_SOURCE diff --git a/scripts/build/host/posix.mk b/scripts/build/host/posix.mk @@ -0,0 +1,3 @@ +DRIVER = posix + +HOST_CFLAGS = -D_POSIX_C_SOURCE=1 diff --git a/scripts/build/tool/clang.mk b/scripts/build/tool/clang.mk @@ -0,0 +1,9 @@ +include $(BUILDDIR)/tool/gnu.mk + +TOOL_ASFLAGS = -c + +COMP = clang +ASM = clang +LINKER = ld.lld +OBJCOPY = llvm-objcopy +OBJDUMP = llvm-objdump diff --git a/scripts/build/tool/gnu-darwin.mk b/scripts/build/tool/gnu-darwin.mk @@ -0,0 +1,3 @@ +include $(BUILDDIR)/tool/gnu.mk + +RANLIB_FLAGS = -c diff --git a/scripts/build/tool/gnu.mk b/scripts/build/tool/gnu.mk @@ -0,0 +1,12 @@ +TOOL_CFLAGS = -std=c99 + +COMP = gcc +ASM = as +LINKER = ld +RANLIB = ranlib +ARCHIVE = ar + +ARCHIVE_FLAGS = -U +NOPIE_CFLAGS = -nopie +NOPIE_LDFLAGS = -nopie +TOOL_CFLAGS = -std=c99 -fno-stack-protector -static diff --git a/scripts/build/tool/pcc.mk b/scripts/build/tool/pcc.mk @@ -0,0 +1,3 @@ +include $(BUILDDIR)/tool/gnu.mk + +COMP = pcc diff --git a/config/tool/unix.mk b/scripts/build/tool/unix.mk diff --git a/scripts/config b/scripts/config @@ -1,11 +1,14 @@ #!/bin/sh case `uname` in +OpenBSD) + echo TOOL=clang HOST=bsd + ;; *BSD) - echo TOOL=gnu HOST=bsd + echo HOST=bsd ;; Linux) - echo TOOL=gnu + echo TOOL=gnu HOST=linux ;; Plan9) echo HOST=plan9 diff --git a/scripts/mklib b/scripts/mklib @@ -1,43 +0,0 @@ -#!/bin/sh - -set -e - -usage() -{ - echo usage: mklib [-o library] file ... >&2 - exit 1 -} - -for i -do - case "$1" in - -o) - out=$2 - shift 2 - ;; - --) - shift - break; - ;; - -*) - usage - ;; - esac -done - -case $# in -0) - usage - ;; -esac - -lib=${out-a.out} - -if ! test -f $lib -then - ${AR:-ar} $ARCHIVEFLAGS -qv $lib $(lorder $@ | tsort) -else - ${AR:-ar} $ARCHIVEFLAGS -ruv $lib $(lorder $@ | tsort) -fi - -${RL:-ranlib} $RLFLAGS $lib diff --git a/scripts/rules.mk b/scripts/rules.mk @@ -1,54 +1,98 @@ -CONF=amd64-linux -TOOL=unix -HOST=unix -include $(PROJECTDIR)/config/conf/$(CONF).mk -include $(PROJECTDIR)/config/tool/$(TOOL).mk -include $(PROJECTDIR)/config/host/$(HOST).mk - -LIBDIR = $(PROJECTDIR)/lib/scc -SCRIPTDIR = $(PROJECTDIR)/scripts -INCDIR = $(PROJECTDIR)/include - -BINDIR = $(PROJECTDIR)/bin -LIBEXEC = $(PROJECTDIR)/libexec/scc -CRTDIR = $(PROJECTDIR)/lib/scc -LIBCDIR = $(CRTDIR)/$(ARCH)-$(SYS) -ENVIRON = $(SCRIPTDIR)/env.sh - -INCLUDE = -I$(INCDIR)/scc +# Define the target all as default +all: +# Define default configuration variables +CONF = amd64-linux +TOOL = unix +HOST = posix +ROFF = gnu + +# Define helper macros for project directories +DOCDIR = $(PROJECTDIR)/doc +INCDIR = $(PROJECTDIR)/include +BINDIR = $(PROJECTDIR)/bin +SRCDIR = $(PROJECTDIR)/src +SCRIPTDIR = $(PROJECTDIR)/scripts +LIBDIR = $(PROJECTDIR)/lib +LIBEXEC = $(PROJECTDIR)/libexec +BUILDDIR = $(PROJECTDIR)/scripts/build +CRTDIR = $(PROJECTDIR)/lib/scc +LIBCDIR = $(CRTDIR)/$(ARCH)-$(SYS) + +# library dependences helpers +LIBMACH = $(LIBDIR)/scc/libmach.a +LIBSCC = $(LIBDIR)/scc/libscc.a + +# Include configuration definitions +include $(BUILDDIR)/conf/$(CONF).mk +include $(BUILDDIR)/tool/$(TOOL).mk +include $(BUILDDIR)/host/$(HOST).mk + +# Locations for -I or -L in compiler, assembler or linker +CINCLUDES = -I$(INCDIR)/scc +ASINCLUDES= -I$(INCDIR)/scc +LDINCLUDES= -L$(LIBDIR)/scc + +# C standard for the target compiler STD = c99 -CC = $(CROSS_COMPILE)$(COMP) -AS = $(CROSS_COMPILE)$(ASM) -LD = $(CROSS_COMPILE)$(LINKER) -RL = $(CROSS_COMPILE)$(RANLIB) -AR = $(CROSS_COMPILE)$(ARCHIVE) - -SCC_CFLAGS =\ - $(MORECFLAGS)\ - $(TOOLCFLAGS)\ - $(HOSTCFLAGS)\ - $(SYSCFLAGS)\ - $(INCLUDE)\ - -g\ + +# Definition of command line for cc, as, ld and emu +PROJ_CFLAGS =\ + $(MORE_CFLAGS)\ + $(HOST_CFLAGS)\ + $(SYS_CFLAGS)\ + $(TOOL_CFLAGS)\ + $(CINCLUDES)\ $(CFLAGS) -SCC_LDFLAGS =\ - $(MORELFLAGS)\ - $(TOOLLDFLAGS)\ - $(HOSTLDFLAGS)\ - $(SYSLDFLAGS)\ - -L$(LIBDIR)\ - -g \ +PROJ_LDFLAGS =\ + $(MORE_LDFLAGS)\ + $(HOST_LDFLAGS)\ + $(SYS_LDFLAGS)\ + $(TOOL_LDFLAGS)\ + $(LDINCLUDES)\ $(LDFLAGS) -SCC_ASFLAGS =\ - $(MOREASFLAGS)\ - $(TOOLASFLAGS)\ - $(HOSTASFLAGS)\ - $(SYSASFLAGS)\ +PROJ_ASFLAGS =\ + $(MORE_ASFLAGS)\ + $(HOST_ASFLAGS)\ + $(SYS_ASFLAGS)\ + $(TOOL_ASFLAGS)\ + $(ASINCLUDES)\ $(ASFLAGS) +PROJ_ARFLAGS =\ + $(MORE_ARFLAGS)\ + $(HOST_ARFLAGS)\ + $(SYS_ARFLAGS)\ + $(TOOL_ARFLAGS)\ + $(ARFLAGS) + +PROJ_RLFLAGS =\ + $(MORE_RLFLAGS)\ + $(HOST_RLFLAGS)\ + $(SYS_RLFLAGS)\ + $(TOOL_RLFLAGS)\ + $(RLFLAGS) + +PROJ_LDLIBS =\ + $(MORE_LDLIBS)\ + $(HOST_LDLIBS)\ + $(SYS_LDLIBS)\ + $(TOOL_LDLIBS)\ + $(LIBS) + +# Definition of tools +CC = $(CROSS_COMPILE)$(COMP) +AS = $(CROSS_COMPILE)$(ASM) +LD = $(CROSS_COMPILE)$(LINKER) +OC = $(CROSS_COMPILE)$(OBJCOPY) +OD = $(CROSS_COMPILE)$(OBJDUMP) +RL = $(CROSS_COMPILE)$(RANLIB) +AR = $(CROSS_COMPILE)$(ARCHIVE) +CPP = $(CROSS_COMPILE)$(PRECOMP) +GS = gs + # helper macro to run over all the directories FORALL = +@set -e ;\ pwd=$$PWD; \ @@ -60,27 +104,104 @@ FORALL = +@set -e ;\ cd $$pwd; \ done -.o: - $(CC) $(SCC_LDFLAGS) -o $@ $< $(LIBS) +$(DIRS): FORCE + +@cd $@ && $(MAKE) + +# Generic rules +.SUFFIXES: +.SUFFIXES: .c .map .dump .elf .bin\ + .i .a .o .s .S .ko .ld .tmpl\ + .pdf .ps .eps .puml\ + .ms .1 .2 .3 .4 .5 .6 .7\ .s.o: - $(AS) $(SCC_ASFLAGS) $< -o $@ + $(AS) $(PROJ_ASFLAGS) $< -o $@ + +.s.ko: + $(AS) $(PROJ_ASFLAGS) $< -o $@ .c.o: - $(CC) $(SCC_CFLAGS) -o $@ -c $< + $(CC) $(PROJ_CFLAGS) -o $@ -c $< -all: +.c.s: + $(CC) $(PROJ_CFLAGS) -S -o $@ $< -dep: +.c.i: + $(CPP) $(PROJ_CFLAGS) -o $@ $< -distclean: +.elf.bin: + $(OC) -O binary $< $@ -inc-dep: FORCE - mkdep +.o.dump: + trap "rm -f $$$$.eps" EXIT QUIT INT TERM;\ + $(OD) -D $< > $$$$.dump && mv $$$$.dump $@ + +.elf.map: + trap "rm -f $$$$.eps" EXIT QUIT INT TERM;\ + $(LD) -Map=$@ $< -o /dev/null + +.puml.eps: + trap "rm -f $$$$.eps" EXIT QUIT INT TERM;\ + plantuml -p -teps < $< > $$$$.eps && mv $$$$.eps $@ + +.ms.ps: + trap "rm -f $$$$.ps" EXIT QUIT INT TERM;\ + $(SOELIM) $< | $(GRAP) | $(PIC) | $(EQN) | $(TBL) |\ + $(TROFF) -ms | $(DPOST) > $$$$.ps &&\ + mv $$$$.ps $@ +.1.ps: + trap "rm -f $$$$.ps" EXIT QUIT INT TERM;\ + $(TBL) $< | $(TROFF) -man | $(DPOST) > $$$$.ps && mv $$$$.ps $@ + +.2.ps: + trap "rm -f $$$$.ps" EXIT QUIT INT TERM;\ + $(TBL) $< | $(TROFF) -man | $(DPOST) > $$$$.ps && mv $$$$.ps $@ -clean: clean-helper +.3.ps: + trap "rm -f $$$$.ps" EXIT QUIT INT TERM;\ + $(TBL) $< | $(TROFF) -man | $(DPOST) > $$$$.ps && mv $$$$.ps $@ -clean-helper: - rm -f *.o $(OBJS) $(TARGET) +.4.ps: + trap "rm -f $$$$.ps" EXIT QUIT INT TERM;\ + $(TBL) $< | $(TROFF) -man | $(DPOST) > $$$$.ps && mv $$$$.ps $@ +.5.ps: + trap "rm -f $$$$.ps" EXIT QUIT INT TERM;\ + $(TBL) $< | $(TROFF) -man | $(DPOST) > $$$$.ps && mv $$$$.ps $@ + +.6.ps: + trap "rm -f $$$$.ps" EXIT QUIT INT TERM;\ + $(TBL) $< | $(TROFF) -man | $(DPOST) > $$$$.ps && mv $$$$.ps $@ + +.7.ps: + trap "rm -f $$$$.ps" EXIT QUIT INT TERM;\ + $(TBL) $< | $(TROFF) -man | $(DPOST) > $$$$.ps && mv $$$$.ps $@ + +.ps.pdf: + $(GS) -P- -dSAFER -q -P- -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \ + -ssdout=%stderr "-sOutputFile=$@" -P- -dSAFER "$<" + +.eps.pdf: + $(GS) -P- -dSAFER -q -P- -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \ + -ssdout=%stderr "-sOutputFile=$@" -P- -dSAFER "$<" FORCE: + +clean: clean-files clean-dirs + +clean-dirs: + +@set -e; \ + for i in $(DIRS); \ + do \ + cd $$i; \ + $(MAKE) clean; \ + cd -; \ + done + +clean-files: + rm -f *.i *.d *.o *.a *.ko *.elf $(TARGET) + rm -f *.csmes *.csexe + +dep: + +inc-dep: FORCE + mkdep diff --git a/src/Makefile b/src/Makefile @@ -1,17 +1,20 @@ .POSIX: +LIBS =\ + libcrt\ + libscc\ + libmach\ + +DIRS =\ + cmd\ + $(LIBS)\ + PROJECTDIR = .. include $(PROJECTDIR)/scripts/rules.mk -LIBS = libcrt libscc libmach -DIRS = cmd $(LIBS) - all: cmd cmd: $(LIBS) -$(DIRS): FORCE - +@cd $@ && $(MAKE) - dep clean: $(FORALL) diff --git a/src/cmd/Makefile b/src/cmd/Makefile @@ -1,5 +1,10 @@ .POSIX: +DIRS =\ + ld\ + as\ + cc\ + PROJECTDIR = ../.. include $(PROJECTDIR)/scripts/rules.mk @@ -13,39 +18,31 @@ TARGET =\ $(BINDIR)/objcopy\ $(BINDIR)/addr2line\ -DIRS = ld as cc - -LIBMACH = $(LIBDIR)/libmach.a -LIBSCC = $(LIBDIR)/libscc.a - all: $(TARGET) $(DIRS) -$(DIRS): FORCE - +@cd $@ && $(MAKE) - $(BINDIR)/nm: nm.o $(LIBMACH) $(LIBSCC) - $(CC) $(SCC_LDFLAGS) nm.o -lmach -lscc -o $@ + $(CC) $(PROJ_LDFLAGS) nm.o -lmach -lscc -o $@ $(BINDIR)/strip: strip.o $(LIBMACH) $(LIBSCC) - $(CC) $(SCC_LDFLAGS) strip.o -lmach -lscc -o $@ + $(CC) $(PROJ_LDFLAGS) strip.o -lmach -lscc -o $@ $(BINDIR)/size: size.o $(LIBMACH) $(LIBSCC) - $(CC) $(SCC_LDFLAGS) size.o -lmach -lscc -o $@ + $(CC) $(PROJ_LDFLAGS) size.o -lmach -lscc -o $@ $(BINDIR)/ranlib: ranlib.o $(DRIVER).o $(LIBMACH) $(LIBSCC) - $(CC) $(SCC_LDFLAGS) ranlib.o $(DRIVER).o -lmach -lscc -o $@ + $(CC) $(PROJ_LDFLAGS) ranlib.o $(DRIVER).o -lmach -lscc -o $@ $(BINDIR)/objdump: objdump.o $(LIBMACH) - $(CC) $(SCC_LDFLAGS) objdump.o -lmach -o $@ + $(CC) $(PROJ_LDFLAGS) objdump.o -lmach -o $@ $(BINDIR)/objcopy: objcopy.o $(LIBMACH) - $(CC) $(SCC_LDFLAGS) objcopy.o -lmach -o $@ + $(CC) $(PROJ_LDFLAGS) objcopy.o -lmach -o $@ $(BINDIR)/addr2line: addr2line.o $(LIBMACH) $(LIBSCC) - $(CC) $(SCC_LDFLAGS) addr2line.o -lmach -lscc -o $@ + $(CC) $(PROJ_LDFLAGS) addr2line.o -lmach -lscc -o $@ $(BINDIR)/ar: ar.o $(DRIVER).o - $(CC) $(SCC_LDFLAGS) ar.o $(DRIVER).o -o $@ + $(CC) $(PROJ_LDFLAGS) ar.o $(DRIVER).o -o $@ dep: inc-dep diff --git a/src/cmd/as/Makefile b/src/cmd/as/Makefile @@ -3,7 +3,7 @@ PROJECTDIR = ../../.. include $(PROJECTDIR)/scripts/rules.mk -MORECFLAGS = -I$(INCDIR)/$(STD) +MORE_CFLAGS = -I$(INCDIR)/$(STD) OBJS = \ main.o\ @@ -13,16 +13,16 @@ OBJS = \ expr.o\ TARGET =\ - $(LIBEXEC)/as-powerpc64\ - $(LIBEXEC)/as-powerpc\ - $(LIBEXEC)/as-amd64\ - $(LIBEXEC)/as-i386\ - $(LIBEXEC)/as-i286\ - $(LIBEXEC)/as-z80 \ + $(LIBEXEC)/scc/as-powerpc64\ + $(LIBEXEC)/scc/as-powerpc\ + $(LIBEXEC)/scc/as-amd64\ + $(LIBEXEC)/scc/as-i386\ + $(LIBEXEC)/scc/as-i286\ + $(LIBEXEC)/scc/as-z80 \ all: $(TARGET) -$(TARGET): $(LIBDIR)/libscc.a +$(TARGET): $(LIBSCC) dep: inc-dep diff --git a/src/cmd/as/target/powerpc/powerpc.mk b/src/cmd/as/target/powerpc/powerpc.mk @@ -8,5 +8,5 @@ POWERPC_OBJ =\ $(POWERPC)/powerpctbl.c: $(POWERPC)/ops.dat $(POWERPC)/opers.dat ./mktbl -f powerpc -c powerpc -$(LIBEXEC)/as-powerpc: $(POWERPC_OBJ) - $(CC) $(SCC_LDFLAGS) $(POWERPC_OBJ) -lscc -o $@ +$(LIBEXEC)/scc/as-powerpc: $(POWERPC_OBJ) + $(CC) $(PROJ_LDFLAGS) $(POWERPC_OBJ) -lscc -o $@ diff --git a/src/cmd/as/target/powerpc/powerpc64.mk b/src/cmd/as/target/powerpc/powerpc64.mk @@ -8,5 +8,5 @@ POWERPC64_OBJ =\ $(POWERPC)/powerpc64tbl.c: $(POWERPC)/ops.dat $(POWERPC)/opers.dat ./mktbl -f powerpc -c powerpc64 -$(LIBEXEC)/as-powerpc64: $(POWERPC64_OBJ) - $(CC) $(SCC_LDFLAGS) $(POWERPC64_OBJ) -lscc -o $@ +$(LIBEXEC)/scc/as-powerpc64: $(POWERPC64_OBJ) + $(CC) $(PROJ_LDFLAGS) $(POWERPC64_OBJ) -lscc -o $@ diff --git a/src/cmd/as/target/x80/z80.mk b/src/cmd/as/target/x80/z80.mk @@ -7,5 +7,5 @@ Z80_OBJ =\ target/x80/z80tbl.c: target/x80/ops.dat target/x80/opers.dat ./mktbl -f x80 -c z80 -$(LIBEXEC)/as-z80: $(OBJ) $(Z80_OBJ) - $(CC) $(SCC_LDFLAGS) $(Z80_OBJ) -lscc -o $@ +$(LIBEXEC)/scc/as-z80: $(OBJ) $(Z80_OBJ) + $(CC) $(PROJ_LDFLAGS) $(Z80_OBJ) -lscc -o $@ diff --git a/src/cmd/as/target/x86/amd64.mk b/src/cmd/as/target/x86/amd64.mk @@ -7,5 +7,5 @@ AMD64_OBJ =\ target/x86/amd64tbl.c: target/x86/ops.dat target/x86/opers.dat ./mktbl -f x86 -c amd64 -$(LIBEXEC)/as-amd64: $(AMD64_OBJ) - $(CC) $(SCC_LDFLAGS) $(AMD64_OBJ) -lscc -o $@ +$(LIBEXEC)/scc/as-amd64: $(AMD64_OBJ) + $(CC) $(PROJ_LDFLAGS) $(AMD64_OBJ) -lscc -o $@ diff --git a/src/cmd/as/target/x86/i286.mk b/src/cmd/as/target/x86/i286.mk @@ -7,5 +7,5 @@ I286_OBJ =\ target/x86/i286tbl.c: target/x86/ops.dat target/x86/opers.dat ./mktbl -f x86 -c i286 -$(LIBEXEC)/as-i286: $(I286_OBJ) - $(CC) $(SCC_LDFLAGS) $(I286_OBJ) -lscc -o $@ +$(LIBEXEC)/scc/as-i286: $(I286_OBJ) + $(CC) $(PROJ_LDFLAGS) $(I286_OBJ) -lscc -o $@ diff --git a/src/cmd/as/target/x86/i386.mk b/src/cmd/as/target/x86/i386.mk @@ -7,5 +7,5 @@ I386_OBJ =\ target/x86/i386tbl.c: target/x86/ops.dat target/x86/opers.dat ./mktbl -f x86 -c i386 -$(LIBEXEC)/as-i386: $(I386_OBJ) - $(CC) $(SCC_LDFLAGS) $(I386_OBJ) -lscc -o $@ +$(LIBEXEC)/scc/as-i386: $(I386_OBJ) + $(CC) $(PROJ_LDFLAGS) $(I386_OBJ) -lscc -o $@ diff --git a/src/cmd/cc/Makefile b/src/cmd/cc/Makefile @@ -1,14 +1,14 @@ .POSIX: +DIRS =\ + cc1\ + cc2\ + $(DRIVER)\ + PROJECTDIR = ../../.. include $(PROJECTDIR)/scripts/rules.mk -DIRS = cc1 cc2 $(DRIVER) - all: $(DIRS) -$(DIRS): FORCE - +@cd $@ && $(MAKE) - dep clean: $(FORALL) diff --git a/src/cmd/cc/cc1/Makefile b/src/cmd/cc/cc1/Makefile @@ -23,12 +23,12 @@ OBJS =\ i386-sysv.o \ z80-scc.o\ -TARGET = $(LIBEXEC)/cc1 +TARGET = $(LIBEXEC)/scc/cc1 all: $(TARGET) -$(TARGET): $(LIBDIR)/libscc.a $(OBJS) - $(CC) $(SCC_LDFLAGS) $(OBJS) -lscc -o $@ +$(TARGET): $(LIBSCC) $(OBJS) + $(CC) $(PROJ_LDFLAGS) $(OBJS) -lscc -o $@ dep: inc-dep diff --git a/src/cmd/cc/cc2/Makefile b/src/cmd/cc/cc2/Makefile @@ -3,20 +3,22 @@ PROJECTDIR = ../../../.. include $(PROJECTDIR)/scripts/rules.mk -MORECFLAGS = -I$(INCDIR)/$(STD) - -OBJS = main.o \ - parser.o \ - peep.o \ - symbol.o \ - node.o \ - code.o \ - optm.o \ - -TARGET = $(LIBEXEC)/cc2-amd64-sysv \ - $(LIBEXEC)/cc2-i386-sysv \ - $(LIBEXEC)/cc2-qbe_amd64-sysv \ - $(LIBEXEC)/cc2-z80-scc \ +MORE_CFLAGS = -I$(INCDIR)/$(STD) + +OBJS =\ + main.o\ + parser.o\ + peep.o\ + symbol.o\ + node.o\ + code.o\ + optm.o\ + +TARGET =\ + $(LIBEXEC)/scc/cc2-amd64-sysv\ + $(LIBEXEC)/scc//cc2-i386-sysv\ + $(LIBEXEC)/scc/cc2-qbe_amd64-sysv\ + $(LIBEXEC)/scc//cc2-z80-scc\ all: $(TARGET) diff --git a/src/cmd/cc/cc2/target/amd64-sysv/target.mk b/src/cmd/cc/cc2/target/amd64-sysv/target.mk @@ -4,5 +4,5 @@ OBJ-amd64-sysv = $(OBJS) \ target/amd64-sysv/code.o \ target/amd64-sysv/types.o -$(LIBEXEC)/cc2-amd64-sysv: $(OBJ-amd64-sysv) - $(CC) $(SCC_LDFLAGS) $(OBJ-amd64-sysv) -lscc -o $@ +$(LIBEXEC)/scc/cc2-amd64-sysv: $(LIBSCC) $(OBJ-amd64-sysv) + $(CC) $(PROJ_LDFLAGS) $(OBJ-amd64-sysv) -lscc -o $@ diff --git a/src/cmd/cc/cc2/target/i386-sysv/target.mk b/src/cmd/cc/cc2/target/i386-sysv/target.mk @@ -4,5 +4,5 @@ OBJ-i386-sysv = $(OBJS) \ target/i386-sysv/code.o \ target/i386-sysv/types.o -$(LIBEXEC)/cc2-i386-sysv: $(OBJ-i386-sysv) - $(CC) $(SCC_LDFLAGS) $(OBJ-i386-sysv) -lscc -o $@ +$(LIBEXEC)/scc/cc2-i386-sysv: $(LIBSCC) $(OBJ-i386-sysv) + $(CC) $(PROJ_LDFLAGS) $(OBJ-i386-sysv) -lscc -o $@ diff --git a/src/cmd/cc/cc2/target/qbe_amd64-sysv/target.mk b/src/cmd/cc/cc2/target/qbe_amd64-sysv/target.mk @@ -4,5 +4,5 @@ OBJ-qbe_amd64-sysv = $(OBJS) \ target/qbe/code.o \ target/amd64-sysv/types.o -$(LIBEXEC)/cc2-qbe_amd64-sysv: $(OBJ-qbe_amd64-sysv) - $(CC) $(SCC_LDFLAGS) $(OBJ-qbe_amd64-sysv) -lscc -o $@ +$(LIBEXEC)/scc/cc2-qbe_amd64-sysv: $(LIBSCC) $(OBJ-qbe_amd64-sysv) + $(CC) $(PROJ_LDFLAGS) $(OBJ-qbe_amd64-sysv) -lscc -o $@ diff --git a/src/cmd/cc/cc2/target/z80-scc/target.mk b/src/cmd/cc/cc2/target/z80-scc/target.mk @@ -4,5 +4,5 @@ OBJ-z80-scc = $(OBJS) \ target/z80-scc/code.o \ target/z80-scc/types.o \ -$(LIBEXEC)/cc2-z80-scc: $(OBJ-z80-scc) - $(CC) $(SCC_LDFLAGS) $(OBJ-z80-scc) -lscc -o $@ +$(LIBEXEC)/scc/cc2-z80-scc: $(LIBSCC) $(OBJ-z80-scc) + $(CC) $(PROJ_LDFLAGS) $(OBJ-z80-scc) -lscc -o $@ diff --git a/src/cmd/cc/posix/Makefile b/src/cmd/cc/posix/Makefile @@ -16,8 +16,8 @@ TARGETS = $(BINDIR)/cc $(BINDIR)/cpp all: $(TARGETS) -$(BINDIR)/cc: cc.o - $(CC) $(SCC_LDFLAGS) cc.o -lscc -o $@ +$(BINDIR)/cc: $(LIBSCC) cc.o + $(CC) $(PROJ_LDFLAGS) cc.o -lscc -o $@ $(BINDIR)/cpp: cpp.sh trap "rm -f $$$$.sh" 0 2 3;\ @@ -27,7 +27,7 @@ $(BINDIR)/cpp: cpp.sh mv $$$$.sh $@ config.h: - PREFIX=$(PREFIX) mkconf $(SYSLST) + PREFIX=$(PREFIX) ./mkconf $(SYSLST) dep: inc-dep diff --git a/src/cmd/ld/Makefile b/src/cmd/ld/Makefile @@ -16,8 +16,8 @@ OBJS =\ all: $(TARGET) -$(TARGET): $(OBJS) $(LIBDIR)/libscc.a $(LIBDIR)/libmach.a - $(CC) $(SCC_LDFLAGS) $(OBJS) -lmach -lscc -o $@ +$(TARGET): $(OBJS) $(LIBMACH) $(LIBSCC) + $(CC) $(PROJ_LDFLAGS) $(OBJS) -lmach -lscc -o $@ dep: inc-dep diff --git a/src/libc/Makefile b/src/libc/Makefile @@ -1,7 +1,4 @@ .POSIX: -PROJECTDIR =../.. -include $(PROJECTDIR)/scripts/rules.mk -include rules.mk DIRS =\ arch\ @@ -13,13 +10,16 @@ DIRS =\ string\ time\ +PROJECTDIR =../.. +include $(PROJECTDIR)/scripts/rules.mk +include rules.mk + + all: $(LIBC) $(LIBC): $(DIRS) - mklib -o $@ `cat $(LIBCLST)`;\ - -$(DIRS): rm-lst - +@cd $@ && $(MAKE) + $(AR) $(PROJ_ARFLAGS) $@ `cat $(LIBCLST)` + $(RL) $(PROJ_RLFLAGS) $@ rm-lst: FORCE rm -f $(LIBCLST) diff --git a/src/libc/arch/Makefile b/src/libc/arch/Makefile @@ -1,7 +1,4 @@ .POSIX: -PROJECTDIR =../../.. -include $(PROJECTDIR)/scripts/rules.mk -include ../rules.mk DIRS =\ amd64\ @@ -10,8 +7,11 @@ DIRS =\ i386\ ppc\ -all: - +@cd $(ARCH) && $(MAKE) +PROJECTDIR =../../.. +include $(PROJECTDIR)/scripts/rules.mk +include ../rules.mk + +all: $(ARCH) dep clean: $(FORALL) diff --git a/src/libc/arch/amd64/Makefile b/src/libc/arch/amd64/Makefile @@ -1,4 +1,12 @@ .POSIX: + +DIRS =\ + netbsd\ + openbsd\ + dragonfly\ + linux\ + darwin\ + PROJECTDIR =../../../.. include $(PROJECTDIR)/scripts/rules.mk include ../../rules.mk @@ -12,21 +20,11 @@ OBJS =\ memmove.$O\ memset.$O\ -DIRS =\ - netbsd\ - openbsd\ - dragonfly\ - linux\ - darwin\ - all: $(LIBC) $(SYS) $(LIBC): $(OBJS) $(MKLST) -$(SYS): FORCE - +@cd $@ && $(MAKE) - dep: inc-dep dep clean: diff --git a/src/libc/arch/amd64/darwin/Makefile b/src/libc/arch/amd64/darwin/Makefile @@ -1,4 +1,5 @@ .POSIX: + PROJECTDIR =../../../../.. include $(PROJECTDIR)/scripts/rules.mk include ../../../rules.mk @@ -36,7 +37,7 @@ $(LIBC): $(OBJS) crt.$O: ../crt-posix.s $(GENSRC): syscall.lst - gensys.sh $(@:.s=) + ./gensys.sh $(@:.s=) dep: inc-dep diff --git a/src/libc/arch/amd64/dragonfly/Makefile b/src/libc/arch/amd64/dragonfly/Makefile @@ -1,4 +1,5 @@ .POSIX: + PROJECTDIR =../../../../.. include $(PROJECTDIR)/scripts/rules.mk include ../../../rules.mk @@ -37,7 +38,7 @@ $(LIBC): $(OBJS) crt.$O: ../crt-posix.s $(GENSRC): syscall.lst - gensys.sh $(@:.s=) + ./gensys.sh $(@:.s=) dep: inc-dep diff --git a/src/libc/arch/amd64/linux/Makefile b/src/libc/arch/amd64/linux/Makefile @@ -1,4 +1,5 @@ .POSIX: + PROJECTDIR =../../../../.. include $(PROJECTDIR)/scripts/rules.mk include ../../../rules.mk @@ -42,7 +43,7 @@ $(LIBC): $(OBJS) crt.$O: ../crt-posix.s $(GENSRC): syscall.lst - gensys.sh $(@:.s=) + ./gensys.sh $(@:.s=) dep: inc-dep diff --git a/src/libc/arch/amd64/netbsd/Makefile b/src/libc/arch/amd64/netbsd/Makefile @@ -1,4 +1,5 @@ .POSIX: + PROJECTDIR =../../../../.. include $(PROJECTDIR)/scripts/rules.mk include ../../../rules.mk @@ -37,7 +38,7 @@ $(LIBC): $(OBJS) crt.$O: ../crt-posix.s ../netbsd/crt.s $(GENSRC): syscall.lst - gensys.sh $(@:.s=) + ./gensys.sh $(@:.s=) deps: inc-dep diff --git a/src/libc/arch/amd64/openbsd/Makefile b/src/libc/arch/amd64/openbsd/Makefile @@ -1,4 +1,5 @@ .POSIX: + PROJECTDIR =../../../../.. include $(PROJECTDIR)/scripts/rules.mk include ../../../rules.mk @@ -35,7 +36,7 @@ $(LIBC): $(OBJS) crt.$O: ../crt-posix.s ../openbsd/crt.s $(GENSRC): syscall.lst - gensys.sh $(@:.s=) + ./gensys.sh $(@:.s=) dep: inc-dep diff --git a/src/libc/arch/arm/Makefile b/src/libc/arch/arm/Makefile @@ -1,4 +1,8 @@ .POSIX: + +DIRS =\ + linux\ + PROJECTDIR =../../../.. include $(PROJECTDIR)/scripts/rules.mk include ../../rules.mk @@ -12,16 +16,11 @@ OBJS =\ memmove.$O\ memset.$O\ -DIRS = linux - all: $(LIBC) $(SYS) $(LIBC): $(OBJS) $(MKLST) -$(SYS): FORCE - +@cd $@ && $(MAKE) - dep: inc-dep dep clean: diff --git a/src/libc/arch/arm/linux/Makefile b/src/libc/arch/arm/linux/Makefile @@ -1,4 +1,5 @@ .POSIX: + PROJECTDIR =../../../../.. include $(PROJECTDIR)/scripts/rules.mk include ../../../rules.mk @@ -37,7 +38,7 @@ $(LIBC): $(OBJS) crt.o: ../crt-posix.s $(GENSRC): syscall.lst - gensys.sh $(@:.s=) + ./gensys.sh $(@:.s=) dep: inc-dep diff --git a/src/libc/arch/arm64/Makefile b/src/libc/arch/arm64/Makefile @@ -1,4 +1,8 @@ .POSIX: + +DIRS =\ + linux\ + PROJECTDIR =../../../.. include $(PROJECTDIR)/scripts/rules.mk include ../../rules.mk @@ -12,16 +16,11 @@ OBJS =\ memmove.$O\ memset.$O\ -DIRS = linux - all: $(LIBC) $(SYS) $(LIBC): $(OBJS) $(MKLST) -$(SYS): FORCE - +@cd $@ && $(MAKE) - dep: inc-dep clean: diff --git a/src/libc/arch/arm64/linux/Makefile b/src/libc/arch/arm64/linux/Makefile @@ -1,4 +1,5 @@ .POSIX: + PROJECTDIR =../../../../.. include $(PROJECTDIR)/scripts/rules.mk include ../../../rules.mk @@ -37,7 +38,7 @@ $(LIBC): $(OBJS) crt.$O: ../crt-posix.s $(GENSRC): syscall.lst - gensys.sh $(@:.s=) + ./gensys.sh $(@:.s=) clean: rm -f $(GENSRC) diff --git a/src/libc/arch/i386/Makefile b/src/libc/arch/i386/Makefile @@ -1,4 +1,8 @@ .POSIX: + +DIRS =\ + linux\ + PROJECTDIR =../../../.. include $(PROJECTDIR)/scripts/rules.mk include ../../rules.mk @@ -12,16 +16,11 @@ OBJS =\ memmove.$O\ memset.$O\ -DIRS = linux - all: $(LIBC) $(SYS) $(LIBC): $(OBJS) $(MKLST) -$(SYS): FORCE - +@cd $@ && $(MAKE) - dep: inc-dep dep clean: diff --git a/src/libc/arch/i386/linux/Makefile b/src/libc/arch/i386/linux/Makefile @@ -1,4 +1,5 @@ .POSIX: + PROJECTDIR =../../../../.. include $(PROJECTDIR)/scripts/rules.mk include ../../../rules.mk @@ -33,7 +34,7 @@ $(LIBCLST): $(OBJS) crt.$O: ../crt-posix.s $(GENSRC): syscall.lst - gensys.sh $(@:.s=) + ./gensys.sh $(@:.s=) dep: inc-dep diff --git a/src/libc/arch/ppc/Makefile b/src/libc/arch/ppc/Makefile @@ -1,4 +1,8 @@ .POSIX: + +DIRS =\ + linux\ + PROJECTDIR =../../../.. include $(PROJECTDIR)/scripts/rules.mk include ../../rules.mk @@ -12,16 +16,11 @@ OBJS =\ memmove.$O\ memset.$O\ -DIRS = linux - all: $(LIBC) $(SYS) $(LIBC): $(OBJS) $(MKLST) -$(SYS): FORCE - +@cd $@ && $(MAKE) - dep: inc-dep dep clean: diff --git a/src/libc/arch/ppc/linux/Makefile b/src/libc/arch/ppc/linux/Makefile @@ -1,4 +1,5 @@ .POSIX: + PROJECTDIR =../../../../.. include $(PROJECTDIR)/scripts/rules.mk include ../../../rules.mk @@ -33,7 +34,7 @@ $(LIBC): $(OBJS) crt.$O: ../crt-posix.s $(GENSRC): syscall.lst - gensys.sh $(@:.s=) + ./gensys.sh $(@:.s=) dep: inc-dep diff --git a/src/libc/rules.mk b/src/libc/rules.mk @@ -1,4 +1,4 @@ -INCLUDE =\ +CINCLUDES =\ -I$(INCDIR)\ -I$(INCDIR)/bits/$(SYS)\ -I$(INCDIR)/bits/$(ARCH)\ @@ -32,42 +32,42 @@ clean-libc: FORCE # amd64-posix objects .c.6: - $(CC) $(SCC_CFLAGS) -o $@ -c $< + $(CC) $(PROJ_CFLAGS) -o $@ -c $< .s.6: - $(AS) $(SCC_ASFLAGS) $< -o $@ + $(AS) $(PROJ_ASFLAGS) $< -o $@ # amd64-darwin objects .c.6d: - $(CC) $(SCC_CFLAGS) -o $@ -c $< + $(CC) $(PROJ_CFLAGS) -o $@ -c $< .s.6d: - $(AS) $(SCC_ASFLAGS) $< -o $@ + $(AS) $(PROJ_ASFLAGS) $< -o $@ # arm64-posix objects .c.7: - $(CC) $(SCC_CFLAGS) -o $@ -c $< + $(CC) $(PROJ_CFLAGS) -o $@ -c $< .s.7: - $(AS) $(SCC_ASFLAGS) $< -o $@ + $(AS) $(PROJ_ASFLAGS) $< -o $@ # 386-posix objects .c.8: - $(CC) $(SCC_CFLAGS) -o $@ -c $< + $(CC) $(PROJ_CFLAGS) -o $@ -c $< .s.8: - $(AS) $(SCC_ASFLAGS) $< -o $@ + $(AS) $(PROJ_ASFLAGS) $< -o $@ # z80 objects .c.z: - $(CC) $(SCC_CFLAGS) -o $@ -c $< + $(CC) $(PROJ_CFLAGS) -o $@ -c $< .s.z: - $(AS) $(SCC_ASFLAGS) $< -o $@ + $(AS) $(PROJ_ASFLAGS) $< -o $@ # ppc32 objects .c.q: - $(CC) $(SCC_CFLAGS) -o $@ -c $< + $(CC) $(PROJ_CFLAGS) -o $@ -c $< .s.q: - $(AS) $(SCC_ASFLAGS) $< -o $@ + $(AS) $(PROJ_ASFLAGS) $< -o $@ diff --git a/src/libc/string/Makefile b/src/libc/string/Makefile @@ -1,4 +1,5 @@ .POSIX: + PROJECTDIR =../../.. include $(PROJECTDIR)/scripts/rules.mk include ../rules.mk diff --git a/src/libcrt/Makefile b/src/libcrt/Makefile @@ -1,4 +1,5 @@ .POSIX: + PROJECTDIR=../.. include $(PROJECTDIR)/scripts/rules.mk diff --git a/src/libcrt/amd64/Makefile b/src/libcrt/amd64/Makefile @@ -1,4 +1,5 @@ .POSIX: + PROJECTDIR=../../.. include $(PROJECTDIR)/scripts/rules.mk @@ -8,4 +9,5 @@ TARGET = $(LIBCDIR)/libcrt.a all: $(TARGET) $(TARGET): $(OBJS) - mklib -o $@ $? + $(AR) $(PROJ_ARFLAGS) $@ $? + $(RL) $(PROJ_RLFLAGS) $@ diff --git a/src/libcrt/arm/Makefile b/src/libcrt/arm/Makefile @@ -1,4 +1,5 @@ .POSIX: + PROJECTDIR=../../.. include $(PROJECTDIR)/scripts/rules.mk @@ -8,4 +9,5 @@ TARGET = $(LIBCDIR)/libcrt.a all: $(TARGET) $(TARGET): $(OBJS) - mklib -o $@ $? + $(AR) $(PROJ_ARFLAGS) $@ $? + $(RL) $(PROJ_RLFLAGS) $@ diff --git a/src/libcrt/arm64/Makefile b/src/libcrt/arm64/Makefile @@ -1,4 +1,5 @@ .POSIX: + PROJECTDIR=../../.. include $(PROJECTDIR)/scripts/rules.mk @@ -8,4 +9,5 @@ TARGET = $(LIBCDIR)/libcrt.a all: $(TARGET) $(TARGET): $(OBJS) - mklib -o $@ $? + $(AR) $(PROJ_ARFLAGS) $@ $? + $(RL) $(PROJ_RLFLAGS) $@ diff --git a/src/libcrt/i386/Makefile b/src/libcrt/i386/Makefile @@ -1,14 +1,17 @@ .POSIX: + PROJECTDIR=../../.. include $(PROJECTDIR)/scripts/rules.mk -OBJS = dummy.o \ - umoddi3.o \ - udivdi3.o \ +OBJS =\ + dummy.o\ + umoddi3.o\ + udivdi3.o\ TARGET = $(LIBCDIR)/libcrt.a all: $(TARGET) $(TARGET): $(OBJS) - mklib -o $@ $? + $(AR) $(PROJ_ARFLAGS) $@ $? + $(RL) $(PROJ_RLFLAGS) $@ diff --git a/src/libcrt/ppc/Makefile b/src/libcrt/ppc/Makefile @@ -1,4 +1,5 @@ .POSIX: + PROJECTDIR=../../.. include $(PROJECTDIR)/scripts/rules.mk @@ -8,4 +9,5 @@ TARGET = $(LIBCDIR)/libcrt.a all: $(TARGET) $(TARGET): $(OBJS) - mklib -o $@ $? + $(AR) $(PROJ_ARFLAGS) $@ $? + $(RL) $(PROJ_RLFLAGS) $@ diff --git a/src/libmach/Makefile b/src/libmach/Makefile @@ -1,8 +1,12 @@ .POSIX: + +DIRS =\ + coff32 + PROJECTDIR =../.. include $(PROJECTDIR)/scripts/rules.mk -TARGET = $(LIBDIR)/libmach.a +TARGET = $(LIBDIR)/scc/libmach.a OBJS =\ mach.o\ @@ -28,17 +32,12 @@ OBJS =\ setindex.o\ getindex.o\ -DIRS = coff32 - all: $(OBJS) $(DIRS) objlst.mk +@$(MAKE) -f Makefile.mach -$(DIRS): FORCE - +@cd $@ && $(MAKE) - objlst.mk: $(OBJS) $(DIRS) - mklst $@ + ./mklst $@ dep: inc-dep $(FORALL) diff --git a/src/libmach/Makefile.mach b/src/libmach/Makefile.mach @@ -3,9 +3,10 @@ PROJECTDIR =../.. include $(PROJECTDIR)/scripts/rules.mk include objlst.mk -TARGET = $(LIBDIR)/libmach.a +TARGET = $(LIBDIR)/scc/libmach.a all: $(TARGET) $(TARGET): $(OBJS) - mklib -o $@ $? + $(AR) $(PROJ_ARFLAGS) $@ $? + $(RL) $(PROJ_RLFLAGS) $@ diff --git a/src/libmach/coff32/Makefile b/src/libmach/coff32/Makefile @@ -1,23 +1,25 @@ .POSIX: + PROJECTDIR =../../.. include $(PROJECTDIR)/scripts/rules.mk -OBJS = coff32.o \ - coff32del.o \ - coff32new.o \ - coff32probe.o \ - coff32read.o \ - coff32strip.o \ - coff32write.o \ - coff32setidx.o \ - coff32xsetidx.o \ - coff32getidx.o \ - coff32xgetidx.o \ - coff32setidx.o \ - coff32getidx.o \ - coff32pc2line.o \ - coff32getsym.o \ - coff32getsec.o \ +OBJS =\ + coff32.o \ + coff32del.o \ + coff32new.o \ + coff32probe.o \ + coff32read.o \ + coff32strip.o \ + coff32write.o \ + coff32setidx.o \ + coff32xsetidx.o \ + coff32getidx.o \ + coff32xgetidx.o \ + coff32setidx.o \ + coff32getidx.o \ + coff32pc2line.o \ + coff32getsym.o \ + coff32getsec.o \ coff32loadmap.o\ all: $(OBJS) diff --git a/src/libscc/Makefile b/src/libscc/Makefile @@ -3,23 +3,25 @@ PROJECTDIR = ../.. include $(PROJECTDIR)/scripts/rules.mk -OBJS = debug.o \ - die.o \ - newitem.o \ - xcalloc.o \ - xmalloc.o \ - xrealloc.o \ - xstrdup.o \ - alloc.o \ - casecmp.o \ - genhash.o +OBJS =\ + debug.o\ + die.o\ + newitem.o\ + xcalloc.o\ + xmalloc.o\ + xrealloc.o\ + xstrdup.o\ + alloc.o\ + casecmp.o\ + genhash.o\ -TARGET = $(LIBDIR)/libscc.a +TARGET = $(LIBDIR)/scc/libscc.a all: $(TARGET) $(TARGET): $(OBJS) - mklib -o $@ $(OBJS) + $(AR) $(PROJ_ARFLAGS) $@ $? + $(RL) $(PROJ_RLFLAGS) $@ dep: inc-dep diff --git a/tests/Makefile b/tests/Makefile @@ -1,16 +1,17 @@ .POSIX: +DIRS =\ + ar/execute\ + nm/execute\ + as/execute\ + ld/execute\ + size/execute\ + strip/execute\ + libc/execute\ + cc/execute cc/error\ + PROJECTDIR = .. include $(PROJECTDIR)/scripts/rules.mk -DIRS=ar/execute \ - nm/execute \ - as/execute \ - ld/execute \ - size/execute \ - strip/execute \ - libc/execute \ - cc/execute cc/error - all clean: $(FORALL) diff --git a/tests/as/execute/Makefile b/tests/as/execute/Makefile @@ -1,4 +1,5 @@ .POSIX: + ROOT=../../../ all: tests diff --git a/tests/nm/execute/Makefile b/tests/nm/execute/Makefile @@ -1,4 +1,5 @@ .POSIX: + ROOT=../../.. OUT = z80.out diff --git a/tests/size/execute/Makefile b/tests/size/execute/Makefile @@ -1,4 +1,5 @@ .POSIX: + ROOT=../../.. OUT = z80.out diff --git a/tests/strip/execute/Makefile b/tests/strip/execute/Makefile @@ -1,4 +1,5 @@ .POSIX: + ROOT=../../.. OUT = z80.out