1dnl Process this file with autoconf to produce a configure script. 2dnl --------------------- 3dnl I found a great tutorial on autoconf: 4dnl http://mi.eng.cam.ac.uk/~er258/code/autoconf/index.html 5dnl --------------------- 6dnl These macros create entries in config.h 7dnl AC_CHECK_HEADERS, AC_CHECK_TYPES, AC_CHECK_FUNCS 8dnl These macros do not 9dnl AC_CHECK_LIB: prepends the library to LIBS 10dnl AC_CHECK_FUNC: defines a shell variable 11 12AC_PREREQ(2.59) 13AC_INIT(streamripper,1.64.6) 14AM_INIT_AUTOMAKE 15 16AC_CONFIG_HEADERS([lib/config.h]) 17 18dnl Checks for programs. 19AC_PROG_CC 20 21if test -n "$GCC"; then 22 CFLAGS="$CFLAGS -Wall" 23fi 24 25AC_PROG_INSTALL 26AC_PROG_RANLIB 27 28dnl test for inline 29AC_C_INLINE 30 31dnl Checks for libraries. 32dnl Replace `main' with a function in -lm: 33AC_CHECK_LIB(m, main) 34 35dnl Yummy alloca() 36AC_FUNC_ALLOCA 37 38dnl Configure options 39 40AC_ARG_WITH(included-libmad, 41 [ --with-included-libmad use the libmad library included with streamripper]) 42 43dnl AC_ARG_WITH(included-glib, 44dnl [ --with-included-glib use the glib library included with streamripper]) 45 46dnl AC_ARG_WITH(included-tre, 47dnl [ --with-included-tre use the tre library included with streamripper]) 48 49AC_ARG_WITH(included-argv, 50 [ --with-included-argv use argv.c included with streamripper]) 51 52dnl AC_ARG_WITH(included-cdk, 53dnl [ --with-included-cdk use the cdk library included with streamripper]) 54 55AC_ARG_WITH(curses, 56 [ --with-curses(=XXX) compile curses front-end (XXX is curses (default), ncurses, ncursesw, pdcurses or slang)]) 57 58 59CPPFLAGS="-D__UNIX__" 60AC_SUBST(CPPFLAGS) 61 62 63dnl -------- Tests for using included glib ------ 64 65dnl use_included_glib=no 66dnl if test "x$with_included_glib" = xyes; then 67dnl if test ! -d glib-2.16.6; then 68dnl AC_MSG_ERROR([Using included glib not available from tarball.]) 69dnl fi 70dnl use_included_glib=yes 71dnl GLIB_LIBS="glib-2.16.6/glib/.libs/libglib-2.0.a" 72dnl AC_CONFIG_SUBDIRS(glib-2.16.6) 73dnl else 74dnl AM_PATH_GLIB_2_0(2.16.0,,AC_MSG_ERROR([Glib 2.16 or greater required])) 75dnl fi 76dnl AM_CONDITIONAL(SUBDIR_GLIB, test "x$with_included_glib" = xyes) 77 78AM_PATH_GLIB_2_0(2.16.0,,AC_MSG_ERROR([Glib 2.16 or greater required])) 79 80dnl -------- Tests for using included libmad ------ 81LIBMAD="" 82AC_SUBST(LIBMAD) 83use_included_libmad=yes 84if test "x$with_included_libmad" != xyes; then 85 sr_save_CPPFLAGS="$CPPFLAGS" 86 CPPFLAGS="-Ilib -D__UNIX__" 87 AC_SUBST(CPPFLAGS) 88 AC_CHECK_LIB(mad, mad_stream_buffer, 89 use_included_libmad=no, 90 use_included_libmad=yes) 91 CPPFLAGS="$sr_save_CPPFLAGS" 92 AC_SUBST(CPPFLAGS) 93fi 94AM_CONDITIONAL(SUBDIR_LIBMAD, test "$use_included_libmad" = yes) 95if test "$use_included_libmad" = yes; then 96 LIBMAD="libmad-0.15.1b/.libs/libmad.a" 97 AC_SUBST(LIBMAD) 98 AC_CONFIG_SUBDIRS(libmad-0.15.1b) 99else 100 LIBMAD=-lmad 101 AC_SUBST(LIBMAD) 102fi 103 104dnl -------- Tests for threading library ---------- 105THREADLIBS=no 106AC_CHECK_LIB(pthread,pthread_create,THREADLIBS="-lpthread",) 107if test "$THREADLIBS" = no; then 108 AC_CHECK_LIB(c_r,pthread_create,THREADLIBS="-pthread",) 109fi 110if test "$THREADLIBS" = no; then 111 AC_CHECK_LIB(dce,pthread_create,THREADLIBS="-ldce",) 112fi 113if test "$THREADLIBS" = no; then 114 AC_CHECK_LIB(pthreads,pthread_create,THREADLIBS="-lpthreads",) 115fi 116if test "$THREADLIBS" = no; then 117 AC_MSG_ERROR(Your system doesn't seem to support posix threads) 118 exit 119fi 120AC_SUBST(THREADLIBS) 121 122dnl Socklen 123TYPE_SOCKLEN_T 124 125dnl Checks for header files. 126AC_HEADER_DIRENT 127AC_HEADER_STDC 128AC_CHECK_HEADERS(unistd.h) 129 130dnl -------- Tests for wchar support --------- 131dnl Wchar support is either all or nothing. All the following 132dnl must be present: 133dnl 1) Working wchar in C library 134dnl 2) Regular expression library with wide character support 135dnl 3) iconv library 136 137dnl It seems that it could be in wchar.h, stddef.h, or builtin 138AC_CHECK_HEADERS(wchar.h) 139AC_CHECK_HEADERS(wctype.h) 140AC_CHECK_TYPES([wchar_t],[],[],[ 141#if HAVE_WCHAR_H 142#include <wchar.h> 143#endif 144#if STDC_HEADERS 145#include <stddef.h> 146#endif 147]) 148dnl -- More wide character madness. 149dnl FreeBSD doesn't have an iswcntrl() 150AC_CHECK_FUNCS(iswcntrl) 151dnl Linux is missing vswprintf prototype 152AC_CHECK_FUNCS(vswprintf) 153AC_FUNC_MBRTOWC 154 155dnl -------- Check for iconv & related 156AM_ICONV 157AM_LANGINFO_CODESET 158SR_FIND_LOCALE_CHARSET 159 160dnl -------- Check for wchar support 161dnl This is will be used and updated in the regex test below 162have_wchar=no 163if test "$ac_cv_type_wchar_t" = yes; then 164if test "$ac_cv_func_mbrtowc" = yes; then 165if test "$ac_cv_func_iswcntrl" = yes; then 166if test "$am_cv_func_iconv" = yes; then 167 have_wchar=yes 168fi 169fi 170fi 171fi 172 173dnl -------- Tests for regular expressions --------- 174dnl Preference: 175dnl 1) Use system tre if installed 176dnl 2a) If we don't have wchar, use system regex 177dnl 2b) If we have wchar, and system regex has regwcomp, use system regex 178dnl 3) Use included tre 179dnl Note: If using included tre, it's not easy to know whether or not 180dnl it will compile with regwcomp() or not. We will assume it does. 181dnl Note: Solaris now has a regwcomp() in system regex. Is it compatible? 182dnl LIBREGEX="" 183dnl AC_SUBST(LIBREGEX) 184dnl use_included_tre=no 185dnl if test "$with_included_tre" = "yes"; then 186dnl use_included_tre=yes 187dnl else 188dnl AC_CHECK_LIB(tre,regwcomp) 189dnl if test "$ac_cv_lib_tre_regwcomp" = "no"; then 190dnl if test "$have_wchar" = "yes"; then 191dnl if test "$with_included_tre" = "no"; then 192dnl AC_CHECK_FUNC(regwcomp,,have_wchar=no) 193dnl else 194dnl AC_CHECK_FUNC(regwcomp,,use_included_tre=yes) 195dnl fi 196dnl fi 197dnl if test "$have_wchar" = "no"; then 198dnl AC_CHECK_LIB(tre,regcomp) 199dnl if test "$ac_cv_lib_tre_regcomp" = "no"; then 200dnl if test "$with_included_tre" = "no"; then 201dnl AC_CHECK_FUNC(regcomp,,AC_MSG_ERROR([cannot find regular expression library])) 202dnl else 203dnl AC_CHECK_FUNC(regcomp,use_included_tre=no) 204dnl fi 205dnl fi 206dnl fi 207dnl fi 208dnl fi 209dnl AM_CONDITIONAL(SUBDIR_TRE, test "$use_included_tre" = yes) 210dnl if test "$use_included_tre" = "yes"; then 211dnl LIBREGEX="tre-0.7.2/lib/.libs/libtre.a" 212dnl AC_SUBST(LIBREGEX) 213dnl AC_CONFIG_SUBDIRS(tre-0.7.2) 214dnl fi 215 216dnl -------- WCHAR support revisited 217dnl if test "$have_wchar" = yes; then 218dnl AC_DEFINE(HAVE_WCHAR_SUPPORT,1,[Define to 1 if you have wide characters, iconv, and regwcomp]) 219dnl fi 220 221dnl -------- Tests for using libiberty or argv.c 222use_included_argv=yes 223if test "x$with_included_argv" != xyes; then 224 AC_CHECK_LIB(iberty, buildargv, 225 use_included_argv=no, 226 use_included_argv=yes) 227fi 228AM_CONDITIONAL(USE_INCLUDED_ARGV, test "$use_included_argv" = yes) 229if test "$use_included_argv" = yes; then 230 LIBIBERTY_LIBS="" 231 AC_SUBST(LIBIBERTY_LIBS) 232else 233 LIBIBERTY_LIBS="-liberty" 234 AC_SUBST(LIBIBERTY_LIBS) 235fi 236 237dnl -------- Tests for using faad2 ------ 238AC_SUBST(FAAD_LIBS) 239AC_CHECK_LIB(faad,NeAACDecDecode2,[ 240 FAAD_LIBS="-lfaad" 241 AC_DEFINE(HAVE_FAAD,1,[Define to 1 if you have faad2 libraries installed]) 242 ], 243 AC_DEFINE(HAVE_FAAD,0,[Define to 1 if you have faad2 libraries installed])) 244AC_SUBST(FAAD_LIBS) 245 246dnl -------- Tests for curses ------ 247if test x$with_curses = xyes || test x$with_curses = x ; then 248 found_curses=no 249 if test x$found_curses = xno; then 250 AC_CHECK_LIB(ncurses , initscr, [ 251 found_curses=yes 252 with_curses=ncurses 253 ]) 254 fi 255 if test x$found_curses = xno; then 256 AC_CHECK_LIB(curses , initscr, [ 257 found_curses=yes 258 with_curses=curses 259 ]) 260 fi 261 if test x$found_curses = xno; then 262 AC_CHECK_LIB(ncursesw, initscr, [ 263 found_curses=yes 264 with_curses=ncursesw 265 ]) 266 fi 267 if test x$found_curses = xno; then 268 AC_CHECK_LIB(pdcurses, initscr, [ 269 found_curses=yes 270 with_curses=pdcurses 271 ]) 272 fi 273 if test x$found_curses = xno; then 274 with_curses=no 275 fi 276fi 277 278case x$with_curses in 279xcurses) 280 CF_WITH_CURSES_DIR 281 AC_MSG_NOTICE([Request for curses]) 282 ;; 283xncurses) 284 CF_WITH_CURSES_DIR 285 AC_MSG_NOTICE([Request for ncurses]) 286 ;; 287xncursesw) 288 CF_WITH_CURSES_DIR 289 AC_MSG_NOTICE([Request for ncursesw]) 290 ;; 291xpdcurses) 292 AC_MSG_NOTICE([Request for pdncurses]) 293 ;; 294xno) 295 AC_MSG_NOTICE([Request no curses]) 296 ;; 297esac 298 299dnl << GCS -- left off debugging here >> 300dnl exit 301 302dnl -------- Tests for using included cdk ------ 303dnl CDK_LIBS="" 304dnl use_included_cdk=no 305dnl use_cdk=no 306dnl if test "$with_included_cdk" = "yes"; then 307dnl use_included_cdk=yes 308dnl use_cdk=yes 309dnl CDK_LIBS="-lcdk -lncurses" 310dnl AC_DEFINE(HAVE_CDK,1,[Define to 1 if you have cdk libraries installed]) 311dnl else 312dnl dnl LDFLAGS="$LDFLAGS -L/usr/local/lib" 313dnl dnl INCLUDES="$INCLUDES -I/usr/local/include" 314dnl AC_CHECK_LIB(cdk,initCDKScreen,[ 315dnl use_cdk=yes 316dnl CDK_LIBS="-lcdk -lncurses" 317dnl AC_DEFINE(HAVE_CDK,1,[Define to 1 if you have cdk libraries installed]) 318dnl ],[],[-lncurses]) 319dnl fi 320dnl AM_CONDITIONAL(SUBDIR_CDK, test "x$use_included_cdk" = "xyes") 321dnl AC_SUBST(CDK_LIBS) 322 323AM_CONDITIONAL([WANT_CSTREAMRIPPER],[test x$use_cdk != xno]) 324 325dnl -------- Tests for using ogg/vorbis ------ 326AC_SUBST(VORBIS_CFLAGS) 327AC_SUBST(VORBIS_LIBS) 328AC_SUBST(OGG_CFLAGS) 329AC_SUBST(OGG_LIBS) 330sr_have_ogg=no 331XIPH_PATH_OGG([ 332 XIPH_PATH_VORBIS([ 333 AC_SUBST(OGG_CFLAGS) 334 AC_SUBST(OGG_LIBS) 335 AC_SUBST(VORBIS_CFLAGS) 336 AC_SUBST(VORBIS_LIBS) 337 AC_DEFINE(HAVE_OGG_VORBIS,1,[Define to 1 if you have both the ogg and vorbis libraries installed]) 338 sr_have_ogg=yes 339 ], 340 AC_DEFINE(HAVE_OGG_VORBIS,0,[Define to 1 if you have both the ogg and vorbis libraries installed]))], 341 AC_DEFINE(HAVE_OGG_VORBIS,0,[Define to 1 if you have both the ogg and vorbis libraries installed]) 342 ) 343 344dnl -------- Check for semaphore library ------ 345AC_CHECK_FUNC(sem_init, , AC_CHECK_LIB(sem, sem_init,)) 346dnl Solaris needs this: -lrt 347AC_CHECK_FUNC(sem_init, , AC_CHECK_LIB(rt, sem_init,)) 348 349dnl -------- Check for integer sizes ------ 350dnl uint32_t vs. u_int32_t 351dnl ISO C 99 requires uint32_t, but u_int32_t is more common(?) 352AC_CHECK_HEADERS(stdint.h) 353AC_CHECK_HEADERS(inttypes.h) 354AC_CHECK_TYPES([uint32_t, u_int32_t]) 355dnl (maybe these are needed in the future) 356dnl AC_CHECK_SIZEOF(short) 357dnl AC_CHECK_SIZEOF(int) 358dnl AC_CHECK_SIZEOF(long) 359 360dnl Sockets header needed on Solaris 361AC_CHECK_HEADERS(sys/sockio.h) 362 363dnl -- GCS: Taken from distcc -- 364dnl The following test taken from the cvs sources via Samba: 365dnl If we can't find connect, try looking in -lsocket, -lnsl, and -linet. 366dnl The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has 367dnl libsocket.so which has a bad implementation of gethostbyname (it 368dnl only looks in /etc/hosts), so we only look for -lsocket if we need 369dnl it. 370AC_CHECK_FUNCS(connect) 371if test x"$ac_cv_func_connect" = x"no"; then 372 case "$LIBS" in 373 *-lnsl*) ;; 374 *) AC_CHECK_LIB(nsl_s, printf) ;; 375 esac 376 case "$LIBS" in 377 *-lnsl*) ;; 378 *) AC_CHECK_LIB(nsl, printf) ;; 379 esac 380 case "$LIBS" in 381 *-lsocket*) ;; 382 *) AC_CHECK_LIB(socket, connect) ;; 383 esac 384 case "$LIBS" in 385 *-linet*) ;; 386 *) AC_CHECK_LIB(inet, connect) ;; 387 esac 388 dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value 389 dnl has been cached. 390 if test x"$ac_cv_lib_socket_connect" = x"yes" || 391 test x"$ac_cv_lib_inet_connect" = x"yes"; then 392 dnl ac_cv_func_connect=yes 393 dnl don't! it would cause AC_CHECK_FUNC to succeed next time configure is run 394 AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()]) 395 fi 396fi 397dnl (GCS: I don't think I need these) 398dnl AC_CHECK_LIB(resolv, hstrerror, , , [-lnsl -lsocket]) 399dnl AC_CHECK_LIB(resolv, inet_aton, , , [-lnsl -lsocket]) 400 401dnl Checks for typedefs, structures, and compiler characteristics. 402AC_TYPE_SIZE_T 403 404dnl Checks for library functions. 405AC_TYPE_SIGNAL 406AC_FUNC_VPRINTF 407AC_CHECK_FUNCS(mkdir socket strerror strstr) 408 409AC_OUTPUT(lib/Makefile Makefile) 410 411cat <<EOF 412* Streamripper configuration 413 Using included MAD library? $use_included_libmad 414dnl Using included CDK library? $use_included_cdk 415dnl Using included GLIB library? $use_included_glib 416 Ogg/vorbis support? $sr_have_ogg 417EOF 418 419