[PATCH] Fix various problems with non-standard build configurations.

From: "Ned T. Crigler" <crigler@gmail.com> Libraries should be prepended to $LIBS instead of appended, as the linker only does a single left-to-right pass over the command line. This sometimes showed up as link errors (such as when shared libraries are not being used) when -lssl came after -lcrypto, since -lssl depends on -lcrypto. Also, we were not actually using the include path for zlib detected by configure, as it was setting $CPPFLAGS, which wasn't being used in the Makefiles. --- configure.in | 26 +++++++++++++++----------- src/Makefile.in | 11 +++++------ tools/Makefile.in | 10 ++++++---- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/configure.in b/configure.in index 2ffb108..140eb97 100644 --- a/configure.in +++ b/configure.in @@ -394,7 +394,7 @@ if test "$check_hmodules" = "yes"; then AC_CHECK_FUNCS(dlopen dlsym, [set_hmodules="enabled"]) if test "$set_hmodules" = "enabled"; then AC_DEFINE(USE_HOOKMODULES) - MOD_LIBS="-Wl,-export-dynamic" + MOD_LDFLAGS="-Wl,-export-dynamic" fi fi @@ -440,7 +440,7 @@ if test "X$cf_enable_openssl" != "Xno" ; then if test "X$cf_openssl_basedir" != "X" ; then if test -f "${cf_openssl_basedir}/include/openssl/opensslv.h" ; then SSL_INCLUDES="-I${cf_openssl_basedir}/include" - SSL_LIBS="-L${cf_openssl_basedir}/lib" + SSL_LDFLAGS="-L${cf_openssl_basedir}/lib" else dnl OpenSSL wasn't found in the directory specified. Naughty dnl administrator... @@ -460,7 +460,9 @@ if test "X$cf_enable_openssl" != "Xno" ; then dnl If we have a basedir defined, then everything is okay. Otherwise, dnl we have a problem. if test "X$cf_openssl_basedir" != "X" ; then - LIBS="$save_LIBS $SSL_LIBS -lcrypto" + CPPFLAGS="$CPPFLAGS $SSL_INCLUDES" + LDFLAGS="$LDFLAGS $SSL_LDFLAGS" + LIBS="-lssl -lcrypto $save_LIBS" AC_MSG_RESULT($cf_openssl_basedir) cf_enable_openssl="yes" encryption="enabled" @@ -613,7 +615,7 @@ fi if test "$solaris2" != "yes" && test "$aix" != "yes" && test "$set_hmodules" = "enabled"; then - LIBS="$LIBS $MOD_LIBS" + LDFLAGS="$LDFLAGS $MOD_LDFLAGS" fi if test "$check_maxconnections" = "auto"; then @@ -691,10 +693,14 @@ then fi if test -n "${ZLIB_HOME}" then - ZLIB_OLD_LDFLAGS=$LDFLAGS - ZLIB_OLD_CPPFLAGS=$LDFLAGS - LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" - CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" + ZLIB_OLD_CPPFLAGS="$CPPFLAGS" + ZLIB_OLD_LDFLAGS="$LDFLAGS" + if test "x$ZLIB_HOME" = "x/usr"; then + : + else + CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" + LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" + fi AC_LANG_PUSH([C]) AC_CHECK_LIB(z, inflateEnd, [zlib_cv_libz=yes], [zlib_cv_libz=no]) AC_CHECK_HEADER(zlib.h, [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no]) @@ -712,8 +718,8 @@ then # If either header or library was not found, revert and bomb # AC_MSG_CHECKING(zlib in ${ZLIB_HOME}) + CPPFLAGS="$ZLIB_OLD_CPPFLAGS" LDFLAGS="$ZLIB_OLD_LDFLAGS" - CPPFLAGS="$ZLIB_OLD_CPPFLAGS" AC_MSG_RESULT(failed) AC_MSG_ERROR(either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib) fi @@ -729,8 +735,6 @@ fi INSTALL_DIR="${prefix}" -AC_SUBST(SSL_INCLUDES) -AC_SUBST(SSL_LIBS) AC_SUBST(LIBS) AC_SUBST(SENGINE) AC_SUBST(INSTALL_DIR) diff --git a/src/Makefile.in b/src/Makefile.in index 5a63328..e0cb628 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,15 +1,15 @@ CC=@CC@ RM=@RM@ MV=@MV@ -IRCDLIBS=@LIBS@ -lssl -INCLUDEDIR=-I../include -OPENSSLINC=@SSL_INCLUDES@ +IRCDLIBS=@LIBS@ ENGINE=@SENGINE@ CRYPTO=@ENCRYPT_SRC@ INSTALL=@INSTALL@ INSTALL_BIN=@INSTALL_PROGRAM@ INSTALL_DIR=@INSTALL_DIR@ CFLAGS=@CFLAGS@ -fno-strict-aliasing +CPPFLAGS=@CPPFLAGS@ -I../include +LDFLAGS=@LDFLAGS@ RES_SRC = @@ -46,10 +46,10 @@ distclean: clean $(RM) -f Makefile version.c.last .c.o: - $(CC) $(CFLAGS) $(INCLUDEDIR) -c $< + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< ircd: $(OBJECTS) - $(CC) ${LDFLAGS} -o ircd $(OBJECTS) $(IRCDLIBS) + $(CC) $(LDFLAGS) -o ircd $(OBJECTS) $(IRCDLIBS) mv version.c version.c.last install: @@ -347,7 +347,6 @@ dh.o: dh.c ../include/memcount.h ../include/struct.h ../include/config.h \ ../include/sbuf.h ../include/h.h ../include/send.h ../include/fdlist.h \ ../include/ircsprintf.h ../include/find.h ../include/blalloc.h \ ../include/throttle.h ../include/queue.h ../include/dh.h - $(CC) $(CFLAGS) $(OPENSSLINC) $(INCLUDEDIR) -c $< rc4.o: rc4.c ../include/memcount.h ../include/struct.h \ ../include/config.h ../include/setup.h ../include/defs.h \ ../include/sys.h ../include/hash.h ../include/sbuf.h ../include/h.h \ diff --git a/tools/Makefile.in b/tools/Makefile.in index 9756987..161ad23 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -7,7 +7,9 @@ IRCDLIBS=@LIBS@ INSTALL=@INSTALL@ INSTALL_BIN=@INSTALL_PROGRAM@ INSTALL_DIR=@INSTALL_DIR@ -INCLUDEDIR=-I../include +CFLAGS=@CFLAGS@ -fno-strict-aliasing +CPPFLAGS=@CPPFLAGS@ -I../include +LDFLAGS=@LDFLAGS@ mkpasswd_SOURCES = mkpasswd.c mkpasswd_OBJECTS = mkpasswd.o @@ -22,10 +24,10 @@ all: mkpasswd convert_conf build: all mkpasswd: $(mkpasswd_OBJECTS) - $(CC) -o mkpasswd $(mkpasswd_OBJECTS) $(IRCDLIBS) + $(CC) $(LDFLAGS) -o mkpasswd $(mkpasswd_OBJECTS) $(IRCDLIBS) convert_conf: $(convert_conf_OBJECTS) - $(CC) -o convert_conf $(convert_conf_OBJECTS) $(IRCDLIBS) + $(CC) $(LDFLAGS) -o convert_conf $(convert_conf_OBJECTS) $(IRCDLIBS) clean: $(RM) -f $(all_OBJECTS) mkpasswd convert_conf *~ core make-cert.sh @@ -34,7 +36,7 @@ distclean: clean $(RM) -f Makefile .c.o: - $(CC) $(CFLAGS) $(INCLUDEDIR) -c $< + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< install: @for i in $(PROGRAMS); do \ -- 1.7.5.4
participants (1)
-
Ned T. Crigler