IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 29, 2006, 2:26:29 PM (20 years ago)
Author:
eugene
Message:

implementing better include/lib tests, shared objects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/configure

    r7080 r10298  
    7676if ($#args != 1) goto usage
    7777
    78 # sun (at least) seems to need the socket library
    79 # linux does not
    80 set archlib = ""
     78set needlibs = "png z jpeg readline X11 pthread m"
     79set syslibpath = "/usr/lib /usr/X11R6/lib /usr/openwin/lib"
     80
     81set needincs = "math.h fcntl.h malloc.h errno.h time.h memory.h stdlib.h string.h X11/X.h"
     82set sysincpath = "/usr/include /usr/X11R6/include /usr/openwin/include"
    8183
    8284# check the hardware architecture:
     
    9395     set arch="sun4";
    9496   endif
    95    # XXX old solaris needed termcap for readline
    96    set archlib = "libsocket libnsl"
     97   # sun (at least) seems to need the socket library (linux does not)
     98   set needlibs = "$needlibs libsocket libnsl"
    9799   breaksw;
    98100 case Linux:
     
    118120set root = `pwd`
    119121if ($prefix == "") set prefix = $root
    120 set inc = $prefix/include/$arch
    121 set lib = $prefix/lib/$arch
     122if ($vararch) then
     123  set inc = $prefix/include/$arch
     124  set lib = $prefix/lib/$arch
     125else
     126  set inc = $prefix/include
     127  set lib = $prefix/lib
     128endif
    122129if ($?LD_LIBRARY_PATH) then
    123130  set libpath = `echo $LD_LIBRARY_PATH | tr ':' ' '`
     
    127134
    128135# check for basic libraries
    129 set fail = 0
    130 foreach f ( libpng libz libjpeg libreadline $archlib )
    131     foreach g ( /usr/lib $lib $libpath )
    132         set name = "$g/$f.a"
    133         if (-e $name) then
    134             echo "found $name"
    135             goto next_lib;
    136         endif
    137         set name = "$g/$f.so"
    138         if (-e $name) then
    139             echo "found $name"
    140             goto next_lib;
    141         endif
     136set faillibs = ""
     137set libflags = ""
     138set libdirs  = ""
     139foreach f ( $needlibs )
     140    foreach g ( $syslibpath $lib $libpath )
     141        set name = "$g/lib$f.a"
     142        if (-e $name) goto got_lib;
     143        set name = "$g/lib$f.so"
     144        if (-e $name) goto got_lib;
    142145    end
    143     echo "missing $f"
    144     set fail = 1
    145 next_lib:
     146    echo "missing lib$f"
     147    set faillibs = "$faillibs lib$f"
    146148    continue
     149got_lib:
     150    echo "found lib$f ($name)"
     151    echo "$libdirs" | grep -- "-L$g " > /dev/null
     152    if ($status) then
     153      set libdirs  = "$libdirs -L$g "
     154    endif
     155    echo "$libflags" | grep -- "-l$f " > /dev/null
     156    if ($status) then
     157      set libflags = "$libflags -l$f "
     158    endif
    147159end
    148160
     161# we need a curses library; can choose one of the following:
    149162# check for termcap, curses, etc
    150 set tlibflag = ""
    151163foreach f ( ncurses curses termcap )
    152       foreach g ( /usr/lib $lib $libpath )
     164    foreach g ( $syslibpath $lib $libpath )
    153165        set name = "$g/lib$f.a"
    154         if (-e $name) then
    155             echo "found $name"
    156             set tlibflag = "-l$f"
    157             goto got_curses;
    158         endif
     166        if (-e $name) goto got_curses;
    159167        set name = "$g/lib$f.so"
    160         if (-e $name) then
    161             echo "found $name"
    162             set tlibflag = "-l$f"
    163             goto got_curses;
    164         endif
     168        if (-e $name) goto got_curses;
    165169    end
    166170end
    167 if ("$tlibflag" == "") then
    168   echo "missing a valid curses library"
    169   set fail = 1
    170 endif
     171set faillibs = "$faillibs (ncurses | curses | termcap)"
     172echo "missing a valid curses library"
     173echo "missing: $faillibs"
     174echo "please find them and install them in $lib"
     175exit 1
    171176
    172177got_curses:
    173 
    174 if ($fail) then
     178  echo "found $f ($name)"
     179  echo "$libdirs" | grep -- "-L$g " > /dev/null
     180  if ($status) then
     181    set libdirs  = "$libdirs -L$g "
     182  endif
     183  echo "$libflags" | grep -- "-l$f " > /dev/null
     184  if ($status) then
     185    set libflags = "$libflags -l$f "
     186  endif
     187
     188if ("$faillibs" != "") then
    175189  echo "your installation is missing some important libraries"
     190  echo "missing: $faillibs"
    176191  echo "please find them and install them in $lib"
    177192  exit 1
    178193endif   
    179194
    180 # check for basic libraries
    181 set fail = 0
    182 foreach f ( libX11.a )
    183     foreach g ( /usr/lib $lib $libpath /usr/X11R6/lib /usr/openwin/lib )
    184         set name = "$g/$f"
    185         if (-e $name) then
    186             echo "found $g/$f"
    187             set xlib = $g
    188             goto next_xlib;
    189         endif
    190     end
    191     echo "missing $f"
    192     set fail = 1
    193 next_xlib:
    194     continue
     195# check for headers
     196set failincs = ""
     197set incdirs = ""
     198foreach f ( $needincs )
     199  foreach g ( $sysincpath $inc )
     200    set name = "$g/$f"
     201    if (-e $name) goto got_inc;
     202  end
     203  echo "missing $f"
     204  set failincs = "$failincs $f"
     205  continue
     206got_inc:
     207  echo "found $f ($name)"
     208  echo "$incdirs" | grep -- "-I$g " > /dev/null
     209  if ($status) then
     210    set incdirs = "$incdirs -I$g "
     211  endif
    195212end
    196213
    197 if ($fail) then
    198   echo "your installation is missing some important libraries"
    199   echo "please find them and install them in $lib"
     214if ("$failincs" != "") then
     215  echo "your installation is missing some important library headers"
     216  echo "please find them and install them in $inc"
    200217  exit 1
    201218endif   
    202219
    203 # check for X11 headers
    204 set fail = 0
    205 foreach f ( X11/X.h )
    206     foreach g ( /usr/include $inc /usr/X11R6/include /usr/openwin/include )
    207         set name = "$g/$f"
    208         if (-e $name) then
    209             echo "found $g/$f"
    210             set xinc = $g
    211             goto next_xinc;
    212         endif
    213     end
    214     echo "missing $f"
    215     set fail = 1
    216 next_xinc:
    217     continue
    218 end
    219 
    220 if ($fail) then
    221   echo "your installation is missing some important libraries"
    222   echo "please find them and install them in $lib"
    223   exit 1
    224 endif   
    225 
    226 echo XINC: $xinc
    227 echo XLIB: $xlib
     220echo INCDIRS: $incdirs
     221echo LIBDIRS: $libdirs
     222echo LIBFLAGS: $libflags
    228223
    229224echo ARCH: $arch
     
    245240# modify the BINDIR
    246241if ("$bindir" == "") then
    247   set subdir = bin/$arch
     242  set subdir = bin
    248243  if ($vararch) set subdir = 'bin/$(ARCH)'
    249244  set bindir = $prefix/$subdir
    250245endif
    251 cat Configure.in.tmp | sed "s| BINDIR| $bindir|" > Configure.tmp
     246cat Configure.in.tmp | sed "s|@BINDIR@| $bindir|" > Configure.tmp
    252247rm -f Configure.in.tmp
    253248mv Configure.tmp Configure.in.tmp
     
    256251# modify the INCDIR
    257252if ("$incdir" == "") then
    258   set subdir = include/$arch
     253  set subdir = include
    259254  if ($vararch) set subdir = 'include/$(ARCH)'
    260255  set incdir = $prefix/$subdir
    261256endif
    262 cat Configure.in.tmp | sed "s| INCDIR| $incdir|" > Configure.tmp
     257cat Configure.in.tmp | sed "s|@INCDIR@|$incdir|" > Configure.tmp
    263258rm -f Configure.in.tmp
    264259mv Configure.tmp Configure.in.tmp
     
    267262# modify the LIBDIR
    268263if ("$libdir" == "") then
    269   set subdir = lib/$arch
     264  set subdir = lib
    270265  if ($vararch) set subdir = 'lib/$(ARCH)'
    271266  set libdir = $prefix/$subdir
    272267endif
    273 cat Configure.in.tmp | sed "s| LIBDIR| $libdir|" > Configure.tmp
     268cat Configure.in.tmp | sed "s|@LIBDIR@|$libdir|" > Configure.tmp
    274269rm -f Configure.in.tmp
    275270mv Configure.tmp Configure.in.tmp
     
    280275  set mandir = $prefix/man
    281276endif
    282 cat Configure.in.tmp | sed "s| MANDIR| $mandir|" > Configure.tmp
     277cat Configure.in.tmp | sed "s|@MANDIR@|$mandir|" > Configure.tmp
    283278rm -f Configure.in.tmp
    284279mv Configure.tmp Configure.in.tmp
     
    290285endif
    291286set helpdir = $datadir/help
    292 cat Configure.in.tmp | sed "s| HELPDIR| $helpdir|" > Configure.tmp
     287cat Configure.in.tmp | sed "s|@HELPDIR@|$helpdir|" > Configure.tmp
    293288rm -f Configure.in.tmp
    294289mv Configure.tmp Configure.in.tmp
     
    298293  cat Configure.in.tmp | sed "s|^\s*ARCH|# ARCH|" > Configure.tmp
    299294else
    300   cat Configure.in.tmp | sed "s|ARCHVAL|$arch|" > Configure.tmp
     295  cat Configure.in.tmp | sed "s|@ARCHVAL@|$arch|" > Configure.tmp
    301296endif
    302297rm -f Configure.in.tmp
    303298mv Configure.tmp Configure.in.tmp
    304299
    305 cat Configure.in.tmp | sed "s|ROOTDIR|$root|" | sed "s|XINCDIR|$xinc|" | sed "s|XLIBDIR|$xlib|" | sed "s|TLIBFLAG|$tlibflag|" | sed "s|OPTFLAGS|$optflags $pedantic|" > Configure
     300cat Configure.in.tmp | sed "s|@ROOTDIR@|$root|" | sed "s|@INCDIRS@|$incdirs|" | sed "s|@LIBDIRS@|$libdirs|" | sed "s|@LIBFLAGS@|$libflags|" | sed "s|@OPTFLAGS@|$optflags $pedantic|" > Configure
    306301rm -f Configure.in.tmp Configure.tmp
    307302
Note: See TracChangeset for help on using the changeset viewer.