Commit 4031e894 authored by Hans-Nikolai Viessmann's avatar Hans-Nikolai Viessmann
Browse files

Merge branch 'artem-remove-old-buildsystem' into 'develop'

Artem remove old buildsystem

Closes #1212

See merge request !45
Showing with 36 additions and 11564 deletions
+36 -11564
###############################################################################
#
# Calling conventions:
#
# Start rules:
# default compile executables as developer code and libraries as product
# code
# devel compile everything as developer code
# prod compile everything as product code
#
# clean cleanup all derived files
# cleandevel cleanup only developer compiled files
# cleanprod cleanup only product compiled files
#
# tidy cleanup all derived files excluding make tools
# tidydevel cleanup only developer compiled files excluding make tools
# tidyprod cleanup only product compiled files excluding make tools
#
# refactor refactor source code (requires parameters below)
#
# config rebuild autoconf-gnerated scripts, e.g. configure,
# src/include/config.h.in, etc.
#
# install install sac2c under the $PREFIX directory. Please note
# that $PREFIX can be set when you run ./configure via
# ./configure --prefix=/path/to/some/location
# Also, make sure that your $PREFIX/bin is on the PATH.
#
# uninstall Remove the files created by the install target. Please
# note that it does not remove a directory structure, only
# the files.
#
# Parameters:
# DEPS="no" de-activate dependency checking meachanism
# HIDE="" show important commands issued by make (debugging)
#
# Refactor parameters:
# PATTERN="" pattern to look for in all source files
# OUTPUT="" text to replace matched pattern
#
###############################################################################
# This Makefile is a wrapper around cmake that allows to quickly
# make default build and install of product and development versions
# of the compiler.
BUILD_DIR_DEBUG := build_d
BUILD_DIR_RELEASE := build_r
MAKE_NUMTHREADS ?= 4
###############################################################################
#
# general setup:
#
define BUILD =
if [ -d $(1) ]; then \
cd $(1); make -j$(MAKE_NUMTHREADS); cd -; \
else \
mkdir -p $(1); \
cd $(1); \
cmake -DCMAKE_BUILD_TYPE=$(2) ..; \
$(MAKE) -j$(MAKE_NUMTHREADS); \
cd -; \
fi
endef
PROJECT_ROOT := .
HIDE := @
DEPS := yes
CLEAN_MAKE_TOOLS := "yes"
all: release debug
MAKEFILE_DIR := $(PROJECT_ROOT)/src/makefiles
release:
$(call BUILD,$(BUILD_DIR_RELEASE),RELEASE)
-include $(MAKEFILE_DIR)/config.mkf # config.mkf may not yet exist
include $(MAKEFILE_DIR)/settings.mkf
debug:
$(call BUILD,$(BUILD_DIR_DEBUG),DEBUG)
# A function that outputs an argument surrounded by the box of stars.
# Like this:
# ********
# * arg
# ********
# The first and second line are expansions of $(frame_stars) variable.
frame_stars := "************************************************************"
framed_text = @$(ECHO) -e "$(frame_stars)\n* $(1)\n$(frame_stars)"
clean: clean-release clean-debug
clean-release:
$(RM) -rf $(BUILD_DIR_RELEASE)
###############################################################################
#
# Dummy rules
#
clean-debug:
$(RM) -rf $(BUILD_DIR_DEBUG)
.PHONY: default devel prod clean cleandevel cleanprod config \
tidy tidydevel tidyprod
install: install-debug install-release
install-release: release
cd $(BUILD_DIR_RELEASE); make install; cd -
@echo "Please run $(BUILD_DIR_RELEASE)/scripts/sac2c-version-manager " \
"now to set symlinks correctly."
###############################################################################
#
# Start rules
#
# The definition of these rules deliberately enforces a sequence in compilation
# rather than expressing the dependencies properly by makefile rules.
#
# The rationale is that commonlib and maketools rather seldomly require
# recompilation. With proper dependencies, however, they would require a
# dependency from every compilation rule. This would lead to extensive
# rechecking at compile time that is absolutely superfluous.
#
# The runtime system may require the compiler and, likewise, the tools may
# need the runtime system or parts thereof. Expressing all this by dependencies
# would lead to a system in which the tools form the main target. This seems
# unnatural.
#
# Furthermore, the current solution allows us to rebuild locally without
# enforcing dependency checks.
#
install-debug: debug
cd $(BUILD_DIR_DEBUG); make install; cd -
@echo "Please run $(BUILD_DIR_DEBUG)/scripts/sac2c-version-manager " \
"now to set symlinks correctly."
default devel prod: checks
$(call framed_text,Building $(PROJECT_NAME))
$(HIDE) $(MAKE) -C src/maketools DEPS="$(DEPS)" HIDE="$(HIDE)" \
PREFIX_LOCAL="src/maketools/" PREFIX_ROOT="" $@
$(HIDE) $(MAKE) -C src/libsac2c DEPS="$(DEPS)" HIDE="$(HIDE)" \
PREFIX_LOCAL="src/libsac2c/" PREFIX_ROOT="" $@
$(HIDE) $(MAKE) -C src/runtime DEPS="$(DEPS)" HIDE="$(HIDE)" \
PREFIX_LOCAL="src/runtime/" PREFIX_ROOT="" $@
$(HIDE) $(MAKE) -C src/tools DEPS="$(DEPS)" HIDE="$(HIDE)" \
PREFIX_LOCAL="src/tools/" PREFIX_ROOT="" $@
$(HIDE) for t in $(BUILD_TARGETS); do \
$(MAKE) -f $(MAKEFILE_DIR)/rtlibs.mkf HIDE="$(HIDE)" TARGET=$$t all || exit 1; \
done
$(call framed_text,Building $(PROJECT_NAME) completed)
###############################################################################
#
# Cleaning rules
#
clean cleandevel cleanprod: checks
$(call framed_text,Cleaning $(PROJECT_NAME))
$(HIDE) if [ "$(CLEAN_MAKE_TOOLS)" = "yes" ]; then \
$(MAKE) -C src/maketools DEPS="$(DEPS)" HIDE="$(HIDE)" \
PREFIX_LOCAL="src/maketools/" PREFIX_ROOT="" $@ ; \
fi
$(HIDE) $(MAKE) -C src/libsac2c DEPS="$(DEPS)" HIDE="$(HIDE)" \
PREFIX_LOCAL="src/libsac2c/" PREFIX_ROOT="" $@
$(HIDE) $(MAKE) -C src/runtime DEPS="$(DEPS)" HIDE="$(HIDE)" \
PREFIX_LOCAL="src/runtime/" PREFIX_ROOT="" $@
$(HIDE) $(MAKE) -C src/tools DEPS="$(DEPS)" HIDE="$(HIDE)" \
PREFIX_LOCAL="src/tools/" PREFIX_ROOT="" $@
$(HIDE) for t in $(BUILD_TARGETS); do \
$(MAKE) -f $(MAKEFILE_DIR)/rtlibs.mkf HIDE="$(HIDE)" TARGET=$$t clean || exit 1; \
done
$(HIDE) $(RM) -rf lib/* bin/*
$(call framed_text,Cleaning $(PROJECT_NAME) completed)
tidy:
$(MAKE) CLEAN_MAKE_TOOLS="no" clean
tidydevel:
$(MAKE) CLEAN_MAKE_TOOLS="no" cleandevel
tidyprod:
$(MAKE) CLEAN_MAKE_TOOLS="no" cleanprod
###############################################################################
#
# Refactoring rules
#
refactor: checks
$(call framed_text,Refactoring $(PROJECT_NAME))
$(HIDE) $(MAKE) -C src/maketools DEPS="$(DEPS)" HIDE="$(HIDE)" \
PREFIX_LOCAL="src/maketools/" PREFIX_ROOT="" $@
$(HIDE) $(MAKE) -C src/libsac2c DEPS="$(DEPS)" HIDE="$(HIDE)" \
PREFIX_LOCAL="src/libsac2c/" PREFIX_ROOT="" $@
$(HIDE) $(MAKE) -C src/runtime DEPS="$(DEPS)" HIDE="$(HIDE)" \
PREFIX_LOCAL="src/runtime/" PREFIX_ROOT="" $@
$(HIDE) $(MAKE) -C src/tools DEPS="$(DEPS)" HIDE="$(HIDE)" \
PREFIX_LOCAL="src/tools/" PREFIX_ROOT="" $@
$(call framed_text,Refactoring $(PROJECT_NAME) completed)
###############################################################################
#
# Rules for making selected subprojects in default mode
#
maketools: checks
$(HIDE) $(MAKE) -C src/maketools DEPS="$(DEPS)" HIDE="$(HIDE)" \
PREFIX_LOCAL="src/maketools/" PREFIX_ROOT="" default
libsac2c: checks
$(HIDE) $(MAKE) -C src/libsac2c DEPS="$(DEPS)" HIDE="$(HIDE)" \
PREFIX_LOCAL="src/libsac2c/" PREFIX_ROOT="" default
runtime: checks
$(HIDE) $(MAKE) -C src/runtime DEPS="$(DEPS)" HIDE="$(HIDE)" \
PREFIX_LOCAL="src/runtime/" PREFIX_ROOT="" default
tools: checks
$(HIDE) $(MAKE) -C src/tools DEPS="$(DEPS)" HIDE="$(HIDE)" \
LIBS="$(LIBS)" POLYLIBINCLUDE="$(POLYLIBINCLUDE)" \
PREFIX_LOCAL="src/tools/" PREFIX_ROOT="" default
rtlibs: checks
$(HIDE) for t in $(BUILD_TARGETS); do \
$(MAKE) -f $(MAKEFILE_DIR)/rtlibs.mkf HIDE="$(HIDE)" TARGET=$$t || exit 1; \
done
###############################################################################
#
# Rules to create configure the script. Put it here as a first target.
#
config:
autoreconf -v -f -i -I setup/config
###############################################################################
#
# Includes for consistency checking mechanism
#
include $(MAKEFILE_DIR)/check.mkf
install: checks-install
$(INSTALL) -d "$(INCPATH_CONF)"
$(INSTALL) -d "$(SAC2CRC_DIR)"
$(INSTALL) -d "$(bindir)"
$(INSTALL) -d $(DLL_DIR)
$(RM) .uninstall
for i in include/*.h; do \
dst="$(INCPATH_CONF)"/`basename $$i`; \
$(ECHO) "$$dst" >>.uninstall; \
$(INSTALL_DATA) $$i "$$dst"; \
done
$(ECHO) "$(SAC2CRC_CONF)" >>.uninstall
$(INSTALL_DATA) setup/sac2crc "$(SAC2CRC_CONF)"
for i in bin/*; do \
dst1="$(DLL_DIR)"/`basename $$i`; \
$(ECHO) "$$dst1" >>.uninstall; \
$(INSTALL_PROGRAM) $$i "$$dst1"; \
dst2="$(bindir)"/`basename $$i`; \
$(ECHO) "$$dst2" >>.uninstall; \
$(RM) "$$dst2"; $(LN) "$$dst1" "$$dst2"; \
done
for i in lib/*.*; do \
dst="$(DLL_DIR)"/`basename $$i`; \
$(ECHO) "$$dst" >>.uninstall; \
$(INSTALL_PROGRAM) $$i "$$dst"; \
done
for t in $(BUILD_TARGETS); do \
$(MAKE) -f $(MAKEFILE_DIR)/rtlibs.mkf HIDE="$(HIDE)" TARGET=$$t install; \
done
uninstall:
if test -r .uninstall; then \
cat .uninstall | while read f; do $(RM) "$$f"; done; \
fi
This diff is collapsed.
### Configuration
### DO NOT use autoconf for this script. Instead, do:
### "make config"
dnl Old versions of Autoconf appear to fail
AC_PREREQ([2.63])
dnl tell configure who we are
dnl parameters: package name, version, where to send bugreports
AC_INIT([sac2c], [git], [info@sac-home.org])
dnl set source directory and scripting directory
AC_CONFIG_SRCDIR([setup])
AC_CONFIG_AUX_DIR([setup/config])
dnl ensure the directories are absolute since they will
dnl be used from Makefiles in sub-directories.
srcdir=$(cd "$srcdir" && pwd)
ac_aux_dir=$(cd "$ac_aux_dir" && pwd)
if test -r "$ac_aux_dir/install-sh"; then
ac_install_sh="$ac_aux_dir/install-sh -c"
elif test -r "$ac_aux_dir/install.sh"; then
ac_install_sh="$ac_aux_dir/install.sh -c"
elif test -r "$ac_aux_dir/shtool"; then
ac_install_sh="$ac_aux_dir/shtool install -c"
fi
dnl where to find the SAC standard library sources
CHECK_STDLIB([src/modules/structures/ArrayBasics.xsac])
dnl we use C as our compiler language
AC_LANG(C)
dnl and which files to create -
dnl * variable `_config files' contains the list of files relevent to the
dnl sac2c build system.
dnl * variable `_rc_files' contains the list of files that are used to
dnl generate the sac2crc.pre file - variables created by this script are
dnl substituted into these files, and are later combined into sac2crc.pre.
dnl NOTE: the order of the files in the list is the order that autotools
dnl uses to generate the files, thus sac2crc.pre needs to appear
dnl toward the end of the list.
_config_files="src/makefiles/config.mkf src/tools/saccc"
_rc_files="setup/sac2crc.backend.mutc setup/sac2crc.backend.cuda \
setup/sac2crc.modifiers.cc setup/sac2crc.modifiers.malloc \
setup/sac2crc.modifiers.rcm setup/sac2crc.SUN setup/sac2crc.X86 \
setup/sac2crc.ALPHA setup/sac2crc.MAC setup/sac2crc.pre \
setup/sac2crc.local"
AC_CONFIG_FILES([$_config_files $_rc_files])
AC_CONFIG_HEADER([src/include/config.h])
dnl check for host type
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
dnl if cygwin set IS_CYGWIN
is_cygwin=0
case "$target_os" in
*cygwin*) is_cygwin=1 ;;
esac
AC_DEFINE_UNQUOTED([IS_CYGWIN], [$is_cygwin],
[Set to 1 if target is Cygwin, otherwise 0.])
dnl set OS and ARCH flags
AC_DEFINE_UNQUOTED([OS], ["$target_os"], [OS string])
AC_DEFINE_UNQUOTED([ARCH], ["$target_cpu"], [CPU architecture string])
dnl Enable sac2c compilation with C++
AC_ARG_ENABLE([cplusplus],
[AS_HELP_STRING([[--enable-cplusplus]],
[Use the C++ compiler to compile files produced by sac2c])],
[enable_cplusplus=$enableval],
[enable_cplusplus=no])
dnl Check if C compiler and preprocessor are available
dnl we force CFLAGS to be empty, so that it does not default to -g -O2
CFLAGS=" "
AC_PROG_CC_C99
AC_PROG_CPP
dnl Enable system extensions when they are disabled by default
AC_USE_SYSTEM_EXTENSIONS
dnl Find out if we are using GCC/SunC/DECC/"Mac C"
CHECK_COMPILER_VENDOR
dnl Try to enable link time optimizations (LTO)
CHECK_LTO
dnl Check if C compiler supports SIMD syntax
CHECK_SIMD_SYNTAX
dnl Prints the value of a makefile variable.
getmakevar() {
makefile="$1"
var="$2"
make getmakevar -f - <<EOI
include $makefile
getmakevar:
@echo \$($var)
EOI
}
dnl Check for SAC back-ends (CHECK_LPEL must appear after CHECK_MT)
CHECK_MT
CHECK_LPEL
CHECK_CUDA
CHECK_SL
CHECK_OMP
dnl enable private heap manager?
CHECK_PHM
CHECK_DISTMEM
dnl check for ranlib
AC_PROG_RANLIB
dnl check for some standard tools
AC_PROG_LN_S
AC_PROG_SED
AC_PROG_FGREP
AC_PROG_INSTALL
AC_PROG_MKDIR_P
dnl find a code beautifier.
CHECK_CODE_BEAUTIFIER
dnl search/check various utilities
CHECK_REQUIRED_TOOL([SORT], [sort])
CHECK_REQUIRED_TOOL([UNIQ], [uniq])
CHECK_REQUIRED_TOOL([M4], [gm4 m4])
CHECK_REQUIRED_TOOL([XSLT], [xsltproc sabcmd])
CHECK_REQUIRED_TOOL([BASH], [bash])
dnl search for dot
CHECK_GRAPHVIZ
dnl check for various environment features
CHECK_PTR_PREFIX
CHECK_CONST_STDERR
AC_CHECK_HEADERS([malloc.h])
AC_CHECK_FUNCS([mkdtemp])
AC_SEARCH_LIBS([sqrt], [m])
AC_CHECK_FUNCS([strtok strrchr])
CHECK_HR_CLOCK
dnl check support for dynamic libraries
AC_CHECK_HEADER([dlfcn.h], [], [AC_MSG_ERROR([dlfcn.h is required.])])
AC_SEARCH_LIBS([dlopen], [dl])
CHECK_DLL_EXT
enable_uuid=no
AC_SEARCH_LIBS([uuid_generate], [uuid], [enable_uuid=yes], [enable_uuid=no])
AC_CHECK_HEADER([uuid/uuid.h], [enable_uuid=yes], [enable_uuid=no])
have_uuid=`if test $enable_uuid = yes; then echo 1; else echo 0; fi`
AC_DEFINE_UNQUOTED([ENABLE_UUID], [$have_uuid],
[Define to 1 if libuuid is available, otherwise 0.])
AC_SUBST([ENABLE_UUID], [$enable_uuid])
enable_crypt=no
AC_SEARCH_LIBS([crypt], [crypt], [enable_crypt=yes], [enable_crypt=no])
AC_CHECK_HEADER([crypt.h], [enable_crypt=yes], [enable_crypt=no])
have_crypt=`if test $enable_crypt = yes; then echo 1; else echo 0; fi`
AC_DEFINE_UNQUOTED([ENABLE_HASH], [$have_crypt],
[Define to 1 if libcrypt is available, otherwise 0.])
AC_SUBST([ENABLE_HASH], [$enable_crypt])
dnl set rtspec flag
enable_rtspec=no
if test x"$ac_cv_search_dlopen" != xno -a x"$enable_mt" = xyes ; then
if test x"$enable_uuid" != xno -o x"$enable_crypt" != xno ; then
enable_rtspec=yes
fi
fi
AC_CHECK_LIB(polylib64,DomainIntersection)
AC_CHECK_LIB(m, log10, AC_SUBST([LIB_M], ["-Xl -lm"]))
AC_SUBST(POLYLIBINCLUDE,["/usr/include/polylib -I/usr/local/include/polylib"])
CHECK_ISL
dnl canonicalize dlopen_libs
case $ac_cv_search_dlopen in
no | none*) dlopen_libs= ;;
* ) dlopen_libs=$ac_cv_search_dlopen ;;
esac
have_rtspec=`if test $enable_rtspec = yes; then echo 1; else echo 0; fi`
AC_DEFINE_UNQUOTED([ENABLE_RTSPEC], [$have_rtspec],
[Define to 1 if runtime specialization is enabled, otherwise 0.])
AC_SUBST([ENABLE_RTSPEC], [$enable_rtspec])
dnl Check which GCC warning options are available and
dnl add them later to MKCCFLAGS and PDCCFLAGS
gcc_options=
if test "$GCC" = yes ; then
CHECK_CC_OPTION([-Wall], [gcc_options])
CHECK_CC_OPTION([-Wextra], [gcc_options])
CHECK_CC_OPTION([-Wstrict-prototypes], [gcc_options])
CHECK_CC_OPTION([-Wno-unused-parameter], [gcc_options])
CHECK_CC_OPTION([-Wno-unused-but-set-variable], [gcc_options])
fi
gcc_native=
if test "$GCC" = yes ; then
CHECK_CC_OPTION([-march=native], [gcc_native])
CHECK_CC_OPTION([-mtune=native], [gcc_native])
fi
dnl Check if the C compiler support large bracket depths
dnl this also updates gcc_options as needed.
CHECK_CC_BRACKETS
dnl
dnl test for compiler flags for sac2crc
dnl
dnl test for compiler flags for sac2crc
AC_MSG_CHECKING([sac2crc compiler flags])
if [ test "$GCC" = yes ]; then
AC_SUBST(OPT_O0, [""])
AC_SUBST(OPT_O1, [-O1])
AC_SUBST(OPT_O2, [-O2])
AC_SUBST(OPT_O3, [-O3])
AC_SUBST(OPT_g, [-g])
AC_SUBST(RCCCFLAGS, ["$gcc_options $gcc_native -pedantic -Wall -Wno-unused -fno-builtin $flags_lto"])
AC_SUBST(MKCCFLAGS, ["$gcc_options $gcc_native -pedantic -g $flags_lto"])
AC_SUBST(PDCCFLAGS, ["$gcc_options $gcc_native -pedantic -g -O3 $flags_lto"])
if [ test "$IS_CYGWIN" = yes ]; then
AC_SUBST(GENPIC, ["-DPIC"])
else
AC_SUBST(GENPIC, ["-fPIC -DPIC"])
fi
AC_SUBST(DEPSFLAG, ["-M"])
AC_SUBST(CPPFILE, ["$CPP -C -x c"])
AC_SUBST(CPP, ["$CPP -P -x c"])
AC_MSG_RESULT([gcc settings])
elif [ test "$SUNC" = yes ]; then
AC_SUBST(OPT_O0, [""])
AC_SUBST(OPT_O1, [-xO2])
AC_SUBST(OPT_O2, [-xO4])
AC_SUBST(OPT_O3, [-xO5])
AC_SUBST(OPT_g, [-g])
AC_SUBST(RCCCFLAGS, ["-dalign -fsimple -xsafe=mem"])
AC_SUBST(MKCCFLAGS, ["-erroff=E_CAST_DOESNT_YIELD_LVALUE -g"])
AC_SUBST(PDCCFLAGS, ["-erroff=E_CAST_DOESNT_YIELD_LVALUE -g -xO4 -KPIC"])
AC_SUBST(GENPIC, ["-KPIC"])
AC_SUBST(DEPSFLAG, ["-xM"])
AC_SUBST(CPPFILE, ["$CPP -C -x c"])
AC_SUBST(CPP, ["$CPP -P -x c"])
AC_MSG_RESULT([Sun cc settings])
elif [ test "$DECC" = yes ]; then
AC_SUBST(OPT_O0, [""])
AC_SUBST(OPT_O1, [-O1])
AC_SUBST(OPT_O2, [-O2])
AC_SUBST(OPT_O3, [-O3])
AC_SUBST(OPT_g, [-g])
AC_SUBST(RCCCFLAGS, [""])
AC_SUBST(MKCCFLAGS, ["-g"])
AC_SUBST(PDCCFLAGS, ["-g3"])
AC_SUBST(GENPIC, [""])
AC_SUBST(DEPSFLAG, ["-M"])
AC_SUBST(CPPFILE, ["$CPP -C -x c"])
AC_SUBST(CPP, ["$CPP -P -x c"])
AC_MSG_RESULT([Compaq/DEC cc settings])
elif [ test "$MACC" = yes ]; then
AC_SUBST(OPT_O0, [""])
AC_SUBST(OPT_O1, [-O1])
AC_SUBST(OPT_O2, [-O2])
AC_SUBST(OPT_O3, [-O3])
AC_SUBST(OPT_g, [-g])
AC_SUBST(RCCCFLAGS, ["-Wall -Wno-unused -fno-builtin"])
AC_SUBST(MKCCFLAGS, ["-Wall -g"])
AC_SUBST(PDCCFLAGS, [""])
AC_SUBST(GENPIC, [""])
AC_SUBST(DEPSFLAG, ["-M"])
AC_SUBST(CPPFILE, ["$CPP -C -x c"])
AC_SUBST(CPP, ["$CPP -P -x c"])
AC_MSG_RESULT([Apple cc settings])
else
AC_SUBST(OPT_O0, [""])
AC_SUBST(OPT_O1, [""])
AC_SUBST(OPT_O2, [""])
AC_SUBST(OPT_O3, [""])
AC_SUBST(OPT_g, [""])
AC_SUBST(RCCCFLAGS, [""])
AC_SUBST(MKCCFLAGS, [""])
AC_SUBST(PDCCFLAGS, [""])
AC_SUBST(GENPIC, [""])
AC_SUBST(DEPSFLAG, ["-M"])
AC_SUBST(CPPFILE, ["$CPP -C"])
AC_SUBST(CPP, ["$CPP -P"])
AC_MSG_RESULT([none found])
fi
AC_SUBST(CCMT_PTH_LINK, ["$PTHREAD_LIBS"])
AC_SUBST(CCMT_PTH_CFLAGS, ["$PTHREAD_CFLAGS"])
AC_SUBST(CCDLLINK, ["$dlopen_libs $flags_lto"])
dnl This is a special case for building sac2c with c++ compiler.
if [[ "$GXX" = yes -a "$enable_cplusplus" = yes ]]; then
AC_SUBST(SAC2C_CC, ["g++"])
AC_SUBST(OPT_O0, [""])
AC_SUBST(OPT_O1, [-O1])
AC_SUBST(OPT_O2, [-O2])
AC_SUBST(OPT_O3, [-O3])
AC_SUBST(OPT_g, [-g])
AC_SUBST(RCCCFLAGS, ["-Wall -Wno-unused -fno-builtin"])
AC_SUBST(SAC2C_MKCCFLAGS, ["-Wno-write-strings -g"])
AC_SUBST(SAC2C_PDCCFLAGS, ["-Wno-write-strings -g -O3"])
AC_SUBST(GENPIC, ["-fPIC -DPIC"])
AC_SUBST(DEPSFLAG, ["-M"])
AC_SUBST(CPPFILE, ["$CPP -C -x c"])
AC_SUBST(CPP, ["$CPP -P -x c"])
AC_MSG_RESULT([gcc settings])
else
AC_SUBST(SAC2C_CC, ["$CC"])
AC_SUBST(SAC2C_MKCCFLAGS, ["$MKCCFLAGS"])
AC_SUBST(SAC2C_PDCCFLAGS, ["$PDCCFLAGS"])
fi
dnl
dnl append platform specific files to sac2crc
dnl
AC_SUBST_FILE([RCMUTC])
AC_SUBST_FILE([RCCUDA])
AC_SUBST_FILE([RCCC])
AC_SUBST_FILE([RCMALLOC])
AC_SUBST_FILE([RCRCM])
AC_SUBST_FILE([RCSUN])
AC_SUBST_FILE([RCX86])
AC_SUBST_FILE([RCALPHA])
AC_SUBST_FILE([RCMAC])
RCMUTC=setup/sac2crc.backend.mutc
RCCUDA=setup/sac2crc.backend.cuda
RCCC=setup/sac2crc.modifiers.cc
RCMALLOC=setup/sac2crc.modifiers.malloc
RCRCM=setup/sac2crc.modifiers.rcm
RCSUN=setup/sac2crc.SUN
RCX86=setup/sac2crc.X86
RCALPHA=setup/sac2crc.ALPHA
RCMAC=setup/sac2crc.MAC
dnl
dnl Append GASNet conduit targets file to sac2crc.
dnl
AC_SUBST_FILE([GASNET_CONDUIT_TARGETS])
GASNET_CONDUIT_TARGETS=./sac2crc.GASNetconduits
dnl
dnl Append GASNet conduit settings file to config.mkf.
dnl
AC_SUBST_FILE([GASNET_CONDUIT_SETTINGS])
GASNET_CONDUIT_SETTINGS=./config.GASNetconduits
dnl
dnl Append rules for building libsacdistmem GASNet object files to build.mkf
dnl
AC_SUBST_FILE([GASNET_CONDUIT_BUILD_OBJECT_FILES])
GASNET_CONDUIT_BUILD_OBJECT_FILES=./build.GASNetconduits
dnl
dnl Append rules for building libsacdistmem GASNet cross variant object files to build.mkf
dnl
AC_SUBST_FILE([GASNET_CONDUIT_BUILD_OBJECT_FILES_CROSS_VARIANT])
GASNET_CONDUIT_BUILD_OBJECT_FILES_CROSS_VARIANT=./build.GASNetconduitsCrossVariant
# generate specific flags for known os
AC_MSG_CHECKING([sac2crc system flags])
OSFLAGS=""
case "$target_os" in
solaris*)
OSFLAGS=["-D__EXTENSIONS__ -D_XPG6 -DMUST_INIT_YY -DPIC"]
LD_DYNAMIC=["-G -dy"]
LD_PATH=["-L%path% -R%path%"]
LD_FLAGS="-Wl,-z,nodefs,-z,lazyload"
AC_MSG_RESULT([solaris settings])
;;
*linux*)
OSFLAGS=["-fPIC -DPIC -D_POSIX_SOURCE -D_DEFAULT_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE"]
LD_DYNAMIC=["-shared -Wl,-allow-shlib-undefined -O3 $flags_lto"]
LD_PATH=["-L%path% -Wl,-rpath,%path%"]
LD_FLAGS="-Wl,-allow-shlib-undefined $flags_lto"
AC_MSG_RESULT([linux settings])
;;
*cygwin* | *mingw*)
OSFLAGS=["-D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE"]
LD_DYNAMIC=["-dy -shared"]
LD_PATH=["-L%path% -Wl,-rpath,%path%"]
LD_FLAGS=""
AC_MSG_RESULT([cygwin settings])
;;
*osf*)
OSFLAGS=["-D_OSF_SOURCE"]
LD_DYNAMIC=[""]
LD_PATH=["-L%path%"]
LD_FLAGS=""
AC_MSG_RESULT([OSF settings])
;;
*darwin*)
dnl darwin needs some extra flags
RANLIB="$RANLIB -c"
OSFLAGS=["-D_DARWIN_C_SOURCE"]
LD_DYNAMIC=["-undefined suppress -flat_namespace -dynamiclib -install_name '@rpath/%libname%.dylib' "]
LD_PATH=["-L%path% -Wl,-rpath,%path%"]
LD_FLAGS=""
AC_MSG_RESULT([darwin settings])
;;
*bsd*)
OSFLAGS=["-fPIC -DPIC"]
LD_DYNAMIC=["-shared -Wl,-allow-shlib-undefined $flags_lto"]
LD_PATH=["-L%path% -Wl,-rpath,%path%"]
LD_FLAGS=["$flags_lto"]
AC_MSG_RESULT([BSD settings])
;;
*)
OSFLAGS=["-fPIC -DPIC -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE"]
LD_DYNAMIC=["-dy -shared -Wl,-allow-shlib-undefined"]
LD_PATH=["-L%path% -Wl,-rpath,%path%"]
LD_FLAGS="-Wl,-allow-shlib-undefined"
AC_MSG_RESULT([unknown])
;;
esac
AC_SUBST([OS], [$target_os])
AC_SUBST([OSFLAGS])
AC_SUBST([CFLAGS])
AC_SUBST([CPPFLAGS])
AC_SUBST([LDFLAGS])
AC_SUBST([LD_DYNAMIC])
AC_SUBST([LD_PATH])
AC_SUBST([LD_FLAGS])
dnl
dnl static sac2c settings for config.h
dnl
AC_DEFINE([PF_MAXFUN], [100], [set to maximum number of sac functions for profiling])
AC_DEFINE([PF_MAXFUNAP], [100],
[set to maximum number of sac function applications for profiling])
AC_DEFINE([PF_MAXFUNNAMELEN], [100],
[set to maximum length of sac function names for profiling])
AC_DEFINE([SAC_PRELUDE_NAME], ["sacprelude"], [Name of the sac prelude module.])
AC_DEFINE( UNUSED, __attribute__((unused)), define macro for unused variables)
if test x"$enable_distmem_gasnet" = xyes; then
gasnet_conduit_names_print=" (conduits: $gasnet_conduits)"
else
gasnet_conduit_names_print=""
fi
if test x"$enable_distmem" = xyes; then
distmem_details_print=" (experimental)
* - GASNet: $enable_distmem_gasnet$gasnet_conduit_names_print
* - GPI: $enable_distmem_gpi
* - MPI: $enable_distmem_mpi
* - ARMCI: $enable_distmem_armci"
else
distmem_details_print=""
fi
AC_OUTPUT
cat <<EOF
* Configuration done.
*
* Detected OS string: $target_os
* Detected CPU string: $target_cpu
*
* Run-time specialization: $enable_rtspec
* Private heap manager: $enable_phm
* Back-ends:
* - MT/pthread: $enable_mt
* - MT/LPEL: $enable_mt_lpel
* - CUDA: $enable_cuda
* - OpenMP: $enable_omp
* - SL: $enable_sl
* - Distributed memory: $enable_distmem$distmem_details_print
* - CC: $CC
* - SaC compiler CFLAGS: $MKCCFLAGS
* - SaC programs CFLAGS: $RCCCFLAGS
*
* Optional packages:
* - Integer Set Library (ISL): $enable_isl
*
EOF
#
# Makefile for generating SAC distributions
#
#
# Settings for version control
#
VERSION = 0_91
#
# Settings for file and package sets
#
SYSTEMS = SOLARIS_SPARC-2_5 SOLARIS_SPARC-2_7 LINUX_X86 OSF_ALPHA OSX_MAC
INST_PACKAGES = runtime.tar stdlib.tar demo.tar
INST_FILES = install_sac LICENSE README
INST_SPECIFICS = sac2c sac2crc tools.tar
SPECIFICS = $(INST_SPECIFICS) libsac.tar Makefile.Config
#
# Settings for temp directories
#
TEMPDIR = /tmp
#
# Settings for source directories
#
SAC2CDIR = $(shell pwd)/../..
RUNTIMEDIR = $(SAC2CDIR)/src/runtime
STDLIBDIR = $(SACBASE)/stdlib
DEMOBASE = $(HOME)/sac
DEMODIR = $(SACBASE)/demo
#
# Settings for target directories
#
BINTARGETDIR = ../binpacks
SRCTARGETDIR = ../srcpacks
#
# Settings for system SOLARIS_SPARC
#
SOLARIS_HOST-2_5 = twice
SOLARIS_HOST-2_7 = idefix
SOLARIS_DIR = /var/tmp/$(USER)_sac_distrib
#
# Settings for system LINUX_X86
#
LX86_HOST = bunasera
LX86_USER = sac
LX86_DIR = sac_distrib
LX86_MAKE = make
#
# Settings for system OSF_ALPHA
#
ALPHA_HOST = scalar03.rz
ALPHA_USER = sunip112
ALPHA_DIR = sac_distrib
ALPHA_MAKE = gmake
#
# Settings for system OSX_MAC
#
MAC_HOST = smeagol.ece.ucsb.edu
MAC_USER = sac
MAC_DIR = sac_distrib
MAC_MAKE = make
#
# Internal settings
#
RSH := ssh -oProtocol=1
RSH_LOCAL := ssh
RCP := scp -oProtocol=1
DATE := $(shell date +%d_%b_%y)
BINDISTRIBS := $(addprefix $(BINTARGETDIR)/SAC-$(VERSION)-, \
$(addsuffix -$(DATE).tar.gz,$(SYSTEMS)))
SRCDISTRIBS := $(SRCTARGETDIR)/SAC-$(VERSION)-$(DATE).tar.gz
CHECKFILES := $(INST_PACKAGES) $(foreach system,$(SYSTEMS), \
$(addsuffix .for.$(system),$(SPECIFICS)))
.PHONY: all source linux solaris25 solaris27 alpha check_existing_files \
clean allclean locker update new allnew
.SECONDARY: $(CHECKFILES)
all: check_existing_files $(BINDISTRIBS) $(SRCDISTRIBS)
source: check_existing_files $(SRCDISTRIBS)
linux: check_existing_files \
$(BINTARGETDIR)/SAC-$(VERSION)-LINUX_X86-$(DATE).tar.gz
solaris25: check_existing_files \
$(BINTARGETDIR)/SAC-$(VERSION)-SOLARIS_SPARC-2_5-$(DATE).tar.gz
solaris27: check_existing_files \
$(BINTARGETDIR)/SAC-$(VERSION)-SOLARIS_SPARC-2_7-$(DATE).tar.gz
alpha: check_existing_files \
$(BINTARGETDIR)/SAC-$(VERSION)-OSF_ALPHA-$(DATE).tar.gz
$(SRCTARGETDIR)/SAC-$(VERSION)-$(DATE).tar.gz: \
$(INST_PACKAGES) $(INST_FILES) src.tar.gz
@echo "**************************************************************"
@echo "* Creating SAC source distribution"
@echo "**************************************************************"
tar cvfh $(SRCTARGETDIR)/SAC-$(VERSION)-$(DATE).tar $^
gzip -f $(SRCTARGETDIR)/SAC-$(VERSION)-$(DATE).tar
rm -f src.tar.gz
$(BINTARGETDIR)/SAC-$(VERSION)-%-$(DATE).tar.gz: \
$(INST_PACKAGES) $(INST_FILES) $(addsuffix .for.%,$(SPECIFICS))
@echo "**************************************************************"
@echo "* Creating SAC binary distribution for $*"
@echo "**************************************************************"
mkdir -p $(TEMPDIR)/$*
mkdir -p $(TEMPDIR)/$*/_tar_
cp -f $(INST_PACKAGES) $(TEMPDIR)/$*
cp -f $(INST_FILES) $(TEMPDIR)/$*
for file in $(SPECIFICS); \
do cp -f $${file}.for.$* $(TEMPDIR)/$*/$${file}; done
@echo "*** merging libsac.tar into runtime.tar ***"
( cd $(TEMPDIR)/$*/_tar_; \
rm -rf *; \
tar xvf ../libsac.tar; \
tar uvf ../runtime.tar `tar tf ../libsac.tar`; )
@echo "*** merging Makefile.Config into stdlib.tar ***"
( cd $(TEMPDIR)/$*/_tar_; \
rm -rf *; \
tar xvf ../stdlib.tar; \
mv -f ../Makefile.Config Makefiles; \
tar cvf ../stdlib.tar `tar tf ../stdlib.tar`; )
@echo "*** creating SAC-$(VERSION)-$*-$(DATE).tar ***"
( cd $(TEMPDIR)/$*; \
tar cvf SAC-$(VERSION)-$*-$(DATE).tar \
$(INST_PACKAGES) $(INST_FILES) $(INST_SPECIFICS); \
gzip -f SAC-$(VERSION)-$*-$(DATE).tar )
mv -f $(TEMPDIR)/$*/SAC-$(VERSION)-$*-$(DATE).tar.gz $(BINTARGETDIR)
rm -rf $(TEMPDIR)/$*
src.tar.gz:
( cd $(SAC2CDIR); $(MAKE) tar )
ln -s $(SAC2CDIR)/$@
sac2c.for.SOLARIS_SPARC-% tools.tar.for.SOLARIS_SPARC-%:
@echo "**************************************************************"
@echo "* Creating sac2c for SOLARIS_SPARC-$* on host $(SOLARIS_HOST-$*)"
@echo "**************************************************************"
$(RSH_LOCAL) $(SOLARIS_HOST-$*) \
'setenv PATH $(PATH);' \
'cd $(SAC2CDIR)/distrib/src;' \
'$(MAKE) sac2c.for.SOLARIS_SPARC'
mv -f sac2c.for.SOLARIS_SPARC sac2c.for.SOLARIS_SPARC-$*
mv -f tools.tar.for.SOLARIS_SPARC tools.tar.for.SOLARIS_SPARC-$*
mv -f libsac.tar.for.SOLARIS_SPARC libsac.tar.for.SOLARIS_SPARC-$*
sac2c.for.SOLARIS_SPARC tools.tar.for.SOLARIS_SPARC:
( cd $(SAC2CDIR); $(MAKE) tar )
rm -rf $(SOLARIS_DIR)
mkdir -p $(SOLARIS_DIR)
cp $(SAC2CDIR)/src.tar.gz $(SOLARIS_DIR)
( cd $(SOLARIS_DIR); gunzip -f src.tar.gz )
( cd $(SOLARIS_DIR); tar xvf src.tar )
( cd $(SOLARIS_DIR); $(MAKE) distrib_product OS=SOLARIS_SPARC )
cp $(SOLARIS_DIR)/sac2c sac2c.for.SOLARIS_SPARC
( cd $(SOLARIS_DIR)/tools/bin; tar cvf tools.tar.for.SOLARIS_SPARC *)
cp $(SOLARIS_DIR)/tools/bin/tools.tar.for.SOLARIS_SPARC .
( cd $(SOLARIS_DIR)/src/runtime; tar cvfh libsac.tar libsac*.a )
cp $(SOLARIS_DIR)/src/runtime/libsac.tar libsac.tar.for.SOLARIS_SPARC
@ if [ $${?} -eq 0 ]; then \
rm -rf $(SOLARIS_DIR); \
else \
echo "Compilation of sac2c for SOLARIS_SPARC failed!"; \
echo "Unable to create SOLARIS_SPARC distribution !"; \
exit 1; \
fi
sac2c.for.LINUX_X86 tools.tar.for.LINUX_X86:
@echo "**************************************************************"
@echo "* Creating sac2c for LINUX_X86"
@echo "**************************************************************"
@ ping $(LX86_HOST) >/dev/null; \
if [ $${?} -ne 0 ]; then \
echo "Host $(LX86_HOST) is down !"; \
echo "Unable to create LINUX_X86 distribution !"; \
exit 1; \
fi
( cd $(SAC2CDIR); $(MAKE) tar )
$(RSH) -l $(LX86_USER) $(LX86_HOST) \
'rm -rf $(LX86_DIR); mkdir -p $(LX86_DIR)'
$(RCP) $(SAC2CDIR)/src.tar.gz $(LX86_USER)@$(LX86_HOST):$(LX86_DIR)
$(RSH) -l $(LX86_USER) $(LX86_HOST) \
'cd $(LX86_DIR);' \
'gunzip -f src.tar.gz;' \
'tar xvf src.tar;' \
'chmod -R u+w *;' \
'touch src/*/*;' \
'$(LX86_MAKE) distrib_product OS=LINUX_X86'
$(RCP) $(LX86_USER)@$(LX86_HOST):$(LX86_DIR)/sac2c sac2c.for.LINUX_X86
$(RSH) -l $(LX86_USER) $(LX86_HOST) \
'cd $(LX86_DIR)/tools/bin;' \
'tar cvf tools.tar.for.LINUX_X86 *;'
$(RCP) $(LX86_USER)@$(LX86_HOST):$(LX86_DIR)/tools/bin/tools.tar.for.LINUX_X86 .
$(RSH) -l $(LX86_USER) $(LX86_HOST) \
'cd $(LX86_DIR)/src/runtime;' \
'tar cvfh libsac.tar libsac*.a'
$(RCP) $(LX86_USER)@$(LX86_HOST):$(LX86_DIR)/src/runtime/libsac.tar \
libsac.tar.for.LINUX_X86
@ if [ $${?} -eq 0 ]; then \
$(RSH) -l $(LX86_USER) $(LX86_HOST) 'rm -rf $(LX86_DIR)'; \
else \
echo "Compilation of sac2c for LINUX_X86 failed!"; \
echo "Unable to create LINUX_X86 distribution !"; \
exit 1; \
fi
sac2c.for.OSF_ALPHA tools.tar.for.OSF_ALPHA:
@echo "**************************************************************"
@echo "* Creating sac2c for OSF_ALPHA"
@echo "**************************************************************"
@ ping $(ALPHA_HOST) >/dev/null; \
if [ $${?} -ne 0 ]; then \
echo "Host $(ALPHA_HOST) is down !"; \
echo "Unable to create OSF_ALPHA distribution !"; \
exit 1; \
fi
( cd $(SAC2CDIR); $(MAKE) tar )
$(RSH) -l $(ALPHA_USER) $(ALPHA_HOST) \
'rm -rf $(ALPHA_DIR); mkdir -p $(ALPHA_DIR)'
$(RCP) $(SAC2CDIR)/src.tar.gz $(ALPHA_USER)@$(ALPHA_HOST):$(ALPHA_DIR)
$(RSH) -l $(ALPHA_USER) $(ALPHA_HOST) \
'export PATH=$$HOME/bin:$$PATH:/usr/local/bin:/usr/bin/X11;' \
'cd $(ALPHA_DIR);' \
'gunzip -f src.tar.gz;' \
'tar xvf src.tar;' \
'chmod -R u+w *;' \
'touch src/*/*;' \
'$(ALPHA_MAKE) distrib_product OS=OSF_ALPHA'
$(RCP) $(ALPHA_USER)@$(ALPHA_HOST):$(ALPHA_DIR)/sac2c sac2c.for.OSF_ALPHA
$(RSH) -l $(ALPHA_USER) $(ALPHA_HOST) \
'cd $(ALPHA_DIR)/tools/bin;' \
'tar cvf tools.tar.for.OSF_ALPHA *;'
$(RCP) $(ALPHA_USER)@$(ALPHA_HOST):$(ALPHA_DIR)/tools/bin/tools.tar.for.OSF_ALPHA .
$(RSH) -l $(ALPHA_USER) $(ALPHA_HOST) \
'cd $(ALPHA_DIR)/src/runtime;' \
'tar cvfh libsac.tar libsac*.a'
$(RCP) $(ALPHA_USER)@$(ALPHA_HOST):$(ALPHA_DIR)/src/runtime/libsac.tar \
libsac.tar.for.OSF_ALPHA
@ if [ $${?} -eq 0 ]; then \
$(RSH) -l $(ALPHA_USER) $(ALPHA_HOST) 'rm -rf $(ALPHA_DIR)'; \
else \
echo "Compilation of sac2c for OSF_ALPHA failed!"; \
echo "Unable to create OSF_ALPHA distribution !"; \
exit 1; \
fi
sac2c.for.OSX_MAC tools.tar.for.OSX_MAC:
@echo "**************************************************************"
@echo "* Creating sac2c for OSX_MAC"
@echo "**************************************************************"
@ ping $(MAC_HOST) >/dev/null; \
if [ $${?} -ne 0 ]; then \
echo "Host $(MAC_HOST) is down !"; \
echo "Unable to create OSX_MAC distribution !"; \
exit 1; \
fi
( cd $(SAC2CDIR); $(MAKE) tar )
$(RSH) -l $(MAC_USER) $(MAC_HOST) \
'rm -rf $(MAC_DIR); mkdir -p $(MAC_DIR)'
$(RCP) $(SAC2CDIR)/src.tar.gz $(MAC_USER)@$(MAC_HOST):$(MAC_DIR)
$(RSH) -l $(MAC_USER) $(MAC_HOST) \
'setenv PATH $$HOME/bin\:$$PATH\:/usr/local/bin\:/usr/bin/X11;' \
'cd $(MAC_DIR);' \
'gunzip -f src.tar.gz;' \
'tar xvf src.tar;' \
'chmod -R u+w *;' \
'touch src/*/*;' \
'$(MAC_MAKE) distrib_product OS=OSX_MAC'
$(RCP) $(MAC_USER)@$(MAC_HOST):$(MAC_DIR)/sac2c sac2c.for.OSX_MAC
$(RSH) -l $(MAC_USER) $(MAC_HOST) \
'cd $(MAC_DIR)/tools/bin;' \
'tar cvf tools.tar.for.OSX_MAC *;'
$(RCP) $(MAC_USER)@$(MAC_HOST):$(MAC_DIR)/tools/bin/tools.tar.for.OSX_MAC .
$(RSH) -l $(MAC_USER) $(MAC_HOST) \
'cd $(MAC_DIR)/src/runtime;' \
'ranlib libsac*.a; ' \
'tar cvfh libsac.tar libsac*.a'
$(RCP) $(MAC_USER)@$(MAC_HOST):$(MAC_DIR)/src/runtime/libsac.tar \
libsac.tar.for.OSX_MAC
@ if [ $${?} -eq 0 ]; then \
$(RSH) -l $(MAC_USER) $(MAC_HOST) 'rm -rf $(MAC_DIR)'; \
else \
echo "Compilation of sac2c for OSX_MAC failed!"; \
echo "Unable to create OSX_MAC distribution !"; \
exit 1; \
fi
libsac.tar.for.%:
$(MAKE) sac2c.for.$*
sac2crc.for.%-2_5:
$(MAKE) sac2crc.for.$*
mv sac2crc.for.$* $@
sac2crc.for.%-2_7:
$(MAKE) sac2crc.for.$*
mv sac2crc.for.$* $@
sac2crc.for.%: $(RUNTIMEDIR)/sac2crc.%
@echo "**************************************************************"
@echo "* Creating sac2crc for $*"
@echo "**************************************************************"
cp $< $@
runtime.tar:
@echo "**************************************************************"
@echo "* Creating package $@"
@echo "**************************************************************"
( cd $(RUNTIMEDIR); $(MAKE) $@ )
cp $(RUNTIMEDIR)/$@ .
stdlib.tar:
@echo "**************************************************************"
@echo "* Creating package $@"
@echo "**************************************************************"
( cd $(STDLIBDIR); $(MAKE) tar )
cp $(STDLIBDIR)/$@ .
Makefile.Config.for.%-2_5:
$(MAKE) Makefile.Config.for.$*
mv Makefile.Config.for.$* $@
Makefile.Config.for.%-2_7:
$(MAKE) Makefile.Config.for.$*
mv Makefile.Config.for.$* $@
Makefile.Config.for.%: $(STDLIBDIR)/Makefiles/Makefile.Config
@echo "**************************************************************"
@echo "* Creating Makefile.Config for $*"
@echo "**************************************************************"
sed -e 's/^[ ]*OS[ ]*:=[ ]*[_A-Za-z0-9]*/OS := $*/g' $< > $@
demo.tar:
@echo "**************************************************************"
@echo "* Creating package $@"
@echo "**************************************************************"
( cd $(DEMODIR); $(MAKE) tar TARFILENAME=$@ )
cp $(DEMODIR)/$@ .
check_existing_files:
@ for file in $(CHECKFILES); do \
if [ -f $${file} ]; then \
echo 'WARNING: '$${file}' is being reused!'; fi; \
done
clean:
rm -f $(BINDISTRIBS) $(SRCDISTRIBS) $(addsuffix .for.*,$(SPECIFICS)) \
$(INST_PACKAGES)
rm -f *~ *.bak *.old
allclean: clean
rm -f $(SAC2CDIR)/src.tar.gz
rm -f $(RUNTIMEDIR)/runtime.tar
rm -f $(STDLIBDIR)/stdlib.tar
rm -f $(DEMODIR)/demo.tar
locker:
locker $(SAC2CDIR)
locker $(DEMOBASE)
locker $(STDLIBDIR)
update: clean
update $(SAC2CDIR)
rmobsfiles $(SAC2CDIR)
update $(DEMOBASE)
rmobsfiles $(DEMOBASE)
update $(STDLIBDIR)
rmobsfiles $(STDLIBDIR)
new:
rm -f $(BINDISTRIBS) $(SRCDISTRIBS) $(addsuffix .for.*,$(SPECIFICS))
$(MAKE)
allnew: allclean
$(MAKE)
############################################################
# SAC Release - README
############################################################
Thanks for downloading SAC.
This binary distribution of SAC contains the SAC compiler sac2c
and the SAC runtime library libsac.a ready to be used for the specific
system you selected. Moreover, the distribution comes with the
complete sources of the SAC standard library and a set of SAC demo
programs.
In order to complete your SAC installation, please run the installation
script install_sac. This will guide you through the entire installation
process and prompt you interactively where necessary. If anything goes
wrong, you may run install_sac repeatedly. If you encounter any problems
during installation, you may find useful information on the SAC web pages
at http://www.informatik.uni-kiel.de/~sacbase. If this still does not
solve your problems, you may drop an e-mail at sacbase@informatik.uni-kiel.de.
Once your installation has been completed successfully, you may find out
how the SAC compiler sac2c works by typing sac2c -h. To find out more about
programming in SAC, have a look into the demo programs and maybe also into
those parts of the standard library that are implemented in SAC.
Enjoy yourself with SAC.
#!/bin/sh
pwd=`pwd`
SACBASE=${SACBASE:-$pwd}
#
# First, the default paths are set:
#
bin="$HOME/bin"
demo="$HOME/sac/demo"
doc="$SACBASE/doc"
base="$SACBASE"
make=gmake
add_search_path () {
PATH=$1\:$PATH
export PATH
}
err () {
echo "error: " $1
echo
}
mess () {
echo
echo ">>>>> " $1
echo
}
warn () {
echo "warning: " $1
echo
}
error () {
err "$1"
exit 1
}
ask () {
ask_res=""
echo $1 "[$2]"
read tmp
if [ $tmp"x" != "x" ] ; then
ask_res=$tmp
else
ask_res=$2
fi
}
ask_for_dir () {
ask_res=""
until [ $ask_res"x" != "x" ]
do
ask "$1" "$2"
if [ -f $ask_res ] ; then
err "$ask_res exists and is a file!"
ask_res=""
elif [ ! -d $ask_res ] ; then
mem_dir=$ask_res
ask 'Create directory "'$ask_res'"?' "y"
if [ $ask_res != "y" ] ; then
ask_res=""
else
ask_res=$mem_dir
mkdir -p $ask_res
fi
fi
done
mem_dir=`pwd`
cd $ask_res
ask_res=`pwd`
cd $mem_dir
}
insert_component() {
#
# $1: flag {f,d} indicating file / directory
# $2: source-file
# $3: destination-file/directory
# $4: flag {r,n} indicating whether to re-use / not re-use existing stuff
#
if [ -f $2 ]
then
if [ -$1 $3 -a $4 = "r" ] ; then
ask '"'$3'" exists! Overwrite?' "y"
if [ $ask_res != "y" ] ; then
warn '"'$2'" neglected - using "'$3'"!'
warn '"'$2'" NOT INSTALLED AGAIN !!'
else
mv -f $2 $3
chmod u+w $3
mess '"'$2'" INSTALLED !!'
fi
else
if [ $1 = "d" ] ; then
mkdir -p $3
fi
mv -f $2 $3
chmod u+w $3
mess '"'$2'" INSTALLED !!'
fi
else
if [ -$1 $3 ] ; then
warn '"'$2'" not found - using "'$3'"!'
warn '"'$2'" NOT INSTALLED AGAIN !!'
else
error '"'$2'" not found!'
fi
fi
}
######################################################################
# This is the beginning...
######################################################################
chmod -f u+w install_sac README LICENSE
echo '**************************************************************************'
echo
echo 'SAC installation process started !'
echo
######################################################################
# sac2c
######################################################################
ask_for_dir "Intended location for the compiler executable?" $bin
bin=$ask_res
insert_component f sac2c $bin/sac2c r
#
# make sure, that $bin is in $PATH!
#
add_search_path $bin
######################################################################
# doc.tar
######################################################################
# ask_for_dir "Intended location for the documentation?" $doc
# doc=$ask_res
# mv -f doc.tar $doc/doc.tar
# (cd $doc; tar xvf doc.tar; rm -f doc.tar)
# chmod -R u+w $doc
######################################################################
# runtime.tar + stdlib.tar + tools.tar
######################################################################
ask_for_dir 'Intended location for $SACBASE, i.e., runtime / lib-files?' $base
base=$ask_res
if [ $SACBASE != $base ]
then
SACBASE=$base
fi
export SACBASE
insert_component d runtime.tar $base/runtime r
if [ -f $SACBASE/runtime/runtime.tar ] ; then
(cd $SACBASE/runtime; tar xvf runtime.tar; rm -f runtime.tar)
chmod -R u+w $SACBASE/runtime
mess "runtime.tar UNPACKED !!"
else
warn "runtime.tar NOT UNPACKED !!"
fi
insert_component f sac2crc $base/runtime/sac2crc r
echo
ask 'How to call GNU-make?' $make
make=$ask_res
insert_component d stdlib.tar $base/stdlib r
if [ -f $SACBASE/stdlib/stdlib.tar ] ; then
(cd $SACBASE/stdlib; tar xvf stdlib.tar; $make untar TARGET=untar; rm -f stdlib.tar )
chmod -R u+w $SACBASE/stdlib
mess "stdlib.tar UNPACKED !!"
else
warn "stdlib.tar NOT UNPACKED !!"
fi
insert_component d tools.tar $base/stdlib/Tools r
if [ -f $SACBASE/stdlib/Tools/tools.tar ] ; then
(cd $SACBASE/stdlib/Tools; tar xvf tools.tar; rm -f tools.tar )
chmod -R u+w $SACBASE/stdlib/tools
(cd $bin; ln -s $SACBASE/stdlib/Tools/ctest .)
mess "tools.tar UNPACKED !!"
else
warn "stools.tar NOT UNPACKED !!"
fi
if [ -f $SACBASE/stdlib/Makefile ] ; then
ask 'Do you want to compile the standard library right now?' "y"
if [ $ask_res = "y" ] ; then
mess "COMPILING stdlib !!"
(cd $SACBASE/stdlib; $make )
else
mess 'If you want to compile the stdlib later, use "cd $SACBASE/stdlib;'" $make"'"'
fi
fi
######################################################################
# demo.tar
######################################################################
ask_for_dir "Intended location for the SAC - demo programs?" $demo
demo=$ask_res
insert_component d demo.tar $demo/ n
if [ -f $demo/demo.tar ] ; then
(cd $demo; tar xvf demo.tar; $make untar TARGET=untar TARFILENAME=demo.tar; rm -f demo.tar)
chmod -R u+w $demo
mess "demo.tar UNPACKED !!"
else
warn "demo.tar NOT UNPACKED !!"
fi
if [ -f $demo/Makefile ] ; then
ask 'Do you want to compile the demo programs right now?' "y"
if [ $ask_res = "y" ] ; then
mess "COMPILING demo programs !!"
(cd $demo; $make )
else
mess 'If you want to compile the demo programs later, use "cd '"$demo; $make"'"'
fi
fi
######################################################################
echo '**************************************************************************'
echo
echo 'SAC installation process completed !'
echo
echo 'Make sure that "'$bin'" is part of your PATH!'
echo 'Make sure that $SACBASE is set to "'$SACBASE'" BEFORE calling sac2c!'
echo
echo 'Enjoy sac2c !!'
echo
echo 'When encountering any problems, please have a look into the FAQs at'
echo ' http://www.informatik.uni-kiel.de/~sacbase/'
echo
echo 'If you do not find your question in the FAQs, please send email to'
echo ' sacbase@informatik.uni-kiel.de'
echo
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_mpi.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_MPI([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro tries to find out how to compile programs that use MPI
# (Message Passing Interface), a standard API for parallel process
# communication (see http://www-unix.mcs.anl.gov/mpi/)
#
# On success, it sets the MPICC, MPICXX, MPIF77, or MPIFC output variable
# to the name of the MPI compiler, depending upon the current language.
# (This may just be $CC/$CXX/$F77/$FC, but is more often something like
# mpicc/mpiCC/mpif77/mpif90.) It also sets MPILIBS to any libraries that
# are needed for linking MPI (e.g. -lmpi or -lfmpi, if a special
# MPICC/MPICXX/MPIF77/MPIFC was not found).
#
# Note that this macro should be used only if you just have a few source
# files that need to be compiled using MPI. In particular, you should
# neither overwrite CC/CXX/F77/FC with the values of
# MPICC/MPICXX/MPIF77/MPIFC, nor assume that you can use the same flags
# etc. as the standard compilers. If you want to compile a whole program
# using the MPI compiler commands, use one of the macros
# AX_PROG_{CC,CXX,FC}_MPI.
#
# ACTION-IF-FOUND is a list of shell commands to run if an MPI library is
# found, and ACTION-IF-NOT-FOUND is a list of commands to run if it is not
# found. If ACTION-IF-FOUND is not specified, the default action will
# define HAVE_MPI.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2008 Julian C. Cummings <cummings@cacr.caltech.edu>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 8
AU_ALIAS([ACX_MPI], [AX_MPI])
AC_DEFUN([AX_MPI], [
AC_PREREQ(2.50) dnl for AC_LANG_CASE
AC_LANG_CASE([C], [
AC_REQUIRE([AC_PROG_CC])
AC_ARG_VAR(MPICC,[MPI C compiler command])
AC_CHECK_PROGS(MPICC, mpicc hcc mpxlc_r mpxlc mpcc cmpicc, $CC)
ax_mpi_save_CC="$CC"
CC="$MPICC"
AC_SUBST(MPICC)
],
[C++], [
AC_REQUIRE([AC_PROG_CXX])
AC_ARG_VAR(MPICXX,[MPI C++ compiler command])
AC_CHECK_PROGS(MPICXX, mpic++ mpicxx mpiCC hcp mpxlC_r mpxlC mpCC cmpic++, $CXX)
ax_mpi_save_CXX="$CXX"
CXX="$MPICXX"
AC_SUBST(MPICXX)
],
[Fortran 77], [
AC_REQUIRE([AC_PROG_F77])
AC_ARG_VAR(MPIF77,[MPI Fortran 77 compiler command])
AC_CHECK_PROGS(MPIF77, mpif77 hf77 mpxlf_r mpxlf mpf77 cmpifc, $F77)
ax_mpi_save_F77="$F77"
F77="$MPIF77"
AC_SUBST(MPIF77)
],
[Fortran], [
AC_REQUIRE([AC_PROG_FC])
AC_ARG_VAR(MPIFC,[MPI Fortran compiler command])
AC_CHECK_PROGS(MPIFC, mpif90 mpxlf95_r mpxlf90_r mpxlf95 mpxlf90 mpf90 cmpif90c, $FC)
ax_mpi_save_FC="$FC"
FC="$MPIFC"
AC_SUBST(MPIFC)
])
if test x = x"$MPILIBS"; then
AC_LANG_CASE([C], [AC_CHECK_FUNC(MPI_Init, [MPILIBS=" "])],
[C++], [AC_CHECK_FUNC(MPI_Init, [MPILIBS=" "])],
[Fortran 77], [AC_MSG_CHECKING([for MPI_Init])
AC_LINK_IFELSE([AC_LANG_PROGRAM([],[ call MPI_Init])],[MPILIBS=" "
AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])],
[Fortran], [AC_MSG_CHECKING([for MPI_Init])
AC_LINK_IFELSE([AC_LANG_PROGRAM([],[ call MPI_Init])],[MPILIBS=" "
AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])])
fi
AC_LANG_CASE([Fortran 77], [
if test x = x"$MPILIBS"; then
AC_CHECK_LIB(fmpi, MPI_Init, [MPILIBS="-lfmpi"])
fi
if test x = x"$MPILIBS"; then
AC_CHECK_LIB(fmpich, MPI_Init, [MPILIBS="-lfmpich"])
fi
],
[Fortran], [
if test x = x"$MPILIBS"; then
AC_CHECK_LIB(fmpi, MPI_Init, [MPILIBS="-lfmpi"])
fi
if test x = x"$MPILIBS"; then
AC_CHECK_LIB(mpichf90, MPI_Init, [MPILIBS="-lmpichf90"])
fi
])
if test x = x"$MPILIBS"; then
AC_CHECK_LIB(mpi, MPI_Init, [MPILIBS="-lmpi"])
fi
if test x = x"$MPILIBS"; then
AC_CHECK_LIB(mpich, MPI_Init, [MPILIBS="-lmpich"])
fi
dnl We have to use AC_TRY_COMPILE and not AC_CHECK_HEADER because the
dnl latter uses $CPP, not $CC (which may be mpicc).
AC_LANG_CASE([C], [if test x != x"$MPILIBS"; then
AC_MSG_CHECKING([for mpi.h])
AC_TRY_COMPILE([#include <mpi.h>],[],[AC_MSG_RESULT(yes)], [MPILIBS=""
AC_MSG_RESULT(no)])
fi],
[C++], [if test x != x"$MPILIBS"; then
AC_MSG_CHECKING([for mpi.h])
AC_TRY_COMPILE([#include <mpi.h>],[],[AC_MSG_RESULT(yes)], [MPILIBS=""
AC_MSG_RESULT(no)])
fi],
[Fortran 77], [if test x != x"$MPILIBS"; then
AC_MSG_CHECKING([for mpif.h])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[ include 'mpif.h'])],[AC_MSG_RESULT(yes)], [MPILIBS=""
AC_MSG_RESULT(no)])
fi],
[Fortran], [if test x != x"$MPILIBS"; then
AC_MSG_CHECKING([for mpif.h])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[ include 'mpif.h'])],[AC_MSG_RESULT(yes)], [MPILIBS=""
AC_MSG_RESULT(no)])
fi])
AC_LANG_CASE([C], [CC="$ax_mpi_save_CC"],
[C++], [CXX="$ax_mpi_save_CXX"],
[Fortran 77], [F77="$ax_mpi_save_F77"],
[Fortran], [FC="$ax_mpi_save_FC"])
AC_SUBST(MPILIBS)
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x = x"$MPILIBS"; then
$2
:
else
ifelse([$1],,[AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.])],[$1])
:
fi
])dnl AX_MPI
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_openmp.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_OPENMP([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro tries to find out how to compile programs that use OpenMP a
# standard API and set of compiler directives for parallel programming
# (see http://www-unix.mcs/)
#
# On success, it sets the OPENMP_CFLAGS/OPENMP_CXXFLAGS/OPENMP_F77FLAGS
# output variable to the flag (e.g. -omp) used both to compile *and* link
# OpenMP programs in the current language.
#
# NOTE: You are assumed to not only compile your program with these flags,
# but also link it with them as well.
#
# If you want to compile everything with OpenMP, you should set:
#
# CFLAGS="$CFLAGS $OPENMP_CFLAGS"
# #OR# CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"
# #OR# FFLAGS="$FFLAGS $OPENMP_FFLAGS"
#
# (depending on the selected language).
#
# The user can override the default choice by setting the corresponding
# environment variable (e.g. OPENMP_CFLAGS).
#
# ACTION-IF-FOUND is a list of shell commands to run if an OpenMP flag is
# found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it is
# not found. If ACTION-IF-FOUND is not specified, the default action will
# define HAVE_OPENMP.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 9
AC_DEFUN([AX_OPENMP], [
AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX
AC_CACHE_CHECK([for OpenMP flag of _AC_LANG compiler], ax_cv_[]_AC_LANG_ABBREV[]_openmp, [save[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
ax_cv_[]_AC_LANG_ABBREV[]_openmp=unknown
# Flags to try: -fopenmp (gcc), -openmp (icc), -mp (SGI & PGI),
# -xopenmp (Sun), -omp (Tru64), -qsmp=omp (AIX), none
ax_openmp_flags="-fopenmp -openmp -mp -xopenmp -omp -qsmp=omp none"
if test "x$OPENMP_[]_AC_LANG_PREFIX[]FLAGS" != x; then
ax_openmp_flags="$OPENMP_[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flags"
fi
for ax_openmp_flag in $ax_openmp_flags; do
case $ax_openmp_flag in
none) []_AC_LANG_PREFIX[]FLAGS=$save[]_AC_LANG_PREFIX[] ;;
*) []_AC_LANG_PREFIX[]FLAGS="$save[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flag" ;;
esac
AC_TRY_LINK([#ifdef __cplusplus
extern "C"
#endif
void omp_set_num_threads(int);], [const int N = 100000;
int i, arr[N];
omp_set_num_threads(2);
#pragma omp parallel for
for (i = 0; i < N; i++) {
arr[i] = i;
}], [ax_cv_[]_AC_LANG_ABBREV[]_openmp=$ax_openmp_flag; break])
done
[]_AC_LANG_PREFIX[]FLAGS=$save[]_AC_LANG_PREFIX[]FLAGS
])
if test "x$ax_cv_[]_AC_LANG_ABBREV[]_openmp" = "xunknown"; then
m4_default([$2],:)
else
if test "x$ax_cv_[]_AC_LANG_ABBREV[]_openmp" != "xnone"; then
OPENMP_[]_AC_LANG_PREFIX[]FLAGS=$ax_cv_[]_AC_LANG_ABBREV[]_openmp
fi
m4_default([$1], [AC_DEFINE(HAVE_OPENMP,1,[Define if OpenMP is enabled])])
fi
])dnl AX_OPENMP
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_pthread.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro figures out how to build C programs using POSIX threads. It
# sets the PTHREAD_LIBS output variable to the threads library and linker
# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
# flags that are needed. (The user can also force certain compiler
# flags/libs to be tested by setting these environment variables.)
#
# Also sets PTHREAD_CC to any special C compiler that is needed for
# multi-threaded programs (defaults to the value of CC otherwise). (This
# is necessary on AIX to use the special cc_r compiler alias.)
#
# NOTE: You are assumed to not only compile your program with these flags,
# but also link it with them as well. e.g. you should link with
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
#
# If you are only building threads programs, you may wish to use these
# variables in your default LIBS, CFLAGS, and CC:
#
# LIBS="$PTHREAD_LIBS $LIBS"
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# CC="$PTHREAD_CC"
#
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
# (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
#
# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
# PTHREAD_CFLAGS.
#
# ACTION-IF-FOUND is a list of shell commands to run if a threads library
# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
# is not found. If ACTION-IF-FOUND is not specified, the default action
# will define HAVE_PTHREAD.
#
# Please let the authors know if this macro fails on any platform, or if
# you have any other suggestions or comments. This macro was based on work
# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
# Alejandro Forero Cuervo to the autoconf macro repository. We are also
# grateful for the helpful feedback of numerous users.
#
# Updated for Autoconf 2.68 by Daniel Richard G.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 20
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_LANG_PUSH([C])
ax_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on True64 or Sequent).
# It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS,
# etcetera environment variables, and if threads linking works using
# them:
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes)
AC_MSG_RESULT($ax_pthread_ok)
if test x"$ax_pthread_ok" = xno; then
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
fi
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
fi
# We must check for the threads library under a number of different
# names; the ordering is very important because some systems
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
# libraries is broken (non-POSIX).
# Create a list of thread flags to try. Items starting with a "-" are
# C compiler flags, and other items are library names, except for "none"
# which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library.
ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# pthreads: AIX (must check this before -lpthread)
# none: in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
# -pthreads: Solaris/gcc
# -mthreads: Mingw32/gcc, Lynx/gcc
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads too;
# also defines -D_REENTRANT)
# ... -mt is also the pthreads flag for HP/aCC
# pthread: Linux, etcetera
# --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library)
case ${host_os} in
solaris*)
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (We need to link with -pthreads/-mt/
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
# a function called by this macro, so we could check for that, but
# who knows whether they'll stub that too in a future libc.) So,
# we'll just look for -pthreads and -lpthread first:
ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
;;
darwin*)
ax_pthread_flags="-pthread $ax_pthread_flags"
;;
esac
if test x"$ax_pthread_ok" = xno; then
for flag in $ax_pthread_flags; do
case $flag in
none)
AC_MSG_CHECKING([whether pthreads work without any flags])
;;
-*)
AC_MSG_CHECKING([whether pthreads work with $flag])
PTHREAD_CFLAGS="$flag"
;;
pthread-config)
AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no)
if test x"$ax_pthread_config" = xno; then continue; fi
PTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
;;
*)
AC_MSG_CHECKING([for the pthreads library -l$flag])
PTHREAD_LIBS="-l$flag"
;;
esac
save_LIBS="$LIBS"
save_CFLAGS="$CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we
# need a special flag -Kthread to make this header compile.)
# We check for pthread_join because it is in -lpthread on IRIX
# while pthread_create is in libc. We check for pthread_attr_init
# due to DEC craziness with -lpthreads. We check for
# pthread_cleanup_push because it is one of the few pthread
# functions on Solaris that doesn't have a non-functional libc stub.
# We try pthread_create on general principles.
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
static void routine(void *a) { a = 0; }
static void *start_routine(void *a) { return a; }],
[pthread_t th; pthread_attr_t attr;
pthread_create(&th, 0, start_routine, 0);
pthread_join(th, 0);
pthread_attr_init(&attr);
pthread_cleanup_push(routine, 0);
pthread_cleanup_pop(0) /* ; */])],
[ax_pthread_ok=yes],
[])
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
AC_MSG_RESULT($ax_pthread_ok)
if test "x$ax_pthread_ok" = xyes; then
break;
fi
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
done
fi
# Various other checks:
if test "x$ax_pthread_ok" = xyes; then
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
AC_MSG_CHECKING([for joinable pthread attribute])
attr_name=unknown
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
[int attr = $attr; return attr /* ; */])],
[attr_name=$attr; break],
[])
done
AC_MSG_RESULT($attr_name)
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
[Define to necessary symbol if this constant
uses a non-standard name on your system.])
fi
AC_MSG_CHECKING([if more special flags are required for pthreads])
flag=no
case ${host_os} in
aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";;
osf* | hpux*) flag="-D_REENTRANT";;
solaris*)
if test "$GCC" = "yes"; then
flag="-D_REENTRANT"
else
flag="-mt -D_REENTRANT"
fi
;;
esac
AC_MSG_RESULT(${flag})
if test "x$flag" != xno; then
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
fi
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
ax_cv_PTHREAD_PRIO_INHERIT, [
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[#include <pthread.h>]], [[int i = PTHREAD_PRIO_INHERIT;]])],
[ax_cv_PTHREAD_PRIO_INHERIT=yes],
[ax_cv_PTHREAD_PRIO_INHERIT=no])
])
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.]))
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
# More AIX lossage: compile with *_r variant
if test "x$GCC" != xyes; then
case $host_os in
aix*)
AS_CASE(["x/$CC"],
[x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
[#handle absolute path differently from PATH based program lookup
AS_CASE(["x$CC"],
[x/*],
[AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
[AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
;;
esac
fi
fi
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_CC)
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x"$ax_pthread_ok" = xyes; then
ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
:
else
ax_pthread_ok=no
$2
fi
AC_LANG_POP
])dnl AX_PTHREAD
AC_DEFUN([CHECK_CC_BRACKETS], dnl
[
AC_REQUIRE([AC_PROG_CC])
brackets_ok=no
save_CFLAGS=$CFLAGS
for cf in "" "-fbracket-depth=2048"; do
CFLAGS="$save_CFLAGS $cf"
AC_MSG_CHECKING([whether $CC $cf supports 300 bracket nesting levels])
AC_TRY_COMPILE([],[
int a =
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((0))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
(void)a;
],[AC_MSG_RESULT(yes); brackets_ok=yes; break])
done
if test $brackets_ok = no; then
AC_MSG_ERROR([$CC does not support large bracketing depths])
fi
gcc_options="$gcc_options $cf"
])
# CHECK_CC_OPTION(OPTION, VAR_TO_APPEND)
# The macro is checking whether chosen compiler supports an OPTION
# in case it does, the VAR_TO_APPEND is being appended by the OPTION
AC_DEFUN([CHECK_CC_OPTION],[
AC_REQUIRE([AC_PROG_CC])
AS_VAR_PUSHDEF([ac_cc_option], [ac_cv_$1_option])
AC_CACHE_CHECK([whether $CC supports $1], ac_cc_option,
[save_CFLAGS="$CFLAGS";
CFLAGS="-Werror $1"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])],
[AS_VAR_SET(ac_cc_option, yes)],
[AS_VAR_SET(ac_cc_option, no)])
AS_IF([test AS_VAR_GET(ac_cc_option) = yes],
[$2="$$2 $1"])
CFLAGS="$save_CFLAGS"
])
AS_VAR_POPDEF([ac_cc_option])
])
dnl find a code beautifier (cb).
dnl sets and substitutes CB to whichever is found.
AC_DEFUN([CHECK_CODE_BEAUTIFIER],dnl
[
AC_ARG_VAR([CB], [Code beautifier (defaults to indent)])
AC_CHECK_PROGS([CB], [gindent indent], [no])
if test "x$CB" = xno; then
# backward compatibility
CB="\$(PROJECT_ROOT)/src/bin/cb"
fi
])
dnl CHECK_COMPILER_VENDOR
dnl this macro checks what type of C compiler
dnl is being used.
AC_DEFUN([CHECK_COMPILER_VENDOR],dnl
[
# When C compiler is not GCC, check if one of
# Sun, Dec or Mac compiler is available on the system.
if test "$GCC" != yes ; then
CHECK_CPP_FLAG([__SUNPRO_C], [SUNC])
CHECK_CPP_FLAG([__DECC], [DECC])
CHECK_CPP_FLAG([__APPLE_CC__], [MACC])
fi
# For some reason, ICC is recognized as GCC.
CHECK_CPP_FLAG([__INTEL_COMPILER], [ICC])
if test "$ICC" != yes ; then
CHECK_CPP_FLAG([__ICC], [ICC])
fi
if test "$ICC" = yes ; then
[GCC=no]
fi
])
AC_DEFUN([CHECK_CONST_STDERR], dnl
[
AC_MSG_CHECKING([whether stderr is a variable])
AC_TRY_COMPILE([@%:@include <stdio.h>],
[FILE *_mine_ = stderr;],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_DEFINE([STDERR_IS_CONSTANT], 1,
[Define if stderr is a constant.])])
])
dnl CHECK_CPP_FLAG(FLAG, VARIABLE)
dnl This macro checks whether a preprocessor have predefined FLAG
dnl and if it does, the VARIABLE is being set to yes
dnl in other case the VARIABLE is set to no
AC_DEFUN([CHECK_CPP_FLAG],dnl
[
AC_REQUIRE([AC_PROG_CC])
AS_VAR_PUSHDEF([ac_cpp_flag], [ac_cv_$1_cpp_flag])
AC_CACHE_CHECK([whether $CC supports $1 flag],
[ac_cpp_flag],
[AC_TRY_COMPILE([],
[
#ifndef $1
choke me
#endif
],
[AS_VAR_SET([ac_cpp_flag], [yes])],
[AS_VAR_SET([ac_cpp_flag], [no])])
$2=AS_VAR_GET(ac_cpp_flag)])
AS_VAR_POPDEF([ac_cpp_flag])
])
dnl
dnl check CUDA tools to enable the CUDA back-end.
dnl
dnl This substitutes NVCC_PATH to the absolute path to the "nvcc" command
dnl and also defines the preprocessor macro ENABLE_CUDA to 0 or 1 depending
dnl on whether support is detected and working.
AC_DEFUN([CHECK_CUDA],dnl
[
AC_ARG_ENABLE([cuda],
[AS_HELP_STRING([--disable-cuda],
[Disable checking for CUDA])],
[enable_cuda=$enableval],
[enable_cuda=yes])
CUDA_ARCH=no
NVCC_PATH=no
CUDA_ROOT=no
if test x"$enable_cuda" != xno; then
# search for the NVidia compiler (nvcc)
AC_ARG_VAR([NVCC], [NVidia CUDA compiler (defaults to nvcc)])
AC_PATH_PROGS([NVCC], [nvcc], [no])
if test x"$NVCC" = xno; then
enable_cuda=no
else
# try to compile a test CUDA program
if cp -f "$srcdir"/src/tools/cuda/deviceQuery.cpp conftest.cc 2>/dev/null; then
AC_MSG_CHECKING([whether nvcc works])
if $NVCC conftest.cc -o conftest$EXEEXT; then
AC_MSG_RESULT([$enable_cuda])
NVCC_PATH=$NVCC
# get cuda base directory from NVCC location
# this is generally safe as CUDA has the same directory
# structure across systems
CUDA_ROOT=$(dirname $(dirname $NVCC))
AC_MSG_NOTICE([using '$CUDA_ROOT' as [CUDA_ROOT]])
# extract the architecture flags from the test program
AC_MSG_CHECKING([what CUDA compute level is supported])
if ./conftest$EXEEXT 2>&1 >/dev/null; then
CUDA_ARCH=$(./conftest$EXEEXT)
else
CUDA_ARCH="\\\"please set this manually\\\""
fi
AC_MSG_RESULT([$CUDA_ARCH])
else
enable_cuda=no
AC_MSG_RESULT([$enable_cuda])
fi
fi
fi
fi
AC_SUBST([CUDA_ARCH])
AC_SUBST([NVCC_PATH])
AC_SUBST([CUDA_ROOT])
])
AC_DEFUN([EMPTY_DUMMY_MACRO])
AC_DEFUN([DISTMEM_INIT_DEFAULTS], dnl
[
AC_ARG_ENABLE([distmem],
[AS_HELP_STRING([--enable-distmem=x,y,z],
[Enable distmem targets x,y,z, or use --disable-distmem to disable entirely.
Available targets: gasnet,gpi,mpi,armci.
The default target is "auto" which enables whichever target can be found.])],
[], [enable_distmem=auto])
enable_distmem_gasnet=no
enable_distmem_gpi=no
enable_distmem_mpi=no
enable_distmem_armci=no
case $enable_distmem in
auto|yes)
enable_distmem_gasnet=auto
enable_distmem_gpi=auto
enable_distmem_mpi=auto
enable_distmem_armci=auto
;;
esac
case $enable_distmem in *gasnet*) enable_distmem_gasnet=yes;; esac
case $enable_distmem in *gpi*) enable_distmem_gpi=yes;; esac
case $enable_distmem in *mpi*) enable_distmem_mpi=yes;; esac
case $enable_distmem in *armci*) enable_distmem_armci=yes;; esac
AC_ARG_ENABLE([distmem-gasnet], [AS_HELP_STRING([--disable-distmem-gasnet], [Disable the GASnet target.])])
AC_ARG_ENABLE([distmem-gpi], [AS_HELP_STRING([--disable-distmem-gpi], [Disable the GPI target.])])
AC_ARG_ENABLE([distmem-mpi], [AS_HELP_STRING([--disable-distmem-mpi], [Disable the MPI target.])])
AC_ARG_ENABLE([distmem-armci], [AS_HELP_STRING([--disable-distmem-armci], [Disable the ARMci target.])])
])
AC_DEFUN([CHECK_DISTMEM_MPI], dnl
[
AX_MPI([enable_distmem_mpi=yes], [enable_distmem_mpi=no])
if test x"$enable_distmem_mpi" != xno; then
AC_MSG_CHECKING([for MPI 3 support])
ax_mpi_save_CC="$CC"
CC="$MPICC"
AC_TRY_COMPILE([#include <mpi.h>],
[
/* This program uses MPI 3 one-sided communication to test
whether the MPI installation does support these operations. */
int main(int argc, char *argv[]) {
static MPI_Win win = NULL;
size_t SAC_DISTMEM_pagesz = 0;
void *local_page_ptr = NULL;
size_t owner_rank = 0;
size_t remote_page_index;
MPI_Get( local_page_ptr, SAC_DISTMEM_pagesz,
MPI_BYTE, owner_rank,
remote_page_index * SAC_DISTMEM_pagesz,
SAC_DISTMEM_pagesz, MPI_BYTE, win);
}
],
[AC_MSG_RESULT(yes)],
[enable_distmem_mpi=no;
AC_MSG_RESULT(no)])
CC="$ax_mpi_save_CC"
fi
])
AC_DEFUN([CHECK_DISTMEM_ARMCI], dnl
[
enable_distmem_armci=no
AC_MSG_CHECKING([whether ARMCI_HOME is set])
if test x"$ARMCI_HOME" != x ; then
AC_MSG_RESULT([using ARMCI_HOME: $ARMCI_HOME])
AC_MSG_CHECKING([whether $ARMCI_HOME exists])
if test -r "$ARMCI_HOME"; then
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([ARMCI_DIR], ["$ARMCI_HOME"],
[ARMCI installation])
AC_SUBST([ARMCI_DIR], [$ARMCI_HOME])
enable_distmem_armci=yes
else
AC_MSG_RESULT([no])
fi
else
AC_MSG_RESULT([no])
fi
])
AC_DEFUN([CHECK_DISTMEM_GPI], dnl
[
enable_distmem_gpi=no
AC_MSG_CHECKING([whether GPI_HOME is set])
if test x"$GPI_HOME" != x ; then
AC_MSG_RESULT([using GPI_HOME: $GPI_HOME])
AC_MSG_CHECKING([whether $GPI_HOME exists])
if test -r "$GPI_HOME"; then
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([GPI_DIR], ["$GPI_HOME"],
[GPI installation])
AC_SUBST([GPI_DIR], [$GPI_HOME])
enable_distmem_gpi=yes
else
AC_MSG_RESULT([no])
fi
else
AC_MSG_RESULT([no])
fi
])
AC_DEFUN([CHECK_DISTMEM_GASNET], dnl
[
enable_distmem_gastnet=no
AC_MSG_CHECKING([whether GASNET_HOME is set])
if test x"$GASNET_HOME" != x ; then
gasnet_home="$GASNET_HOME"
AC_MSG_RESULT([using GASNET_HOME: $gasnet_home])
AC_MSG_CHECKING([whether $gasnet_home exists])
if test -r "$gasnet_home"; then
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([for installed gasnet conduits])
gasnet_conduits=$(echo $( (cd "$gasnet_home/include" && ls -d *-conduit 2>/dev/null | cut -d- -f1 ) ) )
if test x"$gasnet_conduits" = x ; then
AC_MSG_RESULT([none])
else
AC_MSG_RESULT([$gasnet_conduits])
enable_distmem_gasnet=yes
fi
else
AC_MSG_RESULT([no])
fi
else
AC_MSG_RESULT([no])
fi
])
AC_DEFUN([GASNET_INIT], dnl
[
dnl Create GASNet conduit targets file.
true >./sac2crc.GASNetconduits
dnl Create GASNet conduit build files.
true >./build.GASNetconduits
true >./build.GASNetconduitsCrossVariant
dnl Create GASNet conduit settings file.
true >./config.GASNetconduits
for gasnet_conduit_name in $gasnet_conduits; do
gasnet_conduit_path=$gasnet_home/include/$gasnet_conduit_name-conduit/
gasnet_conduit_name_uc=$(echo $gasnet_conduit_name | tr '[a-z]' '[A-Z]')
gasnet_conduit_makefile=$gasnet_conduit_path$gasnet_conduit_name-seq.mak
gasnet_conduit_cc=$(getmakevar $gasnet_conduit_makefile GASNET_CC)
gasnet_conduit_cppflags=$(getmakevar $gasnet_conduit_makefile GASNET_CPPFLAGS)
gasnet_conduit_cflags=$(getmakevar $gasnet_conduit_makefile GASNET_CFLAGS)
gasnet_conduit_ld=$(getmakevar $gasnet_conduit_makefile GASNET_LD)
gasnet_conduit_ldflags=$(getmakevar $gasnet_conduit_makefile GASNET_LDFLAGS)
gasnet_conduit_libs=$(getmakevar $gasnet_conduit_makefile GASNET_LIBS)
cat <<EOF >>./sac2crc.GASNetconduits
target distmem_gasnet_$gasnet_conduit_name::distmem_gasnet:
COMMLIB_CONDUIT := "$gasnet_conduit_name"
CC := "$gasnet_conduit_ld -std=gnu99"
CCLINK += "$gasnet_conduit_libs"
LDFLAGS += "$gasnet_conduit_ldflags"
target distmemcheck_gasnet_$gasnet_conduit_name::distmemcheck_gasnet:
COMMLIB_CONDUIT := "$gasnet_conduit_name"
CC := "$gasnet_conduit_ld -std=gnu99"
CCLINK += "$gasnet_conduit_libs"
LDFLAGS += "$gasnet_conduit_ldflags"
target distmemprofile_gasnet_$gasnet_conduit_name::distmemprofile_gasnet:
COMMLIB_CONDUIT := "$gasnet_conduit_name"
CC := "$gasnet_conduit_ld -std=gnu99"
CCLINK += "$gasnet_conduit_libs"
LDFLAGS += "$gasnet_conduit_ldflags"
EOF
cat <<EOF >>./config.GASNetconduits
GASNET_${gasnet_conduit_name_uc}_CC := $gasnet_conduit_cc -std=gnu99
GASNET_${gasnet_conduit_name_uc}_CPPFLAGS := $gasnet_conduit_cppflags
GASNET_${gasnet_conduit_name_uc}_CFLAGS := $gasnet_conduit_cflags
GASNET_${gasnet_conduit_name}_cap := $gasnet_conduit_name_uc
EOF
dnl Append the rules for the libsacdistmem GASNet object files to build.mkf
dnl At the places where we print \$$** or \$$*@ we want $* $@ to end up in the makefile.
dnl However, $* is replaced by an empty string and $@ by \, escaping does not help.
cat <<EOF >>./build.GASNetconduits
%.\$(\$(STYLE)_short).gasnet${gasnet_conduit_name}.o: %.c
@if [[ "compile \$(dir \$$**)" != "\`cat .make_track\`" ]] ; \\
then \$(ECHO) "compile \$(dir \$$**)" > .make_track; \\
\$(ECHO) ""; \\
\$(ECHO) "Compiling files in directory \$(PREFIX_LOCAL)\$(dir \$@)"; \\
fi
@\$(ECHO) " Compiling GasNET ${gasnet_conduit_name} \$(\$(STYLE)_long) code: \$(notdir \$<)"
\$(HIDE) \$(GASNET_${gasnet_conduit_name_uc}_CC) \\
\$(GASNET_${gasnet_conduit_name_uc}_CPPFLAGS) \$(GASNET_${gasnet_conduit_name_uc}_CFLAGS) \$(CC_FLAGS_\$(\$(STYLE)_cap)) \$(SETTINGS_\$(\$(STYLE)_cap)) \\
\$(CC_FLAGS_YY) \$(SETTINGS_DISTMEM) \$(SETTINGS_DISTMEM_GASNET) \\
\$(INCDIRS) -o \$$*@ -c \$<
@\$(CLOCK_SKEW_ELIMINATION)
EOF
dnl Append the rules for the libsacdistmem GASNet cross variant object files to build.mkf
dnl At the places where we print \$$** or \$$*@ we want $* $@ to end up in the makefile.
dnl However, $* is replaced by an empty string and $@ by \, escaping does not help.
cat <<EOF >>./build.GASNetconduitsCrossVariant
%.\$(\$(STYLE)_short)\$(CROSS_VARIANT).gasnet${gasnet_conduit_name}.o: %.c
@if [[ "compile \$(dir \$$**)" != "\`cat .make_track\`" ]] ; \\
then \$(ECHO) "compile \$(dir \$$**)" > .make_track; \\
\$(ECHO) ""; \\
\$(ECHO) "Compiling files in directory \$(PREFIX_LOCAL)\$(dir \$@)"; \\
fi
@\$(ECHO) " Compiling GasNET ${gasnet_conduit_name} \$(\$(STYLE)_long) code: \$(notdir \$<)"
\$(HIDE) \$(GASNET_${gasnet_conduit_name_uc}_CC) \\
\$(GASNET_${gasnet_conduit_name_uc}_CPPFLAGS) \$(GASNET_${gasnet_conduit_name_uc}_CFLAGS) \$(CC_FLAGS_\$(\$(STYLE)_cap)) \$(SETTINGS_\$(\$(STYLE)_cap)) \\
\$(CC_FLAGS_YY) \$(SETTINGS_DISTMEM) \$(SETTINGS_DISTMEM_GASNET) \\
\$(INCDIRS) -o \$$*@ -c \$<
@\$(CLOCK_SKEW_ELIMINATION)
EOF
done
])
AC_DEFUN([CHECK_DISTMEM_BACKEND], dnl
[
if test x"$enable_distmem_$1" != xno; then
expected=$enable_distmem_$1
$2
if test x"$expected" = xyes -a x"$enable_distmem_$1" = xno; then
AC_MSG_ERROR($3)
fi
fi
])
dnl check for Distributed Memory support
AC_DEFUN([CHECK_DISTMEM], dnl
[
DISTMEM_INIT_DEFAULTS
if test x"$enable_distmem" != xno; then
CHECK_DISTMEM_BACKEND([mpi], [CHECK_DISTMEM_MPI], [unable to find a working MPI back-end])
CHECK_DISTMEM_BACKEND([armci], [CHECK_DISTMEM_ARMCI], [AMRCI_HOME not set or ARMci directory not found])
CHECK_DISTMEM_BACKEND([gpi], [CHECK_DISTMEM_GPI], [GPI_HOME not set or GPI directory not found])
CHECK_DISTMEM_BACKEND([gasnet], [CHECK_DISTMEM_GASNET], [GASNET_HOME not set or directory not found or no GASnet conduits defined.])
if test x"$enable_distmem_gasnet" != xno; then
GASNET_INIT
fi
if test x"$enable_distmem_gasnet" = xno \
-a x"$enable_distmem_gpi" = xno \
-a x"$enable_distmem_mpi" = xno \
-a x"$enable_distmem_armci" = xno \
; then
if test x"$enable_distmem" != xauto; then
AC_MSG_ERROR([unable to find a suitable distmem back-end.])
fi
enable_distmem=no
else
enable_distmem=yes
fi
fi
AC_DEFINE_UNQUOTED([ENABLE_DISTMEM], [`test x"$enable_distmem" = xno && echo 0 || echo 1`],
[Define to 1 if distributed memory support is enabled, otherwise 0.])
AC_DEFINE_UNQUOTED([ENABLE_DISTMEM_GASNET], [`test x"$enable_distmem_gasnet" = xno && echo 0 || echo 1`],
[Define to 1 if GASNet conduit is supported, otherwise 0.])
AC_DEFINE_UNQUOTED([DISTMEM_GASNET_CONDUITS], ["$gasnet_conduits"],
[Available GASNet conduits.])
AC_DEFINE_UNQUOTED([ENABLE_DISTMEM_GPI], [`test x"$enable_distmem_gpi" = xno && echo 0 || echo 1`],
[Define to 1 if GPI conduit is supported, otherwise 0.])
AC_DEFINE_UNQUOTED([ENABLE_DISTMEM_MPI], [`test x"$enable_distmem_mpi" = xno && echo 0 || echo 1`],
[Define to 1 if MPI conduit is supported, otherwise 0.])
AC_DEFINE_UNQUOTED([ENABLE_DISTMEM_ARMCI], [`test x"$enable_distmem_armci" = xno && echo 0 || echo 1`],
[Define to 1 if ARMCI conduit is supported, otherwise 0.])
AC_SUBST([ENABLE_DISTMEM], [$enable_distmem])
AC_SUBST([ENABLE_DISTMEM_GASNET], [$enable_distmem_gasnet])
AC_SUBST([DISTMEM_GASNET_CONDUITS], [$gasnet_conduits])
AC_SUBST([ENABLE_DISTMEM_GPI], [$enable_distmem_gpi])
AC_SUBST([ENABLE_DISTMEM_MPI], [$enable_distmem_mpi])
AC_SUBST([ENABLE_DISTMEM_ARMCI], [$enable_distmem_armci])
])
dnl set the preferred file extension for shared libraries.
AC_DEFUN([CHECK_DLL_EXT],dnl
[
AC_REQUIRE([AC_CANONICAL_TARGET])
AC_MSG_CHECKING([for file name extension for dynamic libraries])
case "$target_os" in
*cygwin* | *windows* | *mingw*) dll_ext=.dll ;;
*darwin* ) dll_ext=.dylib ;;
* ) dll_ext=.so ;;
esac
AC_SUBST([SHARED_LIB_EXT], [$dll_ext])
AC_DEFINE_UNQUOTED([SHARED_LIB_EXT],
["$dll_ext"],
[File extension used for shared library files.])
AC_MSG_RESULT([$dll_ext])
])
dnl Searches for graphviz.
dnl defines DOT_FLAG to 0/1 and DOT_CMD to the program name
dnl may be overriden by user with DOT argument/envvar
AC_DEFUN([CHECK_GRAPHVIZ],dnl
[
AC_CHECK_PROGS([DOT], [dot], [no])
have_dot=`if test x"$DOT" = xno; then echo 0; else echo 1; fi`
AC_DEFINE_UNQUOTED([DOT_FLAG],
[$have_dot],
[Define to 1 to enable graphviz visualization, otherwise 0.])
AC_DEFINE_UNQUOTED([DOT_CMD],
["$DOT "], dnl SPACE IS IMPORTANT!
[Define to the command to use to invoke graphviz/dot, followed by a space.])
])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment