summaryrefslogtreecommitdiff
path: root/configure.ac
blob: ce37da42b9bc80d799d9ed0992b6c2b7fb24d2cd (plain)
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
dnl Process this file with autoconf to produce a configure script.

dnl Schism Tracker - a cross-platform Impulse Tracker clone
dnl copyright (c) 2003-2005 Storlek <storlek@rigelseven.com>
dnl copyright (c) 2005-2008 Mrs. Brisby <mrs.brisby@nimh.org>
dnl copyright (c) 2009 Storlek & Mrs. Brisby
dnl copyright (c) 2010-2012 Storlek
dnl URL: http://schismtracker.org/
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

AC_INIT([libplayit], [1.0], [vcaputo@pengaru.com])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
AC_CONFIG_HEADERS([config.h])

dnl -----------------------------------------------------------------------

dnl Check for standard programs
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_CC_C99
AC_PROG_RANLIB

dnl Windows poop
AC_CHECK_TOOL([WINDRES], [windres])
AC_SUBST(WINDRES)
AM_CONDITIONAL([HAVE_WINDRES], [test "x$WINDRES" != "x"])

dnl We're using C
AC_LANG([C])

dnl check endianness
AC_C_BIGENDIAN

dnl Functions
AC_CHECK_FUNCS(strchr memmove strerror strtol strcasecmp strncasecmp strverscmp stricmp strnicmp strcasestr strptime asprintf vasprintf memcmp mmap nice unsetenv dup fnmatch mkstemp)
AM_CONDITIONAL([NEED_ASPRINTF], [test "$ac_cv_func_asprintf" = "no"])
AM_CONDITIONAL([NEED_VASPRINTF], [test "$ac_cv_func_vasprintf" = "no"])
AM_CONDITIONAL([NEED_MEMCMP], [test "$ac_cv_func_memcmp" = "no"])
AM_CONDITIONAL([NEED_STRPTIME], [test "$ac_cv_func_strptime" = "no"])
AM_CONDITIONAL([NEED_MKSTEMP], [test "$ac_cv_func_mkstemp" = "no"])

AM_CONDITIONAL([USE_MMAP], [test "$ac_cv_func_mmap" = "yes"])

dnl Headers, typedef crap, et al.
AC_HEADER_STDC
AC_HEADER_DIRENT
AC_HEADER_TIME
AC_CHECK_HEADERS(inttypes.h fcntl.h limits.h signal.h unistd.h sys/param.h sys/ioctl.h sys/kd.h linux/fb.h byteswap.h sys/soundcard.h)
AM_CONDITIONAL([USE_OSS], [test "$ac_cv_header_sys_soundcard_h" = yes])

AC_C_CONST
AC_C_INLINE
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_STRUCT_TM
AC_SEARCH_LIBS([powf], [m])

dnl -----------------------------------------------------------------------

dnl Always use x11 by default unless overriden later per-platform
dnl (this is stupid, and only needed because the x11 check is dysfunctional)
defaultx11=yes


dnl CoreMIDI (Mac OS X)
AC_MSG_CHECKING(for CoreAudio/CoreMIDI Framework)
if echo "$SDL_LIBS" | grep -- -framework >/dev/null 2>&1; then
        AC_MSG_RESULT(found)
        dnl frameworks aren't part of sdl... should be a separate variable
        SDL_LIBS="$SDL_LIBS -framework CoreAudio -framework CoreMIDI -framework IOKit -framework OpenGL"
        AC_SUBST(SDL_LIBS)

        AM_CONDITIONAL([USE_MACOSX], true)
        AM_CONDITIONAL([am__fastdepOBJC], true)
        defaultx11=no
else
        AC_MSG_RESULT(not found)
        AM_CONDITIONAL([USE_MACOSX], false)
        AM_CONDITIONAL([am__fastdepOBJC], false)
fi



dnl winmm testing...
AC_CHECK_HEADERS(winsock.h winsock2.h windows.h)
if test "X$ac_cv_header_windows_h" = "Xyes"; then
        AM_CONDITIONAL([USE_WIN32], true)
        SDL_LIBS="$SDL_LIBS -lwinmm"
        AC_SUBST(SDL_LIBS)
        defaultx11=no
else
        AM_CONDITIONAL([USE_WIN32], false)
fi


dnl Wii crap
AC_CHECK_LIB(ogc, IOS_ReloadIOS, libogc_found=yes, libogc_found=no, [-mrvl -L${DEVKITPRO}/libogc/lib/wii])
if test x"$libogc_found" = "xyes"; then
        AM_CONDITIONAL([USE_WII], true)
        wii_machdep="-DGEKKO -mrvl -mcpu=750 -meabi -mhard-float"
        CFLAGS="$CFLAGS $wii_machdep -I${DEVKITPRO}/libogc/include"
        LIBS="$LIBS $wii_machdep -L${DEVKITPRO}/libogc/lib/wii"
        SDL_CFLAGS="$SDL_CFLAGS -I${DEVKITPRO}/libogc/include/SDL"
        SDL_LIBS="$SDL_LIBS -lSDL -lfat -lwiiuse -lbte -logc -lm -lwiikeyboard"
        AC_SUBST(CFLAGS)
        AC_SUBST(LIBS)
        AC_SUBST(SDL_CFLAGS)
        AC_SUBST(SDL_LIBS)
        EXEEXT=.elf
        AC_SUBST(EXEEXT)
        defaultx11=no
