[Libreoffice] gbuild of external libraries and question about apparently special case like zlib, jpeg etc.

Norbert Thiebaud nthiebaud at gmail.com
Mon Sep 5 03:44:21 PDT 2011


On Mon, Sep 5, 2011 at 4:47 AM, Caolán McNamara <caolanm at redhat.com> wrote:

> As an aside, for prettyness, it would be nice to have the external
> headers and libs always installed in inc/external libs/external and add
> -I -L to the compiler/linker to find them. I gave a go at this at one
> stage but fell into some trap or other with the odbc headers IIRC

It may be easier to have --prefix=$(SOLARVER)/external  (and then
things in external/lib external/include)
but then again why bother with 'external'. surely we don't want to
pick and choose between system header and our local one for the same
library.
if we have the local one we use it all he time right ?

What I did for zlib to keep, somewhat' the current behavior is a patch
that allow to specify the name of the library in configure:

With that I can ./configure + make  + make install . no deliver, no
name mangling
But that solution was relatively easy for zlib because the configure
is actually not the standard autotools
I'm not sure that would transpose to other, more complicated external
libraries...

--- a/configure 2011-09-04 01:04:57.739956936 -0500
+++ b/configure 2011-09-04 01:11:25.436743937 -0500
@@ -18,8 +18,7 @@
     CROSS_PREFIX="${CHOST}-"
 fi

