Skip to content

Commit 2c891f2

Browse files
authored
Merge pull request #58 from kubilus1/sgdk_162
Bump to sgdk 1.62. Use original makelib.gen makefile to build lib (modified)
2 parents dcd86cc + bc280a8 commit 2c891f2

16 files changed

+119
-170
lines changed

.circleci/config.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ jobs:
2323
command: make tools_build
2424
- run:
2525
name: build SGDK
26-
command: make sgdk_build
26+
command: |
27+
export GENDEV=`pwd`/build
28+
make sgdk_build sgdk_install
2729
- run:
2830
name: build samples
2931
command: |

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ ENV PATH $GENDEV/bin:$PATH
4242

4343
WORKDIR /src
4444

45-
ENTRYPOINT make -f $GENDEV/sgdk/mkfiles/makefile.gen
45+
ENTRYPOINT make -f $GENDEV/sgdk/mkfiles/Makefile.rom

Makefile

+10-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ PATH := $(BUILDDIR)/bin:$(PATH)
1919
build: toolchain_build tools_build sgdk_build
2020
echo "Done"
2121

22+
docker_build:
23+
docker build -t gendev .
24+
2225
$(BUILDDIR):
2326
mkdir -p $@
2427

@@ -44,9 +47,6 @@ tools_build:
4447
tools_clean:
4548
cd tools && $(MAKE) tools_clean
4649

47-
sgdk_samples:
48-
cd sgdk && $(MAKE) sample_clean samples
49-
5050
$(GENDEV):
5151
if [ -w /opt ]; then \
5252
mkdir -p $(GENDEV); \
@@ -82,11 +82,17 @@ dist/gendev_$(VER)_all.deb: pkg_build
8282
cd dist && dpkg-deb -Zxz -z9 --build $(TOPDIR)/pkg_build .
8383

8484
sgdk_build:
85-
cd sgdk && GENDEV=$(BUILDDIR) $(MAKE) install
85+
cd sgdk && GENDEV=$(BUILDDIR) $(MAKE)
86+
87+
sgdk_install: $(GENDEV)
88+
cd sgdk && $(MAKE) install
8689

8790
sgdk_clean:
8891
- cd sgdk && $(MAKE) clean
8992

93+
sgdk_samples:
94+
cd sgdk && $(MAKE) sample_clean samples
95+
9096
clean: tools_clean toolchain_clean sgdk_clean
9197
-rm -rf $(BUILDDIR)
9298
-rm -rf pkg_build

sgdk/Makefile

+74-35
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,97 @@
1+
2+
# Locatin of gendev install
13
GENDEV?=/opt/gendev/
24
GENBIN=$(GENDEV)/bin
3-
GENGCC_BIN=$(GENDEV)/bin
4-
SGDKDIR=$(CURDIR)/SGDK
5+
6+
# Location of build and source
7+
BUILDDIR?=$(CURDIR)/build
8+
SGDKDIR=$(BUILDDIR)/sgdk
59
SAMPLESDIR=$(SGDKDIR)/sample
610

7-
SGDKVER=v1.51
11+
# Version of SGDK to build
12+
SGDKVER=v1.62
13+
14+
# SGDK install location
815
SGDKINSTALLDIR=$(GENDEV)/sgdk$(SGDKVER)
916

10-
all: tools $(SGDKDIR) $(SGDKDIR)/libmd.a
17+
all: $(SGDKDIR) $(SGDKDIR)/lib/libmd.a tools
1118

