Skip to content

Commit

Permalink
Makefile modifications to allow build on FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
edenist committed Feb 19, 2018
1 parent b57b872 commit 5326c28
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 16 deletions.
15 changes: 8 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
SUDO?= sudo
MGET?= wget
MAKE?= make

ORIG_USER:=$(shell whoami)

BUILDDIR?=$(CURDIR)/build
Expand All @@ -22,19 +23,19 @@ $(BUILDDIR):
mkdir -p $@

toolchain_build:
cd toolchain && make toolchain_build
cd toolchain && $(MAKE) toolchain_build

toolchain_clean:
cd toolchain && make toolchain_clean
cd toolchain && $(MAKE) toolchain_clean

tools_build:
cd tools && make tools_build
cd tools && $(MAKE) tools_build

tools_clean:
cd tools && make tools_clean
cd tools && $(MAKE) tools_clean

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

install:
if [ -w /opt ]; then \
Expand Down Expand Up @@ -69,10 +70,10 @@ 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) install

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

clean: tools_clean toolchain_clean sgdk_clean
-rm -rf $(BUILDDIR)
Expand Down
41 changes: 41 additions & 0 deletions doc/FreeBSD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Build **gendev** for FreeBSD

## Install Dependencies

*Note: This guide is tested for FreeBSD 11.1-RELEASE*

From the root shell, run the following commands:

pkg install git gmake texinfo gcc openjdk-jre-7.151.01,1 wget

Type 'y' and hit enter to proceed with installing the packages.

## Build the toolchain

Next, clone the repository and build the toolchain. [This may take some time to complete]

git clone https://github.com/edenist/gendev.git
cd gendev
MAKE=gmake gmake

The built toolchain and SGDK can now be installed.

## Install Gendev

Gendev is installed to $GENDEV [/opt/gendev] by default. While generally not 100% in line with FreeBSD's hier policy, it doesn't cause any interference so I would recommend using this to maintain compatability.
Make sure that this directory is writable by the user.

Now install to $GENDEV

gmake install

## Build some sample code [or your project!]

You can test your new installation by building some sample code. This is also useful as a project template.

cd ~/ (or some other directory)
cp -r gendev/sgdk/SGDK/sample/cube_flat ./
cd cube_flat
gmake -f $GENDEV/sgdk/mkfiles/makefile.gen clean all

If everything builds correctly, you should end up with a file out/rom.bin with a size of 131072 bytes. You can run this file in an emulator of choice to confirm your builds are correct.
8 changes: 4 additions & 4 deletions sgdk/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ tools: $(SGDKDIR)
cd $(SGDKDIR)/tools/wavtoraw/src && \
gcc -o wavtoraw wavtoraw.c -lm && cp wavtoraw $(GENDEV)/bin/.
cd $(SGDKDIR)/tools/xgmtool && \
make -f ../../../files/Makefile.xgmtool && cp out/xgmtool $(GENDEV)/bin/.
$(MAKE) -f ../../../files/Makefile.xgmtool && cp out/xgmtool $(GENDEV)/bin/.
cd $(SGDKDIR)/tools/rescomp && \
make -f ../../../files/Makefile.rescomp && cp out/rescomp $(GENDEV)/bin/.
$(MAKE) -f ../../../files/Makefile.rescomp && cp out/rescomp $(GENDEV)/bin/.
#patch -u -p0 < ../../../files/rescomp.diff && \
#
cp $(SGDKDIR)/bin/lz4w.jar $(GENDEV)/bin/.
Expand Down Expand Up @@ -75,14 +75,14 @@ sample_clean: $(CLEANSAMPLES)
@echo "Done cleaning samples"

$(CLEANSAMPLES):
cd $@/.. && make -f $(GENDEV)/sgdk/mkfiles/makefile.gen clean
cd $@/.. && $(MAKE) -f $(GENDEV)/sgdk/mkfiles/makefile.gen clean

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

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

clean:
echo "Clean"
Expand Down
8 changes: 4 additions & 4 deletions toolchain/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,27 @@ build-binutils: $(WORKDIR)/build-binutils
$(WORKDIR)/build-binutils:
mkdir -p $@
cd $@ && ../binutils-$(BINUTILS_VERSION)/configure --target=m68k-elf --prefix=$(BUILDDIR) --enable-install-libbfd --disable-werror
make -C $@ all install DESTDIR= > $(LOG)
$(MAKE) -C $@ all install DESTDIR= > $(LOG)

build-gcc-1: $(WORKDIR)/build-gcc
$(WORKDIR)/build-gcc:
cd $(WORKDIR)/gcc-$(GCC_VERSION) && patch -p1 -i $(FILESDIR)/gcc.patch
cd $(WORKDIR)/gcc-$(GCC_VERSION) && ./contrib/download_prerequisites
mkdir -p $@
cd $@ && ../gcc-$(GCC_VERSION)/configure --target=m68k-elf --prefix=$(BUILDDIR) --without-headers --with-newlib --enable-languages=c --disable-libssp --disable-tls --with-cpu=m68000 --disable-werror --disable-nls --disable-multilib
make -C $@ all install DESTDIR= > $(LOG)
$(MAKE) -C $@ all install DESTDIR= > $(LOG)

build-newlib: $(WORKDIR)/build-newlib
$(WORKDIR)/build-newlib:
find $(BUILDDIR) -name "m68k-elf-cc"
find $(WORKDIR) -name "m68k-elf-cc"
mkdir -p $@
cd $@ && ../newlib-$(NEWLIB_VERSION)/configure --target=m68k-elf --prefix=$(BUILDDIR) --with-cpu=m68000 --disable-werror
make -C $@ all install DESTDIR= $(LOG)
$(MAKE) -C $@ all install DESTDIR= $(LOG)

build-gcc-2:
cd $(WORKDIR)/build-gcc && ../gcc-$(GCC_VERSION)/configure --target=m68k-elf --prefix=$(BUILDDIR) --with-newlib --disable-libssp --disable-tls --enable-threads=single --enable-languages=c --with-cpu=m68000 --disable-werror --disable-nls --disable-multilib
make -C $(WORKDIR)/build-gcc all install DESTDIR= $(LOG)
$(MAKE) -C $(WORKDIR)/build-gcc all install DESTDIR= $(LOG)
cp $(BUILDDIR)/lib/gcc/m68k-elf/$(GCC_VERSION)/libgcc.a $(BUILDDIR)/lib/.

build-ldscripts: $(BUILDDIR)/ldscripts
Expand Down
2 changes: 1 addition & 1 deletion tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,5 @@ $(TOOLSDIR)/appack:
- mkdir -p $(WORKDIR)/applib
cp -r files/applib/* $(WORKDIR)/applib/.
cd $(WORKDIR)/applib/example && \
make -f makefile.elf && \
$(MAKE) -f makefile.elf && \
cp appack $@
Binary file modified tools/files/sjasm39g6.zip
Binary file not shown.

0 comments on commit 5326c28

Please sign in to comment.