4 # Note: When adding make options to this script, ensure that the source still
5 # compiles without those options! (and just with GNUstep.sh being
7 # We do not want to force people to run configure.
10 # ******************** variables ****************
12 CFG_ARGS="$0 $1 $2 $3 $4 $5 $6 $7 $8 $9"
18 ARG_GSMAKE="$GNUSTEP_MAKEFILES"
19 ARG_CFGMAKE="$PWD/config.make"
24 DARG_GNUSTEP_SH="$ARG_GSMAKE/GNUstep.sh"
27 SOPE_SRCDIR="$PWD" # TODO: rather use location of configure (using basename)
28 NGSTREAMS_DIR="${SOPE_SRCDIR}/sope-core/NGStreams"
29 GSTEPMAKE_SRCDIR="${SOPE_SRCDIR}/gnustep-make"
30 INTERNAL_MAKEDIR="${SOPE_SRCDIR}/.gsmake"
33 # TODO: add pg_config, mysql_config etc!
34 LINK_SYSLIBDIRS="-L/usr/local/pgsql/lib -L/usr/local/lib -L/usr/lib"
36 # ******************** usage ********************
40 \`configure' configures a GNUstep-make based sourcetree for installation.
44 Note: You do not need to configure this source tree, as another option
45 just ensure that the GNUstep.sh of your GNUstep make installation
46 is properly sourced prior running make.
49 -h, --help display this help and exit
50 -q, --quiet, --silent do not print \`checking...' messages
51 -n, --no-create do not create output files
53 Installation directories:
54 --prefix=PREFIX install files in PREFIX [/usr/local]
55 --frameworks=DIR build frameworks and install in DIR
56 --gsmake=PATH path to gnustep-make tree
57 --configmake=PATH path to the config file being created
58 --with-gnustep install in GNUstep tree
59 --enable-debug turn on debugging and compile time warnings
60 --enable-strip turn on stripping of debug symbols
67 # ******************** running ********************
69 function printParas() {
71 if test $ARG_BEQUIET = 1; then echo " will be quite."; fi
72 if test $ARG_NOCREATE = 1; then echo " won't create files"; fi
73 if test "x$ARG_FRAMEWORK_DIR" != "x"; then
74 echo " FHS: install in frameworks directory";
75 elif test $DARG_IS_FHS = 1; then
76 echo " FHS: install in FHS root";
78 echo " FHS: install in GNUstep tree";
81 if test $ARG_WITH_DEBUG = 1; then
86 if test $ARG_WITH_STRIP = 1; then
92 echo " prefix: $ARG_PREFIX"
93 echo " frameworks: $ARG_FRAMEWORK_DIR"
94 echo " gstep: $ARG_GSMAKE"
95 echo " config: $ARG_CFGMAKE"
96 echo " script: $DARG_GNUSTEP_SH"
100 function warnOnFHSPrefix() {
102 Warning: you are configuring for a non standard FHS style prefix.
105 Some code in SOPE only looks in /usr and /usr/local for resources and is
106 therefore incompatible with arbitary install pathes.
108 If you want to have the flexibility of installation in arbitary pathes just
109 configure GNUstep-make and source the GNUstep.sh script prior executing tools
110 to ensure a proper environment.
111 All SOPE based code is completely relocatable when being used in a GNUstep
117 function setupInternalGSMake() {
118 if test -f ${INTERNAL_MAKEDIR}/Library/Makefiles/GNUstep.sh; then
119 ARG_GSMAKE="${INTERNAL_MAKEDIR}/Library/Makefiles/"
123 USES_INTERNAL_MAKE=yes
124 if test "x$ARG_PREFIX" = "x"; then
125 ARG_PREFIX="/usr/local/"
127 elif test -d gnustep-make; then
129 SETUP_COMBO="gnu-fd-nil"
130 SETUP_LOGNAME="config-gstepmake.log"
131 if test -d /Developer/Applications/Xcode.app; then
132 # rather weird OSX test, right? ;->
133 SETUP_COMBO="apple-apple-nil"
134 ENABLE_PCH_OPT="--enable-pch"
138 echo -n "configuring builtin gnustep-make environment (${SETUP_LOGNAME}) .."
140 cd "$GSTEPMAKE_SRCDIR"
141 ./configure >${pregsmdir}/${SETUP_LOGNAME} \
143 --prefix="${INTERNAL_MAKEDIR}" \
144 --with-config-file="${INTERNAL_MAKEDIR}/GNUstep.conf" \
145 --with-system-root="${INTERNAL_MAKEDIR}" \
146 --with-network-root="${INTERNAL_MAKEDIR}" \
147 --with-local-root="${INTERNAL_MAKEDIR}" \
148 --with-user-root="${INTERNAL_MAKEDIR}" \
149 --with-library-combo="${SETUP_COMBO}"
151 echo -n ".. install .."
152 make install >>${pregsmdir}/${SETUP_LOGNAME}
154 ARG_GSMAKE="${INTERNAL_MAKEDIR}/Library/Makefiles/"
158 USES_INTERNAL_MAKE=yes
159 if test "x$ARG_PREFIX" = "x"; then
160 ARG_PREFIX="/usr/local/"
164 if test -f $ARG_GSMAKE/GNUstep.sh; then
165 echo ".. done (log in ${SETUP_LOGNAME})."
167 echo "error: failed to setup embedded gnustep-make sources!"
168 tail ${pregsmdir}/${SETUP_LOGNAME}
172 echo "error: did not find embedded gnustep-make sources!"
177 function validateGNUstepArgs() {
179 if test "x$ARG_GSMAKE" = "x"; then
180 if test -f $HOME/OGoRoot/Library/Makefiles/GNUstep.sh; then
181 ARG_GSMAKE="$HOME/OGoRoot/Library/Makefiles/"
182 elif test -f $HOME/GNUstep/Library/Makefiles/GNUstep.sh; then
183 ARG_GSMAKE="$HOME/GNUstep/Library/Makefiles/"
184 elif test -f /usr/GNUstep/System/Library/Makefiles/GNUstep.sh; then
185 ARG_GSMAKE="/usr/GNUstep/System/Library/Makefiles/"
189 DARG_GNUSTEP_SH="$ARG_GSMAKE/GNUstep.sh"
190 elif test -d $ARG_GSMAKE; then
191 if test -f $ARG_GSMAKE/GNUstep.sh; then
192 DARG_GNUSTEP_SH="$ARG_GSMAKE/GNUstep.sh"
193 elif test -f $ARG_GSMAKE/Library/Makefiles/GNUstep.sh; then
194 ARG_GSMAKE="$ARG_GSMAKE/Library/Makefiles"
195 DARG_GNUSTEP_SH="$ARG_GSMAKE/GNUstep.sh"
197 echo "error: specified directory contains no GNUstep.sh: $ARG_GSMAKE"
201 echo "error: specified GNUstep make tree does not exist: $ARG_GSMAKE"
206 function setupAppleArgs() {
208 if test "x${USES_INTERNAL_MAKE}" = "no"; then
212 # no reason to print a warning?
213 #if test "x${xLIBRARY_COMBO}" != "xapple-apple-nil"; then
214 # if test "x${LIBRARY_COMBO}" != "xapple-apple-apple"; then
215 # echo "WARNING: detected MacOSX GNUstep setup: ${LIBRARY_COMBO}"
221 function validateArgs() {
222 # validate prefix (could be better?)
223 case "x$ARG_PREFIX" in
224 "x/usr/local"|"x/usr/local/")
230 "x$GNUSTEP_USER_ROOT"|"x$GNUSTEP_LOCAL_ROOT"|"x$GNUSTEP_SYSTEM_ROOT")
235 if test $ARG_WITH_GNUSTEP = 1; then
237 ARG_PREFIX="$GNUSTEP_LOCAL_ROOT"
238 if test $ARG_BEQUIET != 1; then
239 echo "Note: will install in GNUSTEP_LOCAL_ROOT: $ARG_PREFIX"
242 elif test "x$ARG_FRAMEWORK_DIR" != "x"; then
244 ARG_PREFIX="$ARG_FRAMEWORK_DIR"
245 echo "Note: will install in frameworks location: $ARG_PREFIX"
249 ARG_PREFIX="/usr/local/"
250 echo "Note: will install in default location: $ARG_PREFIX"
255 if test $ARG_WITH_GNUSTEP = 1; then
256 echo "error: specified --with-gnustep, but specified prefix is not"
257 echo " a GNUstep root: '$ARG_PREFIX'"
260 if test $ARG_BEQUIET != 1; then
268 if test $ARG_WITH_GNUSTEP = 1; then
269 if test $DARG_IS_FHS = 1; then
270 echo "error: configured for FHS root _and_ GNUstep tree. Choose one!"
276 function printGNUstepSetup() {
277 echo "GNUstep environment:"
278 echo " system: ${GNUSTEP_SYSTEM_ROOT}"
279 echo " local: ${GNUSTEP_LOCAL_ROOT}"
280 echo " user: ${GNUSTEP_USER_ROOT}"
281 echo " path: ${GNUSTEP_PATHLIST}"
282 echo " flat: ${GNUSTEP_FLATTENED}"
283 echo " arch: ${GNUSTEP_HOST}"
284 echo " combo: ${LIBRARY_COMBO}"
288 function cfgwrite() {
289 echo "$1" >> $ARG_CFGMAKE
292 function genConfigMake() {
293 # we ignore the following vars also patches by gstep-make:
299 if test $ARG_BEQUIET != 1; then
300 echo "creating: $ARG_CFGMAKE"
303 echo "# GNUstep environment configuration" > $ARG_CFGMAKE
304 cfgwrite "# created by: '$CFG_ARGS'"
307 cfgwrite "# Note: you can override any option as a 'make' parameter, eg:"
308 cfgwrite "# make debug=yes"
311 #cfgwrite "# print on the cmdline that this file is being used"
313 #cfgwrite " @echo Local GNUstep config.make is active"
316 # TODO: should be also write a GNUSTEP_INSTALLATION_DIR / BUNDLE_INSTALL_DIR?
319 if test "x$ARG_FRAMEWORK_DIR" != "x"; then
320 cfgwrite "# configured to install in Frameworks directory"
321 cfgwrite "FRAMEWORK_INSTALL_DIR:=${ARG_FRAMEWORK_DIR}"
322 cfgwrite "frameworks=yes"
324 elif test $DARG_IS_FHS = 1; then
325 cfgwrite "# configured for FHS install"
326 cfgwrite "FHS_INSTALL_ROOT:=$ARG_PREFIX"
329 cfgwrite "# configured for GNUstep install"
332 if test $ARG_WITH_DEBUG = 1; then
333 cfgwrite "# configured to produce debugging code";
334 cfgwrite "debug:=yes"
336 cfgwrite "# configured to produce non-debugging code";
341 if test $ARG_WITH_STRIP = 1; then
342 cfgwrite "# configured to produce stripped code";
343 cfgwrite "strip:=yes"
345 cfgwrite "# configured not to strip code";
350 cfgwrite "# enforce shared libraries";
351 cfgwrite "shared:=yes"
354 cfgwrite "# GNUstep environment variables:";
355 for i in `env | grep GNUSTEP_ | sort`; do
356 MAKE_ASSI="`echo $i | sed s/=/:=/`"
357 cfgwrite "${MAKE_ASSI}";
359 cfgwrite "LIBRARY_COMBO=$LIBRARY_COMBO"
362 # Note: GNUSTEP_TARGET_CPU is not yet available (set by common.make), so we
363 # only have environment variables
364 # Note: we can't set SYSTEM_LIB_DIR in this location, it gets overridden by
366 cfgwrite "ifeq (\$(findstring _64, \$(GNUSTEP_HOST_CPU)), _64)"
367 cfgwrite "CONFIGURE_64BIT:=yes"
368 cfgwrite "CGS_LIBDIR_NAME:=lib64"
370 cfgwrite "CGS_LIBDIR_NAME:=lib"
373 cfgwrite "ifneq (\$(FHS_INSTALL_ROOT),)"
374 cfgwrite "CONFIGURE_FHS_INSTALL_LIBDIR:=\$(FHS_INSTALL_ROOT)/\$(CGS_LIBDIR_NAME)/"
375 cfgwrite "CONFIGURE_SYSTEM_LIB_DIR += -L\$(CONFIGURE_FHS_INSTALL_LIBDIR)"
377 cfgwrite "CONFIGURE_SYSTEM_LIB_DIR += -L/usr/\$(CGS_LIBDIR_NAME)/"
379 cfgwrite "# avoid a gstep-make warning"
380 cfgwrite "PATH:=\$(GNUSTEP_SYSTEM_ROOT)/Tools:\$(PATH)"
383 function checkLinking() {
384 # library-name => $1, type => $2
386 local tmpdir=".configure-test-$$"
390 cp ../maintenance/dummytool.c .
392 tmpmake="GNUmakefile"
393 echo >$tmpmake "include ../config.make"
394 echo >>$tmpmake "include \$(GNUSTEP_MAKEFILES)/common.make"
395 echo >>$tmpmake "CTOOL_NAME := linktest"
396 echo >>$tmpmake "linktest_C_FILES := dummytool.c"
397 echo >>$tmpmake "linktest_TOOL_LIBS += -l$1"
398 echo >>$tmpmake "SYSTEM_LIB_DIR += \$(CONFIGURE_SYSTEM_LIB_DIR)"
399 echo >>$tmpmake "SYSTEM_LIB_DIR += ${LINK_SYSLIBDIRS}"
400 echo >>$tmpmake "include \$(GNUSTEP_MAKEFILES)/ctool.make"
402 make -s messages=yes -f $tmpmake linktest >out.log 2>err.log
405 if test $LINK_RESULT = 0; then
406 echo "$2 library found: $1"
407 cfgwrite "HAS_LIBRARY_$1=yes"
409 if test "x$2" = "xrequired"; then
410 echo "failed to link $2 library: $1"
414 echo "failed to link $2 library: $1"
415 cfgwrite "HAS_LIBRARY_$1=no"
423 function checkDependencies() {
425 cfgwrite "# library dependencies"
426 checkLinking "xml2" optional;
427 checkLinking "ldap" optional;
428 checkLinking "ssl" required; # TODO: make optional
429 checkLinking "pq" optional;
430 checkLinking "sqlite3" optional;
431 checkLinking "mysqlclient" optional;
435 if test $ARG_BEQUIET != 1; then
439 if test $ARG_NOCREATE = 1; then
440 if test $ARG_BEQUIET != 1; then
441 echo "not creating the config file ...";
447 if test -x $NGSTREAMS_DIR/configure; then
448 if test $ARG_BEQUIET != 1; then
449 echo -n "configuring NGStreams library .."
452 ./configure >$old/config-NGStreams.log
454 echo ".. done (log in config-NGStreams.log)."
460 # ******************** options ********************
462 function extractFuncValue() {
463 VALUE="`echo "$1" | sed "s/[^=]*=//g"`"
466 function processOption() {
471 "x--quiet"|"x--silent"|"x-q") ARG_BEQUIET=1; ;;
472 "x--no-create"|"x-n") ARG_NOCREATE=1; ;;
479 ARG_FRAMEWORK_DIR="$VALUE";
487 ARG_CFGMAKE="$VALUE";
493 "x--without-gnustep")
510 *) echo "error: cannot process argument: $1"; exit 1; ;;
518 # load GNUstep environment
520 # first we load the GNUstep.sh environment
521 source $DARG_GNUSTEP_SH
522 if test $ARG_BEQUIET != 1; then
526 # setup some GNUstep dependend defaults
527 if test "x$GNUSTEP_HOST_VENDOR" = "xapple"; then
531 # ensure the parameters make sense