12-
tools: $(SGDKDIR)
19+
# Various tools needed to use SGDK
20+
tools: $(SGDKDIR) $(SGDKINSTALLDIR)
21+
cd $(SGDKDIR)/tools/bintos/src && \
22+
gcc -o bintos bintos.c
23+
cd $(SGDKDIR)/tools/sizebnd/src && \
24+
gcc -o sizebnd sizebnd.c
25+
cd $(SGDKDIR)/tools/xgmtool && \
26+
$(MAKE) -f $(CURDIR)/mkfiles/Makefile.xgmtool
1327
cd $(SGDKDIR)/tools/bintos/src && \
14-
gcc -o bintos bintos.c && cp bintos $(GENDEV)/bin/.
28+
cp bintos $(SGDKINSTALLDIR)/bin/.
1529
cd $(SGDKDIR)/tools/sizebnd/src && \
16-
gcc -o sizebnd sizebnd.c && cp sizebnd $(GENDEV)/bin/.
30+
cp sizebnd $(SGDKINSTALLDIR)/bin/.
1731
cd $(SGDKDIR)/tools/xgmtool && \
18-
$(MAKE) -f ../../../files/Makefile.xgmtool && cp out/xgmtool $(GENDEV)/bin/.
19-
cp $(SGDKDIR)/bin/*.jar $(GENDEV)/bin/.
32+
cp out/xgmtool $(SGDKINSTALLDIR)/bin/.
33+
cp $(SGDKDIR)/bin/*.jar $(SGDKINSTALLDIR)/bin/.
2034

35+
36+
# Create a new patchfile based on the current SGDK checkout
2137
patch: $(SGDKDIR)
22-
cd $(SGDKDIR) && git diff . > ../files/sgdk_$(SGDKVER).diff
38+
cd $(SGDKDIR) && git diff . > $(CURDIR)/patches/sgdk_$(SGDKVER).diff
2339

40+
# Update an SGDK checkout with the current versions patchfile
2441
prep: $(SGDKDIR)
25-
cd $(SGDKDIR) && patch -u -p1 -l < ../files/sgdk_$(SGDKVER).diff
42+
cd $(SGDKDIR) && patch -u -p1 -l < $(CURDIR)/patches/sgdk_$(SGDKVER).diff
43+
44+
$(BUILDDIR):
45+
mkdir -p $@
2646

47+
# Checkout and prep SGDK for building
2748
SGDK: $(SGDKDIR)
28-
$(SGDKDIR):
29-
git clone -b '$(SGDKVER)' --single-branch --depth 1 https://github.com/Stephane-D/SGDK.git
49+
$(SGDKDIR): $(BUILDDIR)
50+
cd $(BUILDDIR) && git clone -b '$(SGDKVER)' --single-branch --depth 1 https://github.com/Stephane-D/SGDK.git sgdk
51+
cd $(SGDKDIR) && patch -u -p1 -l < $(CURDIR)/patches/sgdk_$(SGDKVER).diff
52+
rm -f $(SGDKDIR)/lib/*.a
53+
rm -f $(SGDKDIR)/bin/*.exe
3054

31-
$(SGDKDIR)/libmd.a: prep
32-
cp -rf ../tools/files/applib/lib $(SGDKDIR)/tools/appack
33-
cd $(SGDKDIR) && ln -sf ../files/Makefile.sgdk_lib .
34-
cd $(SGDKDIR) && $(MAKE) -f Makefile.sgdk_lib
55+
$(SGDKDIR)/mkfiles: $(SGDKDIR)
56+
mkdir -p $(SGDKDIR)/mkfiles
57+
cp -f $(CURDIR)/mkfiles/makefile.vars $@/.
58+
cp -f $(CURDIR)/mkfiles/Makefile.sgdk_lib $@/.
59+
cp -f $(CURDIR)/mkfiles/Makefile.rom $@/.
60+
61+
$(SGDKDIR)/lib/libmd.a: $(SGDKDIR) $(SGDKDIR)/mkfiles tools
62+
cd $(SGDKDIR) && SGDKDIR=$(SGDKDIR) $(MAKE) -f $(CURDIR)/mkfiles/Makefile.sgdk_lib
63+
cp $(GENDEV)/lib/libgcc.a $(SGDKDIR)/lib/libgcc.a
64+
mv $(SGDKDIR)/libmd.a $(SGDKDIR)/lib/libmd.a
65+
@echo "Done building sgdk library"
3566

3667
$(SGDKINSTALLDIR):
3768
mkdir -p $@
3869
rm -f $(GENDEV)/sgdk
3970
cd $(GENDEV) && ln -sf sgdk$(SGDKVER) sgdk
71+
mkdir -p $@/src
72+
mkdir -p $@/bin
73+
mkdir -p $@/inc
74+
mkdir -p $@/res
75+
mkdir -p $@/lib
76+
mkdir -p $@/mkfiles
4077

41-
install: tools $(SGDKDIR)/libmd.a $(SGDKINSTALLDIR)
78+
install: $(SGDKDIR)/lib/libmd.a $(SGDKINSTALLDIR)
4279
echo "Install"
43-
mkdir -p $(GENDEV)/sgdk/src
44-
mkdir -p $(GENDEV)/sgdk/inc
45-
mkdir -p $(GENDEV)/sgdk/lib
46-
mkdir -p $(GENDEV)/sgdk/res
47-
mkdir -p $(GENDEV)/sgdk/mkfiles
48-
cp $(SGDKDIR)/md.ld $(GENDEV)/sgdk/.
49-
cp $(SGDKDIR)/inc/* $(GENDEV)/sgdk/inc/.
50-
cp -r $(SGDKDIR)/src/boot $(GENDEV)/sgdk/src/.
51-
cp -r $(SGDKDIR)/res/* $(GENDEV)/sgdk/res/.
52-
cp $(GENDEV)/lib/libgcc.a $(GENDEV)/sgdk/lib/.
53-
cp $(SGDKDIR)/libmd.a $(GENDEV)/sgdk/lib/.
54-
cp $(SGDKDIR)/makefile.gen $(GENDEV)/sgdk/mkfiles/.
55-
cp files/makefile.vars $(GENDEV)/sgdk/mkfiles/.
56-
cp $(SGDKDIR)/tools/sizebnd/src/sizebnd $(GENDEV)/bin/
80+
cp $(SGDKDIR)/md.ld $(SGDKINSTALLDIR)/.
81+
cp $(SGDKDIR)/inc/* $(SGDKINSTALLDIR)/inc/.
82+
cp -r $(SGDKDIR)/src/boot $(SGDKINSTALLDIR)/src/.
83+
cp -r $(SGDKDIR)/res/* $(SGDKINSTALLDIR)/res/.
84+
cp $(GENDEV)/lib/libgcc.a $(SGDKINSTALLDIR)/lib/.
85+
cp $(SGDKDIR)/lib/libmd.a $(SGDKINSTALLDIR)/lib/.
86+
cp $(SGDKDIR)/makefile.gen $(SGDKINSTALLDIR)/mkfiles/.
87+
cp $(SGDKDIR)/mkfiles/* $(SGDKINSTALLDIR)/mkfiles/.
88+
cp $(SGDKDIR)/tools/sizebnd/src/sizebnd $(SGDKINSTALLDIR)/bin/
89+
cd $(SGDKINSTALLDIR)/bin && ln -sf ../../bin/m68k-elf-gcc gcc
90+
cd $(SGDKINSTALLDIR)/bin && ln -sf ../../bin/m68k-elf-nm nm
91+
cd $(SGDKINSTALLDIR)/bin && ln -sf ../../bin/m68k-elf-ld ld
92+
cd $(SGDKINSTALLDIR)/bin && ln -sf ../../bin/m68k-elf-objcopy objcopy
93+
cd $(SGDKINSTALLDIR)/bin && ln -sf ../../bin/sjasm sjasm
94+
5795

5896
SAMPLES=$(wildcard $(SAMPLESDIR)/*/out)
5997
SAMPLEROMS=$(addsuffix /rom.bin,$(SAMPLES))
@@ -64,15 +102,16 @@ sample_clean: $(CLEANSAMPLES)
64102
@echo "Done cleaning samples"
65103