else
        AM_CONDITIONAL([USE_WII], false)
fi


dnl should probably have some AC_MSG_CHECKING here, but meh
if test "x$defaultx11" = "xno"; then
        if test "x$with_x" = "x"; then
                AC_MSG_NOTICE([X11 disabled by default; use --with-x if you really want it])
                dnl (you don't want it, because it's probably broken anyway)
                with_x=no
        fi
fi

dnl OpenGL crud - it doesn't always exist
saved_cppflags=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $SDL_CFLAGS"
AC_CHECK_HEADER([SDL_opengl.h], [AC_DEFINE([USE_OPENGL], 1, [Define to 1 if SDL's OpenGL works])])
CPPFLAGS=$saved_cppflags

dnl -----------------------------------------------------------------------

saved_libs=$LIBS
alsa=no
AC_CHECK_LIB(asound, snd_seq_open,[alsa=yes])
alsadltrick=no
if test "$alsa" = "yes"; then
        if test "$ac_cv_header_sys_soundcard_h" = "yes"; then
                alsadltrick=yes
                LIBS=$saved_libs
        fi
fi
AM_CONDITIONAL([USE_ALSA], [test "$alsa" = yes])
AM_CONDITIONAL([USE_ALSA_DLTRICK], [test "$alsadltrick" = yes])


AC_PATH_XTRA()
if test "$no_x" = "yes"; then
        dnl no X11
        AM_CONDITIONAL([USE_X11], [false])
        AM_CONDITIONAL([USE_XV], [false])
else
        AM_CONDITIONAL([USE_X11], [true])

        SDL_LIBS="$SDL_LIBS -lX11 -lXext"
        AC_SUBST(SDL_LIBS)

        LIBS="$LIBS $X_LIBS"
        AC_SUBST(LIBS)

        dnl this previously checked X11/extensions/XKB.h, but nothing
        dnl ever used it (xkb.c still included X11/XKBlib.h even when
        dnl autoconf reported it as nonexistent -- weird!)
        AC_CHECK_HEADERS(X11/Xlib.h X11/XKBlib.h)
        AC_CHECK_LIB(Xv, XvQueryExtension,,,-lX11 -lXext)
        if test "$ac_cv_lib_Xv_XvQueryExtension" = "yes"; then
                AC_CHECK_HEADERS(X11/extensions/Xvlib.h,,,[[
#include <X11/Xlib.h>
                ]])
                if test "$ac_cv_header_X11_extensions_xvlib_h" = "yes"; then
                        SDL_LIBS="$SDL_LIBS -lXv -lXext"
                        AC_SUBST(SDL_LIBS)
                        AM_CONDITIONAL([USE_XV], [true])
                elif test "$ac_cv_header_X11_extensions_Xvlib_h" = "yes"; then
                        SDL_LIBS="$SDL_LIBS -lXv -lXext"
                        AC_SUBST(SDL_LIBS)
                        AM_CONDITIONAL([USE_XV], [true])
                else
                        AM_CONDITIONAL([USE_XV], [false])
                fi
        else
                AM_CONDITIONAL([USE_XV], [false])
        fi
fi

dnl asdjklfjklasdfaskdfjklads
saved_LIBS="$LIBS"
AC_SEARCH_LIBS(socket, socket network)
LIBS="$saved_LIBS"
if test "x$ac_cv_search_socket" = "xno"; then
        dnl Windows sucks (I don't even know what this is about, but it apparently works)
        AC_CHECK_HEADERS(winsock.h winsock2.h)
        if test "x$ac_cv_header_winsock_h" = "xyes"; then
                socketlib="-lwsock32"
        elif test "x$ac_cv_header_winsock2_h" = "xyes"; then
                socketlib="-lws2_32"
        fi
        if test "x$socketlib" = "x"; then
                echo "*** No sockets for you!"
                AM_CONDITIONAL([USE_NETWORK], false)
        else
                AM_CONDITIONAL([USE_NETWORK], true)
                SDL_LIBS="$SDL_LIBS $socketlib"
                AC_SUBST(SDL_LIBS)
        fi
elif test "x$ac_cv_search_socket" = "xnone required"; then
        dnl free networking
        AM_CONDITIONAL([USE_NETWORK], true)
else
        SDL_LIBS="$SDL_LIBS $ac_cv_search_socket"
        AC_SUBST(SDL_LIBS)
        AM_CONDITIONAL([USE_NETWORK], true)
fi

#AC_CHECK_LIB(kernel32, GetConsoleMode, SDL_LIBS="$SDL_LIBS -Wl,--subsystem,console")

dnl wee...
dnl this completely sucks...
OBJC=$CC
OBJCFLAGS=$CFLAGS
AC_SUBST(OBJC)
AC_SUBST(OBJCFLAGS)

AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
© All Rights Reserved