File: configure.ac

package info (click to toggle)
pftools 3+dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 2,344 kB
  • sloc: fortran: 11,706; ansic: 10,085; makefile: 85; sh: 65
file content (221 lines) | stat: -rw-r--r-- 8,683 bytes parent folder | download | duplicates (3)
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.68])
AC_INIT([PfTools],[3.0],[thierry.schuepbach@isb-sib.ch],[pftools])
AC_LANG([C])
AC_MSG_NOTICE([Configuring PfTools for your system.])
AC_CANONICAL_TARGET

AC_CONFIG_HEADERS([src/C/include/config.h])

AM_INIT_AUTOMAKE

PfTools_DATE="November 2012"
PfTools_COPYRIGHT="Copyright (C) 2012 Swiss Institute of Bioinformatics."
PfTools_LICENSE="Freely distributed under the GNU General Public License (GPLv3)."
PfTools_VERSION=$PACKAGE_VERSION
PfTools_URL="http://www.isb-sib.ch/"

#-------------------------------------------------------------------------------------------------------
# Checks for programs.
#-------------------------------------------------------------------------------------------------------
AC_PROG_F77
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_INSTALL
AX_COMPILER_VENDOR

#-------------------------------------------------------------------------------------------------------
# Checks for target system
#-------------------------------------------------------------------------------------------------------
if test $target_cpu != "x86_64" ; then
  AC_MSG_ERROR([Currently pftools only runs on 64 bit architectures.])
fi

#-------------------------------------------------------------------------------------------------------
# Add features.
#-------------------------------------------------------------------------------------------------------
AC_ARG_ENABLE(mmap,
              [AS_HELP_STRING([--enable-mmap],
              [use memory mapping of files rather than libc fopen, default is yes])],
              enable_mmap=$enableval, enable_mmap=yes)
AC_ARG_ENABLE(thread-affinity,
              [AS_HELP_STRING([--enable-thread-affinity],[Enforce affinity on threads, default is yes])],
              enable_thread_affinity=$enableval, enable_thread_affinity=yes)

#-------------------------------------------------------------------------------------------------------
# Checks for libraries.
#-------------------------------------------------------------------------------------------------------
if test $ax_cv_c_compiler_vendor = "intel"; then
  AC_CHECK_HEADERS([mathimf.h])
  AC_SUBST([INTEL_IMF],[-limf])
  AC_MSG_NOTICE([Intel IMF library will be used])
fi
AC_CHECK_LIB([m], [expf])

#-------------------------------------------------------------------------------------------------------
# Checks for header files.
#-------------------------------------------------------------------------------------------------------
AC_FUNC_ALLOCA
AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h sys/time.h unistd.h inttypes.h mm_malloc.h])

#-------------------------------------------------------------------------------------------------------
# Checks for typedefs, structures, and compiler characteristics.
#-------------------------------------------------------------------------------------------------------
AC_HEADER_STDBOOL
AC_PROG_CC_C99
if test "$ac_cv_prog_cc_c99" = "no"; then
  AC_MSG_ERROR([PfTools $PACKAGE_VERSION require a C compiler supporting C99 mode.])
fi
AC_C_INLINE
AC_C_VOLATILE
AC_C_CONST
AC_C_RESTRICT

AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_TYPE_UID_T
#AC_SYS_LARGEFILE

#AC_HEADER_TIME

AX_CHECK_COMPILE_FLAG(-msse2,[SIMD_SSE2_CFLAGS="-msse2"], SIMD_SSE2_CFLAGS="")
if test $SIMD_SSE2_CFLAGS != "-msse2"; then
  AC_MSG_ERROR([Compiler cannot generate SSE 2 code])
#else
#  AC_CHECK_HEADERS([emmintrin.h],[], [AC_MSG_ERROR([Missing SSE 2 header file emmintrin.h])])
fi
AC_SUBST(SIMD_SSE2_CFLAGS)

AX_CHECK_COMPILE_FLAG(-msse4.1,[SIMD_SSE4_1_CFLAGS="-msse4.1"], SIMD_SSE4_1_CFLAGS="")
if test $SIMD_SSE4_1_CFLAGS != "-msse4.1"; then
  AC_MSG_ERROR([Compiler cannot generate SSE 4.1 code])
#else
#  AC_CHECK_HEADERS([smmintrin.h],[], [AC_MSG_ERROR([Missing SSE 4.1 header file smmintrin.h])])
fi
AC_SUBST(SIMD_SSE4_1_CFLAGS)

AX_PTHREAD([AC_MSG_NOTICE([Posix thread found.])
	    AC_SUBST(PTHREAD_LIBS)
	    AC_SUBST(PTHREAD_CFLAGS) ],
	    AC_MSG_ERROR([Posix thread not found.]))

# get the fortran preprocessor option
AC_MSG_CHECKING([for $F77 option to accept preprocessor commands])
case $F77 in
  gfortran) AC_SUBST(FPP_OPTION,[-cpp])
	    AC_MSG_RESULT($FPP_OPTION);;
  g77)      AC_SUBST(FPP_OPTION,[-cpp])
            AC_MSG_RESULT($FPP_OPTION);;
  ifort)    AC_SUBST(FPP_OPTION,[-fpp])
            AC_MSG_RESULT($FPP_OPTION);;
  *)	    AC_MSG_RESULT([unknown])
            AC_MSG_NOTICE([You may encounter preprocessor statement warnings.])
