-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure.ac
136 lines (113 loc) · 3.7 KB
/
configure.ac
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
AC_PREREQ(2.57)
AC_INIT([rphast], 1.5, [mjhubisz@cornell.edu], [], [http://compgen.cshl.edu/phast])
#AC_CONFIG_SRCDIR([RPHAST/src/rph_init.c])
: ${R_HOME=`R RHOME`}
if test -z "${R_HOME}"; then
AC_MSG_ERROR([Could not determine R_HOME.])
fi
AC_MSG_CHECKING(for CFLAGS)
#AC_PROG_CC
CC=`"${R_HOME}/bin/R" CMD config CC`
#RCFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS`
RCFLAGS="-g"
#CFLAGS="${RCFLAGS} ${CFLAGS}"
CFLAGS="${CFLAGS} -g"
AC_MSG_RESULT(${CFLAGS})
AC_PROG_CC
AC_MSG_RESULT(${CFLAGS})
# Checks for header files.
AC_FUNC_ALLOCA
AC_HEADER_STDC
AC_CHECK_HEADERS([stddef.h stdlib.h string.h strings.h sys/time.h unistd.h], ,
[AC_MSG_ERROR(
[Couldn't find all necessary system headers])])
AC_CHECK_HEADER(pcre.h, , [AC_MSG_ERROR([Couldn't find pcre.h... download/install at www.pcre.org])])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_HEADER_STDBOOL
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_MEMCMP
AC_FUNC_REALLOC
AC_FUNC_STRTOD
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([atexit bzero floor gethostname gettimeofday memset pow re_comp regcomp rint sqrt strcasecmp strdup strstr strtol])
AC_SEARCH_LIBS([pcre_compile], [pcre], [],
[AC_MSG_RESULT(no)
AC_MSG_ERROR([ Need to install pcre ])])
# Check for Accelerate framework first
AC_MSG_CHECKING(for Accelerate)
OLD_CFLAGS=${CFLAGS}
OLD_LIBS=${LIBS}
CFLAGS="${CFLAGS} -DACCELERATE"
LIBS="${LIBS} -framework Accelerate"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM()],
[AC_MSG_RESULT(yes)
LAPACK_FLAG="-DACCELERATE"
LAPACK_LIBS="-framework Accelerate"],
[AC_MSG_RESULT(no)
CFLAGS=${OLD_CFLAGS}
LIBS=${OLD_LIBS}
# If Accelerate is not found, check for vecLib
AC_MSG_CHECKING(for vecLib)
CFLAGS="${CFLAGS} -DVECLIB"
LIBS="${LIBS} -framework vecLib"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM()],
[AC_MSG_RESULT(yes)
LAPACK_FLAG="-DVECLIB"
LAPACK_LIBS="-framework vecLib"],
[AC_MSG_RESULT(no)
CFLAGS=${OLD_CFLAGS}
LIBS=${OLD_LIBS}]
)
]
)
CFLAGS=${OLD_CFLAGS}
LIBS=${OLD_LIBS}
# if not veclib, try to use R's lapack
if test -z "$LAPACK_FLAG"; then
LAPACK_LIBS=`"${R_HOME}/bin/R" CMD config LAPACK_LIBS`
BLAS_LIBS=`"${R_HOME}/bin/R" CMD config BLAS_LIBS`
FLIBS=`"${R_HOME}/bin/R" CMD config FLIBS`
SHLIB=`"${R_HOME}/bin/R" CMD config SHLIB_LDFLAGS`
FPIC=`"${R_HOME}/bin/R" CMD config CPICFLAGS`
LIBS="${FPIC} ${SHLIB} ${LAPACK_LIBS} ${BLAS_LIBS} ${FLIBS}"
AC_MSG_CHECKING(for R's Lapack)
AC_LINK_IFELSE([AC_LANG_PROGRAM()],
[AC_MSG_RESULT(yes)
LAPACK_LIBS="\${LAPACK_LIBS} \${BLAS_LIBS} \${FLIBS}"
LAPACK_FLAG="-DR_LAPACK"
],
[AC_MSG_RESULT(no)
AC_MSG_ERROR(Error linking to R's lapack library. Check R installation.)])
fi
LIBS="${OLD_LIBS}"
OLD_CFLAGS=${CFLAGS}
#Removing -g flag (CRAN rules)
#CFLAGS="${CFLAGS} -fno-strict-aliasing"
CFLAGS="-fno-strict-aliasing"
AC_MSG_CHECKING(for -fno-strict-aliasing)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT(yes), [AC_MSG_RESULT(no)
CFLAGS=${OLD_CFLAGS}])
AC_C_INLINE
AC_SUBST(LAPACK_FLAG)
AC_SUBST(LAPACK_LIBS)
AC_SUBST(CFLAGS)
AC_OUTPUT(src/Makevars)
cat <<EOF
$PACKAGE-$VERSION configuration summary:
C preprocessor .................. : ${CPP}
C compiler ...................... : ${CC}
C compiler flags ................ : ${CFLAGS}
Extra libraries ................. : ${LIBS}
Lapack flag ..................... : ${LAPACK_FLAG}
Lapack libs ..................... : ${LAPACK_LIBS}
BLAS libs ....................... : ${BLAS_LIBS}
FLIBS ........................... : ${FLIBS}
EOF
dnl end configure.ac