diff options
author | hubertf <hubertf@pkgsrc.org> | 1998-07-16 06:50:46 +0000 |
---|---|---|
committer | hubertf <hubertf@pkgsrc.org> | 1998-07-16 06:50:46 +0000 |
commit | 1c28c5e464218a254a39dac06ae11d9f0d99cab5 (patch) | |
tree | 2d50bcad89ab25eb6181550b3e7b20428d26a313 | |
parent | d141ff7a829210231b2ffb5b6a3dcadf5892eb6d (diff) | |
download | pkgsrc-1c28c5e464218a254a39dac06ae11d9f0d99cab5.tar.gz |
Add notes on libtool, by Todd Vierling <tv@netbsd.org>
-rw-r--r-- | Packages.txt | 86 |
1 files changed, 82 insertions, 4 deletions
diff --git a/Packages.txt b/Packages.txt index 842f8d66ea0..fe16a507fd6 100644 --- a/Packages.txt +++ b/Packages.txt @@ -1,4 +1,4 @@ -# $NetBSD: Packages.txt,v 1.38 1998/07/13 15:37:12 hubertf Exp $ +# $NetBSD: Packages.txt,v 1.39 1998/07/16 06:50:46 hubertf Exp $ ########################################################################### ========================== @@ -644,7 +644,84 @@ You should also avoid defining __FreeBSD__=1 and then simply using the FreeBSD port, if only from an aesthetic viewpoint. - 6.2 Gotchas of FreeBSD ports + 6.2 Shared libraries - libtool + ============================== + +NetBSD supports many different machines, with different object formats +like a.out and ELF, and varying abilities to do shared library and +dynamic loading at all. To accompany this, verying commands and options +have to be passed to the compiler, linker etc. to get the Right Thing, +which can be pretty annoying esp. if you don't have all the machines at +your hand to test things. The "libtool" pkg can help here, as it just +"knows" how to build both static and dynamic libraries from a set our +source files, thus being platform independent. + +To use "libtool", add a build-dependency on the libtool-pkg, then modify +the pkg's sources to use libtool for building it's libraries and add the +resulting patches to your pkg's patches-directory. + +Here's how to use libtool in a pkg in seven simple steps: + +1. Define LIBTOOL=${PREFIX}/bin/libtool in MAKE_ENV, or define it in a + patch to the native Makefile. Make the pkg depend on libtool with: + + BUILD_DEPENDS= ${PREFIX}/bin/libtool:../../devel/libtool + +2. For library objects, use "${LIBTOOL} --mode=compile ${CC}" in place of + ${CC}. You could even add it to the definition of CC, if only + libraries are being built in a given Makefile. This one command will + build both PIC and non-PIC library objects, so you need not have + separate shared and non-shared library rules. + +3. For the linking of the library, remove any "ar", "ranlib", and "ld + -Bshareable" commands, and use instead: + + ${LIBTOOL} --mode=link cc -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} -rpath ${PREFIX}/lib -version-info major:minor + + Note that the library is changed to have a .la extension, and the + objects are changed to have a .lo extension. Change OBJS as necessary. + This automatically creates all of the .a, .so.major.minor, and ELF + symlinks (if necessary) in the build directory. + +4. When linking programs that depend on these libraries _before_ they are + installed, preface the cc or ld line with "${LIBTOOL} --mode=link", and + it will find the correct libraries (static or shared), but please be + aware that libtool will not allow you to specify a relative path in -L + (such as -L../somelib), because it is trying to force you to change + that argument to be the .la file. For example: + + ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib + + won't work; it needs to be changed to: + + ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la + + and it will DTRT with the libraries. If you *must* use a relative path + with -L, and you are not going to run this program before installing + it, you can omit the use of libtool during link and install of this + program if you add the subdirectory ".libs" in your -L command: + + ${CC} -o someprog -L../somelib/.libs -lsomelib + +5. When installing libraries, preface the install or cp command with + "${LIBTOOL} --mode=install", and change the library name to .la. For + example: + + ${LIBTOOL} --mode=install ${BSD_INSTALL_DATA} ${SOMELIB:.a=.la} ${PREFIX}/lib + + This will install the static .a, shared library, any needed symlinks, + and run "ldconfig." + +6. In your PLIST, include the .a, .la, and .so.major.minor files. Don't + include the ELF symlink files; those are automatic. + +FOR GNU PKGS THAT ALREADY SUPPORT LIBTOOL: +Put LIBTOOL=${PREFIX}/bin/libtool in CONFIGURE_ENV, and possibly modify the +"configure" script not to check for or configure its own libtool. See the +libwww pkg, patch-ab, for the quick way to bypass the pkg's own libtool. + + + 6.3 Gotchas of FreeBSD ports ============================ See section 4.1 for Makefile issues (MANx, CATx, MANCOMPRESSED, ldconfig, @@ -672,7 +749,7 @@ manpages without compressing them; rather, we add our own .gz suffix there according to MANZ. - 6.3 Feedback to the author + 6.4 Feedback to the author ========================== If you have found any bugs in the package you make available, if you had to @@ -1266,7 +1343,8 @@ Now compile: > cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g version.c > cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g getopt.c > cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g getopt1.c -> cc -g -o bison LR0.o allocate.o closure.o conflicts.o derives.o files.o getargs.o gram.o lalr.o lex.o main.o nullable.o output.o print.o reader.o reduce.o symtab.o warshall.o version.o getopt.o getopt1.o +> cc -g -o bison LR0.o allocate.o closure.o conflicts.o derives.o files.o getargs.o gram.o lalr.o lex.o main.o nullable.o output.o print.o reader.o reduce.o symtab.o warshall.o version.o + getopt.o getopt1.o > ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp() > rm -f bison.s1 > sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1 |