Snapshot
[openmx:openmx.git] / configure.ac
1 AC_INIT(OpenMx, 0.1)
2 AC_PREREQ([2.62])
3 AC_CONFIG_AUX_DIR("inst/tools")
4
5 npsol_library='inst/npsol'
6
7 : ${R_HOME:=`R RHOME`}
8 if test -z "${R_HOME}"; then 
9 echo "could not determine R_HOME" 
10 exit 1 
11 fi 
12
13 # check for gcc compiler
14 AC_LANG(C++)
15 AC_PROG_CC
16 AS_IF([test "x$enable_openmp" != "xno"], [
17 AC_OPENMP
18 ])
19 AC_MSG_CHECKING(whether gcc is installed)
20 if test "$GCC" != yes; then
21 AC_MSG_RESULT(no)
22 AC_MSG_ERROR(gcc is not the default C compiler)
23 compiler_specific_flags=""
24 else
25 AC_MSG_RESULT(yes)
26 compiler_specific_flags="-Wall"
27 fi
28
29 # check the host type
30 AC_CANONICAL_HOST
31 case "${host_os}" in
32 linux-gnu*) 
33     omx_platform=linux 
34     arch_specific_linker_flags=""
35     arch_specific_compiler_flags=""
36     ;;
37 darwin*) 
38     omx_platform=osx 
39     arch_specific_linker_flags="-mmacosx-version-min=10.4"
40     arch_specific_compiler_flags="-mmacosx-version-min=10.4"
41     ;;
42 *) AC_MSG_ERROR(host os is not recognized: ${host_os}) ;;
43 esac
44
45 case "${omx_platform}" in
46 linux)
47    case "${host_cpu}" in
48    *86) omx_arch=x86 ;;
49    *86_64) omx_arch=x86_64 ;;
50    *) AC_MSG_ERROR(host arch is not recognized: ${host_cpu}) ;;
51    esac
52
53    # check for gcc version number
54    AX_GCC_VERSION
55    AC_PROG_AWK
56    major_release=`echo "$GCC_VERSION" | $AWK -F '.' '{print $1 "." $2}'`
57    npsol_library="${npsol_library}/linux/${omx_arch}/gcc${major_release}"
58 ;;
59 osx)
60    npsol_library="${npsol_library}/osx"
61 ;;
62 *)
63    AC_MSG_ERROR(openmx platform is not recognized: ${omx_platform})
64 esac
65
66 npsol_file="${npsol_library}/libnpsol.a"
67 AC_CHECK_FILE([${npsol_file}],,[AC_MSG_ERROR([npsol library not found])])
68
69 npsol_dir="../${npsol_library}"
70 AC_SUBST(npsol_dir)
71 AC_SUBST(compiler_specific_flags)
72 AC_SUBST(arch_specific_linker_flags)
73 AC_SUBST(arch_specific_compiler_flags)
74 AC_SUBST(OPENMP_CXXFLAGS)
75 AC_CONFIG_FILES([src/Makevars])
76
77 AC_CONFIG_COMMANDS([src/omxSymbolTable.h],[${R_HOME}/bin/R --slave --vanilla < inst/tools/genSymbolTableHeader.R  > src/omxSymbolTable.h],[R_HOME=${R_HOME}])
78 AC_CONFIG_COMMANDS([src/omxSymbolTable.cpp],[${R_HOME}/bin/R --slave --vanilla < inst/tools/genSymbolTableSource.R  > src/omxSymbolTable.cpp],[R_HOME=${R_HOME}])
79 AC_OUTPUT