1 From 3163bf87d7b955d08dedd5ebaccb1b2a86ffdcb9 Mon Sep 17 00:00:00 2001
2 From: Simon Howard <fraggle@soulsphere.org>
3 Date: Thu, 25 Feb 2016 22:55:04 -0500
4 Subject: [PATCH] configure: Switch to pkg-config macros.
6 All dependency libraries install pkg-config .pc files nowadays, which
7 makes the process of looking them up a lot simpler. Get rid of the SDL
8 workaround macro as it's not needed.
10 [Backported from upstream commit 3163bf87d7b955d08dedd5ebaccb1b2a86ffdcb9.
11 Fixes static linking issues with SDL_mixer.]
13 Signed-off-by: Rodrigo Rebello <rprebello@gmail.com>
15 configure.ac | 117 ++++++++++++++--------------------------
16 opl/examples/Makefile.am | 2 +-
17 src/Makefile.am | 7 ++-
18 textscreen/Makefile.am | 2 +-
19 textscreen/examples/Makefile.am | 2 +-
20 5 files changed, 49 insertions(+), 81 deletions(-)
22 diff --git a/configure.ac b/configure.ac
23 index 7b03485..48f83ef 100644
26 @@ -33,89 +33,54 @@ then
27 CFLAGS="-O$OPT_LEVEL -g $WARNINGS $orig_CFLAGS"
30 -dnl Search for SDL ...
34 -# Add the SDL compiler flags to the default compiler flag variables.
35 -# It is important to do this now, before checking for headers and
36 -# library functions. The reason being that on Windows, sdl-config
37 -# sets the -mno-cygwin compiler option in order to generate MinGW
38 -# executables. If we don't do this now, we might end up discovering
39 -# header files that are not actually available to us when we come
42 -CFLAGS="$CFLAGS $SDL_CFLAGS"
43 -LDFLAGS="$LDFLAGS $SDL_LIBS"
45 -# On some platforms, SDL renames main() to SDL_main() using a #define,
46 -# so that its own main, stored in the SDLmain library, can be run first.
47 -# Unfortunately, this causes problems for autoconf, which builds
48 -# test programs to probe the system. All library/header/symbol checks
49 -# must be run in this block, that performs a workaround for the problem.
51 -AC_SDL_MAIN_WORKAROUND([
53 - # Check for SDL_mixer.
55 - AC_CHECK_LIB(SDL_mixer,Mix_LoadMUS,[
56 - SDLMIXER_LIBS="$SDLMIXER_LIBS -lSDL_mixer"
58 - echo "*** Could not find SDL_mixer. Please install it."
62 - # Check for SDL_net.
64 - AC_CHECK_LIB(SDL_net,SDLNet_UDP_Send,[
65 - SDLNET_LIBS="$SDLNET_LIBS -lSDL_net"
67 - echo "*** Could not find SDL_net. Please install it."
71 - # Check for libsamplerate.
72 - AC_ARG_WITH([libsamplerate],
73 - AS_HELP_STRING([--without-libsamplerate],
74 - [Build without libsamplerate @<:@default=check@:>@]),
77 - [with_libsamplerate=check]
79 - AS_IF([test "x$with_libsamplerate" != xno], [
80 - AC_CHECK_LIB(samplerate, src_new, [], [
81 - AS_IF([test "x$with_libsamplerate" != xcheck], [AC_MSG_FAILURE(
82 - [--with-libsamplerate was given, but test for libsamplerate failed])
84 +PKG_CHECK_MODULES([SDL], [sdl])
85 +PKG_CHECK_MODULES([SDLMIXER], [SDL_mixer])
86 +PKG_CHECK_MODULES([SDLNET], [SDL_net])
88 +# Check for libsamplerate.
89 +AC_ARG_WITH([libsamplerate],
90 +AS_HELP_STRING([--without-libsamplerate],
91 + [Build without libsamplerate @<:@default=check@:>@]),
94 + [with_libsamplerate=check]
96 +AS_IF([test "x$with_libsamplerate" != xno], [
97 + PKG_CHECK_MODULES([SAMPLERATE], [samplerate >= 0.1.8], [
98 + AC_DEFINE([HAVE_LIBSAMPLERATE], [1], [libsamplerate installed])
100 + AS_IF([test "x$with_libsamplerate" != xcheck], [AC_MSG_FAILURE(
101 + [--with-libsamplerate was given, but test for libsamplerate failed])
104 - # Check for libpng.
105 - AC_ARG_WITH([libpng],
106 - AS_HELP_STRING([--without-libpng],
107 - [Build without libpng @<:@default=check@:>@]),
110 - [with_libpng=check]
112 - AS_IF([test "x$with_libpng" != xno], [
113 - AC_CHECK_LIB(z, zlibVersion)
114 - AC_CHECK_LIB(png, png_get_io_ptr, [], [
115 - AS_IF([test "x$with_libpng" != xcheck], [AC_MSG_FAILURE(
116 - [--with-libpng was given, but test for libpng failed])
120 +AC_ARG_WITH([libpng],
121 +AS_HELP_STRING([--without-libpng],
122 + [Build without libpng @<:@default=check@:>@]),
125 + [with_libpng=check]
127 +AS_IF([test "x$with_libpng" != xno], [
128 + PKG_CHECK_MODULES([PNG], [libpng >= 1.6.10], [
129 + AC_DEFINE([HAVE_LIBPNG], [1], [libpng installed])
131 + AS_IF([test "x$with_libpng" != xcheck], [AC_MSG_FAILURE(
132 + [--with-libpng was given, but test for libpng failed])
135 - AC_CHECK_LIB(m, log)
137 +AC_CHECK_LIB(m, log)
139 - AC_CHECK_HEADERS([linux/kd.h dev/isa/spkrio.h dev/speaker/speaker.h])
140 - AC_CHECK_FUNCS(mmap ioperm)
141 +AC_CHECK_HEADERS([linux/kd.h dev/isa/spkrio.h dev/speaker/speaker.h])
142 +AC_CHECK_FUNCS(mmap ioperm)
144 - # OpenBSD I/O i386 library for I/O port access.
145 - # (64 bit has the same thing with a different name!)
146 +# OpenBSD I/O i386 library for I/O port access.
147 +# (64 bit has the same thing with a different name!)
149 - AC_CHECK_LIB(i386, i386_iopl)
150 - AC_CHECK_LIB(amd64, amd64_iopl)
152 +AC_CHECK_LIB(i386, i386_iopl)
153 +AC_CHECK_LIB(amd64, amd64_iopl)
157 diff --git a/opl/examples/Makefile.am b/opl/examples/Makefile.am
158 index 9afcd51..54c37f8 100644
159 --- a/opl/examples/Makefile.am
160 +++ b/opl/examples/Makefile.am
163 -AM_CFLAGS = -I$(top_srcdir)/opl
164 +AM_CFLAGS = -I$(top_srcdir)/opl @SDL_CFLAGS@
166 noinst_PROGRAMS=droplay
168 diff --git a/src/Makefile.am b/src/Makefile.am
169 index 78ee3ba..9624e01 100644
170 --- a/src/Makefile.am
171 +++ b/src/Makefile.am
172 @@ -21,7 +21,8 @@ execgames_SCRIPTS = $(SETUP_BINARIES)
173 AM_CFLAGS = -I$(top_srcdir)/textscreen \
174 -I$(top_srcdir)/opl \
175 -I$(top_srcdir)/pcsound \
176 - @SDLMIXER_CFLAGS@ @SDLNET_CFLAGS@
177 + @SDLMIXER_CFLAGS@ @SDLNET_CFLAGS@ \
178 + @SAMPLERATE_CFLAGS@ @PNG_CFLAGS@
180 # Common source files used by absolutely everything:
182 @@ -150,7 +151,9 @@ EXTRA_LIBS = \
188 + @SAMPLERATE_LIBS@ \
192 @PROGRAM_PREFIX@doom_SOURCES=$(SOURCE_FILES_WITH_DEH) resource.rc
193 diff --git a/textscreen/Makefile.am b/textscreen/Makefile.am
194 index 628d4ff..427ed40 100644
195 --- a/textscreen/Makefile.am
196 +++ b/textscreen/Makefile.am
199 -AM_CFLAGS = -I$(top_srcdir)/src
200 +AM_CFLAGS = -I$(top_srcdir)/src @SDL_CFLAGS@
202 CTAGS_ARGS=-I TXT_UNCAST_ARG+
204 diff --git a/textscreen/examples/Makefile.am b/textscreen/examples/Makefile.am
205 index 4632d92..b857748 100644
206 --- a/textscreen/examples/Makefile.am
207 +++ b/textscreen/examples/Makefile.am
210 -AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/textscreen
211 +AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/textscreen @SDL_CFLAGS@
213 noinst_PROGRAMS=guitest calculator