[lokisetup] [PATCH] more control over static/dynamic linking

Ludwig Nussel ludwig.nussel at gmx.de
Mon Dec 20 11:18:14 EST 2004


Stephane Peter wrote:
> >And while we are at it here is another patch for non-static libz.
> >Would probably cause unexpected effects if it's linked statically
> >and drawn in dynamically at the same time.
> 
> Well I do care quite a lot about unexpected side effects. ;-) Your last 
> patch completely broke the static linking of GTK on non-Linux 
> platforms, which I critically needed for my own projects. I have fixed 
> this now, but it's still very delicate to alter the linking system 
> without breaking something.

Another try. Patches to configure how gtk, libz and gpm should be
linked as well as a patch to show a summary at the end of configure
run. I do not have any non-Linux operating system so I cannot test
whether it breaks on such systems.

cu
Ludwig

-- 
(o_  Ludwig.Nussel at gmx.de
//\
V_/_ PGP Key ID: FF8135CE
-------------- next part --------------
Index: loki_setup/configure.in
===================================================================
--- loki_setup.orig/configure.in
+++ loki_setup/configure.in
@@ -353,6 +353,13 @@ if test "x$enable_libncurses_static" = "
 	NCURSES_STATIC="$BSTATIC"
 fi
 
+AC_ARG_ENABLE(libz-static,
+[  --enable-libz-static            whether to statically link libz (default=yes)],,
+enable_libz_static=yes)
+if test "x$enable_libz_static" = "xyes"; then
+	LIBZ_STATIC="$BSTATIC"
+fi
+
 AC_CHECK_HEADERS(ncurses/term.h)
 AC_CHECK_HEADERS(ncurses/curses.h)
 AC_CHECK_HEADERS(ncurses.h)
@@ -505,20 +512,20 @@ fi
 LIBS="$LIBS $BZ2_STATIC $BZ2LIB $BDYNAMIC"
 
 if test ! -z "$USE_LIBINTL"; then
-	LIBINTL="$BSTATIC $LIBINTL -lz \$(BDYNAMIC)"
+	LIBINTL="$BSTATIC $LIBINTL \$(BDYNAMIC)"
 	LIBS="$LIBS $LIBINTL"
 	GUI_LIBS="$GUI_LIBS $LIBINTL"
 	CARBON_LIBS="$CARBON_LIBS $LIBINTL"
-else
-	if test "$STATIC" = ""; then
-		LIBS="$LIBS $BSTATIC -lz \$(BDYNAMIC)"
-	else
-		LIBS="$LIBS -lz"
-	fi
-	GUI_LIBS="$GUI_LIBS $BSTATIC -lz \$(BDYNAMIC)"
-	CARBON_LIBS="$CARBON_LIBS $BSTATIC -lz \$(BDYNAMIC)"
 fi
 
+# libz
+if test "$STATIC" = ""; then
+	LIBS="$LIBS $LIBZ_STATIC -lz $BDYNAMIC"
+else
+	LIBS="$LIBS -lz"
+fi
+GUI_LIBS="$GUI_LIBS $LIBZ_STATIC -lz $BDYNAMIC"
+CARBON_LIBS="$CARBON_LIBS $LIBZ_STATIC -lz $BDYNAMIC"
 
 if test ! -z "$USE_NCURSES"; then
 	if test "$STATIC" = ""; then
-------------- next part --------------
Index: loki_setup/configure.in
===================================================================
--- loki_setup.orig/configure.in
+++ loki_setup/configure.in
@@ -267,8 +267,6 @@ AC_CHECK_HEADERS(libintl.h)
 AC_CHECK_HEADERS(langinfo.h)
 AC_CHECK_HEADERS(locale.h)
 
-AC_CHECK_LIB(gpm, Gpm_Open, USE_GPM=yes)
-
 dnl Check for gtk12 libraries in case those are available (FreeBSD)
 AC_CHECK_LIB(glib12, g_log, GTK12="12")
 
@@ -332,6 +330,17 @@ AC_ARG_WITH(ncurses,
 	USE_NCURSES=yes
 )	
 
+AC_ARG_ENABLE(gpm,
+[  --enable-gpm            enable gpm support (yes/no/static, default=no)],,
+enable_gpm=no)
+if test "x$enable_gpm" = "xstatic"; then
+	GPM_STATIC="$BSTATIC"
+	USE_GPM=yes
+elif test "x$enable_gpm" = "xyes"; then
+	GPM_STATIC=""
+	USE_GPM=yes
+fi
+
 AC_ARG_ENABLE(libglade-static,
 [  --enable-libglade-static            whether to statically link libglade (default=yes)],,
 enable_libglade_static=yes)
@@ -541,9 +550,10 @@ else
 	fi
 fi
 
-if test ! -z "$USE_GPM"; then
-	AC_CHECK_HEADERS(gpm.h)
-	CONSOLE_LIBS="$CONSOLE_LIBS -lgpm"
+if test "x$USE_GPM" = "xyes"; then
+	AC_CHECK_LIB(gpm, Gpm_Open,[:],AC_MSG_ERROR([libgpm not found]))
+	AC_CHECK_HEADERS(gpm.h,,AC_MSG_ERROR([gpm.h not found]))
+	CONSOLE_LIBS="$CONSOLE_LIBS $GPM_STATIC -lgpm \$(BDYNAMIC)"
 fi
 
 X11_LIBS="\$(BDYNAMIC) $X_PRE_LIBS -L$x_libraries -lXi -lXext -lX11 -lm"
@@ -623,6 +633,3 @@ AC_SUBST(BRAND)
 AC_SUBST(BDYNAMIC)
 
 AC_OUTPUT(Makefile plugins/Makefile dialog/Makefile)
-
-
-
-------------- next part --------------
Index: loki_setup/configure.in
===================================================================
--- loki_setup.orig/configure.in
+++ loki_setup/configure.in
@@ -183,12 +183,13 @@ case "$target" in
         ARCH=`uname -p 2> /dev/null || uname -m` ;;
 esac
 
-GTK_STATIC=$BSTATIC
 case "$target" in
 	*linux*)
