]> git.proxmox.com Git - mirror_frr.git/commitdiff
build: pre-generate built headers in configure
authorDavid Lamparter <equinox@opensourcerouting.org>
Fri, 4 Aug 2017 07:59:00 +0000 (09:59 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Fri, 4 Aug 2017 09:09:50 +0000 (11:09 +0200)
zebra.h includes route_types.h, which means almost all of our Makefile
targets have a dependency on route_types.h.  While BUILT_SOURCES ensures
that this dependency is fulfilled on a "make all", this doesn't work
when building specific targets (e.g. "make lib/libfrr.la").

There seems to be no good way to add a dependency on everything, so the
best fix for this is to just generate the file during ./configure.

(The Makefile rule is still there, so if route_types.txt is changed,
route_types.h will be rebuilt.)

This only affects "initial" builds from a clean directory and/or builds
with --disable-dependency-tracking;  other than that gcc will output
Makefile dependencies during compilation so that route_types.h will
become a dependency for all output files.

gitversion.h has the same problem on a smaller scope.

command_lex.h & command_parse.h *don't* have the problem because they're
only used in specific files, and these files have the dependency
explicitly listed in the Makefile.  Hence, they can also be removed from
BUILT_SOURCES.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
configure.ac

index 81ab9dc6822d41d001a159f693b434c5a552bb82..5bc075ccc15570537c0ecd8c664f39f7f5e3ea1a 100755 (executable)
@@ -1840,6 +1840,34 @@ AC_CONFIG_FILES([solaris/Makefile])
 
 AC_CONFIG_FILES([vtysh/extract.pl],[chmod +x vtysh/extract.pl])
 
+AC_CONFIG_COMMANDS([lib/route_types.h], [
+       dst="${ac_abs_top_builddir}/lib/route_types.h"
+       ${PERL} "${ac_abs_top_srcdir}/lib/route_types.pl" \
+               < "${ac_abs_top_srcdir}/lib/route_types.txt" \
+               > "${dst}.tmp"
+       test -f "${dst}" \
+               && diff "${dst}.tmp" "${dst}" >/dev/null 2>/dev/null \
+               && rm "${dst}.tmp" \
+               || mv "${dst}.tmp" "${dst}"
+], [
+       PERL="$PERL"
+])
+
+AS_IF([test "x$with_pkg_git_version" = "xyes"], [
+    AC_CONFIG_COMMANDS([lib/gitversion.h], [
+       dst="${ac_abs_top_builddir}/lib/gitversion.h"
+       ${PERL} "${ac_abs_top_srcdir}/lib/gitversion.pl" \
+               "${ac_abs_top_srcdir}" \
+               > "${dst}.tmp"
+       test -f "${dst}" \
+               && diff "${dst}.tmp" "${dst}" >/dev/null 2>/dev/null \
+               && rm "${dst}.tmp" \
+               || mv "${dst}.tmp" "${dst}"
+    ], [
+       PERL="$PERL"
+    ])
+])
+
 ## Hack, but working solution to avoid rebuilding of frr.info.
 ## It's already in CVS until texinfo 4.7 is more common.
 AC_OUTPUT