Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple libtool alternative?

Being perfectly satisfied with old-style Makefiles, I am looking for a simple alternative to libtool. I do not want to switch to automake, and I keep running into problems with libtool when I try to use it directly. The latest one is 'unsupported hardcode properties', and I am getting fed up with the lack of complete documentation that just tells me what is wrong this time...

I only want to compile a bunch of .o files with the right flags and then link them into a shared library, such that it works on as many platforms as possible. Is there anything out there that does just that and not force me to switch all of my other tools at the same time?

like image 846
Kasper Peeters Avatar asked Mar 04 '10 13:03

Kasper Peeters


4 Answers

slibtool (dl.midipix.org/slibtool, git://midipix.org/slibtool) is a libtool drop-in replacement, written in C. A single slibtool binary aims to seamlessly support both native and cross-builds, and the utility also provides some additional features (installation of .la files is optional, optional color-coded annotation, etc). The following minimal plain makefile demonstrates how to (cross-) build a library using slibtool.

CC      = cc
LIBTOOL = slibtool
DESTDIR = destdir

all:    libfoo.la

a.lo:
    $(LIBTOOL) --mode=compile --tag=CC $(CC) -c a.c

libfoo.la: a.lo
    $(LIBTOOL) --mode=link --tag=CC $(CC) -o libfoo.la -rpath /lib

install: all
    mkdir -p destdir
    $(LIBTOOL) --mode=install cp libfoo.la $(DESTDIR)

# the -rpath argument is required for semantic compatibility with libtool.

native build, default (both shared library and static library)

$ make
$ make install

native build, shared library only

$ make LIBTOOL=slibtool-shared
$ make install

native build, static library only

$ make LIBTOOL=slibtool-static
$ make install

cross-build, default

$ make CC=some-target-tuple-gcc
$ make install

cross-build, default, with lots of colors

$ make LIBTOOL=dlibtool CC=some-target-tuple-gcc
$ make install
like image 87
Nikodem Zawadzki Avatar answered Nov 13 '22 02:11

Nikodem Zawadzki


There's jlibtool (which has nothing to do with java).

It's written in C, and can just be bundled with your source.

It was originally an apache project, but whoever was working it there seems to of abandoned it around 2004.

It was taken over by FreeRADIUS project maintainer Alan Dekok, who modernised the code and fixed a few niggling issues. We use it for the FreeRADIUS project (>= 3.0.0) to do all the build time linking.

like image 43
Arran Cudbard-Bell Avatar answered Nov 13 '22 04:11

Arran Cudbard-Bell


I not sure if it would fit info your workflow but I'd recommend looking at CMake. It works on Windows, Linux and Mac and should not force you to change any of your other tools. You'll have to judge its suitability yourself though.

like image 6
Milliams Avatar answered Nov 13 '22 04:11

Milliams


Given your description in the comment to Milliams' answer,

I just want one tool that I tell: "give me the compiler flags so that I can compile these n files for use in a shared library, and then give me the commands to link them together",

then libtool may well be the simplest tool for the job. I know of no other alternative.

You are right that the documentation for using libtool with plain makefiles is practically nonexistent, but libtool certainly does not require you to switch to automake. Cross-platform libraries are difficult, and the price you have to pay for them is libtool. (Or maybe the discount price is libtool+automake+autoconf or CMake or Jam.)

like image 3
ptomato Avatar answered Nov 13 '22 02:11

ptomato