Makefile: Move the per CPU stuff into the CPU directory
authorAlan Cox <alan@linux.intel.com>
Sun, 8 Feb 2015 15:30:52 +0000 (15:30 +0000)
committerAlan Cox <alan@linux.intel.com>
Sun, 8 Feb 2015 15:30:52 +0000 (15:30 +0000)
Before the Makefiles get out of hand, impose some kind of sanity. We will also
need the platform bits for things like ZX Spectrum 128 where we need to add
our new --external-banker flags and the like.

Kernel/Makefile
Kernel/cpu-6502/rules.mk [new file with mode: 0644]
Kernel/cpu-68000/rules.mk [new file with mode: 0644]
Kernel/cpu-6809/rules.mk [new file with mode: 0644]
Kernel/cpu-8086/rules.mk [new file with mode: 0644]
Kernel/cpu-z180/rules.mk [new file with mode: 0644]
Kernel/cpu-z80/rules.mk [new file with mode: 0644]

index b9284ce..e9a54f0 100644 (file)
@@ -1,13 +1,13 @@
 TARGET_LIST = platform-nc100 platform-micropack platform-pcw8256 platform-socz80 platform-zx128 platform-trs80 platform-z80pack platform-z80pack-lite platform-z80pack32 platform-dragon platform-tgl6502
 
-#export TARGET= trs80
-#export CPU = z80
+export TARGET= trs80
+export CPU = z80
 #export TARGET = dragon
 #export CPU = 6809
 #export TARGET = tgl6502
 #export CPU = 6502
-export TARGET=atarist
-export CPU = 68000
+#export TARGET=atarist
+#export CPU = 68000
 #export TARGET = 8086test
 #export CPU = 8086
 
@@ -16,105 +16,12 @@ export SUBVERSION = "ac1"
 
 UNAME_S := $(shell uname -s)
 
