From 0e4164ad0c8744efcbcceda2d7c1d70aa5e1d71a Mon Sep 17 00:00:00 2001 From: TingPing Date: Sat, 6 Sep 2014 08:04:52 -0400 Subject: configure: Improve various build flags - Store openssl flags in own vars - Share some common flags for plugins - Fix building plugins on win32 - Store all glib flags in one var - Don't link against every lib for each plugin - Don't hardcode ldflags for sysinfo --- configure.ac | 82 +++++++++++++++++++++----------------------- plugins/checksum/Makefile.am | 6 ++-- plugins/doat/Makefile.am | 4 +-- plugins/fishlim/Makefile.am | 6 ++-- plugins/perl/Makefile.am | 11 +++--- plugins/python/Makefile.am | 8 ++--- plugins/sysinfo/Makefile.am | 6 ++-- 7 files changed, 60 insertions(+), 63 deletions(-) diff --git a/configure.ac b/configure.ac index 36c20c0f..25f4f6ac 100644 --- a/configure.ac +++ b/configure.ac @@ -74,6 +74,13 @@ else fi fi +platform_win32=no +case $host_os in + *mingw*|*cygwin*|*msys*) + platform_win32=yes;; + *);; +esac + dnl ********************************************************************* dnl ** configure switches *********************************************** dnl ********************************************************************* @@ -183,17 +190,9 @@ dnl ********************************************************************* dnl ** GLIB ************************************************************* dnl ********************************************************************* -AM_PATH_GLIB_2_0(2.28.0, glib=yes, glib=no) -if test "$glib" = no; then - AC_MSG_ERROR(Cannot find GLib!) -fi - -PKG_CHECK_MODULES([GOBJECT], [gobject-2.0], [], [AC_MSG_ERROR(Cannot find gobject-2.0!)]) -PKG_CHECK_MODULES([GIO], [gio-2.0], [], [AC_MSG_ERROR(Cannot find gio-2.0!)]) -PKG_CHECK_MODULES([GMODULE], [gmodule-2.0], [], [AC_MSG_ERROR(Cannot find gmodule-2.0!)]) - -COMMON_CFLAGS="$GLIB_CFLAGS $GIO_CFLAGS $GOBJECT_CFLAGS $GMODULE_CFLAGS -DG_DISABLE_SINGLE_INCLUDES" -COMMON_LIBS="$GLIB_LIBS $GIO_LIBS $GOBJECT_LIBS $GMODULE_LIBS" +AM_PATH_GLIB_2_0([2.28.0], [], [AC_MSG_ERROR([Glib not found!])], [gmodule gobject gio]) +COMMON_CFLAGS="$GLIB_CFLAGS -DG_DISABLE_SINGLE_INCLUDES" +COMMON_LIBS="$GLIB_LIBS" dnl ********************************************************************* dnl ** GTK ************************************************************** @@ -376,17 +375,14 @@ dnl ********************************************************************* retry=no if test "$openssl" != no; then - AC_MSG_CHECKING(for openssl through pkg-config) - if $PKG_CONFIG openssl --exists; then - CPPFLAGS="$CPPFLAGS `$PKG_CONFIG openssl --cflags`" - LIBS="$LIBS `$PKG_CONFIG openssl --libs`" + PKG_CHECK_MODULES(OPENSSL, [openssl], [ AC_DEFINE(USE_OPENSSL) - AC_MSG_RESULT(yes) openssl=yes - else - AC_MSG_RESULT(no) + COMMON_LIBS="$COMMON_LIBS $OPENSSL_LIBS" + COMMON_CFLAGS="$COMMON_CFLAGS $OPENSSL_CFLAGS" + ], [ retry=yes - fi + ]) fi if test "$retry" = "yes"; then @@ -395,30 +391,29 @@ if test "$retry" = "yes"; then openssl_path=$openssl fi openssl=no - SAVED_LIBS=$LIBS - LIBS="$LIBS -lcrypto" + OPENSSL_LIBS="-lcrypto" if test -n "$openssl_path"; then - LIBS="-L$openssl_path/lib $LIBS" + OPENSSL_LIBS="-L$openssl_path/lib $OPENSSL_LIBS" fi - AC_CHECK_LIB(ssl, SSL_new, have_openssl=yes) - LIBS=$SAVED_LIBS - if test "$have_openssl" = yes; then - SAVED_CPPFLAGS=$CPPFLAGS + SAVED_LIBS=$LIBS + LIBS="$LIBS $OPENSSL_LIBS" + AC_CHECK_LIB(ssl, SSL_new, [ if test -n "$openssl_path"; then - CPPFLAGS="-I$openssl_path/include $CPPFLAGS" + OPENSSL_CFLAGS="-I$openssl_path/include" fi - AC_CHECK_HEADERS(openssl/ssl.h, have_openssl_h=yes) - if test "$have_openssl_h" = yes; then + SAVED_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS $OPENSSL_CFLAGS" + AC_CHECK_HEADERS(openssl/ssl.h, [ openssl=yes AC_DEFINE(USE_OPENSSL) - LIBS="$LIBS -lssl -lcrypto" - if test -n "$openssl_path"; then - LIBS="-L$openssl_path/lib $LIBS" - fi - else - CPPFLAGS=$SAVED_CPPFLAGS - fi - fi + OPENSSL_LIBS="$OPENSSL_LIBS -lssl" + + COMMON_LIBS="$COMMON_LIBS $OPENSSL_LIBS" + COMMON_CFLAGS="$COMMON_CFLAGS $OPENSSL_CFLAGS" + ]) + CFLAGS=$SAVED_CFLAGS + ]) + LIBS=$SAVED_LIBS fi dnl ********************************************************************* @@ -447,6 +442,10 @@ dnl ********************************************************************* if test "$plugin" = yes; then AC_DEFINE(USE_PLUGIN) + PLUGIN_LDFLAGS="-avoid-version" + if test "$platform_win32" = yes; then + PLUGIN_LDFLAGS="$PLUGIN_LDFLAGS -no-undefined" + fi fi dnl ********************************************************************* @@ -524,8 +523,7 @@ if test "x$dbus" = "xyes" ; then dbus=no ]) AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool, no) - AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal, no) - if test "x$DBUS_BINDING_TOOL" = "xno" || test "x$GLIB_GENMARSHAL" = "xno" || test "x$dbus" = "xno" ; then + if test "x$DBUS_BINDING_TOOL" = "xno" || test "x$dbus" = "xno" ; then dbus="no" else COMMON_LIBS="$COMMON_LIBS $DBUS_LIBS" @@ -805,12 +803,12 @@ AC_SUBST(PY_CFLAGS) AC_SUBST(PY_LIBS) AC_SUBST(DBUS_CFLAGS) AC_SUBST(DBUS_LIBS) +AC_SUBST(OPENSSL_LIBS) +AC_SUBST(OPENSSL_CFLAGS) +AC_SUBST(PLUGIN_LDFLAGS) m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], AC_SUBST([pkgconfigdir], ${libdir}/pkgconfig)) -PLUGIN_INCLUDES='-I$(top_srcdir)/plugins' -AC_SUBST(PLUGIN_INCLUDES) - dnl for plugin.c and pixmaps.c test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix="$prefix" diff --git a/plugins/checksum/Makefile.am b/plugins/checksum/Makefile.am index 419c762f..4e911f28 100644 --- a/plugins/checksum/Makefile.am +++ b/plugins/checksum/Makefile.am @@ -2,6 +2,6 @@ libdir = $(hexchatlibdir) lib_LTLIBRARIES = checksum.la checksum_la_SOURCES = checksum.c -checksum_la_LDFLAGS = -avoid-version -module -checksum_la_LIBADD = -AM_CPPFLAGS = $(COMMON_CFLAGS) -I$(srcdir)/../../src/common +checksum_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module +checksum_la_LIBADD = $(GLIB_LIBS) +checksum_la_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)/src/common diff --git a/plugins/doat/Makefile.am b/plugins/doat/Makefile.am index abfca29e..10b38cc6 100644 --- a/plugins/doat/Makefile.am +++ b/plugins/doat/Makefile.am @@ -2,7 +2,7 @@ libdir = $(hexchatlibdir) lib_LTLIBRARIES = doat.la doat_la_SOURCES = doat.c -doat_la_LDFLAGS = -avoid-version -module +doat_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module doat_la_LIBADD = -AM_CPPFLAGS = $(COMMON_CFLAGS) -I$(srcdir)/../../src/common +doat_la_CFLAGS = -I$(top_srcdir)/src/common diff --git a/plugins/fishlim/Makefile.am b/plugins/fishlim/Makefile.am index 255ea0c3..c57a4de9 100644 --- a/plugins/fishlim/Makefile.am +++ b/plugins/fishlim/Makefile.am @@ -4,6 +4,6 @@ libdir = $(hexchatlibdir) lib_LTLIBRARIES = fishlim.la fishlim_la_SOURCES = fish.c irc.c keystore.c misc.c plugin_hexchat.c -fishlim_la_LDFLAGS = -avoid-version -module -fishlim_la_LIBADD = -AM_CPPFLAGS = $(COMMON_CFLAGS) -I$(srcdir)/../../src/common +fishlim_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module +fishlim_la_LIBADD = $(GLIB_LIBS) $(OPENSSL_LIBS) +fishlim_la_CFLAGS = $(GLIB_CFLAGS) $(OPENSSL_CFLAGS) -I$(top_srcdir)/src/common diff --git a/plugins/perl/Makefile.am b/plugins/perl/Makefile.am index 79621549..7e7bbe68 100644 --- a/plugins/perl/Makefile.am +++ b/plugins/perl/Makefile.am @@ -6,12 +6,13 @@ libdir = $(hexchatlibdir) lib_LTLIBRARIES = perl.la perl_la_SOURCES = perl.c -perl_la_LDFLAGS = -avoid-version -module -perl_la_LIBADD = $(PERL_LDFLAGS) +perl_la_LDFLAGS = $(PERL_LDFLAGS) $(PLUGIN_LDFLAGS) -module +perl_la_LIBADD = $(PERL_LIBS) +perl_la_CFLAGS = $(PERL_CFLAGS) -I$(top_srcdir)/src/common + BUILT_SOURCES = hexchat.pm.h irc.pm.h -#CFLAGS = @CFLAGS@ -Wno-unused -AM_CPPFLAGS = $(PERL_CFLAGS) $(COMMON_CFLAGS) -I$(srcdir)/../../src/common -CLEANFILES = hexchat.pm.h irc.pm.h +CLEANFILES = $(BUILT_SOURCES) + hexchat.pm.h irc.pm.h: lib/HexChat.pm lib/Xchat.pm lib/HexChat/Embed.pm \ lib/HexChat/List/Network.pm lib/HexChat/List/Network/Entry.pm \ lib/HexChat/List/Network/AutoJoin.pm lib/IRC.pm diff --git a/plugins/python/Makefile.am b/plugins/python/Makefile.am index 259f2a0f..063f2009 100644 --- a/plugins/python/Makefile.am +++ b/plugins/python/Makefile.am @@ -1,10 +1,8 @@ -EXTRA_DIST = - libdir = $(hexchatlibdir) lib_LTLIBRARIES = python.la python_la_SOURCES = python.c -python_la_LDFLAGS = -avoid-version -module -python_la_LIBADD = $(PY_LIBS) -AM_CPPFLAGS = $(PY_CFLAGS) $(COMMON_CFLAGS) -I$(srcdir)/../../src/common +python_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module +python_la_LIBADD = $(PY_LIBS) $(GLIB_LIBS) +python_la_CFLAGS = $(PY_CFLAGS) $(GLIB_CFLAGS) -I$(top_srcdir)/src/common diff --git a/plugins/sysinfo/Makefile.am b/plugins/sysinfo/Makefile.am index 3e7ef1aa..4ac9c016 100644 --- a/plugins/sysinfo/Makefile.am +++ b/plugins/sysinfo/Makefile.am @@ -2,6 +2,6 @@ libdir = $(hexchatlibdir) lib_LTLIBRARIES = sysinfo.la sysinfo_la_SOURCES = match.c parse.c pci.c xsys.c -sysinfo_la_LDFLAGS = -avoid-version -module -sysinfo_la_LIBADD = -lpci -AM_CPPFLAGS = $(COMMON_CFLAGS) -I$(srcdir)/../../src/common +sysinfo_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module +sysinfo_la_LIBADD = $(LIBPCI_LIBS) $(GLIB_LIBS) +sysinfo_la_CFLAGS = $(LIBPCI_CFLAGS) $(GLIB_CFLAGS) -I$(srcdir)/../../src/common -- cgit 1.4.1