-# Newer glibc's require to depend at least on them
+		# Newer glibc's require to depend at least on them
 		STATIC=""
-		GTK_STATIC="\$(BDYNAMIC)" ;;
+		want_gtk_static=no ;;
+	*)
+		want_gtk_static=yes ;;
 esac
 
 CFLAGS="$CFLAGS $REENTRANT"
@@ -227,8 +228,8 @@ fi
 
 CFLAGS="$CFLAGS -I$SETUPDB"
 
-GUI_LIBS=$GTK_STATIC
-GTK_LIBS=$GTK_STATIC
+GUI_LIBS=
+GTK_LIBS=
 #!!!TODO - Add carbon libs as necessary
 CARBON_LIBS=
 
@@ -341,6 +342,13 @@ elif test "x$enable_gpm" = "xyes"; then
 	USE_GPM=yes
 fi
 
+AC_ARG_ENABLE(gtk-static,
+[  --enable-gtk-static            whether to statically link gtk and glib (default=$want_gtk_static)],,
+enable_gtk_static=$want_gtk_static)
+if test "x$enable_gtk_static" = "xyes"; then
+	GTK_STATIC="$BSTATIC"
+fi
+
 AC_ARG_ENABLE(libglade-static,
 [  --enable-libglade-static            whether to statically link libglade (default=yes)],,
 enable_libglade_static=yes)
@@ -417,7 +425,7 @@ if test ! -z "$HAVEGTK"; then
     GLIB_PREFIX=`$HAVEGLIB --prefix`
 
     CFLAGS="$CFLAGS $GTK_CFLAGS"
-    GTK_LIBS="$GTK_LIBS -L$GTK_PREFIX/lib$LIBSUFFIX -L$GLIB_PREFIX/lib$LIBSUFFIX -lgtk$GTK12 -lgdk$GTK12 $RDYNAMIC -lgmodule$GTK12 -lglib$GTK12"
+    GTK_LIBS="$GTK_STATIC -L$GTK_PREFIX/lib$LIBSUFFIX -L$GLIB_PREFIX/lib$LIBSUFFIX -lgtk$GTK12 -lgdk$GTK12 $RDYNAMIC -lgmodule$GTK12 -lglib$GTK12 $BDYNAMIC"
     GUI_LIBS="$GUI_LIBS $GTK_LIBS"
 else
     AC_MSG_ERROR([*** gtk-config not found. You need a working GTK+ 1.2 installation.])
