root/configure.ac

Revision 620d0bc9171778d792155d20f01b9ea0599ea1de, 6.2 KB (checked in by David I. Lehn <dlehn@…>, 16 months ago)

Slight improvement in Python version detection.

Systems with just a single python version from 2.4 to 2.7 should now
work. Code could still use improvement.

  • Property mode set to 100644
Line 
1# Configure script for Digital Bazaar librdfa library
2# Usage: Run ./configure once
3#
4# This file is part of librdfa.
5#
6# librdfa is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Lesser General Public License as
8# published by the Free Software Foundation, either version 3 of the
9# License, or (at your option) any later version.
10#
11# librdfa 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 Lesser General Public
17# License along with librdfa. If not, see <http://www.gnu.org/licenses/>.
18#
19# Author: Manu Sporny
20
21AC_INIT(librdfa, 0.18, support@digitalbazaar.com)
22AC_CONFIG_AUX_DIR(setup)
23
24# Setup standard build environment variables
25RDFADIR=`pwd`
26RELEASE=`date +%Y%m%d`
27
28# Check for particular build options
29# Check for particular build options
30AC_ARG_ENABLE([linux],
31   AS_HELP_STRING([--enable-linux], [compile for linux [[yes]]]),
32   [
33      case "${enableval}" in
34         yes) BUILD_FOR_LINUX=yes ;;
35         no) BUILD_FOR_LINUX=no ;;
36         *) AC_MSG_ERROR(bad value ${enableval} for --enable-linux) ;;
37      esac
38   ], [BUILD_FOR_LINUX=yes])  dnl Default value
39
40AC_ARG_ENABLE([windows],
41   AS_HELP_STRING([--enable-windows], [compile for windows [[no]]]),
42   [
43      case "${enableval}" in
44         yes) BUILD_FOR_WINDOWS=yes ;;
45         no) BUILD_FOR_WINDOWS=no ;;
46         *) AC_MSG_ERROR(bad value ${enableval} for --enable-windows) ;;
47      esac
48   ], [BUILD_FOR_WINDOWS=no])  dnl Default value
49
50AC_ARG_ENABLE([macos],
51   AS_HELP_STRING([--enable-macos], [compile for MacOS [[no]]]),
52   [
53      case "${enableval}" in
54         yes) BUILD_FOR_MACOS=yes ;;
55         no) BUILD_FOR_MACOS=no ;;
56         *) AC_MSG_ERROR(bad value ${enableval} for --enable-macos) ;;
57      esac
58   ], [BUILD_FOR_MACOS=no])  dnl Default value
59
60AC_ARG_ENABLE([python],
61               AC_HELP_STRING([--enable-python],
62                              [compile extensions for Python (default is NO)]),
63              [ac_enable_python_build=yes], [ac_enable_python_build=no])
64
65AC_ARG_ENABLE([docs],
66               AC_HELP_STRING([--enable-docs],
67                              [build documentation (default is NO)]),
68              [ac_enable_docs_build=yes], [ac_enable_docs_build=no])
69
70echo -e "\n--------- Configuring librdfa Build Environment -----------"
71
72# Check the system type
73AC_CANONICAL_BUILD()
74AC_CANONICAL_HOST()
75AC_CANONICAL_SYSTEM()
76OS="$build_os"
77
78# Checking for standard build tools
79#AC_LANG(C++)
80AC_PROG_INSTALL()
81
82# Conditional setup for Windows build
83if test "$BUILD_FOR_WINDOWS" = "yes" ; then
84   BUILD_FOR_LINUX="no"
85   BUILD_FOR_MACOS="no"
86   AC_CHECK_PROGS(CC, i586-mingw32msvc-gcc gcc, not found)
87   AC_CHECK_PROGS(AR, i586-mingw32msvc-ar ar, not found)
88   AC_CHECK_PROGS(AS, i586-mingw32msvc-as as, not found)
89   EXPAT_INCLUDE_DIRECTORY="$RDFADIR/3rdparty/expat/include"
90   EXPAT_LIB_DIRECTORY="$RDFADIR/3rdparty/expat"
91   OS="mingw32"
92fi
93
94# Conditional setup for MacOS build
95if test "$BUILD_FOR_MACOS" = "yes" ; then
96   BUILD_FOR_LINUX="no"
97   BUILD_FOR_WINDOWS="no"
98   AC_PROG_CC()
99   AC_CHECK_PROG(AR, ar, ar, not found)
100   AC_CHECK_PROG(AS, as, as, not found)
101   EXPAT_INCLUDE_DIRECTORY="/opt/local/include"
102   EXPAT_LIB_DIRECTORY="/opt/local/lib"
103   OS="macos"
104fi
105
106# Conditional setup for Linux build
107if test "$BUILD_FOR_LINUX" = "yes" ; then
108   AC_PROG_CC()
109   AC_CHECK_PROG(AR, ar, ar, not found)
110   AC_CHECK_PROG(AS, as, as, not found)
111   EXPAT_INCLUDE_DIRECTORY="/usr/include"
112   EXPAT_LIB_DIRECTORY="/usr/lib"
113fi
114
115CC="$CC"
116
117# Check to see if we need to build the Python modules
118if test "$ac_enable_python_build" = "yes" ; then
119   # guess default python version
120   PY_DEFAULT=["`python -c \"import platform; print '.'.join(platform.python_version_tuple()[:2])\"`"]
121   if test "x$PY_DEFAULT" = "x"; then
122      AC_MSG_ERROR([No default Python found])
123   fi
124
125   # check all versions
126   PY_POTENTIAL_VERSIONS="2.4 2.5 2.6 2.7"
127   PY_VERSIONS=""
128   for v in $PY_POTENTIAL_VERSIONS; do
129      AC_CHECK_FILE(/usr/include/python$v/Python.h, [PY_VERSIONS="$PY_VERSIONS $v"])
130   done
131   # error if no verions found
132   if test "x$PY_VERSIONS" = "x"; then
133      AC_MSG_ERROR([No Python headers found (checked $PY_POTENTIAL_VERSIONS)])
134   fi
135
136   AC_SUBST(PY_DEFAULT)
137   AC_SUBST(PY_VERSIONS)
138
139   BUILD_FOR_PYTHON="yes"
140fi
141
142# Check doc build tools
143if test "$ac_enable_docs_build" = "yes"; then
144   AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, yes, no)
145   AC_SUBST(HAVE_DOXYGEN)
146fi
147
148# Perform compilation environment tests
149#AC_CHECK_HEADERS(iostream)
150
151# Make sure the proper libraries exist
152if test "$BUILD_FOR_WINDOWS" = "no" ; then
153   AC_CHECK_LIB(expat, main, [], AC_MSG_ERROR(could not find expat library), -L$EXPAT_LIB_DIRECTORY)
154fi
155
156# Make all the proper substitutions
157AC_SUBST(RDFADIR)
158
159# Make all the proper substitutions
160VERSION="$PACKAGE_VERSION"
161AC_SUBST(VERSION)
162AC_SUBST(RELEASE)
163
164AC_SUBST(BUILD_FOR_LINUX)
165AC_SUBST(BUILD_FOR_WINDOWS)
166AC_SUBST(BUILD_FOR_PYTHON)
167
168AC_SUBST(CC)
169AC_SUBST(AR)
170AC_SUBST(AS)
171
172AC_SUBST(OS)
173
174AC_SUBST(EXPAT_LIB_DIRECTORY)
175AC_SUBST(EXPAT_INCLUDE_DIRECTORY)
176
177# Generating files
178AC_CONFIG_FILES([
179   .gitignore
180   Makefile
181   setup/Makefile.base
182   c/Makefile
183   python/Makefile
184   docs/Makefile
185   tests/Makefile
186   installers/debian/changelog
187   librdfa.pc
188   librdfa-uninstalled.pc
189])
190
191# add newlines to internal output file list
192CONFIGURE_GENERATED_FILES="`echo $ac_config_files | tr ' ' '\n'`"
193AC_SUBST(CONFIGURE_GENERATED_FILES)
194
195AC_OUTPUT
196
197# Dump the build configuration for the developer
198echo -e "\n--------- librdfa Build Environment -----------"
199echo "Product        : $PACKAGE_STRING-$RELEASE"
200echo "Build host     : $build_cpu-$build_vendor-$build_os"
201echo "Build target   : $OS"
202echo "C compiler     : $CC"
203echo "Archiver       : $AR"
204echo "Assembler      : $AS"
205
206if test "$BUILD_FOR_PYTHON" = "yes"; then
207   echo "Python modules : enabled (versions: $PY_VERSIONS, default: $PY_DEFAULT)"
208else
209   echo "Python modules : disabled (use --enable-python to enable)"
210fi
211if test "$ac_enable_docs_build" = "yes"; then
212   echo "Documentation  : enabled"
213else
214   echo "Documentation  : disabled (use --enable-docs to enable)"
215fi
Note: See TracBrowser for help on using the browser.