configure.in 4.98 KB
Newer Older
Ken Martin's avatar
Ken Martin committed
1 2 3 4 5
# Process this file with autoconf to produce a configure script.
AC_INIT()

AC_CONFIG_HEADER(Source/cmConfigure.h)

6

Ken Martin's avatar
Ken Martin committed
7 8 9 10

#
# check for some programs we use
#
11 12 13 14 15 16

# save the CFLAGS and CXXFLAGS specified by the user
save_CFLAGS=$CFLAGS
save_CXXFLAGS=$CXXFLAGS

# let autoconf find cc and CC, it will try to add -g -O2 to CFLAGS and CXXFLAGS
Ken Martin's avatar
Ken Martin committed
17 18 19
AC_PROG_CC
AC_PROG_CXX

20 21 22 23 24
# restore the flags specified by the user and get rid of any flags
# found by autoconf (we do not want -02 -g by default)
CFLAGS=$save_CFLAGS
CXXFLAGS=$save_CXXFLAGS

Ken Martin's avatar
Ken Martin committed
25 26 27 28
fullSrcDir=`cd $srcdir; pwd`
CMAKE_ROOT_DIR=$fullSrcDir
AC_SUBST(CMAKE_ROOT_DIR)

Bill Hoffman's avatar
Bill Hoffman committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

# Step 1: set the variable "system" to hold the name and version number
# for the system.  This can usually be done via the "uname" command, but
# there are a few systems, like Next, where this doesn't work.

AC_MSG_CHECKING([system version (for dynamic loading)])
if test -f /usr/lib/NextStep/software_version; then
  system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
else
    system=`uname -s`-`uname -r`
    if test "$?" -ne 0 ; then
	AC_MSG_RESULT([unknown (can't find uname command)])
	system=unknown
    else
	# Special check for weird MP-RAS system (uname returns weird
	# results, and the version is kept in special file).
    
	if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
	    system=MP-RAS-`awk '{print $3}' /etc/.relid'`
	fi
	AC_MSG_RESULT($system)
    fi
fi

53 54 55 56 57 58 59 60 61 62 63

CMAKE_CONFIG_DIR=`pwd`
AC_SUBST(CMAKE_CONFIG_DIR)
case $system in 
	CYGWIN_NT*)
		CMAKE_CONFIG_DIR=`pwd`
		CMAKE_CONFIG_DIR="\"$CMAKE_CONFIG_DIR\""
	;;
esac


Ken Martin's avatar
Ken Martin committed
64
CMAKE_ANSI_CFLAGS=""
65
CMAKE_ANSI_CXXFLAGS=""
Ken Martin's avatar
Ken Martin committed
66 67 68 69
# on hp use -Aa for ansi
if test $ac_cv_prog_gxx = no; then
case $system in
    HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
70 71 72 73 74 75 76 77 78 79 80 81
        CFLAGS_ORIG="$FLAGS"
        CFLAGS="-Aa $CFLAGS"
        AC_MSG_CHECKING([whether ${CC} accepts -Aa])
        AC_TRY_COMPILE([
        void foo() {}
        ],,[
        AC_MSG_RESULT(yes)
        CMAKE_ANSI_CFLAGS="$CMAKE_ANSI_CFLAGS -Aa"
        ],[
        AC_MSG_RESULT(no)
        ])
        CFLAGS="$CFLAGS_ORIG"
82
	;;  
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
     IRIX-5* | IRIX-6* | IRIX64-6* | IRIX-64-6*)
        CXXFLAGS_ORIG="$CXXFLAGS"
        CXXFLAGS="-LANG:std $CXXFLAGS"
        AC_MSG_CHECKING([whether ${CXX} accepts -LANG:std])
        AC_LANG_SAVE
        AC_LANG_CPLUSPLUS
        AC_TRY_COMPILE([
        void foo() {}
        ],,[
        AC_MSG_RESULT(yes)
        CMAKE_ANSI_CXXFLAGS="-LANG:std"
        ],[
        AC_MSG_RESULT(no)
        ])
        AC_LANG_RESTORE
        CXXFLAGS="$CXXFLAGS_ORIG"
	;;
100 101
     OSF1-*)

102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
        CXXFLAGS_ORIG="$CXXFLAGS"
        CXXFLAGS="-std strict_ansi -nopure_cname $CXXFLAGS"
        AC_MSG_CHECKING([whether ${CXX} accepts -std strict_ansi -nopure_cname])
        AC_LANG_SAVE
        AC_LANG_CPLUSPLUS
        AC_TRY_COMPILE([
        void foo() {}
        ],,[
        AC_MSG_RESULT(yes)
        CMAKE_ANSI_CXXFLAGS="-std strict_ansi -nopure_cname"
        ],[
        AC_MSG_RESULT(no)
        ])
        AC_LANG_RESTORE
        CXXFLAGS="$CXXFLAGS_ORIG"
	;;
