File: configure.ac

package info (click to toggle)
mikmod 3.2.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,372 kB
  • sloc: ansic: 11,220; sh: 4,840; pascal: 218; makefile: 38
file content (253 lines) | stat: -rw-r--r-- 6,633 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
dnl Process this file with autoconf to produce a configure script.

AC_PREREQ([2.59])

AC_INIT([mikmod],[3.2.9])
AC_CONFIG_AUX_DIR([autotools])
AM_INIT_AUTOMAKE([1.7 foreign])
AC_CONFIG_SRCDIR([src/mikmod.c])
AC_CONFIG_MACRO_DIR([m4])
AM_MAINTAINER_MODE

AC_CANONICAL_HOST

dnl ==============================================================
dnl mikmod specific control variables and their default values.
dnl ==============================================================

mikmod_threads=yes

dnl =========================
dnl Configure script options.
dnl =========================

AC_ARG_ENABLE([threads],[AS_HELP_STRING([--enable-threads],[use an own thread for the player [default=guessed]])],
[if test "$enableval" = "yes"
then
    mikmod_threads=yes
else
    mikmod_threads=no
fi])

dnl ====================
dnl Checks for programs.
dnl ====================

AC_PROG_CC
AC_PROG_CPP
AC_PROG_EGREP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET

dnl =================================
dnl Use -Wall warning level with gcc.
dnl =================================

if test $ac_cv_c_compiler_gnu = yes ; then
	CFLAGS="$CFLAGS -Wall"
fi

dnl ==============================================================
dnl Checks for typedefs, structures, and compiler characteristics.
dnl ==============================================================

AC_C_CONST
AC_TYPE_PID_T
AC_TYPE_SIZE_T

dnl ========================
dnl Checks for header files.
dnl ========================

AC_CHECK_HEADERS(fcntl.h limits.h stdint.h fnmatch.h sys/ioctl.h sys/param.h sys/time.h unistd.h)
AC_CHECK_HEADERS(sched.h)
AC_CHECK_HEADERS(ncurses.h curses.h ncurses/curses.h)
AC_CHECK_HEADERS(termios.h)

AC_HEADER_SYS_WAIT
AC_HEADER_TIOCGWINSZ

dnl =====================
dnl Checks for libraries.
dnl =====================

dnl libmikmod
AM_PATH_LIBMIKMOD(3.1.5, , AC_MSG_ERROR([
--- ERROR: No suitable libmikmod library found.
           You need at least libmikmod 3.1.5 for this program to work.
]))
# MikMod_free() is in libmikmod-3.2.0b3 and later. The only fool-proof
# way of detecting MikMod_free() is a configury check at compile time
# or a dlsym() check at runtime, and the bad thing is 3.2.0beta1/2 were
# (still are?) in distros..
ac_save_LIBS=$LIBS
LIBS="$LIBS $LIBMIKMOD_LIBS"
AC_CHECK_LIB(mikmod, MikMod_free, AC_DEFINE(HAVE_MIKMOD_FREE, 1,
		[Define if your libmikmod has MikMod_free (not found in <= 3.2.0-beta2).]))
LIBS="$ac_save_LIBS"

dnl ncurses
case $host_os in
    mingw*|emx*|*djgpp)
	need_curses=no  ;;
    *)
	need_curses=yes ;;
esac

if test "$need_curses" = "yes" ; then
	AC_CHECK_LIB([ncurses], [initscr], [libcurses=ncurses],
			AC_CHECK_LIB([curses], [initscr], [libcurses=curses],
				AC_MSG_ERROR([--- ERROR: No curses library found.])))
	AC_CHECK_LIB([tinfo], [tgetflag], [have_tinfo=yes], [have_tinfo=no])

	# resizeterm is an optional part of ncurses
	AC_CHECK_LIB($libcurses, resizeterm, AC_DEFINE(HAVE_NCURSES_RESIZETERM, 1,
		[Define if your libncurses defines resizeterm (not found in <4.2).]))

	ac_save_LIBS=$LIBS
	LIBS="$LIBS -l$libcurses"
	AC_MSG_CHECKING([whether curses links without libtinfo])
	AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#ifdef HAVE_NCURSES_H
