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 unix tools bin directory should already be in the path
23 # so that tools like dirname are already available. use msys or cygwin
24 # at your discretion and your own risk.
26 # make sure we know how to find our bash bins.
27 export PATH=/bin:$PATH
29 # signals that we're doing a fresh build to the variables script.
30 export INCLUDED_FROM_BOOTSTRAP=true
32 # pull in our build variables using the path to this script.
33 export BUILD_SCRIPTS_DIR="$( \cd "$(\dirname "$0")" && /bin/pwd )"
34 #echo build scripts dir initial value: $BUILD_SCRIPTS_DIR
35 BUILD_SCRIPTS_DIR="$(echo $BUILD_SCRIPTS_DIR | tr '\\\\' '/' )"
36 #echo build scripts dir after chewing: $BUILD_SCRIPTS_DIR
38 # load in feisty meow basic scripts, if not already loaded.
39 if [ -z "$FEISTY_MEOW_SCRIPTS_LOADED" ]; then
40 bash "$BUILD_SCRIPTS_DIR/../core/reconfigure_feisty_meow.sh"
41 source "$BUILD_SCRIPTS_DIR/../core/launch_feisty_meow.sh"
44 source "$FEISTY_MEOW_SCRIPTS/core/functions.sh"
46 # translate to dos format if there's a cygdrive in there; otherwise microsoft's tools
47 # will hose up completely due to unknown paths.
48 export FEISTY_MEOW_APEX="$(unix_to_dos_path $FEISTY_MEOW_APEX)"
50 # load in build variables based on our deduced paths.
51 source "$BUILD_SCRIPTS_DIR/build_variables.sh" "$BUILD_SCRIPTS_DIR/build_variables.sh"
55 # creates the directory for our binaries and gives it a reasonable paths configuration.
56 function prepare_binaries_dir()
58 # we'll store binaries here from the bootstrap process.
59 if [ ! -d "$CLAM_BINARY_DIR" ]; then
60 echo "creating binary dir now in $CLAM_BINARY_DIR"
61 mkdir -p "$CLAM_BINARY_DIR"
63 if [ ! -f "$CLAM_BINARY_DIR/paths.ini" ]; then
64 echo "copied paths.ini to binary dir."
65 cp "$PRODUCTION_DIR/paths.ini" "$CLAM_BINARY_DIR"
71 # turn off sounds to avoid running the sound player that's not been built yet.
72 unset CLAM_ERROR_SOUND
73 unset CLAM_FINISH_SOUND
77 echo "Build bootstrap process has started."
79 # preconditions for the build process...
81 # set up our output directories etc.
84 # set a flag for this process so we can omit certain compilations as necessary.
85 export BOOT_STRAPPING=true
87 # enable this macro to get a much noisier build.
88 #export BE_NOISY=NOISY=t
92 # these default flags turn off unnecessary support when we're rebuilding the
93 # minimal toolset needed for a successful build of hoople.
94 declare -a BUILD_DEFAULTS=( "BOOT_STRAPPING=t" "OPTIMIZE=t" "REBUILD=t" "DEBUG=" )
95 # bootstrapping is always turned on for this particular script.
96 # we also always optimize these builds and turn off the debug flag.
97 # rebuild ensures that the new apps are made fresh: "REBUILD=t"
98 # it can be turned off when the build bootstrapper is being tested.
99 # noisy can be added to spew lots of text: "NOISY=t"
100 # this can help with compilation issues by showing all the flags.
103 make $* $BE_NOISY ${BUILD_DEFAULTS[@]}
105 echo "Failed to make on: $*"
110 # removes pcdos eol from any scripts. that assumes that the bootstrap script
111 # itself isn't polluted with them.
115 tempgrep="$(mktemp "$TEMPORARIES_DIR/tempgrep.XXXXXX")"
116 grep -l "$ctrl_m" "$i" >$tempgrep
117 if [ ! -z "$(cat $tempgrep)" ]; then
118 temp="$(mktemp "$TEMPORARIES_DIR/tempsed.XXXXXX")"
119 sed -e "s/$ctrl_m$//" <$i >$temp
126 # the promote function moves a file from the exe directory into the build's
127 # bin directory. it performs the copy step and makes the file executable.
128 # the original name should just be the root of the filename without any
130 # NOTE: this depends on the operating system having been chosen above!
131 if [ "$OPERATING_SYSTEM" = "UNIX" ]; then
135 if [ ! -f "$INTERMEDIATE_EXE_DIR/$1" ]; then
136 echo "Failed to build the application $1--quitting now."
139 cp "$INTERMEDIATE_EXE_DIR/$1" "$CLAM_BINARY_DIR/$1"
140 strip "$CLAM_BINARY_DIR/$1"
141 chmod 755 "$CLAM_BINARY_DIR/$1"
143 elif [ "$OPERATING_SYSTEM" = "WIN32" ]; then
147 if [ ! -f "$INTERMEDIATE_EXE_DIR/$1.exe" ]; then
148 echo "Failed to build the application $1.exe--quitting now."
151 cp "$INTERMEDIATE_EXE_DIR/$1.exe" "$CLAM_BINARY_DIR"
152 chmod 755 "$CLAM_BINARY_DIR/$1.exe"
155 echo "The OPERATING_SYSTEM variable is unset or unknown. Bailing out."
161 # start the actual build process now...
163 # load in the feisty meow building environment.
164 source "$BUILD_SCRIPTS_DIR/build_variables.sh" "$BUILD_SCRIPTS_DIR/build_variables.sh"
166 # clean out any current contents.
167 bash "$BUILD_SCRIPTS_DIR/whack_build.sh" clean
169 # make this again so no one gets cranky.
172 toolset_names=(makedep value_tagger version_stamper vsts_version_fixer write_build_config short_path sleep_ms zap_process playsound create_guid)
174 if [ -z "$SAVE_BINARIES" ]; then
175 for i in ${toolset_names[*]}; do
176 whack_name="$CLAM_BINARY_DIR/$i$EXE_ENDING"
177 #echo removing "$whack_name"
182 # make the clam shell scripts executable.
183 chmod 755 "$CLAM_DIR"/*.sh
184 chmod 755 "$CLAM_DIR"/cpp/*.sh
185 #chmod 755 "$CLAM_DIR"/csharp/*.sh
186 chmod 755 "$FEISTY_MEOW_SCRIPTS/generator/wrapdoze.sh"
188 # rebuild the dependency tool. needed by everything, pretty much, but
189 # since it's from the xfree project, it doesn't need any of our libraries.
190 if [ ! -f "$CLAM_BINARY_DIR/makedep$EXE_ENDING" ]; then
191 pushd "$TOOL_SOURCES/dependency_tool" &>/dev/null
192 make_code pre_compilation NO_DEPS=t OMIT_VERSIONS=t
193 make_code NO_DEPS=t OMIT_VERSIONS=t
194 if [ ! -f "$INTERMEDIATE_EXE_DIR/makedep$EXE_ENDING" ]; then
197 echo "The build of the makedep tool has failed. Unknown causes... Argh."
201 # make the tool available for the rest of the build.
206 # rebuild the version tools and other support apps.
207 if [ ! -f "$CLAM_BINARY_DIR/value_tagger$EXE_ENDING" \
208 -o ! -f "$CLAM_BINARY_DIR/version_stamper$EXE_ENDING" \
209 -o ! -f "$CLAM_BINARY_DIR/vsts_version_fixer$EXE_ENDING" \
210 -o ! -f "$CLAM_BINARY_DIR/write_build_config$EXE_ENDING" ]; then
211 pushd "$TOOL_SOURCES/clam_tools" &>/dev/null
212 make_code pre_compilation OMIT_VERSIONS=t
213 make_code OMIT_VERSIONS=t
215 #hmmm: really this should check all the expected apps.
216 # nice to just have an array of the things built by this guy.
217 if [ ! -f "$INTERMEDIATE_EXE_DIR/version_stamper$EXE_ENDING" ]; then
220 echo "The build of the version_stamper tool has failed. Unknown causes... Argh."
225 promote value_tagger # tool scrambles through headers to standardize outcomes.
226 promote version_stamper # used for version stamping.
227 promote vsts_version_fixer # used for version stamping.
228 promote write_build_config # creates a header of build-specific config info.
233 # build a few other utilities.
234 if [ ! -f "$CLAM_BINARY_DIR/short_path$EXE_ENDING" \
235 -o ! -f "$CLAM_BINARY_DIR/sleep_ms$EXE_ENDING" \
236 -o ! -f "$CLAM_BINARY_DIR/create_guid$EXE_ENDING" \
237 -o ! -f "$CLAM_BINARY_DIR/zap_process$EXE_ENDING" \
238 -o ! -f "$CLAM_BINARY_DIR/playsound$EXE_ENDING" ]; then
239 pushd "$TOOL_SOURCES/simple_utilities" &>/dev/null
240 make_code pre_compilation OMIT_VERSIONS=t
241 make_code OMIT_VERSIONS=t
243 promote create_guid # globally unique ID creator.
244 promote playsound # sound playback tool.
245 promote short_path # provides short path names for exes on windows.
246 promote sleep_ms # sleep tool is used in some scripts.
247 promote zap_process # kills a process in the task list.
252 echo "The build binaries have been re-created (or were already present)."
254 # we won't do the full build if they told us to just do the bootstrap.
255 if [ -z "$JUST_BOOTSTRAP_APPS" ]; then
256 echo Cleaning up the temporary files that were built.
257 bash "$BUILD_SCRIPTS_DIR/whack_build.sh" clean
259 # recreate our useful junk directories...
260 mkdir -p "$GENERATED_DIR"
261 mkdir -p "$TEMPORARIES_DIR"
264 echo Now starting a normal build of the repository source code.
265 pushd "$FEISTY_MEOW_APEX" &>/dev/null
267 declare -a BUILD_DEFAULTS=( "BOOT_STRAPPING=" "OPTIMIZE=t" "DEBUG=t" "REBUILD=t" )