]> rtime.felk.cvut.cz Git - orte.git/blob - configure.ac
README added to shape_android.
[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 ###############################
147 # enable GNU source
148 AH_VERBATIM([_GNU_SOURCE],[
149 #ifndef _GNU_SOURCE
150   #define _GNU_SOURCE
151 #endif
152 ]) 
153
154 ###############################
155 # Checks for header files.
156 # user space
157 if test ${UNIX} == 'yes' -o ${WIN} == 'yes' ; then
158     AC_HEADER_STDC
159     AC_CHECK_HEADERS([\
160     arpa/inet.h fcntl.h stdio.h netdb.h stdlib.h \
161     string.h sys/ioctl.h sys/stat.h sys/time.h unistd.h pthread.h \
162     sys/types.h sys/sockio.h stdarg.h byteswap.h getopt.h \
163     ctype.h signal.h stdint.h errno.h],,,[[]])
164     AC_CHECK_HEADERS([sys/socket.h], [], [],
165           [#ifdef HAVE_SYS_TYPES_H
166              #include <sys/types.h>
167            #endif])
168     AC_CHECK_HEADERS([netinet/in.h], [], [],
169           [#ifdef HAVE_SYS_TYPES_H
170              #include <sys/types.h>
171            #endif])
172     AC_CHECK_HEADERS([net/if.h], [], [],
173           [#ifdef HAVE_SYS_TYPES_H
174              #include <sys/types.h>
175            #endif
176            #ifdef HAVE_SYS_SOCKET_H
177              #include <sys/socket.h>
178            #endif])
179 fi
180 # win32
181 if test ${WIN} == 'yes' ; then
182     AC_CHECK_HEADERS([\
183     winsock2.h ws2tcpip.h windows.h w32api/windows.h],,,[[]])
184     AC_CHECK_FUNCS([gettimeofday])
185 fi
186 # kernel
187 if test "${CONFIG_ORTE_KERNEL}" == 'yes' ; then
188     AC_CHECK_HEADERS([\
189     asm/byteorder.h linux/ctype.h linux/string.h \
190     linux/module.h linux/if.h linux/socket.h \
191     linux/time.h linux/types.h],,,[[]])
192     AC_CHECK_HEADERS([linux/in.h],,,[
193     #ifdef HAVE_LINUX_SOCKET_H
194       #include <linux/socket.h>
195     #endif
196     ])
197 fi
198 # RTLinux
199 if test ${USE_RTLINUX} == 'yes' ; then
200     AC_CHECK_HEADERS([\
201     string.h pthread.h \
202     rtl.h rtl_malloc.h udp.h nic.h time.h],,,[[]])
203     AC_CHECK_HEADERS([nictab.h],,,[
204     #ifdef HAVE_UDP_H
205       #include <udp.h>
206     #endif
207     #ifdef HAVE_NIC_H
208       #include <nic.h>
209     #endif
210     ])
211     AC_CHECK_HEADERS([onetd.h],,,[
212     #ifdef HAVE_LINUX_IF_H
213       #include <linux/if.h>
214     #endif
215     #ifdef HAVE_LINUX_IN_H
216       #include <linux/in.h>
217     #endif
218     #ifdef HAVE_PTHREAD_H
219       #include <pthread.h>
220     #endif
221     ])
222 fi
223 # RTAI
224 if test ${USE_RTAI} == 'yes' ; then
225     AC_CHECK_HEADERS([\
226     rtnet.h],,,[[]])
227 fi
228
229 ###############################
230 # includes
231 INCLUDES='-I$(top_srcdir)/orte/include -I$(top_builddir)/orte/include'
232 AC_SUBST(INCLUDES)
233
234 ###############################
235 # Checks for typedefs, structures, and compiler characteristics.
236
237 AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,[#ifdef HAVE_SYS_TYPES_H
238                    #include <sys/types.h>
239                  #endif
240                  #ifdef HAVE_SYS_SOCKET_H
241                    #include <sys/socket.h>
242                  #endif
243                  #ifdef HAVE_WINSOCK2_H
244                    #include <winsock2.h>
245                  #endif])
246
247
248 AC_CHECK_HEADERS([ifaddrs.h],,,[#ifdef HAVE_SYS_TYPES_H
249              #include <sys/types.h>
250            #endif])
251
252 ###############################
253 # Endianness support attempts to allow build with same configure
254 # for both cases on recent systems
255
256 need_endian_test=yes
257 AC_CHECK_HEADERS([endian.h sys/param.h], [], [],[])
258
259 if test "$ac_cv_header_sys_param_h" == 'yes' ; then
260     AC_MSG_CHECKING([whether BYTE_ORDER defined in sys/param.h])
261     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/param.h>], [
262                         unsigned int a=BYTE_ORDER;
263                         unsigned int b=BIG_ENDIAN;
264                         unsigned int c=LITTLE_ENDIAN;])],
265                       [AC_MSG_RESULT([yes])
266                        need_endian_test=no],[AC_MSG_RESULT([no])])
267
268     if test "$need_endian_test" == 'yes' ; then
269         AC_MSG_CHECKING([whether __BYTE_ORDER defined in sys/param.h])
270         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/param.h>], [
271                         unsigned int a=__BYTE_ORDER;
272                         unsigned int b=__BIG_ENDIAN;
273                         unsigned int c=__LITTLE_ENDIAN;])],
274                       [AC_MSG_RESULT([yes])
275                        need_endian_test=no],[AC_MSG_RESULT([no])])
276     fi
277 fi
278 if test "$ac_cv_header_endian_h" == 'yes' ; then
279     if test "$need_endian_test" == 'yes' ; then
280         AC_MSG_CHECKING([whether endian can be determined from endian.h])
281         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <endian.h>], [
282                         unsigned int a=__BYTE_ORDER;
283                         unsigned int b=__BIG_ENDIAN;
284                         unsigned int c=__LITTLE_ENDIAN;])],
285                       [AC_MSG_RESULT([yes])
286                        need_endian_test=no],[AC_MSG_RESULT([no])])
287     fi
288 fi
289
290 if test "$need_endian_test" == 'yes' ; then
291   AC_C_BIGENDIAN
292 fi
293
294 AH_BOTTOM([
295 #if defined(HAVE_ENDIAN_H) || defined(HAVE_SYS_PARAM_H)
296   #ifdef HAVE_SYS_PARAM_H
297     #include <sys/param.h>
298   #endif
299   #if defined(HAVE_ENDIAN_H) && !defined(BYTE_ORDER) && !defined(__BYTE_ORDER)
300     #include <endian.h>
301   #endif
302   #if defined(__BYTE_ORDER)
303     #if __BYTE_ORDER == __BIG_ENDIAN
304       #define WORDS_BIGENDIAN 1
305     #endif
306   #elif defined(BYTE_ORDER)
307     #if BYTE_ORDER == BIG_ENDIAN
308       #define WORDS_BIGENDIAN 1
309     #endif
310   #endif
311 #endif
312 ])
313
314 AC_C_CONST
315 AC_C_INLINE
316
317 ###############################
318 # Checks for library functions.
319 AC_PROG_GCC_TRADITIONAL
320 if test -z "${CONFIG_ORTE_RT}" ; then
321 AC_CHECK_FUNCS([gethostbyname getopt_long sigwaitinfo])
322 fi
323
324 AC_CONFIG_FILES([Makefile
325                  orte/Makefile
326                  orte/liborte/Makefile
327                  orte/liborte/rtl/Makefile
328                  orte/examples/Makefile
329                  orte/examples/hello/Makefile
330                  orte/examples/multicast/Makefile
331                  orte/examples/reliable/Makefile
332                  orte/examples/ping/Makefile
333                  orte/examples/spy/Makefile
334                  orte/examples/schneider/Makefile
335                  orte/examples/mpo/Makefile
336                  orte/idl-compiler/Makefile
337                  orte/libjorte/Makefile
338                  orte/manager/Makefile])
339
340 LIBS="$LIBS$INTERNAL_PTHREAD_LIBS"
341
342 AC_CONFIG_FILES([
343 modtool
344 ])
345 AC_OUTPUT
346 chmod +x modtool
347
348 # ======================================================================
349 #               generate orte/include/orte/orte_config.h
350 # ======================================================================
351
352 AC_MSG_NOTICE([fixing orte/include/orte/orte_config.h])
353 sed -e "s/ PACKAGE/ ORTE_PACKAGE/" -e "s/ VERSION/ ORTE_VERSION/" \
354     orte/include/orte/orte_config.h >orte/include/orte/orte_config.h.new
355 if cmp -s orte/include/orte/orte_config.h.new orte/include/orte/orte_config.h; then
356         rm orte/include/orte/orte_config.h.new
357         AC_MSG_NOTICE([orte/include/orte/orte_config.h is unchanged])
358 else
359         mv orte/include/orte/orte_config.h.new orte/include/orte/orte_config.h
360 fi
361
362 echo \
363 "------------------------------------------------------------------------
364 Configuration ORTE:
365
366   Source code location:       ${srcdir}
367   Compiler:                   ${CC}
368   Compiler flags:             ${CFLAGS}
369   Host System Type:           ${host}
370   
371   See orte_config.h for future configuration information.
372   
373   Now you can run
374   make  
375   
376 ------------------------------------------------------------------------"
377