]> rtime.felk.cvut.cz Git - orte.git/blob - configure.ac
Add shell.nix
[orte.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2 #
3 # $Id: configure.in,v 1.15 2008/10/07 21:19:01 smolik Exp $
4
5 # autoconf requirement
6
7 AC_PREREQ([2.69])
8
9 AC_INIT([orte],[0.3.4],[orte@rtime.felk.cvut.cz],[],[http://orte.sf.net])
10 AC_CONFIG_AUX_DIR(admin)
11
12 ###############################
13 # Package info
14 ORTE_MAJOR_VERSION=0
15 ORTE_MINOR_VERSION=3
16 ORTE_MICRO_VERSION=3
17 ORTE_VERSION=$ORTE_MAJOR_VERSION.$ORTE_MINOR_VERSION.$ORTE_MICRO_VERSION
18 AC_SUBST(ORTE_MAJOR_VERSION)
19 AC_SUBST(ORTE_MINOR_VERSION)
20 AC_SUBST(ORTE_MICRO_VERSION)
21 AC_SUBST(ORTE_VERSION)
22
23 # Libtool versioning (see libtool manual)
24
25 LT_CURRENT=1 # This will be part of SONAME
26 LT_REVISION=0
27 LT_AGE=0
28 AC_SUBST(LT_CURRENT)
29 AC_SUBST(LT_REVISION)
30 AC_SUBST(LT_AGE)
31 VERSION=$ORTE_VERSION
32 PACKAGE=orte
33
34 echo
35 echo "ORTE version $PACKAGE_VERSION"
36 echo "Configuring..."
37 echo
38
39 #Check for CPU / vendor / OS
40 AC_CANONICAL_HOST
41 AC_CANONICAL_TARGET
42 AC_CONFIG_HEADER(orte/include/orte/orte_config.h)
43 AM_INIT_AUTOMAKE(no-define)
44
45 AC_CONFIG_MACRO_DIR([admin])
46
47 # Activate maintainer mode
48 AM_MAINTAINER_MODE
49
50 DS_LINUX()
51
52 ###############################
53 # target
54 WIN='no'
55 MINGW='no'
56 CYGWIN='no'
57 UNIX='no'
58 case "$target" in
59   *-cygwin*)
60     CFLAGS="$CFLAGS"
61     WIN='yes'
62     CYGWIN='yes'
63     AC_DEFINE([CONFIG_ORTE_WIN],[1],[Define if is target windows])
64     AC_DEFINE([CONFIG_ORTE_CYGWIN],[1],[Define if is target CYGWIN])
65     ;;  
66   *-mingw*)
67     CFLAGS="$CFLAGS"
68     WIN='yes'
69     MINGW='yes'
70     AC_DEFINE([CONFIG_ORTE_WIN],[1],[Define if is target windows])
71     AC_DEFINE([CONFIG_ORTE_MINGW],[1],[Define if is target MINGW])
72     AC_DEFINE([HAVE_GETPOT_LONG_ORTE],[1],[Define for ORTE getopt_long self implemetation])
73     ;;
74   *)
75     # Assume a Unix.
76     if test -z "${CONFIG_ORTE_RT}" -a "${CONFIG_ORTE_KERNEL}" ; then
77       UNIX='yes'
78       AC_DEFINE([CONFIG_ORTE_UNIX],[1],[Define if is target a unix system])
79     fi
80     ;;
81 esac
82 AM_CONDITIONAL(CONFIG_ORTE_WIN, test x$WIN = xyes)
83 AM_CONDITIONAL(CONFIG_ORTE_CYGWIN, test x$CIGWIN = xyes)
84 AM_CONDITIONAL(CONFIG_ORTE_MINGW, test x$MINGW = xyes)
85 AM_CONDITIONAL(CONFIG_ORTE_UNIX, test x$UNIX = xyes)
86
87 ###############################
88 # modules
89 moduledir="\$(libdir)/modules/\$(LINUX_KERNELRELEASE)/orte"
90 modulePROGRAMS_INSTALL="\$(top_builddir)/modtool --install"
91 modulePROGRAMS_UNINSTALL="\$(top_builddir)/modtool --uninstall"
92 AC_SUBST(moduledir)
93 AC_SUBST(modulePROGRAMS_INSTALL)
94
95 ###############################
96 # CFLAGS
97 CFLAGS="$CFLAGS -Wall"
98 if test ${USE_RTLINUX} == 'yes' ; then
99   CFLAGS="$CFLAGS $RTLINUX_CFLAGS"
100   CC="$RTLINUX_CC"
101 else
102   if test ${USE_RTAI} == 'yes' ; then
103     CFLAGS="$CFLAGS $RTAI_CFLAGS $LINUX_CFLAGS"
104   else
105     if test -n "${CONFIG_ORTE_KERNEL}" ; then
106       CFLAGS="$CFLAGS $LINUX_CFLAGS"
107     fi
108   fi
109 fi
110
111 ###############################
112 # Checks for programs.
113 # Initialize libtool
114 AC_PROG_CC
115 AM_PROG_CC_C_O
116 LT_INIT([win32-dll])
117 PKG_PROG_PKG_CONFIG()
118
119 ###############################
120 # Checks for ability to compile ORTE_IDL
121 AM_ORTE_IDL
122
123 ###############################
124 # Checks for ability to compile JORTE
125 AM_JORTE
126
127 ###############################
128 # Checks for libraries and init libtools
129 if test -z "${CONFIG_ORTE_RT}" ; then
130   AC_CHECK_LIB([ws2_32], [main])
131   AC_CHECK_LIB([socket], [main])
132   AC_CHECK_LIB([nsl], [main])
133   dnl Check for pthreads
134   AC_CHECK_LIB(pthread, pthread_create, ,
135          AC_CHECK_LIB(c_r, pthread_create, ,
136               if test ${MINGW} == 'yes' ; then
137                      INTERNAL_PTHREAD_LIBS=' -L$(top_srcdir)/orte/contrib/win_pthread/ -lpthread'
138                      AC_MSG_NOTICE([Using internal version of pthreads!!!])
139               else
140                      AC_MSG_ERROR([Can't compile without pthreads!!!])
141               fi       
142          )
143   )
144 fi
145
146 AC_CHECK_FUNCS([pthread_condattr_setclock])
147 AC_CHECK_LIB([rt], [clock_gettime])
148 AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include <time.h>]])
149
150 ###############################
151 # enable GNU source
152 AH_VERBATIM([_GNU_SOURCE],[
153 #ifndef _GNU_SOURCE
154   #define _GNU_SOURCE
155 #endif
156 ]) 
157
158 ###############################
159 # Checks for header files.
160 # user space
161 if test ${UNIX} == 'yes' -o ${WIN} == 'yes' ; then
162     AC_HEADER_STDC
163     AC_CHECK_HEADERS([\
164     arpa/inet.h fcntl.h stdio.h netdb.h stdlib.h \
165     string.h sys/ioctl.h sys/stat.h sys/time.h unistd.h pthread.h \
166     sys/types.h sys/sockio.h stdarg.h byteswap.h getopt.h \
167     ctype.h signal.h stdint.h errno.h],,,[[]])
168     AC_CHECK_HEADERS([sys/socket.h], [], [],
169           [#ifdef HAVE_SYS_TYPES_H
170              #include <sys/types.h>
171            #endif])
172     AC_CHECK_HEADERS([netinet/in.h], [], [],
173           [#ifdef HAVE_SYS_TYPES_H
174              #include <sys/types.h>
175            #endif])
176     AC_CHECK_HEADERS([net/if.h], [], [],
177           [#ifdef HAVE_SYS_TYPES_H
178              #include <sys/types.h>
179            #endif
180            #ifdef HAVE_SYS_SOCKET_H
181              #include <sys/socket.h>
182            #endif])
183 fi
184 # win32
185 if test ${WIN} == 'yes' ; then
186     AC_CHECK_HEADERS([\
187     winsock2.h ws2tcpip.h windows.h w32api/windows.h],,,[[]])
188     AC_CHECK_FUNCS([gettimeofday])
189 fi
190 # kernel
191 if test "${CONFIG_ORTE_KERNEL}" == 'yes' ; then
192     AC_CHECK_HEADERS([\
193     asm/byteorder.h linux/ctype.h linux/string.h \
194     linux/module.h linux/if.h linux/socket.h \
195     linux/time.h linux/types.h],,,[[]])
196     AC_CHECK_HEADERS([linux/in.h],,,[
197     #ifdef HAVE_LINUX_SOCKET_H
198       #include <linux/socket.h>
199     #endif
200     ])
201 fi
202 # RTLinux
203 if test ${USE_RTLINUX} == 'yes' ; then
204     AC_CHECK_HEADERS([\
205     string.h pthread.h \
206     rtl.h rtl_malloc.h udp.h nic.h time.h],,,[[]])
207     AC_CHECK_HEADERS([nictab.h],,,[
208     #ifdef HAVE_UDP_H
209       #include <udp.h>
210     #endif
211     #ifdef HAVE_NIC_H
212       #include <nic.h>
213     #endif
214     ])
215     AC_CHECK_HEADERS([onetd.h],,,[
216     #ifdef HAVE_LINUX_IF_H
217       #include <linux/if.h>
218     #endif
219     #ifdef HAVE_LINUX_IN_H
220       #include <linux/in.h>
221     #endif
222     #ifdef HAVE_PTHREAD_H
223       #include <pthread.h>
224     #endif
225     ])
226 fi
227 # RTAI
228 if test ${USE_RTAI} == 'yes' ; then
229     AC_CHECK_HEADERS([\
230     rtnet.h],,,[[]])
231 fi
232
233 ###############################
234 # includes
235 INCLUDES='-I$(top_srcdir)/orte/include -I$(top_builddir)/orte/include'
236 AC_SUBST(INCLUDES)
237
238 ###############################
239 # Checks for typedefs, structures, and compiler characteristics.
240
241 AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,[#ifdef HAVE_SYS_TYPES_H
242                    #include <sys/types.h>
243                  #endif
244                  #ifdef HAVE_SYS_SOCKET_H
245                    #include <sys/socket.h>
246                  #endif
247                  #ifdef HAVE_WINSOCK2_H
248                    #include <winsock2.h>
249                  #endif])
250
251
252 AC_CHECK_HEADERS([ifaddrs.h],,,[#ifdef HAVE_SYS_TYPES_H
253              #include <sys/types.h>
254            #endif])
255
256 ###############################
257 # Endianness support attempts to allow build with same configure
258 # for both cases on recent systems
259
260 need_endian_test=yes
261 AC_CHECK_HEADERS([endian.h sys/param.h], [], [],[])
262
263 if test "$ac_cv_header_sys_param_h" == 'yes' ; then
264     AC_MSG_CHECKING([whether BYTE_ORDER defined in sys/param.h])
265     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/param.h>], [
266                         unsigned int a=BYTE_ORDER;
267                         unsigned int b=BIG_ENDIAN;
268                         unsigned int c=LITTLE_ENDIAN;])],
269                       [AC_MSG_RESULT([yes])
270                        need_endian_test=no],[AC_MSG_RESULT([no])])
271
272     if test "$need_endian_test" == 'yes' ; then
273         AC_MSG_CHECKING([whether __BYTE_ORDER defined in sys/param.h])
274         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/param.h>], [
275                         unsigned int a=__BYTE_ORDER;
276                         unsigned int b=__BIG_ENDIAN;
277                         unsigned int c=__LITTLE_ENDIAN;])],
278                       [AC_MSG_RESULT([yes])
279                        need_endian_test=no],[AC_MSG_RESULT([no])])
280     fi
281 fi
282 if test "$ac_cv_header_endian_h" == 'yes' ; then
283     if test "$need_endian_test" == 'yes' ; then
284         AC_MSG_CHECKING([whether endian can be determined from endian.h])
285         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <endian.h>], [
286                         unsigned int a=__BYTE_ORDER;
287                         unsigned int b=__BIG_ENDIAN;
288                         unsigned int c=__LITTLE_ENDIAN;])],
289                       [AC_MSG_RESULT([yes])
290                        need_endian_test=no],[AC_MSG_RESULT([no])])
291     fi
292 fi
293
294 if test "$need_endian_test" == 'yes' ; then
295   AC_C_BIGENDIAN
296 fi
297
298 AH_BOTTOM([
299 #if defined(HAVE_ENDIAN_H) || defined(HAVE_SYS_PARAM_H)
300   #ifdef HAVE_SYS_PARAM_H
301     #include <sys/param.h>
302   #endif
303   #if defined(HAVE_ENDIAN_H) && !defined(BYTE_ORDER) && !defined(__BYTE_ORDER)
304     #include <endian.h>
305   #endif
306   #if defined(__BYTE_ORDER)
307     #if __BYTE_ORDER == __BIG_ENDIAN
308       #define WORDS_BIGENDIAN 1
309     #endif
310   #elif defined(BYTE_ORDER)
311     #if BYTE_ORDER == BIG_ENDIAN
312       #define WORDS_BIGENDIAN 1
313     #endif
314   #endif
315 #endif
316 ])
317
318 AC_C_CONST
319 AC_C_INLINE
320
321 ###############################
322 # Checks for library functions.
323 AC_PROG_GCC_TRADITIONAL
324 if test -z "${CONFIG_ORTE_RT}" ; then
325 AC_CHECK_FUNCS([gethostbyname getopt_long sigwaitinfo])
326 fi
327
328 AC_CONFIG_FILES([Makefile
329                  orte/Makefile
330                  orte/liborte/Makefile
331                  orte/liborte/rtl/Makefile
332                  orte/examples/Makefile
333                  orte/examples/hello/Makefile
334                  orte/examples/multicast/Makefile
335                  orte/examples/reliable/Makefile
336                  orte/examples/ping/Makefile
337                  orte/examples/spy/Makefile
338                  orte/examples/schneider/Makefile
339                  orte/examples/mpo/Makefile
340                  orte/idl-compiler/Makefile
341                  orte/libjorte/Makefile
342                  orte/manager/Makefile])
343
344 LIBS="$LIBS$INTERNAL_PTHREAD_LIBS"
345
346 AC_CONFIG_FILES([
347 modtool
348 ])
349 AC_OUTPUT
350 chmod +x modtool
351
352 # ======================================================================
353 #               generate orte/include/orte/orte_config.h
354 # ======================================================================
355
356 AC_MSG_NOTICE([fixing orte/include/orte/orte_config.h])
357 sed -e "s/ PACKAGE/ ORTE_PACKAGE/" -e "s/ VERSION/ ORTE_VERSION/" \
358     orte/include/orte/orte_config.h >orte/include/orte/orte_config.h.new
359 if cmp -s orte/include/orte/orte_config.h.new orte/include/orte/orte_config.h; then
360         rm orte/include/orte/orte_config.h.new
361         AC_MSG_NOTICE([orte/include/orte/orte_config.h is unchanged])
362 else
363         mv orte/include/orte/orte_config.h.new orte/include/orte/orte_config.h
364 fi
365
366 echo \
367 "------------------------------------------------------------------------
368 Configuration ORTE:
369
370   Source code location:       ${srcdir}
371   Compiler:                   ${CC}
372   Compiler flags:             ${CFLAGS}
373   Host System Type:           ${host}
374   
375   See orte_config.h for future configuration information.
376   
377   Now you can run
378   make  
379   
380 ------------------------------------------------------------------------"
381