Skip to content

Commit

Permalink
Support FreeBSD.
Browse files Browse the repository at this point in the history
Based on patch from Arrigo Marchiori.
#11

Use gmake instead of make (that is: GNU Make instead of BSD Make).
Use the standard Clang compiler instead of the standard GCC.
Remove the --verbose option from the patch invocations inside
unpack-gcc.sh (BSD Patch does not support that option).

Also, change script shebang for FreeBSD :
/bin/bash -> /usr/bin/env bash
  • Loading branch information
andrewwutw committed Jan 26, 2016
1 parent 1c4a638 commit cec35c2
Show file tree
Hide file tree
Showing 10 changed files with 367 additions and 237 deletions.
10 changes: 6 additions & 4 deletions README.md
@@ -1,6 +1,6 @@
## Building DJGPP cross compiler on Windows, Mac OSX and Linux
## Building DJGPP cross compiler on Windows, Mac OSX, Linux and FreeBSD.

build-djgpp : Build DJGPP cross compiler and binutils on Windows (MinGW/Cygwin), Mac OSX and Linux
build-djgpp : Build DJGPP cross compiler and binutils on Windows (MinGW/Cygwin), Mac OSX, Linux and FreeBSD.

### Prebuilt binary files

Expand All @@ -15,12 +15,13 @@ Before running this script, you need to install these programs first :
* unzip
* bison
* flex
* make
* make (or gmake for FreeBSD)
* makeinfo
* patch
* zlib header/library
* curl (for Cygwin/OSX/Linux)
* curl (for Cygwin/OSX/Linux/FreeBSD)
* wget (for MinGW)
* bash (for FreeBSD)

Depending on your system, installation procedure maybe different.

