I have the following regular (hand-written) makefile:
all: $(patsubst %.c,%.so,$(wildcard *.c))
%.so: %.c
$(CC) $(CFLAGS) $(LDFLAGS) -rdynamic -o $@ $^
I need to convert this makefile to autotools (primary for populating CFLAGS and LDFLAGS with good stuff) My first reading of autotools documentation made me thought that this is impossible since autotools need to know all its targets in advance... but i may be wrong.
Any idea ?
Automake certainly wants to know all of the filenames, but it is quite common to have a bootstrap script that creates Makefile.am prior to running automake. Here's a fairly naive example:
#!/bin/sh
cat Makefile.am.head > Makefile.am
ls *.c | sed 's/$/ \\/' >> Makefile.am
cat Makefile.am.tail >> Makefile.am
autoreconf -ivf
Note that if you are going to use the autotools, you probably do not want to write rules to generate a *.so anyway, but should use libtool and the LTLIBRARIES primary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With