home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / maths / plplot / plplot_2 / cf / configure. < prev    next >
Encoding:
Text File  |  1994-09-05  |  13.9 KB  |  460 lines

  1. #!/bin/sh
  2. # -----------------------------------------------------------------------
  3. #
  4. # configure.in
  5. #
  6. # Maurice LeBrun
  7. # IFS, University of Texas at Austin
  8. # 14-Jul-1994
  9. #
  10. # PLplot configure script input
  11. #
  12. # This script does a few things that most autoconf-generated scripts do
  13. # not.  I resisted going with autoconf for a long time, in favor of a
  14. # home-rolled solution because of (a) certain needs that autoconf didn't
  15. # appear to meet, and (b) PLplot started out as a package with much less
  16. # demanding needs than today.  Eventually the build situation got out of
  17. # hand, and I took the plunge -- all those nice features in autoconf were
  18. # just too hard to resist any longer.  Those areas where I needed to be a
  19. # bit inventive include:
  20. #
  21. # - makefile control flow and file inclusion.  Standard make is braindead
  22. # in this regard.  The problem is how to conditionally enable/disable
  23. # packages in the makefile itself.  GNU make appears to handle this quite
  24. # well, but I have concerns about portability -- I've heard of (and had)
  25. # problems porting it to old versions of Unix, and it's not available
  26. # under some non-Unix systems (notably MSDOS).  Anyhow, there are several
  27. # ways one can simulate active control, and the route I've gone is to
  28. # include a separate file for each capability.  Makefile.in is created by
  29. # the configure script by concatenating the right pieces together.  Not
  30. # only is this very portable, but keeping the target/dependency portion
  31. # separate allows (a) this to be generated automatically e.g. by
  32. # makedepend without changing any other file, and (b) non-Unix ports to
  33. # share it (important because the target/dependency list tends to change a
  34. # lot).  Since these Makefile fragments are just text files, it should
  35. # be simple enough to string them together as desired.
  36. #
  37. # - System-specific settings for ANSI C compiler, Fortran compiler, and
  38. # other non-standard switches (profiling, auto promotion in Fortran,
  39. # optimization levels).  This is handled by a largish case statement over
  40. # system type that I snarfed from my previous configure utils.  A similar
  41. # case statement for building shared libraries was snarfed from the BLT
  42. # (Tk extension package) configure script.
  43. #
  44. # - Fast, site-specific configures.  I have set things up so that most of
  45. # the configure is skipped if the relevant shell variables are set.  Early
  46. # on I try to source a defaults file (~/config/cf_plplot.in) which does
  47. # this.  The point is, for a given site most settings are invariant from
  48. # one configure to the next, but you might want to change things like what
  49. # packages are enabled, compilers, precision, profiling, debugging, etc.
  50. # Very useful for development.
  51. #
  52. # -----------------------------------------------------------------------
  53.  
  54. # Running configure from a subdirectory doesn't work quite right.
  55. # This is a lot easier than trying to fix it.
  56.  
  57. if test "$0" = "../configure"; then
  58.     cd ..
  59.     configure $*
  60.     exit
  61. fi
  62.  
  63. # -----------------------------------------------------------------------
  64. # Source site-specific variables file, if present.
  65. # Can be used to dramatically reduce the time spent configuring.
  66. # Should be done before command-line flags are handled so that the user
  67. # can override if necessary.
  68. #
  69. # The special command line flag --nodefaults (must come first) can be used
  70. # to skip sourcing the defaults file.
  71. # -----------------------------------------------------------------------
  72.  
  73. if test "$1" = "--nodefaults"; then
  74.     shift
  75.     echo "Performing full configure."
  76. else
  77.     initfile="$HOME/config/cf_plplot.in"
  78.     if test -f $initfile; then
  79.     echo "Getting default settings from $initfile."
  80.     . $initfile
  81.     else
  82.     echo "No defaults file found, performing full configure."
  83.     fi
  84. fi
  85.  
  86. LIBS=""
  87. INCS=""
  88.  
  89. # -----------------------------------------------------------------------
  90. # Initialize autoconf.
  91. # -----------------------------------------------------------------------
  92.  
  93. AC_INIT(src/plcore.c)
  94. AC_CONFIG_HEADER(tmp/plConfig.h tmp/plDevs.h)
  95.  
  96. # -----------------------------------------------------------------------
  97. # First get system using uname.
  98. # -----------------------------------------------------------------------
  99.  
  100. AC_PROGRAM_CHECK(uname_found, uname, 1, 0)
  101. [ if test $uname_found -eq 1 ; then
  102.     system=`uname -s`-`uname -r`
  103.  
  104.     # Fix Cray braindamage
  105.  
  106.     case "$system" in
  107.     sn* )
  108.         system=`uname -m`-`uname -r`
  109.     ;;
  110.     esac
  111.  
  112. fi ]
  113.  
  114. if test "$system" ; then
  115.     echo "system is: $system"
  116. fi
  117.  
  118. # -----------------------------------------------------------------------
  119. # Some defaults
  120. # -----------------------------------------------------------------------
  121.  
  122. AC_WITH(debug, ,   with_debug="no")
  123. AC_WITH(opt, ,     with_opt="yes")
  124. AC_WITH(double, ,  with_double="no")
  125. AC_WITH(profile, , with_profile="no")
  126. AC_WITH(shlib, ,   with_shlib="yes")
  127. AC_WITH(f2c, ,     with_f2c="no")
  128. AC_WITH(gcc, ,     with_gcc="no")
  129. AC_WITH(warn, ,    with_warn="no")
  130.  
  131. AC_ENABLE(f77, , enable_f77="yes")
  132.  
  133. # --------------------------------------------------------------------
  134. # Set up prefix
  135. #
  136. # The prefix is set using the following algorithm:
  137. #
  138. #    via the command line --prefix flag
  139. #    via the shell variable "pl_prefix", set in the defaults file
  140. #    via the directory "plrender" currently is located in
  141. #
  142. # If still not set, prefix defaults to /usr/local/plplot.
  143. #
  144. # I recommend using a separate directory tree for PLplot files.  You can
  145. # use the "mklinks" script for soft-linking the bin, lib, and include
  146. # files to the usual places under /usr/local or /usr.  See the discussion
  147. # of this in the FAQ for more info.
  148. # --------------------------------------------------------------------
  149.  
  150. if test -z "$prefix"; then
  151.     if test -z "$pl_prefix"; then
  152.     AC_PREFIX(plrender)
  153.     if test -z "$prefix"; then
  154.         prefix="/usr/local/plplot"
  155.         echo "Unable to determine prefix; using $prefix"
  156.     fi
  157.     else
  158.     prefix="$pl_prefix"
  159.     fi
  160. fi
  161.  
  162. # -----------------------------------------------------------------------
  163. # This is where the real work is done.
  164. # -----------------------------------------------------------------------
  165.  
  166. AC_REQUIRE_CPP
  167. AC_ISC_POSIX
  168.  
  169. AC_INCLUDE(sysconf.in)
  170. AC_INCLUDE(sysloc.in)
  171.  
  172. AC_STDC_HEADERS
  173. AC_HAVE_HEADERS(unistd.h)
  174. AC_PROG_RANLIB
  175. AC_CADDR_T
  176. AC_VFORK
  177.  
  178. # -----------------------------------------------------------------------
  179. # It'd be good to let this be selected too, need to put it in somewhere:
  180. # You can use the NOBRAINDEAD option here if you wish
  181. # If you use it, you may want to define NOBRAINDEAD in plplot.h
  182. # before moving it to it's permanent location.
  183.  
  184. #CC="$CC -DNOBRAINDEAD"
  185.  
  186. # -----------------------------------------------------------------------
  187. # Set up library suffix.
  188. # -----------------------------------------------------------------------
  189.  
  190. # Define tags to be used in multiple-precision library names
  191. #
  192. # Single precision: tag with "f"
  193. # Double precision: tag with "d"
  194.  
  195. if test "$with_double" = "yes"; then
  196.     TAG_PREC="d"
  197. else
  198.     TAG_PREC="f"
  199. fi
  200.  
  201. # Add suffix of:
  202. #    b    for baseline library (no X or TK)
  203. #    X    with X support enabled
  204. #    tk    with X, TK, and/or Tcl-DP support enabled
  205. #
  206. # Build those best suited to your system and softlink to libplplotf
  207. # and libplplotd to create the system default.  
  208.  
  209. TAG_ENABLE="b"
  210. if test "$enable_xwin" = "yes"; then
  211.     TAG_ENABLE="X"
  212. fi
  213. if test "$enable_tk" = "yes"; then
  214.     TAG_ENABLE="tk"
  215. fi
  216.  
  217. # Put them together
  218.  
  219. LIB_TAG="$TAG_PREC$TAG_ENABLE"
  220.  
  221. AC_SUBST(LIB_TAG)
  222.  
  223. # -----------------------------------------------------------------------
  224. # Now build up Makefile.in, out of all the eensy-weensy little pieces.
  225. # -----------------------------------------------------------------------
  226.  
  227. if test ! -d tmp; then
  228.     mkdir tmp
  229. fi
  230. echo "creating tmp/Makefile.in"
  231.  
  232. # Makefile initialization
  233.  
  234. cat cf/init.in        >tmp/Makefile.in 
  235.  
  236. # Default target, core source and object file lists
  237.  
  238. cat cf/dist.in        >>tmp/Makefile.in 
  239.  
  240. # Optional packages
  241.  
  242. if test "$enable_f77" = "yes"; then
  243.     cat cf/pkg_f77.in    >>tmp/Makefile.in 
  244. fi
  245. if test "$enable_tcl" = "yes"; then
  246.     cat cf/pkg_tcl.in    >>tmp/Makefile.in 
  247. fi
  248. if test "$enable_tk" = "yes"; then
  249.     cat cf/pkg_tk.in    >>tmp/Makefile.in 
  250. fi
  251.  
  252. # Library targets
  253.  
  254. cat cf/initlib.in    >>tmp/Makefile.in
  255.  
  256. if test "$with_shlib" = "yes"; then
  257.     case $system in 
  258.     SunOS-4* ) 
  259.         cat cf/lib_sh_sun.in    >>tmp/Makefile.in
  260.     ;;
  261.     * )
  262.         cat cf/lib_sh.in    >>tmp/Makefile.in
  263.     ;;
  264.     esac
  265. else
  266.     cat cf/lib_ar.in    >>tmp/Makefile.in
  267. fi
  268.  
  269. # Program and demo file dependencies, targets
  270.  
  271. cat cf/exes.in        >>tmp/Makefile.in 
  272. cat cf/demos.in        >>tmp/Makefile.in 
  273.  
  274. # Installation and miscellaneous.
  275.  
  276. cat cf/install.in    >>tmp/Makefile.in 
  277. cat cf/misc.in        >>tmp/Makefile.in 
  278.  
  279. # Object file dependencies
  280.  
  281. cat cf/objs.in        >>tmp/Makefile.in 
  282.  
  283. # -----------------------------------------------------------------------
  284. # Now build Makedemo.in.
  285. # Makedemo is a stand-alone makefile for the demo programs.
  286. # Note: it links against the installed PLplot library.
  287. # -----------------------------------------------------------------------
  288.  
  289. echo "creating tmp/Makedemo.in"
  290.  
  291. cat cf/init.in        >tmp/Makedemo.in 
  292. cat cf/initdemo.in    >>tmp/Makedemo.in 
  293. cat cf/demos.in        >>tmp/Makedemo.in 
  294. cat cf/miscdemo.in    >>tmp/Makedemo.in 
  295.  
  296. # --------------------------------------------------------------------
  297. # Set up variables governing device driver inclusion.
  298. # --------------------------------------------------------------------
  299.  
  300. define(PL_DRIVERS,[ifelse($1,,,[PL_ADD_DRIVER($1)dnl
  301. PL_DRIVERS(builtin([shift],$*))])])
  302.  
  303. define(PL_ADD_DRIVER,[dnl
  304. AC_ENABLE($1, , enable_$1="yes")
  305. if test "$enable_$1" = "yes"; then
  306.     AC_DEFINE(PLD_$1)
  307.     DEVICES="$DEVICES $1"
  308. fi
  309. ])dnl
  310.  
  311. # Including a driver in this list includes it by default.  Maybe not
  312. # complete, but most of the devices of interest under Unix.  You can
  313. # enable/disable drivers either by the command line (--enable-<driver> or
  314. # --disable-<driver>) or via the cf_plplot.in file (remember to use
  315. # underscores instead of dashes here).
  316.  
  317. PL_DRIVERS(plmeta, null, xterm, tek4010, tek4107, mskermit, conex, vlt,
  318. versaterm, dg300, ps, xfig, ljii, hp7470, hp7580, lj_hpgl, imp, xwin, tk,
  319. dp)
  320.  
  321. # --------------------------------------------------------------------
  322. # Set up variables that specify install directories
  323. #
  324. # You can preset these to anything you want if you don't like the default
  325. # choice.  In particular, if you /don't/ install PLplot under its own
  326. # directory, the examples, tcl, and doc subdirectories will cause
  327. # problems.  In this case, set the <whatever>_DIR variables below as
  328. # desired in ~/config/cf_plplot.in, and you are set.
  329. # --------------------------------------------------------------------
  330.  
  331. if test -z "$LIB_DIR"; then
  332.     LIB_DIR=$prefix/lib
  333. fi
  334. if test -z "$BIN_DIR"; then
  335.     BIN_DIR=$prefix/bin
  336. fi
  337. if test -z "$TCL_DIR"; then
  338.     TCL_DIR=$prefix/tcl
  339. fi
  340. if test -z "$DOC_DIR"; then
  341.     DOC_DIR=$prefix/doc
  342. fi
  343. if test -z "$INFO_DIR"; then
  344.     INFO_DIR=$prefix/info
  345. fi
  346. if test -z "$INCLUDE_DIR"; then
  347.     INCLUDE_DIR=$prefix/include
  348. fi
  349. if test -z "$DEMOS_DIR"; then
  350.     DEMOS_DIR=$prefix/examples
  351. fi
  352.  
  353. AC_DEFINE_UNQUOTED(LIB_DIR, \"$LIB_DIR\")
  354. AC_DEFINE_UNQUOTED(BIN_DIR, \"$BIN_DIR\")
  355. AC_DEFINE_UNQUOTED(TCL_DIR, \"$TCL_DIR\")
  356.  
  357. AC_SUBST(LIB_DIR)
  358. AC_SUBST(BIN_DIR)
  359. AC_SUBST(TCL_DIR)
  360. AC_SUBST(DOC_DIR)
  361. AC_SUBST(INFO_DIR)
  362. AC_SUBST(INCLUDE_DIR)
  363. AC_SUBST(DEMOS_DIR)
  364.  
  365. # --------------------------------------------------------------------
  366. # Create links to source code.
  367. #
  368. # I've found that with the PLplot distribution spread out over so many
  369. # directories, the "monolithic build directory" paradigm is the easiest
  370. # for me to use during development.  On systems that don't support
  371. # softlinks, you can always use copy.  At least you will only have to do
  372. # it once.
  373. # --------------------------------------------------------------------
  374.  
  375. if test ! -f tmp/plcore.c; then
  376.     echo "Creating links.."
  377.     cd tmp
  378.  
  379.     ln -s \
  380.     ../src/*.c \
  381.     ../src/tcl/*.c \
  382.     ../src/stubc/*.c \
  383.     ../examples/C/*.c \
  384.     ../examples/tcl/*.tcl \
  385.     ../examples/tk/*.c \
  386.     ../examples/tk/tk* \
  387.     ../utils/*.c \
  388.     ../fonts/*.c \
  389.     ../scripts/pl* \
  390.     ../include/*.h \
  391.     ../drivers/*.c \
  392.     ../drivers/tk/*.* \
  393.     ../drivers/tk/tclIndex \
  394.     ../lib/*.fnt \
  395.     ../lib/*.map \
  396.     .
  397.  
  398. # Create links to the Fortran files.  
  399. # Double precision Fortran files in the stub interface are obtained
  400. # entirely by m4 macro expansion.  This should work anywhere.  Double
  401. # precision example programs are obtained through automatic compiler
  402. # promotion.  Your compiler needs to be able to automatically promote
  403. # all real variables and constants for this to work (note: the HPUX 8.x
  404. # compiler did not support this, but it's supported under 9.0).
  405.  
  406.     ln -s \
  407.     ../src/stubf/*.* \
  408.     ../examples/f77/*.* \
  409.     .
  410.  
  411. # Create links to config files.
  412.  
  413.     ln -s ../cf/*.in cvtdeps .
  414.     cd ..
  415. fi
  416.  
  417. if test ! -d tmp/shared; then
  418.     mkdir tmp/shared
  419. fi
  420.  
  421. # --------------------------------------------------------------------
  422. # Print out some of the more important settings, then create output
  423. # files.
  424. #
  425. # IMPORTANT: the with_<foo> and enable_<bar> vars are printed as
  426. # with-<foo> and enable-<bar>.  Yes, this is confusing.  I really wish the
  427. # same syntax were used for both the command line switch and the variable
  428. # it is setting.  The possibility for confusion is much higher if I don't
  429. # write them the same in the status message as they appear in the command
  430. # line.  The only occasion you will have to set the variable directly is
  431. # in ~/config/cf_plplot.in if you use it, and just make sure you remember
  432. # to use an underscore in that case.
  433. # --------------------------------------------------------------------
  434.  
  435. echo "
  436. Configuration results (edit and run ./config.status to modify):
  437.  
  438. system:        $system
  439. prefix:        $prefix
  440. CC:        $CC $CC_FLAGS
  441. F77:        $F77 $F77_FLAGS
  442. LDC:        $LDC $LDC_FLAGS
  443. LDF:        $LDF $LDF_FLAGS
  444. INCS:        $INCS
  445. LIBS:        $LIBS
  446. LIB_TAG:    $LIB_TAG
  447. devices:    $DEVICES
  448.  
  449. with-shlib:    $with_shlib        with-double:    $with_double
  450. with-debug:    $with_debug        with-opt:    $with_opt
  451. with-warn:    $with_warn        with-profile:    $with_profile
  452. with-f2c:    $with_f2c        with-gcc:    $with_gcc
  453.  
  454. enable-xwin:    $enable_xwin        enable-tcl:    $enable_tcl
  455. enable-tk:    $enable_tk        enable-dp:    $enable_dp
  456. enable-itcl:    $enable_itcl        enable-f77:    $enable_f77
  457. "
  458.  
  459. AC_OUTPUT(tmp/Makefile tmp/Makedemo)
  460.