ref: 5a887532fdcc8d14f6ee68fb647dd83725c0f43f
parent: 68337316883089a65169e2aa3f0289acc08a9627
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon May 3 15:27:06 EDT 2021
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.
--- 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
@@ -22,23 +27,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)
--- a/config/conf/amd64-darwin.mk
+++ /dev/null
@@ -1,4 +1,0 @@
-ARCH = amd64
-SYS = darwin
-ABI = amd64-darwin
-O = 6d
--- a/config/conf/amd64-dragonfly.mk
+++ /dev/null
@@ -1,3 +1,0 @@
-include $(PROJECTDIR)/config/conf/amd64-posix.mk
-
-SYS = dragonfly
--- a/config/conf/amd64-linux.mk
+++ /dev/null
@@ -1,3 +1,0 @@
-include $(PROJECTDIR)/config/conf/amd64-posix.mk
-
-SYS = linux
--- a/config/conf/amd64-netbsd.mk
+++ /dev/null
@@ -1,3 +1,0 @@
-include $(PROJECTDIR)/config/conf/amd64-posix.mk
-
-SYS = netbsd
--- a/config/conf/amd64-openbsd.mk
+++ /dev/null
@@ -1,3 +1,0 @@
-include $(PROJECTDIR)/config/conf/amd64-posix.mk
-
-SYS = openbsd
--- a/config/conf/amd64-posix.mk
+++ /dev/null
@@ -1,3 +1,0 @@
-ARCH = amd64
-ABI = amd64-posix
-O = 6
--- a/config/conf/arm32-linux.mk
+++ /dev/null
@@ -1,3 +1,0 @@
-include $(PROJECTDIR)/config/conf/arm32-posix.mk
-
-SYS = linux
--- a/config/conf/arm32-posix.mk
+++ /dev/null
@@ -1,3 +1,0 @@
-ABI = arm32-posix
-ARCH = arm32
-O = 5
--- a/config/conf/arm64-linux.mk
+++ /dev/null
@@ -1,3 +1,0 @@
-include $(PROJECTDIR)/config/conf/arm64-posix.mk
-
-SYS = linux
--- a/config/conf/arm64-posix.mk
+++ /dev/null
@@ -1,3 +1,0 @@
-ARCH = arm64
-ABI = arm64-posix
-O = 6
--- a/config/conf/ppc32-linux.mk
+++ /dev/null
@@ -1,3 +1,0 @@
-include $(PROJECTDIR)/config/conf/ppc32-posix.mk
-
-SYS = linux
--- a/config/conf/ppc32-posix.mk
+++ /dev/null
@@ -1,3 +1,0 @@
-ABI = ppc32-posix
-ARCH = ppc32
-O = q
--- a/config/host/bsd.mk
+++ /dev/null
@@ -1,3 +1,0 @@
-include $(PROJECTDIR)/config/host/unix.mk
-
-HOSTCFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
--- a/config/host/plan9.mk
+++ /dev/null
@@ -1,3 +1,0 @@
-include $(PROJECTDIR)/config/host/unix.mk
-
-HOSTCFLAGS = -D_SUSV2_SOURCE
--- a/config/host/unix.mk
+++ /dev/null
@@ -1,3 +1,0 @@
-DRIVER = posix
-
-HOSTCFLAGS = -D_POSIX_C_SOURCE
--- a/config/tool/clang.mk
+++ /dev/null
@@ -1,8 +1,0 @@
-include $(PROJECTDIR)/config/tool/gnu.mk
-
-COMP = clang
-ASM = clang
-TOOLASFLAGS = -c
-LINKER = ld.lld
-OBJCOPY = llvm-objcopy
-OBJDUMP = llvm-objdump
--- a/config/tool/gnu-darwin.mk
+++ /dev/null
@@ -1,3 +1,0 @@
-include $(PROJECTDIR)/config/tool/gnu.mk
-
-RANLIBFLAGS = -c
--- a/config/tool/gnu.mk
+++ /dev/null
@@ -1,12 +1,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
--- a/config/tool/pcc.mk
+++ /dev/null
@@ -1,3 +1,0 @@
-include $(PROJECTDIR)/config/tool/gnu.mk
-
-COMP = pcc
--- a/config/tool/unix.mk
+++ /dev/null
@@ -1,5 +1,0 @@
-COMP = c99
-ASM = as
-LINKER = ld
-RANLIB = ranlib
-ARCHIVE = ar
--- /dev/null
+++ b/scripts/build/conf/amd64-darwin.mk
@@ -1,0 +1,4 @@
+ARCH = amd64
+SYS = darwin
+ABI = amd64-darwin
+O = 6d
--- /dev/null
+++ b/scripts/build/conf/amd64-dragonfly.mk
@@ -1,0 +1,3 @@
+include $(BUILDDIR)/conf/amd64-posix.mk
+
+SYS = dragonfly
--- /dev/null
+++ b/scripts/build/conf/amd64-linux.mk
@@ -1,0 +1,3 @@
+include $(BUILDDIR)/conf/amd64-posix.mk
+
+SYS = linux
--- /dev/null
+++ b/scripts/build/conf/amd64-netbsd.mk
@@ -1,0 +1,3 @@
+include $(BUILDDIR)/conf/amd64-posix.mk
+
+SYS = netbsd
--- /dev/null
+++ b/scripts/build/conf/amd64-openbsd.mk
@@ -1,0 +1,3 @@
+include $(BUILDDIR)/conf/amd64-posix.mk
+
+SYS = openbsd
--- /dev/null
+++ b/scripts/build/conf/amd64-posix.mk
@@ -1,0 +1,3 @@
+ARCH = amd64
+ABI = amd64-posix
+O = 6
--- /dev/null
+++ b/scripts/build/conf/arm32-linux.mk
@@ -1,0 +1,3 @@
+include $(BUILDDIR)/conf/arm32-posix.mk
+
+SYS = linux
--- /dev/null
+++ b/scripts/build/conf/arm32-posix.mk
@@ -1,0 +1,3 @@
+ABI = arm32-posix
+ARCH = arm32
+O = 5
--- /dev/null
+++ b/scripts/build/conf/arm64-linux.mk
@@ -1,0 +1,3 @@
+include $(BUILDDIR)/conf/arm64-posix.mk
+
+SYS = linux
--- /dev/null
+++ b/scripts/build/conf/arm64-posix.mk
@@ -1,0 +1,3 @@
+ARCH = arm64
+ABI = arm64-posix
+O = 6
--- /dev/null
+++ b/scripts/build/conf/ppc32-linux.mk
@@ -1,0 +1,3 @@
+include $(BUILDDIR)/conf/ppc32-posix.mk
+
+SYS = linux
--- /dev/null
+++ b/scripts/build/conf/ppc32-posix.mk
@@ -1,0 +1,3 @@
+ABI = ppc32-posix
+ARCH = ppc32
+O = q
--- /dev/null
+++ b/scripts/build/host/bsd.mk
@@ -1,0 +1,3 @@
+DRIVER = posix
+
+HOST_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
--- /dev/null
+++ b/scripts/build/host/linux.mk
@@ -1,0 +1,3 @@
+DRIVER = posix
+
+HOST_CFLAGS = -D_ISOC99_SOURCE -D__STRICT_ANSI__
--- /dev/null
+++ b/scripts/build/host/plan9.mk
@@ -1,0 +1,3 @@
+DRIVER = posix
+
+HOST_CFLAGS = -D_SUSV2_SOURCE
--- /dev/null
+++ b/scripts/build/host/posix.mk
@@ -1,0 +1,3 @@
+DRIVER = posix
+
+HOST_CFLAGS = -D_POSIX_C_SOURCE=1
--- /dev/null
+++ b/scripts/build/tool/clang.mk
@@ -1,0 +1,9 @@
+include $(BUILDDIR)/tool/gnu.mk
+
+TOOL_ASFLAGS = -c
+
+COMP = clang
+ASM = clang
+LINKER = ld.lld
+OBJCOPY = llvm-objcopy
+OBJDUMP = llvm-objdump
--- /dev/null
+++ b/scripts/build/tool/gnu-darwin.mk
@@ -1,0 +1,3 @@
+include $(BUILDDIR)/tool/gnu.mk
+
+RANLIB_FLAGS = -c
--- /dev/null
+++ b/scripts/build/tool/gnu.mk
@@ -1,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
--- /dev/null
+++ b/scripts/build/tool/pcc.mk
@@ -1,0 +1,3 @@
+include $(BUILDDIR)/tool/gnu.mk
+
+COMP = pcc
--- /dev/null
+++ b/scripts/build/tool/unix.mk
@@ -1,0 +1,5 @@
+COMP = c99
+ASM = as
+LINKER = ld
+RANLIB = ranlib
+ARCHIVE = ar
--- 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
--- a/scripts/mklib
+++ /dev/null
@@ -1,43 +1,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
--- 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
+# Define the target all as default
+all:
-LIBDIR = $(PROJECTDIR)/lib/scc
-SCRIPTDIR = $(PROJECTDIR)/scripts
-INCDIR = $(PROJECTDIR)/include
+# Define default configuration variables
+CONF = amd64-linux
+TOOL = unix
+HOST = posix
+ROFF = gnu
-BINDIR = $(PROJECTDIR)/bin
-LIBEXEC = $(PROJECTDIR)/libexec/scc
-CRTDIR = $(PROJECTDIR)/lib/scc
-LIBCDIR = $(CRTDIR)/$(ARCH)-$(SYS)
-ENVIRON = $(SCRIPTDIR)/env.sh
+# 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)
-INCLUDE = -I$(INCDIR)/scc
+# 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 @@
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 $@
-clean: clean-helper
+.elf.map:
+ trap "rm -f $$$$.eps" EXIT QUIT INT TERM;\
+ $(LD) -Map=$@ $< -o /dev/null
-clean-helper:
- rm -f *.o $(OBJS) $(TARGET)
+.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 $@
+
+.3.ps:
+ trap "rm -f $$$$.ps" EXIT QUIT INT TERM;\
+ $(TBL) $< | $(TROFF) -man | $(DPOST) > $$$$.ps && mv $$$$.ps $@
+
+.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
--- 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)
--- 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 @@
$(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
--- 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 @@
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
--- a/src/cmd/as/target/powerpc/powerpc.mk
+++ b/src/cmd/as/target/powerpc/powerpc.mk
@@ -8,5 +8,5 @@
$(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 $@
--- a/src/cmd/as/target/powerpc/powerpc64.mk
+++ b/src/cmd/as/target/powerpc/powerpc64.mk
@@ -8,5 +8,5 @@
$(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 $@
--- a/src/cmd/as/target/x80/z80.mk
+++ b/src/cmd/as/target/x80/z80.mk
@@ -7,5 +7,5 @@
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 $@
--- a/src/cmd/as/target/x86/amd64.mk
+++ b/src/cmd/as/target/x86/amd64.mk
@@ -7,5 +7,5 @@
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 $@
--- a/src/cmd/as/target/x86/i286.mk
+++ b/src/cmd/as/target/x86/i286.mk
@@ -7,5 +7,5 @@
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 $@
--- a/src/cmd/as/target/x86/i386.mk
+++ b/src/cmd/as/target/x86/i386.mk
@@ -7,5 +7,5 @@
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 $@
--- 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)
--- a/src/cmd/cc/cc1/Makefile
+++ b/src/cmd/cc/cc1/Makefile
@@ -23,12 +23,12 @@
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
--- 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)
+MORE_CFLAGS = -I$(INCDIR)/$(STD)
-OBJS = main.o \
- parser.o \
- peep.o \
- symbol.o \
- node.o \
- code.o \
- optm.o \
+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 \
+TARGET =\
+ $(LIBEXEC)/scc/cc2-amd64-sysv\
+ $(LIBEXEC)/scc//cc2-i386-sysv\
+ $(LIBEXEC)/scc/cc2-qbe_amd64-sysv\
+ $(LIBEXEC)/scc//cc2-z80-scc\
all: $(TARGET)
--- a/src/cmd/cc/cc2/target/amd64-sysv/target.mk
+++ b/src/cmd/cc/cc2/target/amd64-sysv/target.mk
@@ -4,5 +4,5 @@
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 $@
--- a/src/cmd/cc/cc2/target/i386-sysv/target.mk
+++ b/src/cmd/cc/cc2/target/i386-sysv/target.mk
@@ -4,5 +4,5 @@
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 $@
--- 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 @@
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 $@
--- a/src/cmd/cc/cc2/target/z80-scc/target.mk
+++ b/src/cmd/cc/cc2/target/z80-scc/target.mk
@@ -4,5 +4,5 @@
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 $@
--- a/src/cmd/cc/posix/Makefile
+++ b/src/cmd/cc/posix/Makefile
@@ -16,8 +16,8 @@
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 @@
mv $$$$.sh $@
config.h:
- PREFIX=$(PREFIX) mkconf $(SYSLST)
+ PREFIX=$(PREFIX) ./mkconf $(SYSLST)
dep: inc-dep
--- a/src/cmd/ld/Makefile
+++ b/src/cmd/ld/Makefile
@@ -16,8 +16,8 @@
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
--- 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 @@
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)
--- 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 @@
i386\
ppc\
-all:
- +@cd $(ARCH) && $(MAKE)
+PROJECTDIR =../../..
+include $(PROJECTDIR)/scripts/rules.mk
+include ../rules.mk
+
+all: $(ARCH)
dep clean:
$(FORALL)
--- 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,20 +20,10 @@
memmove.$O\
memset.$O\
-DIRS =\
- netbsd\
- openbsd\
- dragonfly\
- linux\
- darwin\
-
all: $(LIBC) $(SYS)
$(LIBC): $(OBJS)
$(MKLST)
-
-$(SYS): FORCE
- +@cd $@ && $(MAKE)
dep: inc-dep
--- 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 @@
crt.$O: ../crt-posix.s
$(GENSRC): syscall.lst
- gensys.sh $(@:.s=)
+ ./gensys.sh $(@:.s=)
dep: inc-dep
--- 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 @@
crt.$O: ../crt-posix.s
$(GENSRC): syscall.lst
- gensys.sh $(@:.s=)
+ ./gensys.sh $(@:.s=)
dep: inc-dep
--- 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 @@
crt.$O: ../crt-posix.s
$(GENSRC): syscall.lst
- gensys.sh $(@:.s=)
+ ./gensys.sh $(@:.s=)
dep: inc-dep
--- 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 @@
crt.$O: ../crt-posix.s ../netbsd/crt.s
$(GENSRC): syscall.lst
- gensys.sh $(@:.s=)
+ ./gensys.sh $(@:.s=)
deps: inc-dep
--- 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 @@
crt.$O: ../crt-posix.s ../openbsd/crt.s
$(GENSRC): syscall.lst
- gensys.sh $(@:.s=)
+ ./gensys.sh $(@:.s=)
dep: inc-dep
--- 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,15 +16,10 @@
memmove.$O\
memset.$O\
-DIRS = linux
-
all: $(LIBC) $(SYS)
$(LIBC): $(OBJS)
$(MKLST)
-
-$(SYS): FORCE
- +@cd $@ && $(MAKE)
dep: inc-dep
--- 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 @@
crt.o: ../crt-posix.s
$(GENSRC): syscall.lst
- gensys.sh $(@:.s=)
+ ./gensys.sh $(@:.s=)
dep: inc-dep
--- 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,15 +16,10 @@
memmove.$O\
memset.$O\
-DIRS = linux
-
all: $(LIBC) $(SYS)
$(LIBC): $(OBJS)
$(MKLST)
-
-$(SYS): FORCE
- +@cd $@ && $(MAKE)
dep: inc-dep
--- 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 @@
crt.$O: ../crt-posix.s
$(GENSRC): syscall.lst
- gensys.sh $(@:.s=)
+ ./gensys.sh $(@:.s=)
clean:
rm -f $(GENSRC)
--- 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,15 +16,10 @@
memmove.$O\
memset.$O\
-DIRS = linux
-
all: $(LIBC) $(SYS)
$(LIBC): $(OBJS)
$(MKLST)
-
-$(SYS): FORCE
- +@cd $@ && $(MAKE)
dep: inc-dep
--- 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 @@
crt.$O: ../crt-posix.s
$(GENSRC): syscall.lst
- gensys.sh $(@:.s=)
+ ./gensys.sh $(@:.s=)
dep: inc-dep
--- 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,15 +16,10 @@
memmove.$O\
memset.$O\
-DIRS = linux
-
all: $(LIBC) $(SYS)
$(LIBC): $(OBJS)
$(MKLST)
-
-$(SYS): FORCE
- +@cd $@ && $(MAKE)
dep: inc-dep
--- 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 @@
crt.$O: ../crt-posix.s
$(GENSRC): syscall.lst
- gensys.sh $(@:.s=)
+ ./gensys.sh $(@:.s=)
dep: inc-dep
--- 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 @@
# 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 $@
--- a/src/libc/string/Makefile
+++ b/src/libc/string/Makefile
@@ -1,4 +1,5 @@
.POSIX:
+
PROJECTDIR =../../..
include $(PROJECTDIR)/scripts/rules.mk
include ../rules.mk
--- a/src/libcrt/Makefile
+++ b/src/libcrt/Makefile
@@ -1,4 +1,5 @@
.POSIX:
+
PROJECTDIR=../..
include $(PROJECTDIR)/scripts/rules.mk
--- 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 @@
all: $(TARGET)
$(TARGET): $(OBJS)
- mklib -o $@ $?
+ $(AR) $(PROJ_ARFLAGS) $@ $?
+ $(RL) $(PROJ_RLFLAGS) $@
--- 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 @@
all: $(TARGET)
$(TARGET): $(OBJS)
- mklib -o $@ $?
+ $(AR) $(PROJ_ARFLAGS) $@ $?
+ $(RL) $(PROJ_RLFLAGS) $@
--- 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 @@
all: $(TARGET)
$(TARGET): $(OBJS)
- mklib -o $@ $?
+ $(AR) $(PROJ_ARFLAGS) $@ $?
+ $(RL) $(PROJ_RLFLAGS) $@
--- a/src/libcrt/i386/Makefile
+++ b/src/libcrt/i386/Makefile
@@ -1,10 +1,12 @@
.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
@@ -11,4 +13,5 @@
all: $(TARGET)
$(TARGET): $(OBJS)
- mklib -o $@ $?
+ $(AR) $(PROJ_ARFLAGS) $@ $?
+ $(RL) $(PROJ_RLFLAGS) $@
--- 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 @@
all: $(TARGET)
$(TARGET): $(OBJS)
- mklib -o $@ $?
+ $(AR) $(PROJ_ARFLAGS) $@ $?
+ $(RL) $(PROJ_RLFLAGS) $@
--- 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 @@
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)
--- a/src/libmach/Makefile.mach
+++ b/src/libmach/Makefile.mach
@@ -3,9 +3,10 @@
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) $@
--- 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)
--- 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
--- 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)
--- a/tests/as/execute/Makefile
+++ b/tests/as/execute/Makefile
@@ -1,4 +1,5 @@
.POSIX:
+
ROOT=../../../
all: tests
--- a/tests/nm/execute/Makefile
+++ b/tests/nm/execute/Makefile
@@ -1,4 +1,5 @@
.POSIX:
+
ROOT=../../..
OUT = z80.out
--- a/tests/size/execute/Makefile
+++ b/tests/size/execute/Makefile
@@ -1,4 +1,5 @@
.POSIX:
+
ROOT=../../..
OUT = z80.out
--- a/tests/strip/execute/Makefile
+++ b/tests/strip/execute/Makefile
@@ -1,4 +1,5 @@
.POSIX:
+
ROOT=../../..
OUT = z80.out