Commit 8aa34abc authored by Maria Matejka's avatar Maria Matejka

Build: Automatic dependency tracking for generated files

parent 875cc073
Pipeline #46542 passed with stages
in 4 minutes and 26 seconds
......@@ -65,7 +65,8 @@ endif
docgoals := docs userdocs progdocs
testgoals := check test tests tests_run
cleangoals := clean distclean testsclean
.PHONY: all daemon cli $(docgoals) $(testgoals) $(cleangoals) tags cscope
.PHONY: all daemon cli $(docgoals) $(testgoals) $(cleangoals) tags cscope geninc
all: daemon cli
daemon: $(daemon)
......@@ -103,35 +104,50 @@ include $(addsuffix /Makefile,$(addprefix $(srcdir)/,$(dirs)))
# Generic rules
# Object file rules
$(objdir)/%.o: $(srcdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
$(objdir)/%.o: $(srcdir)/%.c $(objdir)/.dir-stamp | geninc
$(E)echo CC -o $@ -c $<
$(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $<
$(objdir)/%.o: $(objdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
$(objdir)/%.o: $(objdir)/%.c $(objdir)/.dir-stamp | geninc
$(E)echo CC -o $@ -c $<
$(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $<
# Debug: Preprocessed source rules
$(objdir)/%.E: $(srcdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
$(objdir)/%.E: $(srcdir)/%.c $(objdir)/.dir-stamp | geninc
$(E)echo CC -o $@ -E $<
$(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -E $<
$(objdir)/%.E: $(objdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
$(objdir)/%.E: $(objdir)/%.c $(objdir)/.dir-stamp | geninc
$(E)echo CC -o $@ -E $<
$(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -E $<
# Debug: Assembler object rules
$(objdir)/%.S: $(srcdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
$(objdir)/%.S: $(srcdir)/%.c $(objdir)/.dir-stamp | geninc
$(E)echo CC -o $@ -S $<
$(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -S $<
$(objdir)/%.S: $(objdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h
$(objdir)/%.S: $(objdir)/%.c $(objdir)/.dir-stamp | geninc
$(E)echo CC -o $@ -S $<
$(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -S $<
# Finally include the computed dependencies:
DEPS := $(shell find $(objdir) -name '*.d')
# ## if there is at least one non-clean goal
ifneq ($(filter-out $(cleangoals),$(MAKECMDGOALS)),)
-include $(DEPS)
endif
# ## if the implicit goal is called
ifeq ($(MAKECMDGOALS),)
-include $(DEPS)
endif
# Rule for pre-generating all generated includables
# before compiling any C file
geninc: $(objdir)/sysdep/paths.h
$(objdir)/.dir-stamp:
$(objdir)/.dir-stamp: Makefile
$(E)echo MKDIR -p $(addprefix $(objdir)/,$(dirs) doc)
$(Q)mkdir -p $(addprefix $(objdir)/,$(dirs) doc)
$(Q)touch $@
......@@ -160,21 +176,11 @@ $(tests_targets): LIBS += $(DAEMON_LIBS)
$(tests_targets_ok): %.ok: %
$(Q)$* 2>/dev/null && touch $*.ok
test: testsclean check
test: testsclean all check
check: tests tests_run
tests: $(tests_targets)
tests_run: $(tests_targets_ok)
# Finally include the computed dependencies
ifneq ($(filter-out $(cleangoals),$(MAKECMDGOALS)),)
-include $(shell find $(objdir) -name "*.d")
endif
ifeq ($(MAKECMDGOALS),)
-include $(shell find $(objdir) -name "*.d")
endif
tags:
cd $(srcdir) ; etags -lc `find $(dirs) -name *.[chY]`
......
......@@ -3,8 +3,6 @@ obj := $(src-o-files)
$(all-client)
$(o)commands.o: $(objdir)/conf/commands.h
$(exedir)/birdc: $(o)birdc.o
$(exedir)/birdc: LIBS += $(CLIENT_LIBS)
......
......@@ -25,9 +25,10 @@ $(o)cf-parse.tab.c: $(o)cf-parse.y
$(o)cf-lex.c: $(s)cf-lex.l
$(FLEX) $(FLEX_DEBUG) -f -s -B -8 -Pcf_ -o$@ $<
$(o)cf-lex.o: $(o)cf-parse.tab.h $(o)keywords.h
$(o)cf-lex.o: CFLAGS+=-Wno-sign-compare -Wno-unused-function
geninc: $(o)keywords.h $(o)commands.h $(o)cf-parse.tab.c
$(addprefix $(o), cf-parse.y keywords.h commands.h cf-parse.tab.h cf-parse.tab.c cf-lex.c): $(objdir)/.dir-stamp
$(call clean,cf-parse.tab.h cf-parse.tab.c cf-parse.y keywords.h commands.h cf-lex.c cf-parse.output)
......@@ -7,7 +7,7 @@
*/
#include "nest/bird.h"
#include "bitops.h"
#include "lib/bitops.h"
/**
* u32_mkmask - create a bit mask
......
......@@ -13,7 +13,7 @@
#include <stdarg.h>
#include "nest/bird.h"
#include "checksum.h"
#include "lib/checksum.h"
static inline u32
add32(u32 sum, u32 x)
......
......@@ -8,7 +8,7 @@
*/
#include "nest/bird.h"
#include "string.h"
#include "lib/string.h"
#include <errno.h>
......
......@@ -3,4 +3,4 @@ obj := $(src-o-files)
$(all-daemon)
$(cf-local)
tests_objs := $(tests_objs) $(src-o-files)
\ No newline at end of file
tests_objs := $(tests_objs) $(src-o-files)
......@@ -36,7 +36,7 @@
*/
#include <stdlib.h>
#include "babel.h"
#include "proto/babel/babel.h"
/*
......
......@@ -10,7 +10,7 @@
* This file contains the packet and TLV handling code for the protocol.
*/
#include "babel.h"
#include "proto/babel/babel.h"
struct babel_pkt_header {
......
......@@ -3,4 +3,4 @@ obj := $(src-o-files)
$(all-daemon)
$(cf-local)
tests_objs := $(tests_objs) $(src-o-files)
\ No newline at end of file
tests_objs := $(tests_objs) $(src-o-files)
......@@ -100,7 +100,7 @@
* - RFC 5883 - BFD for multihop paths
*/
#include "bfd.h"
#include "proto/bfd/bfd.h"
#define HASH_ID_KEY(n) n->loc_id
......
......@@ -22,7 +22,7 @@
#include "lib/string.h"
#include "nest/bfd.h"
#include "io.h"
#include "proto/bfd/io.h"
#define BFD_CONTROL_PORT 3784
......
......@@ -4,7 +4,7 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include "bfd.h"
#include "proto/bfd/bfd.h"
#include "lib/mac.h"
......
......@@ -3,4 +3,4 @@ obj := $(src-o-files)
$(all-daemon)
$(cf-local)
tests_objs := $(tests_objs) $(src-o-files)
\ No newline at end of file
tests_objs := $(tests_objs) $(src-o-files)
......@@ -22,7 +22,7 @@
#include "lib/string.h"
#include "lib/unaligned.h"
#include "bgp.h"
#include "proto/bgp/bgp.h"
/*
* UPDATE message error handling
......
......@@ -119,7 +119,7 @@
#include "lib/resource.h"
#include "lib/string.h"
#include "bgp.h"
#include "proto/bgp/bgp.h"
struct linpool *bgp_linpool; /* Global temporary pool */
......
......@@ -25,7 +25,7 @@
#include "nest/cli.h"
#include "bgp.h"
#include "proto/bgp/bgp.h"
#define BGP_RR_REQUEST 0
......
......@@ -3,4 +3,4 @@ obj := $(src-o-files)
$(all-daemon)
$(cf-local)
tests_objs := $(tests_objs) $(src-o-files)
\ No newline at end of file
tests_objs := $(tests_objs) $(src-o-files)
......@@ -43,7 +43,7 @@
#include <limits.h>
#include <errno.h>
#include "mrt.h"
#include "proto/mrt/mrt.h"
#include "nest/cli.h"
#include "filter/filter.h"
......
......@@ -3,4 +3,4 @@ obj := $(src-o-files)
$(all-daemon)
$(cf-local)
tests_objs := $(tests_objs) $(src-o-files)
\ No newline at end of file
tests_objs := $(tests_objs) $(src-o-files)
......@@ -8,7 +8,7 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include "ospf.h"
#include "proto/ospf/ospf.h"
struct ospf_dbdes2_packet
......
......@@ -8,7 +8,7 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include "ospf.h"
#include "proto/ospf/ospf.h"
struct ospf_hello2_packet
......
......@@ -8,7 +8,7 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include "ospf.h"
#include "proto/ospf/ospf.h"
#include "nest/password.h"
......
......@@ -8,7 +8,7 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include "ospf.h"
#include "proto/ospf/ospf.h"
/*
......
......@@ -8,7 +8,7 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include "ospf.h"
#include "proto/ospf/ospf.h"
#include "lib/fletcher16.h"
......
......@@ -8,7 +8,7 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include "ospf.h"
#include "proto/ospf/ospf.h"
/*
......
......@@ -8,7 +8,7 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include "ospf.h"
#include "proto/ospf/ospf.h"
/*
......
......@@ -8,7 +8,7 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include "ospf.h"
#include "proto/ospf/ospf.h"
const char *ospf_ns_names[] = {
......
......@@ -103,7 +103,7 @@
*/
#include <stdlib.h>
#include "ospf.h"
#include "proto/ospf/ospf.h"
static int ospf_preexport(struct proto *P, rte **new, struct linpool *pool);
static void ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool);
......
......@@ -8,7 +8,7 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include "ospf.h"
#include "proto/ospf/ospf.h"
#include "nest/password.h"
#include "lib/md5.h"
#include "lib/mac.h"
......
......@@ -8,7 +8,7 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include "ospf.h"
#include "proto/ospf/ospf.h"
static void add_cand(struct ospf_area *oa, struct top_hash_entry *en, struct top_hash_entry *par, u32 dist, int i, uint lif, uint nif);
static void rt_sync(struct ospf_proto *p);
......
......@@ -12,7 +12,7 @@
#include "nest/bird.h"
#include "lib/string.h"
#include "ospf.h"
#include "proto/ospf/ospf.h"
#define HASH_DEF_ORDER 6
......
......@@ -24,7 +24,7 @@
#include "filter/filter.h"
#include "lib/string.h"
#include "perf.h"
#include "proto/perf/perf.h"
#include <stdlib.h>
#include <time.h>
......
......@@ -3,4 +3,4 @@ obj := $(src-o-files)
$(all-daemon)
$(cf-local)
tests_objs := $(tests_objs) $(src-o-files)
\ No newline at end of file
tests_objs := $(tests_objs) $(src-o-files)
......@@ -41,7 +41,7 @@
#include "filter/filter.h"
#include "lib/string.h"
#include "pipe.h"
#include "proto/pipe/pipe.h"
static void
pipe_rt_notify(struct proto *P, struct channel *src_ch, net *n, rte *new, rte *old)
......
......@@ -3,4 +3,4 @@ obj := $(src-o-files)
$(all-daemon)
$(cf-local)
tests_objs := $(tests_objs) $(src-o-files)
\ No newline at end of file
tests_objs := $(tests_objs) $(src-o-files)
......@@ -7,7 +7,7 @@
#include <stdlib.h>
#include "radv.h"
#include "proto/radv/radv.h"
struct radv_ra_packet
{
......
......@@ -7,7 +7,7 @@
#include <stdlib.h>
#include "radv.h"
#include "proto/radv/radv.h"
/**
* DOC: Router Advertisements
......
......@@ -3,4 +3,4 @@ obj := $(src-o-files)
$(all-daemon)
$(cf-local)
tests_objs := $(tests_objs) $(src-o-files)
\ No newline at end of file
tests_objs := $(tests_objs) $(src-o-files)
......@@ -11,7 +11,7 @@
#undef LOCAL_DEBUG
#include "rip.h"
#include "proto/rip/rip.h"
#include "lib/mac.h"
......
......@@ -76,7 +76,7 @@
*/
#include <stdlib.h>
#include "rip.h"
#include "proto/rip/rip.h"
static inline void rip_lock_neighbor(struct rip_neighbor *n);
......
......@@ -3,4 +3,4 @@ obj := $(src-o-files)
$(all-daemon)
$(cf-local)
tests_objs := $(tests_objs) $(src-o-files)
\ No newline at end of file
tests_objs := $(tests_objs) $(src-o-files)
......@@ -15,9 +15,9 @@
#undef LOCAL_DEBUG
#include "rpki.h"
#include "transport.h"
#include "packets.h"
#include "proto/rpki/rpki.h"
#include "proto/rpki/transport.h"
#include "proto/rpki/packets.h"
#define RPKI_ADD_FLAG 0b00000001
......
......@@ -93,7 +93,7 @@
#undef LOCAL_DEBUG
#include "rpki.h"
#include "proto/rpki/rpki.h"
#include "lib/string.h"
#include "nest/cli.h"
......
......@@ -18,8 +18,8 @@
#include "lib/socket.h"
#include "lib/ip.h"
#include "transport.h"
#include "packets.h"
#include "proto/rpki/transport.h"
#include "proto/rpki/packets.h"
#define RPKI_TCP_PORT 323
#define RPKI_SSH_PORT 22
......
......@@ -15,7 +15,7 @@
#include <string.h>
#include <sys/time.h>
#include "rpki.h"
#include "proto/rpki/rpki.h"
static int
rpki_tr_ssh_open(struct rpki_tr_sock *tr)
......
......@@ -18,7 +18,7 @@
#include <sys/types.h>
#include <unistd.h>
#include "rpki.h"
#include "proto/rpki/rpki.h"
#include "sysdep/unix/unix.h"
static int
......
......@@ -12,8 +12,8 @@
#include <sys/socket.h>
#include <netdb.h>
#include "rpki.h"
#include "transport.h"
#include "proto/rpki/rpki.h"
#include "proto/rpki/transport.h"
#include "sysdep/unix/unix.h"
/**
......
......@@ -3,4 +3,4 @@ obj := $(src-o-files)
$(all-daemon)
$(cf-local)
tests_objs := $(tests_objs) $(src-o-files)
\ No newline at end of file
tests_objs := $(tests_objs) $(src-o-files)
......@@ -45,7 +45,7 @@
#include "lib/string.h"
#include "lib/alloca.h"
#include "static.h"
#include "proto/static/static.h"
static linpool *static_lp;
......
......@@ -60,8 +60,8 @@
#include "lib/string.h"
#include "lib/timer.h"
#include "unix.h"
#include "krt.h"
#include "sysdep/unix/unix.h"
#include "sysdep/unix/krt.h"
/*
* Global resources
......
......@@ -37,8 +37,8 @@
#include "conf/conf.h"
#include "filter/filter.h"
#include "unix.h"
#include "krt.h"
#include "sysdep/unix/unix.h"
#include "sysdep/unix/krt.h"
/*
* Debugging
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment