do not (mis-)use the config file generator for non-autobuild stuff
authorKay Sievers <kay.sievers@vrfy.org>
Wed, 21 Dec 2011 13:48:07 +0000 (11:48 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Wed, 21 Dec 2011 13:50:04 +0000 (11:50 -0200)
"Similarly, you should not rely on AC_CONFIG_FILES to replace bindir
and friends in your shell scripts and other files; instead, let make
manage their replacement."

http://www.gnu.org/software/autoconf/manual/autoconf.html#Makefile-Substitutions

Makefile.am
configure.ac

index 1186cff..9d2ac56 100644 (file)
@@ -19,6 +19,19 @@ AM_LDFLAGS = \
        -Wl,--gc-sections \
        -Wl,--as-needed
 
+SED_PROCESS = \
+       $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(SED) \
+       -e 's,@VERSION\@,$(VERSION),g' \
+       -e 's,@prefix\@,$(prefix),g' \
+       -e 's,@exec_prefix\@,$(exec_prefix),g' \
+       -e 's,@libdir\@,$(libdir),g' \
+       -e 's,@includedir\@,$(includedir),g' \
+       -e 's,@required_private_libs\@,$(required_private_libs),g' \
+       < $< > $@ || rm $@
+
+%.pc: %.pc.in Makefile
+       $(SED_PROCESS)
+
 LIBKMOD_CURRENT=2
 LIBKMOD_REVISION=0
 LIBKMOD_AGE=1
@@ -52,6 +65,8 @@ libkmod_libkmod_la_LIBADD = @zlib_libs@
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libkmod/libkmod.pc
+EXTRA_DIST += libkmod/libkmod.pc.in
+CLEANFILES += libkmod/libkmod.pc
 
 if BUILD_TOOLS
 bin_PROGRAMS = tools/kmod-insmod tools/kmod-rmmod tools/kmod-lsmod \
index 6569a6b..9c84a04 100644 (file)
@@ -25,6 +25,9 @@ AM_PROG_CC_C_O
 AC_PROG_GCC_TRADITIONAL
 AC_C_BIGENDIAN
 
+AC_PROG_SED
+AC_PROG_MKDIR_P
+
 required_private_libs=""
 
 AC_ARG_WITH([rootprefix],
@@ -122,7 +125,6 @@ AC_SUBST(required_private_libs)
 AC_CONFIG_HEADERS(config.h)
 AC_CONFIG_FILES([
        Makefile
-       libkmod/libkmod.pc
 ])
 
 AC_OUTPUT