oops, that commit wasn't so clean
[hrr.git] / configure.in
blob0aa924c84f2c3f485ecc2fe01ea4bde04fb97c9a
1 #  m m mm mmm .----------.  .---------------------. mmm mm m m
2 #  8 8 88 888 | .--------`  |  .------------------` 888 88 8 8
3 #  8 8 88 888 | ```````|`V```````|   |``||``|`````| 888 88 8 8
4 #  8 8 88 888 `------  | |  [] | |``````||  |  [] | 888 88 8 8
5 #  8 8 88 888 |``````  | |     | ````|````  |     | 888 88 8 8
6 #  ` ` `` ``` ``````````````>  |````````````|   |`` ``` `` ` `
7 #                ==============`            `---`
8 #                                 L A B O R A T O R I E S
9 #  
10 #This file is part of Hacker Radio Rec.
11 #  
12 #Hacker Radio Rec is free software: you can redistribute it and/or
13 #modify it under the terms of the GNU General Public License as
14 #published by the Free Software Foundation, either version 3 of
15 #the License or (at your option) any later version.
17 #Hacker Radio Rec is distributed in the hope that it will be
18 #useful, but WITHOUT ANY WARRANTY; without even the implied
19 #warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 #See the GNU General Public License for more details.
22 #               Copyright (C) 2009, Thea DeSilva
23 #  You can find a copy of GNU General Public License in COPYING
28 AC_REVISION($Revision: 1 $)
29 AC_INIT(hrr,0.1)
31 AC_CONFIG_HEADER([config.h])
33 VERSION=0.1
35 AC_DEFUN(AC_PROGRAM_SOURCE,
36 [AC_REQUIRE([AC_PROG_CPP])AC_PROVIDE([$0])cat > conftest.c <<EOF
37 #include "confdefs.h"
38 [$1]
39 _CUT_HERE_
40 [$2]
41 EOF
42 eval "$ac_cpp conftest.c 2>&5 | sed -e '1,/_CUT_HERE_/d' -e 's/ //g' > conftest.out"
43 . ./conftest.out
44 rm -f conftest*
45 ])dnl
46 dnl
47 define(AC_NOTE,
48 [echo "$1" 1>&AC_FD_MSG
49 ])dnl
52 AC_SUBST(VERSION)
53 AC_PREFIX_PROGRAM(hrr)
54 AC_PREFIX_PROGRAM(gzip)
56 old_CFLAGS="$CFLAGS"
57 AC_PROG_CC
58 AC_PROG_CPP
59 AC_PROG_GCC_TRADITIONAL
60 AC_ISC_POSIX
62 AC_TRY_RUN(main(){exit(0);},,[
63 if test $CC != cc ; then
64 CC=cc
65 export CC
66 exec $0 $configure_args
70 AC_TRY_RUN(main(){exit(0);},,
71 exec 5>&2
72 eval $ac_link
73 AC_NOTE(CC=$CC; CFLAGS=$CFLAGS; LIBS=$LIBS;)
74 AC_NOTE($ac_compile)
75 AC_MSG_ERROR(Can't run the compiler - sorry))
77 AC_TRY_RUN([
78 main()
80   int __something_strange_();
81   __something_strange_(0);
83 ],AC_MSG_ERROR(Your compiler does not set the exit status - sorry))
85 AC_PROG_INSTALL
87 if test -f etc/toolcheck; then
88 AC_CHECKING(for buggy tools)
89 sh etc/toolcheck 1>&AC_FD_MSG
94 dnl
95 dnl    ****  special unix variants  ****
96 dnl
97 if test -n "$ISC"; then
98   AC_DEFINE(ISC) LIBS="$LIBS -linet"
101 dnl AC_CHECKING(for OSF1)
102 dnl if test -f /bin/uname ; then
103 dnl if test `/bin/uname` = OSF1 || test -f /osf_boot; then
104 dnl AC_DEFINE(OSF1)     # this disables MIPS again....
105 dnl fi
106 dnl fi
108 if test -f /sysV68 ; then
109 AC_DEFINE(sysV68)
112 AC_CHECKING(for MIPS)
113 if test -f /lib/libmld.a || test -f /usr/lib/libmld.a || test -f /usr/lib/cmplrs/cc/libmld.a; then
114 oldlibs="$LIBS"
115 test -f /bin/mx || LIBS="$LIBS -lmld" # for nlist. But not on alpha.
116 dnl djm@eng.umd.edu: "... for one thing, it doubles the size of the executable"
117 AC_CHECKING(mld library)
118 AC_TRY_LINK(,,,LIBS="$oldlibs")
121 if test -r /dev/ptc; then
122 AC_DEFINE(MIPS)
123 AC_CHECKING(wait3)
124 AC_TRY_LINK(,[wait3();], ,
125 AC_CHECKING(wait2)
126 AC_TRY_LINK(,[wait2();],
127 dnl John Rouillard (rouilj@sni-usa.com):
128 dnl need -I/usr/include/bsd in RISCOS otherwise sockets are broken, no
129 dnl job control etc.
130 dnl Detect RISCOS if wait2 is present, but not wait3.
131 AC_DEFINE(USE_WAIT2) LIBS="$LIBS -lbsd" ; CC="$CC -I/usr/include/bsd"
136 AC_CHECKING(for Ultrix)
137 AC_EGREP_CPP(yes,
138 [#if defined(ultrix) || defined(__ultrix)
139    yes;
140 #endif
141 ], ULTRIX=1)
143 if test -f /usr/lib/libpyr.a ; then
144 oldlibs="$LIBS"
145 LIBS="$LIBS -lpyr"
146 AC_CHECKING(Pyramid OSX)
147 AC_TRY_LINK(,[open_controlling_pty("")], AC_DEFINE(OSX), LIBS="$oldlibs")
150 dnl ghazi@caip.rutgers.edu (Kaveh R. Ghazi):
151 dnl BBN butterfly is not POSIX, but a MACH BSD system.
152 dnl Do not define POSIX and TERMIO.
153 AC_CHECKING(for butterfly)
154 AC_EGREP_CPP(yes,
155 [#if defined(butterfly)
156   yes;
157 #endif
158 ], butterfly=1)
160 if test -z "$butterfly"; then
161 if test -n "$ULTRIX"; then
162   test -z "$GCC" && CC="$CC -YBSD"
164 AC_CHECKING(for POSIX.1)
165 AC_EGREP_CPP(yes,
166 [#include <sys/types.h>
167 #include <unistd.h>
168 main () {
169 #ifdef _POSIX_VERSION
170   yes;
171 #endif
172 ], AC_NOTE(- you have a POSIX system) AC_DEFINE(POSIX) posix=1)
175 AC_CHECKING(for System V)
176 AC_TRY_COMPILE(
177 [#include <sys/types.h>
178 #include <signal.h>
179 #include <fcntl.h>], [int x = SIGCHLD | FNDELAY;], , AC_DEFINE(SYSV))
181 AC_CHECKING(for sequent/ptx)
182 AC_EGREP_CPP(yes,
183 [#ifdef _SEQUENT_
184   yes;
185 #endif
186 ], LIBS="$LIBS -lsocket -linet";seqptx=1)
188 oldlibs="$LIBS"
189 LIBS="$LIBS -lelf"
190 AC_CHECKING(SVR4)
191 AC_TRY_LINK([#include <utmpx.h>
193 [AC_CHECK_HEADER(dwarf.h, AC_DEFINE(SVR4) AC_DEFINE(BUGGYGETLOGIN),
194 [AC_CHECK_HEADER(elf.h, AC_DEFINE(SVR4) AC_DEFINE(BUGGYGETLOGIN))])]
195 ,LIBS="$oldlibs")
197 AC_CHECKING(for Solaris 2.x)
198 AC_EGREP_CPP(yes,
199 [#if defined(SVR4) && defined(sun)
200   yes
201 #endif
202 ], LIBS="$LIBS -lsocket -lnsl -lkstat")
205 dnl    ****  typedefs ****
207 dnl (currently not used)
209 AC_CHECKING(for pid_t)
210 AC_EGREP_CPP(pid_t,[#include <sys/types.h>
211 ],AC_DEFINE(PID_T_DEFINED))
213 AC_CHECKING(for sig_t)
214 AC_EGREP_CPP(sig_t,[#include <sys/types.h>
215 #include <signal.h>
216 ],AC_DEFINE(SIG_T_DEFINED))
218 AC_CHECKING(for uid_t)
219 AC_EGREP_CPP(uid_t,[#include <sys/types.h>
220 ],AC_DEFINE(UID_T_DEFINED))
223 dnl    ****  setreuid(), seteuid()  ****
225 AC_CHECKING(setreuid)
226 AC_TRY_LINK(,[
227 #ifdef __hpux
228 setresuid(0, 0, 0);
229 #else
230 setreuid(0, 0);
231 #endif
232 ], AC_DEFINE(HAVE_SETREUID))
234 dnl seteuid() check:
235 dnl   linux seteuid was broken before V1.1.11
236 dnl   NeXT, AUX, ISC, and ultrix are still broken (no saved uid support)
237 dnl   Solaris seteuid doesn't change the saved uid, bad for
238 dnl     multiuser screen sessions
239 AC_CHECKING(seteuid)
240 AC_TRY_LINK(,[
241 #if defined(linux) || defined(NeXT) || defined(_AUX_SOURCE) || defined(AUX) || defined(ultrix) || (defined(sun) && defined(SVR4)) || defined(ISC) || defined(sony_news)
242 seteuid_is_broken(0);
243 #else
244 seteuid(0);
245 #endif
246 ], AC_DEFINE(HAVE_SETEUID))
249 dnl    ****  signal handling  ****
251 if test -n "$posix" ; then
253 dnl POSIX has reliable signals with void return type.
254 AC_NOTE(assuming posix signal definition)
255 AC_DEFINE(SIGVOID)
257 else
259 AC_CHECKING(return type of signal handlers)
260 AC_TRY_COMPILE(
261 [#include <sys/types.h>
262 #include <signal.h>
263 #ifdef signal
264 #undef signal
265 #endif
266 extern void (*signal ()) ();], [int i;], AC_DEFINE(SIGVOID))
267 AC_CHECKING(sigset)
268 AC_TRY_LINK([
269 #include <sys/types.h>
270 #include <signal.h>
272 #ifdef SIGVOID
273 sigset(0, (void (*)())0);
274 #else
275 sigset(0, (int (*)())0);
276 #endif
277 ], AC_DEFINE(USESIGSET))
278 AC_CHECKING(signal implementation)
279 AC_TRY_RUN([
280 #include <sys/types.h>
281 #include <signal.h>
283 #ifndef SIGCLD
284 #define SIGCLD SIGCHLD
285 #endif
286 #ifdef USESIGSET
287 #define signal sigset
288 #endif
290 int got;
292 #ifdef SIGVOID
293 void
294 #endif
295 hand()
297   got++;
300 main()
302   /* on hpux we use sigvec to get bsd signals */
303 #ifdef __hpux
304   (void)signal(SIGCLD, hand);
305   kill(getpid(), SIGCLD);
306   kill(getpid(), SIGCLD);
307   if (got < 2)
308     exit(1);
309 #endif
310   exit(0);
312 ],,AC_DEFINE(SYSVSIGS))
317 dnl    ****  misc things  ****
319 AC_CHECKING(wait union)
320 AC_TRY_COMPILE([#include <sys/types.h>
321 #include <sys/wait.h>
323   union wait x;
324   int y;
325 #ifdef WEXITSTATUS
326   y = WEXITSTATUS(x);
327 #endif
328 ],AC_DEFINE(BSDWAIT))
330 if test -z "$butterfly"; then
331 AC_CHECKING(for termio or termios)
332 AC_TRY_CPP([#include <termio.h>], AC_DEFINE(TERMIO),
333 if test -n "$posix"; then
334 AC_TRY_CPP([#include <termios.h>], AC_DEFINE(TERMIO))
340 AC_CHECKING(whether memcpy/memmove/bcopy handles overlapping arguments)
341 AC_TRY_RUN([
342 main() {
343   char buf[10];
344   strcpy(buf, "abcdefghi");
345   bcopy(buf, buf + 2, 3);
346   if (strncmp(buf, "ababcf", 6))
347     exit(1);
348   strcpy(buf, "abcdefghi");
349   bcopy(buf + 2, buf, 3);
350   if (strncmp(buf, "cdedef", 6))
351     exit(1);
352   exit(0); /* libc version works properly.  */
353 }], AC_DEFINE(USEBCOPY))
355 AC_TRY_RUN([
356 #define bcopy(s,d,l) memmove(d,s,l)
357 main() {
358   char buf[10];
359   strcpy(buf, "abcdefghi");
360   bcopy(buf, buf + 2, 3);
361   if (strncmp(buf, "ababcf", 6))
362     exit(1);
363   strcpy(buf, "abcdefghi");
364   bcopy(buf + 2, buf, 3);
365   if (strncmp(buf, "cdedef", 6))
366     exit(1);
367   exit(0); /* libc version works properly.  */
368 }], AC_DEFINE(USEMEMMOVE))
371 AC_TRY_RUN([
372 #define bcopy(s,d,l) memcpy(d,s,l)
373 main() {
374   char buf[10];
375   strcpy(buf, "abcdefghi");
376   bcopy(buf, buf + 2, 3);
377   if (strncmp(buf, "ababcf", 6))
378     exit(1);
379   strcpy(buf, "abcdefghi");
380   bcopy(buf + 2, buf, 3);
381   if (strncmp(buf, "cdedef", 6))
382     exit(1);
383   exit(0); /* libc version works properly.  */
384 }], AC_DEFINE(USEMEMCPY))
386 AC_MSG_CHECKING(long file names)
387 (echo 1 > /tmp/conftest9012345) 2>/dev/null
388 (echo 2 > /tmp/conftest9012346) 2>/dev/null
389 val=`cat /tmp/conftest9012345 2>/dev/null`
390 if test -f /tmp/conftest9012345 && test "$val" = 1; then
391 AC_MSG_RESULT(yes)
392 else
393 AC_MSG_RESULT(no)
394 AC_DEFINE(NAME_MAX, 14)
396 rm -f /tmp/conftest*
398 AC_MSG_CHECKING(for vsprintf)
399 AC_TRY_LINK(,[vsprintf(0,0,0);], AC_MSG_RESULT(yes);AC_DEFINE(USEVARARGS), AC_MSG_RESULT(no))
401 AC_HEADER_DIRENT
403 AC_MSG_CHECKING(for setenv)
404 AC_TRY_LINK(,[setenv((char *)0,(char *)0);unsetenv((char *)0);], AC_MSG_RESULT(yes);AC_DEFINE(USESETENV),
405 AC_MSG_RESULT(no)
406 AC_MSG_CHECKING(for putenv)
407 AC_TRY_LINK(,[putenv((char *)0);unsetenv((char *)0);], AC_MSG_RESULT(yes) ,  AC_MSG_RESULT(no);AC_DEFINE(NEEDPUTENV)
410 if test -z "$old_CFLAGS"; then
411   if test "x$CFLAGS" = "x-g"; then
412     CFLAGS="-O"
413   fi
415 dnl Ptx bug workaround -- insert -lc after -ltermcap
417 AC_TRY_RUN(main(){exit(0);},,AC_MSG_ERROR(Can't run the compiler - internal error. Sorry.))
419 $CC -o errors errors.c
421 if ! test -a errors; then
422  echo "Can't use the compiler to compile errors.c, which is used in the rest of this configuration"
423  exit;
426 AC_CHECK_PROG([HAVELEX], [lex], "true", "false")
427 if test "$HAVELEX" = "false"; then
428  ./errors no_lex
429  exit;
432 HRR_CHECK_HEAD(Xlib.h,  X11/, no_x11)
433 HRR_CHECK_LIB(X11,XOpenDisplay)
436 HRR_CHECK_HEAD(SDL.h, SDL/, no_sdl_head)
437 HRR_CHECK_LIB(SDL, SDL_Init, no_sdl)
440 HRR_CHECK_HEAD(SDL_image.h, SDL/, no_sdl_image_head)
441 HRR_CHECK_LIB(SDL_image, IMG_Load, no_sdl_image)
444 dnl 
445 dnl ** check for libav libraries/headers
448 HRR_CHECK_HEAD(avdevice.h, libavdevice/, no_ffmpeg_devel)
449 HRR_CHECK_HEAD(avformat.h, libavformat/, no_ffmpeg_devel)
450 HRR_CHECK_HEAD(avcodec.h, libavcodec/, no_ffmpeg_devel)
451 HRR_CHECK_HEAD(swscale.h, libswscale/, no_ffmpeg_devel)
452 HRR_CHECK_HEAD(fifo.h, libavutil/, no_ffmpeg_devel)
453 HRR_CHECK_HEAD(avstring.h, libavutil/, no_ffmpeg_devel)
457 HRR_CHECK_LIB(avcodec, avpicture_fill, no_ffmpeg)
458 HRR_CHECK_LIB(avformat, av_read_frame, no_ffmpeg)
459 HRR_CHECK_LIB(swscale, sws_scale, no_ffmpeg)
460 HRR_CHECK_LIB(avutil, av_rescale, no_ffmpeg)
461 HRR_CHECK_LIB(avdevice, avdevice_register_all, no_ffmpeg)
463 HRR_CHECK_LIB(bz2, BZ2_bzopen, no_bz2)
464 HRR_CHECK_LIB(pthread, pthread_kill, no_pthread)
466 AC_C_BIGENDIAN([AC_DEFINE(BIG_ENDIAN,1,[big_endian])],
467                [AC_DEFINE(LITTLE_ENDIAN,1,[little_endian])])
469 if test "$prefix" = "/"; then
470  PREFIX=/usr/
471 else
472  PREFIX=$prefix
475 AC_SUBST(PREFIX)
479 AC_CHECK_PROG([PERL_PATH], [perl], `which perl`, "false")
480 if test "$PERL_PATH" = "false"; then
481  ./errors no_perl
482  exit;
486 AC_SUBST(PERL_PATH)
489 dnl 
490 dnl *** wow, hope all that worked 
493 CFLAGS=$CFLAGS\ -w
495 AC_OUTPUT(Makefile gui/Makefile audio/Makefile not/Makefile tools/bin2head)
497 chmod +x tools/bin2head
498 cat confdefs.h >> config.h
500 ./errors all_is_well