]> err.no Git - scalable-opengroupware.org/blob - configure
Install libs to /usr/lib
[scalable-opengroupware.org] / configure
1 #!/bin/sh
2
3 #
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
6 #       sourced)
7 #       We do not want to force people to run configure.
8 #
9
10 # ******************** variables ****************
11
12 CFG_ARGS="$0 $1 $2 $3 $4 $5 $6 $7 $8 $9"
13
14 ARG_BEQUIET=0
15 ARG_NOCREATE=0
16 ARG_PREFIX=""
17 ARG_GSMAKE=`gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null`
18 ARG_CFGMAKE="$PWD/config.make"
19 ARG_WITH_GNUSTEP=1
20 ARG_WITH_DEBUG=1
21 ARG_WITH_STRIP=1
22
23 DARG_GNUSTEP_SH="$ARG_GSMAKE/GNUstep.sh"
24 DARG_IS_FHS=1
25
26 # detect GNU make, needed at least on *BSD
27 make -v 2>/dev/null | grep GNU >/dev/null 2>/dev/null
28 if [ $? -eq 0 ];then
29   MAKE=make
30 else
31   MAKE=gmake
32 fi
33
34 NGSTREAMS_DIR="./sope-core/NGStreams"
35 LINK_SYSLIBDIRS="-L/usr/local/pgsql/lib -L/usr/local/lib -L/usr/lib"
36
37 # ******************** usage ********************
38
39 usage() {
40   cat <<_ACEOF
41 \`configure' configures a GNUstep-make based sourcetree for installation.
42
43 Usage: $0 [OPTION]...
44
45 Note: You do not need to configure this source tree, as another option
46       just ensure that the GNUstep.sh of your GNUstep make installation
47       is properly sourced prior running make.
48
49 Configuration:
50   -h, --help              display this help and exit
51   -q, --quiet, --silent   do not print \`checking...' messages
52   -n, --no-create         do not create output files
53
54 Installation directories:
55   --prefix=PREFIX         install files in PREFIX [/usr/local]
56   --gsmake=PATH           path to gnustep-make tree
57   --configmake=PATH       path to the config file being created
58   --without-gnustep       do not install in GNUstep tree
59   --enable-debug          turn on debugging and compile time warnings
60   --enable-strip          turn on stripping of debug symbols
61
62 _ACEOF
63
64   exit 0;
65 }
66
67 # ******************** running ********************
68
69 printParas() {
70   echo "Configuration:"
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 $DARG_IS_FHS = 1;  then
74     echo "  FHS:    install in FHS root"; 
75   else
76     echo "  FHS:    install in GNUstep tree"; 
77   fi
78
79   if test $ARG_WITH_DEBUG = 1; then 
80     echo "  debug:  yes";
81   else
82     echo "  debug:  no";
83   fi
84   if test $ARG_WITH_STRIP = 1; then 
85     echo "  strip:  yes";
86   else
87     echo "  strip:  no";
88   fi
89   
90   echo "  prefix: $ARG_PREFIX"
91   echo "  gstep:  $ARG_GSMAKE"
92   echo "  config: $ARG_CFGMAKE"
93   echo "  script: $DARG_GNUSTEP_SH"
94   echo ""
95 }
96
97 warnOnFHSPrefix() {
98   cat <<_ACEOFWARN
99 Warning: you are configuring for a non standard FHS style prefix.
100          prefix: $ARG_PREFIX
101
102 Some code in SOPE only looks in /usr and /usr/local for resources and is
103 therefore incompatible with arbitary install pathes.
104
105 If you want to have the flexibility of installation in arbitary pathes just
106 configure GNUstep-make and source the GNUstep.sh script prior executing tools
107 to ensure a proper environment.
108 All SOPE based code is completely relocatable when being used in a GNUstep
109 environment.
110
111 _ACEOFWARN
112 }
113
114 validateGNUstepArgs() {
115   # GNUstep make
116   if test "x$ARG_GSMAKE" = "x"; then
117     if test -f $HOME/OGoRoot/Library/Makefiles/GNUstep.sh; then
118       ARG_GSMAKE="$HOME/OGoRoot/Library/Makefiles/"
119     elif test -f $HOME/GNUstep/Library/Makefiles/GNUstep.sh; then
120       ARG_GSMAKE="$HOME/GNUstep/Library/Makefiles/"
121     elif test -f /usr/GNUstep/System/Library/Makefiles/GNUstep.sh; then
122       ARG_GSMAKE="/usr/GNUstep/System/Library/Makefiles/"
123     else
124       echo "error: please specify a GNUstep make tree!"
125       exit 1
126     fi
127     DARG_GNUSTEP_SH="$ARG_GSMAKE/GNUstep.sh"
128   elif test -d $ARG_GSMAKE; then
129     if test -f $ARG_GSMAKE/GNUstep.sh; then
130       DARG_GNUSTEP_SH="$ARG_GSMAKE/GNUstep.sh"
131     elif test -f $ARG_GSMAKE/Library/Makefiles/GNUstep.sh; then
132       ARG_GSMAKE="$ARG_GSMAKE/Library/Makefiles"
133       DARG_GNUSTEP_SH="$ARG_GSMAKE/GNUstep.sh"
134     else
135       echo "error: specified directory contains no GNUstep.sh: $ARG_GSMAKE"
136       exit 1
137     fi
138   else
139     echo "error: specified GNUstep make tree does not exist: $ARG_GSMAKE"
140     exit 1
141   fi
142 }
143
144 setupAppleArgs() {
145   ARG_WITH_STRIP=0
146   ARG_WITH_GNUSTEP=1
147   
148   if test "xLIBRARY_COMBO" != "apple-apple-nil"; then
149     if test "xLIBRARY_COMBO" != "apple-apple-apple"; then
150       echo "WARNING: detected unusual GNUstep setup: $LIBRARY_COMBO"
151       echo ""
152     fi
153   fi
154 }
155
156 validateArgs() {
157   # validate prefix (could be better?)
158   case "x$ARG_PREFIX" in
159     "x/usr/local"|"x/usr/local/")
160         DARG_IS_FHS=1;
161         ;;
162     "x/usr"|"x/usr/")
163         DARG_IS_FHS=1;
164         ;;
165     "x$GNUSTEP_USER_ROOT"|"x$GNUSTEP_LOCAL_ROOT"|"x$GNUSTEP_SYSTEM_ROOT")
166         DARG_IS_FHS=0;
167         ARG_WITH_GNUSTEP=1;
168         ;;
169     "x")
170         if test $ARG_WITH_GNUSTEP = 1; then
171           DARG_IS_FHS=0;
172           ARG_PREFIX="$GNUSTEP_LOCAL_ROOT"
173           if test $ARG_BEQUIET != 1; then
174             echo "Note: will install in GNUSTEP_LOCAL_ROOT: $ARG_PREFIX"
175             echo ""
176           fi
177         else
178           DARG_IS_FHS=1;
179           ARG_PREFIX="/usr/local/"
180           echo "Note: will install in default location: $ARG_PREFIX"
181           echo ""
182         fi
183         ;;
184     *)
185         if test $ARG_WITH_GNUSTEP = 1; then
186           echo "error: specified --with-gnustep, but specified prefix is not"
187           echo "       a GNUstep root: '$ARG_PREFIX'"
188           exit 1
189         else
190           if test $ARG_BEQUIET != 1; then
191             warnOnFHSPrefix;
192           fi
193           DARG_IS_FHS=1;
194         fi
195         ;;
196   esac
197   
198   if test $ARG_WITH_GNUSTEP = 1; then
199     if test $DARG_IS_FHS = 1; then
200       echo "error: configured for FHS root _and_ GNUstep tree. Choose one!"
201       exit 1
202     fi
203   fi
204 }
205
206 printGNUstepSetup() {
207   echo "GNUstep environment:"
208   echo "  system: ${GNUSTEP_SYSTEM_ROOT}"
209   echo "  local:  ${GNUSTEP_LOCAL_ROOT}"
210   echo "  user:   ${GNUSTEP_USER_ROOT}"
211   echo "  path:   ${GNUSTEP_PATHLIST}"
212   echo "  flat:   ${GNUSTEP_FLATTENED}"
213   echo "  arch:   ${GNUSTEP_HOST}"
214   echo "  combo:  ${LIBRARY_COMBO}"
215   echo ""
216 }
217
218 cfgwrite() {
219   echo "$1" >> $ARG_CFGMAKE
220 }
221
222 genConfigMake() {
223   # we ignore the following vars also patches by gstep-make:
224   #   PATH
225   #   DYLD_LIBRARY_PATH
226   #   GUILE_LOAD_PATH
227   #   CLASSPATH
228   
229   if test $ARG_BEQUIET != 1; then
230     echo "creating: $ARG_CFGMAKE"
231   fi
232   
233   echo "# GNUstep environment configuration" > $ARG_CFGMAKE
234   cfgwrite "#   created by: '$CFG_ARGS'"
235   cfgwrite ""
236   
237   cfgwrite "# Note: you can override any option as a 'make' parameter, eg:"
238   cfgwrite "#         $MAKE debug=yes"
239   cfgwrite ""
240   
241   #cfgwrite "# print on the cmdline that this file is being used"
242   #cfgwrite "all :: "
243   #cfgwrite "   @echo Local GNUstep config.make is active"
244   #cfgwrite ""
245
246   cfgwrite "SOGO_MAJOR_VERSION=0"
247   cfgwrite "SOGO_MINOR_VERSION=9"
248   cfgwrite "SOPE_MAJOR_VERSION=4"
249   cfgwrite "SOPE_MINOR_VERSION=7"
250   
251   if test $DARG_IS_FHS = 1; then
252     cfgwrite "# configured for FHS install"
253     cfgwrite "FHS_INSTALL_ROOT:=$ARG_PREFIX"
254     cfgwrite ""
255   fi
256   
257   if test $ARG_WITH_DEBUG = 1; then
258     cfgwrite "# configured to produce debugging code";
259     cfgwrite "debug:=yes"
260   else
261     cfgwrite "# configured to produce non-debugging code";
262     cfgwrite "debug:=no"
263   fi
264   cfgwrite ""
265   UNAME=`uname`
266   if [ "X${UNAME}" = "XLinux" ];then
267     UNAME=`uname -p`
268     if [ ${UNAME} = x86_64 -o ${UNAME} = sparc64 -o ${UNAME} = ppc64 ];then
269       cfgwrite "CGS_LIBDIR_NAME:=lib64"
270     else
271       cfgwrite "CGS_LIBDIR_NAME:=lib"
272     fi
273   else
274     cfgwrite "CGS_LIBDIR_NAME:=lib"
275   fi
276
277   cfgwrite "ifneq (\$(FHS_INSTALL_ROOT),)"
278   cfgwrite "CONFIGURE_FHS_INSTALL_LIBDIR:=\$(FHS_INSTALL_ROOT)/\$(CGS_LIBDIR_NAME)/"
279 #  cfgwrite "CONFIGURE_SYSTEM_LIB_DIR += -L\$(CONFIGURE_FHS_INSTALL_LIBDIR)"
280   cfgwrite "endif"
281 #  cfgwrite "CONFIGURE_SYSTEM_LIB_DIR += -L/usr/\$(CGS_LIBDIR_NAME)/"
282
283   if test $DARG_IS_FHS = 1; then
284     cfgwrite "# configured for FHS install"
285     cfgwrite "FHS_INSTALL_ROOT:=$ARG_PREFIX"
286     cfgwrite ""
287     cfgwrite "SOGO_SYSLIBDIR=\${DESTDIR}\${FHS_INSTALL_ROOT}/\${CGS_LIBDIR_NAME}"
288     cfgwrite "SOGO_LIBDIR=\${SOGO_SYSLIBDIR}/sogod-\${SOGO_MAJOR_VERSION}.\${SOGO_MINOR_VERSION}"
289     cfgwrite "SOPE_LIBDIR=\$(SOGO_SYSLIBDIR)/sope-\${SOPE_MAJOR_VERSION}.\${SOPE_MINOR_VERSION}"
290     cfgwrite "SOGO_SYSSHAREDIR=\${DESTDIR}\${FHS_INSTALL_ROOT}/share"
291     cfgwrite "SOGO_SHARED=\${SOGO_SYSSHAREDIR}/sogo-\${SOGO_MAJOR_VERSION}.\${SOGO_MINOR_VERSION}"
292     cfgwrite "SOPE_SHARED=\${SOGO_SYSSHAREDIR}/sope-\${SOPE_MAJOR_VERSION}.\${SOPE_MINOR_VERSION}"
293     cfgwrite "SOGO_TEMPLATESDIR=\${SOGO_SHARED}/templates"
294     cfgwrite "SOGO_WEBSERVERRESOURCESDIR=\${SOGO_SHARED}/www"
295     cfgwrite "SOGO_TOOLS=\${DESTDIR}\${FHS_INSTALL_ROOT}/bin"
296     cfgwrite "SOGO_ADMIN_TOOLS=\${DESTDIR}\${FHS_INSTALL_ROOT}/sbin"
297     cfgwrite "SOPE_SAXMAPPINGS=\${SOPE_SHARED}/saxmappings"
298     cfgwrite "SOPE_SAXDRIVERS=\${SOPE_LIBDIR}/saxdrivers"
299     cfgwrite "SOPE_WOXBUILDERS=\${SOPE_LIBDIR}/wox-builders"
300     cfgwrite "SOGO_TYPEMODELS=\${SOGO_SYSSHAREDIR}/ocs"
301
302     cfgwrite ""
303   else
304     cfgwrite "# configured for GNUstep install"
305     cfgwrite ""
306     cfgwrite "SOGO_SYSLIBDIR=\${DESTDIR}/\${GNUSTEP_LIBRARY}/Libraries"
307     cfgwrite "SOGO_LIBDIR=\${DESTDIR}/\${GNUSTEP_LIBRARY}/SOGo-\${SOGO_MAJOR_VERSION}.\${SOGO_MINOR_VERSION}"
308     cfgwrite "SOGO_TEMPLATESDIR=\${SOGO_LIBDIR}/Templates"
309     cfgwrite "SOGO_WEBSERVERRESOURCESDIR=\${SOGO_LIBDIR}/WebServerResources"
310     cfgwrite "SOGO_TOOLS=\${DESTDIR}/\${GNUSTEP_TOOLS}"
311     cfgwrite "SOGO_ADMIN_TOOLS=\${DESTDIR}/\${GNUSTEP_ADMIN_TOOLS}"
312     cfgwrite "SOPE_SAXMAPPINGS=\${DESTDIR}/\${GNUSTEP_LIBRARY}/SaxMappings"
313     cfgwrite "SOPE_SAXDRIVERS=\${DESTDIR}/\${GNUSTEP_LIBRARY}/SaxDrivers-\${SOPE_MAJOR_VERSION}.\${SOPE_MINOR_VERSION}"
314     cfgwrite "SOPE_WOXBUILDERS=\${DESTDIR}/\${GNUSTEP_LIBRARY}/WOxElemBuilders-\${SOPE_MAJOR_VERSION}.\${SOPE_MINOR_VERSION}"
315     cfgwrite "SOGO_TYPEMODELS=\${DESTDIR}/\${GNUSTEP_LIBRARY}/OCSTypeModels"
316   fi
317
318   if test $ARG_WITH_STRIP = 1; then
319     cfgwrite "# configured to produce stripped code";
320     cfgwrite "strip:=yes"
321   else
322     cfgwrite "# configured not to strip code";
323     cfgwrite "strip:=no"
324   fi
325   cfgwrite ""
326
327   cfgwrite "# enforce shared libraries";
328   cfgwrite "shared:=yes"
329   cfgwrite ""
330   
331   cfgwrite "# GNUstep environment variables:";
332   for i in `env | grep GNUSTEP_ | sort`; do
333     MAKE_ASSI="`echo $i | sed s/=/:=/`"
334     cfgwrite "${MAKE_ASSI}";
335   done
336   cfgwrite "LIBRARY_COMBO=$LIBRARY_COMBO"
337   cfgwrite ""
338   
339 }
340
341 checkLinking() {
342   local oldpwd=$PWD
343   local tmpdir=".configure-test-$$"
344   
345   mkdir $tmpdir
346   cd $tmpdir
347   cp ../maintenance/dummytool.m .
348   
349   tmpmake="GNUmakefile"
350   echo  >$tmpmake "include ../config.make"
351   echo >>$tmpmake "include \$(GNUSTEP_MAKEFILES)/common.make"
352   echo >>$tmpmake "TOOL_NAME           := linktest"
353   echo >>$tmpmake "linktest_OBJC_FILES := dummytool.m"
354   echo >>$tmpmake "linktest_TOOL_LIBS  += -l$1"
355   echo >>$tmpmake "SYSTEM_LIB_DIR      += ${LINK_SYSLIBDIRS}"
356   echo >>$tmpmake "include \$(GNUSTEP_MAKEFILES)/tool.make"
357   
358   $MAKE -s messages=yes -f $tmpmake linktest >out.log 2>err.log
359   LINK_RESULT=$?
360
361   if test $LINK_RESULT = 0; then
362     echo "$2 library found: $1"
363   else
364     if test "x$2" = "xrequired"; then
365       echo "failed to link $2 library: $1"
366       rm ../config.make
367       exit 1
368     else
369       echo "failed to link $2 library: $1"
370     fi
371   fi
372   
373   cd $oldpwd
374   rm -rf $tmpdir
375 }
376
377 checkDependencies() {
378   checkLinking "SaxObjC" required;
379   checkLinking "NGLdap"  required;
380 }
381
382 runIt() {
383   if test $ARG_BEQUIET != 1; then
384     printParas;
385   fi
386   
387   if test $ARG_NOCREATE = 1; then 
388     if test $ARG_BEQUIET != 1; then
389       echo "not creating the config file ...";
390     fi
391   else
392     genConfigMake;
393     #checkDependencies;
394     
395     if test -x $NGSTREAMS_DIR/configure; then
396       if test $ARG_BEQUIET != 1; then
397         echo -n "configuring NGStreams library .."
398         old="$PWD"
399         cd $NGSTREAMS_DIR
400         ./configure >$old/config-NGStreams.log
401         cd $old
402         echo ".. done (log in config-NGStreams.log)."
403       fi
404     fi
405   fi
406 }
407
408 # ******************** options ********************
409
410 extractFuncValue() {
411   VALUE="`echo "$1" | sed "s/[^=]*=//g"`"
412 }
413
414 processOption() {
415   case "x$1" in
416     "x--help"|"x-h")
417         usage;
418         ;;
419     "x--quiet"|"x--silent"|"x-q") ARG_BEQUIET=1;  ;;
420     "x--no-create"|"x-n")         ARG_NOCREATE=1; ;;
421     x--prefix=*)
422         extractFuncValue $1;
423         ARG_PREFIX="$VALUE";
424         ;;
425     x--gsmake=*)
426         extractFuncValue $1;
427         ARG_GSMAKE="$VALUE";
428         ;;
429     x--configmake=*)
430         extractFuncValue $1;
431         ARG_CFGMAKE="$VALUE";
432         ;;
433     "x--with-gnustep")
434         ARG_WITH_GNUSTEP=1
435         DARG_IS_FHS=0
436         ;;
437     "x--without-gnustep")
438         ARG_WITH_GNUSTEP=0
439         DARG_IS_FHS=1
440         ;;
441     "x--enable-debug")
442         ARG_WITH_DEBUG=1
443         ;;
444     "x--disable-debug")
445         ARG_WITH_DEBUG=0
446         ;;
447     "x--enable-strip")
448         ARG_WITH_STRIP=1
449         ;;
450     "x--disable-strip")
451         ARG_WITH_STRIP=0
452         ;;
453
454     *) echo "error: cannot process argument: $1"; exit 1; ;;
455   esac
456 }
457
458 for i in $@; do
459   processOption $i;
460 done
461
462 # load GNUstep environment
463 validateGNUstepArgs
464 # first we load the GNUstep.sh environment
465 . $DARG_GNUSTEP_SH
466 if test $ARG_BEQUIET != 1; then
467   printGNUstepSetup;
468 fi
469
470 # setup some GNUstep dependend defaults
471 if test "x$GNUSTEP_HOST_VENDOR" = "xapple"; then
472   setupAppleArgs;
473 fi
474
475 # ensure the parameters make sense
476 validateArgs
477
478 # start it
479 runIt