File: configure.ac

package info (click to toggle)
starlink-pal 0.9.8-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 1,808 kB
  • sloc: ansic: 6,689; makefile: 128; sh: 81
file content (144 lines) | stat: -rw-r--r-- 5,433 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
dnl    Process this file with autoconf to produce a configure script
AC_REVISION($Revision: 27534 $)

dnl    Initialisation: package name and version number
AC_INIT([pal],[0.9.8],[starlink@jiscmail.ac.uk])
AC_CONFIG_AUX_DIR([build-aux])

dnl    Require autoconf-2.50 at least
AC_PREREQ([2.69])
dnl    Require Starlink automake
AM_INIT_AUTOMAKE([foreign])

dnl    Sanity-check: name a file in the source directory -- if this
dnl    isn't found then configure will complain
AC_CONFIG_SRCDIR([pal.h])

dnl    Include defaults for Starlink configurations
STAR_DEFAULTS

dnl    Would like the version number as an integer
AC_DEFINE_UNQUOTED([PACKAGE_VERSION_INTEGER], $PACKAGE_VERSION_INTEGER,
                    [Integer version number, in the form major*1e6+minor*1e3+release])

dnl    Find required versions of the programs we need for configuration
AC_PROG_CC
LT_INIT

#   If --with-pic=no is set we should honour that.
AM_CONDITIONAL(NOPIC, test x$pic_mode = xno)

dnl    copysign and isblank are a c99 feature
AC_CHECK_FUNCS(copysign)
AC_CHECK_FUNCS(isblank)

dnl    Use strlcpy if it is available
AC_SEARCH_LIBS([strlcpy], [bsd])
AS_IF([test "x$ac_cv_search_strlcpy" = "x-lbsd"], [AC_CHECK_HEADERS([bsd/string.h])])
AC_CHECK_FUNCS([strlcpy])

dnl    Windows might not have str[n]casecmp
AC_CHECK_FUNCS(strcasecmp)
AC_CHECK_FUNCS(strncasecmp)
AC_CHECK_FUNCS(_stricmp)
AC_CHECK_FUNCS(_strnicmp)

# Need the math library
AC_CHECK_LIB([m],[sin])

dnl    We can not simply test for Starlink starutil because
dnl    when configure runs in a Starlink build starutil will not
dnl    have been built yet. If --without-starlink has been used
dnl    $STARLINK will be unset but to play safe we also check STARCONF_DEFAULT_PREFIX
dnl    If we do not have Starlink we can do the test anyhow just in case

if test -n "$STARCONF_DEFAULT_PREFIX" -a -n "$STARLINK"
then
  AC_MSG_NOTICE([Assuming a Starlink environment])
  AC_SUBST( STARUTIL_LIBADD, "${libdir}/libstarutil.la" )
  AC_SUBST( ERFA_LIBADD, "${libdir}/liberfa.la" )
  AC_SUBST( ERFA_LDFLAGS, "" )
  AC_DEFINE( [HAVE_STAR_UTIL_H], [1], [Define to 1 if you have the <star/util.h> header file])
else
  AC_MSG_NOTICE([Building outside a Starlink environment])

  #   Allow ERFA/SOFA location to be specified using --with-erfa=$ERFA_DIR
  #   Assumes that the value supplied here is the root and lib and include directories
  #   are below it. --with-erfa=no or --without-erfa will result in ERFA being
  #   located in $PREFIX tree. This option is only effective if Starlink is not
  #   active.
  AC_ARG_WITH(erfa,
              AS_HELP_STRING([--with-erfa],
                             [Location of ERFA/SOFA tree]),
              [if test -z "$withval" -o "$withval" = yes; then
                   unset ERFA_DIR
               elif test "X$withval" = Xno; then
                   unset ERFA_DIR
               elif test -d "$withval"; then
                   ERFA_DIR="$withval"
               else
                   unset ERFA_DIR
                   AC_MSG_WARN([--with-erfa given nonexistent directory; ignored: using default instead])
               fi])
  if test -n "$ERFA_DIR"; then
      AC_MSG_NOTICE([ERFA/SOFA tree located at $ERFA_DIR])
      erfa_includedir="${ERFA_DIR}/include"
      erfa_libdir="${ERFA_DIR}/lib"
  else
      ERFA_DIR=${prefix}
      erfa_includedir=${includedir}
      erfa_libdir=${libdir}
      AC_MSG_NOTICE([Looking for ERFA/SOFA in default location of $ERFA_DIR])
  fi

  dnl AC_CHECK_HEADERS does not search $includedir
  save_CPPFLAGS="$CPPFLAGS"
  eval CPPFLAGS=\"$CPPFLAGS -I${includedir} -I${erfa_includedir}\"
  eval CPPFLAGS=\"$CPPFLAGS\"
  AC_CHECK_HEADERS( star/util.h )
  CPPFLAGS="$save_CPPFLAGS"

  dnl for some reason AC_CHECK_LIB does not look in the --prefix hierarchy so
  dnl $libdir is not searched.
  dnl and we use eval twice to convert $libdir -> $exec_prefix/lib -> $prefix/lib
  save_LDFLAGS="$LDFLAGS"
  eval LDFLAGS=\"$LDFLAGS -L${libdir} -L${erfa_libdir}\"
  eval LDFLAGS=\"$LDFLAGS\"

  AC_CHECK_LIB([starutil],[star_strlcpy],
               [AC_SUBST(STARUTIL_LIBADD, "-lstarutil")],
               [AC_SUBST(STARUTIL_LIBADD, "")])

  AC_CHECK_LIB([erfa],[eraCal2jd],
               [AC_SUBST(ERFA_LIBADD, "-lerfa")],
               [
                AC_CHECK_LIB([sofa_c],[iauCal2jd],
                             [AC_SUBST(ERFA_LIBADD, "-lsofa_c")
                              AC_DEFINE([HAVE_SOFA_H],[1],"Build with SOFA library")],
                             [AC_MSG_ERROR(Neither ERFA nor SOFA library located. Can not continue)])
               ])
  LDFLAGS="$save_LDFLAGS"

  dnl  Ensure that we use the $prefix values and the ERFA values
  AC_SUBST( ERFA_LDFLAGS, "-L${libdir} -L${erfa_libdir}" )
  AC_SUBST( ERFA_CPPFLAGS, "-I${includedir} -I${erfa_includedir}" )

  dnl  Disable document building regardless of --without-stardocs
  _star_build_docs=false
fi

dnl    Declare the build and use dependencies for this package
STAR_DECLARE_DEPENDENCIES(build, [erfa starutil])
STAR_DECLARE_DEPENDENCIES(link,  [erfa starutil])

dnl    List the sun/ssn/... numbers which document this package and
dnl    which are present as .tex files in this directory.
STAR_LATEX_DOCUMENTATION(sun267)

dnl    If you wish to configure extra files, you can add them to this
dnl    declaration.
AC_CONFIG_FILES(Makefile component.xml)
AC_CONFIG_HEADERS( config.h )

dnl    This is the bit that does the actual work
AC_OUTPUT