Ken Martin's avatar
Ken Martin committed
118 119 120
esac
fi
AC_SUBST(CMAKE_ANSI_CFLAGS)
121
AC_SUBST(CMAKE_ANSI_CXXFLAGS)
Ken Martin's avatar
Ken Martin committed
122

123
# check non-g++ compilers to see if they have the standard 
Ken Martin's avatar
Ken Martin committed
124 125
# ansi stream files (without the .h)
if test $ac_cv_prog_gxx = no; then
126 127
  CXXFLAGS_ORIG="$CXXFLAGS"
  CXXFLAGS="$CMAKE_ANSI_CXXFLAGS $CXXFLAGS"
Ken Martin's avatar
Ken Martin committed
128
  AC_MSG_CHECKING( ansi standard C++ stream headers ) 
129 130 131 132 133 134 135 136 137 138 139 140
  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  AC_TRY_COMPILE([
  #include <iostream>
  ],,[
  AC_MSG_RESULT(yes)
  ],[
  CMAKE_NO_ANSI_STREAM_HEADERS=1
  AC_MSG_RESULT(no)
  ])
  AC_LANG_RESTORE
  CXXFLAGS="$CXXFLAGS_ORIG"
Ken Martin's avatar
Ken Martin committed
141 142
fi

143
# check non-g++ compilers to see if they have std::stringstream
144 145 146 147 148 149
CXXFLAGS_ORIG="$CXXFLAGS"
CXXFLAGS="$CMAKE_ANSI_CXXFLAGS $CXXFLAGS"
AC_MSG_CHECKING([for ansi standard C++ stringstream])
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([
150
#include <sstream>
151 152 153 154 155 156 157 158
],,[
AC_MSG_RESULT(yes)
],[
CMAKE_NO_ANSI_STRING_STREAM=1
AC_MSG_RESULT(no)
])
AC_LANG_RESTORE
CXXFLAGS="$CXXFLAGS_ORIG"
159

Ken Martin's avatar
Ken Martin committed
160 161
# check to see if stl is in the std namespace
if test $ac_cv_prog_gxx = no; then
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
  CXXFLAGS_ORIG="$CXXFLAGS"
  CXXFLAGS="$CMAKE_ANSI_CXXFLAGS $CXXFLAGS"
  AC_MSG_CHECKING([whether the std namespace is supported])
  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  AC_TRY_COMPILE([
  #include <list>
  void foo() { std::list<int>(); }
  ],,[
  AC_MSG_RESULT(yes)
  ],[
  CMAKE_NO_STD_NAMESPACE=1
  AC_MSG_RESULT(no)
  ])
  AC_LANG_RESTORE
  CXXFLAGS="$CXXFLAGS_ORIG"
Ken Martin's avatar
Ken Martin committed
178 179
fi

180 181
# check to see if for scoping is supported
if test $ac_cv_prog_gxx = no; then
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
  CXXFLAGS_ORIG="$CXXFLAGS"
  CXXFLAGS="$CMAKE_ANSI_CXXFLAGS $CXXFLAGS"
  AC_MSG_CHECKING([ansi for scope support])
  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  AC_TRY_COMPILE([
  void foo() { for(int i;;); for(int i;;); }
  ],,[
  AC_MSG_RESULT(yes)
  ],[
  CMAKE_NO_ANSI_FOR_SCOPE=1
  AC_MSG_RESULT(no)
  ])
  AC_LANG_RESTORE
  CXXFLAGS="$CXXFLAGS_ORIG"
197 198
fi

199 200
# find make to use to build cmake, prefer gmake
AC_PATH_PROGS(RUNMAKE, gmake make)
Ken Martin's avatar
Ken Martin committed
201

Andy Cedilnik's avatar
Andy Cedilnik committed
202
AC_OUTPUT(Source/InitialConfigureFlags.cmake Makefile Source/Makefile)
Bill Hoffman's avatar
Bill Hoffman committed
203
# build cmake
Andy Cedilnik's avatar
Andy Cedilnik committed
204
$RUNMAKE 
Bill Hoffman's avatar
Bill Hoffman committed
205
# run cmake 
Andy Cedilnik's avatar
Andy Cedilnik committed
206
./Source/cmake $fullSrcDir
Bill Hoffman's avatar
Bill Hoffman committed
207 208
# run cmake depends
$RUNMAKE depend