esac
#-------------------------------------------------------------------------------------------------------
# Checks for library functions.
#-------------------------------------------------------------------------------------------------------
AC_FUNC_MALLOC

if test $enable_mmap = "yes"; then 
  AC_FUNC_MMAP
  if test "$ac_cv_func_mmap_fixed_mmaped" = "no"; then
      AC_MSG_NOTICE([The system does not support file memory mapping, option removed.])
  else
      AC_SUBST(USE_MMAP,[-D__USE_MMAP__])
  fi
fi

#-------------------------------------------------------------------------------------------------------
# Check for the Linux functions for controlling processor affinity.
#------------------------------------------------------------------------------------------------------- 
# LINUX: sched_setaffinity
# AIX:   bindprocessor
# OSX (Leopard): thread_policy_set
if test $enable_thread_affinity = "yes"; then
  AC_CHECK_FUNCS(sched_setaffinity sched_getaffinity bindprocessor thread_policy_set)
  if test "$ac_cv_func_sched_setaffinity" = "yes" ; then
      # Test for the cpu process set type
      AC_CACHE_CHECK(
	[whether cpu_set_t available],pac_cv_have_cpu_set_t,[
	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sched.h>]], [[ cpu_set_t t; ]])],[pac_cv_have_cpu_set_t=yes],[pac_cv_have_cpu_set_t=no])])
      if test "$pac_cv_have_cpu_set_t" = yes ; then
	  AC_DEFINE(HAVE_CPU_SET_T,1,[Define if cpu_set_t is defined in sched.h])

	  AC_CACHE_CHECK(
	    [whether the CPU_SET and CPU_ZERO macros are defined],
	    pac_cv_cpu_set_defined,
	    [
	      AC_LINK_IFELSE(
		[AC_LANG_PROGRAM(
		  [[#define _GNU_SOURCE
		  #include <sched.h>]],
		[[ cpu_set_t t; CPU_ZERO(&t); CPU_SET(1,&t); ]]
		)
		],
	      [pac_cv_cpu_set_defined=yes],
	      [pac_cv_cpu_set_defined=no]
	      )
	    ]
	  )
	  if test "$pac_cv_cpu_set_defined" = "yes" ; then
	      AC_DEFINE(HAVE_CPU_SET_MACROS,1,[Define if CPU_SET and CPU_ZERO defined])
	      #
	      # Check for pthread_{,attr_}[sg]etaffinity_np.
	      #
	      ac_orig_LIBS="$LIBS"
	      ac_orig_CFLAGS="$CFLAGS"
	      LIBS="$ac_orig_LIBS $PTHREAD_LIBS"
	      CFLAGS="$ac_orig_CFLAGS $PTHREAD_CFLAGS"
	      AC_MSG_CHECKING([pthread_attr_setaffinity_np])
	      AC_LINK_IFELSE(
		[AC_LANG_PROGRAM(
		  [#define _GNU_SOURCE
		   #include <pthread.h>],
		  [cpu_set_t cpuset;
		   pthread_attr_t attr;
		   pthread_getaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
		   if (CPU_ISSET (0, &cpuset))
		      CPU_SET (1, &cpuset);
		   else
		      CPU_ZERO (&cpuset);
		   pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
		   pthread_attr_init (&attr);
		   pthread_attr_getaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);
		   pthread_attr_setaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);
		  ])
		],
	        [AC_DEFINE(HAVE_PTHREAD_AFFINITY_NP, 1,[ Define if pthread_{,attr_}{g,s}etaffinity_np is supported.])
	         AC_SUBST(USE_AFFINITY,[-D__USE_AFFINITY__]) AC_MSG_RESULT([yes])
	        ],
	        [AC_MSG_RESULT([no])
	         AC_MSG_NOTICE([pthread_attr_setaffinity_np not available, affinity cannot be used.])
	        ]
	      )
	      LIBS="$ac_orig_LIBS"
	      CFLAGS="$ac_orig_CFLAGS"
	  else 
	      AC_MSG_NOTICE([CPU_SET and CPU_ZERO not available, affinity cannot be used.])
	  fi
      fi
  fi
  if test "$ac_cv_func_thread_policy_set" = yes ; then
      AC_CACHE_CHECK([whether thread affinity macros defined],
      pac_cv_have_thread_affinity_policy,[
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <mach/thread_policy.h>]], [[
  #if !defined(THREAD_AFFINITY_POLICY) || !defined(THREAD_AFFINITY_TAG_NULL)
      :'thread macros not defined
  ]])],[pac_cv_have_thread_affinity_policy=yes],[pac_cv_have_thread_affinity_policy=no])])
      if test "$pac_cv_have_thread_affinity_policy" = yes ; then
	  AC_DEFINE(HAVE_OSX_THREAD_AFFINITY,1,[Define is the OSX thread affinity policy macros defined])
      fi
  fi
  
  
fi

AC_CHECK_FUNCS([gettimeofday memset munmap strtol memcpy fseek ftell],[],[AC_MSG_ERROR([Missing function.])])


AC_CONFIG_FILES([Makefile src/Fortran/Makefile src/C/Makefile])
AC_OUTPUT