From b85cf3e16d7dbb753000cd595bea9719caf2b43d Mon Sep 17 00:00:00 2001 From: Tom Everett Date: Fri, 25 Mar 2016 13:24:07 -0600 Subject: [PATCH] externalized os.mk --- Makefile | 10 ++++++---- build/Makefile | 35 ++--------------------------------- build/os.mk | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 37 deletions(-) create mode 100644 build/os.mk diff --git a/Makefile b/Makefile index ced05fe..315d803 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,16 @@ +include build/os.mk + all: buildit buildit: - cd build && make all + cd build && $(MAKE) all run: buildit - cd build && make run + cd build && $(MAKE) run altrun: buildit - cd build && make alt && make altrun + cd build && $(MAKE) alt && $(MAKE) altrun clean: - cd build && make clean + cd build && $(MAKE) clean diff --git a/build/Makefile b/build/Makefile index 92df5f4..aca6360 100644 --- a/build/Makefile +++ b/build/Makefile @@ -1,5 +1,7 @@ # Build the kernel, the utilities, the filesystem and run SimH +include os.mk + # tools AS=../tools/as7 ASARGS=--format=ptr @@ -9,38 +11,6 @@ FSCK=../tools/fsck7 CCARGS=-Wno-multichar PDP7=pdp7 -# detect OS -UNAME= $(shell uname) -ifeq ($(UNAME), Linux) - UNAME= LINUX -else -ifeq ($(UNAME), Darwin) - UNAME= DARWIN -else -ifeq ($(UNAME), FreeBSD) - UNAME= FREEBSD -endif -endif -endif - -# choose C compiler -ifeq ($(UNAME), LINUX) -# Linux - CC=gcc -else -ifeq ($(UNAME), FREEBSD) -# FreeBSD - CC=cc -else -ifeq ($(UNAME), DARWIN) -# Mac OS X - CC=cc -else: -$(error "Unknown OS: " $(UNAME)) -endif -endif -endif - # source dirs SYSSRC=../src/sys CMDSRC=../src/cmd @@ -53,7 +23,6 @@ BINDIR=bin TESTDIR=tests BINARIES=../binaries/ - all: cmd others a.out boot.rim image.fs # Make alternative everything: no dd but . and .. diff --git a/build/os.mk b/build/os.mk new file mode 100644 index 0000000..8ad50ca --- /dev/null +++ b/build/os.mk @@ -0,0 +1,36 @@ + +# detect OS +UNAME=$(shell uname) +ifeq ($(UNAME), Linux) + UNAME=LINUX + MAKE=make +else +ifeq ($(UNAME), Darwin) + UNAME=DARWIN + MAKE=make +else +ifeq ($(UNAME), FreeBSD) + UNAME=FREEBSD + MAKE=gmake +endif +endif +endif + +# choose C compiler +ifeq ($(UNAME), LINUX) +# Linux + CC=gcc +else +ifeq ($(UNAME), FREEBSD) +# FreeBSD + CC=cc +else +ifeq ($(UNAME), DARWIN) +# Mac OS X + CC=cc +else + $(error "Unknown OS: " $(UNAME)) +endif +endif +endif +