2 # Name : initial setup script for HOOPLE
3 # Author : Chris Koeritz
5 # This script can bootstrap the HOOPLE libraries from a state where none #
6 # of the required binaries are built yet. It will build the tools that the #
7 # CLAM system and HOOPLE need to get a build done. Then the script builds #
8 # the whole source tree as a test of the code's overall health. #
10 # Copyright (c) 2004-$now By Author. This program is free software; you can #
11 # redistribute it and/or modify it under the terms of the GNU General Public #
12 # License as published by the Free Software Foundation; either version 2 of #
13 # the License or (at your option) any later version. This is online at: #
14 # http://www.fsf.org/copyleft/gpl.html #
15 # Please send any updates to: fred@gruntose.com #
18 # prerequisites for this script:
20 # (1) the script should be run with a full path, so that it can decide where
21 # it lives with minimal fuss.
22 # (2) on windows, the msys bin directory should already be in the path so that
23 # tools like dirname are already available.
25 # make sure we know how to find our bash bins.
26 export PATH=/bin:$PATH
27 # signals that we're doing a fresh build to the variables script.
28 export INCLUDED_FROM_BOOTSTRAP=true
29 # pull in our build variables using the path to this script.
30 export BUILD_SCRIPTS_DIR="$( \cd "$(\dirname "$0")" && \pwd )"
31 echo build script initial from bootstrap: $BUILD_SCRIPTS_DIR
32 BUILD_SCRIPTS_DIR="$(echo $BUILD_SCRIPTS_DIR | tr '\\\\' '/' )"
33 echo build script after: $BUILD_SCRIPTS_DIR
34 # drop any previous version of the repository variable.
36 source "$BUILD_SCRIPTS_DIR/build_variables.sh" "$BUILD_SCRIPTS_DIR/build_variables.sh"
40 # creates the directory for our binaries and gives it a reasonable paths configuration.
41 function prepare_binaries_dir()
43 # we'll store binaries here from the bootstrap process.
44 if [ ! -d "$BINARY_DIR" ]; then
45 echo "creating binary dir now in $BINARY_DIR"
48 if [ ! -f "$BINARY_DIR/paths.ini" ]; then
49 echo "copied paths.ini to binary dir."
50 cp "$PRODUCTION_DIR/paths.ini" "$BINARY_DIR"
56 # turn off sounds to avoid running the sound player that's not been built yet.
57 unset CLAM_ERROR_SOUND
58 unset CLAM_FINISH_SOUND
62 echo "Build bootstrap process has started."
64 # preconditions for the build process...
68 # set a flag for this process so we can omit certain compilations as necessary.
69 export BOOT_STRAPPING=true
71 # enable this macro to get a much noisier build.
72 #export BE_NOISY=NOISY=t
76 # these default flags turn off unnecessary support when we're rebuilding the
77 # minimal toolset needed for a successful build of hoople.
78 declare -a BUILD_DEFAULTS=( "BOOT_STRAPPING=t" "OPTIMIZE=t" "REBUILD=t" "DEBUG=" )
79 # bootstrapping is always turned on for this particular script.
80 # we also always optimize these builds and turn off the debug flag.
81 # rebuild ensures that the new apps are made fresh: "REBUILD=t"
82 # it can be turned off when the build bootstrapper is being tested.
83 # noisy can be added to spew lots of text: "NOISY=t"
84 # this can help with compilation issues by showing all the flags.
87 make $* $BE_NOISY ${BUILD_DEFAULTS[@]}
89 echo "Failed to make on: $*"
94 # removes pcdos eol from any scripts. that assumes that the bootstrap script
95 # itself isn't polluted with them.
99 tempgrep="$(mktemp "$TEMPORARIES_DIR/tempgrep.XXXXXX")"
100 grep -l "$ctrl_m" "$i" >$tempgrep
101 if [ ! -z "$(cat $tempgrep)" ]; then
102 temp="$(mktemp "$TEMPORARIES_DIR/tempsed.XXXXXX")"
103 sed -e "s/$ctrl_m$//" <$i >$temp
110 # the promote function moves a file from the exe directory into the build's
111 # bin directory. it performs the copy step and makes the file executable.
112 # the original name should just be the root of the filename without any
114 # NOTE: this depends on the operating system having been chosen above!
115 if [ "$OPERATING_SYSTEM" = "UNIX" ]; then
119 if [ ! -f "$INTERMEDIATE_EXE_DIR/$1" ]; then
120 echo "Failed to build the application $1--quitting now."
123 cp "$INTERMEDIATE_EXE_DIR/$1" "$BINARY_DIR/$1"
124 strip "$BINARY_DIR/$1"
125 chmod 755 "$BINARY_DIR/$1"
127 elif [ "$OPERATING_SYSTEM" = "WIN32" ]; then
131 if [ ! -f "$INTERMEDIATE_EXE_DIR/$1.exe" ]; then
132 echo "Failed to build the application $1.exe--quitting now."
135 cp "$INTERMEDIATE_EXE_DIR/$1.exe" "$BINARY_DIR"
136 chmod 755 "$BINARY_DIR/$1.exe"
139 echo "The OPERATING_SYSTEM variable is unset or unknown. Bailing out."
145 # start the actual build process now...
147 # clean out any current contents.
148 bash "$BUILD_SCRIPTS_DIR/whack_build.sh" clean
150 # recreate our useful waste directories and other things...
151 source "$BUILD_SCRIPTS_DIR/build_variables.sh" "$BUILD_SCRIPTS_DIR/build_variables.sh"
153 toolset_names=(makedep value_tagger version_stamper vsts_version_fixer write_build_config short_path sleep_ms zap_process playsound create_guid)
155 if [ -z "$SAVE_BINARIES" ]; then
156 for i in ${toolset_names[*]}; do
157 whack_name="$BINARY_DIR/$i$EXE_ENDING"
158 #echo removing "$whack_name"
163 # make the clam shell scripts executable.
164 chmod 755 "$CLAM_DIR"/*.sh
165 chmod 755 "$CLAM_DIR"/cpp/*.sh
166 #chmod 755 "$CLAM_DIR"/csharp/*.sh
168 # rebuild the dependency tool. needed by everything, pretty much, but
169 # since it's from the xfree project, it doesn't need any of our libraries.
170 if [ ! -f "$BINARY_DIR/makedep$EXE_ENDING" ]; then
171 pushd "$TOOL_SOURCES/dependency_tool" &>/dev/null
172 make_code pre_compilation NO_DEPS=t OMIT_VERSIONS=t
173 make_code NO_DEPS=t OMIT_VERSIONS=t
174 if [ ! -f "$INTERMEDIATE_EXE_DIR/makedep$EXE_ENDING" ]; then
177 echo "The build of the makedep tool has failed. Unknown causes... Argh."
181 # make the tool available for the rest of the build.
186 # rebuild the version tools and other support apps.
187 if [ ! -f "$BINARY_DIR/value_tagger$EXE_ENDING" \
188 -o ! -f "$BINARY_DIR/version_stamper$EXE_ENDING" \
189 -o ! -f "$BINARY_DIR/vsts_version_fixer$EXE_ENDING" \
190 -o ! -f "$BINARY_DIR/write_build_config$EXE_ENDING" ]; then
191 pushd "$TOOL_SOURCES/clam_tools" &>/dev/null
192 make_code pre_compilation OMIT_VERSIONS=t
193 make_code OMIT_VERSIONS=t
195 #hmmm: really this should check all the expected apps.
196 # nice to just have an array of the things built by this guy.
197 if [ ! -f "$INTERMEDIATE_EXE_DIR/version_stamper$EXE_ENDING" ]; then
200 echo "The build of the version_stamper tool has failed. Unknown causes... Argh."
205 promote value_tagger # tool scrambles through headers to standardize outcomes.
206 promote version_stamper # used for version stamping.
207 promote vsts_version_fixer # used for version stamping.
208 promote write_build_config # creates a header of build-specific config info.
213 # build a few other utilities.
214 if [ ! -f "$BINARY_DIR/short_path$EXE_ENDING" \
215 -o ! -f "$BINARY_DIR/sleep_ms$EXE_ENDING" \
216 -o ! -f "$BINARY_DIR/create_guid$EXE_ENDING" \
217 -o ! -f "$BINARY_DIR/zap_process$EXE_ENDING" \
218 -o ! -f "$BINARY_DIR/playsound$EXE_ENDING" ]; then
219 pushd "$TOOL_SOURCES/simple_utilities" &>/dev/null
220 make_code pre_compilation OMIT_VERSIONS=t
221 make_code OMIT_VERSIONS=t
223 promote create_guid # globally unique ID creator.
224 promote playsound # sound playback tool.
225 promote short_path # provides short path names for exes on windows.
226 promote sleep_ms # sleep tool is used in some scripts.
227 promote zap_process # kills a process in the task list.
232 echo "The build binaries have been re-created (or were already present)."
234 # we won't do the full build if they told us to just do the bootstrap.
235 if [ -z "$JUST_BOOTSTRAP_APPS" ]; then
236 echo Cleaning up the temporary files that were built.
237 bash "$BUILD_SCRIPTS_DIR/whack_build.sh" clean
239 # recreate our useful junk directories...
240 mkdir -p "$WASTE_DIR"
241 mkdir -p "$TEMPORARIES_DIR"
243 echo Now starting a normal build of the repository source code.
244 pushd "$REPOSITORY_DIR" &>/dev/null
246 declare -a BUILD_DEFAULTS=( "BOOT_STRAPPING=" "OPTIMIZE=t" "DEBUG=t" "REBUILD=t" )
247 export NOT_SLIMLINE=true