Created
April 28, 2012 03:32
-
-
Save fuzzy/2515456 to your computer and use it in GitHub Desktop.
DMD (git) builds (supports multilib builds)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
run() { | |
${*} 1>>/tmp/log 2>>/tmp/log | |
} | |
case "$(uname -s)" in | |
Linux) NCPU=$(($(cat /proc/cpuinfo|grep MHz|wc -l)+1)) ;; | |
esac | |
if [ -z "${NCPU}" ]; then NCPU=1; fi | |
if [ ! -z "$(which gmake 2>/dev/null)" ]; then # Detect gmake if necessary | |
MK=$(which gmake) | |
else | |
MK=$(which make) | |
fi | |
OSl=$(uname -s|tr '[:lower:]' '[:upper:]') # Upper case os name | |
OSs=$(echo ${OSl}|tr '[:upper:]' '[:lower:]') # Lower case os name | |
PDIR=${PWD} # Set our parent directory | |
dir=dmd2-$(date +%m%d%y) ; mkdir -p $dir # Make our installdirs | |
mkdir -p ${dir}/{bin,include,lib,lib32} | |
mkdir -p ${dir}/include/d{32,64}/{druntime,phobos2} | |
buildit() { | |
for i in dmd druntime phobos; do # checkout and build our shit | |
echo " ${i}" | |
run "git clone git://github.com/D-Programming-Language/${i}.git ${i}" | |
cd ${i} | |
case "${i}" in | |
dmd) | |
cd src; run "${MK} -f posix.mak clean" | |
run "${MK} TARGET=$OSl MODEL=${BITS} -f posix.mak -j${NCPU}" | |
if [ ${MULTILIB} = 0 ]; then | |
cp dmd *gen ${PDIR}/${dir}/bin/; cd ${PDIR} | |
else | |
for itm in $(ls dmd *gen); do | |
cp ${itm} ${PDIR}/${dir}/bin/${itm}${BITS} | |
done | |
fi | |
;; | |
druntime) | |
run "${MK} -f posix.mak clean" | |
if [ ${MULTILIB} = 1 ]; then | |
run "${MK} OS=$OSs DMD=${PDIR}/${dir}/bin/dmd${BITS} MODEL=${BITS} -f posix.mak -j${NCPU}" | |
else | |
run "${MK} OS=$OSs DMD=${PDIR}/${dir}/bin/dmd MODEL=${BITS} -f posix.mak -j${NCPU}" | |
fi | |
if [ ${MULTILIB} = 1 ] && [ ${BITS} = 32 ]; then | |
cp ./lib/libdruntime-${OSs}${BITS}.a ${PDIR}/${dir}/lib32/ | |
else | |
cp ./lib/libdruntime-${OSs}${BITS}.a ${PDIR}/${dir}/lib/ | |
fi | |
cp -r ./import ${PDIR}/${dir}/include/d${BITS}/druntime/ ; cd ${PDIR} | |
;; | |
phobos) | |
run "${MK} -f posix.mak clean" | |
if [ ${MULTILIB} = 1 ]; then | |
run "${MK} OS=$OSs DMD=${PDIR}/${dir}/bin/dmd${BITS} MODEL=${BITS} -f posix.mak -j${NCPU}" | |
else | |
run "${MK} OS=$OSs DMD=${PDIR}/${dir}/bin/dmd MODEL=${BITS} -f posix.mak -j${NCPU}" | |
fi | |
if [ ${MULTILIB} = 1 ] && [ ${BITS} = 32 ]; then | |
cp -r ./generated/${OSs}/release/${BITS}/libphobos2.a ${PDIR}/${dir}/lib32/libphobos2.a | |
else | |
cp -r ./generated/${OSs}/release/${BITS}/libphobos2.a ${PDIR}/${dir}/lib/libphobos2.a | |
fi | |
cp -r ./*.d ./std ${PDIR}/${dir}/include/d${BITS}/phobos2/ ; cd ${PDIR} | |
;; | |
esac | |
cd ${PDIR} | |
done | |
} | |
if [ -d /lib64 ] || [ -d /usr/lib32 ]; then | |
MULTILIB=1;echo '===> 32bit';BITS=32;buildit;echo '===> 64bit';BITS=64;buildit | |
else | |
MULTILIB=0 | |
case "$(uname -m)" in # Determine 32 or 64 bit models | |
*86) BITS=32 ;; | |
*64) BITS=64 ;; | |
esac | |
buildit | |
fi | |
if [ ${MULTILIB} = 1 ]; then | |
echo | |
echo "In order for these to coexist, I have elected not to set the DFLAGS env variable." | |
echo "What I recommend is to set DFLAGS32 and DFLAGS64 to their proper and respective values," | |
echo 'so that you can issue a DFLAGS=${DFLAGSNN} statement with your build command as desired.' | |
echo | |
echo 'Examples of proper values would be:' | |
echo | |
echo "$ export DFLAGS32=-I${PDIR}/${dir}/include/d32/druntime -I${PDIR}/${dir}/include/d32/phobos2/" | |
echo "$ export DFLAGS64=-I${PDIR}/${dir}/include/d64/druntime -I${PDIR}/${dir}/include/d64/phobos2/" | |
echo | |
echo "Your LDFLAGS should include:" | |
echo "-L${PDIR}/${dir}/lib -L${PDIR}/${dir}/lib32" | |
echo | |
else | |
echo | |
echo "Export your DFLAGS environment variable to something like:" | |
echo "$ export DFLAGS=-I${PDIR}${dir}/include/d/druntime -I${PDIR}/${dir}/include/d/phobos2" | |
echo | |
echo "Your LDFLAGS should include:" | |
echo "-L${PDIR}/${dir}/lib" | |
echo | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment