source: trunk/third/tiff/configure @ 18174

Revision 18174, 46.4 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18173, which included commits to RCS files with non-trunk default branches.
  • Property svn:executable set to *
RevLine 
[18173]1#!/bin/sh
2#       $Header: /afs/dev.mit.edu/source/repository/third/tiff/configure,v 1.1.1.1 2002-12-26 02:37:26 ghudson Exp $
3#
4# Tag Image File Format (TIFF) Software
5#
6# Copyright (c) 1988-1997 Sam Leffler
7# Copyright (c) 1991-1997 Silicon Graphics, Inc.
8#
9# Permission to use, copy, modify, distribute, and sell this software and
10# its documentation for any purpose is hereby granted without fee, provided
11# that (i) the above copyright notices and this permission notice appear in
12# all copies of the software and related documentation, and (ii) the names of
13# Sam Leffler and Silicon Graphics may not be used in any advertising or
14# publicity relating to the software without the specific, prior written
15# permission of Sam Leffler and Silicon Graphics.
16#
17# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
18# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
19# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 
20#
21# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
22# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
23# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
24# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
25# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
26# OF THIS SOFTWARE.
27#
28
29# Configuration script for the TIFF Software
30
31#
32# Shell script to setup machine-dependent files in
33# preparation for building TIFF source.
34#
35
36POSIXLY_CORRECT=1; export POSIXLY_CORRECT       # disable GNU extensions
37
38QUIET=no                                # suppress messages to tty
39NONINTERACTIVE=no                       # control prompting of config params
40SITE=                                   # dir where config.site is located
41TARGET=                                 # target system identity
42SRCDIR=                                 # dir where source is located
43
44#
45# Setup general configuration parameters.
46#
47PREFIX=/usr/local                       # root of installation
48EPREFIX=${PREFIX}
49DIRS_LIBINC=                            # dirs to search for ancillary includes
50DIR_JPEGLIB=                            # dir for IJG -ljpeg
51DIR_GZLIB=                              # dir for zlib -lgz
52DSO=auto                                # auto-enable DSO support
53LIBCOPTS=                               # library-specific C-compiler options
54JPEG=no                                 # configure JPEG support
55ZIP=no                                  # configure ZIP/Deflate support
56PORT=auto                               # enable portability emulations
57HTML=no                                 # install HTML documentation
58LIBGL=auto                              # auto-enable build of SGI -lgl apps
59LIBIMAGE=auto                           # auto-enable build of SGI -limage apps
60: ${CC=}                                # name of C compiler to use
61: ${CCOMPILER=}                         # full pathname of C compiler
62: ${OPTIMIZER=-O}                       # Optimization flag
63: ${ENVOPTS=}                           # CC opts for ANSI C compilation
64: ${MAKE=make}                          # make to use
65
66# screws up the test of `-f -'
67: ${MAKEFLAGS=}                         # unset MAKEFLAGS
68RM="rm -f"
69
70#
71# Error diagnostics that should go to the terminal are
72# done with this interface (or cat).
73#
74bitch()
75{
76    echo "configure: $@" 1>&2
77}
78
79#
80# This is the preferred interface for
81# configure to terminate abnormally.
82#
83boom()
84{
85    bitch ""
86    bitch "Unrecoverable error!  Once you've corrected the problem rerun this script."
87    kill -1 $$                          # use kill so trap handler is called
88}
89
90usage()
91{
92    cat<<'EOF'
93Usage: configure [options] [host]
94Options: [defaults in brackets after descriptions]
95  --help                  print this message
96  --quiet                 do not print `Using ...' messages
97  --verbose               opposite of --quiet
98  --noninteractive        don't ask any questions
99  --version               print the version of autoconf that created configure
100  --prefix=PREFIX         root of installation [PREFIX=/usr/local]
101  --exec-prefix=EPREFIX   root of installation [EPREFIX=PREFIX]
102  --target=TARGET         configure for TARGET [TARGET=HOST]
103  --srcdir=DIR            find the sources in DIR [configure dir or ..]
104  --with-PARAM[=ARG]      set configuration PARAM [ARG=yes]
105EOF
106}
107
108#
109# Crack command line arguments.  We purposely
110# use syntax and options that are compatible
111# with GNU autoconf.
112#
113ac_prev=
114for ac_option
115do
116    if [ -n "$ac_prev" ]; then          # assign the argument to previous option
117        eval "$ac_prev=\$ac_option"
118        ac_prev=
119        continue
120    fi
121    case "$ac_option" in                # collect optional argument
122    -*=*)       ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'`;;
123    *)          ac_optarg=;;
124    esac
125    case "$ac_option" in
126    -with-*|--with-*)
127        ac_with=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
128        # Reject names that are not valid shell variable names.
129        if [ -n "`echo $ac_with| sed 's/[-_a-zA-Z0-9]//g'`" ]; then
130            bitch "configure: $ac_with: invalid parameter name."
131            kill -1 $$
132        fi
133        ac_with=`echo $ac_with| sed 's/-/_/g'`
134        case "$ac_option" in
135        *=*)    ;;
136        *)      ac_optarg=yes;;
137        esac
138        eval "${ac_with}='$ac_optarg'"
139        ;;
140    -quiet|--quiet)             QUIET=yes;;
141    -verbose|--verbose)         QUIET=no;;
142    -noninteractive|--noninteractive) NONINTERACTIVE=yes;;
143    -site|--site)               ac_prev=SITE;;
144    -site=*|--site=*)           SITE="$ac_optarg";;
145    -srcdir|--srcdir)           ac_prev=SRCDIR;;
146    -srcdir=*|--srcdir=*)       SRCDIR="$ac_optarg";;
147    --exec-prefix)              ac_prev=EPREFIX;;
148    --exec-prefix=*)            EPREFIX="$ac_optarg" ;;
149    --prefix)                   ac_prev=PREFIX;;
150    --prefix=*)                 PREFIX="$ac_optarg";
151                                EPREFIX=${PREFIX} ;;
152    -target|--target)           ac_prev=TARGET;;
153    -target=*|--target=*)       TARGET="$ac_optarg" ;;
154    -version|--version)
155        echo "This is TIFF configure $Revision: 1.1.1.1 $"
156        exit 0
157        ;;
158    -help|--help)               usage; exit 0;;
159    -*)
160        bitch "configure: $ac_option: invalid option; use -help for usage."
161        kill -1 $$
162        ;;
163    *)
164        if [ x"$TARGET" != x ]; then
165            bitch "configure: Can only configure for one target at a time."
166            kill -1 $$
167        fi
168        TARGET="$ac_option"
169        ;;
170    esac
171done
172
173DIR_BIN=${EPREFIX}/bin          # destination for applications
174DIR_LIB=${EPREFIX}/lib          # destination for library
175DIR_INC=${PREFIX}/include               # destination for include files
176DIR_HTML=${PREFIX}/doc/libtiff          # destination for HTML files
177
178if [ -n "$ac_prev" ]; then
179    bitch "configure: missing argument to --`echo $ac_prev | sed 's/_/-/g'`"
180    kill -1 $$
181fi
182
183#
184# Locate source directory by looking for the VERSION file.
185# The directory must either be specified through the
186# environment or be located in the current directory or a
187# parent of the current directory.
188#
189test "$SRCDIR" || {
190    configure=$0
191    # NB: don't use dirname since it may not exist
192    SRCDIR=`echo $configure | sed 's;/[^/][^/]*$;;'`
193    if [ @"$SRCDIR" = @"$configure" ]; then
194        SRCDIR=.
195    fi
196    while [ ! -r $SRCDIR/VERSION ]; do
197        # strip last directory from pathname
198        newdir=`echo $SRCDIR | sed 's;/[^/]*$;;'`
199        if [ -z "$newdir" ] || [ "$newdir" = $SRCDIR ]; then
200            break;
201        fi
202        SRCDIR=$newdir
203    done
204}
205if [ ! -r $SRCDIR/VERSION ]; then
206    bitch "Cannot locate sources in $SRCDIR."
207    kill -1 $$
208fi
209SRCDIR=`echo "$SRCDIR" | sed 's;\([^/]\)/*$;\1;'`
210
211if [ -r ${SRCDIR}/tif_version.c ] ; then
212    SRCDIR_IS_LIBTIFF=yes
213    PORTDOTH=port.h
214else
215    SRCDIR_IS_LIBTIFF=no
216    PORTDOTH=libtiff/port.h
217fi
218
219#
220# Descriptor usage:
221# 1: ???
222# 2: errors that should be seen even if we're in the background.
223# 3: [stdout from test runs]
224# 4: verbose-style messages (Using ...)
225# 5: compiler stderr when running tests
226#
227if [ $QUIET = yes ]; then
228    exec 4>/dev/null                    # chuck messages
229else
230    exec 4>&1                           # messages got to stdout
231fi
232exec 5>./config.log                     # compiler messages and the like
233
234capture()
235{
236    (eval "set -x; $*") >&5 2>&1
237    return
238}
239captureX()
240{
241    (eval "set -x; $*") 2>&5
242    return
243}
244
245date >&5
246echo Running "$0" with arguments: "$@" >&5
247
248cat 1>&5 <<'EOF'
249
250This file contains information that is captured from running the configure
251script.  Lines that begin with a "+" are command lines echoed by the
252shell.  Other lines are the output of commands; usually the contents of
253test case files or the output from compilers.  If configure does the
254wrong thing, you can use the information captured here to aid in debugging.
255
256EOF
257
258VERSIONFILE=$SRCDIR/VERSION
259DATE=`date`
260
261eval `cat $VERSIONFILE |  sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\(.*\)/DIST_MAJOR=\1; DIST_MINOR=\2; DIST_POINT=\3/'`
262VERSION="v${DIST_MAJOR}.${DIST_MINOR}.${DIST_POINT}"
263
264RELEASE=`cat $VERSIONFILE |  sed -e 's/[0-9 \.]//g'`
265Note()
266{
267    echo "$@" 1>&4
268}
269
270Note ""
271if [ $SRCDIR_IS_LIBTIFF = yes ] ; then
272  Note "Configuring TIFF Software (library only) $VERSION"
273else
274  Note "Configuring TIFF Software $VERSION"
275fi
276
277Note ""
278Note "If configure does the wrong thing, check the file config.log for"
279Note "information that may help you understand what went wrong."
280Note ""
281
282#
283# Read site and local configuration parameters.
284#
285if [ -f $SITE/config.site ]; then
286    Note "Reading site-wide parameters from $SITE/config.site."
287    . $SITE/config.site
288    capture . $SITE/config.site
289elif [ -f $SRCDIR/config.site ]; then
290    Note "Reading site-wide parameters from $SRCDIR/config.site."
291    . $SRCDIR/config.site
292    capture . $SRCDIR/config.site
293fi
294if [ -f config.local ]; then
295    Note "Reading local parameters from config.local."
296    . ./config.local
297    capture . ./config.local
298elif [ -f $SRCDIR/config.local ]; then
299    Note "Reading local parameters from $SRCDIR/config.local."
300    . $SRCDIR/config.local
301    capture . $SRCDIR/config.local
302fi
303
304#
305# Emulate old-style settups...
306#
307test -z "${DIR_JPEG-}"  || {
308    DIRS_LIBINC="${DIRS_LIBINC} ${DIR_JPEG}"
309    DIR_JPEGLIB="${DIR_JPEG}"
310}
311test -z "${DIR_LIBGZ-}" || {
312    DIRS_LIBINC="${DIRS_LIBINC} ${DIR_LIBGZ}"
313    DIR_GZLIB="${DIR_LIBGZ}"
314}
315
316identifyTarget()
317{
318    random=`date | awk '{print $4}' | sed -e 's/.*://'` 2>/dev/null
319    case "$random" in
320    *0) Note "Wow, you've got a $1 system!";;
321    *1) Note "Hmm, looks like a $1 system.";;
322    *2) Note "Oh no, not another $1 system...";;
323    *3) Note "Well I'll be, a $1 system.";;
324    *4) Note "Fee, fie, foe, this smells like a $1 system.";;
325    *5) Note "Gosh, aren't you lucky to have a $1 system!";;
326    *6) Note "YOW!!  Did something bad happen or am I on a $1 system?";;
327    *7) Note "Do they really still make $1 systems?!";;
328    *8) Note "I'm always happy to encounter another $1 system.";;
329    *9) Note "Here we are again, this time on a $1 system.";;
330esac
331}
332
333#
334# If no target is specified, try to deduce the system.
335# We use the GNU scripts for guessing and canonicalizing
336# the system identification, if available.
337#
338if [ -z "$TARGET" ]; then
339    test -f $SRCDIR/config.guess && TARGET=`sh $SRCDIR/config.guess` 2>/dev/null
340    if [ -z "$TARGET" ]; then
341        bitch "Sorry, no target specified on the command line and I don't seem"
342        bitch "to have the GNU config.guess script that is used to deduce your"
343        bitch "system type."
344        kill -1 $$
345    fi
346    identifyTarget $TARGET
347elif [ -f $SRCDIR/config.sub ]; then
348    TARGET=`sh $SRCDIR/config.sub "$TARGET"`
349else
350    Note "Warning, I don't seem to have the GNU config.sub script to canonicalize"
351    Note "your target specification; this may cause problems later on..."
352fi
353if [ -z "${FILLORDER-}" ]; then
354    #
355    # Host bit order within a word.
356    #
357    case $TARGET in
358    mips-dec-*) FILLORDER=LSB2MSB;;
359    i[345]86-*) FILLORDER=LSB2MSB;;
360    *)          FILLORDER=MSB2LSB;;
361    esac
362fi
363
364#
365# Find the full pathname of a file
366# using the specified test operation.
367#
368findThing()
369{
370    t="$1"; app="$2"; path="$3";
371    case "$app" in
372    /*) eval "$t" "$app" && { echo "$app"; return; };;
373    esac
374    (IFS=:
375    for i in $path; do
376        eval "$t" "$i/$app" && { echo "$i/$app"; return 0; }
377    done
378    return 1
379    )
380}
381
382#
383# Find the full pathname of a plain file.
384#
385findFile()
386{
387    findThing "test -f" "$1" "$2"
388}
389
390#
391# Find the full pathname of an executable.
392#
393findApp()
394{
395    findThing "test -x" $1 $2
396}
397
398#
399# Find the full pathname of an executable;
400# supply a default if nothing is found.
401#
402findAppDef()
403{
404    app=$1; path=$2; def=$3
405    case $app in
406    /*) test -x $app && { echo $app; return; };;
407    esac
408    IFS=:
409    for i in $path; do
410        test -x $i/$app && { echo $i/$app; return; }
411    done
412    echo $def
413}
414
415#
416# Find the full pathname of a header file; in search-path $DIRS_LIBINC
417#
418findHeader()
419{
420    case "$1" in
421    /*) echo "$1"; return ;;
422    esac
423    for i in ${DIRS_LIBINC} /usr/include; do
424        test -r $i/$1 && {
425            case "$i" in
426            /*) echo "$i/$1"; return ;;
427            esac
428            if [ $SRCDIR_IS_LIBTIFF = yes ]; then
429                echo "$i/$1";
430            else
431                echo "../$i/$1";
432            fi
433            return;
434        }
435    done
436}
437
438#
439# Locate a C compiler that satisfies our needs (using assorted heuristics).
440#
441JUNK="
442    a.out
443    confsed
444    conftestmmap
445    confx confy
446    confMakefile
447    core
448    dummy
449    dummy.a
450    dummy.c
451    dummy.o
452    foo
453    so_locations
454    t.c
455    t.o
456    t
457    xMakedepend
458    xdefs
459    xgnu.c
460    xmakeinc
461    xport.h
462"
463trap "$RM \$JUNK; exit 1" 1 2 15
464
465$RM $JUNK
466
467cat>xgnu.c<<EOF
468#ifdef __GNUC__
469yes;
470#endif
471EOF
472
473#
474# Check if the specified compiler is from GNU
475#
476isGNU()
477{
478    capture "cat xgnu.c; ($1 -E xgnu.c 2>&5 | egrep yes)"
479}
480
481#
482# NB: use ANSI C prototype to weed out non-ANSI compilers.
483#
484cat>dummy.c<<EOF
485main(int argc, char* argv) { exit(0); }
486EOF
487
488checkCompiler()
489{
490    compiler=$1
491    if isGNU $compiler; then
492        ISGCC=yes
493    else
494        ISGCC=no
495    fi
496    #
497    # Guess special options needed to get an
498    # ANSI C compiler and/or similar.  Must
499    # be combined with above checks so we only
500    # select an ANSI C compiler.
501    #
502    if [ -z "${ENVOPTS-}" ]; then
503        case $ISGCC-$TARGET in
504        no-*-irix*)     C_ANSI="-ansi";;
505        no-*-hp*)       C_ANSI="-D_HPUX_SOURCE";;
506        no-*-apollo-*)  C_ANSI="-A nansi";;
507        no-*-aix*)      C_ANSI="-Dunix -qlanglvl=ansi -qsrcmsg -qmaxmem=8192";;
508        *-sco*)         C_ANSI="-Dsco";;
509        esac
510    else
511        C_ANSI="$ENVOPTS"
512    fi
513    $RM dummy dummy.o
514    capture $compiler -o dummy ${C_ANSI} dummy.c && {
515        CC=$compiler;
516        test -z "${CCOMPILER-}" && CCOMPILER=`findApp $compiler $PATH`
517        test -z "${ENVOPTS-}"   && ENVOPTS="${C_ANSI-}"
518        return 0
519    }
520    return 1
521}
522
523CCtested=
524capture cat dummy.c
525if [ -z "${CC-}" ]; then
526    CCOMPILER=
527    for i in gcc cc ncc dcc xlc c89 gcc2; do
528        CCtested="$CCtested $i"
529        checkCompiler $i && break
530    done
531else
532    CCtested="$CCtested $CC"
533    checkCompiler $CC
534fi
535if [ -z "$CCOMPILER" ]; then
536    cat<<EOF
537
538Cannot locate a working ANSI C compiler.
539
540We attempted to compile the following test program:
541
542----------------------------------------------------------
543EOF
544    cat dummy.c
545    cat<<EOF
546----------------------------------------------------------
547
548with these compilers:
549
550    $CCtested
551
552but none of them were successful.
553
554If your compiler is in a non-standard location, you can specify its
555location in several ways:
556
557    o set the environment variable CC
558    o create a config.local or config.site file that includes a
559      definition for CC
560    o supply it on the command line using -with-CC=<pathname>
561
562If command line options are required for ANSI C compilation, set the
563ENVOPTS parameter to these options in a similar way (either through
564an environment variable or config.local/config.site) and then rerun
565this script.
566EOF
567    boom
568fi
569Note "Using $CCOMPILER for a C compiler (use -with-CC=compilername to override)."
570
571test "$ENVOPTS" && {
572    Note "Using $ENVOPTS to get the appropriate compilation environment."
573}
574
575if [ ${ISGCC} = yes ] ; then
576    GCCversion="`${CCOMPILER} -v 2>&1 | \
577        sed -n -e '/version/s/.* \([0-9]*\)\.\([0-9]*\).\([0-9]*\)/\1.\2.\3/p'`"
578fi
579
580
581CheckForGandO()
582{
583   f=$1
584   if test -s $f; then
585        capture grep -i \(error\|warning\) $f || return 1
586    fi
587    return 0
588}
589
590if [ -z "${GCOPTS-}" ]; then
591    if capture $CCOMPILER $ENVOPTS -g -c dummy.c; then
592        Note "Looks like $CCOMPILER supports the -g option."
593        # NB: cannot use captureX here 'cuz we lose stderr
594        if $CCOMPILER $ENVOPTS -c -g $OPTIMIZER dummy.c >t 2>&1 && CheckForGandO t; then
595            GCOPTS="-g"
596        else
597            Note "... but not together with the $OPTIMIZER option, not using it."
598            GCOPTS=
599        fi
600    else
601        GCOPTS=
602    fi
603fi
604if [ ! -z "${GCOPTS}" ]; then
605    Note "Using \"$GCOPTS\" for C compiler options."
606fi
607
608#
609# Verify that $MAKE is accessible
610#
611PATHMAKE=`findApp ${MAKE} $PATH`
612if [ "$PATHMAKE" ]; then
613    Note "Using $PATHMAKE to configure the software."
614    (echo 'all:') | ${MAKE} -f - all >/dev/null 2>&5 || {
615        cat<<EOF
616
617Something is wrong with "$MAKE" or $MAKE does not accept Makefiles
618from stdin with "-f -".  If you have MAKE set in your environment,
619verify it points to the right program you want to" use to build this
620software.  Otherwise, verify that you have the make program installed
621somewhere on your system and set the MAKE environment variable to the
622pathname of the program.
623EOF
624        boom
625    }
626else
627    cat<<EOF
628No $MAKE located in the search path.
629
630There was no $MAKE program in the restricted search used by this script
631If $MAKE is in a non-standard location set the MAKE environment variable
632to the pathname of the appropriate program.
633EOF
634    boom
635fi
636
637# Find sh (likely /bin/sh or /usr/bin/sh), and put in SCRIPT_SH
638
639test -z "${SCRIPT_SH-}" && SCRIPT_SH=`findAppDef sh $PATH sh`
640
641#
642# Check whether or not $MAKE automatically sets MAKE
643# in the Makefiles.  If not, we add an explicit define
644# for places where recursive calls are made.
645#
646if [ -z "${SETMAKE-}" ]; then
647    if (sed "s;@SHELL@;$SCRIPT_SH;" <<'EOF'
648SHELL=@SHELL@
649all:
650        @if [ -n "${MAKE}" ] ; then echo "make sets make"  ; fi
651EOF
652) | $MAKE -f - | grep "make sets make" > /dev/null ; then
653        SETMAKE=
654    else
655        Note "Looks like $MAKE does not setup MAKE in Makefiles, will compensate."
656        SETMAKE="MAKE   = ${MAKE}"
657    fi
658fi
659
660test -z "${AR-}" && AR=`findApp ar $PATH`
661if [ -z "$AR" ]; then
662    Note "*** Warning, could not locate a suitable ar command; using a default."
663    AR=ar
664fi
665test -z "${AROPTS-}" && AROPTS=rc
666test -z "${RANLIB-}" && RANLIB=`findApp ranlib $PATH`
667if [ -z "$RANLIB" ]; then
668    Note "Warning, no ranlib, assuming it's not needed."
669    RANLIB=":"
670    $RM dummy.a
671    if $AR rcs dummy.a >/dev/null 2>&1; then
672       AROPTS=crs
673       Note "Looks like ar has an s option to build symbol tables."
674    fi
675fi
676
677#
678# runMake target rules ...
679#
680runMakeX()
681{
682    target="$1"; shift
683    $RM $target
684    (echo SRCDIR=.
685       for i in "$@"; do
686          echo "$i";
687       done
688    )>confMakefile
689    captureX ${MAKE} -f confMakefile $target
690    return
691}
692runMake()
693{
694    runMakeX "$@" >&5
695    return
696}
697
698#
699# Look for a library using a known (unique) function.
700#
701CheckForLibrary()
702{
703    f=$1; shift
704    libs="$@";
705    cat>t.c<<EOF
706int t() { $f(); return 0; }
707int main(){ t(); return 0; }
708EOF
709    runMake t "t:; ${CCOMPILER} ${ENVOPTS} t.c $libs"
710}
711
712#
713# Look for an include file.
714#
715CheckForIncludeFile()
716{
717    (for i do
718        echo "#include \"$i\""
719     done)>t.c
720    runMake t "t:; ${CCOMPILER} ${ENVOPTS} -E t.c"
721}
722
723#
724# Figure out if certain system-specific interfaces are
725# supported.  We craft a port.h file that has external
726# declarations for missing routines that are required by
727# the system and modify defs to reflect which optional
728# interfaces are supported.
729#
730
731EmitCPlusPlusPrologue()
732{
733    echo '/*'
734    echo ' * Warning, this file was automatically created by the TIFF configure script'
735    echo ' * VERSION:   ' $VERSION
736    echo ' * RELEASE:   ' $RELEASE
737    echo ' * DATE:      ' $DATE
738    echo ' * TARGET:    ' $TARGET
739    if [ $ISGCC = yes ]; then
740        echo ' * CCOMPILER:     ' ${CCOMPILER}-${GCCversion}
741    else
742        echo ' * CCOMPILER:     ' $CCOMPILER
743    fi
744    echo ' */'
745    echo "#ifndef $1"
746    echo "#define $1 1"
747    echo '#ifdef __cplusplus'
748    echo 'extern "C" {'
749    echo '#endif'
750}
751
752EmitCPlusPlusEpilogue()
753{
754    echo '#ifdef __cplusplus'
755    echo '}'
756    echo '#endif'
757    echo '#endif'
758}
759
760#
761# Look for a function in one of the standard libraries
762# or one of the machine-dependent libraries selected above.
763#
764CheckForFunc()
765{
766    echo "extern int $1(); main(){$1();exit(0);}" >t.c
767    runMake t "t:; ${CCOMPILER} ${ENVOPTS} t.c ${MACHDEPLIBS}"
768}
769
770#
771# Verify that we have -lm.  Darwin (for instance) does not.  Add to
772# MACHDEPLIBS if required.
773#
774
775if [ -z "${MACHDEPLIBS-}" ]; then
776    MACHDEPLIBS=""
777    if CheckForFunc cos ; then
778        echo "Leaving MACHDEPLIBS empty, apparently you don't need -lm."
779    else
780        MACHDEPLIBS="-lm"
781        echo "Defaulting MACHDEPLIBS to -lm."
782    fi
783fi
784
785#
786# Look for a function declaration in system include files.
787#
788AddFuncDecl()
789{
790    echo "$2";
791    Note "... add function prototype for $1"
792}
793CheckForFuncDecl()
794{
795    f=$1; shift
796    (for i do
797        echo "#include \"$i\""
798     done)>t.c
799    capture cat t.c
800    runMakeX t "t:; ${CCOMPILER} ${ENVOPTS} -E t.c" |\
801     awk '{while($0~/[,(][ \t]*$/){printf"%s",$0;getline}print}' |\
802     grep "$f[ ]*(.*)" >&5
803    return
804}
805CheckFuncDecl()
806{
807    f=$1; shift
808    decl=$1; shift
809    CheckForFuncDecl "$f" "$@" || AddFuncDecl "$f" "$decl"
810}
811
812#
813# Look for a variable declaration in system include files.
814#
815CheckForVarDecl()
816{
817    v="$1"; shift
818    (for i do
819        echo "#include \"$i\""
820     done)>t.c
821    capture cat t.c
822    runMakeX t "t:; ${CCOMPILER} ${ENVOPTS} -E t.c" | grep "$v" >&5
823    return
824}
825CheckVarDecl()
826{
827    v="$1"; shift
828    decl="$1"; shift
829    CheckForVarDecl "$v" "$@" || \
830        (echo "$decl"; Note "... add declaration $decl")
831}
832
833#
834# Look for a #define in system include files.
835#
836AddDefine()
837{
838   echo '#ifndef' $1
839   echo '#define' "$2"
840   echo '#endif'
841   Note '... add #define for' "$1"
842}
843CheckForDefine()
844{
845    def=$1; shift
846    (for i do
847        echo "#include \"$i\""
848     done
849     echo "#ifdef $def"
850     echo "FOUND();"
851     echo "#endif"
852    )>t.c
853    capture cat t.c
854    runMakeX t "t:; ${CCOMPILER} ${ENVOPTS} -E t.c" | grep FOUND >&5
855}
856CheckDefine()
857{
858    def=$1; shift
859    decl=$1; shift
860    CheckForDefine "$def" "$@" || AddDefine "$def" "$decl"
861}
862
863CheckForMMAP()
864{
865    if CheckForFunc getpagesize; then
866        cat>t.c<<'EOF'
867/* this was lifted from GNU autoconf */
868/* Thanks to Mike Haertel and Jim Avera for this test. */
869#include <sys/types.h>
870#include <fcntl.h>
871#include <sys/mman.h>
872EOF
873    else
874        cat>t.c<<'EOF'
875/* this was lifted from GNU autoconf */
876/* Thanks to Mike Haertel and Jim Avera for this test. */
877#include <sys/types.h>
878#include <fcntl.h>
879#include <sys/mman.h>
880
881#ifdef BSD
882# ifndef BSD4_1
883#  define HAVE_GETPAGESIZE
884# endif
885#endif
886
887#ifndef HAVE_GETPAGESIZE
888# include <sys/param.h>
889# ifdef EXEC_PAGESIZE
890#  define getpagesize() EXEC_PAGESIZE
891# else
892#  ifdef NBPG
893#   define getpagesize() NBPG * CLSIZE
894#   ifndef CLSIZE
895#    define CLSIZE 1
896#   endif
897#  else
898#   ifdef NBPC
899#    define getpagesize() NBPC
900#   else
901#    define getpagesize() PAGESIZE /* SVR4 */
902#   endif
903#  endif
904# endif
905#endif
906EOF
907    fi
908cat>>t.c<<'EOF'
909#if defined(__osf__) || defined(_AIX)
910# define valloc malloc
911#endif
912char *valloc(), *malloc();
913
914int
915main()
916{
917  char *buf1, *buf2, *buf3;
918  int i = getpagesize(), j;
919  int i2 = getpagesize()*2;
920  int fd;
921
922  buf1 = (char *)valloc(i2);
923  buf3 = (char *)malloc(i2);
924  for (j = 0; j < i2; ++j)
925    *(buf1 + j) = rand();
926  fd = open("conftestmmap", O_CREAT | O_RDWR, 0666);
927  write(fd, buf1, i2);
928  buf2 = mmap(0, i, PROT_READ|PROT_WRITE, MAP_VARIABLE|MAP_PRIVATE, fd, 0);
929  for (j = 0; j < i; ++j)
930    if (*(buf1 + j) != *(buf2 + j))
931      exit(1);
932  lseek(fd, (long)i, 0);
933  read(fd, buf2, i); /* read into mapped memory -- file should not change */
934  /* (it does in i386 SVR4.0 - Jim Avera, jima@netcom.com) */
935  lseek(fd, (long)0, 0);
936  read(fd, buf3, i2);
937  for (j = 0; j < i2; ++j)
938    if (*(buf1 + j) != *(buf3 + j))
939      exit(1);
940  exit(0);
941}
942EOF
943    capture cat t.c
944    runMake t "t:; ${CCOMPILER} ${ENVOPTS} t.c ${MACHDEPLIBS}" && ./a.out
945}
946
947CheckForBigEndian()
948{
949    echo 'main() { int one = 1; char* cp = (char*)&one; exit(*cp!=0); }'>t.c
950    capture cat t.c
951    runMake t "t:; ${CCOMPILER} ${ENVOPTS} t.c" && ./a.out
952}
953
954#
955# Check an existing port.h to see if it was created
956# for the target and compiler we are using.
957#
958CheckPortDotH()
959{
960    getConfigTag()
961    {
962        param=`grep "$1:" $2 | sed -e 's/.*:[   ]*\([^  ]*\).*/\1/'`
963    }
964    getConfigTag TARGET $PORTDOTH; target="$param"
965    getConfigTag CCOMPILER $PORTDOTH; ccompiler="$param"
966    CCOMP=$CCOMPILER
967    if [ $ISGCC = yes ]; then
968        CCOMP="${CCOMP}-${GCCversion}"
969    fi
970    test "$target" = "$TARGET" && test "$ccompiler" = "$CCOMP"
971}
972
973#
974# Built port.h based on the system and compiler setup.
975#
976BuildPortDotH()
977{
978    Note ""
979    Note "Creating $PORTDOTH with necessary definitions."
980
981    (EmitCPlusPlusPrologue _PORT_
982
983    CheckForIncludeFile sys/types.h && echo '#include <sys/types.h>'
984    CheckVarDecl off_t 'typedef long off_t;' sys/types.h stdlib.h
985    CheckVarDecl size_t 'typedef unsigned size_t;' sys/types.h stdlib.h
986    CheckVarDecl u_char 'typedef unsigned char u_char;' sys/types.h
987    CheckVarDecl u_short 'typedef unsigned short u_short;' sys/types.h
988    CheckVarDecl u_int 'typedef unsigned int u_int;' sys/types.h
989    CheckVarDecl u_long 'typedef unsigned long u_long;' sys/types.h
990
991    echo "#define HOST_FILLORDER FILLORDER_${FILLORDER}"
992    CPU=`echo $TARGET | sed 's/-.*//'`
993    Note "... using $FILLORDER bit order for your $CPU cpu"
994    if CheckForBigEndian; then
995        echo "#define HOST_BIGENDIAN    1"
996        Note "... using big-endian byte order for your $CPU cpu"
997    else
998        echo "#define HOST_BIGENDIAN    0"
999        Note "... using little-endian byte order for your $CPU cpu"
1000    fi
1001
1002    CheckForMMAP && {
1003        echo '#define HAVE_MMAP 1'
1004        Note "... configure use of mmap for memory-mapped files"
1005        CheckFuncDecl mmap \
1006            'extern void* mmap(void*, size_t, int, int, int, off_t);' sys/mman.h
1007    }
1008
1009    CheckForIncludeFile stdio.h         && echo '#include <stdio.h>'
1010    CheckForIncludeFile unistd.h        && echo '#include <unistd.h>'
1011    CheckForIncludeFile string.h        && echo '#include <string.h>'
1012    CheckForIncludeFile stdlib.h        && echo '#include <stdlib.h>'
1013    if CheckForDefine O_RDONLY fcntl.h; then
1014        echo '#include <fcntl.h>'
1015        Note "... O_RDONLY is in <fcntl.h>"
1016    elif CheckForDefine O_RDONLY sys/file.h; then
1017        echo '#include <sys/file.h>'
1018        Note "... O_RDONLY is in <sys/file.h>"
1019    else
1020        AddDefine O_RDONLY "O_RDONLY    0"
1021        AddDefine O_WRONLY "O_WRONLY    1"
1022        AddDefine O_RDWR   "O_RDWR      2"
1023    fi
1024
1025    echo 'typedef double dblparam_t;'
1026        Note "... using double for promoted floating point parameters"
1027
1028    if [ -z "${INLINE-}" ]; then
1029        if [ $ISGCC = yes ]; then
1030            echo '#ifdef __STRICT_ANSI__'
1031            echo '#define       INLINE  __inline__'
1032            echo '#else'
1033            echo '#define       INLINE  inline'
1034            echo '#endif'
1035            Note "... enabling use of inline functions"
1036        else
1037            echo '#define       INLINE'
1038            Note "... disabling use of inline functions"
1039        fi
1040    else
1041        echo "#define INLINE $INLINE"
1042        Note "... using \"$INLINE\" to control inline function usage"
1043    fi
1044
1045    echo '#define GLOBALDATA(TYPE,NAME) extern TYPE NAME'
1046
1047    CheckFuncDecl memset 'extern void* memset(void*, int, size_t);' string.h
1048    CheckFuncDecl floor 'extern double floor(double);' math.h
1049    CheckFuncDecl ceil 'extern double ceil(double);' math.h
1050    CheckFuncDecl exp 'extern double exp(double);' math.h
1051    CheckFuncDecl pow 'extern double pow(double, double);' math.h
1052    CheckFuncDecl read 'extern int read(int, const void*, unsigned int);' unistd.h
1053    CheckFuncDecl malloc 'extern void* malloc(size_t);' stdlib.h
1054    CheckFuncDecl realloc 'extern void* realloc(void*, size_t);' stdlib.h
1055    CheckFuncDecl free 'extern void free(void*);' stdlib.h
1056    EmitCPlusPlusEpilogue
1057    )>xport.h
1058    if [ $SRCDIR_IS_LIBTIFF = no -a ! -d libtiff ]; then
1059        Note "Creating libtiff directory"
1060        mkdir libtiff
1061    fi
1062    mv xport.h $PORTDOTH; chmod 444 $PORTDOTH
1063    Note "Done creating $PORTDOTH."
1064}
1065
1066if [ "$PORT" != no ] && test -f $PORTDOTH && CheckPortDotH; then
1067    Note ""
1068    Note "Using previously created $PORTDOTH."
1069else
1070    $RM xport.h t.c a.out $PORTDOTH
1071    BuildPortDotH
1072fi
1073
1074if [ "$PORT" = auto ]; then
1075    Note ""
1076    Note "Checking system libraries for functionality to emulate."
1077
1078    FUNCS="
1079        strcasecmp
1080        strtoul
1081        getopt
1082    "
1083
1084    for i in $FUNCS; do
1085        CheckForFunc $i || {
1086            Note "... emulate $i"
1087            PORTFUNCS="${PORTFUNCS-} $i.c"
1088        }
1089    done
1090    if [ "${PORTFUNCS-}" ]; then
1091        LIBPORT='../port/libport.a'
1092        PORT=yes
1093    else
1094        PORT=no
1095    fi
1096fi
1097if [ $PORT != yes ] ; then
1098   LIBPORT=
1099   PORTFUNCS=
1100fi
1101Note "Done checking system libraries."
1102
1103Note ""
1104Note "Checking for Dynamic Shared Object (DSO) support."
1105if [ "$DSO" = auto ]; then
1106    DSO=no
1107    DSOSUF_VERSION=
1108    DSOLD='${LD}'
1109    TIFFLIBREF=
1110    case $TARGET-$CC-$ISGCC in
1111    *-irix5.2*)
1112        if (findApp rld /lib:/usr/lib:$PATH) >/dev/null 2>&1; then
1113            DSOSUF=so
1114            DSOOPTS='-elf -shared -no_unresolved -all'
1115            DSO=IRIX52
1116            TIFFLIBREF='-L${DEPTH}/libtiff -rpath '${DIR_LIB}' -ltiff'
1117        fi
1118        ;;
1119    *-irix*)
1120        if (findApp rld /lib:/usr/lib:$PATH) >/dev/null 2>&1; then
1121            DSOSUF=so
1122            DSOLD="${CCOMPILER} ${ENVOPTS}"
1123            if [ $ISGCC = yes ]; then
1124               LIBCOPTS="-fpic"
1125               DSOOPTS='-shared -rdata_shared'
1126            else
1127               LIBCOPTS="-KPIC"
1128               DSOOPTS='-shared -rdata_shared -check_registry ${SRCDIR}/port/irix/so_locations -quickstart_info'
1129            fi
1130            DSO=IRIX
1131            TIFFLIBREF='-L${DEPTH}/libtiff -rpath '${DIR_LIB}' -ltiff'
1132        fi
1133        ;;
1134    *-aix*)
1135        DSOSUF=a
1136        DSOOPTS='-r'
1137        LIBCOPTS="-bM\:SRE"
1138        DSO=AIX
1139        TIFFLIBREF='-L${DEPTH}/libtiff -ltiff'
1140        ;;
1141    *-hpux*yes)
1142        DSOSUF=sl
1143        DSOLD=gcc
1144        DSOOPTS='-fpic -shared'
1145        LIBCOPTS=-fpic
1146        DSO=HPUX
1147        TIFFLIBREF="-Wl,+s,+b${DIR_LIB}"' -L${DEPTH}/libtiff -ltiff'
1148        ;;               
1149    *-hpux*)
1150        DSOSUF=sl
1151        DSOSUF_VERSION=${DIST_MAJOR}.${DIST_MINOR}${DIST_POINT}
1152        DSOOPTS='-b'
1153        LIBCOPTS="+z"
1154        DSO=HPUX
1155        TIFFLIBREF='-L$(DEPTH)/libtiff -ltiff'
1156        ;;
1157    *-solaris*)
1158        DSOSUF=so
1159        DSOOPTS='-G'
1160        if [ $ISGCC = yes ]; then
1161            LIBCOPTS="-fpic"
1162        else
1163            LIBCOPTS="-K PIC"
1164        fi
1165        DSO=SOLARIS
1166        TIFFLIBREF='-L${DEPTH}/libtiff -R'${DIR_LIB}' -ltiff'
1167        ;;
1168    *-netbsd*)
1169        DSOSUF=so.${DIST_MAJOR}.0
1170        LIBCOPTS='-fPIC'
1171        DSO=NETBSD
1172        TIFFLIBREF='-L${DEPTH}/libtiff -ltiff'
1173        ;;
1174    *-freebsd*)
1175        DSOSUF=so.${DIST_MAJOR}
1176        DSOSUF_VERSION=${DSOSUF}.${DIST_MINOR}.${DIST_POINT}
1177        LIBCOPTS='-fPIC'
1178        DSOOPTS='-shared'
1179        DSO=GNULD
1180        ;;
1181    *-openbsd*)
1182        DSOSUF=so.${DIST_MAJOR}.${DIST_MINOR}
1183        LIBCOPTS='-fpic'
1184        TIFFLIBREF='-L${DEPTH}/libtiff -ltiff'
1185        case "$TARGET" in
1186           *-openbsd[01].* | *-openbsd2.[0-7] | *-openbsd2.[0-7].*)
1187              DSO=oldOPENBSD
1188           ;;
1189           *)
1190              DSO=OPENBSD
1191              DSOLD="${CCOMPILER} ${ENVOPTS}"
1192              DSOOPTS='-shared ${LIBCOPTS}'
1193           ;;
1194        esac
1195        ;;
1196    *-darwin*)
1197        DSOSUF=${DIST_MAJOR}.dylib
1198        DSOSUF_VERSION=${DIST_MAJOR}.${DIST_MINOR}.${DIST_POINT}.dylib
1199        LIBCOPTS='-fno-common'
1200          DSOLD=gcc
1201        DSOOPTS='-dynamiclib -undefined suppress'
1202        DSO=DARWIN
1203        ;;
1204    *-linux*)
1205        DSOSUF=so.${DIST_MAJOR}
1206        DSOSUF_VERSION=${DSOSUF}.${DIST_MINOR}.${DIST_POINT}
1207        LIBCOPTS='-fPIC'
1208        DSOOPTS='-shared'
1209        DSO=GNULD
1210        ;;
1211    *-osf3*|*-osf4*)
1212        DSOSUF=so
1213        DSOOPTS='-shared'
1214        DSO=OSF
1215        ;;
1216
1217    esac
1218fi
1219if [ "$DSO" != no ]; then
1220    JUNK="$JUNK t.${DSOSUF}"
1221    #
1222    # Check to make sure the compilers process
1223    # the DSO options in the expected way.
1224    #
1225    CheckCCDSO()
1226    {
1227    $RM t.c t.o t.${DSOSUF}
1228    cat>t.c<<EOF
1229int f() { return 0; }
1230EOF
1231    capture cat t.c
1232    runMake t \
1233        "t.o:; ${CCOMPILER} ${ENVOPTS} ${LIBCOPTS} -c t.c" \
1234        "t: t.o; ${DSOLD} ${DSOOPTS} -o t.${DSOSUF} t.o"
1235    }
1236    if CheckCCDSO; then
1237        Note "Looks like your system supports $DSO-style DSOs."
1238    else
1239        cat 1>&4 <<EOF
1240Looks like your system supports $DSO-style DSOs...
1241... sigh, but $CCOMPILER does not support DSOs in the expected way.
1242EOF
1243        DSO=no
1244    fi
1245fi
1246if [ "$DSO" = no ]; then
1247    DSOSUF=a DSOOPTS= LIBCOPTS=
1248    DSOSUF_VERSION=$DSOSUF
1249fi
1250test -z "$TIFFLIBREF" && TIFFLIBREF="\${DEPTH}/libtiff/libtiff.${DSOSUF}"
1251test -z "$DSOSUF_VERSION" && DSOSUF_VERSION=${DSOSUF}
1252Note "Done checking for DSO support."
1253
1254Note ""
1255if [ "$LIBIMAGE" = auto ]; then
1256    if CheckForLibrary iopen -limage && CheckForIncludeFile gl/image.h; then
1257        Note "Looks like there is support for SGI RGB images."
1258        LIBIMAGE=yes
1259    else
1260        LIBIMAGE=no
1261    fi
1262fi
1263if [ "$LIBGL" = auto ]; then
1264    if CheckForLibrary winopen -lgl && CheckForIncludeFile gl.h; then
1265        Note "Looks like there is support for IRIS GL."
1266        LIBGL=yes
1267    else
1268        LIBGL=no
1269    fi
1270fi
1271
1272test $LIBGL = no -a $LIBIMAGE = no || Note ""
1273Note "Selecting programs used during installation."
1274
1275
1276#
1277# Miscellaneous ``little'' programs.
1278#
1279test -z "${CHMOD-}"     && CHMOD=`findAppDef chmod $PATH chmod`
1280test -z "${LN-}"        && LN=`findAppDef ln $PATH ln`
1281test -z "${SED-}"       && SED=`findAppDef sed $PATH sed`
1282test -z "${STRIP-}"     && STRIP=`findAppDef strip $PATH strip`
1283
1284#
1285# Check if mv -f is supported
1286#
1287if [ -z "${MV_F-}" ]; then
1288    $RM t.c; echo "">t.c
1289    if mv -f t.c t.o; then
1290        Note "Looks like mv supports the -f option to force a move."
1291        MV_F=-f
1292    else
1293        Note "Warning, looks like mv has no -f option to force move operations;"
1294        Note "... this may cause problems during installation."
1295        MV_F=
1296    fi
1297fi
1298
1299#
1300# Check if ln -s creates a symbolic link.
1301#
1302if [ -z "${LN_S-}" ]; then
1303    $RM t.c; $LN -s foo t.c && LN_S=-s
1304fi
1305if [ -n "$LN_S" ]; then
1306    Note "Looks like $LN supports the -s option to create a symbolic link."
1307else
1308    Note "Warning, looks like $LN has no -s option to create symbolic links;"
1309    Note "... this may cause problems during installation."
1310fi
1311
1312#
1313# Pick install mechanism.
1314#
1315if [ -z "${INSTALL-}" ]; then
1316    case $TARGET in
1317    *-irix*)    INSTALL=`findApp install /sbin:$PATH`;;
1318    *)          INSTALL='${SCRIPT_SH} ../port/install.sh';;
1319    esac
1320fi
1321
1322Note "Done selecting programs."
1323
1324#
1325# User-changable configuration parameters section.
1326# Anything selected here is presented to the user
1327# and may be interactively changed.
1328#
1329
1330Note ""
1331Note "Selecting default TIFF configuration parameters."
1332Note ""
1333
1334#
1335# Fill in any other configuration parameters not
1336# setup in the site and local files.
1337#
1338
1339bitchExecutable()
1340{
1341    echo ""
1342    echo "Warning, $1 does not seem to be an executable program;"
1343    echo "you'll need to correct this before starting up the fax server."
1344    echo ""
1345}
1346
1347#
1348# Setup manual page-related stuff.
1349#
1350# Manual pages are processed according to:
1351# 1. Section organization (BSD or System V)
1352# 2. Pre-formatted (w/ nroff) or source.
1353# 3. Compressed (compress, gzip, pack) or uncompressed.
1354# 4. Whether or not the FlexFAX ``F'' suffix must be
1355#    stripped for pages to be found (only for 4F pages).
1356#
1357if [ -z "${DIR_MAN-}" ]; then
1358    MANPATH="
1359        $MANPATH
1360        /usr/local/man
1361        /usr/contrib/man
1362        /usr/catman/local
1363    "
1364    DIR_MAN=
1365    for i in $MANPATH; do
1366        test -d $i && { DIR_MAN=$i; break; }
1367    done
1368    test -z "$DIR_MAN" && DIR_MAN=${PREFIX}/man
1369fi
1370Note "Looks like manual pages go in $DIR_MAN."
1371if [ -z "${MANSCHEME-}" ]; then
1372    case $TARGET in
1373    *-bsdi*|*-netbsd*)          MANSCHEME=bsd-nroff-gzip-0.gz;;
1374    *-freebsd*)                 MANSCHEME=bsd-source-cat;;
1375    *-linux*)                   MANSCHEME=bsd-source-cat;;
1376    *-ultrix*)                  MANSCHEME=bsd-source-cat;;
1377    *-sunos*)                   MANSCHEME=bsd-source-cat-strip;;
1378    *-sysv[234]*)               MANSCHEME=sysv-source-cat-strip;;
1379    *-hpux*)                    MANSCHEME=sysv-source-cat;;
1380    *-solaris*)                 MANSCHEME=sysv-source-cat-strip;;
1381    *-aix*)                     MANSCHEME=sysv-source-strip;;
1382    *-isc*|*-sco*)              MANSCHEME=sysv-source-cat;;
1383    *-irix*)                    MANSCHEME=sysv-nroff-compress-Z;;
1384    *)
1385        #
1386        # Try to deduce the setup from existing manual pages.
1387        # XXX needs more work XXX
1388        #
1389        MANSCHEME=sysv-source-cat
1390        if [ -d /usr/share/man ]; then
1391            if [ -d /usr/share/man/u_man ]; then
1392               MANSCHEME=sysv-source-cat
1393            elif [ -d /usr/share/man/man8 ]; then
1394               MANSCHEME=bsd-source-cat
1395            fi
1396        elif [ -d /usr/share/catman ]; then
1397            if [ -d /usr/share/catman/u_man ]; then
1398               MANSCHEME=sysv-nroff-cat
1399            elif [ -d /usr/share/catman/man8 ]; then
1400               MANSCHEME=bsd-nroff-cat
1401            fi
1402        fi
1403        ;;
1404    esac
1405fi
1406Note "Looks like manual pages should be installed with $MANSCHEME."
1407
1408#
1409# Figure out which brand of echo we have and define
1410# prompt and print shell functions accordingly.
1411#
1412if [ `echo foo\\\c`@ = "foo@" ]; then
1413    prompt()
1414    {
1415        echo "$* \\c"
1416    }
1417elif [ "`echo -n foo`@" = "foo@" ]; then
1418    prompt()
1419    {
1420        echo -n "$* "
1421    }
1422else
1423    prompt()
1424    {
1425        echo "$*"
1426    }
1427fi
1428
1429#
1430# Prompt the user for a string that can not be null.
1431#
1432promptForNonNullStringParameter()
1433{
1434    x="" val="$1" desc="$2"
1435    while [ -z "$x" ]; do
1436        prompt "$desc [$val]?"; read x
1437        if [ "$x" ]; then
1438            # strip leading and trailing white space
1439            x=`echo "$x" | sed -e 's/^[         ]*//' -e 's/[   ]*$//'`
1440        else
1441            x="$val"
1442        fi
1443    done
1444    param="$x"
1445}
1446
1447promptForManPageScheme()
1448{
1449    x=""
1450    while [ -z "$x" ]; do
1451        prompt "Manual page installation scheme [$MANSCHEME]?"; read x
1452        if [ "$x" ]; then
1453            # strip leading and trailing white space
1454            x=`echo "$x" | sed -e 's/^[         ]*//' -e 's/[   ]*$//'`
1455            # XXX do a better job of validating...
1456            case "$x" in
1457            bsd-nroff-cat*|sysv-nroff-cat*)     ;;
1458            bsd-nroff-gzip*|sysv-nroff-gzip*)   ;;
1459            bsd-nroff-comp*|sysv-nroff-comp*)   ;;
1460            bsd-nroff-pack*|sysv-nroff-pack*)   ;;
1461            bsd-source-cat*|sysv-source-cat*)   ;;
1462            bsd-source-gzip*|sysv-source-gzip*) ;;
1463            bsd-source-comp*|sysv-source-comp*) ;;
1464            bsd-source-pack*|sysv-source-pack*) ;;
1465            *)
1466cat <<EOF
1467
1468"$x" is not a valid manual page installation scheme.  Schemes are
1469constructed according to:
1470
1471    <organization>-<formatting>-<compression>[-<suffix>]
1472
1473where:
1474
1475<organization>  is either "bsd" for BSD-style section organization (e.g.
1476                file formats in section 5) or "sysv" for System V-style
1477                organization (e.g. file formats in section 4).
1478
1479<formatting>    is either "nroff" to force installation of formatted
1480                materials (using nroff) or "source" to get the nroff
1481                source installed.
1482
1483<compression>   is either the name of a program to compress the manual
1484                pages (gipz, compress, pack) or "cat" for uncompressed data.
1485
1486<suffix>        is either the file suffix to convert installed pages to
1487                (e.g. 0.gz for gzip-compressed pages under BSD) or "strip"
1488                to force the normal ".4f" suffix to be converted to ".4"
1489                (or ".5" if using the BSD organization).  If no -<suffix>
1490                is specified then filenames are not converted when they
1491                are installed.
1492
1493Common schemes are:
1494
1495bsd-nroff-gzip-0.gz     compressed formatted pages for BSD
1496bsd-source-cat          nroff source w/ BSD organization
1497sysv-source-cat-strip   nroff source for SysV w/o .4f suffix
1498sysv-source-cat         nroff source for SysV as-is
1499
1500EOF
1501                x="";;
1502            esac
1503        else
1504            x="$MANSCHEME"
1505        fi
1506    done
1507    MANSCHEME="$x"
1508}
1509
1510printConfig()
1511{
1512    cat<<EOF
1513
1514TIFF configuration parameters are:
1515
1516[ 1] Directory for tools:               $DIR_BIN
1517[ 2] Directory for libraries:           $DIR_LIB
1518[ 3] Directory for include files:       $DIR_INC
1519[ 4] Directory for manual pages:        $DIR_MAN
1520[ 5] Directory for HTML documents:      $DIR_HTML
1521[ 6] Manual page installation scheme:   $MANSCHEME
1522
1523EOF
1524}
1525
1526promptForParameter()
1527{
1528    case $1 in
1529    1)  promptForNonNullStringParameter "$DIR_BIN" \
1530            "Directory to install tools";               DIR_BIN="$param"
1531        ;;
1532    2)  promptForNonNullStringParameter "$DIR_LIB" \
1533            "Directory to install libraries";           DIR_LIB="$param"
1534        ;;
1535    3)  promptForNonNullStringParameter "$DIR_INC" \
1536            "Directory to install include files";       DIR_INC="$param"
1537        ;;
1538    4)  promptForNonNullStringParameter "$DIR_MAN" \
1539            "Directory to install manual pages";        DIR_MAN="$param"
1540        ;;
1541    5)  promptForNonNullStringParameter "$DIR_HTML" \
1542            "Directory to install HTML documents";      DIR_HTML="$param"
1543        ;;
1544    6)  promptForManPageScheme;;
1545    esac
1546}
1547
1548checkJPEG()
1549{
1550    if [ "${JPEG}" = yes ]; then
1551        test "`findHeader jpeglib.h`" || {
1552            cat<<EOF
1553
1554The set of libtiff include directories,
1555
1556    DIRS_LIBINC=${DIRS_LIBINC}
1557
1558does not seem to be setup correctly; "jpeglib.h" was not found.
1559This must be corrected if the JPEG support is to be enabled.
1560Either fix the pathname or disable the JPEG support.
1561
1562EOF
1563        }
1564        test $SRCDIR_IS_LIBTIFF = yes || \
1565          test -d "${DIR_JPEGLIB:-/dev/null/no-such-file}" || {
1566            cat<<EOF
1567
1568The JPEG library directory, "${DIR_JPEGLIB}", does not seem to exist.
1569This must be corrected if the JPEG support is to be enabled.
1570Either fix the pathname or disable the JPEG support.
1571
1572EOF
1573        }
1574    fi
1575}
1576
1577checkZIP()
1578{
1579    if [ "${ZIP}" = yes ]; then
1580        test "`findHeader zlib.h`" || {
1581            cat<<EOF
1582
1583The set of libtiff include directories,
1584
1585    DIRS_LIBINC=${DIRS_LIBINC}
1586
1587does not seem to be setup correctly; "zlib.h" was not found.
1588This must be corrected if the (G)ZIP support is to be enabled.
1589Either fix the pathname or disable the (G)ZIP support.
1590
1591EOF
1592        }
1593        test $SRCDIR_IS_LIBTIFF = yes \
1594          || test -d "${DIR_GZLIB:-/dev/null/no-such-file}" || {
1595            cat<<EOF
1596
1597The libgz library directory, "${DIR_GZLIB}", does not seem to exist.
1598This must be corrected if the ZIP support is to be enabled.
1599Either fix the pathname or disable the ZIP support.
1600
1601EOF
1602        }
1603    fi
1604}
1605
1606if [ $NONINTERACTIVE = no ] ; then
1607    ok=skip
1608    while [ "$ok" != y ] && [ "$ok" != yes ]; do
1609        if [ "$ok" != skip ]; then
1610            for i in 1 2 3 4 5 6; do
1611                promptForParameter $i;
1612            done
1613        fi
1614        printConfig; prompt "Are these ok [yes]?"; read ok
1615        test -z "$ok" && ok=yes
1616        case "$ok" in
1617        [1-9]|1[0-7])   promptForParameter $ok;;
1618        [yY]*|[nN]*)    continue;;
1619        ?*)
1620            echo ""
1621            echo "\"y\", \"yes\", or <RETURN> accepts the displayed parameters."
1622            echo "A number lets you change the numbered parameter."
1623            echo ""
1624            ;;
1625        esac
1626        ok=skip
1627    done
1628    checkJPEG
1629    checkZIP
1630else
1631    checkJPEG
1632    checkZIP
1633fi
1634
1635case $MANSCHEME in
1636*-source-*)     MANAPPS=man1 MANLIB=man3;;
1637*-nroff-*)      MANAPPS=cat1 MANLIB=cat3;;
1638esac
1639case $MANSCHEME in
1640*-strip)        MANSEDLOCAL="-e s/3T/3/g";;
1641*)              MANSEDLOCAL="";;
1642esac
1643case $MANSCHEME in
1644*-source-*)     MANCVT='${MANSED} $? >$@';;
1645*-nroff-gzip-*) MANCVT='${MANSED} $? | nroff -man | gzip > $@';;
1646*-nroff-pack-*) MANCVT='${MANSED} $? | nroff -man | pack > $@';;
1647*-nroff-com*-*) MANCVT='${MANSED} $? | nroff -man | compress > $@';;
1648*-nroff-cat-*)  MANCVT='${MANSED} $? | nroff -man > $@';;
1649esac
1650case $MANSCHEME in
1651*-0|*-0.gz|*-0.Z|*-gz|*-Z|*-z)
1652    suf=`echo $MANSCHEME | sed 's/.*-/./'`
1653    A='`echo $$i | sed' B='`'           # workaround shell bugs
1654    MANAPPNAME="$A s/\\\\.1\$\$/$suf/$B"
1655    MANLIBNAME="$A s/\\\\.3t\$\$/$suf/$B"
1656    ;;
1657*-strip)
1658    MANAPPNAME='$$i'
1659    MANLIBNAME='`echo $$i | sed s/\\.3t$$/.3/`'
1660    ;;
1661*)
1662    MANAPPNAME='$$i' MANLIBNAME='$$i'
1663    ;;
1664esac
1665
1666if [ "${JPEG}" = yes ]; then
1667    test -z "${CONF_JPEG-}"     && CONF_JPEG="-DJPEG_SUPPORT"
1668    if test -z "${LIBJPEG-}" ; then
1669      LIBJPEG="-ljpeg"
1670      test -z "${DIR_JPEGLIB-}" || LIBJPEG="-L${DIR_JPEGLIB} ${LIBJPEG}"
1671    fi
1672else
1673    CONF_JPEG=
1674    LIBJPEG=
1675fi
1676if [ "${ZIP}" = yes ]; then
1677    test -z "${CONF_ZIP-}"      && CONF_ZIP="-DZIP_SUPPORT"
1678    if test -z "${LIBGZ-}" ; then
1679      LIBGZ="-lz"
1680      test -z "${DIR_GZLIB-}" || LIBGZ="-L${DIR_GZLIB} ${LIBGZ}"
1681    fi
1682else
1683    CONF_ZIP=
1684    LIBGZ=
1685fi
1686
1687Note ""
1688
1689#
1690# Fixup a list of potentially relative pathnames so
1691# that they work when used in a subdirectory.  The
1692# string sent to stdout has no extraneous spaces so
1693# it can be used, for example, in building pathnames.
1694#
1695# NB: There's an extra echo done here so we get a
1696#     \n-terminated string passed to sed.
1697#
1698relativize()
1699{
1700    echo `if [ $SRCDIR_IS_LIBTIFF = no ]; then
1701        (for i do
1702            case "$i" in
1703            /*|-l*)     echo "$i" ;;
1704            -[LR])      ;;                              # XXX???
1705            -[LR]/*)    echo "$i" ;;
1706            -L*)        echo "$i" | sed 's;^-L;-L../;' ;;
1707            -R*)        echo "$i" | sed 's;^-R;-R../;' ;;
1708            *)          echo "../$i" ;;
1709            esac
1710        done) | tr '\012' ' '
1711    else
1712        echo "$@"
1713    fi` | sed -e 's;[ ][ ]*$;;' -e 's;/[.]$;;'
1714}
1715#
1716# Generate a list of compiler include options,
1717# prepending ``../'' to any relative pathnames.
1718#
1719makeIncArgs()
1720{
1721    (for i do
1722        case "$i" in
1723        /*)  echo "-I$i" ;;
1724        *)
1725            if [ $SRCDIR_IS_LIBTIFF = yes ]; then
1726                echo "-I$i"
1727            else
1728                echo "-I../$i"
1729            fi ;;
1730        esac
1731    done) | tr '\012' ' '
1732}
1733
1734#
1735# Setup parameters needed below.
1736#
1737if [ $SRCDIR_IS_LIBTIFF = yes ]; then
1738    CONFIGDIR="."
1739    LIBSRCDIR="${SRCDIR}"
1740else
1741    CONFIGDIR=".."
1742    LIBSRCDIR=`relativize ${SRCDIR}`/libtiff
1743fi
1744
1745# NB: these should be sorted alphabetically
1746cat>>confsed<<EOF
1747s;@AR@;${AR};g
1748s;@AROPTS@;${AROPTS};g
1749s;@CONFIGDIR@;${CONFIGDIR};g
1750s;@CCOMPILER@;${CCOMPILER};g
1751s;@CHMOD@;${CHMOD};g
1752s;@CONF_JPEG@;${CONF_JPEG};g
1753s;@CONF_ZIP@;${CONF_ZIP};g
1754s;@COPT_LIBINC@;`makeIncArgs ${DIRS_LIBINC}`;g
1755s;@DATE@;${DATE};g
1756s;@DEPEND_JPEGLIB@;${CONF_JPEG:+`findHeader jpeglib.h` `findHeader jerror.h`};g
1757s;@DEPEND_ZLIB@;${CONF_ZIP:+`findHeader zlib.h`};g
1758s;@DIR_BIN@;${DIR_BIN};g
1759s;@DIR_JPEGLIB@;`relativize ${DIR_JPEGLIB}`;g
1760s;@DIR_GZLIB@;`relativize ${DIR_GZLIB}`;g
1761s;@DIR_HTML@;${DIR_HTML};g
1762s;@DIR_INC@;${DIR_INC};g
1763s;@DIR_LIB@;${DIR_LIB};g
1764s;@DIR_MAN@;${DIR_MAN};g
1765s;@DIRS_LIBINC@;`relativize ${DIRS_LIBINC}`;g
1766s;@DIST_POINT@;${DIST_POINT};g
1767s;@DIST_MAJOR@;${DIST_MAJOR};g
1768s;@DIST_MINOR@;${DIST_MINOR};g
1769s;@DSO@;${DSO};g
1770s;@DSOSUF@;${DSOSUF};g
1771s;@DSOSUF_VERSION@;${DSOSUF_VERSION};g
1772s;@ENVOPTS@;${ENVOPTS};g
1773s;@FILLORDER@;${FILLORDER};g
1774s;@GCOPTS@;${GCOPTS};g
1775s;@HTML@;${HTML};g
1776s;@INSTALL@;${INSTALL};g
1777s;@LIBJPEG@;`relativize ${LIBJPEG}`;g
1778s;@LIBGL@;${LIBGL};g
1779s;@LIBGZ@;`relativize ${LIBGZ}`;g
1780s;@LIBSRCDIR@;${LIBSRCDIR};g
1781s;@LIBIMAGE@;${LIBIMAGE};g
1782s;@LIBCOPTS@;${LIBCOPTS};g
1783s;@LIBPORT@;${LIBPORT};g
1784s;@LN@;${LN};g
1785s;@LN_S@;${LN_S};g
1786s;@MACHDEPLIBS@;${MACHDEPLIBS};g
1787s;@MANAPPS@;${MANAPPS};g
1788s;@MANAPPNAME@;${MANAPPNAME};g
1789s;@MANLIBNAME@;${MANLIBNAME};g
1790s;@MANCVT@;${MANCVT};g
1791s;@MANSEDLOCAL@;${MANSEDLOCAL};g
1792s;@MANLIB@;${MANLIB};g
1793s;@MV_F@;${MV_F};g
1794s;@OPTIMIZER@;${OPTIMIZER};g
1795s;@PORT@;${PORT};g
1796s;@PORTFUNCS@;${PORTFUNCS};g
1797s;@RANLIB@;${RANLIB};g
1798s;@SCRIPT_SH@;${SCRIPT_SH};g
1799s;@SED@;${SED};g
1800s;@SETMAKE@;${SETMAKE};g
1801s;@SRCDIR@;${SRCDIR};g
1802s;@RELSRCDIR@;`relativize ${SRCDIR}`;g
1803s;@STRIP@;${STRIP};g
1804s;@TARGET@;${TARGET};g
1805s;@TIFFLIBREF@;${TIFFLIBREF};g
1806s;@VERSION@;${VERSION};g
1807s;@RELEASE@;${RELEASE};g
1808s;@VERSIONFILE@;`relativize ${VERSIONFILE}`;g
1809s;@WARNING@;Warning, this file was automatically created by the TIFF configure script;g
1810EOF
1811
1812SedConfigFiles()
1813{
1814    for F do
1815        test -f $SRCDIR/$F.in || {
1816            bitch "$SRCDIR/$F.in is missing; this should be part of the distribution."
1817            boom
1818        }
1819        dir=`echo $F | $SED 's;/[^/]*$;;'`
1820        if [ $dir != $F ] && [ ! -d $dir ]; then
1821            Note "Creating $dir directory"
1822            mkdir $dir
1823        fi
1824        suffix=`echo $F | $SED 's/.*\.//'`
1825        if [ "$suffix" = h ]; then
1826            #
1827            # Compare old and new versions so that include files
1828            # are only updated when something has changed--this
1829            # saves time for subsequent makes.  Note we screen
1830            # out use of @DATE@ 'cuz otherwise that'll mess up
1831            # the comparison (this assumes dates are used in lines
1832            # of the form DATE: @DATE@).
1833            #
1834            $RM $F.new; $SED -f confsed $SRCDIR/$F.in > $F.new
1835            $RM confx; $SED '/DATE:/d' $F.new >confx
1836            $RM confy; $SED '/DATE:/d' $F >confy 2>/dev/null
1837            if cmp -s confx confy >/dev/null 2>&1; then
1838                $RM $F.new
1839            else
1840                Note "Creating $F from $SRCDIR/$F.in"
1841                $RM $F; mv $F.new $F; $CHMOD 444 $F
1842            fi
1843        else
1844            Note "Creating $F from $SRCDIR/$F.in"
1845            if $SED -f confsed $SRCDIR/$F.in >$F.new; then
1846                $RM $F; mv $F.new $F; $CHMOD 444 $F
1847            else
1848                cat 1>&2 <<EOF
1849Help, there was a problem crafting $F from $F.in.
1850The command:
1851
1852    $SED -f confsed $SRCDIR/$F.in >$F.new
1853
1854failed.  Aborting without cleaning up files so you can take a look...
1855EOF
1856                exit 1
1857            fi
1858        fi
1859    done
1860}
1861
1862#
1863# port/install.sh is the SGI install program emulator script.
1864#
1865CONF_FILES="Makefile"
1866if [ $SRCDIR_IS_LIBTIFF != yes ] ; then
1867    CONF_FILES="$CONF_FILES
1868        libtiff/Makefile
1869        man/Makefile
1870        tools/Makefile
1871        port/install.sh
1872        "
1873    test $HTML = yes &&         CONF_FILES="$CONF_FILES html/Makefile"
1874    test $PORT = yes &&         CONF_FILES="$CONF_FILES port/Makefile"
1875fi
1876SedConfigFiles $CONF_FILES
1877
1878Note "Done."
1879
1880$RM $JUNK
1881exit 0
Note: See TracBrowser for help on using the repository browser.