1
+
2
+ # Locatin of gendev install
1
3
GENDEV? =/opt/gendev/
2
4
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
5
9
SAMPLESDIR =$(SGDKDIR ) /sample
6
10
7
- SGDKVER =v1.51
11
+ # Version of SGDK to build
12
+ SGDKVER =v1.62
13
+
14
+ # SGDK install location
8
15
SGDKINSTALLDIR =$(GENDEV ) /sgdk$(SGDKVER )
9
16
10
- all : tools $(SGDKDIR ) $(SGDKDIR ) /libmd.a
17
+ all : $(SGDKDIR ) $(SGDKDIR ) /lib/ libmd.a tools
11
18
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
13
27
cd $(SGDKDIR ) /tools/bintos/src && \
14
- gcc -o bintos bintos.c && cp bintos $(GENDEV ) /bin/.
28
+ cp bintos $(SGDKINSTALLDIR ) /bin/.
15
29
cd $(SGDKDIR ) /tools/sizebnd/src && \
16
- gcc -o sizebnd sizebnd.c && cp sizebnd $(GENDEV ) /bin/.
30
+ cp sizebnd $(SGDKINSTALLDIR ) /bin/.
17
31
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/.
20
34
35
+
36
+ # Create a new patchfile based on the current SGDK checkout
21
37
patch : $(SGDKDIR )
22
- cd $(SGDKDIR ) && git diff . > ../files /sgdk_$(SGDKVER ) .diff
38
+ cd $(SGDKDIR ) && git diff . > $( CURDIR ) /patches /sgdk_$(SGDKVER ) .diff
23
39
40
+ # Update an SGDK checkout with the current versions patchfile
24
41
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 $@
26
46
47
+ # Checkout and prep SGDK for building
27
48
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
30
54
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"
35
66
36
67
$(SGDKINSTALLDIR ) :
37
68
mkdir -p $@
38
69
rm -f $(GENDEV ) /sgdk
39
70
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
40
77
41
- install : tools $(SGDKDIR ) /libmd.a $(SGDKINSTALLDIR )
78
+ install : $(SGDKDIR ) /lib /libmd.a $(SGDKINSTALLDIR )
42
79
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
+
57
95
58
96
SAMPLES =$(wildcard $(SAMPLESDIR ) /* /out)
59
97
SAMPLEROMS =$(addsuffix /rom.bin,$(SAMPLES ) )
@@ -64,15 +102,16 @@ sample_clean: $(CLEANSAMPLES)
64
102
@echo " Done cleaning samples"
65
103
66
104
$(CLEANSAMPLES ) :
67
- cd $@ /.. && $(MAKE ) -f $(SGDKDIR ) /makefile.gen clean
105
+ cd $@ /.. && $(MAKE ) -f $(CURDIR ) /mkfiles/Makefile.rom clean
68
106
69
107
samples : $(SAMPLEROMS )
70
108
@echo " All samples built"
71
109
72
- $(SAMPLEDIR ) /% /out/rom.bin :
110
+ $(SAMPLESDIR ) /% /out/rom.bin :
73
111
echo " ROM $@ "
74
- cd $@ /../../ && $( MAKE ) -f $(GENDEV ) /sgdk/ mkfiles/makefile.gen
112
+ cd $@ /../../ && GENDEV= $( GENDEV ) $( MAKE ) -f $(SGDKINSTALLDIR ) / mkfiles/Makefile.rom
75
113
76
114
clean :
77
115
echo " Clean"
78
116
-rm -rf $(SGDKDIR )
117
+ -rm -rf $(BUILDDIR )
0 commit comments