5 # Name : build variable calculator
6 # Author : Chris Koeritz
10 # This script sets up all the variables needed by the HOOPLE system for
11 # building the source code. It can either be run as a bash script directly
14 # bash $FEISTY_MEOW_APEX/scripts/generator/build_variables.sh
16 # which will establish a new shell containing all the variables, or you can
17 # 'source' the script like so:
19 # build_vars=$FEISTY_MEOW_APEX/scripts/generator/build_variables.sh
20 # source $build_vars $build_vars
22 # to set all of the variables in your current shell. The full path is
23 # necessary in these commands to allow the script to easily find itself.
24 # The 'source' version needs to be fed the actual path to the script
25 # because bash 'source' commands cause the first parameter (called $0) to
26 # be set to just the path to bash itself.
29 # Copyright (c) 2004-$now By Author. This program is free software; you can
30 # redistribute it and/or modify it under the terms of the GNU General Public
31 # License as published by the Free Software Foundation; either version 2 of
32 # the License or (at your option) any later version. This is online at:
33 # http://www.fsf.org/copyleft/gpl.html
34 # Please send any updates to: fred@gruntose.com
37 # here is where we compute the locations for the build's pieces, based on
38 # where this script is located. we currently assume that the build scripts
39 # like this one are at the same height in the hierarchy as the clam scripts
40 # that are used in the bootstrapping process.
42 # get the most important bits first; the directory this script lives in and
49 # helpful build function zone.
51 source "$FEISTY_MEOW_SCRIPTS/core/functions.sh"
55 # outer check on whether this already was run or not.
56 if [ -z "$BUILD_VARS_LOADED" ]; then
58 echo build variables were not loaded so recalculating.
60 # perform some calculations to get the right paths from our parameters.
61 if [ ! -z "$PARM_1" ]; then
62 # use the first real parameter since this is probably the 'source' version.
63 export BUILD_SCRIPTS_PATH="$(dirname "$PARM_1")"
64 THIS_TOOL_NAME="$(basename "$PARM_1")"
66 # use the zeroth parameter, since we know nothing more about our name.
67 export BUILD_SCRIPTS_PATH="$(dirname "$PARM_0")"
68 THIS_TOOL_NAME="$(basename "$PARM_0")"
70 BUILD_SCRIPTS_PATH="$(cd $(echo $BUILD_SCRIPTS_PATH | tr '\\\\' '/' ); \pwd)"
72 # figure out the other paths based on where we found this script.
73 export BUILDING_HIERARCHY="$(echo "$BUILD_SCRIPTS_PATH" | sed -e 's/\(.*\)\/[^\/]*/\1/')"
74 export CLAM_SCRIPTS="$(cd $BUILD_SCRIPTS_PATH/../clam ; \pwd)"
75 # synonym to make other builds happy.
76 export BUILDER_PATH="$BUILDING_HIERARCHY"
78 # set some clam parameters for compilation. if the script can't guess the
79 # right configuration, then you will need to set them in the last 'else'
81 if [ ! -z "$IS_UNIX" ]; then export OPERATING_SYSTEM=UNIX;
82 elif [ ! -z "$IS_DOS" ]; then export OPERATING_SYSTEM=WIN32;
84 # the system is unknown, so we give up on guessing.
85 export OPERATING_SYSTEM=unknown
87 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then
88 echo "[OS is \"$OPERATING_SYSTEM\"]"
91 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then
92 echo "[FEISTY_MEOW_APEX is $FEISTY_MEOW_APEX]"
95 # set some extra variables that clam uses.
97 # CLAM_ON_UNIX or CLAM_ON_DOS might get defined here.
98 # we also can set OS_SUBCLASS if we detect darwin.
99 if [ $OPERATING_SYSTEM == UNIX ]; then
100 export CLAM_ON_UNIX=$(uname)
101 if [[ $CLAM_ON_UNIX =~ .*[Dd]arwin.* ]]; then
102 # pick the subclass now that we know this is darwin.
103 export CLAM_OS_SUBCLASS=darwin
105 elif [ $OPERATING_SYSTEM == WIN32 ]; then
106 export CLAM_ON_DOS=$(uname)
108 echo "Unknown operating system--clam will not build well here."
111 # CLAM_BASE_CPU is a flag that distinguishes the type of processor, if necessary.
112 export CLAM_BASE_CPU="$(machine 2>/dev/null || arch 2>/dev/null || uname -m 2>/dev/null || echo i686)"
114 # "FEISTY_MEOW_CPP_HEADERS" are folders where our C and C++ header files can be found.
115 # we'll compute the set of folders as best we can below.
116 if [ -d "$FEISTY_MEOW_APEX/nucleus" ]; then
117 # just assumes we're at home and know our header locations under the feisty meow hierarchy.
118 export LOCUS_LIBRARY_HEADERS="$FEISTY_MEOW_APEX/nucleus $FEISTY_MEOW_APEX/octopi $FEISTY_MEOW_APEX/graphiq"
120 export LOCUS_LIBRARY_HEADERS=
122 ####blech! maybe not needed now? was involved above. | tr "\\\\" / | sed -e "s/\([a-zA-Z]\):\/\([^ ]*\)/\/cygdrive\/\1\/\2/g" ')
123 export FEISTY_MEOW_CPP_HEADERS=$(find $LOCUS_LIBRARY_HEADERS -mindepth 1 -maxdepth 1 -type d | grep -v "\.settings" )
125 # the root name of the version file. This is currently irrelevant on
126 # non-windoze platforms.
127 export CLAM_VERSION_RC_ROOT=$(bash $CLAM_SCRIPTS/cpp/rc_name.sh)
129 # CLAM_COMPILER is the C/C++ compiler application that builds our code.
130 # The variable is mainly used within CLAM itself for determining the proper
133 if [ "$OPERATING_SYSTEM" == UNIX ]; then
134 if [ "$CLAM_OS_SUBCLASS" == darwin ]; then
135 CLAM_COMPILER=GNU_DARWIN
137 CLAM_COMPILER=GNU_LINUX
139 elif [ "$OPERATING_SYSTEM" == WIN32 ]; then
140 CLAM_COMPILER=GNU_WINDOWS
142 if [ -z "$CLAM_COMPILER" ]; then
143 # if we get into this case, we have no idea how to set the default compiler.
144 # so... pick a fun default.
145 CLAM_COMPILER=GNU_LINUX
148 # "CLAM_COMPILER_ROOT_DIR" is the top-level for the C++ compiler location.
149 # it is generally the top of the OS, although some variants may need this
150 # modified (e.g., gnu arm linux, but we haven't built on that in a bit).
151 export CLAM_COMPILER_ROOT_DIR="/"
153 # CLAM_COMPILER_VERSION specifies the version of the particular compiler we're using.
154 # this is sometimes needed to distinguish how the code is built or where headers/libraries are found.
155 export CLAM_COMPILER_VERSION=$(bash $CLAM_SCRIPTS/cpp/get_version.sh $CLAM_COMPILER $CLAM_COMPILER_ROOT_DIR )
157 # new BUILD_TOP variable points at the utter top-most level of any files
158 # in the building hierarchy.
159 export BUILD_TOP="$FEISTY_MEOW_APEX"
161 # the production directory is the location for all the scripts and setup
162 # code needed to produce the executables for feisty meow.
163 export PRODUCTION_STORE="$BUILD_TOP/production"
165 ## set up the top-level for all build creations and logs and such.
166 #export FEISTY_MEOW_GENERATED_STORE="$TMP/generated-feisty_meow"
167 #if [ ! -d "$FEISTY_MEOW_GENERATED_STORE" ]; then
168 # mkdir -p "$FEISTY_MEOW_GENERATED_STORE"
170 ## set up our effluent outsourcing valves.
171 #export TEMPORARIES_PILE="$FEISTY_MEOW_GENERATED_STORE/temporaries"
172 #if [ ! -d "$TEMPORARIES_PILE" ]; then
173 # mkdir -p "$TEMPORARIES_PILE"
176 # this variable points at a folder where we store the generated products of
177 # the build, such as the binaries and installer packages.
178 export RUNTIME_PATH="$FEISTY_MEOW_GENERATED_STORE/runtime"
179 if [ ! -d "$RUNTIME_PATH" ]; then
180 mkdir -p "$RUNTIME_PATH"
183 # we define a log file storage area that can be relied on by the build.
184 export FEISTY_MEOW_LOGS="$FEISTY_MEOW_GENERATED_STORE/logs"
185 if [ ! -d "$FEISTY_MEOW_LOGS" ]; then
186 mkdir -p "$FEISTY_MEOW_LOGS"
191 # debugging area where we say what we think we know.
193 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then
194 echo scripts: $BUILD_SCRIPTS_PATH
195 echo build tools hier: $BUILDING_HIERARCHY
196 echo this tool: $THIS_TOOL_NAME
197 echo repository: $FEISTY_MEOW_APEX
198 echo clam: $CLAM_SCRIPTS
203 # test out our computed variables to make sure they look right.
204 pushd / &>/dev/null # jump to the root so relative paths are caught.
206 # flag for whether any checks have failed.
209 # first the scripts directory; do we find this script there?
210 if [ ! -f "$BUILD_SCRIPTS_PATH/$THIS_TOOL_NAME" ]; then
211 echo "This script cannot locate the proper build folders. The crucial path"
212 echo "variable seems to be '$BUILD_SCRIPTS_PATH', which"
213 echo "does not seem to contain '$THIS_TOOL_NAME' (this"
214 echo "script's apparent name)."
218 # next the clam directory; is the main variables file present there?
219 if [ -z "$got_bad" -a ! -f "$CLAM_SCRIPTS/variables.def" ]; then
220 echo "The clam directory could not be located under our build tools hierarchy."
221 echo "Please examine the configuration and make sure that this script is in a"
222 echo "directory that resides at the same height as the 'clam' directory."
226 # now compute some more paths with a bit of "heuristics" for where we can
227 # find the source code.
228 export TOOL_SOURCES="$FEISTY_MEOW_APEX/nucleus/tools"
229 if [ -z "$got_bad" -a ! -d "$TOOL_SOURCES/dependency_tool" -o ! -d "$TOOL_SOURCES/clam_tools" ]; then
230 echo "This script cannot locate the tool source code folder. This is where the"
231 echo "dependency_tool and clam_tools folders are expected to be."
235 ############################
237 # we only run the rest of the script if we know we didn't have some kind of
238 # bad thing happen earlier.
239 if [ -z "$got_bad" ]; then
241 # where we store the binaries used for building the rest of the code base.
242 export CLAM_BINARIES="$RUNTIME_PATH/clam_bin"
243 # the final destination for the new binaries which provide the
244 # build with all the applications it needs to get going.
245 export TARGETS_STORE="$RUNTIME_PATH/binaries"
246 # targets directory is meaningful to clam, which will use it for output.
247 export INTERMEDIATE_STORE="$TARGETS_STORE"
248 # where we are building the applications before they get promoted.
250 #hmmm: could allow override on this if already set.
251 # calculate which build ini file to use.
252 export BUILD_PARAMETER_FILE="$PRODUCTION_STORE/feisty_meow_config.ini"
253 if [ ! -f "$BUILD_PARAMETER_FILE" ]; then
254 echo "Cannot find a useful build configuration file."
257 # pick the executable's file ending based on the platform.
258 if [ "$OPERATING_SYSTEM" == "UNIX" ]; then export EXE_ENDING=;
259 elif [ "$OPERATING_SYSTEM" == "WIN32" ]; then export EXE_ENDING=.exe;
261 echo "The OPERATING_SYSTEM variable is unset or unknown. Bailing out."
264 # we should have established our internal variables now, so let's try
266 export PATH=$(dos_to_unix_path $CLAM_BINARIES):$PATH
268 # load up the helper variables for visual studio on winders.
269 if [ "$OPERATING_SYSTEM" == "WIN32" ]; then
270 # moved back to the good path of using gcc, not visual studio.
272 #trying just unixy ones, since we're doing cygwin on doze.
273 export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$TARGETS_STORE"
275 export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$TARGETS_STORE"
278 popd &>/dev/null # checking is over, jump back to the starting point.
280 ############################
282 # at this point, all the build related variables should be valid.
284 if [ -z "$INCLUDED_FROM_BOOTSTRAP" \
285 -a -z "$PARM_1" ]; then
286 # we are running as a stand-alone script, so we stay resident with our
287 # current set of variables.
291 # sentinel that tells us this script was pulled in.
292 export BUILD_VARS_LOADED=true
296 fi # outer wrapper for already ran build vars check.
300 # hook clam into the compilation system.
301 # this always needs to be defined since functions aren't exported.
304 /usr/bin/make -I "$CLAM_SCRIPTS" $*