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
128 SETUP_COMBO="gnu-fd-nil"
129 SETUP_LOGNAME="config-gstepmake.log"
130 if test -d /Developer/Applications/Xcode.app; then
131 # rather weird OSX test, right? ;->
132 SETUP_COMBO="apple-apple-nil"
136 echo -n "configuring builtin gnustep-make environment (${SETUP_LOGNAME}) .."
138 cd "$GSTEPMAKE_SRCDIR"
139 ./configure >${pregsmdir}/${SETUP_LOGNAME} \
140 --prefix="${INTERNAL_MAKEDIR}" \
141 --without-system-root \
142 --with-network-root="${INTERNAL_MAKEDIR}" \
143 --with-local-root="${INTERNAL_MAKEDIR}" \
144 --with-user-root="${INTERNAL_MAKEDIR}" \
145 --with-library-combo="${SETUP_COMBO}"
147 echo -n ".. install .."
148 make install >>${pregsmdir}/${SETUP_LOGNAME}
150 ARG_GSMAKE="${INTERNAL_MAKEDIR}/Library/Makefiles/"
154 USES_INTERNAL_MAKE=yes
155 if test "x$ARG_PREFIX" = "x"; then
156 ARG_PREFIX="/usr/local/"
160 if test -f $ARG_GSMAKE/GNUstep.sh; then
161 echo ".. done (log in ${SETUP_LOGNAME})."
163 echo "error: failed to setup embedded gnustep-make sources!"
164 cat ${pregsmdir}/${SETUP_LOGNAME}
168 echo "error: did not find embedded gnustep-make sources!"
173 function validateGNUstepArgs() {
175 if test "x$ARG_GSMAKE" = "x"; then
176 if test -f $HOME/OGoRoot/Library/Makefiles/GNUstep.sh; then
177 ARG_GSMAKE="$HOME/OGoRoot/Library/Makefiles/"
178 elif test -f $HOME/GNUstep/Library/Makefiles/GNUstep.sh; then
179 ARG_GSMAKE="$HOME/GNUstep/Library/Makefiles/"
180 elif test -f /usr/GNUstep/System/Library/Makefiles/GNUstep.sh; then
181 ARG_GSMAKE="/usr/GNUstep/System/Library/Makefiles/"
185 DARG_GNUSTEP_SH="$ARG_GSMAKE/GNUstep.sh"
186 elif test -d $ARG_GSMAKE; then
187 if test -f $ARG_GSMAKE/GNUstep.sh; then
188 DARG_GNUSTEP_SH="$ARG_GSMAKE/GNUstep.sh"
189 elif test -f $ARG_GSMAKE/Library/Makefiles/GNUstep.sh; then
190 ARG_GSMAKE="$ARG_GSMAKE/Library/Makefiles"
191 DARG_GNUSTEP_SH="$ARG_GSMAKE/GNUstep.sh"
193 echo "error: specified directory contains no GNUstep.sh: $ARG_GSMAKE"
197 echo "error: specified GNUstep make tree does not exist: $ARG_GSMAKE"
202 function setupAppleArgs() {
204 if test "x${USES_INTERNAL_MAKE}" = "no"; then
208 # no reason to print a warning?
209 #if test "x${xLIBRARY_COMBO}" != "xapple-apple-nil"; then
210 # if test "x${LIBRARY_COMBO}" != "xapple-apple-apple"; then
211 # echo "WARNING: detected MacOSX GNUstep setup: ${LIBRARY_COMBO}"
217 function validateArgs() {
218 # validate prefix (could be better?)
219 case "x$ARG_PREFIX" in
220 "x/usr/local"|"x/usr/local/")
226 "x$GNUSTEP_USER_ROOT"|"x$GNUSTEP_LOCAL_ROOT"|"x$GNUSTEP_SYSTEM_ROOT")
231 if test $ARG_WITH_GNUSTEP = 1; then
233 ARG_PREFIX="$GNUSTEP_LOCAL_ROOT"
234 if test $ARG_BEQUIET != 1; then
235 echo "Note: will install in GNUSTEP_LOCAL_ROOT: $ARG_PREFIX"
238 elif test "x$ARG_FRAMEWORK_DIR" != "x"; then
240 ARG_PREFIX="$ARG_FRAMEWORK_DIR"
241 echo "Note: will install in frameworks location: $ARG_PREFIX"
245 ARG_PREFIX="/usr/local/"
246 echo "Note: will install in default location: $ARG_PREFIX"
251 if test $ARG_WITH_GNUSTEP = 1; then
252 echo "error: specified --with-gnustep, but specified prefix is not"
253 echo " a GNUstep root: '$ARG_PREFIX'"
256 if test $ARG_BEQUIET != 1; then
264 if test $ARG_WITH_GNUSTEP = 1; then
265 if test $DARG_IS_FHS = 1; then
266 echo "error: configured for FHS root _and_ GNUstep tree. Choose one!"
272 function printGNUstepSetup() {
273 echo "GNUstep environment:"
274 echo " system: ${GNUSTEP_SYSTEM_ROOT}"
275 echo " local: ${GNUSTEP_LOCAL_ROOT}"
276 echo " user: ${GNUSTEP_USER_ROOT}"
277 echo " path: ${GNUSTEP_PATHLIST}"
278 echo " flat: ${GNUSTEP_FLATTENED}"
279 echo " arch: ${GNUSTEP_HOST}"
280 echo " combo: ${LIBRARY_COMBO}"
284 function cfgwrite() {
285 echo "$1" >> $ARG_CFGMAKE
288 function genConfigMake() {
289 # we ignore the following vars also patches by gstep-make:
295 if test $ARG_BEQUIET != 1; then
296 echo "creating: $ARG_CFGMAKE"
299 echo "# GNUstep environment configuration" > $ARG_CFGMAKE
300 cfgwrite "# created by: '$CFG_ARGS'"
303 cfgwrite "# Note: you can override any option as a 'make' parameter, eg:"
304 cfgwrite "# make debug=yes"
307 #cfgwrite "# print on the cmdline that this file is being used"
309 #cfgwrite " @echo Local GNUstep config.make is active"
312 # TODO: should be also write a GNUSTEP_INSTALLATION_DIR / BUNDLE_INSTALL_DIR?
315 if test "x$ARG_FRAMEWORK_DIR" != "x"; then
316 cfgwrite "# configured to install in Frameworks directory"
317 cfgwrite "FRAMEWORK_INSTALL_DIR:=${ARG_FRAMEWORK_DIR}"
318 cfgwrite "frameworks=yes"
320 elif test $DARG_IS_FHS = 1; then
321 cfgwrite "# configured for FHS install"
322 cfgwrite "FHS_INSTALL_ROOT:=$ARG_PREFIX"
325 cfgwrite "# configured for GNUstep install"
328 if test $ARG_WITH_DEBUG = 1; then
329 cfgwrite "# configured to produce debugging code";
330 cfgwrite "debug:=yes"
332 cfgwrite "# configured to produce non-debugging code";
337 if test $ARG_WITH_STRIP = 1; then
338 cfgwrite "# configured to produce stripped code";
339 cfgwrite "strip:=yes"
341 cfgwrite "# configured not to strip code";
346 cfgwrite "# enforce shared libraries";
347 cfgwrite "shared:=yes"
350 cfgwrite "# GNUstep environment variables:";
351 for i in `env | grep GNUSTEP_ | sort`; do
352 MAKE_ASSI="`echo $i | sed s/=/:=/`"
353 cfgwrite "${MAKE_ASSI}";
355 cfgwrite "LIBRARY_COMBO=$LIBRARY_COMBO"
358 cfgwrite "# avoid a gstep-make warning"
359 cfgwrite "PATH:=\$(GNUSTEP_SYSTEM_ROOT)/Tools:\$(PATH)"
362 function checkLinking() {
363 # library-name => $1, type => $2
365 local tmpdir=".configure-test-$$"
369 cp ../maintenance/dummytool.m .
371 tmpmake="GNUmakefile"
372 echo >$tmpmake "include ../config.make"
373 echo >>$tmpmake "include \$(GNUSTEP_MAKEFILES)/common.make"
374 echo >>$tmpmake "TOOL_NAME := linktest"
375 echo >>$tmpmake "linktest_OBJC_FILES := dummytool.m"
376 echo >>$tmpmake "linktest_TOOL_LIBS += -l$1"
377 echo >>$tmpmake "SYSTEM_LIB_DIR += ${LINK_SYSLIBDIRS}"
378 echo >>$tmpmake "include \$(GNUSTEP_MAKEFILES)/tool.make"
380 make -s messages=yes -f $tmpmake linktest >out.log 2>err.log
383 if test $LINK_RESULT = 0; then
384 echo "$2 library found: $1"
385 cfgwrite "HAS_LIBRARY_$1=yes"
387 if test "x$2" = "xrequired"; then
388 echo "failed to link $2 library: $1"
392 echo "failed to link $2 library: $1"
393 cfgwrite "HAS_LIBRARY_$1=no"
401 function checkDependencies() {
403 cfgwrite "# library dependencies"
404 checkLinking "xml2" optional;
405 checkLinking "ldap" optional;
406 checkLinking "ssl" required; # TODO: make optional
407 checkLinking "pq" optional;
408 checkLinking "sqlite3" optional;
409 checkLinking "mysqlclient" optional;
413 if test $ARG_BEQUIET != 1; then
417 if test $ARG_NOCREATE = 1; then
418 if test $ARG_BEQUIET != 1; then
419 echo "not creating the config file ...";
425 if test -x $NGSTREAMS_DIR/configure; then
426 if test $ARG_BEQUIET != 1; then
427 echo -n "configuring NGStreams library .."
430 ./configure >$old/config-NGStreams.log
432 echo ".. done (log in config-NGStreams.log)."
438 # ******************** options ********************
440 function extractFuncValue() {
441 VALUE="`echo "$1" | sed "s/[^=]*=//g"`"
444 function processOption() {
449 "x--quiet"|"x--silent"|"x-q") ARG_BEQUIET=1; ;;
450 "x--no-create"|"x-n") ARG_NOCREATE=1; ;;
457 ARG_FRAMEWORK_DIR="$VALUE";
465 ARG_CFGMAKE="$VALUE";
471 "x--without-gnustep")
488 *) echo "error: cannot process argument: $1"; exit 1; ;;
496 # load GNUstep environment
498 # first we load the GNUstep.sh environment
499 source $DARG_GNUSTEP_SH
500 if test $ARG_BEQUIET != 1; then
504 # setup some GNUstep dependend defaults
505 if test "x$GNUSTEP_HOST_VENDOR" = "xapple"; then
509 # ensure the parameters make sense