| 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 | |
|---|
| 21 | AC_INIT(librdfa, 0.18, support@digitalbazaar.com) |
|---|
| 22 | AC_CONFIG_AUX_DIR(setup) |
|---|
| 23 | |
|---|
| 24 | # Setup standard build environment variables |
|---|
| 25 | RDFADIR=`pwd` |
|---|
| 26 | RELEASE=`date +%Y%m%d` |
|---|
| 27 | |
|---|
| 28 | # Check for particular build options |
|---|
| 29 | # Check for particular build options |
|---|
| 30 | AC_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 | |
|---|
| 40 | AC_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 | |
|---|
| 50 | AC_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 | |
|---|
| 60 | AC_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 | |
|---|
| 65 | AC_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 | |
|---|
| 70 | echo -e "\n--------- Configuring librdfa Build Environment -----------" |
|---|
| 71 | |
|---|
| 72 | # Check the system type |
|---|
| 73 | AC_CANONICAL_BUILD() |
|---|
| 74 | AC_CANONICAL_HOST() |
|---|
| 75 | AC_CANONICAL_SYSTEM() |
|---|
| 76 | OS="$build_os" |
|---|
| 77 | |
|---|
| 78 | # Checking for standard build tools |
|---|
| 79 | #AC_LANG(C++) |
|---|
| 80 | AC_PROG_INSTALL() |
|---|
| 81 | |
|---|
| 82 | # Conditional setup for Windows build |
|---|
| 83 | if 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" |
|---|
| 92 | fi |
|---|
| 93 | |
|---|
| 94 | # Conditional setup for MacOS build |
|---|
| 95 | if 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" |
|---|
| 104 | fi |
|---|
| 105 | |
|---|
| 106 | # Conditional setup for Linux build |
|---|
| 107 | if 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" |
|---|
| 113 | fi |
|---|
| 114 | |
|---|
| 115 | CC="$CC" |
|---|
| 116 | |
|---|
| 117 | # Check to see if we need to build the Python modules |
|---|
| 118 | if 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" |
|---|
| 140 | fi |
|---|
| 141 | |
|---|
| 142 | # Check doc build tools |
|---|
| 143 | if test "$ac_enable_docs_build" = "yes"; then |
|---|
| 144 | AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, yes, no) |
|---|
| 145 | AC_SUBST(HAVE_DOXYGEN) |
|---|
| 146 | fi |
|---|
| 147 | |
|---|
| 148 | # Perform compilation environment tests |
|---|
| 149 | #AC_CHECK_HEADERS(iostream) |
|---|
| 150 | |
|---|
| 151 | # Make sure the proper libraries exist |
|---|
| 152 | if test "$BUILD_FOR_WINDOWS" = "no" ; then |
|---|
| 153 | AC_CHECK_LIB(expat, main, [], AC_MSG_ERROR(could not find expat library), -L$EXPAT_LIB_DIRECTORY) |
|---|
| 154 | fi |
|---|
| 155 | |
|---|
| 156 | # Make all the proper substitutions |
|---|
| 157 | AC_SUBST(RDFADIR) |
|---|
| 158 | |
|---|
| 159 | # Make all the proper substitutions |
|---|
| 160 | VERSION="$PACKAGE_VERSION" |
|---|
| 161 | AC_SUBST(VERSION) |
|---|
| 162 | AC_SUBST(RELEASE) |
|---|
| 163 | |
|---|
| 164 | AC_SUBST(BUILD_FOR_LINUX) |
|---|
| 165 | AC_SUBST(BUILD_FOR_WINDOWS) |
|---|
| 166 | AC_SUBST(BUILD_FOR_PYTHON) |
|---|
| 167 | |
|---|
| 168 | AC_SUBST(CC) |
|---|
| 169 | AC_SUBST(AR) |
|---|
| 170 | AC_SUBST(AS) |
|---|
| 171 | |
|---|
| 172 | AC_SUBST(OS) |
|---|
| 173 | |
|---|
| 174 | AC_SUBST(EXPAT_LIB_DIRECTORY) |
|---|
| 175 | AC_SUBST(EXPAT_INCLUDE_DIRECTORY) |
|---|
| 176 | |
|---|
| 177 | # Generating files |
|---|
| 178 | AC_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 |
|---|
| 192 | CONFIGURE_GENERATED_FILES="`echo $ac_config_files | tr ' ' '\n'`" |
|---|
| 193 | AC_SUBST(CONFIGURE_GENERATED_FILES) |
|---|
| 194 | |
|---|
| 195 | AC_OUTPUT |
|---|
| 196 | |
|---|
| 197 | # Dump the build configuration for the developer |
|---|
| 198 | echo -e "\n--------- librdfa Build Environment -----------" |
|---|
| 199 | echo "Product : $PACKAGE_STRING-$RELEASE" |
|---|
| 200 | echo "Build host : $build_cpu-$build_vendor-$build_os" |
|---|
| 201 | echo "Build target : $OS" |
|---|
| 202 | echo "C compiler : $CC" |
|---|
| 203 | echo "Archiver : $AR" |
|---|
| 204 | echo "Assembler : $AS" |
|---|
| 205 | |
|---|
| 206 | if test "$BUILD_FOR_PYTHON" = "yes"; then |
|---|
| 207 | echo "Python modules : enabled (versions: $PY_VERSIONS, default: $PY_DEFAULT)" |
|---|
| 208 | else |
|---|
| 209 | echo "Python modules : disabled (use --enable-python to enable)" |
|---|
| 210 | fi |
|---|
| 211 | if test "$ac_enable_docs_build" = "yes"; then |
|---|
| 212 | echo "Documentation : enabled" |
|---|
| 213 | else |
|---|
| 214 | echo "Documentation : disabled (use --enable-docs to enable)" |
|---|
| 215 | fi |
|---|