Skip to content

Instantly share code, notes, and snippets.

@hasufell
Created January 29, 2015 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hasufell/f9f810e8e348b192150a to your computer and use it in GitHub Desktop.
Save hasufell/f9f810e8e348b192150a to your computer and use it in GitHub Desktop.
Fix compilation with '--as-needed' in IceGenerator-0.5.5-pre2
From 4d0868e2f0a6acd8f0cb1625b9012d094d0a9111 Mon Sep 17 00:00:00 2001
From: hasufell <hasufell@gentoo.org>
Date: Thu, 29 Jan 2015 03:24:24 +0100
Subject: [PATCH] Clean up configure.ac
* use foo_LIBS instead of hacking on LDFLAGS which also solves
problems with '--as-needed' linker flag
* convert to modern autotools standards
* remove some obsolete parts
---
configure.ac | 174 +++++++++++++++++++++++++++++++++++++++++++++++++++++
configure.in | 184 --------------------------------------------------------
src/Makefile.am | 11 ++++
3 files changed, 185 insertions(+), 184 deletions(-)
create mode 100644 configure.ac
delete mode 100644 configure.in
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..ec3adad
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,174 @@
+AC_INIT([IceGenerator],0.5.5,administrator@tortugalabs.it)
+AC_COPYRIGHT([Copyright 2004 Tortuga Labs. Inc.])
+AC_CANONICAL_HOST
+AC_CONFIG_SRCDIR(src/main.cpp)
+AM_INIT_AUTOMAKE([-Wall])
+AM_CONFIG_HEADER(config.h)
+AM_SANITY_CHECK
+AM_MAINTAINER_MODE
+
+MAJOR_VERSION=0
+MINOR_VERSION=5
+RELEASE_VERSION=5
+VERSION="$MAJOR_VERSION.$MINOR_VERSION.$RELEASE_VERSION"
+
+if test "x$prefix" = xNONE; then
+ prefix=`eval echo ${ac_default_prefix}`
+fi
+
+if test "x$exec_prefix" = xNONE; then
+ exec_prefix=`eval echo ${ac_default_prefix}`
+fi
+
+dnl checks for programs needed to build.
+CXXFLAGS="$CXXFLAGS -ansi -pedantic"
+
+AC_PROG_INSTALL
+AC_PROG_CC
+AM_PROG_CC_STDC
+AC_PROG_CXX
+AC_LANG_CPLUSPLUS
+
+AC_PROG_MAKE_SET
+AC_PROG_LN_S
+
+
+dnl libshout path check
+AC_ARG_WITH([shout],
+ [AS_HELP_STRING([--with-shout=DIR],
+ [libshout include and library files prefix path])],
+ [shoutdir=$withval],
+ [shoutdir=""])
+
+dnl MySQL path check
+AC_ARG_WITH([mysql],
+ [AS_HELP_STRING([--with-mysql],
+ [MySQL support])],
+ [mysql_en="yes"],
+ [mysql_en=""])
+
+dnl PostGreSQL path check
+AC_ARG_WITH([pgsql],
+ [AS_HELP_STRING([--with-pgsql],
+ [PostGreSQL support])],
+ [pgsql_en="yes"],
+ [pgsql_en=""])
+
+dnl ID3 path check
+AC_ARG_WITH([id3],
+ [AS_HELP_STRING([--with-id3],
+ [ID3 support])],
+ [id3_en="yes"],
+ [id3_en=""])
+
+
+dnl check for POSIX Threads library
+echo -e $'\n'$'\n'POSIX Threads
+ACX_PTHREAD
+AC_CHECK_HEADERS(pthread.h)
+AC_CHECK_FUNCS(pthread_create pthread_join)
+dnl AC_TRY_LINK_FUNC(pthread_create,[have_pthread_funcs=yes],AC_MSG_ERROR([Could not link to libpthread. IceGenerator package uses the pthread library. Install libpthread first.]))
+dnl AC_TRY_LINK_FUNC(pthread_join,[have_pthread_funcs=yes],AC_MSG_ERROR([Could not link to libpthread. IceGenerator package uses the pthread library. Install libpthread first.]))
+
+dnl I/O functions
+echo -e $'\n'$'\n'I/O functions
+AC_HEADER_STDC
+AC_HEADER_STAT
+AC_CHECK_HEADERS(stdio.h fcntl.h)
+AC_CHECK_FUNCS(open read write close printf fopen fprintf fflush fclose sprintf unlink fread fwrite,[have_io_funcs=yes],AC_MSG_ERROR([required function missing]))
+
+dnl log functions
+echo -e $'\n'$'\n'System log functions
+AC_CHECK_HEADERS(syslog.h)
+AC_CHECK_FUNCS(openlog syslog closelog,[have_log_funcs=yes],AC_MSG_ERROR([required function missing]))
+
+dnl network functions
+echo -e $'\n'$'\n'Network functions
+AC_CHECK_HEADERS(sys/socket.h netinet/in.h arpa/inet.h)
+AC_CHECK_FUNCS(socket bind listen accept connect htons htonl inet_addr,[have_net_funcs=yes],AC_MSG_ERROR([required function missing]))
+TYPE_SOCKLEN_T
+
+dnl directory functions
+echo -e $'\n'$'\n'Directory functions
+AC_HEADER_DIRENT
+AC_CHECK_HEADERS(dirent.h)
+AC_CHECK_FUNCS(opendir readdir closedir,[have_dir_funcs=yes],AC_MSG_ERROR([required function missing]))
+
+dnl string/char functions
+echo -e $'\n'$'\n'String and character functions
+AC_CHECK_HEADERS(getopt.h ctype.h)
+AC_CHECK_FUNCS(getopt memset strcpy atoi strtok strcat strlen toupper strcmp strncmp bzero,[have_str_funcs=yes],AC_MSG_ERROR([required function missing]))
+
+dnl POSIX signal functions
+echo -e $'\n'$'\n'POSIX signal functions
+AC_CHECK_HEADERS(signal.h)
+AC_CHECK_FUNCS(sigaction sigemptyset sigaddset sigprocmask kill,[have_sigs_funcs=yes],AC_MSG_ERROR([required function missing]))
+
+dnl POSIX semaphores functions
+echo -e $'\n'$'\n'POSIX semaphores functions
+AC_CHECK_HEADERS(semaphore.h)
+AC_SEARCH_LIBS(sem_init, pthread rt)
+AC_CHECK_FUNCS(sem_init sem_destroy sem_wait sem_post,[have_sems_funcs=yes],AC_MSG_ERROR([required function missing]))
+
+dnl Utility functions
+echo -e $'\n'$'\n'Other functions
+AC_HEADER_TIME
+AC_STRUCT_TM
+AC_CHECK_HEADERS(time.h)
+AC_CHECK_FUNCS(sleep time srand rand getpid,[have_other_funcs=yes],AC_MSG_ERROR([required function missing]))
+
+dnl check for shout library path
+echo -e $'\n'$'\n'SHOUT library
+if test "$shoutdir" != "" ; then
+ SHOUT_CFLAGS="-I$withval/include"
+ SHOUT_LIBS="-L$withval/lib -lshout -lvorbis"
+ AC_CHECK_HEADERS($withval/include/shout/shout.h)
+else
+ PKG_CHECK_MODULES(SHOUT, shout >= 2.0)
+ AC_CHECK_HEADERS(shout/shout.h)
+fi
+AC_CHECK_LIB(shout,shout_init,[have_shout_funcs=yes],AC_MSG_ERROR([Could not link to libshout. IceGenerator package uses the libshout-2.0 library. Install libshout first.]),)
+
+dnl check for mysql library
+if test "$mysql_en" != "" ; then
+ echo -e $'\n'$'\n'MySQL library
+ MYSQL_CFLAGS=`mysql_config --cflags`
+ MYSQL_LIBS=`mysql_config --libs`
+ AC_CHECK_HEADERS(mysql/mysql.h)
+ AC_CHECK_LIB(mysqlclient,mysql_init,AC_DEFINE(HAVE_MYSQL,1,[MySQL is enabled]),AC_MSG_ERROR([Could not link to MySQL library.]),)
+fi
+
+dnl check for pgsql library
+if test "$pgsql_en" != "" ; then
+ echo -e $'\n'$'\n'PostGreSQL library
+ pgsql_cflags=`pg_config --includedir`
+ pgsql_lflags=`pg_config --libdir`
+ PGSQL_CFLAGS="-I$pgsql_cflags"
+ PGSQL_LIBS="-L$pgsql_lflags -lpq"
+ AC_CHECK_HEADERS(libpq-fe.h)
+ AC_CHECK_LIB(pq,PQconnectdb,AC_DEFINE(HAVE_PGSQL,1,[PgSQL is enabled]),AC_MSG_ERROR([Could not link to PgSQL library.]),)
+fi
+
+dnl check for id3 library
+if test "$id3_en" != "" ; then
+ echo -e $'\n'$'\n'ID3 library
+ AC_SEARCH_LIBS(ID3Tag_Link,"id3",
+ id3lib=yes
+ AC_DEFINE(HAVE_ID3, [], [Description]),
+ id3lib=no
+ AC_MSG_WARN(id3lib not found - disabling id3v2 support))
+dnl AC_CHECK_HEADERS(tag.h)
+fi
+
+dnl =================================================================
+dnl Always defined
+dnl =================================================================
+
+AC_DEFINE(__MT__,1,
+ [Always define this, for thread safety on some platforms.])
+
+SYSCONFDIR=`eval echo ${sysconfdir}`
+AC_SUBST(SYSCONFDIR)
+AC_DEFINE_UNQUOTED(DEFAULT_CONF_FILE,"`eval echo "${sysconfdir}/icegenerator.conf"`",[Default config file path])
+
+AC_OUTPUT(Makefile src/Makefile)
diff --git a/configure.in b/configure.in
deleted file mode 100644
index 6e654a4..0000000
--- a/configure.in
+++ /dev/null
@@ -1,184 +0,0 @@
-AC_INIT([IceGenerator],0.5.5,administrator@tortugalabs.it)
-AC_COPYRIGHT([Copyright 2004 Tortuga Labs. Inc.])
-AC_CANONICAL_HOST
-AC_CONFIG_SRCDIR(src/main.cpp)
-AM_INIT_AUTOMAKE(icegenerator,0.5.5)
-AM_CONFIG_HEADER(config.h)
-AM_SANITY_CHECK
-AM_MAINTAINER_MODE
-
-MAJOR_VERSION=0
-MINOR_VERSION=5
-RELEASE_VERSION=5
-VERSION="$MAJOR_VERSION.$MINOR_VERSION.$RELEASE_VERSION"
-
-if test "x$prefix" = xNONE; then
- prefix=`eval echo ${ac_default_prefix}`
-fi
-
-if test "x$exec_prefix" = xNONE; then
- exec_prefix=`eval echo ${ac_default_prefix}`
-fi
-
-dnl checks for programs needed to build.
-CXXFLAGS="-ansi -pedantic"
-
-AC_PROG_INSTALL
-AC_PROG_CC
-AM_PROG_CC_STDC
-AC_PROG_CXX
-AC_LANG_CPLUSPLUS
-
-AC_PROG_MAKE_SET
-AC_PROG_LN_S
-
-dnl debug check
-AC_ARG_ENABLE(debug,
- [ --enable-debug enable debug (default disabled)],
- [ CXXFLAGS="$CXXFLAGS -g" ],
- [ CXXFLAGS="$CXXFLAGS -pipe -Wall -O3" ])
-
-dnl libshout path check
-AC_ARG_WITH(shout,[ --with-shout=DIR libshout include and library files prefix path],[shoutdir=$withval],[shoutdir=""])
-
-dnl MySQL path check
-AC_ARG_WITH(mysql,[ --with-mysql MySQL support],[mysql_en="yes"],[mysql_en=""])
-
-dnl PostGreSQL path check
-AC_ARG_WITH(pgsql,[ --with-pgsql PostGreSQL support],[pgsql_en="yes"],[pgsql_en=""])
-
-dnl ID3 path check
-AC_ARG_WITH(id3,[ --with-id3 ID3 support],[id3_en="yes"],[id3_en=""])
-
-dnl checking mkdir -p
-AC_MSG_CHECKING([whether mkdir accepts -p])
-if (mkdir -p config.tmpdir/p && mkdir -p config.tmpdir/p 2>&1) > /dev/null; then
- AC_MSG_RESULT(yes)
- MKDIR="mkdir -p"
-else
- AC_MSG_RESULT(no)
- MKDIR=mkdir
-fi
-rm -rf config.tmpdir
-
-dnl check for POSIX Threads library
-echo -e $'\n'$'\n'POSIX Threads
-ACX_PTHREAD([
- LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
- CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
- ])
-AC_CHECK_HEADERS(pthread.h)
-AC_CHECK_FUNCS(pthread_create pthread_join)
-dnl AC_TRY_LINK_FUNC(pthread_create,[have_pthread_funcs=yes],AC_MSG_ERROR([Could not link to libpthread. IceGenerator package uses the pthread library. Install libpthread first.]))
-dnl AC_TRY_LINK_FUNC(pthread_join,[have_pthread_funcs=yes],AC_MSG_ERROR([Could not link to libpthread. IceGenerator package uses the pthread library. Install libpthread first.]))
-
-dnl I/O functions
-echo -e $'\n'$'\n'I/O functions
-AC_HEADER_STDC
-AC_HEADER_STAT
-AC_CHECK_HEADERS(stdio.h fcntl.h)
-AC_CHECK_FUNCS(open read write close printf fopen fprintf fflush fclose sprintf unlink fread fwrite,[have_io_funcs=yes],AC_MSG_ERROR([required function missing]))
-
-dnl log functions
-echo -e $'\n'$'\n'System log functions
-AC_CHECK_HEADERS(syslog.h)
-AC_CHECK_FUNCS(openlog syslog closelog,[have_log_funcs=yes],AC_MSG_ERROR([required function missing]))
-
-dnl network functions
-echo -e $'\n'$'\n'Network functions
-AC_CHECK_HEADERS(sys/socket.h netinet/in.h arpa/inet.h)
-dnl AC_CHECK_LIB(socket,socket,[LDFLAGS="$LDFLAGS -lsocket -lnsl"],,$LDFLAGS)
-ETR_SOCKET_NSL
-LDFLAGS="$LDFLAGS $ETR_SOCKET_LIBS"
-AC_CHECK_FUNCS(socket bind listen accept connect htons htonl inet_addr,[have_net_funcs=yes],AC_MSG_ERROR([required function missing]))
-TYPE_SOCKLEN_T
-
-dnl directory functions
-echo -e $'\n'$'\n'Directory functions
-AC_HEADER_DIRENT
-AC_CHECK_HEADERS(dirent.h)
-AC_CHECK_FUNCS(opendir readdir closedir,[have_dir_funcs=yes],AC_MSG_ERROR([required function missing]))
-
-dnl string/char functions
-echo -e $'\n'$'\n'String and character functions
-AC_CHECK_HEADERS(getopt.h ctype.h)
-AC_CHECK_FUNCS(getopt memset strcpy atoi strtok strcat strlen toupper strcmp strncmp bzero,[have_str_funcs=yes],AC_MSG_ERROR([required function missing]))
-
-dnl POSIX signal functions
-echo -e $'\n'$'\n'POSIX signal functions
-AC_CHECK_HEADERS(signal.h)
-AC_CHECK_FUNCS(sigaction sigemptyset sigaddset sigprocmask kill,[have_sigs_funcs=yes],AC_MSG_ERROR([required function missing]))
-
-dnl POSIX semaphores functions
-echo -e $'\n'$'\n'POSIX semaphores functions
-AC_CHECK_HEADERS(semaphore.h)
-AC_CHECK_LIB(rt,sem_init,[LDFLAGS="$LDFLAGS -lrt"],,$LDFLAGS)
-AC_CHECK_FUNCS(sem_init sem_destroy sem_wait sem_post,[have_sems_funcs=yes],AC_MSG_ERROR([required function missing]))
-
-dnl Utility functions
-echo -e $'\n'$'\n'Other functions
-AC_HEADER_TIME
-AC_STRUCT_TM
-AC_CHECK_HEADERS(time.h)
-AC_CHECK_FUNCS(sleep time srand rand getpid,[have_other_funcs=yes],AC_MSG_ERROR([required function missing]))
-
-dnl check for shout library path
-echo -e $'\n'$'\n'SHOUT library
-if test "$shoutdir" != "" ; then
- CXXFLAGS="$CXXFLAGS -I$withval/include"
- LDFLAGS="$LDFLAGS -L$withval/lib -lshout -lvorbis"
- AC_CHECK_HEADERS($withval/include/shout/shout.h)
-else
- PKG_CHECK_MODULES(SHOUT, shout >= 2.0)
- CXXFLAGS="$CXXFLAGS $SHOUT_CFLAGS"
- LDFLAGS="$LDFLAGS $SHOUT_LIBS"
- AC_CHECK_HEADERS(shout/shout.h)
-fi
-AC_CHECK_LIB(shout,shout_init,[have_shout_funcs=yes],AC_MSG_ERROR([Could not link to libshout. IceGenerator package uses the libshout-2.0 library. Install libshout first.]),$LDFLAGS)
-
-dnl check for mysql library
-if test "$mysql_en" != "" ; then
- echo -e $'\n'$'\n'MySQL library
- mysql_cflags=`mysql_config --cflags`
- mysql_lflags=`mysql_config --libs`
- CXXFLAGS="$CXXFLAGS $mysql_cflags"
- LDFLAGS="$LDFLAGS $mysql_lflags"
- AC_CHECK_HEADERS(mysql/mysql.h)
- AC_CHECK_LIB(mysqlclient,mysql_init,AC_DEFINE(HAVE_MYSQL,1,[MySQL is enabled]),AC_MSG_ERROR([Could not link to MySQL library.]),$LDFLAGS)
-fi
-
-dnl check for pgsql library
-if test "$pgsql_en" != "" ; then
- echo -e $'\n'$'\n'PostGreSQL library
- pgsql_cflags=`pg_config --includedir`
- pgsql_lflags=`pg_config --libdir`
- CXXFLAGS="$CXXFLAGS -I$pgsql_cflags"
- LDFLAGS="$LDFLAGS -L$pgsql_lflags -lpq"
- AC_CHECK_HEADERS(libpq-fe.h)
- AC_CHECK_LIB(pq,PQconnectdb,AC_DEFINE(HAVE_PGSQL,1,[PgSQL is enabled]),AC_MSG_ERROR([Could not link to PgSQL library.]),$LDFLAGS)
-fi
-
-dnl check for id3 library
-if test "$id3_en" != "" ; then
- echo -e $'\n'$'\n'ID3 library
- AC_SEARCH_LIBS(ID3Tag_Link,"id3 -lz -lstdc++",
- id3lib=yes
- AC_DEFINE(HAVE_ID3, [], [Description])
- LDFLAGS="$LDFLAGS -lid3 -lz -lstdc++",
- id3lib=no
- AC_MSG_WARN(id3lib not found - disabling id3v2 support))
-dnl AC_CHECK_HEADERS(tag.h)
-fi
-
-dnl =================================================================
-dnl Always defined
-dnl =================================================================
-
-AC_DEFINE(__MT__,1,
- [Always define this, for thread safety on some platforms.])
-
-SYSCONFDIR=`eval echo ${sysconfdir}`
-AC_SUBST(SYSCONFDIR)
-AC_DEFINE_UNQUOTED(DEFAULT_CONF_FILE,"`eval echo "${sysconfdir}/icegenerator.conf"`",[Default config file path])
-
-AC_OUTPUT(Makefile src/Makefile)
diff --git a/src/Makefile.am b/src/Makefile.am
index 2ebca45..56dae5f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,4 +2,15 @@ bin_PROGRAMS = icegenerator
icegenerator_SOURCES = circular.cpp log.cpp streamer.cpp sgnl_handler.cpp synch.cpp config.cpp main.cpp selector.cpp data_streamer.cpp data_server.cpp player.cpp meta_parser.cpp
+icegenerator_CPPFLAGS = \
+ $(PTHREAD_CFLAGS) \
+ $(SHOUT_CFLAGS) \
+ $(MYSQL_CFLAGS) \
+ $(PGSQL_CFLAGS)
+
+icegenerator_LDADD = $(PTHREAD_LIBS) \
+ $(SHOUT_LIBS) \
+ $(MYSQL_LIBS) \
+ $(PGSQL_LIBS)
+
noinst_HEADERS = circular.h log.h streamer.h sgnl_handler.h synch.h config.h player.h data_streamer.h data_server.h main.h selector.h globals.h meta_parser.h
--
2.2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment