3 ###########################################################################
4 ###########################################################################
7 # This tool is aimed to help Nevrax programmers to manage the
8 # compilation of a "debug" and a "release" version of NeL, NeLNS,
9 # and Snowballs2 (http://www.nevrax.org) based on the same source
10 # code and with the possibility to not having to re-compile everything
11 # each time the compilation mode (debug/release) change.
13 # This script is a simple wrapper around the 'autogen.sh'/'configure'
14 # commands ('build init nel/nelns/snowballs ...'), and the 'make'
15 # command ('build nel/nelns/snowballs ...').
19 # $ build mode release static
20 # $ build init nel --enable-sound --enable-ai
21 # $ build nel all install
23 # $ build nelns all install
24 # $ build init snowballs
25 # $ build snowballs all install
27 # As you can see there is no need to specify the installed directory
28 # of NeL, etc ... These information are automaticly provided to the
31 # Check the following variables to get an idea of the place of the
32 # source code, object, and installed files.
34 # In silent mode it use a perl script named 'buildquiet' which
35 # "cleanup" the 'make' command output to only print the compiled
36 # file name instead of the compilation command line.
38 ###########################################################################
42 ###########################################################################
43 ###########################################################################
44 ###########################################################################
47 #MAKE_ARGS="-j20 CC=distcc CXX=distcc"
50 # Set the source directory. Use the environment SRC_DIR variable, if it's
51 # not set, use $HOME/cvs as a default value
52 if test X
"$RYZOM_PATH" = "X"
54 RYZOM_PATH
="$HOME/code"
56 SRC_DIR
="$RYZOM_PATH/../../code"
59 BUILD_DEBUG
="$SRC_DIR/build/debug"
60 BUILD_RELEASE
="$SRC_DIR/build/release"
63 INSTALL_DEBUG
="$SRC_DIR/install/debug"
64 INSTALL_RELEASE
="$SRC_DIR/install/release"
71 BUILD_CFLAGS
="$CFLAGS -pipe"
72 BUILD_CXXFLAGS
="$CXXFLAGS -pipe"
75 CONFIGURE_OPT
="--disable-xmltest --enable-maintainer-mode"
77 ###########################################################################
79 # Flag files associated to each mode
80 DEBUG_FILE
="$RYZOM_PATH/.mode_debug"
81 STATIC_FILE
="$RYZOM_PATH/.mode_static"
82 DYNAMIC_FILE
="$RYZOM_PATH/.mode_dynamic"
83 SILENT_FILE
="$RYZOM_PATH/.mode_silent"
85 # Specify the source code directory of each projects
86 NEL_SRC
="$SRC_DIR/nel"
87 SNOWBALLS_SRC
="$SRC_DIR/snowballs2"
88 NELNS_SRC
="$SRC_DIR/nelns"
91 ###########################################################################
92 ###########################################################################
93 ###########################################################################
97 ###########################################################################
102 echo "Usage: $BUILD_CMD mode [debug] [static] [dynamic] [quiet]"
103 echo " debug -> turn ON/OFF debug compilation"
104 echo " static -> turn ON/OFF static linking"
105 echo " dynamic -> turn ON/OFF dynamic linking"
106 echo " quiet -> turn ON/OFF quiet compilation"
108 echo "Usage: $BUILD_CMD [init] [nel | nelns | snowballs] [ARGS]"
109 echo " init -> init. the build system"
110 echo " nel, nelns, snowballs -> module to init./compile"
112 echo " ARGS with init are passed to the 'configure' script"
113 echo " otherwise they are passed to 'make'"
118 ###########################################################################
123 echo "Compilation modes :"
125 echo " Debug mode : $DEBUG_MODE"
127 echo " Static linking : $STATIC_MODE"
128 echo " Dynamic linking : $DYNAMIC_MODE"
130 echo " Quiet compilation : $SILENT_MODE"
135 ###########################################################################
136 # Print a message error (given in argument) and exit.
141 echo "*** ERROR: $MSG ***" >&2
147 ###########################################################################
148 # Get the specific mode value and set the corresponding variable
163 ###########################################################################
164 # Set a specific mode to ON if it's OFF, and to OFF if its ON
169 local OLD_VALUE NEW_VALUE
171 # Get the current mode value
172 OLD_VALUE
=$
(eval echo \$
$VAR)
174 if test X
"$OLD_VALUE" = "XOFF"
176 # Set the MODE to ON in case it's OFF
178 touch -f $FILE || printError
"cannot create mode file: $FILE"
180 # Set the MODE to OFF in case it's ON
182 rm -f $FILE || printError
"cannot delete mode file: $FILE"
189 ###########################################################################
190 ###########################################################################
191 ###########################################################################
193 BUILD_CMD
=`basename $0`
195 ###########################################################################
196 # Get current the mode settings
197 getMode DEBUG_MODE
$DEBUG_FILE
198 getMode STATIC_MODE
$STATIC_FILE
199 getMode DYNAMIC_MODE
$DYNAMIC_FILE
200 getMode SILENT_MODE
$SILENT_FILE
203 ###########################################################################
204 ###########################################################################
205 ###########################################################################
206 # BUILDMODE / BUILD MODE call
208 if test "$BUILD_CMD" = 'buildmode' -o "$1" = 'mode'
211 if test "$1" = 'mode'
216 # Print the mode values and exit if there is no argument
228 setMode DEBUG_MODE
$DEBUG_FILE
232 setMode STATIC_MODE
$STATIC_FILE
236 setMode DYNAMIC_MODE
$DYNAMIC_FILE
240 setMode SILENT_MODE
$SILENT_FILE
243 *) echo "*** ERROR : $1 : Unknown building mode ***" >&2
261 ###########################################################################
262 ###########################################################################
263 # Default call: BUILD
266 ###########################################################################
267 # Set the LD_LIBRARY_PATH variable to use the STLPORT
268 if test -n "$STLPORT_DIR"
270 CONFIGURE_OPT
="$CONFIGURE_OPT --with-stlport=$STLPORT_DIR"
272 if test -z "$LD_LIBRARY_PATH"
274 LD_LIBRARY_PATH
="$STLPORT_DIR/lib"
276 LD_LIBRARY_PATH
="$STLPORT_DIR/lib:$LD_LIBRARY_PATH"
280 # Set the configure option to use the rigth python version
281 if test -n "$PYTHON_VERSION"
283 CONFIGURE_OPT
="$CONFIGURE_OPT --with-python-version=$PYTHON_VERSION"
287 ###########################################################################
290 echo "Using source directory : $SRC_DIR"
292 # If we are in debug mode we use the debug build and install directories
293 # Otherwise we use the release build and install directories
294 if test "$DEBUG_MODE" = 'ON'
296 BUILD_DIR
=$BUILD_DEBUG
297 INSTALL_DIR
=$INSTALL_DEBUG
298 CONFIGURE_OPT
="$CONFIGURE_OPT --with-debug"
299 PATH
="$INSTALL_DEBUG/bin:$PATH"
300 LD_LIBRARY_PATH
="$INSTALL_DEBUG/lib:LD_LIBRARY_PATH"
302 BUILD_DIR
=$BUILD_RELEASE
303 INSTALL_DIR
=$INSTALL_RELEASE
304 BUILD_CFLAGS
="$BUILD_CFLAGS"
305 BUILD_CXXFLAGS
="$BUILD_CXXFLAGS"
306 PATH
="$INSTALL_RELEASE/bin:$PATH"
307 LD_LIBRARY_PATH
="$INSTALL_RELEASE/lib:$LD_LIBRARY_PATH"
310 export LD_LIBRARY_PATH
312 # Set where to install and where find NeL library files
313 CONFIGURE_OPT
="$CONFIGURE_OPT --prefix=$INSTALL_DIR --with-nel=$INSTALL_DIR"
315 # Get if it's a static and/or a dynamic compilation
316 if test "$STATIC_MODE" != "$DYNAMIC_MODE"
318 if test "$STATIC_MODE" = 'ON'
320 CONFIGURE_OPT
="--enable-static=yes --enable-shared=no $CONFIGURE_OPT"
323 if test "$DYNAMIC_MODE" = 'ON'
325 CONFIGURE_OPT
="--enable-static=no --enable-shared=yes $CONFIGURE_OPT"
328 if test "$DYNAMIC_MODE" = 'OFF' -a "$STATIC_MODE" = 'OFF'
330 echo "*** ERROR: You must set building of static and/or dynamic libraries ***" >&2
334 echo "*** WARNING: Building both static and dynamic libraries ***" >&2
340 echo "*** ERROR: You have to decide what to do !... ***" >&2
348 # Modules initialisation
352 $RYZOM_PATH/tools
/scripts
/linux
/buildmode
357 # Create the build directories
358 if test ! -d $BUILD_DIR/$BUILD_ARG
360 echo -n "Creating $BUILD_DIR/$ARG ..."
361 mkdir
-p $BUILD_DIR/$BUILD_ARG \
362 || printError
"cannot create the $BUILD_DIR/$BUILD_ARG directory"
366 # Erase the already existing configuration cache
367 rm -f $BUILD_DIR/$BUILD_ARG/config.cache \
368 $BUILD_DIR/$BUILD_ARG/config.h
373 # Run the bootstrap script
374 cd $SRC_DIR/$BUILD_ARG \
375 || printError
"You must get the source files first !..."
378 # Run the configure script
379 cd $BUILD_DIR/$BUILD_ARG
380 CFLAGS
="$BUILD_CFLAGS" CXXFLAGS
="$BUILD_CXXFLAGS" \
381 $SRC_DIR/$BUILD_ARG/configure
$CONFIGURE_OPT $
* ||
exit 1
384 *) echo "*** ERROR: $BUILD_ARG : Unknown module ***" >&2
392 # Modules compilation
397 # VPATH compilation and NeL include's Makefile.am command
398 # '$(wildcard *.h)' doesn't like each other very much. So the
399 # include files must be copied in NeL's compilation directory
400 # before each build (in case one or several header files changed).
401 if test "$BUILD_MODULE" = "nel"
403 # Delete any existing include file in the compilation
404 # directory to avoid any kind of conflict
405 if test -d $BUILD_DIR/nel
/include
/nel
407 cd $BUILD_DIR/nel
/include
/nel
408 find .
-type f
-name \
*.h
-exec rm -rf \
{\
} \
;
410 printError
"You must get the source files first !..."
414 mkdir
-p $BUILD_DIR/nel \
415 && cp -RfPp $NEL_SRC/include
$BUILD_DIR/nel
417 # Remove from the compilation directory the useless CVS
419 cd $BUILD_DIR/nel
/include \
420 && find .
-prune -type d
-name CVS
-exec rm -rf \
{\
} \
;
424 cd $BUILD_DIR/$BUILD_MODULE ||
exit 1
426 # Launch make in silent mode or not, depending of the config.
427 if test $SILENT_MODE = 'ON'
429 make $MAKE_ARGS $
* | buildquiet
435 *) echo "*** ERROR: $1 : Unknown argument ***" >&2