-ifneq (,$(filter $(CPU),z80 z180)) # matches CPU = z80 or z180
-export CROSS_AS=sdasz80
-export CROSS_LD=tools/bankld/sdldz80
-export CROSS_CC=sdcc
-#export CROSS_CCOPTS=-c --std-sdcc99 --no-std-crt0 -mz80 -I$(ROOT_DIR)/cpu-z80 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include --max-allocs-per-node 1000000 --opt-code-size --Werror --stack-auto --constseg CONST
-#export CROSS_CCOPTS=-c --std-sdcc99 --no-std-crt0 -mz80 -I$(ROOT_DIR)/cpu-z80 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include --max-allocs-per-node 200000 --opt-code-size --Werror --stack-auto --constseg CONST
-export CROSS_CCOPTS=-c --std-sdcc99 --no-std-crt0 -m$(CPU) -I$(ROOT_DIR)/cpu-$(CPU) -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include --max-allocs-per-node 30000 --opt-code-size --Werror --stack-auto --constseg CONST
-#export CROSS_CCOPTS+=--nostdlib --nostdinc -Isdcclib/include 
-export CROSS_CC_SEG2=--codeseg CODE2
-# For now but we are overspilling in a lot of configs so will need a real CODE3
-export CROSS_CC_SEG3=--codeseg CODE2
-export CROSS_CC_SEGDISC=--codeseg DISCARD --constseg DISCARD
-export CROSS_CC_FONT=--constseg FONT
-export CROSS_CC_VIDEO=--codeseg VIDEO
-export ASOPTS=-plosff
-export ASMEXT = .s
-export BINEXT = .rel
-export BITS=16
-#
-#      Adjust this as needed for your platform (or contribute a script
-#      to look in the usual places !)
-#
-ifeq ($(SDCC_LIB),)
-  ifeq ($(UNAME_S),Darwin)
-    export LIBZ80=/usr/local/share/sdcc/lib/$(CPU)
-  else
-    export LIBZ80=/usr/share/sdcc/lib/$(CPU)
-  endif
-else
-  export LIBZ80=$(SDCC_LIB)/$(CPU)
-endif
-else ifeq ($(CPU),6502)
-export CROSS_AS=ca65
-export CROSS_LD=cl65
-export CROSS_CC=cl65
-export CROSS_CCOPTS=--all-fastcall -c -O -t none -I$(ROOT_DIR)/cpu-6502 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include
-#
-# The 6502 compiler produces what is mostly threadcode and is quite determined
-# that the runtime lives in the code segment. As we want the runtime in common
-# memory we use SEG1/SEG2 names for all the kernel code.
-#
-export CROSS_CC_SEG1=--code-name SEG1
-export CROSS_CC_SEG2=--code-name SEG2
-# 6502 we need a real SEG3 to make it fit
-export CROSS_CC_SEG3=--code-name SEG3
-export CROSS_CC_SEGDISC=--code-name DISCARD --rodata-name DISCARDDATA
-export ASMEXT = .s
-export BINEXT = .o
-export BITS=16
-else ifeq ($(CPU),6809)
-export CROSS_AS=m6809-unknown-as
-export CROSS_LD=lwlink
-export CROSS_CC = m6809-unknown-gcc
-#export CROSS_CCOPTS=-Wall -O2 -I$(ROOT_DIR)/cpu-6809 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include
-export CROSS_CCOPTS=-c -Wall -Os -msoft-reg-count=0 -mfar-stack-param -I$(ROOT_DIR)/cpu-6809 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include
-export CROSS_CC_SEG1=-mcode-section=.text -mfar-code-page=1
-export CROSS_CC_SEG2=-mcode-section=.text2 -mfar-code-page=2
-#Given the compactness we don't need a CODE3 segment really
-export CROSS_CC_SEG3=-mcode-section=.text2 -mfar-code-page=2
-export CROSS_CC_SEGDISC=-mcode-section=.discard -mfar-code-page=3
-export CROSS_CC_VIDEO=-mcode-section=.video -mdata-section=.videodata -mfar-code-page=4
-export ASOPTS=
-export ASMEXT = .s
-export BINEXT = .o
-export BITS=16
-else ifeq ($(CPU),68000)
-export CROSS_LD=m68k-atari-mint-ld
-export CROSS_CC = m68k-atari-mint-gcc
-export CROSS_CCOPTS=-c -fno-builtin -Wall -Os -m68000 -mshort -I$(ROOT_DIR)/cpu-68000 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include
-export CROSS_AS=$(CROSS_CC) $(CROSS_CCOPTS) #-Wa,-M
-export CROSS_CC_SEG1=
-export CROSS_CC_SEG2=
-export CROSS_CC_SEG3=
-# Fixme: we should split discard off
-export CROSS_CC_SEGDISC=
-export CROSS_CC_VIDEO=
-export ASOPTS=
-export ASMEXT = .S
-export BINEXT = .o
-export BITS=32
-else
-export CROSS_LD=ld86
-export CROSS_CC = bcc
-export CROSS_CCOPTS=-c -ansi -0 -O -I$(ROOT_DIR)/cpu-8086 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include
-export CROSS_AS=$(CROSS_CC) $(CROSS_CCOPTS)
-export CROSS_CC_SEG1=
-export CROSS_CC_SEG2=
-export CROSS_CC_SEG3=
-# Fixme: we should split discard off
-export CROSS_CC_SEGDISC=
-export CROSS_CC_VIDEO=
-export ASOPTS=
-export ASMEXT = .S
-export BINEXT = .o
-export BITS=16
-endif
-
 ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
 
+include cpu-$(CPU)/rules.mk
+-include platform-$(TARGET)/rules.mk
+
+
 
 #
 #      We put these into two code segments so that the caller can plan to
