1dnl Copyright (C) 2003-2006, 2017-2018 Rocky Bernstein <rocky@gnu.org> 2dnl Copyright (C) 2003-2004 Herbert Valerio Riedel <hvr@gnu.org> 3dnl 4dnl This program is free software; you can redistribute it and/or modify 5dnl it under the terms of the GNU General Public License as published by 6dnl the Free Software Foundation; either version 2, or (at your option) 7dnl any later version. 8dnl 9dnl This program is distributed in the hope that it will be useful, 10dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 11dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12dnl GNU General Public License for more details. 13dnl 14dnl You should have received a copy of the GNU General Public License 15dnl along with this program; if not, write to the Free Software 16dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 17dnl 02111-1307, USA. 18 19define(RELEASE_NUM, 1) 20define(LIBVCD_VERSION_STR, 2.0.$1) 21 22AC_PREREQ(2.61) 23AC_REVISION([$Id$])dnl 24 25AC_INIT([GNU VCDimager],LIBVCD_VERSION_STR(RELEASE_NUM), 26 [bugs-vcdimager@gnu.org], [vcdimager]) 27AC_CONFIG_SRCDIR([lib/vcd.c]) 28AM_INIT_AUTOMAKE(1.6.0) 29AC_CONFIG_MACRO_DIR([m4]) 30 31# Enable silent build rules by default (Automake v1.11 or later). 32# Disable by either passing --disable-silent-rules to configure or passing V=1 to make 33m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], 34 [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])]) 35 36SPEC_VERSION=VCD_VERSION_STR 37AC_SUBST(SPEC_VERSION) 38 39dnl AM_ACLOCAL_INCLUDE(.) 40dnl AM_CONFIG_HEADER(include/libvcd/acconfig.h) 41AM_CONFIG_HEADER(config.h) 42 43LIBVCD_VERSION_NUM=$(echo RELEASE_NUM | sed 's/git|rc.$//') 44AC_SUBST(LIBVCD_VERSION_NUM) 45 46AM_MISSING_PROG(HELP2MAN, help2man, $missing_dir) 47AM_MISSING_PROG(GIT2CL, git2cl, $missing_dir) 48AM_MAINTAINER_MODE 49 50AM_SANITY_CHECK 51AC_CANONICAL_HOST 52AC_PROG_CXX 53 54AC_DEFINE_UNQUOTED(HOST_ARCH, "$host_os/$host_cpu", [host os/cpu identifier]) 55 56dnl conditionally built frontends 57 58AC_ARG_WITH(cli-frontend, 59 [ --without-cli-frontend enable cli frontend (enabled by default)], 60 enable_cli_fe="${withval}", enable_cli_fe=yes) 61 62AC_ARG_WITH(xml-frontend, 63 [ --without-xml-frontend enable XML frontend (enabled by default)], 64 enable_xml_fe="${withval}", enable_xml_fe=yes) 65 66AC_ARG_WITH(versioned_libs, 67[ --without-versioned-libs build versioned library symbols (enabled by default)], 68enable_versioned_libs="${withval}", enable_versioned_libs=yes) 69 70dnl programs 71 72AC_PROG_CC 73if test "x$GCC" != "xyes" 74then 75 echo "*** non GNU CC compiler detected." 76 echo "*** This package has not been tested very well with non GNU compilers" 77 echo "*** you should try to use 'gcc' for compiling this package." 78else 79 WARN_CFLAGS=" 80 -Wall 81 -Wbad-function-cast 82 -Wcast-align 83 -Wchar-subscripts 84 -Wdeclaration-after-statement 85 -Wendif-labels 86 -Winline 87 -Wmissing-declarations 88 -Wmissing-prototypes 89 -Wnested-externs 90 -Wno-sign-compare 91 -Wpointer-arith 92 -Wundef 93 -Wunused 94 -Wwrite-strings 95 " 96 97 warning_flags="" 98 99 if test "x$enable_maintainer_mode" = "xyes"; then 100 101 case $host_os in 102 solaris*) 103 # Something with -std=c99 in libcdio messes up the uint64_t decls 104 # There is probably a better fix around somewhere. 105 WOPT="-pedantic" 106 ;; 107 *) 108 WOPT="-std=c99 -pedantic" 109 ;; 110 esac 111 112 WOPT="std=c99 -pedantic" 113 SAVE_CFLAGS="$CFLAGS" 114 CFLAGS="$CFLAGS $WOPT" 115 AC_MSG_CHECKING([whether $CC accepts $WOPT]) 116 AC_TRY_COMPILE([], [], 117 [has_option=yes; warning_flags="$warning_flags $WOPT"], 118 has_option=no) 119 CFLAGS="$SAVE_CFLAGS" 120 AC_MSG_RESULT($has_option) 121 fi 122 123 for WOPT in $WARN_CFLAGS; do 124 SAVE_CFLAGS="$CFLAGS" 125 CFLAGS="$CFLAGS $WOPT" 126 AC_MSG_CHECKING([whether $CC accepts $WOPT]) 127 AC_TRY_COMPILE([], [], has_option=yes, has_option=no) 128 CFLAGS="$SAVE_CFLAGS" 129 AC_MSG_RESULT($has_option) 130 if test "x$has_option" = "xyes"; then 131 warning_flags="$warning_flags $WOPT" 132 fi 133 unset has_option 134 unset SAVE_CFLAGS 135 done 136 unset WOPT 137 WARN_CFLAGS="$warning_flags" 138 unset warning_flags 139fi 140 141AC_PROG_CPP 142AM_PROG_CC_STDC 143AC_PROG_AWK 144dnl AM_PROG_LIBTOOL tests whether we have GNU ld 145dnl this must come before checking --with-versioned-libs 146dnl which requires GNU ld. 147AM_PROG_LIBTOOL 148 149dnl We use a diff in regression testing 150AC_PATH_PROG(DIFF, diff, no) 151DIFF_OPTS= 152 153if test "$DIFF" = no ; then 154 AC_PATH_PROG(DIFF, cmp, no) 155else 156 dnl Try for GNU diff options. 157 # MSDOG output uses \r\n rather than \n in tests 158 for diff_opt in -w --unified ; do 159 if $DIFF $diff_opt ./configure ./configure > /dev/null 2>&1; then 160 AC_MSG_RESULT([adding $diff_opt to diff in regression tests]) 161 DIFF_OPTS="$DIFF_OPTS $diff_opt" 162 fi 163 done 164fi 165AC_SUBST(DIFF) 166AC_SUBST(DIFF_OPTS) 167 168dnl libs 169AC_CHECK_FUNCS(snprintf vsnprintf, , [AC_MSG_ERROR(required function not found)]) 170 171dnl For vcdimager and vcdxbuild to be able to set creation time of VCD 172AC_CHECK_FUNCS(getdate strptime, , ) 173 174if test "x$enable_cli_fe" = "xyes" -o "x$enable_xml_fe" = "xyes"; then 175 PKG_CHECK_MODULES(LIBPOPT, popt, [], [enable_cli_fe=no; enable_xml_fe=no]) 176fi 177 178if test "x$enable_xml_fe" = "xyes"; then 179 PKG_CHECK_MODULES(XML, libxml-2.0 >= 2.3.8, [], [enable_xml_fe=no]) 180fi 181 182dnl headers 183 184dnl AC_DEFINE(_DEVELOPMENT_, [], enable warnings about being development release) 185# AC_DEFINE(_GNU_SOURCE, [], enable GNU libc extension) 186AC_STDC_HEADERS 187AC_CHECK_HEADERS(sys/stat.h stdint.h inttypes.h stdbool.h sys/mman.h time.h) 188 189if test "x$ac_cv_header_stdint_h" != "xyes" 190 then 191 AC_CHECK_SIZEOF(int, 4) 192 AC_CHECK_SIZEOF(long, 4) 193 AC_CHECK_SIZEOF(long long, 8) 194fi 195 196dnl compiler 197AC_C_BIGENDIAN 198AC_C_CONST 199AC_C_INLINE 200 201dnl ISOC99_PRAGMA 202AC_MSG_CHECKING([whether $CC supports ISO C99 _Pragma()]) 203AC_TRY_COMPILE([_Pragma("pack(1)")], [], [ 204 ISOC99_PRAGMA=yes 205 AC_DEFINE(HAVE_ISOC99_PRAGMA, [], [Supports ISO _Pragma() macro]) 206],ISOC99_PRAGMA=no) 207AC_MSG_RESULT($ISOC99_PRAGMA) 208 209empty_array_size="xxxx" 210AC_TRY_COMPILE([],[struct { int foo; int bar[]; } doo;], empty_array_size="") 211 212if test "x$empty_array_size" = "xxxx"; then 213 AC_TRY_COMPILE([],[struct { int foo; int bar[0]; } doo;], empty_array_size="0") 214fi 215 216if test "x$empty_array_size" = "xxxx"; then 217 AC_MSG_ERROR([compiler is unable to creaty empty arrays]) 218else 219 AC_DEFINE_UNQUOTED(EMPTY_ARRAY_SIZE, $empty_array_size, 220 [what to put between the brackets for empty arrays]) 221 changequote(`,') 222 msg="[${empty_array_size}]" 223 changequote([,]) 224 AC_MSG_RESULT($msg) 225fi 226 227# 228# Check bitfield order in structs 229# 230AC_MSG_CHECKING([bitfield ordering in structs]) 231dnl basic compile test for all platforms 232AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ 233int 234 main() { 235 struct { char bit_0:1, bit_12:2, bit_345:3, bit_67:2; } 236#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) 237 __attribute__((packed)) 238#endif 239 bf = { 1,1,1,1 }; 240 switch (0) case 0: case sizeof(bf) == 1:; 241 return 0; 242} 243]])], [], AC_MSG_ERROR([compiler doesn't support bitfield structs])) 244 245dnl run test 246AC_RUN_IFELSE([AC_LANG_SOURCE([[ 247int main() { 248 struct { char bit_0:1, bit_12:2, bit_345:3, bit_67:2; } 249#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) 250 __attribute__((packed)) 251#endif 252 bf = { 1,1,1,1 }; 253 if (sizeof (bf) != 1) return 1; 254 return *((unsigned char*) &bf) != 0x4b; } 255]])], bf_lsbf=1, [ 256 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 257int main() { 258 struct { char bit_0:1, bit_12:2, bit_345:3, bit_67:2; } 259#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) 260 __attribute__((packed)) 261#endif 262 bf = { 1,1,1,1 }; 263 if (sizeof (bf) != 1) return 1; 264 return *((unsigned char*) &bf) != 0xa5; } 265]])], bf_lsbf=0, AC_MSG_ERROR([unsupported bitfield ordering])) 266 ], 267 [case "$host" in 268 *-*-mingw32* | *-*-cygwin*) 269 bf_lsbf=1 270 ;; 271 *) 272 AC_MSG_RESULT([unknown]) 273 AC_MSG_ERROR([value of bitfield test isn't known for $host 274********************************************************************* 275Value of bitfield test can't find out for cross-compiling and we 276don't know its value for host "$host". 277*********************************************************************]) 278 esac] 279) 280 281 if test "x$cross_compiling" = "xyes"; then 282 TEXT=" (guessed)" 283 else 284 TEXT="" 285 fi 286 287 if test "x$bf_lsbf" = "x1"; then 288 AC_MSG_RESULT(LSBF${TEXT}) 289 AC_DEFINE(BITFIELD_LSBF, [], [compiler does lsbf in struct bitfields]) 290 else 291 AC_MSG_RESULT(MSBF${TEXT}) 292 fi 293dnl 294 295dnl system 296PKG_CHECK_MODULES(LIBCDIO, libcdio >= 2.0.0, [], 297 [AC_MSG_ERROR(Required libcdio library (> 2.0.0) not found. Please get libcdio from http://www.gnu.org/software/libcdio/ and install it.)]) 298AC_SUBST(LIBCDIO_LIBS) 299AC_SUBST(LIBCDIO_CFLAGS) 300 301PKG_CHECK_MODULES(LIBISO9660, libiso9660 >= 2.0.0, [], 302 [AC_MSG_ERROR(Required libiso9660 library (part of libcdio) not found. Please get libcdio from http://www.gnu.org/software/libcdio/ and install it.)]) 303AC_SUBST(LIBISO9660_CFLAGS) 304AC_SUBST(LIBISO9660_LIBS) 305 306case $host_os in 307 cygwin*) 308 AC_DEFINE([CYGWIN], [1], 309 [Define 1 if you are compiling using cygwin]) 310 ;; 311 darwin*) 312 AC_CHECK_HEADERS(IOKit/IOKitLib.h CoreFoundation/CFBase.h, 313 [have_iokit_h="yes"]) 314 if test "x$have_iokit_h" = "xyes" ; then 315 LIBS="$LIBS -framework CoreFoundation -framework IOKit" 316 fi 317 ;; 318esac 319 320LIBS="$LIBS -lm" 321CFLAGS="$CFLAGS $WARN_CFLAGS" 322 323# We need either GNU make or --without-versioned-libs 324if test "x$enable_versioned_libs" = "xyes" ; then 325 if test -n "$MAKE" ; then 326 $MAKE --version 2>/dev/null >/dev/null 327 if test "$?" -ne 0 ; then 328 AC_MSG_ERROR(Either set MAKE variable to GNU make or use 329 --without-versioned-libs option) 330 fi 331 else 332 make --version 2>/dev/null >/dev/null 333 if test "$?" -ne 0 ; then 334 AC_MSG_ERROR(Either set MAKE variable to GNU make or use 335 --without-versioned-libs option) 336 else 337 # Do we have GNU ld? We need that too. 338 if test "$with_gnu_ld" != yes; then 339 AC_MSG_WARN(I don't see GNU ld. I'm going to assume --without-versioned-libs) 340 enable_versioned_libs='no' 341 fi 342 fi 343 fi 344fi 345 346AM_CONDITIONAL(CYGWIN, test "x$CYGWIN" = "xyes") 347AM_CONDITIONAL(BUILD_CLI_FE, test "x$enable_cli_fe" = "xyes") 348AM_CONDITIONAL(BUILD_XML_FE, test "x$enable_xml_fe" = "xyes") 349AM_CONDITIONAL(BUILD_VERSIONED_LIBS, test "x$enable_versioned_libs" = "xyes") 350 351LIBVCD_CFLAGS='-I$(top_srcdir)/include/ -I$(top_srcdir)/lib/' 352LIBVCD_LIBS='$(top_builddir)/lib/libvcd.la' 353LIBVCDINFO_LIBS='$(top_builddir)/lib/libvcdinfo.la' 354AC_SUBST(LIBVCD_CFLAGS) 355AC_SUBST(LIBVCD_LIBS) 356AC_SUBST(LIBVCDINFO_LIBS) 357 358AC_CONFIG_FILES([ \ 359 Makefile \ 360 libvcdinfo.pc \ 361 include/Makefile \ 362 include/libvcd/Makefile \ 363 include/libvcd/version.h \ 364 lib/Makefile \ 365 frontends/Makefile \ 366 frontends/xml/Makefile \ 367 frontends/cli/Makefile \ 368 docs/Makefile \ 369 docs/doxygen/Doxyfile \ 370 example/Makefile \ 371 test/check_common_fn \ 372 test/Makefile \ 373 vcdimager.spec \ 374]) 375AC_OUTPUT 376 377if test -z "$enable_maintainer_mode"; then 378 enable_maintainer_mode="no" 379fi 380 381echo " 382Setup: 383 Install path: ${prefix} 384 Build CLI FE: $enable_cli_fe 385 Build XML FE: $enable_xml_fe 386 Maintainer mode: $enable_maintainer_mode 387" 388 389if test "x$enable_cli_fe" != "xyes" -a "x$enable_xml_fe" != "xyes" 390then 391 cat <<EOF 392**************************************************************************** 393**************************************************************************** 394*** *** 395*** WARNING: BUILDING ONLY LIBVCD W/O ANY FRONTENDS *** 396*** (maybe you are missing some libraries (libpopt 1.7 or greater *** 397*** and libxml2)? *** 398*** *** 399**************************************************************************** 400**************************************************************************** 401EOF 402fi 403 404dnl EOF 405