############################################################################### # # # Name : initial setup script for HOOPLE # # Author : Chris Koeritz # # # # Purpose: # # # # This script can bootstrap the HOOPLE libraries from a state where none # # of the required binaries are built yet. It will build makedep and # # version_stamper and plunk them into the bin directory. Then it will build # # the whole source tree (with optimization enabled) as a test of the code's # # overall health. If you want a more debuggable build, tune the build.ini # # file to take out optimization and turn on debugging. # # # ############################################################################### # Copyright (c) 2004-$now By Author. This program is free software; you can # # redistribute it and/or modify it under the terms of the GNU General Public # # License as published by the Free Software Foundation; either version 2 of # # the License or (at your option) any later version. This is online at: # # http://www.fsf.org/copyleft/gpl.html # # Please send any updates to: fred@gruntose.com # ############################################################################### # guess the current platform. IS_UNIX=`uname | grep -i linux` if [ -z "$IS_UNIX" ]; then IS_UNIX=`uname | grep -i unix`; fi IS_DOS=`uname | grep -i ming` if [ -z "$IS_DOS" ]; then IS_DOS=`uname | grep -i cygwin`; fi # set some clam parameters for compilation. if the script can't guess the # right configuration, then you will need to set them in the last 'else' # below. if [ ! -z "$IS_UNIX" ]; then echo "Using system type of: unix compatible." export OP_SYSTEM=UNIX export COMPILER=GNU_LINUX elif [ ! -z "$IS_DOS" ]; then echo "Using system type of: pc-dos/windoze." export OP_SYSTEM=WIN32 # export COMPILER=GNU_WIN32 export COMPILER=VISUAL_CPP else # this alternative is used when the system is unknown. change these # values as necessary. echo "Using system type of: \"unknown\"." export OP_SYSTEM=UNIX export COMPILER=GNU_LINUX fi echo "Current settings: OS=$OP_SYSTEM COMPILER=$COMPILER" # set a flag for this process so we can omit certain compilations as necessary. export BOOT_STRAPPING=true if [ -z "$REPOSITORY_DIR" ]; then echo "The REPOSITORY_DIR variable is not set; it must point at the top of the build." exit 2398 fi # fix the repository directory just in case it has backslashes. export REPOSITORY_DIR=`echo $REPOSITORY_DIR | tr '\\\\' '/' ` export TOP_DIR="$REPOSITORY_DIR" # we assume we are cranking up in the top of the build repository. #hmmm: maybe make that a command line parameter? # these default flags turn off unnecessary support when we're rebuilding the # minimal toolset needed for a successful build of hoople. declare -a BUILD_DEFAULTS=( "BOOT_STRAPPING=t" "OPTIMIZE=t" "DEBUG=" \ "REBUILD=t" ) # bootstrapping is always turned on for this particular script. # we also always optimize these builds and turn off the debug flag. # rebuild ensures that the new apps are made fresh: "REBUILD=t" # it can be turned off when the build bootstrapper is being tested. # noisy can be added to spew lots of text: "NOISY=t" # this can help with compilation issues by showing all the flags. function make_code { echo "make $* ${BUILD_DEFAULTS[@]}" make $* ${BUILD_DEFAULTS[@]} if [ $? != 0 ]; then echo "Failed to make on: $*" exit 2323 fi } # removes pcdos eol from any scripts. that assumes that the bootstrap script # itself isn't polluted with them. function strip_cr { ctrl_m=$'\015' for i in $*; do tempgrep=$TMP/tempgrep.$RANDOM grep -l "$ctrl_m" "$i" >$tempgrep if [ ! -z "`cat $tempgrep`" ]; then temp=$TMP/tempsed.$RANDOM sed -e "s/$ctrl_m$//" <$i >$temp mv -f $temp $i fi rm "$tempgrep" done } # the promote function moves a file from the exe directory into the build's bin # directory. it performs the copy step and makes the file executable. the original # name should just be the root of the filename without any extension. if [ "$OP_SYSTEM" = "UNIX" ]; then export EXE_ENDING= function promote { if [ ! -f exe/$1 ]; then echo "Failed to build the application $1--quitting now." exit 1892 fi cp exe/$1 bin/$1 strip bin/$1 chmod 755 bin/$1 } elif [ "$OP_SYSTEM" = "WIN32" ]; then export EXE_ENDING=.exe function promote { if [ ! -f exe/$1.exe ]; then echo "Failed to build the application $1.exe--quitting now." exit 1892 fi cp exe/$1.exe bin chmod 755 bin/$1.exe } else echo "The operating system variable OP_SYSTEM is unset. Bailing out." exit 1822 fi ############################################################################ # start the actual build process now. cd $TOP_DIR # clean out any current contents. bash $REPOSITORY_DIR/bin/whack_build.sh if [ ! -z "$YETI_DIR" ]; then # make sure we correct any dos-style slashes before using the variable. export YETI_DIR=`echo $YETI_DIR | tr '\\\\' '/' ` else # yeti dir wasn't set, so we'll try the default. export YETI_DIR="$REPOSITORY_DIR" fi # set some crucial variables that hook clam into the compilation system. export CLAM_DIR= if [ ! -z "$YETI_DIR" ]; then export CLAM_DIR="$YETI_DIR/clam" fi if [ ! -d "$CLAM_DIR" ]; then CLAM_DIR="$TOP_DIR/clam" fi export MAKEFLAGS="-I $CLAM_DIR" if [ ! -d "$CLAM_DIR" -o ! -d "$TOP_DIR/bin" -o ! -d "$TOP_DIR/source" ]; then echo "There is a problem; the clam or bin or source directories are missing." echo "You are currently in $TOP_DIR." echo " CLAM_DIR=$CLAM_DIR" echo " bin directory is $TOP_DIR/bin" echo " source directory is $TOP_DIR/source" echo "Please make sure that you're in the top-level directory of HOOPLE." exit 2323 fi # make sure the clam scripts don't have yucky PC end-of-line characters. echo about to strip files and set permissions... ###strip_cr $CLAM_DIR/*.sh $CLAM_DIR/cpp/*.sh # make the clam shell scripts executable. chmod 755 $CLAM_DIR/*.sh chmod 755 $CLAM_DIR/cpp/*.sh chmod 755 $CLAM_DIR/csharp/*.sh # make sure files are writable as needed. find . -iname "*.ini" -exec chmod 644 {} ';' # rebuild the dependency tool. needed by everything, pretty much, but # since it's from the xfree project, it doesn't need any of our libraries. cd source/app_src/dependency_tool make_code pre_compilation NO_DEPS=t OMIT_VERSIONS=t make_code NO_DEPS=t OMIT_VERSIONS=t cd $TOP_DIR if [ ! -f exe/makedep$EXE_ENDING ]; then echo "" echo "" echo "The build of the makedep tool has failed. Unknown causes... Argh." echo "" exit 1820 fi # make the tool available for the rest of the build. promote makedep # rebuild the version tool. so far this is a NOP for linux/unix, since i # don't know the version structures stuff yet. but it shuts up a bunch # of make errors if the tool is available. cd $TOP_DIR cd source/app_src/utilities make_code pre_compilation OMIT_VERSIONS=t make_code OMIT_VERSIONS=t cd $TOP_DIR if [ ! -f exe/version_stamper$EXE_ENDING ]; then echo "" echo "" echo "The build of the version_stamper tool has failed. Unknown causes... Argh." echo "" exit 1821 fi cd $TOP_DIR # make the tools we just compiled available also. promote sleep_ms # sleep tool is used in some scripts. promote value_tagger # tool scrambles through headers to standardize outcomes. promote version_stamper # used for version stamping. promote vsts_version_fixer # used for version stamping. promote write_build_config # creates a header of build-specific config info. if [ "$OP_SYSTEM" = "WIN32" ]; then # these are only needed for win32. promote playsound # sound playback tool. promote zap_process # kills a process in the task list. promote short_path # provides short path names for exes on windows. fi cd $TOP_DIR # force version info to be created. rm source/lib_src/library/i_library/i_library_version.rc source/lib_src/communication/i_communication/i_communication_version.rc # force manifest to be rebuilt. rm manifest.txt echo The build binaries have been re-created. echo Cleaning up the temporary files from build binaries. bash $REPOSITORY_DIR/bin/whack_build.sh echo Now starting a normal build of the repository source code. unset BUILD_DEFAULTS declare -a BUILD_DEFAULTS=( "BOOT_STRAPPING=" "OPTIMIZE=t" "DEBUG=" \ "REBUILD=t" ) export NOT_SLIMLINE=true make_code