66104
$(CLEANSAMPLES):
67-
cd $@/.. && $(MAKE) -f $(SGDKDIR)/makefile.gen clean
105+
cd $@/.. && $(MAKE) -f $(CURDIR)/mkfiles/Makefile.rom clean
68106

69107
samples: $(SAMPLEROMS)
70108
@echo "All samples built"
71109

72-
$(SAMPLEDIR)/%/out/rom.bin:
110+
$(SAMPLESDIR)/%/out/rom.bin:
73111
echo "ROM $@"
74-
cd $@/../../ && $(MAKE) -f $(GENDEV)/sgdk/mkfiles/makefile.gen
112+
cd $@/../../ && GENDEV=$(GENDEV) $(MAKE) -f $(SGDKINSTALLDIR)/mkfiles/Makefile.rom
75113

76114
clean:
77115
echo "Clean"
78116
-rm -rf $(SGDKDIR)
117+
-rm -rf $(BUILDDIR)

sgdk/files/sgdk.ld

-116
This file was deleted.

sgdk/mkfiles/Makefile.rom

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Use this Makefile for most SGDK projects
3+
#
4+
5+
GENDEV?=/opt/gendev
6+
SGDKDIR?=$(GENDEV)/sgdk
7+
8+
# Set GDK before including default SGDK makefile
9+
GDK=$(SGDKDIR)
10+
11+
include $(SGDKDIR)/mkfiles/makefile.gen
12+
13+
# Override shell variables
14+
MKDIR=/bin/mkdir
15+
RM=/bin/rm
16+
CP=/bin/cp
17+
SHELL=/bin/bash

