Skip to content

Commit

Permalink
Merge pull request #58 from kubilus1/sgdk_162
Browse files Browse the repository at this point in the history
Bump to sgdk 1.62.  Use original makelib.gen makefile to build lib (modified)
  • Loading branch information
kubilus1 authored Jun 5, 2021
2 parents dcd86cc + bc280a8 commit 2c891f2
Show file tree
Hide file tree
Showing 16 changed files with 119 additions and 170 deletions.
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ jobs:
command: make tools_build
- run:
name: build SGDK
command: make sgdk_build
command: |
export GENDEV=`pwd`/build
make sgdk_build sgdk_install
- run:
name: build samples
command: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ ENV PATH $GENDEV/bin:$PATH

WORKDIR /src

ENTRYPOINT make -f $GENDEV/sgdk/mkfiles/makefile.gen
ENTRYPOINT make -f $GENDEV/sgdk/mkfiles/Makefile.rom
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ PATH := $(BUILDDIR)/bin:$(PATH)
build: toolchain_build tools_build sgdk_build
echo "Done"

docker_build:
docker build -t gendev .

$(BUILDDIR):
mkdir -p $@

Expand All @@ -44,9 +47,6 @@ tools_build:
tools_clean:
cd tools && $(MAKE) tools_clean

sgdk_samples:
cd sgdk && $(MAKE) sample_clean samples

$(GENDEV):
if [ -w /opt ]; then \
mkdir -p $(GENDEV); \
Expand Down Expand Up @@ -82,11 +82,17 @@ dist/gendev_$(VER)_all.deb: pkg_build
cd dist && dpkg-deb -Zxz -z9 --build $(TOPDIR)/pkg_build .

sgdk_build:
cd sgdk && GENDEV=$(BUILDDIR) $(MAKE) install
cd sgdk && GENDEV=$(BUILDDIR) $(MAKE)

sgdk_install: $(GENDEV)
cd sgdk && $(MAKE) install

sgdk_clean:
- cd sgdk && $(MAKE) clean

sgdk_samples:
cd sgdk && $(MAKE) sample_clean samples

clean: tools_clean toolchain_clean sgdk_clean
-rm -rf $(BUILDDIR)
-rm -rf pkg_build
Expand Down
109 changes: 74 additions & 35 deletions sgdk/Makefile
Original file line number Diff line number Diff line change
@@ -1,59 +1,97 @@

# Locatin of gendev install
GENDEV?=/opt/gendev/
GENBIN=$(GENDEV)/bin
GENGCC_BIN=$(GENDEV)/bin
SGDKDIR=$(CURDIR)/SGDK

# Location of build and source
BUILDDIR?=$(CURDIR)/build
SGDKDIR=$(BUILDDIR)/sgdk
SAMPLESDIR=$(SGDKDIR)/sample

SGDKVER=v1.51
# Version of SGDK to build
SGDKVER=v1.62

# SGDK install location
SGDKINSTALLDIR=$(GENDEV)/sgdk$(SGDKVER)

all: tools $(SGDKDIR) $(SGDKDIR)/libmd.a
all: $(SGDKDIR) $(SGDKDIR)/lib/libmd.a tools

