Bump date stamp to 20130514
[official-gcc.git] / libgupc / configure.ac
blob4412a0ea07fea6687219309979cfb46a0600da2f
1 # Process this file with autoconf to produce a configure script, like so:
2 # aclocal -I . -I .. -I ../config && autoconf && autoheader && automake
4 #   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
5 #   2010, 2011, 2012
6 #   Free Software Foundation, Inc.
7 #   Contributed by Gary Funck <gary@intrepid.com>
8 #   Derived from libgomp/configure.ac
10 #This file is part of GNU UPC.
12 #GNU UPC is free software; you can redistribute it and/or modify
13 #it under the terms of the GNU General Public License as published by
14 #the Free Software Foundation; either version 2, or (at your option)
15 #any later version.
17 #GNU UPC is distributed in the hope that it will be useful,
18 #but WITHOUT ANY WARRANTY; without even the implied warranty of
19 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 #GNU General Public License for more details.
22 #You should have received a copy of the GNU General Public License
23 #along with GNU UPC; see the file COPYING.  If not, write to
24 #the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 #02111-1307, USA.
27 AC_PREREQ(2.64)
28 AC_INIT([GNU UPC Runtime Library], 1.0,,[libgupc])
29 AC_CONFIG_SRCDIR([include/upc.h])
30 AC_CONFIG_HEADERS([config.h])
32 # -------
33 # Options
34 # -------
36 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
37 LIBGUPC_ENABLE(version-specific-runtime-libs, no, ,
38    [specify that runtime libraries should be installed
39    in a compiler-specific directory],
40    permit yes|no)
41 AC_MSG_RESULT($enable_version_specific_runtime_libs)
43 # We would like our source tree to be readonly. However when releases or
44 # pre-releases are generated, the flex/bison generated files as well as the
45 # various formats of manuals need to be included along with the rest of the
46 # sources.  Therefore we have --enable-generated-files-in-srcdir to do
47 # just that.
48 AC_MSG_CHECKING([for --enable-generated-files-in-srcdir])
49 LIBGUPC_ENABLE(generated-files-in-srcdir, no, ,
50    [put copies of generated files in source dir intended for creating source
51     tarballs for users without texinfo bison or flex],
52    permit yes|no)
53 AC_MSG_RESULT($enable_generated_files_in_srcdir)
54 AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
57 # -------
58 # Get build environment
59 # -------
61 # Gets build, host, target, *_vendor, *_cpu, *_os, etc.
63 # You will slowly go insane if you do not grok the following fact:  when
64 # building this library, the top-level /target/ becomes the library's /host/.
66 # configure then causes --target to default to --host, exactly like any
67 # other package using autoconf.  Therefore, 'target' and 'host' will
68 # always be the same.  This makes sense both for native and cross compilers
69 # just think about it for a little while.  :-)
71 # Also, if this library is being configured as part of a cross compiler, the
72 # top-level configure script will pass the "real" host as $with_cross_host.
74 # Do not delete or change the following two lines.  For why, see
75 # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
76 AC_CANONICAL_SYSTEM
77 target_alias=${target_alias-$host_alias}
79 # Sets up automake.  Must come after AC_CANONICAL_SYSTEM.  Each of the
80 # following is magically included in AUTOMAKE_OPTIONS in each Makefile.am.
81 #  1.11.1:  minimum required version
82 #  no-define:  PACKAGE and VERSION will not be #define'd in config.h (a bunch
83 #              of other PACKAGE_* variables will, however, and there's nothing
84 #              we can do about that; they come from AC_INIT).
85 #  foreign:  we don't follow the normal rules for GNU packages (no COPYING
86 #            file in the top srcdir, etc, etc), so stop complaining.
87 #  -Wall:  turns on all automake warnings...
88 #  -Wno-portability:  ...except this one, since GNU make is required.
89 #  -Wno-override: ... and this one, since we do want this in testsuite.
90 AM_INIT_AUTOMAKE([1.11.1 foreign -Wall -Wno-portability -Wno-override])
92 # UPC disables multilib for portals4 runtime
93 if echo "${with_upc_runtime}" | grep -v -i '^portals4$' 2>&1 >/dev/null; then
94   AM_ENABLE_MULTILIB(, ..)
97 # Calculate toolexeclibdir
98 # Also toolexecdir, though it's only used in toolexeclibdir
99 case ${enable_version_specific_runtime_libs} in
100   yes)
101     # Need the gcc compiler version to know where to install libraries
102     # and header files if --enable-version-specific-runtime-libs option
103     # is selected.
104     toolexecdir='$(libdir)/gcc/$(target_alias)'
105     toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
106     ;;
107   no)
108     if test -n "$with_cross_host" &&
109        test x"$with_cross_host" != x"no"; then
110       # Install a library built with a cross compiler in tooldir, not libdir.
111       toolexecdir='$(exec_prefix)/$(target_alias)'
112       toolexeclibdir='$(toolexecdir)/lib'
113     else
114       toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
115       toolexeclibdir='$(libdir)'
116     fi
117     multi_os_directory=`$CC -print-multi-os-directory`
118     case $multi_os_directory in
119       .) ;; # Avoid trailing /.
120       *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
121     esac
122     ;;
123   *)
124     AC_MSG_ERROR(['$enable_version_specific_runtime_libs' is not set])
125     ;;
126 esac
127 AC_SUBST(toolexecdir)
128 AC_SUBST(toolexeclibdir)
130 # If the language specific compiler does not exist, but the "gcc" directory
131 # does, we do not build anything. Note, $r is set by the top-level Makefile.
132 # Note that when we look for the compiler, we search both with and without
133 # extension to handle cross and canadian cross builds.
134 compiler_name=cc1upc
135 rm -f skip-this-dir
136 AC_MSG_CHECKING(if compiler $compiler_name has been built)
137 AC_CACHE_VAL(upc_cv_compiler_exists,
139   upc_cv_compiler_exists=yes
140   if test -n "$r"; then
141     if test -d "$r"/gcc; then
142       if test -f "$r"/gcc/$compiler_name \
143            -o -f "$r"/gcc/$compiler_name.exe; then
144         true
145       else
146         upc_cv_compiler_exists=no
147       fi
148     fi
149   fi
151 AC_MSG_RESULT($upc_cv_compiler_exists)
152 AC_MSG_CHECKING([if UPC driver 'gupc' has been built])
153 AC_CACHE_VAL(upc_cv_driver_exists,
155   upc_cv_driver_exists=yes
156   if test -n "$r"; then
157     if test -d "$r"/gcc; then
158       if (test -f "$r"/gcc/gupc && test -f "$r"/gcc/gupc); then
159         true
160       else
161         upc_cv_driver_exists=no
162       fi
163     fi
164   fi
166 AC_MSG_RESULT($upc_cv_driver_exists)
167 if test x$upc_cv_compiler_exists = xno \
168      -o x$upc_cv_driver_exists = xno
169 then
170   echo "rm -f config.cache config.log multilib.out" > skip-this-dir
171   rm -f Makefile conftest* confdefs* core
172   exit 0
175 # Check the compiler.
176 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
177 # We must force CC to /not/ be precious variables; otherwise
178 # the wrong, non-multilib-adjusted value will be used in multilibs.
179 # As a side effect, we have to subst CFLAGS ourselves.
181 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
182 m4_define([_AC_ARG_VAR_PRECIOUS],[])
183 AC_PROG_CC
184 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
186 AC_SUBST(CFLAGS)
189 # If UPCFLAGS hasn't been set explicitly then default to "$CFLAGS".
191 if test x"$UPCFLAGS" = "x"; then
192   UPCFLAGS="$CFLAGS"
195 AC_SUBST(UPCFLAGS)
197 # In order to override CFLAGS_FOR_TARGET, all of our special flags go
198 # in XCFLAGS.  But we need them in CFLAGS during configury.  So put them
199 # in both places for now and restore CFLAGS at the end of config.
200 save_CFLAGS="$CFLAGS"
202 # Add -Wall -Werror if we are using GCC.
203 if test "x$GCC" = "xyes"; then
204   XCFLAGS="$XCFLAGS -Wall -Werror"
207 dnl The UPC compiler is used to compile some parts of the runtime
208 dnl This hack makes sure that we pick up the multiflags that
209 dnl may have been tacked onto the $CC command.
210 if echo "$CC" | grep '/xgcc ' >/dev/null 2>&1; then
211   UPC=`echo "$CC" | sed -e 's=/xgcc =/gupc ='`
212 else
213   AC_MSG_ERROR([cannot create UPC from CC because it does not contain the
214   string '/xgcc '; the value of CC is: "$CC"])
216 # The just built UPC compiler is not fully functional as it is
217 # unable to auto pre-include "gcc-upc.h" and "gcc-upc-lib.h".
218 # Make sure that "upc-pre-include" feature is disabled for any of the
219 # UPC program checks (e.g. checking for dependency options).
220 saved_UPC="$UPC"
221 UPC="$UPC -fno-upc-pre-include"
222 AM_PROG_UPC()
223 UPC="$saved_UPC"
225 # Find other programs we need.
226 AC_CHECK_TOOL(AR, ar)
227 AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
228 AC_PATH_PROG(PERL, perl, perl-not-found-in-path-error)
229 AC_PATH_PROG(ADDR2LINE, addr2line, addr2line-not-found-in-path-error)
230 AC_PROG_MAKE_SET
231 AC_PROG_INSTALL
233 # See if makeinfo has been installed and is modern enough
234 # that we can use it.
235 ACX_CHECK_PROG_VER([MAKEINFO], [makeinfo], [--version],
236                    [GNU texinfo.* \([0-9][0-9.]*\)],
237                    [4.[4-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*])
238 AM_CONDITIONAL(BUILD_INFO, test $gcc_cv_prog_makeinfo_modern = "yes")
241 # libgupc cannot be built as shared library
242 enable_shared=no
243 # Configure libtool
244 AC_DISABLE_SHARED
245 AM_PROG_LIBTOOL
247 AM_MAINTAINER_MODE
249 # For libtool versioning info, format is CURRENT:REVISION:AGE
250 libtool_VERSION=1:0:0
251 AC_SUBST(libtool_VERSION)
253 # Check header files.
254 AC_STDC_HEADERS
255 ACX_HEADER_STRING
256 GCC_HEADER_STDINT(gstdint.h)
257 AC_HEADER_TIME
258 AC_HEADER_SYS_WAIT
260 AC_CHECK_HEADERS([execinfo.h fcntl.h limits.h netdb.h netinet/in.h])
261 AC_CHECK_HEADERS([sched.h semaphore.h stddef.h stdlib.h sys/loadavg.h])
262 AC_CHECK_HEADERS([sys/socket.h unistd.h])
264 # Checks for typedefs, structures, and compiler characteristics.
265 AC_C_CONST
266 AC_C_INLINE
267 AC_TYPE_MODE_T
268 AC_TYPE_OFF_T
269 AC_TYPE_PID_T
270 AC_TYPE_SIZE_T
271 AC_CHECK_DECLS([sys_siglist])
272 AC_C_VOLATILE
273 AC_CHECK_TYPES([ptrdiff_t])
275 # Check to see if -pthread or -lpthread is needed.  Prefer the former.
276 # In case the pthread.h system header is not found, this test will fail.
277 XPCFLAGS=""
278 CFLAGS="$CFLAGS -pthread"
279 AC_LINK_IFELSE(
280  [AC_LANG_PROGRAM(
281   [#include <pthread.h>
282    void *g(void *d) { return NULL; }],
283   [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
284  [XPCFLAGS=" -Wc,-pthread"],
285  [CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS"
286   AC_LINK_IFELSE(
287    [AC_LANG_PROGRAM(
288     [#include <pthread.h>
289      void *g(void *d) { return NULL; }],
290     [pthread_t t; pthread_create(&t,NULL,g,NULL);])],
291    [],
292    [AC_MSG_NOTICE([Pthreads are not supported in this libgupc build])])])
294 # Check for functions needed.
295 AC_FUNC_FORK
296 AC_FUNC_MALLOC
297 AC_FUNC_MMAP
298 AC_FUNC_STAT
299 AC_CHECK_FUNCS([clock_gettime ftruncate getcwd gethostbyname gethostname])
300 AC_CHECK_FUNCS([getloadavg memset mkdir munmap socket])
301 AC_CHECK_FUNCS([strcasecmp strdup strerror strtol strtoull])
302 AC_CHECK_FUNCS([backtrace backtrace_symbols backtrace_symbols_fd])
303 AC_SYS_LARGEFILE
305 # Check for broken semaphore implementation on darwin.
306 # sem_init returns: sem_init error: Function not implemented.
307 case "$host" in
308   *-darwin*)
309     AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
310         Define if the POSIX Semaphores do not work on your system.)
311     ;;
312 esac
314 GCC_LINUX_FUTEX(:)
316 # Check for pthread_{,attr_}[sg]etaffinity_np.
317 AC_LINK_IFELSE(
318  [AC_LANG_PROGRAM(
319   [#define _GNU_SOURCE
320    #include <pthread.h>],
321   [cpu_set_t cpuset;
322    pthread_attr_t attr;
323    pthread_getaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
324    if (CPU_ISSET (0, &cpuset))
325      CPU_SET (1, &cpuset);
326    else
327      CPU_ZERO (&cpuset);
328    pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
329    pthread_attr_init (&attr);
330    pthread_attr_getaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);
331    pthread_attr_setaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);])],
332   AC_DEFINE(HAVE_PTHREAD_AFFINITY_NP, 1,
333     [Define  to 1 if pthread_{,attr_}{g,s}etaffinity_np is supported.]))
335 # At least for glibc, clock_gettime is in librt.  But don't pull that
336 # in if it still doesn't give us the function we want.
337 if test $ac_cv_func_clock_gettime = no; then
338   AC_CHECK_LIB(rt, clock_gettime,[ac_cv_func_clock_gettime="yes"])
339   if test $ac_cv_func_clock_gettime = yes; then
340     LIBS="-lrt $LIBS"
341     AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
342               [Define to 1 if you have the `clock_gettime' function.])
343   fi
346 # See if we support thread-local storage.
347 GCC_CHECK_TLS
349 # See what sort of export controls are availible.
350 LIBGUPC_CHECK_ATTRIBUTE_VISIBILITY
351 LIBGUPC_CHECK_ATTRIBUTE_DLLEXPORT
352 LIBGUPC_CHECK_ATTRIBUTE_ALIAS
353 LIBGUPC_ENABLE_SYMVERS
355 if test $enable_symvers = gnu; then
356   AC_DEFINE(LIBGUPC_GNU_SYMBOL_VERSIONING, 1,
357             [Define to 1 if GNU symbol versioning is used for libgupc.])
360 CFLAGS="$save_CFLAGS $XCFLAGS"
362 # Check for __sync_val_compare_and_swap, but only after the target has
363 # had a chance to set XCFLAGS.
364 LIBGUPC_CHECK_SYNC_BUILTINS
366 # Check for __sync_fetch_and_add
367 AC_CACHE_CHECK([for __sync_fetch_and_add_4],
368 [upc_cv_sync_fetch_and_add_4],
369 [AC_LINK_IFELSE([
370 typedef unsigned int uint32  __attribute__ ((mode (SI)));
371 uint32 i;
372 int main() { return __sync_fetch_and_add (&i, 1); }
374 [upc_cv_sync_fetch_and_add_4=yes],
375 [upc_cv_sync_fetch_and_add_4=no])])
376 if test "$upc_cv_sync_fetch_and_add_4" = "yes"; then
377   AC_DEFINE(HAVE_SYNC_FETCH_AND_ADD_4, 1,
378     [Define to 1 if the compiler provides the
379     __sync_fetch_and_add function for uint32])
382 AC_CACHE_CHECK([for __sync_fetch_and_add_8],
383 [upc_cv_sync_fetch_and_add_8],
384 [AC_LINK_IFELSE([
385 typedef unsigned int uint64  __attribute__ ((mode (DI)));
386 uint64 i;
387 int main() { return __sync_fetch_and_add (&i, 1); }
389 [upc_cv_sync_fetch_and_add_8=yes],
390 [upc_cv_sync_fetch_and_add_8=no])])
391 if test "$upc_cv_sync_fetch_and_add_8" = "yes"; then
392   AC_DEFINE(HAVE_SYNC_FETCH_AND_ADD_8, 1,
393     [Define to 1 if the compiler provides the
394     __sync_fetch_and_add function for uint64])
397 XCFLAGS="$XCFLAGS"
400 # Cleanup and exit.
401 CFLAGS="$save_CFLAGS"
402 AC_CACHE_SAVE
404 if test "x${multilib}" = xyes; then
405   multilib_arg="--enable-multilib"
406 else
407   multilib_arg=
410 AC_MSG_CHECKING([for thread model used by GCC])
411 target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
412 AC_MSG_RESULT([$target_thread_file])
414 if test $target_thread_file != single; then
415   AC_DEFINE(HAVE_GTHR_DEFAULT, 1,
416         [Define if the compiler has a thread header that is non single.])
419 AC_MSG_CHECKING([UPC shared pointer representation])
420 cat > conftest.upc << _ACEOF
421 #define _XSTR(X) #X
422 #define _STR(S) _XSTR(S)
423 #ifdef __UPC_VADDR_FIRST__
424   GUPCR_PTS_VADDR_FIRST=1
425 #else
426   GUPCR_PTS_VADDR_FIRST=0
427 #endif
428 GUPCR_PTS_VADDR_SIZE=_STR(__UPC_VADDR_SIZE__)
429 GUPCR_PTS_PHASE_SIZE=_STR(__UPC_PHASE_SIZE__)
430 GUPCR_PTS_THREAD_SIZE=_STR(__UPC_THREAD_SIZE__)
431 #if __UPC_PTS_STRUCT_REP__
432   GUPCR_PTS_REP="struct"
433   GUPCR_PTS_STRUCT_REP=1
434   GUPCR_PTS_VADDR_TYPE=_STR(__UPC_VADDR_TYPE__)
435   GUPCR_PTS_PHASE_TYPE=_STR(__UPC_PHASE_TYPE__)
436   GUPCR_PTS_THREAD_TYPE=_STR(__UPC_THREAD_TYPE__)
437   #if __UPC_PTS_ALIGN__
438     GUPCR_PTS_ALIGN=_STR(__UPC_PTS_ALIGN__)
439   #endif
440 #else
441   GUPCR_PTS_REP="packed"
442   GUPCR_PTS_PACKED_REP=1
443 #endif
444 _ACEOF
445 eval `$UPC -fno-upc-pre-include -DNO_GCC_UPC_LIB=1 -E conftest.upc | \
446   grep '^ *GUPCR_[[A-Z0-9_]]*='`
447 rm -f conftest.upc
448 AC_MSG_RESULT($GUPCR_PTS_REP)
449 if test -z "$GUPCR_PTS_REP"; then
450   AC_MSG_ERROR([can't determine UPC sptr representation])
452 for cfg in \
453      GUPCR_PTS_PACKED_REP \
454      GUPCR_PTS_PHASE_SIZE \
455      GUPCR_PTS_PHASE_TYPE \
456      GUPCR_PTS_REP \
457      GUPCR_PTS_STRUCT_REP \
458      GUPCR_PTS_ALIGN \
459      GUPCR_PTS_THREAD_SIZE \
460      GUPCR_PTS_THREAD_TYPE \
461      GUPCR_PTS_VADDR_FIRST \
462      GUPCR_PTS_VADDR_SIZE \
463      GUPCR_PTS_VADDR_TYPE ; do
464   eval "cval=\$$cfg"
465   if test -n "$cval"; then
466     AC_MSG_CHECKING([value of $cfg])
467     AC_MSG_RESULT($cval)
468   fi
469 done
470 if test "$with_upc_pts" -a "$with_upc_pts" != "$GUPCR_PTS_REP" ; then
471   AC_MSG_ERROR([--with-upc-pts=$with_upc_pts is incompatible with the
472 UPC compiler's supported pointer-to-shared representation ($GUPCR_PTS_REP)])
474 AC_DEFINE_UNQUOTED(GUPCR_PTS_VADDR_SIZE,[$GUPCR_PTS_VADDR_SIZE],
475   [Size of shared pointer's vaddr field (in bits)])
476 AC_DEFINE_UNQUOTED(GUPCR_PTS_THREAD_SIZE,[$GUPCR_PTS_THREAD_SIZE],
477   [Size of shared pointer's thread field (in bits)])
478 AC_DEFINE_UNQUOTED(GUPCR_PTS_PHASE_SIZE,[$GUPCR_PTS_PHASE_SIZE],
479   [Size of shared pointer's phase field (in bits)])
480 if test "$GUPCR_PTS_REP" = "struct"; then
481   AC_DEFINE(GUPCR_PTS_STRUCT_REP,[1],
482     [Whether UPC shared pointers use the 'struct' representation])
483   AC_DEFINE_UNQUOTED(GUPCR_PTS_VADDR_TYPE,[$GUPCR_PTS_VADDR_TYPE],
484     [The data type of the 'vaddr' field in a UPC shared pointer])
485   AC_DEFINE_UNQUOTED(GUPCR_PTS_THREAD_TYPE,[$GUPCR_PTS_THREAD_TYPE],
486     [The data type of the 'thread' field in a UPC shared pointer])
487   AC_DEFINE_UNQUOTED(GUPCR_PTS_PHASE_TYPE,[$GUPCR_PTS_PHASE_TYPE],
488     [The data type of the 'phase' field in a UPC shared pointer])
489   if test -n "$GUPCR_PTS_ALIGN"; then
490     AC_DEFINE_UNQUOTED(GUPCR_PTS_ALIGN,[$GUPCR_PTS_ALIGN],
491       [The required alignment for the UPC struct shared pointer
492       representation.])
493   fi
494 else
495   AC_DEFINE(GUPCR_PTS_PACKED_REP,[1],
496     [Whether UPC pointers-to-shared use the 'packed' representation])
498 if test "$GUPCR_PTS_VADDR_FIRST" -eq 1; then
499   AC_DEFINE(GUPCR_PTS_VADDR_FIRST,[1],
500     [Whether the 'vaddr' field comes first (ie, [[vaddr,thread,phase]])])
503 dnl Select target specific runtime implementation.
505 AC_MSG_CHECKING([for UPC runtime model])
506 AC_ARG_WITH(upc-runtime,
507 [AS_HELP_STRING([--with-upc-runtime=MODEL],
508                 [specify the runtime implementation model for UPC,
509                  where MODEL may be: 'SMP' (Symmetric Multiprocessing)
510                  or 'Portals4'.  [default='SMP']])],
512   case "$withval" in
513 changequote(,)dnl
514     [Ss][Mm][Pp])
515       upc_runtime_model=smp
516       ;;
517     [Pp][Oo][Rr][Tt][Aa][Ll][Ss]4)
518       upc_runtime_model=portals4
519       ;;
520 changequote([,])dnl
521     *)
522       AC_MSG_ERROR([$withval is an invalid runtime model for
523       --with-upc-runtime])
524       ;;
525   esac
528   upc_runtime_model=smp
530 AC_MSG_RESULT([$upc_runtime_model])
532 AC_MSG_CHECKING([for UPC runtime checking support])
533 AC_ARG_ENABLE(upc-runtime-checks,
534 [AS_HELP_STRING([--enable-upc-runtime-checks],
535                 [enable internal UPC runtime checks that validate
536                  arguments, and check for inconsistent runtime state.
537                  [default=no]])],
539   case $enableval in
540   yes | no) ;;
541   *)
542     AC_MSG_ERROR([--enable-upc-runtime-checks accepts only yes or no.])
543   esac
546   enable_upc_runtime_checks=no
548 AC_MSG_RESULT($enable_upc_runtime_checks)
549 if test "$enable_upc_runtime_checks" = "yes"; then
550   AC_DEFINE(GUPCR_HAVE_CHECKS, 1,
551             [Define to 1 if UPC runtime checks are supported.])
554 AC_MSG_CHECKING([for UPC runtime statistics support])
555 AC_ARG_ENABLE(upc-runtime-stats,
556 [AS_HELP_STRING([--enable-upc-runtime-stats],
557                 [enable internal UPC runtime statistics collection support;
558                  these statistics count the number of various significant
559                  internal operations, and dump those counts into a
560                  per-process statistics file.
561                  [default=no]])],
563   case $enableval in
564   yes | no) ;;
565   *)
566     AC_MSG_ERROR([--enable-upc-runtime-stats accepts only yes or no.])
567   esac
570   enable_upc_runtime_stats=no
572 AC_MSG_RESULT($enable_upc_runtime_stats)
573 if test "$enable_upc_runtime_stats" = "yes"; then
574   AC_DEFINE(GUPCR_HAVE_STATS, 1,
575             [Define to 1 if UPC runtime statistics collection is supported.])
578 AC_MSG_CHECKING([for UPC runtime trace support])
579 AC_ARG_ENABLE(upc-runtime-trace,
580 [AS_HELP_STRING([--enable-upc-runtime-trace],
581                 [enable internal UPC runtime trace collection support;
582                  a runtime trace is a time stamped log that records
583                  various significant internal events; this trace
584                  is written to a per-process log file.
585                  [default=no]])],
587   case $enableval in
588   yes | no) ;;
589   *)
590     AC_MSG_ERROR([--enable-upc-runtime-trace accepts only yes or no.])
591   esac
594   enable_upc_runtime_trace=no
596 AC_MSG_RESULT($enable_upc_runtime_trace)
597 if test "$enable_upc_runtime_trace" = "yes"; then
598   AC_DEFINE(GUPCR_HAVE_TRACE, 1,
599             [Define to 1 if UPC runtime tracing is supported.])
602 AC_MSG_CHECKING([for UPC runtime debug configuration])
603 AC_ARG_ENABLE(upc-runtime-debug,
604 [AS_HELP_STRING([--enable-upc-runtime-debug],
605                 [enable UPC runtime debugging mode,
606                  where more expensive internal checks are implemented,
607                  and conservative algorithms are used that
608                  reduce the degree of parallelism, and that
609                  exercise less complex/sophisticated operations
610                  provided by the operating system and/or the
611                  network communication packages called by the UPC runtime.
612                  In addition, conservative compilation options will
613                  be used to build the runtime, and debugging symbols
614                  will be generated.
615                  [default=no]])],
617   case $enableval in
618   yes | no) ;;
619   *)
620     AC_MSG_ERROR([--enable-upc-runtime-debug accepts only yes or no.])
621   esac
624   enable_upc_runtime_debug=no
626 AC_MSG_RESULT($enable_upc_runtime_debug)
627 if test "$enable_upc_runtime_debug" = "yes"; then
628   AC_DEFINE(GUPCR_HAVE_DEBUG, 1,
629             [Define to 1 if UPC runtime debugging mode is enabled.])
631 AC_SUBST(enable_upc_runtime_debug)
634 AC_MSG_CHECKING([for UPC link script support])
635 AC_ARG_ENABLE(upc-link-script,
636 [AS_HELP_STRING([--enable-upc-link-script],
637                 [enable UPC's use of a custom linker script;
638                  this will define the UPC shared section as a
639                  no load section on targets where this feature
640                  is supported (requires GNU LD)])],
642   case $enableval in
643   yes | no) ;;
644   *)
645     AC_MSG_ERROR([--enable-upc-link-script accepts only yes or no])
646   esac
649   enable_upc_link_script=no
651 if test "$enable_upc_link_script" = yes; then
652   if test "$with_gnu_ld" = yes; then
653     gen_ld_script=${srcdir}/${targ_runtime}/gen-upc-ld-script.pl
654     if ! ${LD} --verbose | ${PERL} $gen_ld_script 1>/dev/null ; then
655       # if gen-upc-ld-script did not accept the output of the linker
656       # then disable UPC link script support.
657       AC_MSG_ERROR([selected linker does not support linker scripts])
658     fi
659   fi
661 AC_MSG_RESULT($enable_upc_link_script)
662 if test "$enable_upc_link_script" = yes; then
663   AC_DEFINE(HAVE_UPC_LINK_SCRIPT, 1,
664     [Define to 1 if UPC link script is supported.])
667 AC_MSG_CHECKING([for UPC runtime tree fanout])
668 AC_ARG_WITH(upc-runtime-tree-fanout,
669 [AS_HELP_STRING([--with-upc-runtime-tree-fanout=WIDTH],
670                 [specify the maximum number of children in each
671                  sub-tree used to implement UPC collectives operations
672                  (e. g. upc_barrier)
673                  [default=4]])],
675   # $withval must be a decimal integer
676   if ! echo "$withval" | grep '^[[0-9]][[0-9]]*$' >/dev/null 2>&1; then
677     AC_MSG_ERROR([$withval is an invalid option to
678     --with-upc-runtime-tree-fanout])
679   fi
680   upc_runtime_tree_fanout="$withval"
683   upc_runtime_tree_fanout=4
685 AC_MSG_RESULT([$upc_runtime_tree_fanout])
686 AC_DEFINE_UNQUOTED(GUPCR_TREE_FANOUT, [$upc_runtime_tree_fanout],
687   [Maximum number of children at each level of a collective operation tree.])
689 if test "$upc_runtime_model" = "smp"; then
690   targ_runtime_pthreads=
691   LIBGUPC_GCC_TLS_SUPPORTED
692   if test "$upc_cv_gcc_tls_supported"x = "yes"x ; then
693     targ_runtime_pthreads=yes
694   fi
695   AC_MSG_CHECKING(for Linux scheduling affinity)
696   AC_TRY_RUN(
697   changequote(<<,>>)dnl
698   <<#define _GNU_SOURCE
699   #include <sched.h>
700   cpu_set_t mask;
701   main ()
702   {
703   unsigned int len = sizeof(mask);
704   if (sched_getaffinity(0, len, &mask) < 0) {
705       return 1;
706       }
707   return 0;
708   }
709   >>,
710   changequote([, ])dnl
711       [upc_affinity=yes],
712       [upc_affinity=no],
713       [upc_affinity=no]
714   )
715   if test "x$enable_upc_affinity" = "xyes" &&
716     test "x$upc_affinity" = "xno"; then
717       AC_MSG_ERROR([scheduling affinity enabled but not supported
718       - use --disable-upc-affinity])
719   fi
720   if test "x$enable_upc_affinity" = "xno"; then
721     upc_affinity=no;
722   fi
723   AC_MSG_RESULT([$upc_affinity])
724   dnl Check if NUMA available
725   AC_MSG_CHECKING(if NUMA available)
726   save_LIBS="$LIBS"
727   LIBS="-lnuma"
728   AC_TRY_RUN(
729   changequote(<<,>>)dnl
730   <<#include <numa.h>
731   int
732   main ()
733   {
734     if (numa_available() < 0) return 1;
735     else return 0;
736   }
737   >>,
738   changequote([, ])dnl
739       [upc_numa=yes],
740       [upc_numa=no],
741       [upc_numa=no],
742   )
743   LIBS="$save_LIBS"
744   if test "x$enable_upc_numa" = "xyes" &&
745     test "x$upc_numa" = "xno"; then
746       AC_MSG_ERROR([NUMA enabled but not supported - use --disable-upc-numa])
747   fi
748   if test "x$enable_upc_numa" = "xno" \
749           -o "x$enable_upc_affinity" = "xno"; then
750     upc_numa=no;
751   fi
752   AC_MSG_RESULT([$upc_numa])
753   AC_MSG_CHECKING([for UPC GUM debugging support])
754   AC_ARG_ENABLE(upc-gum-debug,
755   [AS_HELP_STRING([--enable-upc-gum-debug],
756                   [enable UPC's source level debugging with GDB and GUM
757                    support (requires UPC aware GDB)])],
758   [
759     case $enableval in
760     yes | no) ;;
761     *)
762       AC_MSG_ERROR([--enable-upc-gum-debug accepts only yes or no])
763     esac
764     upc_gum_debug=$enableval
765   ],
766   [
767     upc_gum_debug=no
768   ])
769   AC_MSG_RESULT([$upc_gum_debug])
770   if test "x${upc_gum_debug}" = "xyes"; then
771     AC_DEFINE_UNQUOTED(GUPCR_HAVE_GUM_DEBUG,[1],
772     [Define if UPC GUM debug server is supported.])
773   fi
774   # Use the generic (reference implementation)
775   use_generic_collectives="yes"
777   DX_DOXYGEN_FEATURE(OFF)
778   DX_INIT_DOXYGEN(${PACKAGE}, doxygen.cfg, doc)
780   AC_MSG_CHECKING([for UPC backtrace support])
781   AC_ARG_ENABLE(upc-backtrace,
782   [AS_HELP_STRING([--enable-upc-backtrace],
783                   [enable UPC backtrace;
784                    enable stack frame backtrace report
785                    when UPC run-time fatal errors occur
786                    or by user request (via signal)])],
787   [
788     case $enableval in
789     yes | no) ;;
790     *)
791       AC_MSG_ERROR([--enable-upc-backtrace accepts only yes or no])
792     esac
793   ],
794   [
795     enable_upc_backtrace=yes
796   ])
797   AC_MSG_RESULT($enable_upc_backtrace)
798   if test "$enable_upc_backtrace" = yes; then
799     AC_DEFINE(HAVE_UPC_BACKTRACE, 1,
800       [Define to 1 if UPC backtrace is enabled.])
801   fi
803   AC_MSG_CHECKING([for UPC backtrace GDB support])
804   AC_ARG_ENABLE(upc-backtrace-gdb,
805   [AS_HELP_STRING([--enable-upc-backtrace-gdb],
806                   [enable the use of GDB for UPC stack backtrace
807                    [default='yes']])],
808   [
809     case "$enableval" in
810     yes | no) ;;
811     *)
812       AC_MSG_ERROR([--enable-upc-backtrace-gdb accepts only yes or no])
813     esac
814   ],
815   [
816     enable_upc_backtrace_gdb=yes
817   ])
818   AC_MSG_RESULT([$enable_upc_backtrace_gdb])
819   if test "$enable_upc_backtrace_gdb" = yes; then
820     AC_DEFINE(HAVE_UPC_BACKTRACE_GDB, 1,
821       [Define to 1 if UPC backtrace with GDB is enabled.])
823     # Check for user specified GDB
824     AC_MSG_CHECKING([for UPC backtrace GDB to use])
825     AC_ARG_WITH(upc-backtrace-gdb,
826       [AS_HELP_STRING([--with-upc-backtrace-gdb=GDB],
827       [specify which GDB to use for UPC backtrace support
828       [default='gdb']])],
829     [
830       upc_backtrace_gdb=$withval
831     ],
832     [
833       upc_backtrace_gdb=gdb
834     ])
835     AC_PATH_PROGS(PATH_TO_GDB, $GDB $upc_backtrace_gdb, , /usr/bin:${PATH})
836     if test -n "$PATH_TO_GDB"; then
837       AC_DEFINE_UNQUOTED(GUPCR_BACKTRACE_GDB, "$PATH_TO_GDB",
838         [Define path to preferred GDB for backtrace])
839     else
840       AC_MSG_ERROR(
841         [cannot find gdb. Try the correct --with-upc-backtrace-gdb
842          option or disable GDB for backtrace with
843          --disable-upc-backtrace option)])
844     fi
845     AC_MSG_RESULT([$PATH_TO_GDB])
846   fi
848   AC_MSG_CHECKING([for UPC backtrace signal support])
849   AC_ARG_ENABLE(upc-backtrace-signal,
850   [AS_HELP_STRING([--enable-upc-backtrace-signal],
851                   [enable signal support for UPC stack backtrace
852                    [default='yes']])],
853   [
854     case "$enableval" in
855     yes | no) ;;
856     *)
857       AC_MSG_ERROR([--enable-upc-backtrace-signal accepts only yes or no])
858     esac
859   ],
860   [
861     enable_upc_backtrace_signal=yes
862   ])
863   AC_MSG_RESULT([$enable_upc_backtrace_signal])
864   if test "$enable_upc_backtrace_signal" = yes; then
865     AC_DEFINE(HAVE_UPC_BACKTRACE_SIGNAL, 1,
866       [Define to 1 if UPC backtrace signal is enabled.])
868     # Check for user specified signal name/number
869     AC_MSG_CHECKING([for UPC backtrace signal name/number])
870     AC_ARG_WITH(upc-backtrace-signal,
871       [AS_HELP_STRING([--with-upc-backtrace-signal=SIGNAL],
872       [specify the signal to be used for UPC stack backtrace
873       [default='SIGUSR1']])],
874       [
875         upc_backtrace_signal=$withval
876       ],
877       [
878         upc_backtrace_signal=SIGUSR1
879       ])
880     AC_DEFINE_UNQUOTED(GUPCR_BACKTRACE_SIGNAL, $upc_backtrace_signal,
881       [Define to preferred signal for UPC backtrace.])
882     AC_MSG_RESULT([$upc_backtrace_signal])
883   fi
885   # UPC source file/line backtrace requires BFD library
886   if test "$enable_upc_backtrace" = yes; then
887     # Specify a location for BFD lib
888     AC_ARG_WITH(bfd,
889     [AS_HELP_STRING([--with-bfd=PATH],
890                 [specify prefix directory for the installed BFD library
891                  needed to provide extended UPC backtrace information
892                  (source file name and line numbers); equivalent to
893                  --with-bfd-include=PATH/include
894                  plus --with-bfd-lib=PATH/lib])])
895     AC_ARG_WITH(bfd-include,
896     [AS_HELP_STRING([--with-bfd-include=PATH],
897                 [specify directory for installed BFD include files])])
898     AC_ARG_WITH(bfd-lib,
899     [AS_HELP_STRING([--with-bfd-lib=PATH],
900                 [specify directory for the installed BFD library])])
902     if test "x$with_bfd" != x; then
903       bfdlibs="-L$with_bfd/lib $bfdlibs"
904       bfdinc="-I$with_bfd/include $bfdinc"
905     fi
906     if test "x$with_bfd_include" != x; then
907       bfdinc="-I$with_bfd_include $bfdinc"
908     fi
909     if test "x$with_bfd_lib" != x; then
910       bfdlibs="-L$with_bfd_lib $bfdlibs"
911     fi
913     have_bfd=yes
914     saved_CFLAGS="$CFLAGS"
915     saved_LIBS="$LIBS"
916     CFLAGS="$CFLAGS $bfdinc"
917     LIBS="$LIBS -lbfd -ldl"
918     AC_MSG_CHECKING([for the libbfd])
919     AC_TRY_LINK([
920         #include <bfd.h>
921         bfd_error_type error;
922         void foo () { error = bfd_get_error (); }
923         ],[ ],
924       [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); have_bfd=no ])
925     CFLAGS="$saved_CFLAGS"
926     LIBS="$saved_LIBS"
928     if test "$have_bfd" = "yes"; then
929       AC_DEFINE(HAVE_LIBBFD, 1,
930         [Use BFD library for improved backtrace.])
931     fi
933     # Check for "-rdynamic" for UPC backtrace
934     case "${host}" in
935       *-*-darwin*)
936         if test x$build = x$host; then
937           export_sym_check="nm${exeext} -g"
938         elif test x$host = x$target; then
939           export_sym_check="$gcc_cv_nm -g"
940         else
941           export_sym_check=
942         fi
943       ;;
944       *)
945         if test x$build = x$host; then
946           export_sym_check="objdump${exeext} -T"
947         elif test x$host = x$target; then
948           export_sym_check="$gcc_cv_objdump -T"
949         else
950           export_sym_check=
951         fi
952       ;;
953     esac
954     AC_MSG_CHECKING([for -rdynamic])
955     if test "x$export_sym_check" != x; then
956       echo "int main() {return 0;} int foobar() {return 0;}" > conftest.c
957       ${CC} ${CFLAGS} ${LDFLAGS} -rdynamic conftest.c \
958         -o conftest > /dev/null 2>&1
959       if $export_sym_check conftest | grep foobar > /dev/null; then
960         have_rdynamic=yes
961       fi
962     fi
963     AC_MSG_RESULT([$have_rdynamic])
964   fi
966   AC_MSG_CHECKING([for UPC runtime maximum number of locks held per thread])
967   AC_ARG_WITH(upc-runtime-max-locks,
968   [AS_HELP_STRING([--with-upc-runtime-max-locks=MAX_LOCKS],
969                   [specify the maximum number of locks that can be held by
970                    a single UPC thread [default=1024]])],
971   [
972     # $withval must be a decimal integer
973     if ! echo "$withval" | grep '^[[0-9]][[0-9]]*$' >/dev/null 2>&1; then
974       AC_MSG_ERROR([$withval is an invalid option to
975       --with-upc-runtime-max-locks])
976     fi
977     upc_runtime_max_locks="$withval"
978   ],
979   [
980     upc_runtime_max_locks=1024
981   ])
982   AC_MSG_RESULT([$upc_runtime_max_locks])
983   AC_DEFINE_UNQUOTED(GUPCR_MAX_LOCKS,[$upc_runtime_max_locks],
984     [Maximum number of locks held per thread])
986 fi #### End: SMP runtime configuration
988 if test "$upc_runtime_model" = "portals4"; then
990   #### Portals4 runtime library configuration ####
992   # Use the generic (reference implementation)
993   use_generic_collectives="no"
995   # Check for Portals4 libs
996   portals4libs="-lportals"
997   portals4inc=
998   have_portals4=no
999   AC_ARG_WITH(portals4,
1000   [AS_HELP_STRING([--with-portals4=PATH],
1001                   [specify prefix directory for installed portals4 package.
1002                    Equivalent to --with-portals4-include=PATH/include
1003                    plus --with-portals4-lib=PATH/lib])])
1004   AC_ARG_WITH(portals4-include,
1005   [AS_HELP_STRING([--with-portals4-include=PATH],
1006                   [specify directory for installed portals4 include files])])
1007   AC_ARG_WITH(portals4-lib,
1008   [AS_HELP_STRING([--with-portals4-lib=PATH],
1009                   [specify directory for the installed portals4 library])])
1011   if test "x$with_portals4" != x; then
1012     portals4libs="-L$with_portals4/lib $portals4libs"
1013     portals4inc="-I$with_portals4/include $portals4inc"
1014   fi
1015   if test "x$with_portals4_include" != x; then
1016     portals4inc="-I$with_portals4_include $portals4inc"
1017   fi
1018   if test "x$with_portals4_lib" != x; then
1019     portals4libs="-L$with_portals4_lib $portals4libs"
1020   fi
1021   if test "x$with_portals4$with_portals4_include$with_portals4_lib" = x \
1022      && test -d ${srcdir}/portals4; then
1023     portals4libs='-L$$r/$(HOST_SUBDIR)/portals4/ '"$lt_cv_objdir $portals4libs"
1024     portals4inc='-I$$r/$(HOST_SUBDIR)/portals4 -I$$s/portals4 '"$portals4inc"
1025     # Do not test the portals4 version.  Assume that it is sufficient, since
1026     # it is in the source tree, and the library has not been built yet
1027     # but it would be included on the link line in the version check below
1028     # hence making the test fail.
1029     have_portals4=yes
1030   fi
1031   AC_SUBST(portals4libs)
1032   AC_SUBST(portals4inc)
1034   AC_MSG_CHECKING([for UPC runtime Portals4 PTE base index])
1035   AC_ARG_WITH(upc-runtime-pte-base,
1036   [AS_HELP_STRING([--with-upc-runtime-pte-base=BASE],
1037                   [specify the base index of the first Portals4 PTE used
1038                    by the UPC runtime [default=16]])],
1039   [
1040     # $withval must be a decimal integer
1041     if ! echo "$withval" | grep '^[[0-9]][[0-9]]*$' >/dev/null 2>&1; then
1042       AC_MSG_ERROR([$withval is an invalid option to --with-upc-runtime-pte-base])
1043     fi
1044     upc_runtime_pte_base="$withval"
1045   ],
1046   [
1047     upc_runtime_pte_base=16
1048   ])
1049   AC_MSG_RESULT([$upc_runtime_pte_base])
1050   AC_DEFINE_UNQUOTED(GUPCR_PTE_BASE,[$upc_runtime_pte_base],
1051     [Portals4 PTE base index.])
1053   AC_MSG_CHECKING([for UPC runtime maximum number of locks held per thread])
1054   AC_ARG_WITH(upc-runtime-max-locks,
1055   [AS_HELP_STRING([--with-upc-runtime-max-locks=MAX_LOCKS],
1056                   [specify the maximum number of locks that can be held by
1057                    a single UPC thread [default=1024]])],
1058   [
1059     # $withval must be a decimal integer
1060     if ! echo "$withval" | grep '^[[0-9]][[0-9]]*$' >/dev/null 2>&1; then
1061       AC_MSG_ERROR([$withval is an invalid option to
1062       --with-upc-runtime-max-locks])
1063     fi
1064     upc_runtime_max_locks="$withval"
1065   ],
1066   [
1067     upc_runtime_max_locks=1024
1068   ])
1069   AC_MSG_RESULT([$upc_runtime_max_locks])
1070   AC_DEFINE_UNQUOTED(GUPCR_MAX_LOCKS,[$upc_runtime_max_locks],
1071     [Maximum number of locks held per thread])
1073   AC_MSG_CHECKING([for UPC runtime bounce buffer size])
1074   AC_ARG_WITH(upc-runtime-bounce-buffer-size,
1075   [AS_HELP_STRING([--with-upc-runtime-bounce-buffer-size=SIZE],
1076                   [specify the size (in bytes) of the bounce buffer
1077                    that is used by the UPC runtime to buffer
1078                    network data [default=256K]])],
1079   [
1080     # $withval must be a decimal integer
1081     if ! echo "$withval" | egrep -i '^[[0-9]]+[[kmg]]?$' >/dev/null 2>&1; then
1082       AC_MSG_ERROR([$withval is an invalid option to
1083                         --with-upc-runtime-bounce-buffer-size])
1084     fi
1085     bb_size="$withval"
1086   ],
1087   [
1088     bb_size="256K"
1089   ])
1090   bb_size_expr=`echo "$bb_size" | \
1091     sed -e 's/[[gG]]$/*1024M/;s/[[mM]]$/*1024K/;s/[[kK]]$/*1024/;s/\\*/ \\\\* /g'`
1092   upc_runtime_bounce_buffer_size=`eval expr $bb_size_expr`
1093   AC_MSG_RESULT([$upc_runtime_bounce_buffer_size])
1094   AC_DEFINE_UNQUOTED(GUPCR_BOUNCE_BUFFER_SIZE,[$upc_runtime_bounce_buffer_size],
1095     [Size of get/put bounce buffer])
1097   AC_MSG_CHECKING([for UPC maximum number of outstanding remote puts])
1098   AC_ARG_WITH(upc-max-outstanding-puts,
1099   [AS_HELP_STRING([--with-upc-max-outstanding-puts=SIZE],
1100                   [specify the maximum number of outstanding
1101                    remote put requests. [default=256]])],
1102   [
1103     # $withval must be a decimal integer
1104     if ! echo "$withval" | grep '^[[0-9]]*$' >/dev/null 2>&1; then
1105       AC_MSG_ERROR([$withval is an invalid option to
1106                         --with-upc-max-outstanding-puts])
1107     fi
1108     upc_max_puts_count="$withval"
1109   ],
1110   [
1111     upc_max_puts_count="256"
1112   ])
1113   AC_MSG_RESULT([$upc_max_puts_count])
1114   AC_DEFINE_UNQUOTED(GUPCR_MAX_OUTSTANDING_PUTS,[$upc_max_puts_count],
1115     [Maximum number of outstanding remote puts])
1117   AC_MSG_CHECKING([for UPC runtime collectives tree fanout])
1118   AC_ARG_WITH(upc-runtime-tree-fanout,
1119   [AS_HELP_STRING([--with-upc-runtime-tree-fanout=WIDTH],
1120                   [specify the maximum number of children in each
1121                    sub-tree used to implement UPC collective operations
1122                    (e. g., upc_barrier and upc_global_alloc).
1123                    [default=4]])],
1124   [
1125     # $withval must be a decimal integer
1126     if ! echo "$withval" | grep '^[[0-9]][[0-9]]*$' >/dev/null 2>&1; then
1127       AC_MSG_ERROR([$withval is an invalid option to
1128                         --with-upc-runtime-tree-fanout])
1129     fi
1130     upc_runtime_tree_fanout="$withval"
1131   ],
1132   [
1133     upc_runtime_tree_fanout=4
1134   ])
1135   AC_MSG_RESULT([$upc_runtime_tree_fanout])
1136   AC_DEFINE_UNQUOTED(GUPCR_TREE_FANOUT, [$upc_runtime_tree_fanout],
1137     [Maximum number of children at each level of a collective operation tree.])
1139   AC_MSG_CHECKING([for UPC runtime Portals4 triggered operation support])
1140   AC_ARG_ENABLE(upc-runtime-triggered-ops,
1141   [AS_HELP_STRING([--enable-upc-runtime-triggered-ops],
1142                   [enable UPC runtime support for Portals4 triggered
1143                    operations.  [default=yes]])],
1144   [
1145     case $enableval in
1146     yes | no) ;;
1147     *)
1148       AC_MSG_ERROR([--enable-upc-runtime-triggered-ops accepts only yes or no.])
1149     esac
1150   ],
1151   [
1152     enable_upc_runtime_triggered_ops=yes
1153   ])
1154   AC_MSG_RESULT($enable_upc_runtime_triggered_ops)
1155   if test "$enable_upc_runtime_triggered_ops" = "yes"; then
1156     AC_DEFINE(GUPCR_USE_PORTALS4_TRIGGERED_OPS, 1,
1157       [Define to 1 if UPC runtime will use Portals4 triggered operations.])
1158   fi
1160 # Portals4 node local memory optimization
1162   AC_MSG_CHECKING([for UPC runtime node local memory access])
1163   AC_ARG_ENABLE(upc-node-local-mem,
1164   [AS_HELP_STRING([--enable-upc-node-local-mem],
1165                   [enable UPC runtime support for accessing shared
1166                    memory of the node local threads.  [default=yes]])],
1167   [
1168     case $enableval in
1169     yes | no) ;;
1170     *)
1171       AC_MSG_ERROR([--enable-upc-node-local-mem accepts only yes or no.])
1172     esac
1173   ],
1174   [
1175     enable_upc_node_local_mem=yes
1176   ])
1177   AC_MSG_RESULT($enable_upc_node_local_mem)
1178   if test "$enable_upc_node_local_mem" = "yes"; then
1179     AC_DEFINE(GUPCR_NODE_LOCAL_MEM, 1,
1180       [Define to 1 if UPC runtime will use node local memory accesses.])
1181   fi
1183   if test "$enable_upc_node_local_mem" = "yes"; then
1184     # START - check for shared memory type
1185     # Check for Posix based shm
1186     AC_MSG_CHECKING([for UPC node local memory type])
1187     AC_ARG_WITH(upc-node-local-mem,
1188     [AS_HELP_STRING([--with-upc-node-local-mem=SHMEM],
1189                     [specify type of shared memory used for node local
1190                      memory accesses (posix or mmap).
1191                     [default=posix]])],
1192     [
1193       case $withval in
1194         posix | mmap)
1195           upc_node_local=$withval
1196           ;;
1197         *)
1198           AC_MSG_ERROR([--with-upc-node-local-mem accepts only posix or mmap.])
1199       esac
1200     ],
1201     [
1202       upc_node_local=posix
1203     ])
1204     AC_MSG_RESULT($upc_node_local);
1206     # Check if POSIX shm is available
1207     if test "$upc_node_local" = "posix"; then
1208       # Check if it is part of librt
1209       have_shm_open=no
1210       AC_CHECK_LIB(rt, shm_open,
1211          [LIBS="-lrt $LIBS"
1212           have_shm_open=yes
1213           AC_DEFINE(HAVE_SHM_OPEN, 1,
1214             [Define to 1 if you have the 'shm_open' function.])])
1215       if test "$have_shm_open" = "no"; then
1216         # Must probe for Posix shmem
1217         AC_MSG_CHECKING([for the shm_open])
1218         AC_TRY_LINK([
1219           #include <sys/types.h>
1220           #include <sys/stat.h>
1221           #include <sys/mman.h>
1222           #include <unistd.h>
1223           #include <fcntl.h>
1224           #include <stdlib.h>
1225           int size = 4096;
1226           int fd;
1227           void * addr;],[
1229           fd = shm_open("shm-config-test", O_CREAT|O_RDWR, S_IRUSR|S_IWUSR);
1230           (void)shm_unlink("shm-config-test");
1231           if (fd < 0) return 1;
1232           if (ftruncate(fd, size) < 0) return 1;
1233           addr = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
1234           (void)close(fd);
1235           if (!addr || (addr == MAP_FAILED)) return 1;
1236           (void)munmap(addr, size);
1237           return 0;
1238           ],[AC_MSG_RESULT(yes); have_shm_open=yes ],
1239             [AC_MSG_RESULT(no); have_shm_open=no ])
1240       fi
1242       if test "$have_shm_open" = "yes"; then
1243         AC_DEFINE(GUPCR_NODE_LOCAL_MEM_POSIX, 1,
1244           [Define to 1 if UPC node local access uses Posix shared memory.])
1245       else
1246         AC_MSG_ERROR([Posix shared memory is not available])
1247       fi
1248     else
1249       # mmap is always available
1250       AC_DEFINE(GUPCR_NODE_LOCAL_MEM_MMAP, 1,
1251         [Define to 1 if UPC node local access uses mmap-ed file.])
1252     fi
1253     # END - check for shared memory type
1254   fi
1256   # Check for portals job launcher
1257   AC_CHECK_HEADER([slurm/slurm.h],[have_slurm=yes],[have_slurm=no])
1258   AC_MSG_CHECKING([for UPC runtime Portals4 job launcher])
1259   AC_ARG_WITH(upc-job-launcher,
1260   [AS_HELP_STRING([--with-upc-job-launcher],
1261                   [Select UPC Portals4 job launcher.
1262                    [default=slurm]])],
1263   [
1264     case $withval in
1265     slurm | yod)
1266       upc_job_launcher=$withval
1267       ;;
1268     *)
1269       AC_MSG_ERROR([--with-upc-job-launcher accepts only slurm or yod.])
1270     esac
1271   ],
1272   [
1273     if test "$have_slurm" = "yes"; then
1274       upc_job_launcher=slurm
1275     else
1276       upc_job_launcher=yod
1277     fi
1278   ])
1279   AC_MSG_RESULT($upc_job_launcher)
1281   if test "$upc_job_launcher" = "slurm"; then
1282     if test "$have_slurm" = "yes"; then
1283       AC_DEFINE(GUPCR_JOB_LAUNCHER_SLURM, 1,
1284       [Use SLURM for UPC Portals4 job launcher])
1285       portals4libs="$portals4libs -lpmi"
1286     else
1287       AC_MSG_ERROR([--with-upc-job-launcher specified slurm,
1288                     but slurm is not available.])
1289     fi
1290   else
1291     AC_DEFINE(GUPCR_JOB_LAUNCHER_YOD, 1,
1292     [Use YOD for UPC Portals4 job launcher])
1293     portals4libs="$portals4libs -lportals_runtime"
1294   fi
1296   # Check for target memory page size
1297   AC_MSG_CHECKING([for memory page size])
1298   AC_ARG_WITH(upc-memory-page-size,
1299   [AS_HELP_STRING([--with-upc-memory-page-size],
1300                   [Select target memory page size.
1301                    [default=4096]])],
1302   [
1303     # $withval must be a decimal integer
1304     if ! echo "$withval" | grep '^[[0-9]][[0-9]]*$' >/dev/null 2>&1; then
1305       AC_MSG_ERROR([$withval is an invalid option to --with-upc-memory-page-size])
1306     fi
1307     memory_page_size="$withval"
1308   ],
1309   [
1310     memory_page_size="4096"
1311   ])
1312   AC_MSG_RESULT($memory_page_size)
1313   AC_DEFINE_UNQUOTED(GUPCR_MEMORY_PAGE_SIZE, [$memory_page_size],
1314     [Target system memory page size.])
1316   AC_DEFINE(GUPCR_GLOBAL_EXIT_TIMEOUT, [2],
1317     [upc_global_exit() timeout in seconds.])
1319   DX_DOXYGEN_FEATURE(ON)
1320   DX_HTML_FEATURE(ON)
1321   DX_PDF_FEATURE(ON)
1322   DX_DOT_FEATURE(ON)
1323   DX_PS_FEATURE(OFF)
1324   DX_INIT_DOXYGEN(${PACKAGE}, doxygen.cfg, doc)
1325   AC_CONFIG_FILES([header.tex doxygen.sty])
1326   AC_CONFIG_FILES([doxygen.cfg:portals4/doxygen.cfg.in])
1328 fi #### End: Portals4 runtime configuration
1330 # Get target configury.
1331 . ${srcdir}/configure.tgt
1333 # configure.tgt sets these substitution variables.
1334 # It also sets 'upc_crtstuff=yes' if upc-crtstuff needs
1335 # to be compiled.
1336 AC_SUBST(config_path)
1337 AC_SUBST(bfdinc)
1338 AC_SUBST(XCFLAGS)
1339 AC_SUBST(XLDFLAGS)
1340 AC_SUBST(link_upc_spec)
1341 AC_SUBST(upc_crtstuff_cflags)
1342 AC_SUBST(upc_crtbegin_spec)
1343 AC_SUBST(upc_crtend_spec)
1344 AC_SUBST(upc_crtstuff_mak)
1345 AC_SUBST(upc_crtstuff_objs)
1347 dnl Define ARG_UNUSED macro
1348 AH_BOTTOM([
1349 #ifndef ARG_UNUSED
1350 # define ARG_UNUSED(NAME) NAME __attribute__ ((__unused__))
1351 #endif
1354 dnl Build the runtime, based upon the --with-upc-runtime setting.
1355 AM_CONDITIONAL(LIBGUPC_SMP_RUNTIME, [test "$upc_runtime_model" = "smp"])
1356 AM_CONDITIONAL(LIBGUPC_PORTALS4_RUNTIME, [test "$upc_runtime_model" = "portals4"])
1357 AM_CONDITIONAL(LIBGUPC_RUNTIME_DEBUG, [test "$enable_upc_runtime_debug" = "yes"])
1359 AM_CONDITIONAL(LIBGUPC_CRTSTUFF, [test "$upc_crtstuff" = "yes"])
1360 AM_CONDITIONAL(LIBGUPC_LINK_SCRIPT, [test "$enable_upc_link_script" = "yes"])
1361 AM_CONDITIONAL(LIBGUPC_GENERIC_COLLECTIVES,
1362                [test "$use_generic_collectives" = "yes"])
1364 dnl 'smp' runtime specific settings
1365 AM_CONDITIONAL(LIBGUPC_PTHREADS, [test "$targ_runtime_pthreads" = "yes"])
1366 AM_CONDITIONAL(LIBGUPC_AFFINITY, [test "$upc_affinity" = "yes"])
1367 AM_CONDITIONAL(LIBGUPC_NUMA, [test "$upc_numa" = "yes"])
1368 AM_CONDITIONAL(LIBGUPC_GUM, [test "$upc_gum_debug" = "yes"])
1369 AM_CONDITIONAL(LIBGUPC_BACKTRACE, [test "$enable_upc_backtrace" = "yes"])
1370 AM_CONDITIONAL(LIBGUPC_BACKTRACE_SUP, [test "$have_bfd" = "yes"])
1371 AM_CONDITIONAL(LIBGUPC_NODE_LOCAL_MEM_POSIX, [test "$upc_node_local" = "posix"])
1372 AM_CONDITIONAL(LIBGUPC_NODE_LOCAL_MEM_MMAP, [test "$upc_node_local" = "mmap"])
1374 AH_TOP(
1375 [/* Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
1376    This file is part of the UPC runtime Library.
1377    Written by Gary Funck <gary@intrepid.com>
1378    and Nenad Vukicevic <nenad@intrepid.com>
1380    This library is free software; you can redistribute it and/or
1381    modify it under the terms of the GNU General Public License as
1382    published by the Free Software Foundation; either version 2, or (at
1383    your option) any later version.
1385    This library is distributed in the hope that it will be useful, but
1386    WITHOUT ANY WARRANTY; without even the implied warranty of
1387    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1388    General Public License for more details.
1390    You should have received a copy of the GNU General Public License
1391    along with this library; see the file COPYING.  If not, write to
1392    the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
1393    MA 02111-1307, USA.
1395    As a special exception, if you link this library with files
1396    compiled with a GNU compiler to produce an executable, this does
1397    not cause the resulting executable to be covered by the GNU General
1398    Public License.  This exception does not however invalidate any
1399    other reasons why the executable file might be covered by the GNU
1400    General Public License.  */
1401 #ifndef __CONFIG_H__
1402 #define __CONFIG_H__ 1
1404 AH_VERBATIM(GUPCR_AAA_BEGIN_CFG,[//begin gupcr_config_h])
1405 AH_VERBATIM(GUPCR_ZZZ_END_CFG,[//end gupcr_config_h])
1406 AH_BOTTOM(
1408 #endif /* __CONFIG_H__ */
1411 AC_CONFIG_FILES([Makefile testsuite/Makefile])
1412 AC_CONFIG_FILES([upc-crtbegin.spec libgupc.spec upc-crtend.spec])
1413 AC_OUTPUT