-STATICLIB=libz.a
-LDFLAGS="${LDFLAGS} -L. ${STATICLIB}"
+basename="libz"
 VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
 VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < zlib.h`
 VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
@@ -67,9 +66,10 @@
       echo 'usage:'
       echo '  configure [--zprefix] [--prefix=PREFIX]  [--eprefix=EXPREFIX]'
       echo '    [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]'
-      echo '    [--includedir=INCLUDEDIR]'
+      echo '    [--includedir=INCLUDEDIR] [--basename=BASELIBNAME]'
         exit 0 ;;
     -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
+    -b*=* | --basename=*) basename=`echo $1 | sed 's/.*=//'`; shift ;;
     -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
     -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
     --sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
@@ -89,6 +89,9 @@
     esac
 done

+STATICLIB="${basename}.a"
+LDFLAGS="${LDFLAGS} -L. ${STATICLIB}"
+
 test=ztest$$
 cat > $test.c <<EOF
 extern int getchar();
@@ -118,7 +121,7 @@
     uname=`(uname -s || echo unknown) 2>/dev/null`
   fi
   case "$uname" in
-  Linux* | linux* | GNU | GNU/* | *BSD | DragonFly)
LDSHARED=${LDSHARED-"$cc -shared
-Wl,-soname,libz.so.1,--version-script,zlib.map"} ;;
+  Linux* | linux* | GNU | GNU/* | *BSD | DragonFly)
LDSHARED=${LDSHARED-"$cc -shared
-Wl,-soname,${basename}.so.1,--version-script,zlib.map"} ;;
   CYGWIN* | Cygwin* | cygwin* | OS/2*)
         EXE='.exe' ;;
   MINGW*|mingw*)
@@ -131,21 +134,21 @@
         EXE='.exe' ;;
   QNX*)  # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
          # (alain.bonnefoy at icbt.com)
-                 LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;;
+                 LDSHARED=${LDSHARED-"$cc -shared -Wl,-h${basename}.so.1"} ;;
   HP-UX*)
          LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
          case `(uname -m || echo unknown) 2>/dev/null` in
          ia64)
                  shared_ext='.so'
-                 SHAREDLIB='libz.so' ;;
+                 SHAREDLIB='${basename}.so' ;;
          *)
                  shared_ext='.sl'
-                 SHAREDLIB='libz.sl' ;;
+                 SHAREDLIB='${basename}.sl' ;;
          esac ;;
   Darwin*)   shared_ext='.dylib'
-             SHAREDLIB=libz$shared_ext
-             SHAREDLIBV=libz.$VER$shared_ext
-             SHAREDLIBM=libz.$VER1$shared_ext
+             SHAREDLIB=${basename}$shared_ext
+             SHAREDLIBV=${basename}.$VER$shared_ext
+             SHAREDLIBM=${basename}.$VER1$shared_ext
              LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name
$libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version
$VER3"} ;;
   *)             LDSHARED=${LDSHARED-"$cc -shared"} ;;
   esac
@@ -164,21 +167,21 @@
          case `(uname -m || echo unknown) 2>/dev/null` in
          ia64)
              shared_ext='.so'
-             SHAREDLIB='libz.so' ;;
+             SHAREDLIB='${basename}.so' ;;
          *)
              shared_ext='.sl'
-             SHAREDLIB='libz.sl' ;;
+             SHAREDLIB='${basename}.sl' ;;
          esac ;;
   IRIX*)     SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
              CFLAGS=${CFLAGS-"-ansi -O2"}
-             LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
+             LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,${basename}.so.1"} ;;
   OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
              CFLAGS=${CFLAGS-"-O -std1"}
              LDFLAGS="${LDFLAGS} -Wl,-rpath,."
-             LDSHARED=${LDSHARED-"cc -shared  -Wl,-soname,libz.so
-Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;;
+             LDSHARED=${LDSHARED-"cc -shared
-Wl,-soname,${basename}.so -Wl,-msym -Wl,-rpath,$(libdir)
-Wl,-set_version,${VER}:1.0"} ;;
   OSF1*)     SFLAGS=${CFLAGS-"-O -std1"}
              CFLAGS=${CFLAGS-"-O -std1"}
-             LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;;
+             LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,${basename}.so.1"} ;;
   QNX*)      SFLAGS=${CFLAGS-"-4 -O"}
              CFLAGS=${CFLAGS-"-4 -O"}
              LDSHARED=${LDSHARED-"cc"}
@@ -225,9 +228,9 @@
   esac
 fi

-SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
-SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
-SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
+SHAREDLIB=${SHAREDLIB-"${basename}$shared_ext"}
+SHAREDLIBV=${SHAREDLIBV-"${basename}$shared_ext.$VER"}
+SHAREDLIBM=${SHAREDLIBM-"${basename}$shared_ext.$VER1"}

 if test $shared -eq 1; then
   echo Checking for shared library support...
@@ -567,6 +567,7 @@
 /^EXE *=/s#=.*#=$EXE#
 /^prefix *=/s#=.*#=$prefix#
 /^exec_prefix *=/s#=.*#=$exec_prefix#
+/^basename *=/s#=.*#=$basename#
 /^libdir *=/s#=.*#=$libdir#
 /^sharedlibdir *=/s#=.*#=$sharedlibdir#
 /^includedir *=/s#=.*#=$includedir#
--- a/Makefile.in       2011-09-04 01:33:36.983060392 -0500
+++ b/Makefile.in       2011-09-04 01:38:00.201555510 -0500
@@ -24,16 +24,17 @@
 #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
 #           -Wstrict-prototypes -Wmissing-prototypes

+basename=libz
 SFLAGS=-O
 LDFLAGS=
-TEST_LDFLAGS=-L. libz.a
+TEST_LDFLAGS=-L. ${basename}.a
 LDSHARED=$(CC)
 CPP=$(CC) -E

-STATICLIB=libz.a
-SHAREDLIB=libz.so
-SHAREDLIBV=libz.so.1.2.5
-SHAREDLIBM=libz.so.1
+STATICLIB=$(basename).a
+SHAREDLIB=$(basename).so
+SHAREDLIBV=$(basename).so.1.2.5
+SHAREDLIBM=$(basename).so.1
 LIBS=$(STATICLIB) $(SHAREDLIBV)

 AR=ar rc
@@ -107,7 +108,7 @@
        fi
        - at rm -f foo.gz

-libz.a: $(OBJS)
+$(basename).a: $(OBJS)
        $(AR) $@ $(OBJS)
        -@ ($(RANLIB) $@ || true) >/dev/null 2>&1

@@ -170,7 +171,7 @@
        cp $(STATICLIB) $(DESTDIR)$(libdir)
        cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)
        cd $(DESTDIR)$(libdir); chmod u=rw,go=r $(STATICLIB)
-       -@(cd $(DESTDIR)$(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
+       -@(cd $(DESTDIR)$(libdir); $(RANLIB) $(basename).a || true)
>/dev/null 2>&1
        - at cd $(DESTDIR)$(sharedlibdir); if test "$(SHAREDLIBV)" -a -f
$(SHAREDLIBV); then \
          chmod 755 $(SHAREDLIBV); \
          rm -f $(SHAREDLIB) $(SHAREDLIBM); \
@@ -192,7 +193,7 @@

 uninstall:
        cd $(DESTDIR)$(includedir); rm -f zlib.h zconf.h
-       cd $(DESTDIR)$(libdir); rm -f libz.a; \
+       cd $(DESTDIR)$(libdir); rm -f $(basename).a; \
        if test "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \
          rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
        fi
@@ -216,7 +217,7 @@
        rm -f *.o *.lo *~ \
           example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
           example64$(EXE) minigzip64$(EXE) \
-          libz.* foo.gz so_locations \
+          $(basename).* foo.gz so_locations \
           _match.s maketree contrib/infback9/*.o
        rm -rf objs


Norbert


More information about the LibreOffice mailing list