tools: $(SGDKDIR)
# Various tools needed to use SGDK
tools: $(SGDKDIR) $(SGDKINSTALLDIR)
cd $(SGDKDIR)/tools/bintos/src && \
gcc -o bintos bintos.c
cd $(SGDKDIR)/tools/sizebnd/src && \
gcc -o sizebnd sizebnd.c
cd $(SGDKDIR)/tools/xgmtool && \
$(MAKE) -f $(CURDIR)/mkfiles/Makefile.xgmtool
cd $(SGDKDIR)/tools/bintos/src && \
gcc -o bintos bintos.c && cp bintos $(GENDEV)/bin/.
cp bintos $(SGDKINSTALLDIR)/bin/.
cd $(SGDKDIR)/tools/sizebnd/src && \
gcc -o sizebnd sizebnd.c && cp sizebnd $(GENDEV)/bin/.
cp sizebnd $(SGDKINSTALLDIR)/bin/.
cd $(SGDKDIR)/tools/xgmtool && \
$(MAKE) -f ../../../files/Makefile.xgmtool && cp out/xgmtool $(GENDEV)/bin/.
cp $(SGDKDIR)/bin/*.jar $(GENDEV)/bin/.
cp out/xgmtool $(SGDKINSTALLDIR)/bin/.
cp $(SGDKDIR)/bin/*.jar $(SGDKINSTALLDIR)/bin/.


# Create a new patchfile based on the current SGDK checkout
patch: $(SGDKDIR)
cd $(SGDKDIR) && git diff . > ../files/sgdk_$(SGDKVER).diff
cd $(SGDKDIR) && git diff . > $(CURDIR)/patches/sgdk_$(SGDKVER).diff

# Update an SGDK checkout with the current versions patchfile
prep: $(SGDKDIR)
cd $(SGDKDIR) && patch -u -p1 -l < ../files/sgdk_$(SGDKVER).diff
cd $(SGDKDIR) && patch -u -p1 -l < $(CURDIR)/patches/sgdk_$(SGDKVER).diff

$(BUILDDIR):
mkdir -p $@

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

$(SGDKDIR)/libmd.a: prep
cp -rf ../tools/files/applib/lib $(SGDKDIR)/tools/appack
cd $(SGDKDIR) && ln -sf ../files/Makefile.sgdk_lib .
cd $(SGDKDIR) && $(MAKE) -f Makefile.sgdk_lib
$(SGDKDIR)/mkfiles: $(SGDKDIR)
mkdir -p $(SGDKDIR)/mkfiles
cp -f $(CURDIR)/mkfiles/makefile.vars $@/.
cp -f $(CURDIR)/mkfiles/Makefile.sgdk_lib $@/.
cp -f $(CURDIR)/mkfiles/Makefile.rom $@/.

$(SGDKDIR)/lib/libmd.a: $(SGDKDIR) $(SGDKDIR)/mkfiles tools
cd $(SGDKDIR) && SGDKDIR=$(SGDKDIR) $(MAKE) -f $(CURDIR)/mkfiles/Makefile.sgdk_lib
cp $(GENDEV)/lib/libgcc.a $(SGDKDIR)/lib/libgcc.a
mv $(SGDKDIR)/libmd.a $(SGDKDIR)/lib/libmd.a
@echo "Done building sgdk library"

$(SGDKINSTALLDIR):
mkdir -p $@
rm -f $(GENDEV)/sgdk
cd $(GENDEV) && ln -sf sgdk$(SGDKVER) sgdk
mkdir -p $@/src
mkdir -p $@/bin
mkdir -p $@/inc
mkdir -p $@/res
mkdir -p $@/lib
mkdir -p $@/mkfiles

install: tools $(SGDKDIR)/libmd.a $(SGDKINSTALLDIR)
install: $(SGDKDIR)/lib/libmd.a $(SGDKINSTALLDIR)
echo "Install"
mkdir -p $(GENDEV)/sgdk/src
mkdir -p $(GENDEV)/sgdk/inc
mkdir -p $(GENDEV)/sgdk/lib
mkdir -p $(GENDEV)/sgdk/res
mkdir -p $(GENDEV)/sgdk/mkfiles
cp $(SGDKDIR)/md.ld $(GENDEV)/sgdk/.
cp $(SGDKDIR)/inc/* $(GENDEV)/sgdk/inc/.
cp -r $(SGDKDIR)/src/boot $(GENDEV)/sgdk/src/.
cp -r $(SGDKDIR)/res/* $(GENDEV)/sgdk/res/.
cp $(GENDEV)/lib/libgcc.a $(GENDEV)/sgdk/lib/.
cp $(SGDKDIR)/libmd.a $(GENDEV)/sgdk/lib/.
cp $(SGDKDIR)/makefile.gen $(GENDEV)/sgdk/mkfiles/.
cp files/makefile.vars $(GENDEV)/sgdk/mkfiles/.
cp $(SGDKDIR)/tools/sizebnd/src/sizebnd $(GENDEV)/bin/
cp $(SGDKDIR)/md.ld $(SGDKINSTALLDIR)/.
cp $(SGDKDIR)/inc/* $(SGDKINSTALLDIR)/inc/.
cp -r $(SGDKDIR)/src/boot $(SGDKINSTALLDIR)/src/.
cp -r $(SGDKDIR)/res/* $(SGDKINSTALLDIR)/res/.
cp $(GENDEV)/lib/libgcc.a $(SGDKINSTALLDIR)/lib/.
cp $(SGDKDIR)/lib/libmd.a $(SGDKINSTALLDIR)/lib/.
cp $(SGDKDIR)/makefile.gen $(SGDKINSTALLDIR)/mkfiles/.
cp $(SGDKDIR)/mkfiles/* $(SGDKINSTALLDIR)/mkfiles/.
cp $(SGDKDIR)/tools/sizebnd/src/sizebnd $(SGDKINSTALLDIR)/bin/
cd $(SGDKINSTALLDIR)/bin && ln -sf ../../bin/m68k-elf-gcc gcc
cd $(SGDKINSTALLDIR)/bin && ln -sf ../../bin/m68k-elf-nm nm
cd $(SGDKINSTALLDIR)/bin && ln -sf ../../bin/m68k-elf-ld ld
cd $(SGDKINSTALLDIR)/bin && ln -sf ../../bin/m68k-elf-objcopy objcopy
cd $(SGDKINSTALLDIR)/bin && ln -sf ../../bin/sjasm sjasm


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

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

samples: $(SAMPLEROMS)
@echo "All samples built"

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

clean:
echo "Clean"
-rm -rf $(SGDKDIR)
-rm -rf $(BUILDDIR)
116 changes: 0 additions & 116 deletions sgdk/files/sgdk.ld

This file was deleted.

17 changes: 17 additions & 0 deletions sgdk/mkfiles/Makefile.rom
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Use this Makefile for most SGDK projects
#

GENDEV?=/opt/gendev
SGDKDIR?=$(GENDEV)/sgdk

# Set GDK before including default SGDK makefile
GDK=$(SGDKDIR)

include $(SGDKDIR)/mkfiles/makefile.gen

# Override shell variables
MKDIR=/bin/mkdir
RM=/bin/rm
CP=/bin/cp
SHELL=/bin/bash
23 changes: 11 additions & 12 deletions sgdk/files/Makefile.sgdk_lib → sgdk/mkfiles/Makefile.sgdk_lib
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
GENDEV?=/opt/toolchains/gen/
GENDEV?=/opt/gendev/
MAKE?=make
GENGCC_BIN=$(GENDEV)/bin
GENBIN=$(GENDEV)/bin
SGDKBIN=$(GENDEV)/sgdk/bin


CC = $(GENGCC_BIN)/m68k-elf-gcc
AR = $(GENGCC_BIN)/m68k-elf-ar
RANLIB = $(GENGCC_BIN)/m68k-elf-ranlib
OBJC = $(GENGCC_BIN)/m68k-elf-objcopy
RM = rm -f
ASMZ80 = $(GENBIN)/sjasm
BINTOS = $(GENBIN)/bintos
BINTOS = $(SGDKBIN)/bintos
RESCOMP= java -jar ./bin/rescomp.jar

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

all: appack $(libmd.a_OBJS) libmd.a

appack:
echo -n "osBits="> tools/appack/makefile.vars
getconf LONG_BIT >> tools/appack/makefile.vars
cd tools/appack/ && make -f makefile.elf
cp tools/appack/appack bin/
all: $(libmd.a_OBJS) libmd.a

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

%.o: %.s
$(CC) $(FLAGS) -c $< -o $@
$(CC) -x assembler-with-cpp -MMD $(FLAGS) -c $< -o $@

%.o: %.rs
$(CC) -x assembler-with-cpp $(FLAGS_LIB) -c $*.rs -o $@

%.s: %.res
$(RESCOMP) $< $@
%.rs: %.res
$(RESCOMP) $*.res $*.rs -dep $*.o

clean:
#$(RM) -f z80_drv1.c z80_drv2.c
Expand Down
File renamed without changes.
Loading

0 comments on commit 2c891f2

Please sign in to comment.