-------------- next part --------------
Index: loki_setup/configure.in
===================================================================
--- loki_setup.orig/configure.in
+++ loki_setup/configure.in
@@ -337,9 +337,13 @@ enable_gpm=no)
 if test "x$enable_gpm" = "xstatic"; then
 	GPM_STATIC="$BSTATIC"
 	USE_GPM=yes
+	gpm_summary=static
 elif test "x$enable_gpm" = "xyes"; then
 	GPM_STATIC=""
 	USE_GPM=yes
+	gpm_summary=dynamic
+else
+	gpm_summary=no
 fi
 
 AC_ARG_ENABLE(gtk-static,
@@ -347,6 +351,9 @@ AC_ARG_ENABLE(gtk-static,
 enable_gtk_static=$want_gtk_static)
 if test "x$enable_gtk_static" = "xyes"; then
 	GTK_STATIC="$BSTATIC"
+	gtk_summary=static
+else
+	gtk_summary=dynamic
 fi
 
 AC_ARG_ENABLE(libglade-static,
@@ -354,6 +361,9 @@ AC_ARG_ENABLE(libglade-static,
 enable_libglade_static=yes)
 if test "x$enable_libglade_static" = "xyes"; then
 	GLADE_STATIC="$BSTATIC"
+	glade_summary=static
+else
+	glade_summary=dynamic
 fi
 
 AC_ARG_ENABLE(libxml-static,
@@ -361,6 +371,9 @@ AC_ARG_ENABLE(libxml-static,
 enable_libxml_static=yes)
 if test "x$enable_libxml_static" = "xyes"; then
 	XML_STATIC="$BSTATIC"
+	xml_summary=static
+else
+	xml_summary=dynamic
 fi
 
 AC_ARG_ENABLE(libncurses-static,
@@ -368,6 +381,9 @@ AC_ARG_ENABLE(libncurses-static,
 enable_libncurses_static=yes)
 if test "x$enable_libncurses_static" = "xyes"; then
 	NCURSES_STATIC="$BSTATIC"
+	ncurses_summary=static
+else
+	ncurses_summary=dynamic
 fi
 
 AC_ARG_ENABLE(libz-static,
@@ -375,6 +391,9 @@ AC_ARG_ENABLE(libz-static,
 enable_libz_static=yes)
 if test "x$enable_libz_static" = "xyes"; then
 	LIBZ_STATIC="$BSTATIC"
+	libz_summary=static
+else
+	libz_summary=dynamic
 fi
 
 AC_CHECK_HEADERS(ncurses/term.h)
@@ -438,7 +457,9 @@ if test x$HAVE_BZIP2_SUPPORT = xyes; the
     AC_DEFINE(BZIP2_DLOPEN, 1, open libbz2 using dlopen)
     BZ2LIB="-ldl"
     BZ2_STATIC=""
+    bzip2_summary=dlopen
   else
+    bzip2_summary=static
     BZ2LIB="-lbz2"
     BZ2_STATIC="$BSTATIC"
     if test x$LIBBZ2_PREFIX = xyes; then
@@ -457,6 +478,8 @@ if test x$HAVE_BZIP2_SUPPORT = xyes; the
        fi		
     esac
   fi
+else
+    bzip2_summary=no
 fi
 
 AC_ARG_ENABLE(dialog,
@@ -556,6 +579,7 @@ else
 	else
 		CONSOLE_LIBS="$CONSOLE_LIBS -lcurses"
 	fi
+	ncurses_summary="static, curses"
 fi
 
 if test "x$USE_GPM" = "xyes"; then
@@ -641,3 +665,12 @@ AC_SUBST(BRAND)
 AC_SUBST(BDYNAMIC)
 
 AC_OUTPUT(Makefile plugins/Makefile dialog/Makefile)
+
+AC_MSG_NOTICE([linked libraries:])
+AC_MSG_NOTICE([gtk:             $gtk_summary])
+AC_MSG_NOTICE([libxml:          $xml_summary])
+AC_MSG_NOTICE([libglade:        $glade_summary])
+AC_MSG_NOTICE([ncurses:         $ncurses_summary])
+AC_MSG_NOTICE([libz:            $libz_summary])
+AC_MSG_NOTICE([bzip2:           $bzip2_summary])
+AC_MSG_NOTICE([gpm:             $gpm_summary])
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://icculus.org/pipermail/lokisetup/attachments/20041220/5dd1e3ad/attachment.pgp>


More information about the Lokisetup mailing list