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