diff --git a/Kernel/cpu-6502/rules.mk b/Kernel/cpu-6502/rules.mk
new file mode 100644 (file)
index 0000000..ad6310d
--- /dev/null
@@ -0,0 +1,17 @@
+export CROSS_AS=ca65
+export CROSS_LD=cl65
+export CROSS_CC=cl65
+export CROSS_CCOPTS=--all-fastcall -c -O -t none -I$(ROOT_DIR)/cpu-6502 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include
+#
+# The 6502 compiler produces what is mostly threadcode and is quite determined
+# that the runtime lives in the code segment. As we want the runtime in common
+# memory we use SEG1/SEG2 names for all the kernel code.
+#
+export CROSS_CC_SEG1=--code-name SEG1
+export CROSS_CC_SEG2=--code-name SEG2
+# 6502 we need a real SEG3 to make it fit
+export CROSS_CC_SEG3=--code-name SEG3
+export CROSS_CC_SEGDISC=--code-name DISCARD --rodata-name DISCARDDATA
+export ASMEXT = .s
+export BINEXT = .o
+export BITS=16
diff --git a/Kernel/cpu-68000/rules.mk b/Kernel/cpu-68000/rules.mk
new file mode 100644 (file)
index 0000000..842ab10
--- /dev/null
@@ -0,0 +1,14 @@
+export CROSS_LD=m68k-atari-mint-ld
+export CROSS_CC = m68k-atari-mint-gcc
+export CROSS_CCOPTS=-c -fno-builtin -Wall -Os -m68000 -mshort -I$(ROOT_DIR)/cpu-68000 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include
+export CROSS_AS=$(CROSS_CC) $(CROSS_CCOPTS) #-Wa,-M
+export CROSS_CC_SEG1=
+export CROSS_CC_SEG2=
+export CROSS_CC_SEG3=
+# Fixme: we should split discard off
+export CROSS_CC_SEGDISC=
+export CROSS_CC_VIDEO=
+export ASOPTS=
+export ASMEXT = .S
+export BINEXT = .o
+export BITS=32
diff --git a/Kernel/cpu-6809/rules.mk b/Kernel/cpu-6809/rules.mk
new file mode 100644 (file)
index 0000000..af92d29
--- /dev/null
@@ -0,0 +1,15 @@
+export CROSS_AS=m6809-unknown-as
+export CROSS_LD=lwlink
+export CROSS_CC = m6809-unknown-gcc
+#export CROSS_CCOPTS=-Wall -O2 -I$(ROOT_DIR)/cpu-6809 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include
+export CROSS_CCOPTS=-c -Wall -Os -msoft-reg-count=0 -mfar-stack-param -I$(ROOT_DIR)/cpu-6809 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include
+export CROSS_CC_SEG1=-mcode-section=.text -mfar-code-page=1
+export CROSS_CC_SEG2=-mcode-section=.text2 -mfar-code-page=2
+#Given the compactness we don't need a CODE3 segment really
+export CROSS_CC_SEG3=-mcode-section=.text2 -mfar-code-page=2
+export CROSS_CC_SEGDISC=-mcode-section=.discard -mfar-code-page=3
+export CROSS_CC_VIDEO=-mcode-section=.video -mdata-section=.videodata -mfar-code-page=4
+export ASOPTS=
+export ASMEXT = .s
+export BINEXT = .o
+export BITS=16
diff --git a/Kernel/cpu-8086/rules.mk b/Kernel/cpu-8086/rules.mk
new file mode 100644 (file)
index 0000000..19b76bc
--- /dev/null
@@ -0,0 +1,14 @@
+export CROSS_LD=ld86
+export CROSS_CC = bcc
+export CROSS_CCOPTS=-c -ansi -0 -O -I$(ROOT_DIR)/cpu-8086 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include
+export CROSS_AS=$(CROSS_CC) $(CROSS_CCOPTS)
+export CROSS_CC_SEG1=
+export CROSS_CC_SEG2=
+export CROSS_CC_SEG3=
+# Fixme: we should split discard off
+export CROSS_CC_SEGDISC=
+export CROSS_CC_VIDEO=
+export ASOPTS=
+export ASMEXT = .S
+export BINEXT = .o
+export BITS=16
diff --git a/Kernel/cpu-z180/rules.mk b/Kernel/cpu-z180/rules.mk
new file mode 100644 (file)
index 0000000..b993187
--- /dev/null
@@ -0,0 +1,30 @@
+export CROSS_AS=sdasz80
+export CROSS_LD=tools/bankld/sdldz80
+export CROSS_CC=sdcc
+#export CROSS_CCOPTS=-c --std-sdcc99 --no-std-crt0 -m$(CPU) -I$(ROOT_DIR)/cpu-z80 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include --max-allocs-per-node 1000000 --opt-code-size --Werror --stack-auto --constseg CONST
+#export CROSS_CCOPTS=-c --std-sdcc99 --no-std-crt0 -m$(CPU) -I$(ROOT_DIR)/cpu-z80 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include --max-allocs-per-node 200000 --opt-code-size --Werror --stack-auto --constseg CONST
+export CROSS_CCOPTS=-c --std-sdcc99 --no-std-crt0 -m$(CPU) -I$(ROOT_DIR)/cpu-$(CPU) -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include --max-allocs-per-node 30000 --opt-code-size --Werror --stack-auto --constseg CONST
+#export CROSS_CCOPTS+=--nostdlib --nostdinc -Isdcclib/include 
+export CROSS_CC_SEG2=--codeseg CODE2
+# For now but we are overspilling in a lot of configs so will need a real CODE3
+export CROSS_CC_SEG3=--codeseg CODE2
+export CROSS_CC_SEGDISC=--codeseg DISCARD --constseg DISCARD
+export CROSS_CC_FONT=--constseg FONT
+export CROSS_CC_VIDEO=--codeseg VIDEO
+export ASOPTS=-plosff
+export ASMEXT = .s
+export BINEXT = .rel
+export BITS=16
+#
+#      Adjust this as needed for your platform (or contribute a script
+#      to look in the usual places !)
+#
+ifeq ($(SDCC_LIB),)
+  ifeq ($(UNAME_S),Darwin)
+    export LIBZ80=/usr/local/share/sdcc/lib/$(CPU)
+  else
+    export LIBZ80=/usr/share/sdcc/lib/$(CPU)
+  endif
+else
+  export LIBZ80=$(SDCC_LIB)/$(CPU)
+endif
diff --git a/Kernel/cpu-z80/rules.mk b/Kernel/cpu-z80/rules.mk
new file mode 100644 (file)
index 0000000..0daf6bc
--- /dev/null
@@ -0,0 +1,30 @@
+export CROSS_AS=sdasz80
+export CROSS_LD=tools/bankld/sdldz80
+export CROSS_CC=sdcc
+#export CROSS_CCOPTS=-c --std-sdcc99 --no-std-crt0 -mz80 -I$(ROOT_DIR)/cpu-z80 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include --max-allocs-per-node 1000000 --opt-code-size --Werror --stack-auto --constseg CONST
+#export CROSS_CCOPTS=-c --std-sdcc99 --no-std-crt0 -mz80 -I$(ROOT_DIR)/cpu-z80 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include --max-allocs-per-node 200000 --opt-code-size --Werror --stack-auto --constseg CONST
+export CROSS_CCOPTS=-c --std-sdcc99 --no-std-crt0 -m$(CPU) -I$(ROOT_DIR)/cpu-$(CPU) -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include --max-allocs-per-node 30000 --opt-code-size --Werror --stack-auto --constseg CONST
+#export CROSS_CCOPTS+=--nostdlib --nostdinc -Isdcclib/include 
+export CROSS_CC_SEG2=--codeseg CODE2
+# For now but we are overspilling in a lot of configs so will need a real CODE3
+export CROSS_CC_SEG3=--codeseg CODE2
+export CROSS_CC_SEGDISC=--codeseg DISCARD --constseg DISCARD
+export CROSS_CC_FONT=--constseg FONT
+export CROSS_CC_VIDEO=--codeseg VIDEO
+export ASOPTS=-plosff
+export ASMEXT = .s
+export BINEXT = .rel
+export BITS=16
+#
+#      Adjust this as needed for your platform (or contribute a script
+#      to look in the usual places !)
+#
+ifeq ($(SDCC_LIB),)
+  ifeq ($(UNAME_S),Darwin)
+    export LIBZ80=/usr/local/share/sdcc/lib/$(CPU)
+  else
+    export LIBZ80=/usr/share/sdcc/lib/$(CPU)
+  endif
+else
+  export LIBZ80=$(SDCC_LIB)/$(CPU)
+endif