Expand Down Expand Up @@ -114,6 +115,7 @@ There are 2 methods to run the compiler (*BASE_DIR* is your DJGPP install locati
* OSX 10.10.4 / 10.9.5 / 10.8.5
* Debian 7 (32bit)
* Ubuntu 12 (64bit)
* FreeBSD-10.2 (64bit)
* Cygwin (32bit Windows XP)
* MinGW (32bit Windows XP)

Expand Down
2 changes: 1 addition & 1 deletion build-djgpp.sh
@@ -1,4 +1,4 @@
#! /bin/bash
#!/usr/bin/env bash

BUILD_VER=$1

Expand Down
74 changes: 45 additions & 29 deletions script/4.7.3
@@ -1,4 +1,4 @@
#! /bin/bash
#!/usr/bin/env bash

unset CDPATH

Expand All @@ -25,6 +25,18 @@ MPC_VERSION=1.0
AUTOCONF_VERSION=2.64
AUTOMAKE_VERSION=1.11.1

CC=gcc
CXX=g++

# use gmake under FreeBSD
if [ `uname` = "FreeBSD" ]; then
MAKE=gmake
export CC=clang
export CXX=clang++
else
MAKE=make
fi

# tarball location
BINUTILS_ARCHIVE="${DJGPP_DOWNLOAD_BASE}/djgpp/deleted/v2gnu/bnu${BINUTILS_VERSION}s.zip"
DJCRX_ARCHIVE="${DJGPP_DOWNLOAD_BASE}/djgpp/deleted/v2/djcrx${DJCRX_VERSION}.zip"
Expand All @@ -42,7 +54,7 @@ AUTOMAKE_ARCHIVE="http://ftp.gnu.org/gnu/automake/automake-${AUTOMAKE_VERSION}.t
PATCH_UNPACK_GCC_SH="patch-unpack-gcc.txt"

# check required programs
REQ_PROG_LIST="g++ gcc unzip bison flex make makeinfo patch"
REQ_PROG_LIST="${CXX} ${CC} unzip bison flex ${MAKE} makeinfo patch"

# MinGW doesn't have curl, so we use wget.
if uname|grep "^MINGW32" > /dev/null; then
Expand Down Expand Up @@ -74,7 +86,7 @@ else
fi

# check zlib is installed
if ! gcc test-zlib.c -o test-zlib -lz; then
if ! ${CC} test-zlib.c -o test-zlib -lz; then
echo "zlib not installed"
exit 1
fi
Expand Down Expand Up @@ -151,16 +163,16 @@ sh ./configure \
--disable-nls \
|| exit 1

make configure-bfd || exit 1
make -C bfd stmp-lcoff-h || exit 1
make || exit 1
${MAKE} configure-bfd || exit 1
${MAKE} -C bfd stmp-lcoff-h || exit 1
${MAKE} || exit 1

if [ ! -z $MAKE_CHECK ]; then
echo "Run make check"
make check || exit 1
echo "Run ${MAKE} check"
${MAKE} check || exit 1
fi

make install || exit 1
${MAKE} install || exit 1

cd ../../..
# binutils done
Expand All @@ -172,8 +184,8 @@ cd djcrx${DJCRX_VERSION}
unzip ../../download/djcrx${DJCRX_VERSION}.zip || exit 1

cd src/stub
gcc -O2 stubify.c -o stubify || exit 1
gcc -O2 stubedit.c -o stubedit || exit 1
${CC} -O2 stubify.c -o stubify || exit 1
${CC} -O2 stubedit.c -o stubedit || exit 1

cd ../..

Expand All @@ -193,7 +205,7 @@ cd djlsr${DJLSR_VERSION}
unzip ../../download/djlsr${DJLSR_VERSION}.zip || exit 1
cd src/stub
patch exe2coff.c ../../../../patch-exe2coff-205.txt || exit 1
gcc -o exe2coff exe2coff.c || exit 1
${CC} -o exe2coff exe2coff.c || exit 1
cp -p exe2coff $DJGPP_PREFIX/i586-pc-msdosdjgpp/bin/ || exit 1
cd ../../..
# djlsr done
Expand All @@ -209,7 +221,7 @@ cd $BUILDDIR
tar xjf ../../download/autoconf-${AUTOCONF_VERSION}.tar.bz2 || exit 1
cd autoconf-${AUTOCONF_VERSION}/
./configure --prefix=$BUILDDIR/tmpinst || exit 1
make all install || exit 1
${MAKE} all install || exit 1

echo "Building automake"
cd $BUILDDIR
Expand All @@ -218,7 +230,7 @@ cd automake-${AUTOMAKE_VERSION}/
PATH="$BUILDDIR//tmpinst/bin:$PATH" \
./configure --prefix=$BUILDDIR/tmpinst || exit 1
PATH="$BUILDDIR//tmpinst/bin:$PATH" \
make all install || exit 1
${MAKE} all install || exit 1

# build GNU sed if needed.
if [ ! -z $SED_VERSION ]; then
Expand All @@ -227,7 +239,7 @@ if [ ! -z $SED_VERSION ]; then
tar xjf ../../download/sed-${SED_VERSION}.tar.bz2 || exit 1
cd sed-${SED_VERSION}/
./configure --prefix=$BUILDDIR/tmpinst || exit 1
make all install || exit 1
${MAKE} all install || exit 1
fi

cd $BUILDDIR
Expand All @@ -238,6 +250,10 @@ tar xzf ../../download/mpc-${MPC_VERSION}.tar.gz || exit 1
if [ ! -z $PATCH_UNPACK_GCC_SH ]; then
echo "Patch unpack-gcc.sh"
patch unpack-gcc.sh ../../${PATCH_UNPACK_GCC_SH} || exit 1
if [ `uname` = "FreeBSD" ]; then
# The --verbose option is not recognized by BSD patch
sed -i '.bsd.back' 's/patch --verbose/patch/' unpack-gcc.sh
fi
fi

echo "Running unpack-gcc.sh"
Expand All @@ -249,32 +265,32 @@ cp $DJGPP_PREFIX/i586-pc-msdosdjgpp/bin/stubify $BUILDDIR/tmpinst/bin
echo "Building gmp"
cd $BUILDDIR/gmp-${GMP_VERSION}/
./configure --prefix=$BUILDDIR/tmpinst --enable-static --disable-shared || exit 1
make all || exit 1
${MAKE} all || exit 1
if [ ! -z $MAKE_CHECK ]; then
echo "Run make check"
make check || exit 1
echo "Run ${MAKE} check"
${MAKE} check || exit 1
fi
make install || exit 1
${MAKE} install || exit 1

echo "Building mpfr"
cd $BUILDDIR/mpfr-${MPFR_VERSION}/
./configure --prefix=$BUILDDIR/tmpinst --with-gmp-build=$BUILDDIR/gmp-${GMP_VERSION} --enable-static --disable-shared || exit 1
make all || exit 1
${MAKE} all || exit 1
if [ ! -z $MAKE_CHECK ]; then
echo "Run make check"
make check || exit 1
echo "Run ${MAKE} check"
${MAKE} check || exit 1
fi
make install || exit 1
${MAKE} install || exit 1

echo "Building mpc"
cd $BUILDDIR/mpc-${MPC_VERSION}/
./configure --prefix=$BUILDDIR/tmpinst --with-gmp=$BUILDDIR/tmpinst --with-mpfr=$BUILDDIR/tmpinst --enable-static --disable-shared || exit 1
make all || exit 1
${MAKE} all || exit 1
if [ ! -z $MAKE_CHECK ]; then
echo "Run make check"
make check || exit 1
echo "Run ${MAKE} check"
${MAKE} check || exit 1
fi
make install || exit 1
${MAKE} install || exit 1

echo "Building gcc"
cd $BUILDDIR/
Expand All @@ -297,9 +313,9 @@ PATH="$BUILDDIR//tmpinst/bin:$PATH" \
--enable-languages=${ENABLE_LANGUAGES} \
|| exit 1

make j=4 "PATH=$BUILDDIR/tmpinst/bin:$PATH" || exit 1
${MAKE} j=4 "PATH=$BUILDDIR/tmpinst/bin:$PATH" || exit 1

make install || exit 1
${MAKE} install || exit 1

echo "Copy long name executables to short name."
(
Expand Down

0 comments on commit cec35c2

Please sign in to comment.