Fix for UBSan build
[platform/upstream/doxygen.git] / configure
1 #!/bin/sh
2 #
3 # $Id: configure,v 1.229 2005/11/09 21:17:03 dimitri Exp $
4 #
5 # Copyright (C) 1997-2012 by Dimitri van Heesch.
6
7 # Permission to use, copy, modify, and distribute this software and its
8 # documentation under the terms of the GNU General Public License is hereby 
9 # granted. No representations are made about the suitability of this software 
10 # for any purpose. It is provided "as is" without express or implied warranty.
11 # See the GNU General Public License for more details.
12
13 # Documents produced by Doxygen are derivative works derived from the
14 # input used in their production; they are not affected by this license.
15
16 # shell script to configure doxygen
17
18 doxygen_version_major=1
19 doxygen_version_minor=8
20 doxygen_version_revision=2
21
22 #NOTE: Setting version_mmn to "NO" will omit mmn info from the package.
23 doxygen_version_mmn=NO
24
25 bin_dirs=`echo $PATH | sed -e "s/:/ /g"`
26
27 f_debug=NO
28 f_shared=YES
29 f_make=NO
30 f_dot=NO
31 f_perl=NO
32 f_plf_auto=NO
33 f_prefix=/usr/local
34 f_insttool=NO
35 f_english=NO
36 f_wizard=NO
37 f_app=NO
38 f_thread=NO
39 f_flex=NO
40 f_bison=NO
41 f_langs=nl,sv,cz,fr,id,it,de,jp,je,es,fi,ru,hr,pl,pt,hu,kr,ke,ro,si,cn,no,mk,br,dk,sk,ua,gr,tw,sr,ca,lt,za,ar,fa,sc,vi,tr,eo,am
42
43 while test -n "$1";  do
44   case $1 in
45     --prefix | -prefix)
46        shift; f_prefix=$1
47        ;;
48     --docdir | -docdir)
49        shift; f_docdir=$1
50        ;;
51     --shared | -shared)
52        f_shared=YES
53        ;;
54     --static | -static)
55        f_shared=NO
56        ;;
57     --release | -release)
58        f_debug=NO
59        ;;
60     --debug | -debug)
61        f_debug=YES
62        ;;
63     --english-only | -english-only)
64        f_english=YES
65        ;;
66     --enable-langs | -enable-langs)
67        shift; f_langs=$1
68        ;;
69     --platform | -platform)
70        shift; f_platform=$1
71        ;;
72     --make | -make)
73        shift; f_make=$1
74        ;;
75     --dot | -dot)
76        shift; f_dot=$1
77        ;;
78     --perl | -perl)
79        shift; f_perl=$1
80        ;;
81     --flex | -flex)
82        shift; f_flex=$1
83        ;;
84     --bison | -bison)
85        shift; f_bison=$1
86        ;;
87     --install | -install)
88        shift; f_insttool=$1
89        ;;
90     --with-doxywizard | -with-doxywizard)
91        f_wizard=YES
92        ;;
93     --with-doxyapp | -with-doxyapp)
94        f_app=YES
95        ;;
96     -h | -help | --help)
97        f_help=y
98        ;;
99     *)
100        echo $1: unknown argument
101        f_help=y
102        f_error=y
103        ;;
104   esac
105   shift
106 done
107
108 if test "$f_help" = y; then
109   cat <<EOF
110 Usage: $0 [--help] [--shared] [--static] [--release] [--debug] 
111           [--perl name] [--flex name] [--bison name] [--make name] 
112           [--dot name] [--platform target] [--prefix dir] [--docdir dir] 
113           [--install name] [--english-only] [----enable-langs list] 
114           [--with-doxywizard] [--with-doxyapp]
115
116 Options: 
117
118   --help                Print this help
119   --shared | --static   Build using shared or static linking
120                         [default: shared]
121   --release | --debug   Build for release or debug 
122                         [default: release]
123   --perl name           Use \`name' as the name of the perl interpreter 
124                         [default: autodetect]
125   --flex name           Use \`name' as the name of the GNU lexical scanner 
126                         [default: autodetect]
127   --bison name          Use \`name' as the name of the GNU compiler generator 
128                         [default: autodetect]
129   --make name           Use \`name' as the name of the GNU make tool
130                         [default: autodetect]
131   --dot name            Use \`name' as the name of the dot tool that
132                         is part of the Graphviz package.
133                         [default: autodetect]
134   --platform target     Do not detect platform but use \`target' instead.
135                         See PLATFORMS for a list of possibilities
136   --prefix dir          Installation prefix directory (doxygen will be
137                         put in PREFIX/bin/doxygen)
138                         [default: $f_prefix]
139   --docdir dir          Documentation is installed in DOCDIR/
140                         [default: PREFIX/share/doc/packages/doxygen]
141   --install name        Use \`name' as the name of the GNU install tool
142                         [default: autodetect]
143   --english-only        Include support for English only.
144   --enable-langs list   Include support for output languages listed in list.
145                         [default: $f_langs]
146   --with-doxywizard     Build the GUI frontend for doxygen. This
147                         requires Qt 3.3.x
148   --with-doxyapp        Example showing how to embed doxygen in an application.
149
150 EOF
151   test "$f_error" = y && exit 1
152   exit 0;
153 fi
154
155 u_release=`(uname -r) 2>/dev/null` || u_release=unknown
156 u_system=`(uname -s) 2>/dev/null` || u_system=unknown
157
158 if test -z "$f_platform"; then
159   f_platforms="`cat PLATFORMS`"
160   
161   case "$u_system:$u_release" in
162     AIX*)
163       f_platform=aix-xlc
164       ;;
165     BeOS*)
166       f_platform=beos-g++
167       ;;
168     dgux:*)
169       f_platform=dgux-g++
170       ;;
171     Darwin:*)
172       f_platform=macosx-c++
173       if test "$f_insttool" = NO; then
174         f_insttool=/usr/bin/install
175       fi
176       ;;
177     FreeBSD:*)
178       f_platform=freebsd-g++
179       if test "$f_insttool" = NO; then
180         f_insttool=/usr/bin/install
181       fi
182       ;;
183     NetBSD:*)
184       f_platform=netbsd-g++
185       if test "$f_insttool" = NO; then
186         f_insttool=/usr/bin/install
187       fi
188       ;;
189     HP-UX:*)
190       f_platform=hpux-g++
191       if test "$f_insttool" = NO; then
192         f_insttool=/usr/bin/install
193       fi
194       ;;
195     IRIX64:*)
196       f_platform=irix-64
197       ;;
198     IRIX:*)
199       f_platform=irix-n32
200       ;;
201     Linux:*|GNU:*|GNU/*:*)
202       f_platform=linux-g++
203       ;;
204     NetBSD:*)
205       f_platform=netbsd-g++
206       ;;
207     OpenBSD:*)
208       f_platform=openbsd-g++
209       ;;
210     OSF1:*)
211       f_platform=osf1-g++
212       ;;
213     QNX:*)
214       f_platform=qnx-g++
215       ;;
216     *:3.2)
217       f_platform=sco-g++
218       ;;
219     SunOS:4*)
220       f_platform=sunos-g++
221       ;;
222     SunOS:5*)
223       f_platform=solaris-g++
224       if test "$f_insttool" = NO; then
225         f_insttool=/usr/bin/install
226       fi
227       ;;
228     ULTRIX:*)
229       f_platform=ultrix-g++
230       ;;
231     UNIX_SV:4.2*)
232       f_platform=unixware-g++
233       ;;
234     Cygwin:*|CYGWIN*)
235       f_platform=win32-g++
236       ;;
237     *MiNT:*)
238       f_platform=m68k-atari-mint-g++
239       ;;
240     *)
241     echo
242     echo "Your platform was not recognised by this configure script"
243     echo "Please use the -platform option to specify one of platforms"
244     echo "in this list:"
245     echo
246     for p in $f_platforms
247     do
248       echo "    $0 $* -platform $p"
249     done
250     echo
251     exit 2
252   esac 
253   echo "  Autodetected platform $f_platform... "
254   f_plf_auto=YES
255 fi
256
257 if test -z "$f_docdir"; then
258   f_docdir='$(INSTALL)/share/doc/packages/doxygen'
259 fi
260
261 if test "$f_plf_auto" = NO; then
262   echo -n "  Checking for platform $f_platform... "
263   if test '!' -d tmake/lib/$f_platform; then
264     echo "not supported!" 
265     echo
266     exit 2
267   fi
268   echo "supported"
269 fi
270
271 #- check for qt --------------------------------------------------------------
272  
273 if test "$f_wizard" = YES; then
274   if test -z "$QTDIR"; then
275     echo "  QTDIR environment variable not set!"
276     echo -n "  Checking for Qt..."
277     for d in /usr/{lib,share,qt}/{qt-4,qt4,qt,qt*,4} /usr; do
278       if test -x "$d/bin/qmake"; then
279         QTDIR=$d
280       fi
281     done
282   else
283     echo "  Detected Qt via the QTDIR environment variable..."
284     echo -n "                    "
285   fi
286   if test -z "$QTDIR"; then
287     echo "QTDIR not set and Qt not found at standard locations!"
288     echo
289     echo "Set the QTDIR environment variable such that \$QTDIR/bin/qmake exists."
290     echo "check the Qt installation instructions!"
291     exit 2
292   fi
293 fi
294    
295 # - check for make ------------------------------------------------------------
296
297 echo -n "  Checking for GNU make tool... "
298 if test "$f_make" = NO; then
299   make_names="gmake make"
300   make_dirs="$bin_dirs /usr/bin /usr/local/bin /bin /sbin"
301   make_prog=NO
302   for i in $make_names; do
303     for j in $make_dirs; do
304       if test -x "$j/$i"; then
305         if test -n "`$j/$i --version 2>/dev/null | grep GNU`"; then
306           make_prog="$j/$i"
307           break 2
308         fi
309       fi
310     done
311   done
312   f_make="$make_prog" 
313 fi
314
315 if test "$f_make" = NO; then
316   echo "not found!";
317   echo
318   exit 2
319 fi
320 echo "using $f_make"
321
322 # - check for install ------------------------------------------------------------
323
324 echo -n "  Checking for GNU install tool... "
325 if test "$f_insttool" = NO; then
326   install_names="ginstall install"
327   install_dirs="$bin_dirs /usr/bin /usr/local/bin /bin /sbin /usr/ucb"
328   install_prog=NO
329   install_found=NO
330   for i in $install_names; do
331     for j in $install_dirs; do
332       if test -x "$j/$i"; then
333         if test -n "`$j/$i --version 2>/dev/null | grep utils`"; then
334           install_found=YES
335           install_prog="$j/$i"
336           break 2
337         fi
338       fi
339     done
340   done
341   f_insttool="$install_prog" 
342 fi
343
344 if test "$f_insttool" = NO; then
345   if test "$install_found" = YES; then
346     echo;
347   else
348     echo "not found!";
349     echo
350   fi
351   echo "GNU version of install is required: this is part of the fileutils/coreutils package: "
352   echo "see http://www.gnu.org/software/fileutils/fileutils.html"
353   echo
354   exit 2
355 fi
356 echo "using $f_insttool";
357
358
359 # - check for dot ------------------------------------------------------------
360
361 echo -n "  Checking for dot (part of GraphViz)... "
362 if test "$f_dot" = NO; then
363   dot_dirs="$bin_dirs /usr/bin /usr/local/bin /bin /sbin"
364   dot_prog=NO
365   for j in $dot_dirs; do
366     if test -x "$j/dot"; then
367       dot_prog="$j/dot"
368       break 2
369     fi
370   done
371   f_dot="$dot_prog" 
372 fi
373
374 if test "$f_dot" = NO; then
375   echo "not found!";
376 else
377   echo "using $f_dot"
378 fi
379
380 # - check for perl ------------------------------------------------------------
381
382 echo -n "  Checking for perl... "
383 if test "$f_perl" = NO; then
384   perl_names="perl perl5"
385   perl_dirs="$bin_dirs /usr/bin /usr/local/bin /bin /sbin"
386   perl_prog=NO
387   perl_found=NO
388   for i in $perl_names; do
389     for j in $perl_dirs; do
390       if test -x "$j/$i"; then
391         perl_found=YES
392         if $j/$i -e 'require 5.000;' 2>/dev/null ; then
393           perl_prog="$j/$i"
394           break 2
395         fi
396       fi
397     done
398   done
399   f_perl="$perl_prog" 
400 fi
401
402 if test "$f_perl" = NO; then
403   if test "$perl_found" = YES; then
404     echo "version is too old (5.000 or higher is required)."
405   else
406     echo "not found!";
407   fi
408   echo
409   exit 2
410 fi
411 echo "using $f_perl";
412
413 # - check for flex ------------------------------------------------------------
414
415 echo -n "  Checking for flex... "
416 if test "$f_flex" = NO; then
417   flex_dirs="$bin_dirs /usr/bin /usr/local/bin /bin"
418   flex_prog=NO
419   flex_found=NO
420   for j in $flex_dirs; do
421     if test -x "$j/flex"; then
422       flex_found=YES
423       flex_prog="$j/flex"
424       break
425     fi
426   done
427   f_flex="$flex_prog" 
428 fi
429
430 if test "$f_flex" = NO; then
431   echo "not found!";
432   exit 2
433 else
434   echo "using $f_flex"
435 fi
436
437 # - check for bison ------------------------------------------------------------
438
439 echo -n "  Checking for bison... "
440 if test "$f_bison" = NO; then
441   bison_dirs="$bin_dirs /usr/bin /usr/local/bin /bin"
442   bison_prog=NO
443   bison_found=NO
444   for j in $bison_dirs; do
445     if test -x "$j/bison"; then
446       bison_found=YES
447       bison_prog="$j/bison"
448       break
449     fi
450   done
451   f_bison="$bison_prog" 
452 fi
453
454 if test "$f_bison" = NO; then
455   echo "not found!";
456   exit 2
457 else
458   echo "using $f_bison"
459 fi
460
461 # -----------------------------------------------------------------------------
462
463 #
464 # Make VERSION file
465 #
466 echo "  Creating VERSION file."
467 # Output should be something like 1.4.5-20051010
468 if test "x$doxygen_version_mmn" = "xNO"; then
469   echo "$doxygen_version_major.$doxygen_version_minor.$doxygen_version_revision" > VERSION
470 else
471   echo "$doxygen_version_major.$doxygen_version_minor.$doxygen_version_revision-$doxygen_version_mmn" > VERSION
472 fi
473
474 test -f .makeconfig && rm .makeconfig
475 test -f .tmakeconfig && rm .tmakeconfig
476
477 configPWD=`pwd`
478
479 cat > .makeconfig <<EOF
480 DOXYGEN   = $configPWD
481 TMAKEPATH = $configPWD/tmake/lib/$f_platform
482 ENV       = env TMAKEPATH=\$(TMAKEPATH)
483 TMAKE     = $configPWD/tmake/bin/tmake
484 MAKE      = $f_make
485 PERL      = $f_perl
486 RM        = rm -f
487 CP        = cp
488 VERSION   = `cat VERSION`
489 INSTALL   = $f_prefix
490 INSTTOOL  = $f_insttool
491 DOXYDOCS  = ..
492 DOCDIR    = $f_docdir
493 QTDIR     = $QTDIR
494 MAN1DIR   = share/man/man1
495 EOF
496
497 if test "$f_dot" != NO; then
498   cat >> .makeconfig <<EOF
499 HAVE_DOT  = $f_dot
500 EOF
501 fi
502
503 if test "$f_platform" = "m68k-atari-mint-g++"; then
504   cat >> .makeconfig <<EOF
505 TMAKE += -unix
506 EOF
507 fi
508
509 if test "$f_platform" = "macosx-c++"; then
510   cat >> .makeconfig <<EOF
511 MKSPECS   = -spec macx-g++
512 EOF
513 fi
514 if test "$f_platform" = "macosx-uni-c++"; then
515   cat >> .makeconfig <<EOF
516 MKSPECS   = -spec macx-g++
517 EOF
518   fi
519
520
521 # Make doxygen.spec...
522 #
523 echo "  Created doxygen.spec file, for rpm generation."
524
525 echo "%define version $doxygen_version_major.$doxygen_version_minor.$doxygen_version_revision" > spec.tmp
526 if test "$doxygen_version_mmn" = NO; then
527   echo "%define revision 1" >> spec.tmp
528   echo "%define mmn 1"      >> spec.tmp
529 else
530   echo "%define revision $doxygen_version_mmn" >> spec.tmp
531   echo "%define mmn $doxygen_version_mmn"      >> spec.tmp
532 fi
533
534 mkdir -p packages
535 mkdir -p packages/rpm
536
537 cat spec.tmp ./packages/rpm/doxygen.spec.in > ./packages/rpm/doxygen.spec
538
539 rm -f spec.tmp
540
541
542 # make .tmakeconfig
543 #
544 touch .tmakeconfig
545 if test "$f_shared" = NO; then
546   if test "$f_platform" = "osf1-cxx" -o "$f_platform" = "irix-n32"; then
547   cat >> .tmakeconfig <<EOF
548     TMAKE_LFLAGS += -non_shared
549 EOF
550   elif test "$f_platform" = "solaris-cc"; then
551   cat >> .tmakeconfig <<EOF
552     TMAKE_LFLAGS += -Bstatic
553 EOF
554   elif test "$f_platform" = "hpux-cc"; then
555   cat >> .tmakeconfig <<EOF
556     TMAKE_LFLAGS += -noshared
557 EOF
558   else
559   cat >> .tmakeconfig <<EOF
560     TMAKE_LFLAGS += -static
561 EOF
562   fi
563 fi
564 if test "$f_platform" = "hpux-g++" -o "$f_platform" = "linux-g++"; then
565   cat >> .tmakeconfig <<EOF
566     TMAKE_CXXFLAGS += -D_LARGEFILE_SOURCE
567 EOF
568 fi
569 if test "$f_platform" = "macosx-uni-c++"; then
570   if test -n "`ls /Developer/SDKs/MacOSX10.*.sdk 2>/dev/null`"; then
571     mac_sdk=MacOSX10.4u.sdk
572   fi
573   if test -n "`ls /Developer/SDKs/MacOSX10.5*.sdk 2>/dev/null`"; then
574     mac_sdk=MacOSX10.5.sdk
575   fi
576   if test -n $mac_sdk; then
577   cat >> .tmakeconfig <<EOF
578     TMAKE_CFLAGS   += -isysroot /Developer/SDKs/$mac_sdk
579     TMAKE_CXXFLAGS += -isysroot /Developer/SDKs/$mac_sdk
580     TMAKE_LFLAGS   += -Wl,-syslibroot,/Developer/SDKs/$mac_sdk
581 EOF
582   fi
583 fi
584 if test "$f_wizard" = YES; then
585   cat >> .tmakeconfig <<EOF
586 TMAKE_MOC = $QTDIR/bin/moc
587 EOF
588 fi
589
590 if test "$f_english" = YES; then
591   cat >> .tmakeconfig <<EOF
592 TMAKE_CXXFLAGS += -DENGLISH_ONLY
593 EOF
594 fi
595
596 f_inmakefiles="Makefile.in qtools/Makefile.in src/Makefile.in examples/Makefile.in doc/Makefile.in addon/doxywizard/Makefile.in addon/doxmlparser/src/Makefile.in addon/doxmlparser/test/Makefile.in addon/doxmlparser/examples/metrics/Makefile.in libmd5/Makefile.in addon/doxyapp/Makefile.in"
597
598 for i in $f_inmakefiles ; do
599      SRC=$i
600      DST=`echo $i|sed 's%\(.*\).in$%\1%'`
601      TIME=`date`
602      cat > $DST <<EOF
603 #
604 # This file was generated from `basename $i` on $TIME
605 #
606
607 EOF
608      cat .makeconfig >> $DST
609      if test $i = Makefile.in; then
610        echo "" >> $DST
611        echo "all: src/version.cpp " >> $DST
612        echo "   \$(MAKE) -C qtools" >> $DST
613        echo "   \$(MAKE) -C libmd5" >> $DST
614        echo "   \$(MAKE) -C src" >> $DST
615        if test $f_wizard = YES; then
616          echo " \$(MAKE) MAN1DIR=\$(MAN1DIR) -C addon/doxywizard" >> $DST
617        fi
618        if test $f_app = YES; then
619          echo " \$(MAKE) -C addon/doxyapp" >> $DST
620        fi
621        echo "" >> $DST
622        echo "doxywizard_install:" >> $DST
623        if test $f_wizard = YES; then
624          echo " \$(MAKE) MAN1DIR=\$(MAN1DIR) -C addon/doxywizard install" >> $DST
625        fi
626        echo "" >> $DST
627      fi
628      if test $f_wizard = YES; then
629        sed -e "s/%%WITHDOXYWIZARD%% /--with doxywizard /g" $SRC >> $DST
630      else
631        sed -e "s/%%WITHDOXYWIZARD%% //g" $SRC >> $DST
632      fi
633      echo "  Created $DST from $SRC..."
634 done
635
636 cat src/libdoxycfg.t.in | sed -e "s|%%FLEX%%|$f_flex|g" -e "s|%%BISON%%|$f_bison|g" > src/libdoxycfg.t
637 cat src/libdoxygen.t.in | sed -e "s|%%FLEX%%|$f_flex|g" -e "s|%%BISON%%|$f_bison|g" > src/libdoxygen.t
638
639 f_inprofiles="qtools/qtools.pro.in src/libdoxygen.pro.in src/libdoxycfg.pro.in src/doxygen.pro.in addon/doxywizard/doxywizard.pro.in addon/doxmlparser/src/doxmlparser.pro.in addon/doxmlparser/test/xmlparse.pro.in addon/doxmlparser/examples/metrics/metrics.pro.in libmd5/libmd5.pro.in addon/doxyapp/doxyapp.pro.in" 
640
641 for i in $f_inprofiles ; do
642      SRC=$i
643      DST=`echo $i|sed 's%\(.*\).in$%\1%'`
644      TIME=`date`
645      cat > $DST <<EOF
646 #
647 # This file was generated from `basename $i` on $TIME
648 #
649
650 EOF
651      if test "$f_debug" = NO; then
652        realopts="release"
653      else
654        realopts="debug"
655      fi
656      #if test "$f_thread" = YES; then
657      #  realopts="$realopts thread"
658      #fi
659      cat $SRC .tmakeconfig | sed -e "s/\$extraopts/$realopts/g" >> $DST
660      echo "  Created $DST from $SRC..."
661 done
662
663 # - generating src/lang_cfg.h 
664
665 if test -f "src/lang_cfg.h"; then
666     chmod u+w src/lang_cfg.h   # make sure file can be overwritten
667 fi
668 echo -n "  Generating src/lang_cfg.h..."
669 echo $f_langs | $f_perl -e '@l=split(/,/,<STDIN>); 
670         chomp @l; 
671         @allowed=(split(/,/,"NL,SV,CZ,FR,ID,IT,DE,JP,JE,ES,FI,RU,HR,PL,PT,HU,KR,KE,RO,SI,CN,NO,MK,BR,DK,SK,UA,GR,TW,SR,CA,LT,ZA,AR,FA,SC,VI,TR,EO,AM"));
672         foreach my $elem (@l){ 
673              $elem =~ tr/a-z/A-Z/;
674              $r=0;
675              foreach my $tst (@allowed){
676                 if ($tst eq $elem) { $r=1; last; }              
677              }      
678              if ($r!=1) { die "ERROR: Invalid language $elem was selected!\n"; } 
679              print "#define LANG_$elem\n";
680         };' > ./src/lang_cfg.h   
681 echo