1dnl Process this file with autoconf to produce a configure script.
2
3AC_PREREQ(2.63)
4
5AC_INIT([libmodplug], [0.8.9.0])
6AC_CONFIG_SRCDIR([Makefile.am])
7
8AM_INIT_AUTOMAKE
9m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
10AC_CONFIG_HEADERS([src/config.h])
11AC_CONFIG_MACRO_DIR([m4])
12AM_MAINTAINER_MODE([enable])
13
14dnl Checks for programs.
15dnl  I am disabling static libraries here because otherwise libtool insists on
16dnl  compiling everything twice -- once with and once without -fPIC.  Pisses me
17dnl  off.  Just do everything with -fPIC, damnit!  Compiling everything twice
18dnl  probably wastes more cycles than not using -fPIC saves.
19AC_DISABLE_STATIC
20AC_DISABLE_STATIC([])
21AC_PROG_CC
22AC_PROG_CXX
23AC_LANG([C++])
24AC_C_BIGENDIAN
25
26#AC_LIBTOOL_WIN32_DLL
27#AC_PROG_LIBTOOL
28LT_INIT([win32-dll])
29
30AC_HEADER_STDC
31AC_CHECK_HEADERS([inttypes.h stdint.h malloc.h])
32AC_CHECK_FUNCS(sinf)
33
34CXXFLAGS="$CXXFLAGS -fno-exceptions -Wall -ffast-math -fno-common -D_REENTRANT"
35
36AC_CANONICAL_HOST
37case "$host" in
38	*mingw* | *cygwin*)
39		LT_LDFLAGS="-no-undefined"
40		;;
41	*)
42		LT_LDFLAGS=""
43		;;
44esac
45AC_SUBST(LT_LDFLAGS)
46
47# require 10.5+ for osx/x86_64 builds
48case "$host" in
49	x86_64-*-darwin*)
50		CXXFLAGS="$CXXFLAGS -mmacosx-version-min=10.5"
51		LDFLAGS="$LDFLAGS -mmacosx-version-min=10.5" ;;
52esac
53
54# symbol visibility
55ac_save_CXXFLAGS="$CXXFLAGS"
56CXXFLAGS="$CXXFLAGS -fvisibility=hidden -Werror"
57AC_CACHE_CHECK([if compiler supports visibility attributes],[libmodplug_cv_gcc_visibility],
58	AC_TRY_COMPILE([void foo(void);
59__attribute__((visibility("default"))) void foo(void) {}],
60		[],
61		[libmodplug_cv_gcc_visibility=yes],
62		[libmodplug_cv_gcc_visibility=no])
63	)
64# we want symbol -fvisibility for elf targets, however it works
65# with darwin/macho too.  other than that, windows, dos and os2
66# do not need it:  for any such targets, the -Werror switch is
67# supposed to fail the above check. (I'm adding the manual test
68# below nonetheless, just in case.)
69case $host_os in
70   mingw*|cygwin*|emx*|*djgpp)
71	libmodplug_cv_gcc_visibility=no
72	;;
73esac
74CXXFLAGS="$ac_save_CXXFLAGS"
75if test $libmodplug_cv_gcc_visibility = yes ;then
76   CXXFLAGS="$CXXFLAGS -DSYM_VISIBILITY -fvisibility=hidden"
77fi
78
79case ${target_os} in
80	*sun* | *solaris*)
81		CXXFLAGS="$CXXFLAGS -fpermissive"
82		;;
83esac
84
85# portable types. requires autoconf 2.60
86# `configure' will check if these are defined in system headers.
87# if not, it will auto-detect and define them in `config.h'
88AC_TYPE_INT8_T
89AC_TYPE_UINT8_T
90AC_TYPE_INT16_T
91AC_TYPE_UINT16_T
92AC_TYPE_INT32_T
93AC_TYPE_UINT32_T
94AC_TYPE_INT64_T
95AC_TYPE_UINT64_T
96
97MODPLUG_LIBRARY_VERSION=1:0:0
98
99AC_SUBST(MODPLUG_LIBRARY_VERSION)
100
101AC_CONFIG_FILES([Makefile
102	  src/Makefile
103	  libmodplug.pc])
104AC_OUTPUT
105