0
votes

I'm trying to define an Automake rule that will generate a text file containing the full path to a libtool library that will be built and installed by the same Makefile. Is there a straightforward way of retrieving the output filename for a libtool library (with the correct extension for the platform the program is being built on)?

For example, I am trying to write something like this:

lib_LTLIBRARIES = libfoo.la

bar.txt:
  echo $(prefix)/lib/$(libfoo_la) >$@ 

Where $(libfoo_la) would expand to libfoo.so, libfoo.dylib or libfoo.dll (or whatever else), depending on the platform. This is essentially the value of the dlname parameter in the resulting libtool library file. I could potentially extract the filename directly from that, but I was hoping there was a simpler way of achieving this.

1

1 Answers

2
votes

Unfortunately, there's not a way I've found of doing this. Fortunately, for you, I did have a little sed script hacked together that did kind of what you want, and hacked it so it does do what you want.

foo.sed

# kill non-dlname lines
/^\(dlname\|libdir\)=/! { d }

/^dlname=/ {

# kill leading/trailing junk
s/^dlname='//

# kill from the last quote to the end
s/'.*$//

# kill blank lines
/./!d

# write out the lib on its own line
s/.*/\/&\n/g

# kill the EOL
s/\n$//

# hold it
h
}

/^libdir=/ {

# kill leading/trailing junk
s/^libdir='//

# kill from the last quote to the end
s/'.*$//

# paste
G

# kill the EOL
s/\n//
p
}

Makefile.am

lib_LTLIBRARIES = libfoo.la

bar.txt: libfoo.la foo.sed
        sed -n -f foo.sed $< > $@