| 1 | # |
|---|
| 2 | # This file is part of the McStas neutron ray-trace simulation package |
|---|
| 3 | # Copyright (C) 1997-2008, All rights reserved |
|---|
| 4 | # Risoe National Laborartory, Roskilde, Denmark |
|---|
| 5 | # Institut Laue Langevin, Grenoble, France |
|---|
| 6 | # |
|---|
| 7 | # This program is free software; you can redistribute it and/or modify |
|---|
| 8 | # it under the terms of the GNU General Public License as published by |
|---|
| 9 | # the Free Software Foundation; version 2 of the License. |
|---|
| 10 | # |
|---|
| 11 | # This program is distributed in the hope that it will be useful, |
|---|
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | # GNU General Public License for more details. |
|---|
| 15 | # |
|---|
| 16 | # You should have received a copy of the GNU General Public License |
|---|
| 17 | # along with this program; if not, write to the Free Software |
|---|
| 18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 19 | # |
|---|
| 20 | dnl Process this file with autoconf to produce a configure script. |
|---|
| 21 | |
|---|
| 22 | AC_INIT(McStas, 1.12c, www.mcstas.org) |
|---|
| 23 | AC_REVISION($Revision: 1.58 $) |
|---|
| 24 | AC_COPYRIGHT([Copyright (C) 1997-2011 Copyright (C) 1997-2011, All rights reserved |
|---|
| 25 | Risoe National Laborartory, Roskilde, Denmark |
|---|
| 26 | Institut Laue Langevin, Grenoble, France |
|---|
| 27 | This software is covered by the GNU LESSER GENERAL PUBLIC LICENSE |
|---|
| 28 | see file COPYING for further information]) |
|---|
| 29 | |
|---|
| 30 | AC_ARG_WITH([cc], AC_HELP_STRING([--with-cc=c compiler], [Specify name of C compiler]), |
|---|
| 31 | [with_cc=$withval], [with_cc=yes]) |
|---|
| 32 | if test x"$with_cc" != x"no" ; then |
|---|
| 33 | if test x"$with_cc" != x"yes" ; then CC="$with_cc"; fi |
|---|
| 34 | AC_PROG_CC |
|---|
| 35 | else |
|---|
| 36 | AC_MSG_ERROR([You need a C compiler to compile this package]) |
|---|
| 37 | fi |
|---|
| 38 | |
|---|
| 39 | AC_PROG_INSTALL |
|---|
| 40 | CF_ANSI_CC_CHECK |
|---|
| 41 | MC_ANSI_MATH_PROTO |
|---|
| 42 | AC_FUNC_MALLOC |
|---|
| 43 | AC_FUNC_REALLOC |
|---|
| 44 | AC_FUNC_STRTOD |
|---|
| 45 | AC_CHECK_FUNCS(strcasecmp fdopen qsort) |
|---|
| 46 | |
|---|
| 47 | AC_PATH_PROGS(PERL, [perl5 perl /usr/bin/perl /usr/local/bin/perl], no) |
|---|
| 48 | AC_PATH_PROGS(SCILAB, [scilab runscilab /usr/local/bin/scilab /usr/lib/scilab/bin/scilab /lib/scilab/bin/scilab scilex], no) |
|---|
| 49 | AC_PATH_PROGS(MATLAB, [matlab /usr/local/bin/matlab], no) |
|---|
| 50 | AC_PATH_PROGS(GNUPLOT, [gnuplot /usr/local/bin/gnuplot], no) |
|---|
| 51 | AC_PATH_PROGS(PGPLOT, [pgxwin_server /usr/local/bin/pgxwin_server /usr/local/pgplot/pgxwin_server], no) |
|---|
| 52 | AC_PATH_PROGS(TCLTK, [wish /usr/local/bin/wish tclsh], no) |
|---|
| 53 | AC_PATH_PROGS(SSH, [ssh plink /usr/local/bin/ssh], no) |
|---|
| 54 | AC_PATH_PROGS(SCP, [scp pscp /usr/local/bin/scp], no) |
|---|
| 55 | AC_PATH_PROGS(DASH, [dash /bin/dash /usr/bin/dash], no) |
|---|
| 56 | AC_PATH_PROGS(MPIRUN, [mpirun /usr/local/bin/mpirun], no) |
|---|
| 57 | AC_PATH_PROGS(MPICC, [mpicc hcc mpxlc_r mpxlc mpcc cmpicc /usr/local/bin/mpicc], no) |
|---|
| 58 | AC_PATH_PROGS(BROWSER,[konqueror firefox mozilla-firefox mozilla netscape gnome-open epiphany galeon start msie /Applications/Safari.app/Contents/MacOS/Safari /Applications/Firefox.app/Contents/MacOS/firefox], no) |
|---|
| 59 | AC_PATH_PROGS(EDITOR, [nedit kate gedit xemacs xedit vim notepad wordpad], no) |
|---|
| 60 | AC_PATH_PROGS(VRMLVIEW, [octagaplayer freewrl gtklookat qtlookat xmlookat maclookat fltklookat lookat], no) |
|---|
| 61 | AC_PATH_PROGS(WGET, [wget], no) |
|---|
| 62 | AC_PATH_PROGS(PERLDL, [perldl /usr/local/bin/perldl /usr/bin/perldl], no) |
|---|
| 63 | AC_PATH_PROGS(G77, [g77 f77 gfortran g95 f95], no) |
|---|
| 64 | AC_PATH_PROGS(MINGW, [i586-mingw32msvc-gcc], no) |
|---|
| 65 | AC_PATH_PROGS(MAKE, [make gmake], no) |
|---|
| 66 | AC_PATH_PROGS(AT, [at], no) |
|---|
| 67 | AC_PATH_PROGS(HDFVIEW, [hdfview /usr/local/bin/hdfview /usr/local/hdfview/hdfview], no) |
|---|
| 68 | # Important here: gnome-terminal is broken: |
|---|
| 69 | # Any commandline arguments after -e must contain escaped spaces. |
|---|
| 70 | # BUT: If escaped in the perl code, use of xterm/konsole is broken.... |
|---|
| 71 | # Hence we allow only gnome-terminal.wrapper which is debian only |
|---|
| 72 | # :( |
|---|
| 73 | AC_PATH_PROGS(TERMINAL, [xterm konsole gnome-terminal.wrapper], no) |
|---|
| 74 | |
|---|
| 75 | # handle PIC options |
|---|
| 76 | AC_ARG_WITH([pic], |
|---|
| 77 | [AS_HELP_STRING([--with-pic], |
|---|
| 78 | [enable support for PIC libraries (required to compile PGPLOT on some systems)])], |
|---|
| 79 | [USE_PIC=$withval], |
|---|
| 80 | [USE_PIC=no]) |
|---|
| 81 | AC_SUBST(USE_PIC) |
|---|
| 82 | |
|---|
| 83 | # check for OpenMP threads and option to use at compile |
|---|
| 84 | AC_CHECK_HEADER(omp.h, [ HAVE_THREADS=yes ]) |
|---|
| 85 | if test "$HAVE_THREADS" = yes; then |
|---|
| 86 | # test flag to use for compilation |
|---|
| 87 | 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 |
|---|
| 88 | ax_cv_[]_AC_LANG_ABBREV[]_openmp=unknown |
|---|
| 89 | # Flags to try: -fopenmp (gcc), -openmp (icc), -mp (SGI & PGI), |
|---|
| 90 | # -xopenmp (Sun), -omp (Tru64), -qsmp=omp (AIX), none |
|---|
| 91 | ax_openmp_flags="-fopenmp -openmp -mp -xopenmp -omp -qsmp=omp none" |
|---|
| 92 | if test "x$OPENMP_[]_AC_LANG_PREFIX[]FLAGS" != x; then |
|---|
| 93 | ax_openmp_flags="$OPENMP_[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flags" |
|---|
| 94 | fi |
|---|
| 95 | for ax_openmp_flag dnl will test flags to pass to compiler |
|---|
| 96 | in "-fopenmp -lgomp" dnl gcc 4.2 with explicit libgomp |
|---|
| 97 | "-fopenmp " dnl gcc 4.2 |
|---|
| 98 | "-openmp -parallel" dnl icc with explicit parallel flag |
|---|
| 99 | "-openmp " dnl icc |
|---|
| 100 | "-mp" dnl pgi |
|---|
| 101 | "-xopenmp" dnl Sun |
|---|
| 102 | "-omp" dnl Tru64 |
|---|
| 103 | "-qsmp=omp" dnl AIX |
|---|
| 104 | "none" dnl no openmp |
|---|
| 105 | "$OPENMP_[]_AC_LANG_PREFIX[]FLAGS" dnl flags defined by user |
|---|
| 106 | # |
|---|
| 107 | do |
|---|
| 108 | case $ax_openmp_flag in |
|---|
| 109 | none) []_AC_LANG_PREFIX[]FLAGS=$save[]_AC_LANG_PREFIX[] ;; |
|---|
| 110 | *) []_AC_LANG_PREFIX[]FLAGS="$save[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flag" ;; |
|---|
| 111 | esac |
|---|
| 112 | AC_TRY_LINK_FUNC(omp_set_num_threads, |
|---|
| 113 | [ax_cv_[]_AC_LANG_ABBREV[]_openmp=$ax_openmp_flag; break]) |
|---|
| 114 | done |
|---|
| 115 | []_AC_LANG_PREFIX[]FLAGS=$save[]_AC_LANG_PREFIX[]FLAGS |
|---|
| 116 | ]) # end AC_CACHE_CHECK |
|---|
| 117 | if test "x$ax_cv_[]_AC_LANG_ABBREV[]_openmp" != "xnone"; then |
|---|
| 118 | OPENMP_[]_AC_LANG_PREFIX[]FLAGS=$ax_cv_[]_AC_LANG_ABBREV[]_openmp |
|---|
| 119 | fi |
|---|
| 120 | # now set DEFINE for mcstas_config |
|---|
| 121 | AC_SUBST([HAVE_THREADS], ["-DUSE_THREADS $OPENMP_CFLAGS "]) |
|---|
| 122 | AC_DEFINE([HAVE_THREADS], ["-DUSE_THREADS $OPENMP_CFLAGS "]) |
|---|
| 123 | else |
|---|
| 124 | AC_SUBST([HAVE_THREADS], []) |
|---|
| 125 | AC_DEFINE([HAVE_THREADS], []) |
|---|
| 126 | fi |
|---|
| 127 | |
|---|
| 128 | # check for MPI |
|---|
| 129 | if test "$MPICC" != "no"; then |
|---|
| 130 | AC_CHECK_HEADER(mpi.h, , [ echo "WARNING: $MPICC may fail to compile without mpi.h" ] ) |
|---|
| 131 | fi |
|---|
| 132 | |
|---|
| 133 | # check for NeXus libraries |
|---|
| 134 | AC_ARG_WITH([nexus], |
|---|
| 135 | [AS_HELP_STRING([--with-nexus], |
|---|
| 136 | [enable support for NeXus/HDF libraries])]) |
|---|
| 137 | if test "${with_nexus+set}" = set; then |
|---|
| 138 | AC_SUBST([HAVE_NEXUS], ["-DUSE_NEXUS -lNeXus "]) |
|---|
| 139 | AC_DEFINE([HAVE_NEXUS], ["-DUSE_NEXUS -lNeXus "]) |
|---|
| 140 | else |
|---|
| 141 | AC_SUBST([HAVE_NEXUS], []) |
|---|
| 142 | AC_DEFINE([HAVE_NEXUS], []) |
|---|
| 143 | fi |
|---|
| 144 | |
|---|
| 145 | AC_OUTPUT(Makefile lib/tools/perl/mcstas_config.perl support/pgplot/pgplot.sh support/scilab/scilab.sh) |
|---|
| 146 | |
|---|
| 147 | chmod a+x support/pgplot/pgplot.sh |
|---|
| 148 | chmod a+x support/scilab/scilab.sh |
|---|
| 149 | chmod a+x lib/tools/perl/mcstas_reconfigure |
|---|
| 150 | |
|---|
| 151 | # warnings and errors |
|---|
| 152 | if test "$MAKE" == "no" ; then |
|---|
| 153 | echo "ERROR: McStas installation requires 'make' or 'gmake'" |
|---|
| 154 | exit |
|---|
| 155 | fi |
|---|
| 156 | |
|---|
| 157 | if test "$PERL" = "no" ; then |
|---|
| 158 | echo "WARNING: No Perl executable could be found !" |
|---|
| 159 | echo "You will have to use" |
|---|
| 160 | echo " mcstas <file>.instr" |
|---|
| 161 | echo " $CC -o <file>.out <file>.instr -lm" |
|---|
| 162 | echo " <file>.out [simulation parameters]" |
|---|
| 163 | fi |
|---|
| 164 | if test "$TCLTK" = "no" ; then |
|---|
| 165 | echo "WARNING: No Tcl/Tk installation could be found !" |
|---|
| 166 | echo "You might not be able to use McGUI interface" |
|---|
| 167 | fi |
|---|
| 168 | if test "$BROWSER" = "no" ; then |
|---|
| 169 | echo "WARNING: No HTML browser could be found !" |
|---|
| 170 | fi |
|---|
| 171 | if test "$SCILAB" == "no" && test "$MATLAB" == "no" && test "$PGPLOT" == "no" && test "$VRMLVIEW" == "no" ; then |
|---|
| 172 | echo "WARNING: No Plotter (Matlab, Scilab, PGPLOT, VRML) could be found !" |
|---|
| 173 | fi |
|---|
| 174 | |
|---|
| 175 | # final message at end of configure |
|---|
| 176 | if test "$USE_PIC" != "no" ; then |
|---|
| 177 | echo "Activating PIC compilation for: make install-pgplot" |
|---|
| 178 | fi |
|---|
| 179 | if test "x$HAVE_NEXUS" != "x" ; then |
|---|
| 180 | echo "Activating NeXus support in McStas ($HAVE_NEXUS)" |
|---|
| 181 | fi |
|---|
| 182 | if test "x$HAVE_THREADS" != "x" ; then |
|---|
| 183 | echo "Activating OpenMP multi-threading support in McStas ($HAVE_THREADS)" |
|---|
| 184 | fi |
|---|
| 185 | echo "" |
|---|
| 186 | if test "$WGET" != no ; then |
|---|
| 187 | echo "Gnome support: If you experience crashes of mcgui when running in the " |
|---|
| 188 | echo " Gnome environment, please come back here and do a" |
|---|
| 189 | echo "# make tk" |
|---|
| 190 | echo "will install our patched version of perl-tk from the net" |
|---|
| 191 | fi |
|---|
| 192 | if test "$PGPLOT" == "no" ; then |
|---|
| 193 | echo "To install PGPLOT for McStas, you need:" |
|---|
| 194 | echo "= perl-PDL (perldl, pdl)" |
|---|
| 195 | echo "= a fortran compiler (g77, gfortran)" |
|---|
| 196 | echo "= X11-dev libraries/includes (libx11-dev, xserver-xorg-dev, libxt-dev)" |
|---|
| 197 | fi |
|---|
| 198 | if test "$PGPLOT" == "no" && test "$PERLDL" != "no" && test "$G77" != "no" ; then |
|---|
| 199 | echo "PGPLOT install: you may try our automatic PGPLOT installation with" |
|---|
| 200 | echo "# make install-pgplot; ./configure; make; make install" |
|---|
| 201 | echo "(For 64-bit machines, reconfigure first: # ./configure --with-pic )" |
|---|
| 202 | else if test "$PGPLOT" == "no" ; then |
|---|
| 203 | echo "Install these and re-run McStas installation ./configure" |
|---|
| 204 | fi |
|---|
| 205 | fi |
|---|
| 206 | if test "$SCILAB" == "no" ; then |
|---|
| 207 | echo "Scilab install: you may try our automatic Scilab installation with" |
|---|
| 208 | echo "" |
|---|
| 209 | echo "# make install-scilab; ./configure; make; make install" |
|---|
| 210 | echo "" |
|---|
| 211 | echo "(requires Linux/Intel, wget and root priviliges)" |
|---|
| 212 | fi |
|---|
| 213 | echo "" |
|---|
| 214 | echo "To setup the plotting environment, execute either" |
|---|
| 215 | echo "# make config (automatically selects plotter, " |
|---|
| 216 | echo " prefers PGPLOT before Matlab before Scilab before VRML)" |
|---|
| 217 | if test "$SCILAB" != "no" ; then |
|---|
| 218 | echo "# make scilab (selects scilab)" |
|---|
| 219 | fi |
|---|
| 220 | if test "$MATLAB" != "no" ; then |
|---|
| 221 | echo "# make matlab (selects matlab)" |
|---|
| 222 | fi |
|---|
| 223 | if test "$PGPLOT" != "no" ; then |
|---|
| 224 | echo "# make pgplot (selects pgplot)" |
|---|
| 225 | fi |
|---|
| 226 | if test "$VRMLVIEW" != "no" ; then |
|---|
| 227 | echo "# make vrml (selects vrml)" |
|---|
| 228 | fi |
|---|
| 229 | echo "" |
|---|
| 230 | echo "After (optional) plotter config, build and install McStas by executing" |
|---|
| 231 | echo "# make; make install" |
|---|
| 232 | echo "" |
|---|
| 233 | if test "$DASH" != "no" ; then |
|---|
| 234 | echo |
|---|
| 235 | echo WARNING: Your system includes the $DASH shell which is known to cause problems. |
|---|
| 236 | echo On Debian/Ubuntu systems, please dpkg-reconfigure dash and say 'no' to install dash as /bin/sh |
|---|
| 237 | fi |
|---|