sgdk/files/Makefile.sgdk_lib sgdk/mkfiles/Makefile.sgdk_lib

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
GENDEV?=/opt/toolchains/gen/
1+
GENDEV?=/opt/gendev/
22
MAKE?=make
33
GENGCC_BIN=$(GENDEV)/bin
44
GENBIN=$(GENDEV)/bin
5+
SGDKBIN=$(GENDEV)/sgdk/bin
6+
57

68
CC = $(GENGCC_BIN)/m68k-elf-gcc
79
AR = $(GENGCC_BIN)/m68k-elf-ar
810
RANLIB = $(GENGCC_BIN)/m68k-elf-ranlib
911
OBJC = $(GENGCC_BIN)/m68k-elf-objcopy
1012
RM = rm -f
1113
ASMZ80 = $(GENBIN)/sjasm
12-
BINTOS = $(GENBIN)/bintos
14+
BINTOS = $(SGDKBIN)/bintos
1315
RESCOMP= java -jar ./bin/rescomp.jar
1416

1517
OPTION= -Dnologo_
@@ -30,13 +32,7 @@ INCS = -Iinc -Ires
3032
FLAGS = $(OPTION) -m68000 -Wall -O1 -c -fomit-frame-pointer $(INCS)
3133
FLAGSZ80 = -isrc -iinc
3234

33-
all: appack $(libmd.a_OBJS) libmd.a
34-
35-
appack:
36-
echo -n "osBits="> tools/appack/makefile.vars
37-
getconf LONG_BIT >> tools/appack/makefile.vars
38-
cd tools/appack/ && make -f makefile.elf
39-
cp tools/appack/appack bin/
35+
all: $(libmd.a_OBJS) libmd.a
4036

4137
%.a: $(libmd.a_OBJS)
4238
$(RM) $@
@@ -53,10 +49,13 @@ appack:
5349
$(CC) $(FLAGS) -c $< -o $@
5450

5551
%.o: %.s
56-
$(CC) $(FLAGS) -c $< -o $@
52+
$(CC) -x assembler-with-cpp -MMD $(FLAGS) -c $< -o $@
53+
54+
%.o: %.rs
55+
$(CC) -x assembler-with-cpp $(FLAGS_LIB) -c $*.rs -o $@
5756

58-
%.s: %.res
59-
$(RESCOMP) $< $@
57+
%.rs: %.res
58+
$(RESCOMP) $*.res $*.rs -dep $*.o
6059

6160
clean:
6261
#$(RM) -f z80_drv1.c z80_drv2.c
File renamed without changes.

0 commit comments

Comments
 (0)