Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # Build script for several Lazarus and Freepascal versions.
- # @version $Id: laz_fpc_build.sh | Sat Jul 22 19:42:24 2017 +0000 | Thierry Bothorel $
- # USE :
- # Build groups must start with number 1 (no 0) without gaps between groups numbers.
- # ************ Common parameters for all builds ************
- # BASEDRV= # Root base directory (usually your home directory), ie. ~
- # FPCBASEDIR= # root of freepascal fields (builds ans sources), ie. $BASEDRV/Sys/local/opt/fpc
- # LOGDIR= # logs directory, ie. $BASEDRV/Sys/Logs
- # ************** GROUP ****************
- # GROUPNAME[x]= # Name of you build, ie. GROUPNAME[1]="Lazarus fixes"
- # FPC parameters
- # FPCNEWVERSION[x]= # Freepascal version to build and to be used to build Lazarus, ie. =2.6.1
- # FPCOLDVERSION[x]= # Freepascal version used to build freepascal (i.e 2.4.5)
- # SRCDIR[x]= # Freepascal new version build directory, ie. $FPCBASEDIR/fpsrc/${FPCNEWVERSION[x]}
- # PPCNAME[x]= # Freepascal binary name (depends on architecture=, ie. ppcx64
- # FPCSTART[x]= # Absolute freepascal binary path used to build the ne one, ie.
- # $BASEDRV/Sys/local/opt/fpc/${FPCOLDVERSION[x]}/bin/${PPCNAME[x]}
- # /usr/bin/$PPCNAME
- # INSTALLDIR[x]= # Directory used to build the new Freepascal version, ie. $FPCBASEDIR/${FPCNEWVERSION[x]}
- # some random opts.
- # OPTS[x]= # Option to build freepascal, ie. -g- , -gl -dSAX_HTML_DEBUG -dUSE_MINGW_GDB
- # COMMONOPTS[x]=
- # COMMONOPTS[x]=UPXPROG=echo COPYTREE=echo OPT="${OPTS[x]}" GINSTALL=myinst.exe
- #
- # Some explanations:
- #
- # UPXPROG=echo -> makes upxing a non-op. It is not needed in general with
- # terabyte HDs on sale.
- # UPXPROG=echo avoids UPXing of the resulting binaries, so that the FPC binaries
- # can be debugged. If you want as small FPC bins as possible, leave it away,
- # and add SMART=1 to both make lines. Note that UPXing wastes memory
- # that is more expensive than disk.
- #
- # COPYTREE=echo -> during install some example trees are recursively copied.
- # this fails on SVN dirs. This omits those copies at the expense of no
- # installed examples (you can still do that once in a while by exporting the
- # source first, since the problem is in the SVN dirs).
- #
- # INSTALL_PREFIX=d:\somedir -> directory where to put snapshot
- #
- # GINSTALL=vistin.exe -> vistin is "ginstall.exe" copied to vistin.exe. This
- # because Vista wants to UAC anything that is named "install" or "setup",
- # which doesn't work for console apps.
- #
- # The OPT= stuff is not fixed, but changes depending on my needs.
- # Lazarus variables
- # LAZSRCDIR[x]= # Lazarus directory, ie. $BASEDRV/Sys/local/opt/lazarus_fixes_0_9_30
- # OPTSLAZ[x]= # Lazarus build options, ie. "-g- -O2 -CX -XX" , "-g- -O2 -CX -XX -Xs" # Check as -Xs use to prevent build
- # LAZCONFDIR[x]= # Lazarus config dir, ie. $BASEDRV/.lazarus-stable/ . If you run several lazarus versions, you have to run
- # them with a different configuration directory with --pcp parameter (ie. --pcp=~/.lazarus-stable)
- # SUPCONFDIR[x]= # If you want to KEEP your configuration directory, you HAVE to set this to 0. If you want to start with a
- # clean build (like Lazarus trunk version), set it to 1
- # ************ Common parameters for all builds ************
- BASEDRV=~
- FPCBASEDIR=$BASEDRV/Sys/local/opt/fpc
- LOGDIR=$BASEDRV/Sys/Logs/Pascal
- # Type of my mainprocessor.
- MYINTEL=i686
- # the root of all, but using it is optional.
- CROSSTOOLSROOT=/home/thierrybo/freepascal/binutils/cross
- #CROSSTOOLSROOT=~/Sys/local/opt/fpc/cross
- CROSSTOOLSROOT=${CROSSTOOLSROOT%/}/
- # ************** FIRST GROUP ****************
- GROUPNAME[1]="Lazarus fixes"
- # FPC parameters
- FPCNEWVERSION[1]=3.0.3
- FPCOLDVERSION[1]=3.0.2
- SRCDIR[1]=$FPCBASEDIR/fpsrc/${FPCNEWVERSION[1]}
- PPCNAME[1]=ppcx64
- FPCSTART[1]=$BASEDRV/Sys/local/opt/fpc/${FPCOLDVERSION[1]}/bin/${PPCNAME[1]}
- INSTALLDIR[1]=$FPCBASEDIR/${FPCNEWVERSION[1]}
- # CROSS
- CROSSPPCNAME[1]=ppcross386
- CROSSPPCLINKNAME[1]=ppc386
- # OSes and CPUs
- #TARGETS_OS[1]="linux freebsd linux win32 go32v2 netbsd openbsd solaris darwin"
- TARGETS_OS[1]="linux win32"
- TARGETS_CPU[1]="i386"
- #TARGETS_CPU[1]="arm"
- # some random opts.
- OPTS[1]="-g- -CX -XXs -O2"
- COMMONOPTS[1]="UPXPROG=echo SMART=1"
- # Lazarus variables
- LAZSRCDIR[1]=$BASEDRV/Sys/local/opt/lazarus_fixes
- OPTSLAZ[1]="-g- -O2 -CX -XX"
- LAZCONFDIR[1]=$BASEDRV/.lazarus-stable/
- SUPCONFDIR[1]=0
- # ************** SECOND GROUP ****************
- GROUPNAME[2]="Lazarus SVN"
- # FPC parameters
- FPCNEWVERSION[2]=3.0.3
- FPCOLDVERSION[2]=3.0.2
- SRCDIR[2]=$FPCBASEDIR/fpsrc/${FPCNEWVERSION[2]}
- PPCNAME[2]=ppcx64
- FPCSTART[2]=$BASEDRV/Sys/local/opt/fpc/${FPCOLDVERSION[2]}/bin/${PPCNAME[2]}
- INSTALLDIR[2]=$FPCBASEDIR/${FPCNEWVERSION[2]}
- # CROSS
- CROSSPPCNAME[2]=ppcross386
- CROSSPPCLINKNAME[2]=ppc386
- # OSes and CPUs
- #TARGETS_OS[2]="linux freebsd linux win32 go32v2 netbsd openbsd solaris darwin"
- TARGETS_OS[2]=""
- TARGETS_CPU[2]=""
- #TARGETS_CPU[2]="arm"
- # some random opts.
- OPTS[2]="-g- -CX -XXs -O2"
- COMMONOPTS[2]="UPXPROG=echo SMART=1"
- # Lazarus variables
- LAZSRCDIR[2]=$BASEDRV/Sys/local/opt/lazarus_svn
- OPTSLAZ[2]=
- LAZCONFDIR[2]=$BASEDRV/.lazarus-svn/
- SUPCONFDIR[2]=1
- # ************** THIRD GROUP ****************
- GROUPNAME[3]="Lazarus AND FPC : SVN"
- # FPC parameters
- FPCNEWVERSION[3]=3.0.3
- FPCOLDVERSION[3]=3.0.2
- SRCDIR[3]=$FPCBASEDIR/fpsrc/${FPCNEWVERSION[3]}
- PPCNAME[3]=ppcx64
- FPCSTART[3]=$BASEDRV/Sys/local/opt/fpc/${FPCOLDVERSION[3]}/bin/${PPCNAME[3]}
- INSTALLDIR[3]=$FPCBASEDIR/${FPCNEWVERSION[3]}
- # CROSS
- CROSSPPCNAME[3]=ppcross386
- CROSSPPCLINKNAME[3]=ppc386
- # OSes and CPUs
- #TARGETS_OS[3]="linux freebsd linux win32 go32v2 netbsd openbsd solaris darwin"
- TARGETS_OS[3]=""
- TARGETS_CPU[3]=""
- #TARGETS_CPU[3]="arm"
- # some random opts.
- OPTS[3]="-gl"
- COMMONOPTS[3]="UPXPROG=echo"
- # Lazarus variables
- LAZSRCDIR[3]=$BASEDRV/Sys/local/opt/lazarus_svn_FPC_svn
- OPTSLAZ[3]=
- LAZCONFDIR[3]=$BASEDRV/.lazarus/
- SUPCONFDIR[3]=1
- # === invariant part ===
- ###########################################################################
- # don't edit below
- MYHOSTARCH=`uname -p | tr "[:upper:]" "[:lower:]"`
- MYHOSTOS=`uname -s | tr "[:upper:]" "[:lower:]"`
- echo HOST platform is ${MYHOSTARCH}-${MYHOSTOS}
- # ********** QUESTIONS *************
- echo "Which version to build?"
- len=${#GROUPNAME[*]}
- i=0
- while [ "$i" -lt "$len" ]
- do
- CHOICES="${CHOICES} ${GROUPNAME[$i+1]},"
- let "i = $i + 1"
- done
- IFS=',' # New IFS
- LIST=(${CHOICES[@]}) # available choices list
- select CHOICE in "${LIST[@]}" ; do
- case $REPLY in
- 0|1|2|3|4|5|6|7|8|9)
- i=$REPLY
- break
- ;;
- esac
- done
- unset IFS # set IFS back ti default
- echo "Subversion update working copy Yes/NO"
- LIST=("[y] yes" "[n] no") # available choices list
- select CHOICE in "${LIST[@]}" ; do
- case $REPLY in
- 1|y)
- CHOICESVNUPDATE=1
- break
- ;;
- 2|n)
- CHOICESVNUPDATE=0
- break
- ;;
- esac
- done
- echo "Build FPC ${FPCNEWVERSION[$i]} Yes/NO"
- LIST=("[y] yes" "[n] no") # available choices list
- select CHOICE in "${LIST[@]}" ; do
- case $REPLY in
- 1|y)
- BUILDFPC=1
- break
- ;;
- 2|n)
- BUILDFPC=0
- break
- ;;
- esac
- done
- echo "Build ${GROUPNAME[$i]} ? YES/No"
- LIST=("[y] yes" "[n] no") # available choices list
- select CHOICE in "${LIST[@]}" ; do
- case $REPLY in
- 1|y)
- BUILDLAZARUS=1
- break
- ;;
- 2|n)
- BUILDLAZARUS=0
- break
- ;;
- esac
- done
- if [[ "$BUILDLAZARUS" == 1 ]]
- then
- echo "Build Lazarus with LAZBUILD instead of MAKE (not for an new svn checkout) ? Yes/No"
- LIST=("[y] yes" "[n] no") # available choices list
- select CHOICE in "${LIST[@]}" ; do
- case $REPLY in
- 1|y)
- BUILDLAZARUSWITHLAZBUILD=1
- break
- ;;
- 2|n)
- BUILDLAZARUSWITHLAZBUILD=0
- break
- ;;
- esac
- done
- fi
- # ************* START BUILDS ***********************
- # add fpcres to path, allowing to build FPC 2.6.1 and later, avoiding :
- # make[3]: entrant dans le répertoire « /home/thierrybo/Sys/local/opt/fpc/fpsrc/2.6.1/utils/fpcmkcfg »
- # /bin/mkdir -p units/x86_64-linux
- # __missing_command_DATA2INC -b -s fppkg.cfg fppkg.inc fppkg
- # make[3]: __missing_command_DATA2INC : commande introuvable
- # make[3]: *** [fppkg.inc] Erreur 127
- ###############################################################
- export PATH=$PATH:$BASEDRV/Sys/local/opt/fpc/${FPCOLDVERSION[$i]}/bin/
- # Previous logs deletion
- #rm -f ${LOGDIR}/fpc_build_log.txt
- #rm -f ${LOGDIR}/fpc_crossbuild_log.txt
- #rm -f ${LOGDIR}/fpc_install_log.txt
- #rm -f ${LOGDIR}/fpc_crossinstall_log.txt
- #rm -f ${LOGDIR}/laz_install_log.txt
- #rm -f ${LOGDIR}/outcome.txt
- #rm -f ${LOGDIR}/crossoutcome.txt
- rm -f ${LOGDIR}/*
- # FREEPASCAL
- if [[ "$BUILDFPC" = 1 ]]
- then
- cd $FPCBASEDIR/fpsrc/${FPCNEWVERSION[$i]}/
- make clean
- ###########################################################################
- # Boucle par CPU puis par OS pour make clean
- #
- for CPU in ${TARGETS_CPU[$i]}; do
- # CPU xlat. translate from FPC cpu designation to binutil's;
- MCPU=${CPU}
- if [ "${CPU}" = "i386" ]; then
- MCPU=${MYINTEL}
- fi
- for OS in ${TARGETS_OS[$i]}; do
- # xlat for OS
- MOS=${OS}
- if [ "${OS}" = "sunos" ]; then
- MOS=solaris
- fi
- if [ "${OS}" = "win32" ]; then
- MOS=mingw32
- fi
- if [ "${OS}" = "go32v2" ]; then
- MOS=msdosdjgpp
- fi
- dothisbuild=1
- if [ "${CPU}" = "${MYHOSTARCH}" ]; then
- if [ "${OS}" = "${MYHOSTOS}" ]; then
- dothisbuild=0
- fi
- fi
- if [ $dothisbuild -eq 1 ]; then
- make clean OS_TARGET=${OS} CPU_TARGET=${CPU}
- fi
- done;
- done;
- # FIN Boucle par CPU puis par OS pour make clean
- ###################################################################
- rm -f --recursive ${INSTALLDIR[$i]}/lib/
- rm -f --recursive ${INSTALLDIR[$i]}/share/
- rm -f --recursive ${INSTALLDIR[$i]}/bin/
- if [ $CHOICESVNUPDATE = 1 ] ; then
- svn up $FPCBASEDIR/fpsrc/${FPCNEWVERSION[$i]}
- fi
- make all ${COMMONOPTS[$i]} OPT="${OPTS[$i]}" PP=${FPCSTART[$i]} > ${LOGDIR}/fpc_build_log.txt 2>&1
- if [ ! $? = 0 ] ; then
- echo Grrr, failed again
- else
- make install ${COMMONOPTS[$i]} OPT="${OPTS[$i]}" INSTALL_PREFIX=${INSTALLDIR[$i]} PP=${SRCDIR[$i]}/compiler/${PPCNAME[$i]} > ${LOGDIR}/fpc_install_log.txt 2>&1
- if [ ! $? = 0 ] ; then
- echo INSTALL failed | tee -a ${LOGDIR}/outcome.txt
- else
- ln --symbolic ${INSTALLDIR[$i]}/lib/fpc/${FPCNEWVERSION[$i]}/${PPCNAME[$i]} ${INSTALLDIR[$i]}/bin/${PPCNAME[$i]}
- echo Everything _should_ be fine.| tee -a ${LOGDIR}/outcome.txt
- fi
- fi
- fi
- # CROSS FREEPASCAL
- if [[ "$BUILDFPC" = 1 ]]
- then
- ###########################################################################
- # Boucle par CPU puis par OS
- #
- for CPU in ${TARGETS_CPU[$i]}; do
- # CPU xlat. translate from FPC cpu designation to binutil's;
- MCPU=${CPU}
- if [ "${CPU}" = "i386" ]; then
- MCPU=${MYINTEL}
- fi
- for OS in ${TARGETS_OS[$i]}; do
- # xlat for OS
- MOS=${OS}
- if [ "${OS}" = "sunos" ]; then
- MOS=solaris
- fi
- if [ "${OS}" = "win32" ]; then
- MOS=mingw32
- fi
- if [ "${OS}" = "go32v2" ]; then
- MOS=msdosdjgpp
- fi
- dothisbuild=1
- if [ "${CPU}" = "${MYHOSTARCH}" ]; then
- if [ "${OS}" = "${MYHOSTOS}" ]; then
- dothisbuild=0
- fi
- fi
- ###################################################################
- if [ $dothisbuild -eq 1 ]; then
- cd $FPCBASEDIR/fpsrc/${FPCNEWVERSION[$i]}/
- ### 201603 : si je laisse make clean, cross compile ne va pas au bout
- #make clean OS_TARGET=${OS} CPU_TARGET=${CPU}
- # Ne pas supprimer le résultat de l'installation normale de freepascal juste avant !
- # rm -f --recursive ${INSTALLDIR[$i]}/lib/
- # rm -f --recursive ${INSTALLDIR[$i]}/share/
- # rm -f --recursive ${INSTALLDIR[$i]}/bin/
- # Pas besoin de Crossbindir ni Binutilsprefix pour linux-32bits, la simple
- # création manuelle des fichiers as et ar dans le wiki suffit. 201603 cross bindir
- # devrait marcher mais pas la création manuelle de as et ar
- make all OS_TARGET=${OS} CPU_TARGET=${CPU} BINUTILSPREFIX=${MCPU}-${MOS}- CROSSBINDIR=${CROSSTOOLSROOT}bin ${COMMONOPTS[$i]} OPT="${OPTS[$i]}" PP=${FPCSTART[$i]} > ${LOGDIR}/fpc_crossbuild_log_${OS}-${CPU}.txt 2>&1
- if [ ! $? = 0 ] ; then
- echo Grrr, failed CROSS ${OS}-${CPU} again
- else
- make crossinstall OS_TARGET=${OS} CPU_TARGET=${CPU} BINUTILSPREFIX=${MCPU}-${MOS}- CROSSBINDIR=${CROSSTOOLSROOT}bin ${COMMONOPTS[$i]} OPT="${OPTS[$i]}" INSTALL_PREFIX=${INSTALLDIR[$i]} PP=${SRCDIR[$i]}/compiler/${PPCNAME[$i]} > ${LOGDIR}/fpc_crossinstall_log-${OS}-${CPU}.txt 2>&1
- if [ ! $? = 0 ] ; then
- echo CROSS ${OS}-${CPU} INSTALL failed | tee -a ${LOGDIR}/crossoutcome.txt
- else
- ln --symbolic ${INSTALLDIR[$i]}/lib/fpc/${FPCNEWVERSION[$i]}/${CROSSPPCNAME[$i]} ${INSTALLDIR[$i]}/bin/${CROSSPPCLINKNAME[$i]}
- echo CROSS ${OS}-${CPU} Everything _should_ be fine.| tee -a ${LOGDIR}/crossoutcome.txt
- fi
- fi
- fi # if [ $dothisbuild -eq 1 ]; then
- #################################################### Fin boucle
- done; # for OS in $TARGETS_OS[$i]; do
- done; # for CPU in $TARGETS_CPU[$i]; do
- fi # if [[ "$BUILDFPC" = 1 ]]
- # LAZARUS +++++++++++++++++++++++++++++++
- if [[ "$BUILDLAZARUS" == 1 ]]
- then
- cd ${LAZSRCDIR[$i]}
- make clean
- rm -f --recursive ${LAZSRCDIR[$i]}/units
- if [ $CHOICESVNUPDATE = 1 ] ; then
- svn up ${LAZSRCDIR[$i]}
- fi
- if [[ "$BUILDLAZARUSWITHLAZBUILD" == 1 ]]
- then
- ./lazbuild --build-ide="${OPTSLAZ[$i]}" --build-mode= --primary-config-path="${LAZCONFDIR[$i]}" --secondary-config-path="${LAZCONFDIR[$i]}" > ${LOGDIR}/laz_install_log.txt 2>&1
- else
- make bigide OPT="${OPTSLAZ[$i]}" FPC=${INSTALLDIR[$i]}/bin/fpc INSTALL_PREFIX=${LAZSRCDIR[$i]} > ${LOGDIR}/laz_install_log.txt 2>&1
- fi
- if [ ! $? = 0 ] ; then
- echo Grrr, failed Lazarus
- else
- echo Lazarus Everything _should_ be fine
- if [[ "${SUPCONFDIR[$i]}" == 1 ]] ; then
- rm -f --recursive ${LAZCONFDIR[$i]}
- fi
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement