1 # Decimal representation of Charm++ release line and API revision
2 # Increment the last 2 digits when making an API change
3 # Increase the first three after branching for a release
5 AC_INIT(Charm++, 60900, [charm@cs.illinois.edu], charm, [http://charm.cs.illinois.edu/])
7 AC_CONFIG_SRCDIR(./Makefile)
9 AC_CONFIG_HEADER(conv-autoconfig.h)
11 AC_CONFIG_COMMANDS([config-cleanup],
12 [sed -i -e 's:^#define\s\+PACKAGE://&:' conv-autoconfig.h])
14 get_full_command_name()
16 if test "$(basename "$*")" != "$*"; then
17 echo "$(cd "$(dirname "$*")" && pwd)/$(basename "$*")"
23 ConvSh='../tmp/conv-mach-opt.sh'
24 ConvMak='../tmp/conv-mach-opt.mak'
26 #clean up conv-mach-opt.sh
27 sed -e '/Option added by configure/d' "$ConvSh" | sed -e '/^$/d' > conv-mach-opt.sh.clean
28 cp -f conv-mach-opt.sh.clean "$ConvSh"
29 rm -f conv-mach-opt.sh.clean
31 #clean up conv-mach-opt.mak
32 sed -e '/Option added by configure/d' "$ConvMak" | sed -e '/^$/d' > conv-mach-opt.mak.clean
33 cp -f conv-mach-opt.mak.clean "$ConvMak"
34 rm -f conv-mach-opt.mak.clean
38 test -r ./conv-config.sh && . ./conv-config.sh
40 echo AC_PACKAGE_VERSION > ../include/VERSION
41 AC_DEFINE_UNQUOTED([CHARM_VERSION], AC_PACKAGE_VERSION, [Charm++ Release/API version number])
43 charmout="charmconfig.out"
45 MAKEFILE_EXT=Make.extlib
52 # add into conv-mach-opt.sh
58 last=`grep -w "$key" "$ConvSh" 2>/dev/null | tail -1 | sed -e 's/ *#.*$//'`
60 if test -n "$last" -a "$last" = "$1"
66 cat >> "$ConvSh" << EOT
68 $1 # Option added by configure script's $2 section
75 sed -e '/^'"$1"'=/d' "$ConvSh" > tmp.$$
80 # add into conv-mach-opt.mak
87 last=`grep -w "$key" "$ConvMak" 2>/dev/null | tail -1 | sed -e 's/ *#.*$//'`
89 if test -n "$last" -a "$last" = "$1"
95 # The lack of whitespace around $1 here is necessary.
96 cat >> "$ConvMak" << EOT
98 $1# Option added by configure script's $2 section
103 # remove_make_flag $1
105 sed -e '/^'"$1"'=/d' "$ConvMak" > tmp.$$
110 add_flag "OPTS_CC='$OPTS_CC'" 'Pass through user-provided C compiler options'
111 add_flag "OPTS_CXX='$OPTS_CXX'" 'Pass through user-provided C++ compiler options'
112 add_make_flag "CMK_COMPILER:=$CMK_COMPILER" 'basic setup'
113 add_make_flag "CMK_SMP:=$CMK_SMP" 'basic setup'
114 add_make_flag "CMK_SHARED_SUF:=$CMK_SHARED_SUF" 'basic setup'
115 add_make_flag "CMK_NO_PARTITIONS:=$CMK_NO_PARTITIONS" 'basic setup'
116 add_make_flag "CMK_BLUEGENEQ:=$CMK_BLUEGENEQ" 'basic setup'
117 add_make_flag "CMK_MULTICORE:=$CMK_MULTICORE" 'basic setup'
118 add_make_flag "CMK_USE_LRTS:=$CMK_USE_LRTS" 'basic setup'
119 add_make_flag "BUILD_CUDA:=$BUILD_CUDA" 'basic setup'
121 # enable/disable error checking
122 AC_ARG_ENABLE([error-checking],
123 [AS_HELP_STRING([--enable-error-checking],
124 [enable error checking])], ,
125 [enable_error_checking=yes])
127 if test "$enable_error_checking" = "no"
129 Echo "Error checking is disabled"
130 AC_DEFINE_UNQUOTED(CMK_ERROR_CHECKING, 0, [disable error checking])
131 add_flag 'OPTS_CC="$OPTS_CC -U_FORTIFY_SOURCE"' 'error checking'
132 add_flag 'OPTS_CXX="$OPTS_CXX -U_FORTIFY_SOURCE"' 'error checking'
134 Echo "Error checking is enabled"
135 AC_DEFINE_UNQUOTED(CMK_ERROR_CHECKING, 1, [enable error checking])
138 # enable/disable AMPI error checking
139 AC_ARG_ENABLE([ampi-error-checking],
140 [AS_HELP_STRING([--enable-ampi-error-checking],
141 [enable AMPI error checking])], ,
142 [enable_ampi_error_checking=yes])
144 if test "$enable_ampi_error_checking" = "no"
146 Echo "AMPI error checking is disabled"
147 AC_DEFINE_UNQUOTED(AMPI_ERROR_CHECKING, 0, [disable ampi error checking])
149 Echo "AMPI error checking is enabled"
150 AC_DEFINE_UNQUOTED(AMPI_ERROR_CHECKING, 1, [enable ampi error checking])
153 # enable/disable statistics collection
154 AC_ARG_ENABLE([stats],
155 [AS_HELP_STRING([--enable-stats],
156 [enable statistics collection])], ,
159 if test "$enable_stats" = "no"
161 Echo "Statistics collection is disabled"
162 AC_DEFINE_UNQUOTED(CMK_WITH_STATS, 0, [disable statistics collection])
164 Echo "Statistics collection is enabled"
165 AC_DEFINE_UNQUOTED(CMK_WITH_STATS, 1, [enable statistics collection])
168 # check enable/disable
169 AC_ARG_ENABLE([tracing],
170 [AS_HELP_STRING([--enable-tracing],
171 [enable tracing modules])], ,
172 [enable_tracing=yes])
174 if test "$enable_tracing" = "no"
176 Echo "Charm tracing is disabled"
177 AC_DEFINE_UNQUOTED(CMK_TRACE_ENABLED, 0, [disable tracing])
178 add_flag CMK_TRACE_ENABLED=0
179 add_make_flag 'CMK_TRACE_ENABLED:=0' 'tracing'
181 Echo "Charm tracing is enabled"
182 AC_DEFINE_UNQUOTED(CMK_TRACE_ENABLED, 1, [enable tracing])
183 add_flag CMK_TRACE_ENABLED=1
184 add_make_flag 'CMK_TRACE_ENABLED:=1' 'tracing'
187 AC_ARG_ENABLE([tracing-commthread],
188 [AS_HELP_STRING([--enable-tracing-commthread],
189 [enable tracing communication thread])], ,
190 [enable_tracing_commthread=no])
192 if test "$enable_tracing_commthread" = "yes"
194 Echo "Charm tracing communication thread is enabled"
195 AC_DEFINE_UNQUOTED(CMK_SMP_TRACE_COMMTHREAD, 1, [enable tracing comm thread])
197 Echo "Charm tracing communication thread is disabled"
198 AC_DEFINE_UNQUOTED(CMK_SMP_TRACE_COMMTHREAD, 0, [disable tracing comm thread])
203 AC_ARG_ENABLE([task_queue],
204 [AS_HELP_STRING([--enable-task-queue],
205 [enable task queue])],
206 [enable_task_queue=$enableval],
207 [enable_task_queue=no])
209 if test "$enable_task_queue" = "no"
211 Echo "Task Queue is disabled"
212 AC_DEFINE_UNQUOTED(CMK_TASKQUEUE, 0, [disable task queue])
214 Echo "Task Queue is enabled"
215 AC_DEFINE_UNQUOTED(CMK_TASKQUEUE, 1, [enable task queue])
219 AC_ARG_ENABLE([drone_mode],
220 [AS_HELP_STRING([--enable-drone-mode],
221 [enable drone mode])],
222 [enable_drone_mode=$enableval],
223 [enable_drone_mode=no])
225 if test "$enable_drone_mode" = "no"
227 Echo "Drone mode is disabled"
228 AC_DEFINE_UNQUOTED(CMK_DRONE_MODE, 0, [disable drone mode])
230 Echo "Drone mode is enabled"
231 AC_DEFINE_UNQUOTED(CMK_DRONE_MODE, 1, [enable drone mode])
234 AC_ARG_ENABLE([charmdebug],
235 [AS_HELP_STRING([--enable-charmdebug],
236 [enable charmDebug])], ,
237 [enable_charmdebug=yes])
239 if test "$enable_charmdebug" = "no" -o "$CMK_CCS_AVAILABLE" = '0'
241 Echo "CharmDebug is disabled"
242 AC_DEFINE_UNQUOTED(CMK_CHARMDEBUG, 0, [disable charmdebug])
243 add_flag CMK_CHARMDEBUG=0
244 add_make_flag 'CMK_CHARMDEBUG:=0'
246 Echo "CharmDebug is enabled"
247 AC_DEFINE_UNQUOTED(CMK_CHARMDEBUG, 1, [enable charmdebug])
248 add_flag CMK_CHARMDEBUG=1
249 add_make_flag 'CMK_CHARMDEBUG:=1'
252 AC_ARG_ENABLE([replay],
253 [AS_HELP_STRING([--enable-replay],
254 [enable record/replay])],
255 [enable_replay=$enableval],
258 if test "$enable_replay" = "no"
260 Echo "Charm record/replay is disabled"
261 AC_DEFINE_UNQUOTED(CMK_REPLAYSYSTEM, 0, [disable replay])
263 Echo "Charm record/replay is enabled"
267 [AS_HELP_STRING([--enable-ccs],
271 if test "$enable_ccs" = "no" -o "$CMK_CCS_AVAILABLE" = '0'
273 Echo "CCS is disabled"
274 AC_DEFINE_UNQUOTED(CMK_CCS_AVAILABLE, 0, [disable ccs])
276 Echo "CCS is enabled"
277 AC_DEFINE_UNQUOTED(CMK_CCS_AVAILABLE, 1, [enable ccs])
280 AC_ARG_ENABLE([controlpoint],
281 [AS_HELP_STRING([--enable-controlpoint],
282 [enable control point])],
283 [enable_controlpoint=$enableval],
284 [enable_controlpoint=yes])
286 if test "$enable_controlpoint" = "yes"
288 Echo "Charm control point is enabled"
289 AC_DEFINE_UNQUOTED(CMK_WITH_CONTROLPOINT, 1, [enable controlpoint])
291 Echo "Charm control point is disabled"
292 AC_DEFINE_UNQUOTED(CMK_WITH_CONTROLPOINT, 0, [disable controlpoint])
295 AC_ARG_ENABLE([lbuserdata],
296 [AS_HELP_STRING([--enable-lbuserdata],
297 [enable LB user data])],
298 [enable_lbuserdata=$enableval],
299 [enable_lbuserdata=no])
301 if test "$enable_lbuserdata" = "yes"
303 Echo "Charm LB user data is enabled"
304 AC_DEFINE_UNQUOTED(CMK_LB_USER_DATA, 1, [enable lb user data])
306 Echo "Charm LB user data is disabled"
307 AC_DEFINE_UNQUOTED(CMK_LB_USER_DATA, 0, [disable lb user data])
310 AC_ARG_ENABLE([lockless-queue],
311 [AS_HELP_STRING([--enable-lockless-queue],
312 [enable lockless queue for PE local and node queue])],
313 [enable_lockless_queue=$enableval],
314 [enable_lockless_queue=no])
316 if test "$enable_lockless_queue" = "no"
318 Echo "Lockless queue for PE local and node queue is disabled"
319 AC_DEFINE_UNQUOTED(CMK_LOCKLESS_QUEUE, 0, [disable lockless queue for pe/node queue])
321 Echo "Lockless queue for PE local and node queue is enabled"
322 AC_DEFINE_UNQUOTED(CMK_LOCKLESS_QUEUE, 1, [enable lockless queue for pe/node queue])
326 AC_ARG_ENABLE([shrinkexpand],
327 [AS_HELP_STRING([--enable-shrinkexpand],
328 [enable malleable jobs / shrink expand])],
329 [enable_shrinkexpand=$enableval],
330 [enable_shrinkexpand=no])
332 if test "$enable_shrinkexpand" = "yes"
334 if test "$enable_ccs" = "no"
336 Echo "CCS cannot be disabled when enabling shrink-expand"
339 Echo "Charm shrink expand is enabled - Controlpoint is disabled."
340 AC_DEFINE_UNQUOTED(CMK_SHRINK_EXPAND, 1, [enable shrinkexpand])
341 AC_DEFINE_UNQUOTED(CMK_WITH_CONTROLPOINT, 0, [disable controlpoint])
344 Echo "Charm shrink expand is disabled"
345 AC_DEFINE_UNQUOTED(CMK_SHRINK_EXPAND, 0, [disable shrinkexpand])
348 AC_ARG_ENABLE([charmpy],
349 [AS_HELP_STRING([--enable-charmpy],
350 [enable charm4py support])],
351 [enable_charmpy=$enableval],
354 if test "$enable_charmpy" = "yes"
356 Echo "charm4py support is enabled"
357 AC_DEFINE_UNQUOTED(CMK_CHARMPY, 1, [enable charmpy])
359 Echo "charm4py support is disabled"
360 AC_DEFINE_UNQUOTED(CMK_CHARMPY, 0, [disable charmpy])
364 [AS_HELP_STRING([--with-numa],
365 [support memory affinity with NUMA])],
370 if test "$with_numa" = "yes"
372 Echo "Charm NUMA support is builtin"
376 AC_ARG_WITH([lbtime-type],
377 [AS_HELP_STRING([--with-lbtime-type=type],
378 [load balancing timer type])],
379 [], [with_lbtime_type=double])
381 if test "$with_lbtime_type" = "float" -o "$with_lbtime_type" = "double"
383 Echo "Setting load balancing timer type as '$with_lbtime_type'"
384 AC_DEFINE_UNQUOTED(CMK_LBTIME_TYPE, $with_lbtime_type, [Setting load balancing timer type])
386 Echo "Invalid type specified for load balancing timer type"
390 AC_DEFINE_UNQUOTED(CMK_LBID_64BIT, 1, [enable 64 bit LB ID])
392 AC_DEFINE_UNQUOTED(CMK_CKSECTIONINFO_STL, 1, [enable STL CkSectionInfo])
394 AC_ARG_WITH([qlogic],
395 [AS_HELP_STRING([--with-qlogic],
396 [QLogic based Infiniband])],[with_qlogic=yes],
399 if test "$with_qlogic" = "no"
401 AC_DEFINE_UNQUOTED(QLOGIC, 0, [disable qlogic])
403 Echo "QLogic based Infiniband"
404 AC_DEFINE_UNQUOTED(QLOGIC, 1, [enable qlogic])
408 AC_MSG_CHECKING(machine name)
409 version=`pwd | awk -F/ '{print $(NF-1)}'`
410 base_version="$CMK_VDIR"
411 AC_DEFINE_UNQUOTED(CMK_MACHINE_NAME, "$version",[machine name])
412 AC_MSG_RESULT($version)
413 AC_SUBST(base_version)
418 # test result passed in $1
419 # If the test suceeded, print $3 and set "pass"/clear "fail"
420 # If the test failed, print $2 and clear "pass"/set "fail"
431 # For debugging the configure script, just "export autoconf_debug=1"
432 # to get this verbose data on any failed tests:
433 if test ! -z "$autoconf_debug"
435 echo "------- test script for $2 failed:"
437 echo "------- the test program was:"
444 # Test: tries to compile C file $t (described by $1).
445 # If successful, prints $2 and sets $pass/clears $fail
446 # If failure, prints $3 and sets $pass/clears $fail
447 # additional arguments to c++ compiler are passed as $4
449 AC_MSG_CHECKING("$1")
450 echo "### $1" >> $charmout
452 echo $CMK_CC $CMK_CC_FLAGS -I../include -I. $CMK_INCDIR $CMK_SYSINC $OPTS_CC -c $tc -o test.o $4 >> $charmout
453 $CMK_CC $CMK_CC_FLAGS -I../include -I. $CMK_INCDIR $CMK_SYSINC $OPTS_CC -c $tc -o test.o $4 > out 2>&1
454 test_result $? "$1" "$2" "$3"
459 if grep -i "warn" out > /dev/null 2>&1 || grep -i "(W)" out > /dev/null 2>&1
461 strictpass="0" && strictfail="1"
468 # Test: tries to compile C++ file $t (described by $1).
469 # If successful, prints $2 and sets $pass/clears $fail
470 # If failure, prints $3 and sets $pass/clears $fail
471 # additional arguments to c++ compiler are passed as $4
473 AC_MSG_CHECKING("$1")
474 echo "### $1" >> $charmout
476 echo $CMK_CXX $CMK_CXX_FLAGS -I../include -I. $CMK_INCDIR $CMK_SYSINC $OPTS_CXX -c $t -o test.o $4 >> $charmout
477 $CMK_CXX $CMK_CXX_FLAGS -I../include -I. $CMK_INCDIR $CMK_SYSINC $OPTS_CXX -c $t -o test.o $4 > out 2>&1
478 test_result $? "$1" "$2" "$3"
483 if grep -i "warn" out > /dev/null 2>&1 || grep -i "(W)" out > /dev/null 2>&1
485 strictpass="0" && strictfail="1"
492 # Test: tries to compile C++ file $t (described by $1) using native compiler.
493 # If successful, prints $2 and sets $pass/clears $fail
494 # If failure, prints $3 and sets $pass/clears $fail
495 # additional arguments to c++ compiler are passed as $4
497 AC_MSG_CHECKING("$1")
498 echo "### $1" >> $charmout
500 echo $CMK_NATIVE_CXX $CMK_NATIVE_CXX_FLAGS -I../include -I. $CMK_INCDIR $CMK_SYSINC $OPTS_CXX -c $t -o test.o $4 >> $charmout
501 $CMK_NATIVE_CXX $CMK_NATIVE_CXX_FLAGS -I../include -I. $CMK_INCDIR $CMK_SYSINC $OPTS_CXX -c $t -o test.o $4 > out 2>&1
502 test_result $? "$1" "$2" "$3"
507 if grep -i "warn" out > /dev/null 2>&1 || grep -i "(W)" out > /dev/null 2>&1
509 strictpass="0" && strictfail="1"
516 # Testlink: tries to compile and link a C++ file $t (described by $1).
517 # If successful, prints $2 and sets $pass/clears $fail
518 # If failure, prints $3 and sets $pass/clears $fail
519 # additional arguments to c++ compiler are passed as $4
521 AC_MSG_CHECKING("$1")
522 echo "### $1" >> $charmout
524 echo $CMK_CXX $CMK_CXX_FLAGS -I../include -I. $CMK_INCDIR $CMK_SYSINC $OPTS_CXX -c $t -o test.o $4 >> $charmout
525 $CMK_CXX $CMK_CXX_FLAGS -I../include -I. $CMK_INCDIR $CMK_SYSINC $OPTS_CXX -c $t -o test.o $4 > out 2>&1
528 test_result 1 "$1" "$2" "$3"
530 echo $CMK_LDXX $CMK_LDXX_FLAGS $CMK_LINK_BINARY -o testlink test.o $CMK_LIBDIR $OPTS_LD $CMK_SYSLIBS $4 $5 >> $charmout
531 $CMK_LDXX $CMK_LDXX_FLAGS $CMK_LINK_BINARY -o testlink test.o $CMK_LIBDIR $OPTS_LD $CMK_SYSLIBS $4 $5 >> out 2>&1
533 test ! -x testlink && ret=1
534 test_result $ret "$1" "$2" "$3"
540 if cat out | grep -i "warn" > /dev/null 2>&1
542 strictpass="0" && strictfail="1"
549 # Testlinkc: tries to compile and link a C file $t (described by $1).
550 # If successful, prints $2 and sets $pass/clears $fail
551 # If failure, prints $3 and sets $pass/clears $fail
552 # additional arguments to c++ compiler are passed as $4
554 AC_MSG_CHECKING("$1")
555 echo "### $1" >> $charmout
557 echo $CMK_CC $CMK_CC_FLAGS -I../include -I. $CMK_INCDIR $CMK_SYSINC $OPTS_CC -c $tc -o test.o $4 >> $charmout
558 $CMK_CC $CMK_CC_FLAGS -I../include -I. $CMK_INCDIR $CMK_SYSINC $OPTS_CC -c $tc -o test.o $4 > out 2>&1
561 test_result 1 "$1" "$2" "$3"
563 echo $CMK_LD $CMK_LD_FLAGS $CMK_LINK_BINARY -o testlink test.o $CMK_LIBDIR $OPTS_LD $CMK_SYSLIBS $4 >> $charmout
564 $CMK_LD $CMK_LD_FLAGS $CMK_LINK_BINARY -o testlink test.o $CMK_LIBDIR $OPTS_LD $CMK_SYSLIBS $4 >> out 2>&1
565 test_result $? "$1" "$2" "$3"
571 if cat out | grep -i "warn" > /dev/null 2>&1
573 strictpass="0" && strictfail="1"
580 # test_linkso $1 $2 $3 $4, where
584 # $4: extra link option
586 AC_MSG_CHECKING("$1")
589 echo $CMK_CXX $CMK_CXX_FLAGS -I../include -I. $CMK_INCDIR $CMK_SYSINC $OPTS_CXX $CMK_PIC -c $t -o test.o $4 >> $charmout
590 $CMK_CXX $CMK_CXX_FLAGS -I../include -I. $CMK_INCDIR $CMK_SYSINC $OPTS_CXX -c $CMK_PIC $t -o test.o $4 > out 2>&1
593 test_result 1 "$1" "$2" "$3"
595 echo $CMK_LD $CMK_LD_FLAGS $CMK_LIBDIR $OPTS_LD $CMK_LD_SHARED $CMK_SYSLIBS test.o -o testlink.$CMK_SHARED_SUF $4 >> $charmout
596 $CMK_LD $CMK_LD_FLAGS $CMK_LIBDIR $OPTS_LD $CMK_LD_SHARED $CMK_SYSLIBS test.o -o testlink.$CMK_SHARED_SUF $4 > out 2>&1
597 test_result $? "$1" "$2" "$3"
600 /bin/rm -f out testlink.$CMK_SHARED_SUF
604 rm -f $t $tc testlink test.o > /dev/null 2>&1
606 test $1 -eq 1 && echo "*** Please find detailed output in tmp/charmconfig.out ***"
610 # detect certain architectures
611 if cat /proc/cpuinfo 2>/dev/null | grep 'POWER7' > /dev/null
613 AC_DEFINE_UNQUOTED(CMK_POWER7, 1, [whether is power7])
618 if test $OSNAME = "Linux"
620 AC_DEFINE_UNQUOTED(CMK_OS_IS_LINUX, 1, [OS is Linux])
622 AC_DEFINE_UNQUOTED(CMK_OS_IS_LINUX, 0, [OS is Linux])
626 AC_MSG_CHECKING("cp command as")
629 if ! $CP test_file test_file.cp 2>err
633 rm -f test_file test_file.cp
635 add_flag CP=\""$CP"\" "cp command"
641 printf("Hello, world!\n");
645 if test "$CMK_BUILD_CRAY" = "1"
647 #echo "Test for known incompatible compiler versions"
649 if test "$CRAY_CC_VERSION" = "8.1.4"
651 echo "CCE 8.1.4 produces incorrect Charm++ code"
652 echo "Please use a newer version of the CCE compiler"
653 echo "e.g. module load cce/8.1.7"
658 #echo "set C++ compiler as: $CMK_CXX $OPTS_CXX $OPTS"
659 AC_MSG_CHECKING("C++ compiler as")
660 AC_MSG_RESULT("$CMK_CXX $OPTS_CXX")
661 test_cxx "whether C++ compiler works" "ok" "no" ""
664 echo "Cannot compile C++ programs with $CMK_CXX"
665 echo " (check your charm++ version)"
672 printf("Hello, world!\n");
676 #echo "set C++ linker as: $CMK_LDXX $OPTS_LD"
677 AC_MSG_CHECKING("C++ linker as")
678 AC_MSG_RESULT("$CMK_LDXX $OPTS_LD")
679 test_link "whether linker works" "ok" "no" ""
682 echo "Cannot link C++ programs with $CMK_LDXX"
683 echo " (check your charm++ version)"
687 AC_MSG_CHECKING("Native C++ compiler as")
688 AC_MSG_RESULT("$CMK_NATIVE_CXX")
689 AC_MSG_CHECKING("Sequential C++ compiler as")
690 AC_MSG_RESULT("$CMK_SEQ_CXX")
692 if echo "$CMK_CC" | grep -E "gcc|clang|icc" > /dev/null 2> /dev/null
694 test_link "whether compiler accept -fno-stack-protector" "ok" "no" "-fno-stack-protector"
695 if test $strictpass -eq 1
697 add_flag OPTS_CC='"$OPTS_CC -fno-stack-protector"' "stack-protection disabling"
698 add_flag OPTS_CXX='"$OPTS_CXX -fno-stack-protector"' "stack-protection disabling"
702 #### check if C++ compiler will accept C++11 features without warning ####
704 // Check for Intel compiler incompatibility with the active g++/libstdc++ by
705 // including an arbitrary standard library header (cf bug #1560)
708 // Check for an excessively old g++/libstdc++ that can't handle features we use
711 std::unique_ptr<int> i;
713 class CkMigrateMessage;
717 base(CkMigrateMessage *) { }
720 template <class Parent>
721 struct CBaseT1 : Parent {
722 std::vector<int> v; // check for C++11's shrink_to_fit()
724 CBaseT1(void) :Parent() { v.shrink_to_fit(); }
725 CBaseT1(CkMigrateMessage *m) :Parent(m) { }
726 CBaseT1(CBaseT1&& rhs) :Parent() { }
728 template <typename... Args>
729 CBaseT1(Args... args) : Parent(args...) { }
732 template struct CBaseT1<base>;
735 test_cxx "whether C++ compiler supports C++11 without flags" "yes" "no" ""
736 if test $strictpass -eq 1
740 # Flags for g++/clang++/icpc/xlC++, pgCC, and CrayCC respectively
741 for i in "-std=c++11" "--c++11" "-h std=c++11"; do
742 test_cxx "whether C++ compiler supports C++11 with '$i'" "yes" "no" "$i"
743 if test $strictpass -eq 1
745 add_flag "$(echo OPTS_CXX=\"\$OPTS_CXX $i\")" "Enable C++11 support"
746 OPTS_CXX="$OPTS_CXX $i"
753 if test -z $got_cpp11
755 echo "Charm++ requires C++11 support, but doesn't know the flag to enable it"
757 echo "For Intel's compiler please see"
758 echo "https://github.com/UIUC-PPL/charm/issues/1560"
759 echo "about making a suitable version of gcc/g++/libstdc++ available"
761 echo "For Blue Gene/Q please use the Clang compiler"
765 test_native_cxx "whether native C++ compiler supports C++11 without flags" "yes" "no" ""
766 if test $strictpass -ne 1
768 # Flags for g++/clang++/icpc/xlC++, pgCC, and CrayCC respectively
769 for i in "-std=c++11" "--c++11" "-h std=c++11"; do
770 test_native_cxx "whether C++ compiler supports C++11 with '$i'" "yes" "no" "$i"
771 if test $strictpass -eq 1
773 add_flag "$(echo CMK_NATIVE_CXX_FLAGS=\"\$CMK_NATIVE_CXX_FLAGS $i\")" "Enable C++11 support"
779 # Workaround for bug #1045 appearing in GCC >6.x
780 test_cxx "whether C++ compiler accepts -fno-lifetime-dse" "yes" "no" "-fno-lifetime-dse"
781 if test $strictpass -eq 1
783 add_flag "$(echo OPTS_CXX=\"\$OPTS_CXX -fno-lifetime-dse\")" "Disable 'Lifetime DSE' optimization to work around bug #1045 in GCC >6.x"
784 OPTS_CXX="$OPTS_CXX -fno-lifetime-dse"
787 # Test for a flag tlsglobals sometimes depends on
788 test_cxx "whether C++ compiler accepts -mno-tls-direct-seg-refs" "yes" "no" "-mno-tls-direct-seg-refs"
789 if test $strictpass -eq 1
791 add_flag 'CMK_COMPILER_KNOWS_TLSDIRECTSEGREFS="1"' "tlsglobals"
794 # Determine compiler/linker flags to build libcharm.so for charm4py
795 if test "$enable_charmpy" = "yes"
799 int main() { return 0; }
802 test_cxx "whether C++ compiler accepts --no-as-needed" "yes" "no" "--no-as-needed"
803 if test $strictpass -eq 1
805 add_flag "$(echo CXX_NO_AS_NEEDED=\"--no-as-needed\")" "--no-as-needed flag necessary for compilers that default to linking with --as-needed"
808 got_opt_whole_archive=""
809 # Flags for g++/clang++/icpc, Apple-LLVM respectively
810 for i in "-Wl,--whole-archive -Wl,--no-whole-archive" "-Wl,-all_load"; do
811 test_link "whether linker supports '$i'" "yes" "no" "" "$i"
812 if test $strictpass -eq 1
814 got_opt_whole_archive="true"
815 IFS=' ' read LDXX_WHOLE_ARCHIVE_PRE LDXX_WHOLE_ARCHIVE_POST <<< $i
816 add_flag "$(echo LDXX_WHOLE_ARCHIVE_PRE=\"$LDXX_WHOLE_ARCHIVE_PRE\")" "Flags to link whole archives into libcharm.so"
817 add_flag "$(echo LDXX_WHOLE_ARCHIVE_POST=\"$LDXX_WHOLE_ARCHIVE_POST\")" "Flags to link whole archives into libcharm.so"
822 if test -z $got_opt_whole_archive
824 echo "Don't know how to build libcharm.so for Charm4py"
829 # Figure out if the user has asked to enable the latest language standards
830 USER_ASKED_FOR_NEW_STD=`echo "$BUILDOPTS" | grep "\-use-new-std" | wc -l`
832 # If the user has asked for the newer standards, check if the compilers know about them
833 if test $USER_ASKED_FOR_NEW_STD -ge 1
836 #### check if c compiler supports c11 compilation flags ####
845 test_cc "whether c compiler knows of the c11 standard" "ok" "no" "$CMK_ENABLE_C11"
846 AC_DEFINE_UNQUOTED(CMK_COMPILER_KNOWS_C11, $pass, [whether c compiler knows of the c11 standard] )
849 # Record results for charmc's future use
850 add_flag 'CMK_COMPILER_KNOWS_C11="1"' "c11"
851 # For the rest of configure, append this to compilation flags
852 OPTS_CC="$CMK_ENABLE_C11 $OPTS_CC"
854 fi # endif USER_ASKED_FOR_NEW_STD
858 AC_ARG_WITH([refnum-type],
859 [AS_HELP_STRING([--with-refnum-type=type],
860 [size of the envelope refnum field])],
861 [], [with_refnum_type=no])
863 if test "$with_refnum_type" = "no" -o "$with_refnum_type" = "short"
865 Echo "Setting charm++ envelope refnum field to unsigned short"
866 AC_DEFINE_UNQUOTED(CMK_REFNUM_TYPE, unsigned short, [envelope refnum field set to UShort])
867 elif test "$with_refnum_type" = "int"
869 Echo "Setting charm++ envelope refnum field to unsigned int"
870 AC_DEFINE_UNQUOTED(CMK_REFNUM_TYPE, unsigned int, [envelope refnum field set to UInt])
872 Echo "Invalid size specified for refnum field"
877 AC_ARG_WITH([prio-type],
878 [AS_HELP_STRING([--with-prio-type=type],
879 [size of expected message priorities])],
880 [], [with_prio_type=bitvec])
882 if test "$with_prio_type" = "char" -o "$with_prio_type" = "short" -o "$with_prio_type" = "int" -o "$with_prio_type" = "long" -o "$with_prio_type" = "float" -o "$with_prio_type" = "double"
884 Echo "Configuring support for message priorities of sizeof type $with_prio_type"
885 AC_DEFINE_UNQUOTED(CMK_USE_STL_MSGQ, 1, [whether charm scheduler should use an STL-based msg q])
886 AC_DEFINE_UNQUOTED(CMK_MSG_PRIO_TYPE, $with_prio_type, [expected message priorities are sizeof $with_prio_type])
887 elif test "$with_prio_type" = "bitvec"
889 Echo "Configuring support for message priorities of arbitrary size (bitvectors)"
890 AC_DEFINE_UNQUOTED(CMK_USE_STL_MSGQ, 0, [whether charm scheduler should use an STL-based msg q])
891 AC_DEFINE_UNQUOTED(CMK_MSG_PRIO_TYPE, $with_prio_type, [expected message priorities are arbitrarily sized])
893 Echo "Invalid size ($with_prio_type) specified for message priorities. Can only accept char, short, int, long, float, double and bitvec"
897 # enable/disable randomized scheduler queue
898 AC_ARG_ENABLE([randomized-msgq],
899 [AS_HELP_STRING([--enable-randomized-msgq],
900 [enable a randomized msg queue (for debugging etc)])], ,
901 [enable_randomized_msgq=no])
903 if test "$enable_randomized_msgq" = "yes" -a "$with_prio_type" != "bitvec"
905 Echo "The charm message queue will be randomized (and will not respect priorities)"
906 AC_DEFINE_UNQUOTED(CMK_RANDOMIZED_MSGQ, 1, [enable the randomized msgq in the scheduler])
908 AC_DEFINE_UNQUOTED(CMK_RANDOMIZED_MSGQ, 0, [disable the randomized msgq in the scheduler])
909 if test "$enable_randomized_msgq" = "yes"
911 Echo 'A randomized message queue is only available when --with-prio-type != bitvec.'
912 Echo "Specify prio-type to be a data type long enough to hold the message priorities in your application"
913 Echo "for example: --with-prio-type=int (or short / long etc)."
918 AC_ARG_WITH([mempool-cutoff],
919 [AS_HELP_STRING([--with-mempool-cutoff=N],
920 [exponent of the maximum power of two to use for bin sizes in the mempool])],
921 [], [with_mempool_cutoff=26])
923 if test "$((6 < $with_mempool_cutoff && $with_mempool_cutoff < 32))" = '1'
925 Echo "Using mempool cutoff... 2^$with_mempool_cutoff"
926 AC_DEFINE_UNQUOTED(CMK_MEMPOOL_CUTOFFNUM, $((with_mempool_cutoff - 6)), [mempool cutoff])
928 Echo "Invalid number ($with_mempool_cutoff) specified for mempool cutoff. Valid range: 7 <= N <= 31"
933 AC_ARG_ENABLE([ampi-mpich-tests],
934 [AS_HELP_STRING([--enable-ampi-mpich-tests],
935 [enable mpich tests for ampi])],
936 [enable_ampi_mpich_tests=yes],
937 [enable_ampi_mpich_tests=no])
939 if test "$enable_ampi_mpich_tests" = "yes"
941 AC_DEFINE([AMPI_ERRHANDLER_RETURN], [1], [enable ampi fatal error return])
942 add_make_flag "BUILD_MPICH_TESTS:=true" 'mpich tests setup'
944 AC_DEFINE([AMPI_ERRHANDLER_RETURN], [0], [disable ampi fatal error return])
947 #### Check if compiler is 64 bit ####
953 int x[[(int)(sizeof(void *) - 7)]]={0};
957 test_cxx "whether compiler generates code for 64-bit" "yes" "no" ""
958 AC_DEFINE_UNQUOTED(CMK_SIZET_64BIT, $strictpass, [whether size_t 64bit])
961 ### Check if compiler supports std::is_constructible<> ###
963 #include <type_traits>
971 return std::is_constructible<s, int>::value;
974 test_cxx "whether compiler supports std::is_constructible" "yes" "no" ""
975 AC_DEFINE_UNQUOTED(CMK_HAS_IS_CONSTRUCTIBLE, $strictpass, [whether compiler supports std::is_constructible])
977 ### Check if compiler supports std::alignment_of<> ###
979 #include <type_traits>
983 return std::alignment_of<int>::value;
986 test_cxx "whether compiler supports std::alignment_of" "yes" "no" ""
987 AC_DEFINE_UNQUOTED(CMK_HAS_ALIGNMENT_OF, $strictpass, [whether compiler supports std::alignment_of])
989 ### Check if compiler implements regex ###
994 #if __cplusplus >= 201103L && \
995 (!defined(__GLIBCXX__) || (__cplusplus >= 201402L) || \
996 (defined(_GLIBCXX_REGEX_DFS_QUANTIFIERS_LIMIT) || \
997 defined(_GLIBCXX_REGEX_STATE_LIMIT) || \
998 (defined(_GLIBCXX_RELEASE) && \
999 _GLIBCXX_RELEASE > 4)))
1000 // compiler has regex support, continue
1002 // force compilation to fail
1003 static_assert(false, "compiler has no regex implementation");
1007 test_cxx "whether compiler implements regex" "yes" "no" ""
1008 AC_DEFINE_UNQUOTED(CMK_HAS_REGEX, $pass, [whether compiler implements regex])
1010 #### test if has values.h ####
1014 double d = MAXDOUBLE;
1018 test_cxx "whether has values.h " "yes" "no" ""
1019 AC_DEFINE_UNQUOTED(CMK_HAS_VALUES_H, $pass, [whether has values.h])
1021 #### test if has stdint.h ####
1028 test_cxx "whether has stdint.h " "yes" "no" ""
1029 AC_DEFINE_UNQUOTED(CMK_HAS_STDINT_H, $pass, [whether has stdint.h])
1031 #### test if has malloc.h ####
1038 test_cxx "whether has malloc.h " "yes" "no" ""
1039 AC_DEFINE_UNQUOTED(CMK_HAS_MALLOC_H, $pass, [whether has malloc.h])
1041 #### test if has alloca.h ####
1045 double *s=(double *)alloca(sizeof(double));
1050 test_cxx "whether has alloca.h " "yes" "no" ""
1051 AC_DEFINE_UNQUOTED(CMK_HAS_ALLOCA_H, $pass, [whether has alloca.h])
1053 #### test if has regex.h ####
1058 regcomp(&re, ".*MOD.*", REG_EXTENDED|REG_NOSUB);
1062 test_cxx "whether has regex.h " "yes" "no" ""
1063 AC_DEFINE_UNQUOTED(CMK_HAS_REGEX_H, $pass, [whether has regex.h])
1065 #### Check long long ####
1068 long long foo(void) { return 17; }
1070 test_cxx "whether long long works" "yes" "no" ""
1071 AC_DEFINE_UNQUOTED(CMK_LONG_LONG_DEFINED, $pass, [whether long long works])
1073 #### Check __int64 ####
1076 __int64 foo(void) { return 17; }
1078 test_cxx "whether __int64 works" "yes" "no" ""
1079 AC_DEFINE_UNQUOTED([CMK___int64_DEFINED], $pass, [whether __int64 works])
1084 #### Check __int128 ####
1089 int x[[(int)(sizeof(__int128) - 15)]]={0};
1093 test_cxx "whether __int128 (128-bit integer) works" "yes" "no" ""
1094 AC_DEFINE_UNQUOTED([CMK___int128_DEFINED], $pass, [whether __int128 works])
1098 add_flag CMK_HAS_INT16=1
1101 #### Check __int128_t ####
1108 int x[[(int)(sizeof(__int128_t) - 15)]]={0};
1112 test_cxx "whether __int128_t (128-bit integer) works" "yes" "no" ""
1113 AC_DEFINE_UNQUOTED([CMK___int128_t_DEFINED], $pass, [whether __int128_t works])
1117 add_flag CMK_HAS_INT16=1
1120 #### Summarize *int128* ####
1122 AC_DEFINE_UNQUOTED([CMK_HAS_INT16], $CMK_HAS_INT16, [whether any 128-bit integer works])
1125 ### Check if we have C++11 <atomic> ###
1128 int main(int argc, char** argv) {
1132 test_cxx "whether C++ library has <atomic> " "yes" "no" ""
1133 AC_DEFINE_UNQUOTED(CMK_HAS_CXX11_ATOMIC, $pass, [whether C++ library has <atomic>])
1137 ### Check if we have pre-C++11 <cstdatomic> ###
1139 #include <cstdatomic>
1140 int main(int argc, char** argv) {
1144 test_cxx "whether C++ library has <cstdatomic> " "yes" "no" ""
1145 AC_DEFINE_UNQUOTED(CMK_HAS_CXX0X_CSTDATOMIC, $pass, [whether C++ library has <cstdatomic>])
1148 if test $pass -ne 1 -a "$CMK_COMPILER" != "bgxlc"
1150 echo "Charm++ requires C++11 atomic support"
1154 #### Check long double ####
1157 long double foo(void) { return 17.0; }
1159 test_cxx "whether long double works" "yes" "no" ""
1160 AC_DEFINE_UNQUOTED(CMK_LONG_DOUBLE_DEFINED, $strictpass, [whether long double works])
1162 #### Check ucontext and FPU pointer ####
1164 #include <ucontext.h>
1165 struct _libc_fpstate fpstate;
1169 context.uc_mcontext.fpregs = 0;
1172 test_cxx "whether ucontext has FPU pointer" "yes" "no" ""
1173 AC_DEFINE_UNQUOTED(CMK_CONTEXT_FPU_POINTER, $pass, [whether ucontext has pointer])
1178 #include <ucontext.h>
1183 context.uc_mcontext.uc_regs = 0;
1186 test_cxx "whether ucontext uses uc_regs" "yes" "no" ""
1187 AC_DEFINE_UNQUOTED(CMK_CONTEXT_FPU_POINTER_UCREGS, $pass, [whether ucontext uses uc_regs union])
1191 #include <ucontext.h>
1197 vrregset_t *ptr = uc.uc_mcontext.v_regs;
1200 test_cxx "whether ucontext has pointer (v_regs) of vector type" "yes" "no" ""
1201 AC_DEFINE_UNQUOTED(CMK_CONTEXT_V_REGS, $pass, [whether ucontext has pointer (v_regs) of vector type])
1203 #### Check ucontext and FPU pointer ####
1205 #include <infiniband/verbs.h>
1208 struct ibv_context *context;
1210 struct ibv_port_attr attr;
1211 if (ibv_query_port(context, ibPort, &attr) != 0) return;
1212 if (attr.link_layer == IBV_LINK_LAYER_INFINIBAND) return;
1215 test_cxx "whether ibverbs ibv_port_attr has link_layer field" "yes" "no" ""
1216 AC_DEFINE_UNQUOTED(CMK_IBV_PORT_ATTR_HAS_LINK_LAYER, $pass, [whether ibv_port_attr has link_layer field])
1219 ###################### C++ Compiler Features #####################
1221 #### check C inline ####
1223 inline static int foo()
1228 test_cc "whether inline works in C" "yes" "no" ""
1229 AC_DEFINE_UNQUOTED(CMK_C_INLINE, $strictpass, [whether C inline works in C])
1231 #### check if signed char is same as char ####
1236 void operator()(char &v,const char *desc=NULL) {};
1237 void operator()(signed char &v,const char *desc=NULL) {};
1240 test_cxx "whether C++ signed char and char differ" "yes" "no" ""
1241 AC_DEFINE_UNQUOTED(CMK_SIGNEDCHAR_DIFF_CHAR, $pass, [whether C++ signed char and char differ])
1243 #### check if typeinfo exists and works #####
1246 const char *foo(void) {
1248 return typeid(x).name();
1251 test_cxx "whether typeinfo/typeid works" "ok" "no" ""
1252 AC_DEFINE_UNQUOTED(CMK_HAS_TYPEINFO, $pass, [whether typeinfo/typeid works])
1254 #### check if iterator_traits is defined #####
1258 template <typename T> // T models Input Iterator
1259 typename std::iterator_traits<T>::value_type accumulate(T first, T last)
1261 typename std::iterator_traits<T>::value_type result = 0;
1262 while(first != last)
1267 test_cxx "whether std::iterator_traits is defined" "ok" "no" ""
1268 AC_DEFINE_UNQUOTED(CMK_HAS_ITERATOR_TRAITS, $pass, [whether iterator_traits works])
1270 #### check if std::distance is defined #####
1277 std::vector<int> tree;
1278 return std::distance(tree.begin(), tree.end());
1281 test_cxx "whether std::distance is defined" "ok" "no" ""
1282 AC_DEFINE_UNQUOTED(CMK_HAS_STD_DISTANCE, $pass, [whether std::distance works])
1284 #### check if std::inserter is defined #####
1291 using namespace std;
1293 inserter ( L, L.end ( ) ) = 500;
1296 test_cxx "whether std::inserter is defined" "ok" "no" ""
1297 AC_DEFINE_UNQUOTED(CMK_HAS_STD_INSERTER, $pass, [whether std::inserter works])
1299 #### check if C++17's std::void_t is defined #####
1301 #include <type_traits>
1303 template<typename T, typename = std::void_t<>>
1304 struct has_pup_member : std::false_type {};
1307 test_cxx "whether std::void_t is defined" "ok" "no" ""
1308 AC_DEFINE_UNQUOTED(CMK_HAS_STD_VOID_T, $pass, [whether std::void_t works])
1310 ####### Check support for features added by the new C11 and CPP11 standards ########
1312 #### test if we can have multiple delete like this ####
1316 void operator delete(void*p){};
1317 void operator delete(void*p,int*){};
1320 test_cxx "whether operator delete can be overloaded in same class" "ok" "no" ""
1321 AC_DEFINE_UNQUOTED(CMK_MULTIPLE_DELETE, $strictpass, [whether operator delete can be overloaded in same class])
1323 #### test if offsetof exists ####
1335 int off = offsetof(FooType, f2);
1338 test_cxx "whether offsetof is defined" "yes" "no" ""
1339 AC_DEFINE_UNQUOTED(CMK_HAS_OFFSETOF, $pass, [whether offsetof exists])
1341 #### test if we can use gcc x86 assembly like this ####
1345 unsigned long long int v=0;
1346 int *lo=0+(int *)&v;
1347 int *hi=1+(int *)&v;
1348 __asm__ __volatile__(
1349 "rdtsc; movl %%edx,%0; movl %%eax,%1"
1350 : /* output */ "=m" (*hi), "=m" (*lo)
1352 : /* trashes */ "%edx", "%eax"
1357 test_cxx "whether GCC x86 assembly works" "yes" "no" ""
1358 AC_DEFINE_UNQUOTED(CMK_GCC_X86_ASM, $strictpass, [Allows gcc x86 assembly.])
1360 #### test if we can use gcc x86 assembly like this ####
1361 if test $strictpass = 1
1367 asm("lock incl %0" :: "m" (x));
1368 asm("lock decl %0" :: "m" (x));
1372 test_cxx "whether GCC x86 assembly for atomic increment works" "yes" "no" ""
1373 AC_DEFINE_UNQUOTED(CMK_GCC_X86_ASM_ATOMICINCREMENT, $strictpass, [Allows gcc x86 assembly for atomic increment.])
1376 #### test if we can use asm eieio assembly like this ####
1380 unsigned long long int x;
1381 asm volatile("eieio" ::: "memory");
1385 test_cxx "whether asm eieio assembly works" "yes" "no" ""
1386 AC_DEFINE_UNQUOTED(CMK_PPC_ASM, $strictpass, [Allows asm eieio assembly.])
1390 #### test if we can use __thread ####
1392 __thread unsigned long long int x;
1393 static __thread int y;
1400 test_cxx "whether __thread (Thread Local Storage) is supported" "yes" "no" ""
1401 AC_DEFINE_UNQUOTED(CMK_HAS_TLS_VARIABLES, $strictpass, [Allows __thread.])
1403 #### check __sync_add_and_fetch ####
1409 __sync_add_and_fetch(&t, 1);
1413 test_linkc "whether synchronization primitives (__sync_add_and_fetch) works in C" "yes" "no" ""
1414 AC_DEFINE_UNQUOTED(CMK_C_SYNC_ADD_AND_FETCH_PRIMITIVE, $pass, [whether sync_add_and_fetch primitive works in C])
1416 #### check __sync_synchronize ####
1421 __sync_synchronize();
1425 test_linkc "whether synchronization primitives (__sync_synchronize) works in C" "yes" "no" ""
1427 AC_DEFINE_UNQUOTED(CMK_C_SYNC_SYNCHRONIZE_PRIMITIVE, $pass, [whether sync_synchronize primitives works in C])
1430 ### test for __executable_start ###
1433 extern int __executable_start;
1436 return __executable_start;
1439 test_linkc "whether has __executable_start" "yes" "no" ""
1440 AC_DEFINE_UNQUOTED([CMK_HAS_EXECUTABLE_START], $pass, [whether has __executable_start])
1442 ### test if switching TLS register ###
1443 if test $in64bit = 1
1448 asm volatile ("movq %%fs:0x0, %0\n\t"
1449 "movq %1, %%fs:0x0\n\t"
1454 test_cxx "whether switching TLS register (64-bit) is supported" "yes" "no" ""
1455 AC_DEFINE_UNQUOTED(CMK_TLS_SWITCHING_X86_64, $strictpass, [Allows switching TLS on x86_64.])
1460 asm volatile ("movl %%gs:0x0, %0\n\t"
1461 "movl %1, %%gs:0x0\n\t"
1466 test_cxx "whether switching TLS register (32-bit) is supported" "yes" "no" ""
1467 AC_DEFINE_UNQUOTED(CMK_TLS_SWITCHING_X86, $strictpass, [Allows switching TLS on x86.])
1470 ### test for dl_iterate_phdr ###
1474 # define _GNU_SOURCE
1481 static int callback(struct dl_phdr_info* info, size_t size, void* data)
1487 dl_iterate_phdr(callback, NULL);
1491 test_linkc "whether has dl_iterate_phdr" "yes" "no" ""
1492 AC_DEFINE_UNQUOTED([CMK_HAS_DL_ITERATE_PHDR], $pass, [whether has dl_iterate_phdr])
1495 ### test for __malloc_hook ###
1498 extern int __malloc_hook;
1501 return __malloc_hook;
1504 test_linkc "whether has __malloc_hook" "yes" "no" ""
1505 AC_DEFINE_UNQUOTED([CMK_HAS_MALLOC_HOOK], $pass, [whether has __malloc_hook])
1506 add_make_flag "CMK_HAS_MALLOC_HOOK:=$pass" 'whether has __malloc_hook'
1509 #### test if we can build OFI ####
1510 if test "$CMK_BUILD_OFI" = 1
1513 #include <rdma/fabric.h>
1514 int main(int argc, char **argv)
1516 struct fi_info *providers;
1517 int ret = fi_getinfo(FI_VERSION(1,0), NULL, NULL, 0ULL, NULL, &providers);
1521 test_cc "whether build on OFI" "yes" "no" "-lfabric"
1522 AC_DEFINE_UNQUOTED(CMK_BUILD_ON_OFI, $strictpass, [build OFI.])
1523 BUILD_OFI=$strictpass
1525 if test $BUILD_OFI -eq 0
1527 echo "Error: Unable to compile OFI"
1530 test_linkc "whether -lfabric" "ok" "no" "-lfabric"
1533 #test for psm incompatibility
1534 PSM_COMPAT_DIR=/usr/lib64/psm2-compat
1535 if test -d $PSM_COMPAT_DIR
1537 add_flag CMK_LIBDIR='"$CMK_LIBDIR -Wl,-rpath=/usr/lib64/psm2-compat"' "psm2-compat lib"
1538 CMK_LIBDIR="$CMK_LIBDIR -Wl,-rpath=/usr/lib64/psm2-compat"
1539 test_linkc "whether -lfabric after adding psm2-compatible library" "ok" "no" "-lfabric"
1542 echo "Error: -lfabric not found or not working. Pass '--basedir=/path/to/dir/' if -lfabric is located in a different directory"
1546 echo "Error: -lfabric not working, $PSM_COMPAT_DIR not found"
1547 echo "Pass '--basedir=/path/to/dir/' if -lfabric is located in a different directory"
1555 #### test if we can build MPI ####
1556 if test "$CMK_BUILD_MPI" = 1
1561 int main(int argc, char **argv)
1563 MPI_Init(&argc, &argv);
1567 mv -f ../include/mpi.h ../include/mpi.h.bak 2>/dev/null
1568 test_cc "whether build on MPI" "yes" "no" ""
1569 AC_DEFINE_UNQUOTED(CMK_BUILD_ON_MPI, $strictpass, [build MPI.])
1570 BUILD_MPI=$strictpass
1572 if test $BUILD_MPI -eq 0
1574 echo "Error: Cannot compile an MPI program"
1578 if test $BUILD_MPI -eq 1
1580 test_linkc "whether need to specify MPI library" "no" "yes" ""
1583 if test -z "$CMK_MPI_LIB"
1585 test_linkc "whether -lmpich" "ok" "no" "-lmpich"
1588 add_flag CMK_SYSLIBS='"$CMK_SYSLIBS -lmpich"' "mpi lib"
1590 test_linkc "whether -lmpi" "ok" "no" "-lmpi"
1593 add_flag CMK_SYSLIBS='"$CMK_SYSLIBS -lmpi"' "mpi lib"
1595 echo "Error: Cannot find MPI library"
1600 add_flag CMK_SYSLIBS='"$CMK_SYSLIBS $CMK_MPI_LIB"' "mpi lib"
1605 if test "$BUILD_MPI" = "1"
1609 int main(int argc, char **argv)
1611 int thread_level, provided;
1612 thread_level = MPI_THREAD_FUNNELED;
1613 MPI_Init_thread(&argc, &argv, thread_level, &provided);
1616 test_cxx "whether MPI_Init_thread is supported" "yes" "no" ""
1617 AC_DEFINE_UNQUOTED(CMK_MPI_INIT_THREAD, $strictpass, [Allows MPI_Init_thread.])
1619 mv -f ../include/mpi.h.bak ../include/mpi.h 2>/dev/null
1623 if test "$BUILD_MPI" = "1"
1630 int main (int argc, char** argv) {
1634 test_cxx "whether macro conflicts occurs due to C++ MPI bindings" "no" "yes" ""
1635 AC_DEFINE_UNQUOTED(CMK_CXX_MPI_BINDINGS, $strictpass, [Disables conflicting macros.])
1639 ################### Syscalls and Libraries ###################
1641 #### test for getrusage with RUSAGE_THREAD ###
1644 # define _GNU_SOURCE
1649 #include <sys/time.h>
1650 #include <sys/resource.h>
1652 struct rusage usage;
1653 getrusage(RUSAGE_THREAD, &usage);
1657 test_linkc "whether getrusage accepts RUSAGE_THREAD" "yes" "no" ""
1658 AC_DEFINE_UNQUOTED(CMK_HAS_RUSAGE_THREAD, $pass, [whether getrusage accepts RUSAGE_THREAD])
1660 #### test for asctime ###
1668 local = localtime(&t);
1673 test_linkc "whether has asctime" "yes" "no" ""
1674 AC_DEFINE_UNQUOTED(CMK_HAS_ASCTIME, $pass, [whether has asctime])
1676 #### test for log2 ###
1684 test_link "whether has log2" "yes" "no" ""
1685 AC_DEFINE_UNQUOTED(CMK_HAS_LOG2, $pass, [whether has log2])
1687 #### test for sqrtf ###
1691 float i = sqrtf((float)10.0);
1695 test_link "whether has sqrtf" "yes" "no" ""
1696 AC_DEFINE_UNQUOTED(CMK_HAS_SQRTF, $pass, [whether has sqrtf])
1698 #### test for fabsf ###
1702 float i = fabsf((float)10.0);
1706 test_link "whether has fabsf" "yes" "no" ""
1707 AC_DEFINE_UNQUOTED(CMK_HAS_FABSF, $pass, [whether has fabsf])
1709 #### test for mkstemp ###
1715 strcpy(fname, "/tmp/fdXXX.XXX");
1720 test_link "whether has mkstemp" "yes" "no" ""
1721 AC_DEFINE_UNQUOTED(CMK_USE_MKSTEMP, $pass, [whether has mkstemp])
1723 #### test for system ###
1731 test_link "whether has system" "yes" "no" ""
1732 AC_DEFINE_UNQUOTED(CMK_HAS_SYSTEM, $pass, [whether has system])
1734 #### test for sync() ###
1742 test_link "whether has sync()" "yes" "no" ""
1743 AC_DEFINE_UNQUOTED(CMK_HAS_SYNC_FUNC, $pass, [whether has sync])
1745 #### test for fsync() ###
1753 test_link "whether has fsync()" "yes" "no" ""
1754 AC_DEFINE_UNQUOTED(CMK_HAS_FSYNC_FUNC, $pass, [whether has fsync])
1756 #### test for fdatasync() ###
1764 test_link "whether has fdatasync()" "yes" "no" ""
1765 AC_DEFINE_UNQUOTED(CMK_HAS_FDATASYNC_FUNC, $pass, [whether has fdatasync])
1767 #### test for sbrk ###
1771 void *ptr = sbrk(0);
1774 test_link "whether has sbrk" "yes" "no" ""
1775 AC_DEFINE_UNQUOTED(CMK_HAS_SBRK, $pass, [whether has sbrk])
1777 #### test for _setjmp/_longjmp ###
1786 test_link "whether has _setjmp/_longjmp" "yes" "no" ""
1787 AC_DEFINE_UNQUOTED(CMK_HAS_UNDERSCORE_SETJMP, $pass, [whether has _setjmp/_longjmp])
1789 #### test for mstats ###
1793 struct mstats ms = mstats();
1796 test_link "whether has mstats" "yes" "no" ""
1797 AC_DEFINE_UNQUOTED(CMK_HAS_MSTATS, $pass, [whether has mstats])
1799 #### test for mallinfo ###
1803 struct mallinfo mi = mallinfo();
1806 test_link "whether has mallinfo" "yes" "no" ""
1807 AC_DEFINE_UNQUOTED(CMK_HAS_MALLINFO, $pass, [whether has mallinfo])
1809 #### test for __morecore ###
1813 extern void *(*__morecore)(ptrdiff_t);
1818 test_link "whether expects __morecore symbol" "yes" "no" ""
1819 AC_DEFINE_UNQUOTED(CMK_EXPECTS_MORECORE, $pass, [whether expects __morecore symbol])
1821 #### test for popen ###
1825 FILE *p = popen("/bin/ps", "r");
1829 test_link "whether has popen" "yes" "no" ""
1830 AC_DEFINE_UNQUOTED(CMK_HAS_POPEN, $pass, [whether has popen])
1832 #### test for poll ###
1836 struct pollfd pos[[3]];
1840 test_cxx "whether has poll" "yes" "no" ""
1841 AC_DEFINE_UNQUOTED(CMK_USE_POLL, $pass, [whether the poll syscall exists])
1843 #### check if getpagesize exists ####
1847 int main(int argc, char **argv) {
1848 int s = getpagesize();
1851 test_linkc "whether has getpagesize" "yes" "no" ""
1852 AC_DEFINE_UNQUOTED(CMK_HAS_GETPAGESIZE, $pass, [whether getpagesize exists])
1854 #### check if getpid exists ####
1856 #include <sys/types.h>
1859 int main(int argc, char **argv) {
1860 pid_t pid = getpid();
1863 test_linkc "whether has getpid" "yes" "no" ""
1864 AC_DEFINE_UNQUOTED(CMK_HAS_GETPID, $pass, [whether getpid exists])
1866 #### check if kill exists ####
1868 #include <sys/types.h>
1872 int main(int argc, char**argv)
1874 pid_t pid = getpid();
1878 test_linkc "whether has kill" "yes" "no" ""
1879 AC_DEFINE_UNQUOTED(CMK_HAS_KILL, $pass, [whether kill exists])
1881 #### test for setpriority ###
1883 #include <sys/time.h>
1884 #include <sys/resource.h>
1886 setpriority(PRIO_PROCESS, 0, 0);
1889 test_cxx "whether has setpriority" "yes" "no" ""
1890 AC_DEFINE_UNQUOTED(CMK_HAS_SETPRIORITY, $pass, [whether the setpriority exists])
1892 #### test for system ###
1894 #include "ckdll_system.C"
1896 test_cxx "whether to use signal-safe system() " "yes" "no" ""
1897 AC_DEFINE_UNQUOTED(CMK_SIGSAFE_SYSTEM, $pass, [whether to use signal-safe system()])
1899 ### test sched_setaffinity ####
1908 CPU_SET(0, &cpuset);
1909 if (sched_setaffinity(0, sizeof(cpuset), &cpuset) < 0) {
1915 test_linkc "whether sched_setaffinity call exists" "yes" "no" ""
1916 AC_DEFINE_UNQUOTED(CMK_HAS_SETAFFINITY, $pass, [whether the sched_setaffinity() exists])
1918 ### test pthread_setaffinity_np ####
1923 #include <pthread.h>
1927 unsigned long mask = 0xffffffff;
1928 unsigned int len = sizeof(mask);
1930 if (pthread_setaffinity_np(pthread_self(), len, &mask) < 0) {
1936 test_linkc "whether pthread_setaffinity_np call exists" "yes" "no" "-lpthread"
1937 AC_DEFINE_UNQUOTED(CMK_HAS_PTHREAD_SETAFFINITY, $pass, [whether the pthread_setaffinity_np() exists])
1939 ### test pthread_spin_lock ####
1944 #include <pthread.h>
1948 pthread_spinlock_t lock;
1950 pthread_spin_init(&lock, 0);
1952 pthread_spin_lock(&lock);
1957 test_linkc "whether pthread_spin_lock exists" "yes" "no" "-lpthread"
1958 AC_DEFINE_UNQUOTED(CMK_HAS_SPINLOCK, $pass, [whether the pthread_spin_lock exists])
1960 ### check libnuma on Linux ####
1961 if test "$WITH_NUMA" = "yes"
1966 #include <linux/mempolicy.h>
1972 if (get_mempolicy(NULL, NULL, 0, 0, 0) == 0) return 0;
1976 test_linkc "whether libnuma exists" "yes" "no" "-lnuma"
1977 AC_DEFINE_UNQUOTED(CMK_HAS_NUMACTRL, $pass, [whether NUMA control related functions exist])
1980 add_flag 'CMK_SYSLIBS="$CMK_SYSLIBS -lnuma"' "libnuma"
1984 #### check bindprocessors on AIX ####
1990 #include <sys/processor.h>
1997 if (bindprocessor(BINDPROCESS, pid, 0) == -1) return -1;
2001 test_linkc "whether bindprocessor call exists" "yes" "no" ""
2002 AC_DEFINE_UNQUOTED(CMK_HAS_BINDPROCESSOR, $pass, [whether the bindprocessor()
2006 #### check if dlopen works ####
2008 # for bproc, ignore -ldl
2009 test -n "$CMK_BPROC" && skip_dl=1
2010 test -n "$CMK_NO_DL" && skip_dl=1
2012 #workaround for pgcc 4.0, -ldl crash linking, so use -Wl,-ldl to skip the prelinker.
2014 pgCC*) dl_opt='-Wl,-ldl' ;;
2017 if test $skip_dl -eq 0
2021 #include "ckdll_dlopen.C"
2023 CkDll dll("foo.so");
2027 test_link "whether dlopen links without $dl_opt" "yes" "no" ""
2029 test_link "whether dlopen links with $dl_opt" "yes" "no" "$dl_opt"
2032 #dlopen requires -ldl: add it to our link line
2033 add_flag CMK_LIBS='"$CMK_LIBS '$dl_opt'"' "dlopen"
2036 if test $pass -eq 1 -o $noldl -eq 1
2039 # One version or another of dlopen worked: compile it in
2040 AC_DEFINE_UNQUOTED(CMK_DLL_USE_DLOPEN, 1, [dlopen])
2045 # define _GNU_SOURCE
2054 return dlsym(RTLD_DEFAULT, "main") != NULL;
2057 test_cc "whether has RTLD_DEFAULT" "yes" "no" ""
2058 AC_DEFINE_UNQUOTED(CMK_HAS_RTLD_DEFAULT, $pass, [whether has RTLD_DEFAULT])
2062 # define _GNU_SOURCE
2071 return dlsym(RTLD_NEXT, "main") != NULL;
2074 test_cc "whether has RTLD_NEXT" "yes" "no" ""
2075 AC_DEFINE_UNQUOTED(CMK_HAS_RTLD_NEXT, $pass, [whether has RTLD_NEXT])
2079 # define _GNU_SOURCE
2088 return dlmopen(LM_ID_NEWLM, "foo.so", 0) == NULL;
2091 test_cc "whether has dlmopen" "yes" "no" ""
2092 AC_DEFINE_UNQUOTED(CMK_HAS_DLMOPEN, $pass, [whether has dlmopen])
2093 CMK_HAS_DLMOPEN="$pass"
2100 return readlink("/proc/self/exe", exe, sizeof(exe)-1) == -1;
2103 test_cc "whether has readlink" "yes" "no" ""
2104 AC_DEFINE_UNQUOTED(CMK_HAS_READLINK, $pass, [whether has readlink])
2105 CMK_HAS_READLINK="$pass"
2112 return realpath("/proc/self/exe", NULL) == NULL;
2115 test_cc "whether has realpath" "yes" "no" ""
2116 AC_DEFINE_UNQUOTED(CMK_HAS_REALPATH, $pass, [whether has realpath])
2117 CMK_HAS_REALPATH="$pass"
2121 CMK_CAN_GET_BINARY_PATH='1'
2122 CMK_CAN_OPEN_SHARED_OBJECTS_DYNAMICALLY='1'
2125 CMK_CAN_GET_BINARY_PATH='1'
2126 CMK_CAN_OPEN_SHARED_OBJECTS_DYNAMICALLY="$CMK_HAS_DLOPEN"
2129 if test "$CMK_HAS_READLINK" = '1' -o "$CMK_HAS_REALPATH" = '1'
2131 CMK_CAN_GET_BINARY_PATH='1'
2133 CMK_CAN_GET_BINARY_PATH='0'
2135 CMK_CAN_OPEN_SHARED_OBJECTS_DYNAMICALLY="$CMK_HAS_DLOPEN"
2139 if test "$CMK_CAN_OPEN_SHARED_OBJECTS_DYNAMICALLY" = '1' -a "$CMK_CAN_GET_BINARY_PATH" = '1'
2141 CMK_SUPPORTS_FSGLOBALS='1'
2143 CMK_SUPPORTS_FSGLOBALS='0'
2145 AC_DEFINE_UNQUOTED(CMK_SUPPORTS_FSGLOBALS, $CMK_SUPPORTS_FSGLOBALS, [whether supports filesystem globals])
2146 add_flag "CMK_SUPPORTS_FSGLOBALS=$CMK_SUPPORTS_FSGLOBALS" 'filesystem globals'
2147 add_make_flag "CMK_SUPPORTS_FSGLOBALS:=$CMK_SUPPORTS_FSGLOBALS" 'filesystem globals'
2149 if test "$CMK_HAS_DLMOPEN" = '1' -a "$CMK_CAN_GET_BINARY_PATH" = '1'
2151 CMK_SUPPORTS_PIPGLOBALS='1'
2153 CMK_SUPPORTS_PIPGLOBALS='0'
2155 AC_DEFINE_UNQUOTED(CMK_SUPPORTS_PIPGLOBALS, $CMK_SUPPORTS_PIPGLOBALS, [whether supports PiP globals])
2156 add_flag "CMK_SUPPORTS_PIPGLOBALS=$CMK_SUPPORTS_PIPGLOBALS" 'PiP globals'
2157 add_make_flag "CMK_SUPPORTS_PIPGLOBALS:=$CMK_SUPPORTS_PIPGLOBALS" 'PiP globals'
2160 ### test gethostname ####
2163 #include <Winsock2.h>
2172 char hostname[[1000]];
2173 gethostname(hostname, 999);
2177 test_cc "whether gethostname call exists" "yes" "no" ""
2178 AC_DEFINE_UNQUOTED(CMK_HAS_GETHOSTNAME, $pass, [whether gethostname() exists])
2180 #### check if getProcAddress works ####
2182 #include "ckdll_win32.C"
2184 test_cxx "whether getProcAddress works" "yes" "no" ""
2185 AC_DEFINE_UNQUOTED(CMK_DLL_USE_WIN32, $pass, [whether getProcAddress works])
2189 #### check if socklen_t exists ####
2191 #include <sys/types.h>
2192 #include <sys/socket.h>
2196 socklen_t s=sizeof(i);
2199 test_cxx "whether has socklen_t" "yes" "no" ""
2200 AC_DEFINE_UNQUOTED(CMK_HAS_SOCKLEN, $pass, [whether has socklen_t])
2202 ### test getifaddrs ####
2204 #include <netinet/in.h> /* for sockaddr_in */
2205 #include <ifaddrs.h> /* for getifaddrs */
2206 #include <net/if.h> /* for IFF_RUNNING */
2210 struct ifaddrs *interfaces=0;
2211 if( getifaddrs(&interfaces) == 0 ) {
2212 struct ifaddrs *interface;
2213 for( interface=interfaces; interface; interface=interface->ifa_next ) {
2214 if( (interface->ifa_flags & IFF_UP) && ! (interface->ifa_flags & IFF_LOOPBACK) ) {
2215 const struct sockaddr_in *addr = (const struct sockaddr_in*)interface->ifa_addr;
2216 if( addr && addr->sin_family==AF_INET ) {
2221 freeifaddrs(interfaces);
2225 test_linkc "whether getifaddrs call exists" "yes" "no" ""
2226 AC_DEFINE_UNQUOTED(CMK_HAS_GETIFADDRS, $pass, [whether getifaddrs() exists])
2228 #### check if mmap exists ####
2230 #include <sys/types.h>
2231 #include <sys/mman.h>
2233 void *foo(void *a,int l,int fd) {
2234 return mmap((caddr_t)a,l,PROT_READ+PROT_WRITE,
2235 MAP_FIXED+MAP_PRIVATE,fd,0);
2238 test_cxx "whether the mmap() syscall exists" "yes" "no" ""
2239 AC_DEFINE_UNQUOTED(CMK_HAS_MMAP, $pass, [whether the mmap() syscall exists])
2240 add_flag "CMK_HAS_MMAP=$pass"
2241 add_make_flag "CMK_HAS_MMAP:=$pass"
2243 #### check if mmap accepts MAP_ANON ####
2245 #include <sys/types.h>
2246 #include <sys/mman.h>
2248 void *foo(void *a,int l) {
2249 return mmap((caddr_t)a,l,PROT_READ+PROT_WRITE,
2250 MAP_FIXED+MAP_PRIVATE+MAP_ANON,-1,0);
2253 test_cxx "whether mmap() accepts MAP_ANON" "yes" "no" ""
2254 AC_DEFINE_UNQUOTED(CMK_HAS_MMAP_ANON, $pass, [whether mmap() accepts MAP_ANON])
2256 #### check if mmap accepts MAP_NORESERVE ####
2258 #include <sys/types.h>
2259 #include <sys/mman.h>
2261 void *foo(void *a,int l) {
2262 return mmap((caddr_t)a,l,PROT_READ+PROT_WRITE,
2263 MAP_FIXED+MAP_PRIVATE+MAP_NORESERVE,-1,0);
2266 test_cxx "whether mmap() accepts MAP_NORESERVE" "yes" "no" ""
2267 AC_DEFINE_UNQUOTED(CMK_HAS_MMAP_NORESERVE, $pass, [whether mmap() accepts MAP_NORESERVE])
2269 #### check if get_myaddress exists ####
2271 #include <rpc/rpc.h>
2274 get_myaddress((struct sockaddr_in*)a);
2277 test_cxx "whether has get_myaddress" "yes" "no" ""
2278 AC_DEFINE_UNQUOTED(CMK_HAS_GET_MYADDRESS, $pass, [whether has get_myaddress])
2280 #### check if mprotect exists ####
2283 #include <sys/mman.h>
2285 void foo(void *a,int l,int fd) {
2287 size_t pagesize = 4096;
2288 mprotect(pg, pagesize, PROT_READ | PROT_WRITE);
2291 test_cxx "whether has mprotect" "yes" "no" ""
2292 AC_DEFINE_UNQUOTED(CMK_HAS_MPROTECT, $pass, [whether has mprotect])
2294 #### check if support for SHM through CMA exists ####
2297 #include <sys/uio.h>
2301 struct iovec *local, *remote;
2302 int nread = process_vm_readv(pid, local, 1, remote, 1, 0);
2303 nread = process_vm_writev(pid, local, 1, remote, 1, 0);
2307 test_link "whether has support for shm transport using Cross Memory Attach" "yes" "no" ""
2308 AC_DEFINE_UNQUOTED(CMK_HAS_CMA, $pass, [whether supports cma])
2310 #### check if -rdynamic works ####
2317 CAN_EXPORT_SYMBOLS='0'
2318 for i in '-rdynamic' '-Wl,--export-dynamic'; do
2319 test_link "whether has $i" "yes" "no" "$i"
2320 if test "$strictpass" = '1'; then
2321 TRACE_LINK_FLAG="$i"
2322 CAN_EXPORT_SYMBOLS='1'
2327 if test "$CAN_EXPORT_SYMBOLS" = '1'; then
2328 add_flag 'CMK_LD="$CMK_LD '$TRACE_LINK_FLAG'"' "exporting program symbols to shared objects"
2329 add_flag 'CMK_LDXX="$CMK_LDXX '$TRACE_LINK_FLAG'"' "exporting program symbols to shared objects"
2332 #### check if glibc backtrace exists ####
2334 #include "cmibacktrace.C"
2339 CmiBacktraceRecord(&stack,0,&nLevels);
2343 test_link "whether glibc backtrace works" "yes" "no" "-DCMK_USE_BACKTRACE=1 $TRACE_LINK_FLAG"
2344 AC_DEFINE_UNQUOTED(CMK_USE_BACKTRACE, $pass, [whether glibc backtrace works])
2346 #### test sleep ####
2354 test_cxx "whether has sleep " "yes" "no" ""
2355 AC_DEFINE_UNQUOTED(CMK_HAS_SLEEP, $pass, [whether has sleep])
2357 #### test usleep ####
2365 test_cxx "whether has usleep " "yes" "no" ""
2366 AC_DEFINE_UNQUOTED(CMK_HAS_USLEEP, $pass, [whether has usleep])
2368 #### test personality() and ADDR_NO_RANDOMIZE ####
2369 # Only works on modern Linux systems
2371 #include <sys/personality.h>
2373 int orig_persona = personality(0xffffffff);
2374 personality(orig_persona | ADDR_NO_RANDOMIZE);
2378 test_cxx "whether personality() and ADDR_NO_RANDOMIZE exist" "yes" "no" ""
2379 AC_DEFINE_UNQUOTED(CMK_HAS_ADDR_NO_RANDOMIZE, $pass, [whether personality() and ADDR_NO_RANDOMIZE exist])
2382 # enable/disable zlib
2383 AC_ARG_ENABLE([zlib],
2384 [AS_HELP_STRING([--enable-zlib],
2385 [enable zlib support])],
2386 [enable_zlib=$enableval],
2389 #### test if has zlib ####
2390 # bproc doesnot like -lz in any case
2391 if test -z "$CMK_BPROC" && test "$enable_zlib" = "yes"
2397 gzFile f = gzopen("/tmp/x","r");
2398 gzprintf(f, "test...\n");
2403 test_link "whether has zlib" "yes" "no" "-lz"
2404 AC_DEFINE_UNQUOTED(CMK_USE_ZLIB, $pass, [whether has zlib])
2407 add_flag 'CMK_SYSLIBS="$CMK_SYSLIBS -lz"' "zlib"
2412 #### test if has elf.h ####
2415 typedef Elf32_Addr ELF_TYPE_Addr;
2419 test_cxx "whether has elf.h " "yes" "no" ""
2420 AC_DEFINE_UNQUOTED([CMK_HAS_ELF_H], $pass, [whether has elf.h])
2423 add_flag "CMK_HAS_ELF_H='1'" "elf.h"
2426 #### test if has Multiprocessing.h for apple ####
2428 #include <Carbon/Carbon.h>
2429 #include <Multiprocessing.h>
2431 int a = MPProcessorsScheduled();
2434 test_cxx "whether has Multiprocessing.h for Apple " "yes" "no" ""
2435 AC_DEFINE_UNQUOTED([CMK_HAS_MULTIPROCESSING_H], $pass, [whether has Multiprocessing.h])
2437 #### test if "ntohl" is available ####
2439 #if defined(_WIN32) || defined(__MINGW_H)
2440 #include <winsock.h>
2443 #include <arpa/inet.h>
2444 #include <netinet/in.h>
2453 test_cc "whether ntohl is available" "yes" "no" ""
2454 AC_DEFINE_UNQUOTED(CMK_HAS_NTOHL, $pass, [whether ntohl is available])
2456 ### test for libjpeg ####
2460 #include "jpeglib.h"
2464 struct jpeg_compress_struct cinfo;
2465 jpeg_create_compress(&cinfo);
2469 test_link "whether has libjpeg" "yes" "no" "-ljpeg"
2470 AC_DEFINE_UNQUOTED(CMK_USE_LIBJPEG, $pass, [whether has libjpeg])
2473 add_flag 'CMK_LIBJPEG="-ljpeg"' "libjpeg"
2474 add_make_flag 'CMK_LIBJPEG:=-ljpeg' 'libjpeg'
2477 #### check if PAPI exists ####
2478 if test -n "$CMK_USE_PAPI"
2485 if (PAPI_library_init(PAPI_VER_CURRENT) != PAPI_VER_CURRENT) return 1;
2489 test_link "whether PAPI exists" "yes" "no" "-lpapi"
2490 AC_DEFINE_UNQUOTED(CMK_HAS_COUNTER_PAPI, $pass, [whether PAPI exists])
2491 if test "$enable_tracing" = "no"
2493 echo "Error: Cannot build papi version when tracing is disabled, build with --enable-tracing"
2495 elif test $fail -eq 1
2497 echo "Error: Cannot find papi library"
2500 add_flag 'CMK_LIBS="$CMK_LIBS -lpapi"' "papi"
2504 #### test if Python headers are installed ####
2505 PYTHON_VERSION=`python -V 2>&1 | awk {'print $2'} | awk -F. {'print $1"."$2'}`
2507 #include "python${PYTHON_VERSION}/Python.h"
2508 #include "python${PYTHON_VERSION}/compile.h"
2509 #include "python${PYTHON_VERSION}/eval.h"
2510 #include "python${PYTHON_VERSION}/node.h"
2514 PyEval_InitThreads();
2515 struct _node* programNode = PyParser_SimpleParseString("return 1\n",Py_file_input);
2516 PyCodeObject *program = PyNode_Compile(programNode, "");
2519 test_link "whether Python is installed" "yes" "no" "-lpython$PYTHON_VERSION -lpthread -lutil -ldl"
2520 AC_DEFINE_UNQUOTED(CMK_HAS_PYTHON, $pass, [whether Python is installed])
2521 AC_DEFINE_UNQUOTED(CMK_PYTHON_VERSION, ${PYTHON_VERSION}, [Python version])
2524 add_flag "CMK_BUILD_PYTHON=$PYTHON_VERSION" "python"
2525 add_make_flag "CMK_BUILD_PYTHON:=$PYTHON_VERSION" 'python'
2528 ## Cray specific test
2529 if test "$CMK_BUILD_CRAY" = "1"
2531 #echo "Test for known incompatible compiler versions"
2533 if test "$CRAY_CC_VERSION" = "8.1.4"
2535 echo "CCE 8.1.4 produces incorrect Charm++ code"
2536 echo "Please use a newer version of the CCE compiler"
2537 echo "e.g. module load cce/8.1.7"
2541 #### test if Cray node topology will work ####
2547 PMI_Get_nid(0, &nid);
2552 test_linkc "whether PMI_Get_nid exists" "yes" "no" "$CMK_CRAY_LIBS"
2553 AC_DEFINE_UNQUOTED(CMK_HAS_PMI_GET_NID, $pass, [whether PMI_Get_nid exists])
2555 #### test if Cray mesh topology will work ####
2557 #include <rca_lib.h>
2560 rca_mesh_coord_t xyz;
2561 rca_get_meshcoord(0, &xyz);
2566 test_linkc "whether Cray rca library is available" "yes" "no" "$CRAY_RCA_POST_LINK_OPTS -lrca"
2567 AC_DEFINE_UNQUOTED(CMK_HAS_RCALIB, $pass, [whether Cray rca library is available])
2569 #### test if Cray mesh dimension query function will work ####
2571 #include <rca_lib.h>
2574 rca_mesh_coord_t xyz;
2575 rca_get_max_dimension(&xyz);
2580 test_linkc "whether Cray rca_has get_max_dimension" "yes" "no" "$CRAY_RCA_POST_LINK_OPTS -lrca"
2581 AC_DEFINE_UNQUOTED(CMK_HAS_RCA_MAX_DIMENSION, $pass, [whether Cray rca has rca_get_max_dimension])
2583 #### query Cray machine max NID if get_max_dimension not exist ####
2587 cmd=`which xtprocadmin 2>/dev/null`
2590 #maxnid=`xtprocadmin | tail -1 | awk '{print $1}'`
2591 # workaround for hopper
2592 (export SHELL=/bin/csh; xtprocadmin >& t.$$)
2593 maxnid=`cat t.$$ | tail -1 | awk '{print $1}'`
2595 AC_MSG_CHECKING(Cray machine maxnid)
2596 AC_MSG_RESULT("$maxnid")
2597 if test -n "$maxnid"
2599 AC_DEFINE_UNQUOTED(CMK_CRAY_MAXNID, $maxnid, [Cray MAXNID])
2607 #### query Cray machine supports BANDWIDTH_INJECTION controls####
2609 if test "$CMK_BUILD_MPI" = "1"
2611 echo "BALANCED_INJECTION test disabled on MPI"
2612 elif test "$GNI_CRAYXC" = "1"
2614 echo "BALANCED_INJECTION test disabled on Aries network"
2618 #include <gni_pub.h>
2621 gni_bi_desc_t gni_bi_desc;
2622 uint32_t gni_device_id = 0;
2623 gni_return_t gni_rc = GNI_GetBIConfig(gni_device_id, &gni_bi_desc);
2624 if (gni_rc == GNI_RC_SUCCESS) {
2629 test_linkc "whether GNI_GetBIConfig exists" "yes" "no" "$CMK_CRAY_LIBS"
2630 AC_DEFINE_UNQUOTED(CMK_BALANCED_INJECTION_API, $pass, [whether Cray gni_pub has GNI_GetBIConfig])
2631 fi # end of BIConfig test
2634 fi # end of Cray specific test
2636 #### test if it can build shared library ####
2641 void * t= malloc(2);
2646 test_linkso "whether can build shared library" "yes" "no" ""
2649 add_flag 'CMK_NO_BUILD_SHARED="true"' "build-shared"
2650 add_make_flag 'CMK_NO_BUILD_SHARED:=true' 'build-shared'
2651 CMK_NO_BUILD_SHARED='true'
2654 if test "$BUILD_MPI" = "1"
2660 int foo(int argc, char ** argv) {
2661 void * t= malloc(2);
2663 MPI_Init(&argc, &argv);
2667 test_linkso "whether can build shared library with MPI" "yes" "no" ""
2670 if test $BUILD_SHARED -eq 0
2672 add_flag 'CMK_NO_BUILD_SHARED="true"' "build-shared"
2673 add_make_flag 'CMK_NO_BUILD_SHARED:=true' 'build-shared'
2674 CMK_NO_BUILD_SHARED='true'
2678 #### test the version number of bproc ####
2679 if test -n "$CMK_BPROC"
2683 #include <sys/bproc.h>
2686 struct bproc_version_t vers;
2687 bproc_version(&vers);
2688 printf("%s\n", vers.version_string);
2691 test_link "whether bproc compiles" "yes" "no" "-lbproc"
2694 AC_MSG_CHECKING("bproc version")
2695 bproc_ver=`./testlink`
2696 if test x$bproc_ver = x
2698 test_result 0 "bproc version" "ERROR" ""
2701 test_result 0 "bproc version" "$bproc_ver" ""
2703 bproc_ver=`echo $bproc_ver | cut -d'.' -f1`
2704 AC_DEFINE_UNQUOTED(CMK_BPROC_VERSION, $bproc_ver, [bproc version])
2708 #### test the if command sync exists ####
2709 AC_CHECK_PROG(SYNC, sync, sync )
2712 AC_DEFINE_UNQUOTED(CMK_HAS_SYNC, 1, [sync program])
2715 ################## Fortran #########################
2717 #echo "set F77 compiler as: $CMK_CF77"
2718 AC_MSG_CHECKING("F77 compiler as")
2719 AC_MSG_RESULT("$CMK_CF77")
2721 AC_MSG_CHECKING("whether Fortran 77 compiler works")
2722 ### test fortran 77 compiler ###
2723 cat > conftest.f <<EOF
2727 $CMK_CF77 -c conftest.f > /dev/null 2> /dev/null
2728 if test ! -r conftest.o
2732 AC_MSG_RESULT("yes")
2735 ### test fortran 90 compiler ###
2736 #echo "set F90 compiler as: $CMK_CF90"
2737 AC_MSG_CHECKING("F90 compiler as")
2738 AC_MSG_RESULT("$CMK_CF90")
2740 AC_MSG_CHECKING("whether Fortran 90 compiler works")
2741 cat > conftest2.f90 <<EOF
2745 $CMK_CF90 -c conftest2.f90 > /dev/null 2> /dev/null
2746 if test ! -r conftest2.o
2750 AC_MSG_RESULT("yes")
2751 mv -f conftest2.o conftest.o
2755 ### check fortran name mangling
2756 AC_MSG_CHECKING(subroutine name used by Fortran 90 compiler)
2758 if test -r conftest.o
2760 AC_CACHE_VAL(_cv_fortran_postfix,
2762 NAME=`$CMK_NM conftest.o | grep "foo_foo__"`
2763 if test "$NAME" != ""
2765 _cv_fortran_postfix=TWOSCORE
2766 AC_DEFINE_UNQUOTED(CMK_FORTRAN_USES_TWOSCORE, 1, [TWOSCORE])
2768 NAME=`$CMK_NM conftest.o | grep "foo_foo_"`
2769 if test "$NAME" != ""
2771 _cv_fortran_postfix=ONESCORE
2772 AC_DEFINE_UNQUOTED(CMK_FORTRAN_USES_ONESCORE, 1, [ONESCORE])
2774 NAME=`$CMK_NM conftest.o | grep "foo_foo"`
2775 if test "$NAME" != ""
2777 _cv_fortran_postfix=NOSCORE
2778 AC_DEFINE_UNQUOTED(CMK_FORTRAN_USES_NOSCORE, 1, [NOSCORE])
2780 NAME=`$CMK_NM conftest.o | grep "FOO_FOO"`
2781 if test "$NAME" != ""
2783 _cv_fortran_postfix=ALLCAPS
2784 AC_DEFINE_UNQUOTED(CMK_FORTRAN_USES_ALLCAPS, 1, [ALLCAPS])
2786 echo "#################################################"
2787 echo "FORTRAN compiler generated name not supported yet"
2788 echo "#################################################"
2793 rm -f conftest.f conftest.o
2795 AC_MSG_RESULT($_cv_fortran_postfix)
2797 AC_MSG_RESULT("Fortran compiler not working")
2800 ### check module name ###
2802 if test "$USE_FORTRAN90" = 1
2804 cat > conftest.f90 <<EOF
2807 function fpup_issizing(p)
2809 logical fpup_issizing
2814 AC_MSG_CHECKING(Fortran 90 mod name is capital)
2815 $CMK_CF90 -c conftest.f90 > /dev/null 2> /dev/null
2816 name=`ls TESTMOD.* 2>/dev/null`
2819 AC_MSG_RESULT("yes")
2820 add_flag 'CMK_MOD_NAME_ALLCAPS=1' "mod name capital"
2823 name=`ls testmod.* 2>/dev/null`
2827 AC_MSG_CHECKING(Fortran 90 mod name extension)
2828 ext=`echo $name | sed -e 's/^[[^.]]*\.//'`
2829 add_flag 'CMK_MOD_EXT="'$ext'"' "mod name extension"
2830 AC_MSG_RESULT("$ext")
2833 /bin/rm -f conftest.f90
2836 ### test if the C++ linker succeeds with a Fortran entry point ##
2838 cat > conftest.f90 <<EOF
2842 test_link_fortran_main() {
2843 AC_MSG_CHECKING("$1")
2844 echo "### $1" >> $charmout
2845 cat conftest.f90 >> $charmout
2846 echo $CMK_CF90 -c conftest.f90 -o test.o $4 >> $charmout
2847 $CMK_CF90 -c conftest.f90 -o test.o $4 > out 2>&1
2850 test_result 1 "$1" "$2" "$3"
2852 echo $CMK_LDXX $CMK_LDXX_FLAGS $CMK_LINK_BINARY -o testlink test.o $CMK_LIBDIR $OPTS_LD $CMK_SYSLIBS $CMK_F90LIBS $CMK_F90MAINLIBS $4 $5 >> $charmout
2853 $CMK_LDXX $CMK_LDXX_FLAGS $CMK_LINK_BINARY -o testlink test.o $CMK_LIBDIR $OPTS_LD $CMK_SYSLIBS $CMK_F90LIBS $CMK_F90MAINLIBS $4 $5 >> out 2>&1
2855 test ! -x testlink && ret=1
2856 test_result $ret "$1" "$2" "$3"
2858 cat out >> $charmout
2860 test_link_fortran_main "whether the C++ linker succeeds with a Fortran entry point" "yes" "no" ""
2861 /bin/rm -f conftest.f90 test.o testlink out
2864 add_flag "CMK_CAN_LINK_FORTRAN='1'" "Fortran"
2867 ### check for OpenMP availability ###
2874 int iam = 0, np = 1;
2876 #pragma omp parallel default(shared) private(iam, np)
2878 np = omp_get_num_threads();
2879 iam = omp_get_thread_num();
2880 printf("Hello from thread %d of %d\n", iam, np);
2886 test_linkc "whether OpenMP is supported" "yes" "no" "$CMK_C_OPENMP"
2889 add_flag "CMK_HAS_OPENMP='1'" "OpenMP"
2892 ### check for Lustre FS availability ###
2895 #include <lustre/lustreapi.h>
2896 #include <lustre/lustre_user.h>
2899 llapi_printf(LLAPI_MSG_NORMAL, "Lustre FS is available");
2903 test_linkc "whether has lustre fs" "yes" "no" "-llustreapi"
2904 AC_DEFINE_UNQUOTED(CMK_HAS_LUSTREFS, $pass, [whether has lustrefs])
2907 add_make_flag 'CMK_LUSTREAPI:=-llustreapi' "lustreapi"
2909 add_make_flag 'CMK_LUSTREAPI:=' "lustreapi"
2914 eval "`./charmc -print-building-blocks $OPTS`"
2915 export CC="$(get_full_command_name "$CMK_SEQ_CC")"
2916 export CXX="$(get_full_command_name "$CMK_SEQ_CXX")"
2917 export CC_FOR_BUILD="$(get_full_command_name "$CMK_NATIVE_CC")"
2918 AC_SUBST(CC_FOR_BUILD)
2919 export HWLOC_FLAGS="$CHARM_CC_FLAGS"
2920 export CFLAGS="$CMK_SEQ_CC_FLAGS"
2921 export AR="$(get_full_command_name "${CMK_SEQ_AR%% *}")"
2922 enable_embedded_mode='yes'
2924 if test "$CMK_NO_BUILD_SHARED" = 'false'
2927 export am_libhwloc_embedded_la_rpath="-rpath $CHARMLIBSO"
2930 export am_libhwloc_embedded_la_rpath=''
2932 AC_SUBST(am_libhwloc_embedded_la_rpath)
2937 enable_visibility='no'
2941 export libhwloc_so_version
2942 AC_SUBST(libhwloc_so_version)
2944 echo "Configuring hwloc:"
2945 AC_CONFIG_AUX_DIR(hwloc/config)
2947 AC_USE_SYSTEM_EXTENSIONS
2950 AM_INIT_AUTOMAKE([no-define])
2952 AC_CONFIG_MACRO_DIR(hwloc/config)
2953 HWLOC_SET_SYMBOL_PREFIX([cmi_])
2954 HWLOC_SETUP_CORE([hwloc], [happy=yes], [happy=no])
2955 HWLOC_DO_AM_CONDITIONALS
2956 add_flag 'CMK_HWLOC_LIBS="-lhwloc_embedded '"$HWLOC_EMBEDDED_LIBS"'"' "hwloc"