1
2dnl Set the directory that contains support scripts such as install-sh and
3dnl config.guess
4AC_CONFIG_AUX_DIR(../../../confdb)
5
6# Autoconf initialization:
7m4_include([../../../maint/version.m4])
8dnl 2nd arg is intentionally underquoted
9AC_INIT([MPD],
10        MPICH2_VERSION_m4,
11        [mpich-discuss@mcs.anl.gov],
12        [mpd],
13        [http://www.mcs.anl.gov/research/projects/mpich2/])
14
15# Autoconf header:
16rm -f ${srcdir}/mpdconf.h mpdconf.h
17AC_CONFIG_HEADER(mpdconf.h)
18AH_TOP([/* -*- Mode: C; c-basic-offset:4 ; -*- */
19/*
20 *  (C) 2001 by Argonne National Laboratory.
21 *      See COPYRIGHT in top-level directory.
22 */
23#ifndef MPDCONF_H_INCLUDED
24#define MPDCONF_H_INCLUDED
25])
26AH_BOTTOM([#endif])
27
28AM_INIT_AUTOMAKE([-Wall -Werror foreign 1.12.3 silent-rules subdir-objects no-installinfo no-installman])
29# first_pm_name is set and exported by the top level configure
30AM_CONDITIONAL([PRIMARY_PM_MPD],[test "X$first_pm_name" = "Xmpd"])
31
32dnl Process configure arguments
33AC_ARG_ENABLE(echo,
34   [--enable-echo - turn on echoing from within configure script],
35   set -x)
36CONFIGURE_ARGS="$*"
37if test -n "$CONFIGURE_ARGS" ; then
38    echo "Configuring with args $CONFIGURE_ARGS"
39fi
40AC_SUBST(COPTIONS)
41
42dnl Checks for programs.
43dnl Determine the executable and object file extensions.  These
44dnl are needed for some operations under cygwin
45AC_EXEEXT
46AC_OBJEXT
47# Checking for programs.
48PAC_PROG_CC
49AC_PROG_MAKE_SET
50AC_PROG_LN_S
51# A quick check to ensure that install-sh has the execute bit set
52# (we've had some problems with that)
53if test -f install.sh -a ! -x install.sh ; then chmod +x install.sh ; fi
54AC_PROG_INSTALL
55
56PAC_PROG_CHECK_INSTALL_WORKS
57
58if test "$installOk" = "no" ; then
59    # echo "RMB1: SETTING install"
60    INSTALL="${srcdir}/install.sh"
61fi
62echo Using INSTALL=$INSTALL
63
64AC_ARG_ENABLE(totalview,[--enable-totalview - turn on mpd-totalview support],,
65              enable_totalview=default )
66if test "$enable_totalview" = "no" ; then
67    DO_MTV="no"
68elif test "$enable_totalview" = "yes" ; then
69    DO_MTV="yes"
70else
71    AC_CHECK_PROG(TOTALVIEW, totalview, totalview)
72    if test -n "$TOTALVIEW" ; then
73        DO_MTV="yes"
74    fi
75fi
76AC_SUBST(DO_MTV)
77
78AC_ARG_WITH(python,
79            [--with-python=name - Specify a particular python to use for mpd],,
80            with_python="")
81PYTHON=$with_python
82# echo "GOT PYTHON", $PYTHON
83if test -z "$PYTHON" ; then  ## user did not give us a python; find one
84    dnl Find a Python
85    AC_CHECK_PROG(PY26, python2.6, python2.6)
86    AC_CHECK_PROG(PY25, python2.5, python2.5)
87    AC_CHECK_PROG(PY24, python2.4, python2.4)
88    AC_CHECK_PROG(PY23, python2.3, python2.3)
89    AC_CHECK_PROG(PY22, python2.2, python2.2)
90    AC_CHECK_PROG(PY2,  python2, python2)
91    AC_CHECK_PROG(PY,   python, python)
92    if test -z "$PY26"  -a  \
93            -z "$PY25"  -a  \
94            -z "$PY24"  -a  \
95            -z "$PY23"  -a  \
96            -z "$PY22"  -a  \
97            -z "$PY2"   -a  \
98            -z "$PY" ; then
99        AC_MSG_WARN([Could not find a python executable in path: $PATH])
100    fi
101    dnl See if one of the pythons has the right modules
102    for pypgm in $PY26 $PY25 $PY24 $PY23 $PY22 $PY2 $PY ; do \
103        AC_MSG_CHECKING([that $pypgm is a valid python version])
104        changequote(,)dnl
105        py_version=`$pypgm -c "import sys;print sys.version_info[0]"`
106        py_subversion=`$pypgm -c "import sys;print sys.version_info[1]"`
107        changequote([,])dnl
108        if test "$py_version" -gt "2" -o "$py_version" -ge "2" -a "$py_subversion" -ge "2" ; then
109            AC_MSG_RESULT(yes)
110        else
111            AC_MSG_RESULT(no)
112            continue
113        fi
114
115        AC_MSG_CHECKING([that the cPickle module is available for $pypgm])
116        if $pypgm -c 'from cPickle import dumps'  >/dev/null 2>&1 ; then
117            AC_MSG_RESULT(yes)
118        else
119            AC_MSG_RESULT(no)
120            continue
121        fi
122
123dnl        if test "$enable_totalview" = "yes" ; then
124dnl             AC_MSG_CHECKING([that $pypgm has development tools for totalview])
125dnl             has_python_sdk=no
126dnl             for python_homedir in /usr/lib64 /usr/lib32 /usr/lib ; do
127dnl                 if test -f $python_homedir/$pypgm/config/Makefile ; then
128dnl                     has_python_sdk=yes
129dnl                     break
130dnl                 fi
131dnl             done
132dnl             if test "$has_python_sdk" = "yes" ; then
133dnl                 AC_MSG_RESULT(yes)
134dnl             else
135dnl                 AC_MSG_RESULT(no)
136dnl                 continue
137dnl             fi
138dnl        fi
139
140        PYTHON="$pypgm"
141        break
142    done
143else  ### user-supplied with_python
144        dnl See if the user's python has the right modules
145	continue
146fi
147#
148if test -z "$PYTHON" ; then
149    AC_MSG_ERROR([Python required (version 2.2 or greater, with necessary modules)])
150fi
151
152CYGWIN_TEST=`uname -a | grep -i cygwin`
153if test -n "$CYGWIN_TEST" ; then
154    AC_MSG_CHECKING([that rebaseall is ok on this cygwin system])
155    echo
156    if ! $PYTHON -c 'from socket import socket ; from os import fork ; x = fork()'  >/dev/null 2>&1 ; then
157        AC_MSG_ERROR([*** fork may fail on this cygwin system; you may need to run rebaseall])
158    fi
159fi
160
161# echo "RMB PYTHON=" $PYTHON
162AC_SUBST(PYTHON)
163
164
165# In case clinker is not defined
166if test -z "$CLINKER" ; then
167    CLINKER="$CC"
168    AC_SUBST(CLINKER)
169fi
170
171dnl Checks for libraries.
172# Searching libraries instead of checking
173AC_SEARCH_LIBS(socket, socket)
174
175dnl Checks for header files.
176# Checking headers
177AC_HEADER_STDC
178AC_HEADER_SYS_WAIT
179# sys/param.h for MAXHOSTNAMELEN
180AC_CHECK_HEADERS(fcntl.h strings.h sys/time.h unistd.h stdlib.h sys/param.h)
181
182dnl Checks for library functions.
183# Checking library functions
184AC_CHECK_FUNCS(putenv socket)
185
186AC_CHECK_FUNCS(snprintf)
187if test "$ac_cv_func_snprintf" = "yes" ; then
188     PAC_FUNC_NEEDS_DECL([#include <stdio.h>],snprintf)
189fi
190
191dnl Output:
192# Starting output
193MPD_HOME=`pwd`
194AC_SUBST(MPD_HOME)
195
196# AC_OUTPUT_COMMANDS(chmod +x startdaemons)
197AC_OUTPUT(Makefile)
198