acx_cfitsio.m4 3.64 KB
Newer Older
1
2
3
4
5
6
7
8
9
dnl
dnl				acx_cfitsio.m4
dnl
dnl Figure out if the CFITSIO library and header files are installed.
dnl
dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dnl
dnl	This file part of:	AstrOmatic software
dnl
10
dnl	Copyright:		(C) 2013 Emmanuel Bertin -- IAP/CNRS/UPMC
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
dnl
dnl	License:		GNU General Public License
dnl
dnl	AstrOmatic software is free software: you can redistribute it and/or
dnl	modify it under the terms of the GNU General Public License as
dnl	published by the Free Software Foundation, either version 3 of the
dnl	License, or (at your option) any later version.
dnl	AstrOmatic software is distributed in the hope that it will be useful,
dnl	but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl	GNU General Public License for more details.
dnl	You should have received a copy of the GNU General Public License
dnl	along with AstrOmatic software.
dnl	If not, see <http://www.gnu.org/licenses/>.
dnl
26
dnl	Last modified:		27/02/2013
27
28
29
dnl
dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dnl
30
31
32
33
34
dnl @synopsis ACX_CFITSIO([CFITSIO_DIR, CFITSIO_INCDIR,
dnl                    [ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]])
dnl This macro figures out if the CFITSIO libraries and header
dnl files are installed.
dnl You may wish to use these variables in your default LIBS and CFLAGS:
35
36
37
dnl
dnl        LIBS="$CFITSIO_LIBS $LIBS"
dnl
38
39
40
41
dnl You may wish to use these variables in your default CFLAGS:
dnl
dnl        CFLAGS="$CFLAGS $CFITSIO_CFLAGS"
dnl
42
dnl ACTION-IF-FOUND is a list of shell commands to run if CFITSIO
43
dnl is found (HAVE_CFITSIO are defined first), and ACTION-IF-NOT-FOUND
44
45
46
47
48
49
50
51
52
dnl is a list of commands to run it if it is not found.

AC_DEFUN([ACX_CFITSIO], [
AC_REQUIRE([AC_CANONICAL_HOST])

dnl --------------------
dnl Search include files
dnl --------------------

53
acx_cfitsio_ok=no
54
if test x$2 = x; then
55
56
57
58
59
60
61
62
63
64
65
  AC_CHECK_HEADER(fitsio.h,[acx_cfitsio_ok=yes])
  if test x$acx_cfitsio_ok = xyes; then
    AC_DEFINE(CFITSIO_H, "fitsio.h", [CFITSIO header filename.])
  else
    AC_CHECK_HEADER(cfitsio/fitsio.h,[acx_cfitsio_ok=yes])
    if test x$acx_cfitsio_ok = xyes; then
      AC_DEFINE(CFITSIO_H, "cfitsio/fitsio.h", [CFITSIO header filename.])
    else
      CFITSIO_ERROR="CFITSIO include files not found at default location!"
    fi
  fi
66
else
67
68
69
70
71
72
  AC_CHECK_HEADER($2/fitsio.h,[acx_cfitsio_ok=yes])
  if test x$acx_cfitsio_ok = xyes; then
    AC_DEFINE_UNQUOTED(CFITSIO_H, "$2/fitsio.h", [CFITSIO header filename.])
  else
    CFITSIO_ERROR="CFITSIO include files not found in $2!"
  fi
73
74
fi

75
76
77
dnl --------------------
dnl Search library files
dnl --------------------
78

79
80
81
CFITSIO_LIBS=""
OLIBS="$LIBS"
LIBS=""
82

83
if test x$acx_cfitsio_ok = xyes; then
84
  if test x$1 = x; then
85
86
87
88
89
90
91
    AC_CHECK_LIB(cfitsio, ffopen, [acx_cfitsio_ok=yes], [acx_cfitsio_ok=no])
    if test x$acx_cfitsio_ok = xyes; then
      AC_DEFINE(HAVE_CFITSIO,1, [Define if you have the CFITSIO libraries and header files.])
      CFITSIO_LIBS="-lcfitsio"
    else
      CFITSIO_ERROR="CFITSIO library files not found at usual locations!"
    fi
92
  else
93
94
95
96
97
98
99
100
101
102
dnl -------------------------
dnl Specific libdir specified
dnl -------------------------
    AC_CHECK_LIB(cfitsio, ffopen, [acx_cfitsio_ok=yes], [acx_cfitsio_ok=no], [-L$1])
    if test x$acx_cfitsio_ok = xyes; then
      AC_DEFINE(HAVE_CFITSIO,1, [Define if you have the CFITSIO libraries and header files.])
        CFITSIO_LIBS="-L$1 -lcfitsio"
    else
      CFITSIO_ERROR="CFITSIO library files not found in $1!"
    fi
103
104
105
  fi
fi

106
107
LIBS="$OLIBS"
if test x$acx_cfitsio_ok = xyes; then
108
  AC_SUBST(CFITSIO_LIBS)
109
  $3
110
111
else
  AC_SUBST(CFITSIO_ERROR)
112
  $4
113
114
115
fi

])dnl ACX_CFITSIO