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 --without-system-root \
145 --with-network-root="${INTERNAL_MAKEDIR}" \
146 --with-local-root="${INTERNAL_MAKEDIR}" \
147 --with-user-root="${INTERNAL_MAKEDIR}" \
148 --with-library-combo="${SETUP_COMBO}"
150 echo -n ".. install .."
151 make install >>${pregsmdir}/${SETUP_LOGNAME}
153 ARG_GSMAKE="${INTERNAL_MAKEDIR}/Library/Makefiles/"
157 USES_INTERNAL_MAKE=yes
158 if test "x$ARG_PREFIX" = "x"; then
159 ARG_PREFIX="/usr/local/"
163 if test -f $ARG_GSMAKE/GNUstep.sh; then
164 echo ".. done (log in ${SETUP_LOGNAME})."
166 echo "error: failed to setup embedded gnustep-make sources!"
167 cat ${pregsmdir}/${SETUP_LOGNAME}
171 echo "error: did not find embedded gnustep-make sources!"
176 function validateGNUstepArgs() {
178 if test "x$ARG_GSMAKE" = "x"; then
179 if test -f $HOME/OGoRoot/Library/Makefiles/GNUstep.sh; then
180 ARG_GSMAKE="$HOME/OGoRoot/Library/Makefiles/"
181 elif test -f $HOME/GNUstep/Library/Makefiles/GNUstep.sh; then
182 ARG_GSMAKE="$HOME/GNUstep/Library/Makefiles/"
183 elif test -f /usr/GNUstep/System/Library/Makefiles/GNUstep.sh; then
184 ARG_GSMAKE="/usr/GNUstep/System/Library/Makefiles/"
188 DARG_GNUSTEP_SH="$ARG_GSMAKE/GNUstep.sh"
189 elif test -d $ARG_GSMAKE; then
190 if test -f $ARG_GSMAKE/GNUstep.sh; then
191 DARG_GNUSTEP_SH="$ARG_GSMAKE/GNUstep.sh"
192 elif test -f $ARG_GSMAKE/Library/Makefiles/GNUstep.sh; then
193 ARG_GSMAKE="$ARG_GSMAKE/Library/Makefiles"
194 DARG_GNUSTEP_SH="$ARG_GSMAKE/GNUstep.sh"
196 echo "error: specified directory contains no GNUstep.sh: $ARG_GSMAKE"
200 echo "error: specified GNUstep make tree does not exist: $ARG_GSMAKE"
205 function setupAppleArgs() {
207 if test "x${USES_INTERNAL_MAKE}" = "no"; then
211 # no reason to print a warning?
212 #if test "x${xLIBRARY_COMBO}" != "xapple-apple-nil"; then
213 # if test "x${LIBRARY_COMBO}" != "xapple-apple-apple"; then
214 # echo "WARNING: detected MacOSX GNUstep setup: ${LIBRARY_COMBO}"
220 function validateArgs() {
221 # validate prefix (could be better?)
222 case "x$ARG_PREFIX" in
223 "x/usr/local"|"x/usr/local/")
229 "x$GNUSTEP_USER_ROOT"|"x$GNUSTEP_LOCAL_ROOT"|"x$GNUSTEP_SYSTEM_ROOT")
234 if test $ARG_WITH_GNUSTEP = 1; then
236 ARG_PREFIX="$GNUSTEP_LOCAL_ROOT"
237 if test $ARG_BEQUIET != 1; then
238 echo "Note: will install in GNUSTEP_LOCAL_ROOT: $ARG_PREFIX"
241 elif test "x$ARG_FRAMEWORK_DIR" != "x"; then
243 ARG_PREFIX="$ARG_FRAMEWORK_DIR"
244 echo "Note: will install in frameworks location: $ARG_PREFIX"
248 ARG_PREFIX="/usr/local/"
249 echo "Note: will install in default location: $ARG_PREFIX"
254 if test $ARG_WITH_GNUSTEP = 1; then
255 echo "error: specified --with-gnustep, but specified prefix is not"
256 echo " a GNUstep root: '$ARG_PREFIX'"
259 if test $ARG_BEQUIET != 1; then
267 if test $ARG_WITH_GNUSTEP = 1; then
268 if test $DARG_IS_FHS = 1; then
269 echo "error: configured for FHS root _and_ GNUstep tree. Choose one!"
275 function printGNUstepSetup() {
276 echo "GNUstep environment:"
277 echo " system: ${GNUSTEP_SYSTEM_ROOT}"
278 echo " local: ${GNUSTEP_LOCAL_ROOT}"
279 echo " user: ${GNUSTEP_USER_ROOT}"
280 echo " path: ${GNUSTEP_PATHLIST}"
281 echo " flat: ${GNUSTEP_FLATTENED}"
282 echo " arch: ${GNUSTEP_HOST}"
283 echo " combo: ${LIBRARY_COMBO}"
287 function cfgwrite() {
288 echo "$1" >> $ARG_CFGMAKE
291 function genConfigMake() {
292 # we ignore the following vars also patches by gstep-make:
298 if test $ARG_BEQUIET != 1; then
299 echo "creating: $ARG_CFGMAKE"
302 echo "# GNUstep environment configuration" > $ARG_CFGMAKE
303 cfgwrite "# created by: '$CFG_ARGS'"
306 cfgwrite "# Note: you can override any option as a 'make' parameter, eg:"
307 cfgwrite "# make debug=yes"
310 #cfgwrite "# print on the cmdline that this file is being used"
312 #cfgwrite " @echo Local GNUstep config.make is active"
315 # TODO: should be also write a GNUSTEP_INSTALLATION_DIR / BUNDLE_INSTALL_DIR?
318 if test "x$ARG_FRAMEWORK_DIR" != "x"; then
319 cfgwrite "# configured to install in Frameworks directory"
320 cfgwrite "FRAMEWORK_INSTALL_DIR:=${ARG_FRAMEWORK_DIR}"
321 cfgwrite "frameworks=yes"
323 elif test $DARG_IS_FHS = 1; then
324 cfgwrite "# configured for FHS install"
325 cfgwrite "FHS_INSTALL_ROOT:=$ARG_PREFIX"
328 cfgwrite "# configured for GNUstep install"
331 if test $ARG_WITH_DEBUG = 1; then
332 cfgwrite "# configured to produce debugging code";
333 cfgwrite "debug:=yes"
335 cfgwrite "# configured to produce non-debugging code";
340 if test $ARG_WITH_STRIP = 1; then
341 cfgwrite "# configured to produce stripped code";
342 cfgwrite "strip:=yes"
344 cfgwrite "# configured not to strip code";
349 cfgwrite "# enforce shared libraries";
350 cfgwrite "shared:=yes"
353 cfgwrite "# GNUstep environment variables:";
354 for i in `env | grep GNUSTEP_ | sort`; do
355 MAKE_ASSI="`echo $i | sed s/=/:=/`"
356 cfgwrite "${MAKE_ASSI}";
358 cfgwrite "LIBRARY_COMBO=$LIBRARY_COMBO"
361 cfgwrite "# avoid a gstep-make warning"
362 cfgwrite "PATH:=\$(GNUSTEP_SYSTEM_ROOT)/Tools:\$(PATH)"
365 function checkLinking() {
366 # library-name => $1, type => $2
368 local tmpdir=".configure-test-$$"
372 cp ../maintenance/dummytool.c .
374 tmpmake="GNUmakefile"
375 echo >$tmpmake "include ../config.make"
376 echo >>$tmpmake "include \$(GNUSTEP_MAKEFILES)/common.make"
377 echo >>$tmpmake "CTOOL_NAME := linktest"
378 echo >>$tmpmake "linktest_C_FILES := dummytool.c"
379 echo >>$tmpmake "linktest_TOOL_LIBS += -l$1"
380 echo >>$tmpmake "SYSTEM_LIB_DIR += ${LINK_SYSLIBDIRS}"
381 echo >>$tmpmake "include \$(GNUSTEP_MAKEFILES)/ctool.make"
383 make -s messages=yes -f $tmpmake linktest >out.log 2>err.log
386 if test $LINK_RESULT = 0; then
387 echo "$2 library found: $1"
388 cfgwrite "HAS_LIBRARY_$1=yes"
390 if test "x$2" = "xrequired"; then
391 echo "failed to link $2 library: $1"
395 echo "failed to link $2 library: $1"
396 cfgwrite "HAS_LIBRARY_$1=no"
404 function checkDependencies() {
406 cfgwrite "# library dependencies"
407 checkLinking "xml2" optional;
408 checkLinking "ldap" optional;
409 checkLinking "ssl" required; # TODO: make optional
410 checkLinking "pq" optional;
411 checkLinking "sqlite3" optional;
412 checkLinking "mysqlclient" optional;
416 if test $ARG_BEQUIET != 1; then
420 if test $ARG_NOCREATE = 1; then
421 if test $ARG_BEQUIET != 1; then
422 echo "not creating the config file ...";
428 if test -x $NGSTREAMS_DIR/configure; then
429 if test $ARG_BEQUIET != 1; then
430 echo -n "configuring NGStreams library .."
433 ./configure >$old/config-NGStreams.log
435 echo ".. done (log in config-NGStreams.log)."
441 # ******************** options ********************
443 function extractFuncValue() {
444 VALUE="`echo "$1" | sed "s/[^=]*=//g"`"
447 function processOption() {
452 "x--quiet"|"x--silent"|"x-q") ARG_BEQUIET=1; ;;
453 "x--no-create"|"x-n") ARG_NOCREATE=1; ;;
460 ARG_FRAMEWORK_DIR="$VALUE";
468 ARG_CFGMAKE="$VALUE";
474 "x--without-gnustep")
491 *) echo "error: cannot process argument: $1"; exit 1; ;;
499 # load GNUstep environment
501 # first we load the GNUstep.sh environment
502 source $DARG_GNUSTEP_SH
503 if test $ARG_BEQUIET != 1; then
507 # setup some GNUstep dependend defaults
508 if test "x$GNUSTEP_HOST_VENDOR" = "xapple"; then
512 # ensure the parameters make sense