#include <ncurses.h>
#elif defined(HAVE_CURSES_H)
#include <curses.h>
#elif defined(HAVE_NCURSES_CURSES_H)
#include <ncurses/curses.h>
#endif]],
[[#ifdef ACS_ULCORNER
return ACS_ULCORNER;
#endif]])],
		[need_tinfo=no], [need_tinfo=yes]
	)
	if test "$need_tinfo" = "yes" ; then
		AC_MSG_RESULT(no)
		if test "$have_tinfo" = "no" ; then
			AC_MSG_ERROR([--- ERROR: libtinfo needed for ncurses, but not found.])
		else
			AC_MSG_CHECKING([whether ncurses links with libtinfo])
			LIBS="$LIBS -ltinfo"
			AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#ifdef HAVE_NCURSES_H
#include <ncurses.h>
#elif defined(HAVE_CURSES_H)
#include <curses.h>
#endif]],
[[#ifdef ACS_ULCORNER
return ACS_ULCORNER;
#endif]])],
				[AC_MSG_RESULT(yes)],
				[AC_MSG_ERROR(--- ERROR: failed linking to ncurses library.)]
			)
		fi
	else
		AC_MSG_RESULT(yes)
	fi
	LIBS="$ac_save_LIBS"
fi

dnl POSIX.4 threads
dnl ---------------
case "$host_os" in
  # mikmod_threads variable is for pthreads only
    mingw*|amigaos*|aros*|morphos*) mikmod_threads=no ;;
esac
if test "$mikmod_threads" = "yes"; then
	mikmod_threads=no
	# AC_CHECK_HEADERS(pthread.h) unreliable
	AC_CHECK_LIB([pthread], [pthread_create],
			[mikmod_threads=-lpthread],
			AC_CHECK_LIB([c_r], [pthread_attr_init],
					[mikmod_threads=-lc_r])
		)
fi

dnl =============================
dnl Checks for library functions.
dnl =============================

AC_FUNC_FNMATCH

AC_CHECK_FUNCS(getopt_long_only, have_getopt_long_only=yes)
AC_CHECK_FUNCS(mkstemp srandom snprintf vsnprintf)

AC_EGREP_HEADER(usleep, unistd.h, AC_DEFINE(HAVE_USLEEP_PROTO, 1,
		[Define if your system has the prototype for usleep(3).]))
AC_EGREP_HEADER(usleep, sys/unistd.h, AC_DEFINE(HAVE_USLEEP_PROTO))

dnl =================================
dnl Set PACKAGE_DATA_DIR in config.h.
dnl =================================

AX_RECURSIVE_EVAL(${datadir}/${PACKAGE},ax_package_data_dir)
AC_DEFINE_UNQUOTED([PACKAGE_DATA_DIR],"$ax_package_data_dir",[Define the directory for shared data.])
#AC_SUBST(PACKAGE_DATA_DIR)

dnl ================
dnl Choose settings.
dnl ================

case $host in
    *-aix*)
	AC_DEFINE(MIKMOD_AIX, 1, [Define if your system is AIX 3.* - might be needed for 4.* too.])
    ;;
esac

if test "$mikmod_threads" != "no"; then
	AC_DEFINE(HAVE_PTHREAD, 1, [Define if your system provides POSIX.4 threads.])
	CFLAGS="$CFLAGS -D_REENTRANT"
	PLAYER_LIB="$mikmod_threads $PLAYER_LIB"
	REENTRANT="-D_REENTRANT"
fi

dnl ===================
dnl Choose extra stuff.
dnl ===================

dnl solaris usleep is not thread safe, use an alternative
dnl implementation on this system
case $host in
    *-*-solaris*)
	if test "$mikmod_threads" != "no"; then
		have_usleep=no
	else
		AC_CHECK_FUNCS(usleep, have_usleep=yes)
	fi
	;;
    *)
	AC_CHECK_FUNCS(usleep, have_usleep=yes)
	;;
esac

if test "$have_getopt_long_only" != "yes"; then
	EXTRA_OBJ="getopt_long.o $EXTRA_OBJ"
fi

dnl Yet another kluge to get the result of AC_FUNC_FNMATCH.
if test "$ac_cv_func_fnmatch_works" != "yes"; then
	EXTRA_OBJ="mfnmatch.o $EXTRA_OBJ"
fi

if test "$have_usleep" != "yes"; then
	EXTRA_OBJ="musleep.o $EXTRA_OBJ"
fi

if test "$need_curses" = "yes"; then
	PLAYER_LIB="$PLAYER_LIB -l$libcurses"
	if test "$need_tinfo" = "yes"; then
		PLAYER_LIB="$PLAYER_LIB -ltinfo"
	fi
fi

dnl =================
dnl Create Makefiles.
dnl =================

AC_SUBST(EXTRA_OBJ)
AC_SUBST(PLAYER_LIB)

AC_CONFIG_FILES([Makefile
src/Makefile])
AC_CONFIG_HEADERS([config.h])
AC_OUTPUT