| 1 | dnl    Process this file with autoconf to produce a configure script | 
|---|
| 2 | AC_REVISION($Revision: 27534 $) | 
|---|
| 3 |  | 
|---|
| 4 | dnl    Initialisation: package name and version number | 
|---|
| 5 | AC_INIT([pal],[0.9.7],[starlink@jiscmail.ac.uk]) | 
|---|
| 6 | AC_CONFIG_AUX_DIR([build-aux]) | 
|---|
| 7 |  | 
|---|
| 8 | dnl    Require autoconf-2.50 at least | 
|---|
| 9 | AC_PREREQ([2.69]) | 
|---|
| 10 | dnl    Require Starlink automake | 
|---|
| 11 | AM_INIT_AUTOMAKE(1.8.2-starlink) | 
|---|
| 12 |  | 
|---|
| 13 | dnl    Sanity-check: name a file in the source directory -- if this | 
|---|
| 14 | dnl    isn't found then configure will complain | 
|---|
| 15 | AC_CONFIG_SRCDIR([pal.h]) | 
|---|
| 16 |  | 
|---|
| 17 | dnl    Include defaults for Starlink configurations | 
|---|
| 18 | STAR_DEFAULTS | 
|---|
| 19 |  | 
|---|
| 20 | dnl    Would like the version number as an integer | 
|---|
| 21 | AC_DEFINE_UNQUOTED([PACKAGE_VERSION_INTEGER], $PACKAGE_VERSION_INTEGER, | 
|---|
| 22 | [Integer version number, in the form major*1e6+minor*1e3+release]) | 
|---|
| 23 |  | 
|---|
| 24 | dnl    Find required versions of the programs we need for configuration | 
|---|
| 25 | AC_PROG_CC | 
|---|
| 26 | LT_INIT | 
|---|
| 27 |  | 
|---|
| 28 | #   If --with-pic=no is set we should honour that. | 
|---|
| 29 | AM_CONDITIONAL(NOPIC, test x$pic_mode = xno) | 
|---|
| 30 |  | 
|---|
| 31 | dnl    copysign and isblank are a c99 feature | 
|---|
| 32 | AC_CHECK_FUNCS(copysign) | 
|---|
| 33 | AC_CHECK_FUNCS(isblank) | 
|---|
| 34 |  | 
|---|
| 35 | dnl    Use strlcpy if it is available | 
|---|
| 36 | AC_SEARCH_LIBS([strlcpy], [bsd]) | 
|---|
| 37 | AS_IF([test "x$ac_cv_search_strlcpy" = "x-lbsd"], [AC_CHECK_HEADERS([bsd/string.h])]) | 
|---|
| 38 | AC_CHECK_FUNCS([strlcpy]) | 
|---|
| 39 |  | 
|---|
| 40 | # Need the math library | 
|---|
| 41 | AC_CHECK_LIB([m],[sin]) | 
|---|
| 42 |  | 
|---|
| 43 | dnl    We can not simply test for Starlink starutil because | 
|---|
| 44 | dnl    when configure runs in a Starlink build starutil will not | 
|---|
| 45 | dnl    have been built yet. If --without-starlink has been used | 
|---|
| 46 | dnl    $STARLINK will be unset but to play safe we also check STARCONF_DEFAULT_PREFIX | 
|---|
| 47 | dnl    If we do not have Starlink we can do the test anyhow just in case | 
|---|
| 48 |  | 
|---|
| 49 | if test -n "$STARCONF_DEFAULT_PREFIX" -a -n "$STARLINK" | 
|---|
| 50 | then | 
|---|
| 51 | AC_MSG_NOTICE([Assuming a Starlink environment]) | 
|---|
| 52 | AC_SUBST( STARUTIL_LIBADD, "${libdir}/libstarutil.la" ) | 
|---|
| 53 | AC_SUBST( ERFA_LIBADD, "${libdir}/liberfa.la" ) | 
|---|
| 54 | AC_SUBST( ERFA_LDFLAGS, "" ) | 
|---|
| 55 | AC_DEFINE( [HAVE_STAR_UTIL_H], [1], [Define to 1 if you have the <star/util.h> header file]) | 
|---|
| 56 | else | 
|---|
| 57 | AC_MSG_NOTICE([Building outside a Starlink environment]) | 
|---|
| 58 |  | 
|---|
| 59 | #   Allow ERFA/SOFA location to be specified using --with-erfa=$ERFA_DIR | 
|---|
| 60 | #   Assumes that the value supplied here is the root and lib and include directories | 
|---|
| 61 | #   are below it. --with-erfa=no or --without-erfa will result in ERFA being | 
|---|
| 62 | #   located in $PREFIX tree. This option is only effective if Starlink is not | 
|---|
| 63 | #   active. | 
|---|
| 64 | AC_ARG_WITH(erfa, | 
|---|
| 65 | AS_HELP_STRING([--with-erfa], | 
|---|
| 66 | [Location of ERFA/SOFA tree]), | 
|---|
| 67 | [if test -z "$withval" -o "$withval" = yes; then | 
|---|
| 68 | unset ERFA_DIR | 
|---|
| 69 | elif test "X$withval" = Xno; then | 
|---|
| 70 | unset ERFA_DIR | 
|---|
| 71 | elif test -d "$withval"; then | 
|---|
| 72 | ERFA_DIR="$withval" | 
|---|
| 73 | else | 
|---|
| 74 | unset ERFA_DIR | 
|---|
| 75 | AC_MSG_WARN([--with-erfa given nonexistent directory; ignored: using default instead]) | 
|---|
| 76 | fi]) | 
|---|
| 77 | if test -n "$ERFA_DIR"; then | 
|---|
| 78 | AC_MSG_NOTICE([ERFA/SOFA tree located at $ERFA_DIR]) | 
|---|
| 79 | erfa_includedir="${ERFA_DIR}/include" | 
|---|
| 80 | erfa_libdir="${ERFA_DIR}/lib" | 
|---|
| 81 | else | 
|---|
| 82 | ERFA_DIR=${prefix} | 
|---|
| 83 | erfa_includedir=${includedir} | 
|---|
| 84 | erfa_libdir=${libdir} | 
|---|
| 85 | AC_MSG_NOTICE([Looking for ERFA/SOFA in default location of $ERFA_DIR]) | 
|---|
| 86 | fi | 
|---|
| 87 |  | 
|---|
| 88 | dnl AC_CHECK_HEADERS does not search $includedir | 
|---|
| 89 | save_CPPFLAGS="$CPPFLAGS" | 
|---|
| 90 | eval CPPFLAGS=\"$CPPFLAGS -I${includedir} -I${erfa_includedir}\" | 
|---|
| 91 | eval CPPFLAGS=\"$CPPFLAGS\" | 
|---|
| 92 | AC_CHECK_HEADERS( star/util.h ) | 
|---|
| 93 | CPPFLAGS="$save_CPPFLAGS" | 
|---|
| 94 |  | 
|---|
| 95 | dnl for some reason AC_CHECK_LIB does not look in the --prefix hierarchy so | 
|---|
| 96 | dnl $libdir is not searched. | 
|---|
| 97 | dnl and we use eval twice to convert $libdir -> $exec_prefix/lib -> $prefix/lib | 
|---|
| 98 | save_LDFLAGS="$LDFLAGS" | 
|---|
| 99 | eval LDFLAGS=\"$LDFLAGS -L${libdir} -L${erfa_libdir}\" | 
|---|
| 100 | eval LDFLAGS=\"$LDFLAGS\" | 
|---|
| 101 |  | 
|---|
| 102 | AC_CHECK_LIB([starutil],[star_strlcpy], | 
|---|
| 103 | [AC_SUBST(STARUTIL_LIBADD, "-lstarutil")], | 
|---|
| 104 | [AC_SUBST(STARUTIL_LIBADD, "")]) | 
|---|
| 105 |  | 
|---|
| 106 | AC_CHECK_LIB([erfa],[eraCal2jd], | 
|---|
| 107 | [AC_SUBST(ERFA_LIBADD, "-lerfa")], | 
|---|
| 108 | [ | 
|---|
| 109 | AC_CHECK_LIB([sofa_c],[iauCal2jd], | 
|---|
| 110 | [AC_SUBST(ERFA_LIBADD, "-lsofa_c") | 
|---|
| 111 | AC_DEFINE([HAVE_SOFA_H],[1],"Build with SOFA library")], | 
|---|
| 112 | [AC_MSG_ERROR(Neither ERFA nor SOFA library located. Can not continue)]) | 
|---|
| 113 | ]) | 
|---|
| 114 | LDFLAGS="$save_LDFLAGS" | 
|---|
| 115 |  | 
|---|
| 116 | dnl  Ensure that we use the $prefix values and the ERFA values | 
|---|
| 117 | AC_SUBST( ERFA_LDFLAGS, "-L${libdir} -L${erfa_libdir}" ) | 
|---|
| 118 | AC_SUBST( ERFA_CPPFLAGS, "-I${includedir} -I${erfa_includedir}" ) | 
|---|
| 119 |  | 
|---|
| 120 | dnl  Disable document building regardless of --without-stardocs | 
|---|
| 121 | _star_build_docs=false | 
|---|
| 122 | fi | 
|---|
| 123 |  | 
|---|
| 124 | dnl    Declare the build and use dependencies for this package | 
|---|
| 125 | STAR_DECLARE_DEPENDENCIES(build, [erfa starutil]) | 
|---|
| 126 | STAR_DECLARE_DEPENDENCIES(link,  [erfa starutil]) | 
|---|
| 127 |  | 
|---|
| 128 | dnl    List the sun/ssn/... numbers which document this package and | 
|---|
| 129 | dnl    which are present as .tex files in this directory. | 
|---|
| 130 | STAR_LATEX_DOCUMENTATION(sun267) | 
|---|
| 131 |  | 
|---|
| 132 | dnl    If you wish to configure extra files, you can add them to this | 
|---|
| 133 | dnl    declaration. | 
|---|
| 134 | AC_CONFIG_FILES(Makefile component.xml) | 
|---|
| 135 | AC_CONFIG_HEADERS( config.h ) | 
|---|
| 136 |  | 
|---|
| 137 | dnl    This is the bit that does the actual work | 
|---|
| 138 | AC_OUTPUT | 
|---|