Simple libtool alternative?
Asked Answered
E

4

14

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?

Expectorate answered 4/3, 2010 at 13:34 Comment(1)
How does using automake imply that you must switch all of your tools? Writing your own makefiles means you have to manually include support for a lot of stuff that automake does for you automatically. When I switched to using automake, only one thing changed: my 150 line Makefiles became far more featureful 10 line Makefile.ams. All other tools stayed the same.Clean
F
6

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.

Footstone answered 8/1, 2014 at 20:45 Comment(0)
E
6

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.

Elamitic answered 4/3, 2010 at 14:9 Comment(1)
I am aware of CMake, but that is a bit more than what I was looking for. I do not want to switch my Makefile system to something else, 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".Expectorate
F
6

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.

Footstone answered 8/1, 2014 at 20:45 Comment(0)
L
4

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
Lentic answered 24/6, 2018 at 10:52 Comment(0)
D
3

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.)

Disentangle answered 5/3, 2010 at 0:4 Comment(1)
I was afraid of that answer... Is there perhaps anyone who knows what is the recommended way to setup libtool in configure.in, without doing that through automake? (i.e. using just autoconf, not automake).Expectorate

© 2022 - 2024 — McMap. All rights reserved.