From 2003a1840731bd57365876e48c96c5a1ea0348cb Mon Sep 17 00:00:00 2001 From: Jan Moskyto Matejka Date: Fri, 8 Apr 2016 13:08:03 +0200 Subject: [PATCH 1/3] Route update: move table lookup from protocols into rte_update2(). Many protocols do almost the same when creating a rte_update request before calling rte_update2(). This commit should simplify the protocol side of the route-creation routine. --- nest/protocol.h | 2 +- nest/route.h | 2 +- nest/rt-dev.c | 15 ++------------- nest/rt-table.c | 14 +++++++++----- proto/ospf/rt.c | 7 ++----- proto/pipe/pipe.c | 5 +---- proto/rip/rip.c | 8 ++------ proto/static/static.c | 10 ++-------- sysdep/unix/krt.c | 7 ++----- 9 files changed, 22 insertions(+), 48 deletions(-) diff --git a/nest/protocol.h b/nest/protocol.h index 19f5d070..68f0d5c5 100644 --- a/nest/protocol.h +++ b/nest/protocol.h @@ -271,7 +271,7 @@ proto_get_router_id(struct proto_config *pc) } /* Moved from route.h to avoid dependency conflicts */ -static inline void rte_update(struct proto *p, net *net, rte *new) { rte_update2(p->main_channel, net, new, p->main_source); } +static inline void rte_update(struct proto *p, net_addr *n, rte *new) { rte_update2(p->main_channel, n, new, p->main_source); } extern list proto_list; diff --git a/nest/route.h b/nest/route.h index 22fca331..5f34d47a 100644 --- a/nest/route.h +++ b/nest/route.h @@ -276,7 +276,7 @@ static inline net *net_get(rtable *tab, const net_addr *addr) { return (net *) f rte *rte_find(net *net, struct rte_src *src); rte *rte_get_temp(struct rta *); -void rte_update2(struct channel *c, net *net, rte *new, struct rte_src *src); +void rte_update2(struct channel *c, net_addr *n, rte *new, struct rte_src *src); /* rte_update() moved to protocol.h to avoid dependency conflicts */ void rte_discard(rtable *tab, rte *old); int rt_examine(rtable *t, net_addr *a, struct proto *p, struct filter *filter); diff --git a/nest/rt-dev.c b/nest/rt-dev.c index a996f4fc..098885b9 100644 --- a/nest/rt-dev.c +++ b/nest/rt-dev.c @@ -55,24 +55,15 @@ dev_ifa_notify(struct proto *P, uint flags, struct ifa *ad) if (flags & IF_CHANGE_DOWN) { - net *n; - DBG("dev_if_notify: %s:%I going down\n", ad->iface->name, ad->ip); - n = net_find(c->table, &ad->prefix); - if (!n) - { - DBG("dev_if_notify: device shutdown: prefix not found\n"); - return; - } /* Use iface ID as local source ID */ struct rte_src *src = rt_get_source(P, ad->iface->index); - rte_update2(c, n, NULL, src); + rte_update2(c, &ad->prefix, NULL, src); } else if (flags & IF_CHANGE_UP) { rta *a; - net *n; rte *e; DBG("dev_if_notify: %s:%I going up\n", ad->iface->name, ad->ip); @@ -90,11 +81,9 @@ dev_ifa_notify(struct proto *P, uint flags, struct ifa *ad) }; a = rta_lookup(&a0); - n = net_get(c->table, &ad->prefix); e = rte_get_temp(a); - e->net = n; e->pflags = 0; - rte_update2(c, n, e, src); + rte_update2(c, &ad->prefix, e, src); } } diff --git a/nest/rt-table.c b/nest/rt-table.c index 03ab3b92..9614d9ef 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -1267,19 +1267,23 @@ rte_unhide_dummy_routes(net *net, rte **dummy) */ void -rte_update2(struct channel *c, net *net, rte *new, struct rte_src *src) +rte_update2(struct channel *c, net_addr *n, rte *new, struct rte_src *src) { struct proto *p = c->proto; struct proto_stats *stats = &c->stats; struct filter *filter = c->in_filter; ea_list *tmpa = NULL; rte *dummy = NULL; + net *nn; ASSERT(c->channel_state == CS_UP); rte_update_lock(); if (new) { + nn = net_get(c->table, n); + + new->net = nn; new->sender = c; if (!new->pref) @@ -1333,7 +1337,7 @@ rte_update2(struct channel *c, net *net, rte *new, struct rte_src *src) { stats->imp_withdraws_received++; - if (!net || !src) + if (!(nn = net_find(c->table, n)) || !src) { stats->imp_withdraws_ignored++; rte_update_unlock(); @@ -1342,9 +1346,9 @@ rte_update2(struct channel *c, net *net, rte *new, struct rte_src *src) } recalc: - rte_hide_dummy_routes(net, &dummy); - rte_recalculate(c, net, new, src); - rte_unhide_dummy_routes(net, &dummy); + rte_hide_dummy_routes(nn, &dummy); + rte_recalculate(c, nn, new, src); + rte_unhide_dummy_routes(nn, &dummy); rte_update_unlock(); return; diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c index 0855f21f..5538f4c8 100644 --- a/proto/ospf/rt.c +++ b/proto/ospf/rt.c @@ -1973,7 +1973,6 @@ again1: if (reload || ort_changed(nf, &a0)) { - net *ne = net_get(p->p.main_channel->table, nf->fn.addr); rta *a = rta_lookup(&a0); rte *e = rte_get_temp(a); @@ -1984,11 +1983,10 @@ again1: e->u.ospf.tag = nf->old_tag = nf->n.tag; e->u.ospf.router_id = nf->old_rid = nf->n.rid; e->pflags = 0; - e->net = ne; DBG("Mod rte type %d - %N via %I on iface %s, met %d\n", a0.source, nf->fn.addr, a0.gw, a0.iface ? a0.iface->name : "(none)", nf->n.metric1); - rte_update(&p->p, ne, e); + rte_update(&p->p, nf->fn.addr, e); } } else if (nf->old_rta) @@ -1997,8 +1995,7 @@ again1: rta_free(nf->old_rta); nf->old_rta = NULL; - net *ne = net_get(p->p.main_channel->table, nf->fn.addr); - rte_update(&p->p, ne, NULL); + rte_update(&p->p, nf->fn.addr, NULL); } /* Remove unused rt entry, some special entries are persistent */ diff --git a/proto/pipe/pipe.c b/proto/pipe/pipe.c index f3df3e71..d40b3f91 100644 --- a/proto/pipe/pipe.c +++ b/proto/pipe/pipe.c @@ -50,7 +50,6 @@ pipe_rt_notify(struct proto *P, struct channel *src_ch, net *n, rte *new, rte *o struct channel *dst = (src_ch == p->pri) ? p->sec : p->pri; struct rte_src *src; - net *nn; rte *e; rta a; @@ -64,7 +63,6 @@ pipe_rt_notify(struct proto *P, struct channel *src_ch, net *n, rte *new, rte *o return; } - nn = net_get(dst->table, n->n.addr); if (new) { memcpy(&a, new->attrs, sizeof(rta)); @@ -73,7 +71,6 @@ pipe_rt_notify(struct proto *P, struct channel *src_ch, net *n, rte *new, rte *o a.eattrs = attrs; a.hostentry = NULL; e = rte_get_temp(&a); - e->net = nn; e->pflags = 0; /* Copy protocol specific embedded attributes. */ @@ -90,7 +87,7 @@ pipe_rt_notify(struct proto *P, struct channel *src_ch, net *n, rte *new, rte *o } src_ch->table->pipe_busy = 1; - rte_update2(dst, nn, e, src); + rte_update2(dst, n->n.addr, e, src); src_ch->table->pipe_busy = 0; } diff --git a/proto/rip/rip.c b/proto/rip/rip.c index 22023279..131c09ce 100644 --- a/proto/rip/rip.c +++ b/proto/rip/rip.c @@ -143,8 +143,6 @@ rip_announce_rte(struct rip_proto *p, struct rip_entry *en) if (rt) { /* Update */ - net *n = net_get(p->p.main_channel->table, en->n.addr); - rta a0 = { .src = p->p.main_source, .source = RTS_RIP, @@ -204,16 +202,14 @@ rip_announce_rte(struct rip_proto *p, struct rip_entry *en) e->u.rip.metric = rt_metric; e->u.rip.tag = rt_tag; - e->net = n; e->pflags = 0; - rte_update(&p->p, n, e); + rte_update(&p->p, en->n.addr, e); } else { /* Withdraw */ - net *n = net_find(p->p.main_channel->table, en->n.addr); - rte_update(&p->p, n, NULL); + rte_update(&p->p, en->n.addr, NULL); } } diff --git a/proto/static/static.c b/proto/static/static.c index 6239fccb..28cb1e77 100644 --- a/proto/static/static.c +++ b/proto/static/static.c @@ -60,7 +60,6 @@ p_igp_table(struct proto *p) static void static_install(struct proto *p, struct static_route *r, struct iface *ifa) { - net *n; rta a; rte *e; @@ -112,15 +111,13 @@ static_install(struct proto *p, struct static_route *r, struct iface *ifa) /* We skip rta_lookup() here */ - n = net_get(p->main_channel->table, r->net); e = rte_get_temp(&a); - e->net = n; e->pflags = 0; if (r->cmds) f_eval_rte(r->cmds, &e, static_lp); - rte_update(p, n, e); + rte_update(p, r->net, e); r->installed = 1; if (r->cmds) @@ -130,14 +127,11 @@ static_install(struct proto *p, struct static_route *r, struct iface *ifa) static void static_remove(struct proto *p, struct static_route *r) { - net *n; - if (!r->installed) return; DBG("Removing static route %N via %I\n", r->net, r->via); - n = net_find(p->main_channel->table, r->net); - rte_update(p, n, NULL); + rte_update(p, r->net, NULL); r->installed = 0; } diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c index 6b3b4eee..fe8af1c0 100644 --- a/sysdep/unix/krt.c +++ b/sysdep/unix/krt.c @@ -345,18 +345,15 @@ krt_learn_announce_update(struct krt_proto *p, rte *e) net *n = e->net; rta *aa = rta_clone(e->attrs); rte *ee = rte_get_temp(aa); - net *nn = net_get(p->p.main_channel->table, n->n.addr); - ee->net = nn; ee->pflags = 0; ee->u.krt = e->u.krt; - rte_update(&p->p, nn, ee); + rte_update(&p->p, n->n.addr, ee); } static void krt_learn_announce_delete(struct krt_proto *p, net *n) { - n = net_find(p->p.main_channel->table, n->n.addr); - rte_update(&p->p, n, NULL); + rte_update(&p->p, n->n.addr, NULL); } /* Called when alien route is discovered during scan */ From 7152e5efbb0fade868d5f2d2c7bc10ed52b3d19d Mon Sep 17 00:00:00 2001 From: Jan Moskyto Matejka Date: Tue, 12 Apr 2016 11:14:54 +0200 Subject: [PATCH 2/3] Build system reworked to one global Makefile with includes and no nesting Also removed the lib-dir merging with sysdep. Updated #include's accordingly. Fixed make doc on recent Debian together with moving generated doc into objdir. Moved Makefile.in into root dir Retired all.o and birdlib.a Linking the final binaries directly from all the .o files. --- Doc | 2 + Makefile.in | 156 +++++++++++++++++++++++++++++++++++++++++ client/Makefile | 14 ++-- conf/Makefile | 34 +++++---- conf/conf.c | 2 +- conf/conf.h | 2 +- conf/confbase.Y | 2 +- configure.in | 32 +++------ doc/LinuxDocTools.pm | 2 + doc/Makefile | 68 +++++++++--------- doc/sgml2html | 8 ++- doc/sgml2latex | 8 ++- doc/sgml2txt | 8 ++- filter/Makefile | 9 ++- lib/Doc | 2 +- lib/Makefile | 7 ++ lib/Modules | 36 ---------- lib/birdlib.h | 4 +- lib/ip.h | 2 +- lib/unaligned.h | 2 +- nest/Makefile | 10 ++- nest/password.h | 2 +- nest/protocol.h | 2 +- nest/route.h | 2 +- proto/bfd/Makefile | 9 ++- proto/bfd/io.h | 2 +- proto/bgp/Makefile | 9 ++- proto/ospf/Makefile | 9 ++- proto/ospf/ospf.h | 2 +- proto/pipe/Makefile | 10 ++- proto/radv/Makefile | 9 ++- proto/radv/radv.h | 2 +- proto/rip/Makefile | 9 ++- proto/rip/rip.h | 2 +- proto/static/Makefile | 10 ++- sysdep/bsd/Makefile | 5 ++ sysdep/bsd/Modules | 4 -- sysdep/bsd/krt-sock.c | 6 +- sysdep/cf/bsd.h | 3 + sysdep/cf/linux.h | 5 ++ sysdep/linux/Makefile | 4 ++ sysdep/linux/Modules | 5 -- sysdep/linux/netlink.c | 6 +- sysdep/unix/Makefile | 5 ++ sysdep/unix/Modules | 12 ---- sysdep/unix/config.Y | 2 +- sysdep/unix/io.c | 6 +- sysdep/unix/krt.Y | 2 +- sysdep/unix/krt.c | 2 +- sysdep/unix/krt.h | 5 +- sysdep/unix/log.c | 2 +- sysdep/unix/main.c | 6 +- sysdep/unix/unix.h | 6 +- tools/Makefile-top.in | 20 ------ tools/Makefile.in | 97 ------------------------- tools/Rules.in | 91 ------------------------ tools/mergedirs | 63 ----------------- tools/progdoc | 33 +++++++-- 58 files changed, 371 insertions(+), 508 deletions(-) create mode 100644 Makefile.in create mode 100644 lib/Makefile delete mode 100644 lib/Modules create mode 100644 sysdep/bsd/Makefile delete mode 100644 sysdep/bsd/Modules create mode 100644 sysdep/linux/Makefile delete mode 100644 sysdep/linux/Modules create mode 100644 sysdep/unix/Makefile delete mode 100644 sysdep/unix/Modules delete mode 100644 tools/Makefile-top.in delete mode 100644 tools/Makefile.in delete mode 100644 tools/Rules.in delete mode 100755 tools/mergedirs diff --git a/Doc b/Doc index f5f15087..77061390 100644 --- a/Doc +++ b/Doc @@ -1,3 +1,4 @@ +D doc/prog-head.sgml C doc C nest C conf @@ -5,3 +6,4 @@ C filter C proto C sysdep C lib +D doc/prog-foot.sgml diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 00000000..c2f8ad4e --- /dev/null +++ b/Makefile.in @@ -0,0 +1,156 @@ +# Makefile for the BIRD Internet Routing Daemon +# (c) 1999--2000 Martin Mares +# (c) 2016 Jan Moskyto Matejka + +# Disable build-in rules +MAKEFLAGS += -r + +# Variable definitions +CPPFLAGS=-I$(objdir) -I$(srcdir) @CPPFLAGS@ +CFLAGS=$(CPPFLAGS) @CFLAGS@ +LDFLAGS=@LDFLAGS@ +LIBS=@LIBS@ +CLIENT_LIBS=@CLIENT_LIBS@ +CC=@CC@ +M4=@M4@ +BISON=@BISON@ +FLEX=@FLEX@ +RANLIB=@RANLIB@ +INSTALL=@INSTALL@ +INSTALL_PROGRAM=@INSTALL_PROGRAM@ +INSTALL_DATA=@INSTALL_DATA@ + +client=$(addprefix $(exedir)/,@CLIENT@) +daemon=$(exedir)/bird +protocols = @protocols@ + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ +sbindir=@sbindir@ +sysconfdir=@sysconfdir@ +localstatedir=@localstatedir@ +docdir=@prefix@/doc + +srcdir := @srcdir@ +objdir := @objdir@ +exedir := @exedir@ + +ifeq ($(objdir),.) + objdir := $(realpath .) +endif + +ifeq ($(VERBOSE),) + Q:=@ +else + Q:= +endif + +# Meta rules +cleangoals := clean distclean +docgoals := docs userdocs progdocs +.PHONY: all daemon cli $(cleangoals) $(docgoals) tags +all: daemon cli + +daemon: $(daemon) +cli: $(client) + +# Include directories +dirs := client conf doc filter lib nest $(addprefix proto/,$(protocols)) @sysdep_dirs@ + +conf-y-targets := $(addprefix $(objdir)/conf/,cf-parse.y keywords.h commands.h) +cf-local = $(conf-y-targets): $(s)config.Y + +src-o-files = $(patsubst %.c,$(o)%.o,$(src)) + +all-daemon = $(exedir)/bird: $(obj) +all-client = $(exedir)/birdc $(exedir)/birdcl: $(obj) + +s = $(dir $(lastword $(MAKEFILE_LIST))) +ifeq ($(srcdir),.) + o = $(objdir)/$(s) +else + o = $(patsubst $(srcdir)%,$(objdir)%,$(s)) +endif + +define clean_in = +clean:: + rm -f $(addprefix $(o),$(1)) +endef + +clean = $(eval $(call clean_in,$(1))) + +include $(addsuffix /Makefile,$(addprefix $(srcdir)/,$(dirs))) + +# Generic rules + +$(objdir)/%.o: $(srcdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h + $(Q)echo CC -o $@ -c $< + $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $< + +$(objdir)/%.o: $(objdir)/%.c $(objdir)/.dir-stamp $(objdir)/sysdep/paths.h + $(Q)echo CC -o $@ -c $< + $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $< + +$(objdir)/.dir-stamp: + $(Q)echo MKDIR -p $(addprefix $(objdir)/,$(dirs) doc) + $(Q)mkdir -p $(addprefix $(objdir)/,$(dirs) doc) + $(Q)touch $@ + +$(client) $(daemon): + $(Q)echo LD $(LDFLAGS) -o $@ $^ $(LIBS) + $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) + +$(objdir)/sysdep/paths.h: Makefile + echo >$@ "/* Generated by Makefile, don't edit manually! */" + echo >>$@ "#define PATH_CONFIG_FILE \"@CONFIG_FILE@\"" + echo >>$@ "#define PATH_CONTROL_SOCKET \"@CONTROL_SOCKET@\"" + if test -n "@iproutedir@" ; then echo >>$@ "#define PATH_IPROUTE_DIR \"@iproutedir@\"" ; fi + +# 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]` + +# Install + +install: all + $(INSTALL) -d $(DESTDIR)/$(sbindir) $(DESTDIR)/$(sysconfdir) $(DESTDIR)/@runtimedir@ + $(INSTALL_PROGRAM) $(exedir)/bird $(DESTDIR)/$(sbindir)/bird + $(INSTALL_PROGRAM) $(exedir)/birdcl $(DESTDIR)/$(sbindir)/birdcl + if test -n "@CLIENT@" ; then \ + $(INSTALL_PROGRAM) $(exedir)/birdc $(DESTDIR)/$(sbindir)/birdc ; \ + fi + if ! test -f $(DESTDIR)/@CONFIG_FILE@ ; then \ + $(INSTALL_DATA) $(srcdir)/doc/bird.conf.example $(DESTDIR)/@CONFIG_FILE@ ; \ + else \ + echo "Not overwriting old bird.conf" ; \ + fi + +install-docs: + $(INSTALL) -d $(DESTDIR)/$(docdir) + $(INSTALL_DATA) $(objdir)/doc/{bird,prog}{,-*}.html $(DESTDIR)/$(docdir)/ + +# Cleanup +clean:: + rm -f $(objdir)/sysdep/paths.h + rm -f $(addprefix $(exedir)/,bird birdc birdcl) + find $(objdir) -name "*.[od]" -exec rm -f '{}' '+' + +ifeq ($(objdir),obj) +distclean: clean + rm -rf $(objdir) + rm -f config.log config.status configure Makefile +else +distclean: clean + rm -rf * .dir-stamp + rm -f config.log config.status configure Makefile +endif diff --git a/client/Makefile b/client/Makefile index a1578766..9bdcb815 100644 --- a/client/Makefile +++ b/client/Makefile @@ -1,11 +1,11 @@ -source=commands.c util.c client.c -root-rel=../ -dir-name=client +src := commands.c util.c client.c +obj := $(src-o-files) -clients := $(client) birdcl +$(all-client) -source-dep := $(source) $(addsuffix .c,$(clients)) +$(o)commands.c.dep: $(objdir)/conf/commands.h -subdir: $(addsuffix .o,$(clients)) +$(exedir)/birdc: $(o)birdc.o +$(exedir)/birdc: LIBS += $(CLIENT_LIBS) -include ../Rules +$(exedir)/birdcl: $(o)birdcl.o diff --git a/conf/Makefile b/conf/Makefile index 5d729a42..c4121805 100644 --- a/conf/Makefile +++ b/conf/Makefile @@ -1,31 +1,29 @@ -source=cf-parse.tab.c cf-lex.c conf.c -root-rel=../ +src := cf-parse.tab.c cf-lex.c conf.c +obj := $(src-o-files) -include ../Rules - -conf-src=$(srcdir)/conf -conf-fragments=$(conf-src)/confbase.Y @CONFS@ $(addsuffix /config.Y,$(static-dir-paths)) +$(all-daemon) ifdef DEBUG BISON_DEBUG=-t #FLEX_DEBUG=-d endif -cf-parse.tab.h: cf-parse.tab.c +$(o)cf-parse.tab.h: $(o)cf-parse.tab.c -cf-parse.tab.c: cf-parse.y - $(BISON) -bcf-parse -dv -pcf_ $(BISON_DEBUG) cf-parse.y +$(o)cf-parse.tab.c: $(o)cf-parse.y + echo $< $@ $(o) + $(BISON) -b$(@:.tab.c=) -dv -pcf_ $(BISON_DEBUG) $< -cf-parse.y: $(conf-fragments) $(conf-src)/gen_parser.m4 - $(M4) -P $(conf-src)/gen_parser.m4 $(conf-fragments) >cf-parse.y +$(conf-y-targets): $(s)confbase.Y + $(M4) -P $| $^ >$@ -keywords.h: $(conf-fragments) $(conf-src)/gen_keywords.m4 - $(M4) -P $(conf-src)/gen_keywords.m4 $(conf-fragments) >keywords.h +$(o)cf-parse.y: | $(s)gen_parser.m4 +$(o)keywords.h: | $(s)gen_keywords.m4 +$(o)commands.h: | $(s)gen_commands.m4 $(srcdir)/client/cmds.m4 -commands.h: $(conf-fragments) $(conf-src)/gen_commands.m4 $(srcdir)/client/cmds.m4 - $(M4) -P $(conf-src)/gen_commands.m4 $(srcdir)/client/cmds.m4 $(conf-fragments) | sort >commands.h +$(o)cf-lex.c: $(s)cf-lex.l $(o)cf-parse.tab.h $(o)keywords.h $(o)commands.h + $(FLEX) $(FLEX_DEBUG) -s -B -8 -o$@ -Pcf_ $< -cf-lex.c: cf-lex.l - $(FLEX) $(FLEX_DEBUG) -s -B -8 -ocf-lex.c -Pcf_ cf-lex.l +$(addprefix $(o),cf-parse.tab.h cf-parse.tab.c cf-parse.y keywords.h commands.h cf-lex.c): $(objdir)/.dir-stamp -depend: keywords.h commands.h cf-parse.tab.c cf-lex.c +$(call clean,cf-parse.tab.h cf-parse.tab.c cf-parse.y keywords.h commands.h cf-lex.c cf-parse.output) diff --git a/conf/conf.c b/conf/conf.c index 3fd10ad8..8d4d28e3 100644 --- a/conf/conf.c +++ b/conf/conf.c @@ -52,7 +52,7 @@ #include "lib/resource.h" #include "lib/string.h" #include "lib/event.h" -#include "lib/timer.h" +#include "sysdep/unix/timer.h" #include "conf/conf.h" #include "filter/filter.h" diff --git a/conf/conf.h b/conf/conf.h index 8e490c7b..03fecd32 100644 --- a/conf/conf.h +++ b/conf/conf.h @@ -10,7 +10,7 @@ #define _BIRD_CONF_H_ #include "lib/resource.h" -#include "lib/timer.h" +#include "sysdep/unix/timer.h" /* Configuration structure */ diff --git a/conf/confbase.Y b/conf/confbase.Y index 22aee770..d5fd2133 100644 --- a/conf/confbase.Y +++ b/conf/confbase.Y @@ -14,7 +14,7 @@ CF_HDR #include "conf/conf.h" #include "lib/resource.h" #include "lib/socket.h" -#include "lib/timer.h" +#include "sysdep/unix/timer.h" #include "lib/string.h" #include "nest/protocol.h" #include "nest/iface.h" diff --git a/configure.in b/configure.in index 1c2c2fe1..f1697c12 100644 --- a/configure.in +++ b/configure.in @@ -23,24 +23,16 @@ AC_ARG_VAR([M4], [location of the M4 program]) if test "$srcdir" = . ; then # Building in current directory => create obj directory holding all objects objdir=obj - mkdir -p obj - srcdir_rel=.. - makefiles="Makefile:tools/Makefile-top.in obj/Makefile:tools/Makefile.in obj/Rules:tools/Rules.in" - exedir=.. else # Building in separate directory objdir=. - srcdir_rel=$srcdir - makefiles="Makefile:tools/Makefile.in Rules:tools/Rules.in" - exedir=. fi -case $srcdir_rel in - /*) srcdir_rel_mf=$srcdir_rel ;; - *) srcdir_rel_mf="\$(root-rel)$srcdir_rel" ;; -esac + +exedir=. + AC_SUBST(objdir) AC_SUBST(exedir) -AC_SUBST(srcdir_rel_mf) +AC_SUBST(srcdir) AC_SUBST(runtimedir) @@ -162,7 +154,7 @@ sysname=`echo $sysdesc | sed 's/\.h$//'` AC_DEFINE_UNQUOTED(SYSCONF_INCLUDE, "$sysdesc") AC_MSG_CHECKING([system-dependent directories]) -sysdep_dirs="`sed <$sysdesc '/^Link: /!d;s/^Link: \(.*\)$/\1/' | tr '\012' ' '` lib" +sysdep_dirs="`sed <$sysdesc '/^Link: /!d;s/^Link: \(.*\)$/\1/' | tr '\012' ' '`" AC_MSG_RESULT($sysdep_dirs) AC_SUBST(sysdep_dirs) @@ -234,10 +226,10 @@ if test "$enable_debug" = yes ; then fi fi -CLIENT= +CLIENT=birdcl CLIENT_LIBS= if test "$enable_client" = yes ; then - CLIENT=birdc + CLIENT="$CLIENT birdc" AC_CHECK_LIB(history, add_history, CLIENT_LIBS="-lhistory") AC_CHECK_LIB(ncurses, tgetent, USE_TERMCAP_LIB=-lncurses, AC_CHECK_LIB(curses, tgetent, USE_TERMCAP_LIB=-lcurses, @@ -255,17 +247,9 @@ AC_SUBST(CLIENT_LIBS) mkdir -p $objdir/sysdep AC_CONFIG_HEADERS([$objdir/sysdep/autoconf.h:sysdep/autoconf.h.in]) -AC_CONFIG_COMMANDS([merge],[[export CPP="$CPP" -$srcdir/tools/mergedirs $srcdir $srcdir_rel $objdir $sysdep_dirs]], - [[srcdir=$srcdir] - [srcdir_rel=$srcdir_rel] - [objdir=$objdir] - [sysdep_dirs="$sysdep_dirs"]]) -AC_CONFIG_FILES($makefiles) +AC_CONFIG_FILES(Makefile:Makefile.in) AC_OUTPUT -rm -f $objdir/sysdep/paths.h - cat >&AC_FD_MSG <prog.spell - ispell prog.spell +$(o)%.txt: $(o)%.sgml + cd $(dir $@) && $(sgml2)txt $(notdir $<) -clean: - rm -f *.tex *.dvi *.log *.txt *.aux *.toc *.spell - rm -f prog.sgml +$(o)prog.spell: $(o)prog.sgml $(s)prog-spell.sed + sed -f $(lastword $^) <$< >$@ + ispell $@ -distclean: clean - rm -f *.html *.ps +$(call clean,prog.spell $(addprefix *.,html dvi ps pdf sgml tex txt aux log toc)) diff --git a/doc/sgml2html b/doc/sgml2html index 774a03d5..a5bbee9e 100755 --- a/doc/sgml2html +++ b/doc/sgml2html @@ -17,8 +17,10 @@ use strict; use vars qw($prefix $DataDir $BinDir $progs); +use FindBin; + $prefix = "/usr"; -$DataDir = "sbase"; +$DataDir = "$FindBin::Bin/sbase"; $BinDir = "/usr/bin"; use lib "/usr/share/linuxdoc-tools"; @@ -32,9 +34,9 @@ $progs = { "GROFFMACRO" => "-ms", "AWK" => "/usr/share/linuxdoc-tools/awkwhich" }; -$ENV{"SGML_CATALOG_FILES"} = "sbase/dtd/catalog"; +$ENV{"SGML_CATALOG_FILES"} = "$DataDir/dtd/catalog"; -require "./LinuxDocTools.pm"; +require "$FindBin::Bin/LinuxDocTools.pm"; &LinuxDocTools::init; my @FileList = LinuxDocTools::process_options ("html", @ARGV); diff --git a/doc/sgml2latex b/doc/sgml2latex index 27aae4c8..02b60d94 100755 --- a/doc/sgml2latex +++ b/doc/sgml2latex @@ -17,8 +17,10 @@ use strict; use vars qw($prefix $DataDir $BinDir $progs); +use FindBin; + $prefix = "/usr"; -$DataDir = "sbase"; +$DataDir = "$FindBin::Bin/sbase"; $BinDir = "/usr/bin"; use lib "/usr/share/linuxdoc-tools"; @@ -32,9 +34,9 @@ $progs = { "GROFFMACRO" => "-ms", "AWK" => "/usr/share/linuxdoc-tools/awkwhich" }; -$ENV{"SGML_CATALOG_FILES"} = "sbase/dtd/catalog"; +$ENV{"SGML_CATALOG_FILES"} = "$DataDir/dtd/catalog"; -require "./LinuxDocTools.pm"; +require "$FindBin::Bin/LinuxDocTools.pm"; &LinuxDocTools::init; my @FileList = LinuxDocTools::process_options ("latex", @ARGV); diff --git a/doc/sgml2txt b/doc/sgml2txt index 90dc4855..dfc017de 100755 --- a/doc/sgml2txt +++ b/doc/sgml2txt @@ -17,8 +17,10 @@ use strict; use vars qw($prefix $DataDir $BinDir $progs); +use FindBin; + $prefix = "/usr"; -$DataDir = "sbase"; +$DataDir = "$FindBin::Bin/sbase"; $BinDir = "/usr/bin"; use lib "/usr/share/linuxdoc-tools"; @@ -32,9 +34,9 @@ $progs = { "GROFFMACRO" => "-ms", "AWK" => "/usr/share/linuxdoc-tools/awkwhich" }; -$ENV{"SGML_CATALOG_FILES"} = "sbase/dtd/catalog"; +$ENV{"SGML_CATALOG_FILES"} = "$DataDir/dtd/catalog"; -require "./LinuxDocTools.pm"; +require "$FindBin::Bin/LinuxDocTools.pm"; &LinuxDocTools::init; my @FileList = LinuxDocTools::process_options ("txt", @ARGV); diff --git a/filter/Makefile b/filter/Makefile index 2de598da..f27befdf 100644 --- a/filter/Makefile +++ b/filter/Makefile @@ -1,5 +1,4 @@ -source=f-util.c filter.c tree.c trie.c -root-rel=../ -dir-name=filter - -include ../Rules +src := filter.c f-util.c tree.c trie.c +obj := $(src-o-files) +$(all-daemon) +$(cf-local) diff --git a/lib/Doc b/lib/Doc index 8f513821..8af1c669 100644 --- a/lib/Doc +++ b/lib/Doc @@ -1,5 +1,5 @@ H Library functions -S ip.c ipv4.c ipv6.c +S ip.c S lists.c S checksum.c bitops.c patmatch.c printf.c xmalloc.c tbf.c D resource.sgml diff --git a/lib/Makefile b/lib/Makefile new file mode 100644 index 00000000..a9aae66f --- /dev/null +++ b/lib/Makefile @@ -0,0 +1,7 @@ +src := bitops.c checksum.c ip.c lists.c md5.c net.c patmatch.c printf.c sha1.c sha256.c sha512.c slists.c xmalloc.c +obj := $(src-o-files) +$(all-client) + +src := bitops.c checksum.c event.c idm.c ip.c lists.c md5.c mempool.c net.c patmatch.c printf.c resource.c sha1.c sha256.c sha512.c slab.c slists.c tbf.c xmalloc.c +obj := $(src-o-files) +$(all-daemon) diff --git a/lib/Modules b/lib/Modules deleted file mode 100644 index 6b9b4b0f..00000000 --- a/lib/Modules +++ /dev/null @@ -1,36 +0,0 @@ -sha256.c -sha256.h -sha512.c -sha512.h -sha1.c -sha1.h -birdlib.h -bitops.c -bitops.h -idm.c -idm.h -ip.c -ip.h -lists.c -lists.h -md5.c -md5.h -mempool.c -resource.c -resource.h -slab.c -socket.h -tbf.c -unaligned.h -xmalloc.c -printf.c -string.h -patmatch.c -slists.c -slists.h -event.c -event.h -checksum.c -checksum.h -alloca.h -net.c diff --git a/lib/birdlib.h b/lib/birdlib.h index ece50dc2..78df81d6 100644 --- a/lib/birdlib.h +++ b/lib/birdlib.h @@ -9,8 +9,8 @@ #ifndef _BIRD_BIRDLIB_H_ #define _BIRD_BIRDLIB_H_ -#include "timer.h" -#include "alloca.h" +#include "sysdep/unix/timer.h" +#include "lib/alloca.h" /* Ugly structure offset handling macros */ diff --git a/lib/ip.h b/lib/ip.h index 3191e307..ffc1b232 100644 --- a/lib/ip.h +++ b/lib/ip.h @@ -9,7 +9,7 @@ #ifndef _BIRD_IP_H_ #define _BIRD_IP_H_ -#include "lib/endian.h" +#include "sysdep/unix/endian.h" #include "lib/string.h" #include "lib/bitops.h" #include "lib/unaligned.h" diff --git a/lib/unaligned.h b/lib/unaligned.h index 130b2479..ad5811ab 100644 --- a/lib/unaligned.h +++ b/lib/unaligned.h @@ -17,7 +17,7 @@ * if possible. */ -#include "lib/endian.h" +#include "sysdep/unix/endian.h" #include "lib/string.h" static inline u16 diff --git a/nest/Makefile b/nest/Makefile index 478a82b7..6f0f9a08 100644 --- a/nest/Makefile +++ b/nest/Makefile @@ -1,6 +1,4 @@ -source=rt-table.c rt-fib.c rt-attr.c proto.c iface.c rt-dev.c password.c cli.c locks.c cmds.c neighbor.c \ - a-path.c a-set.c -root-rel=../ -dir-name=nest - -include ../Rules +src := a-path.c a-set.c cli.c cmds.c iface.c locks.c neighbor.c password.c proto.c rt-attr.c rt-dev.c rt-fib.c rt-table.c +obj := $(src-o-files) +$(all-daemon) +$(cf-local) diff --git a/nest/password.h b/nest/password.h index 1d9de53c..cbf80b99 100644 --- a/nest/password.h +++ b/nest/password.h @@ -9,7 +9,7 @@ #ifndef PASSWORD_H #define PASSWORD_H -#include "lib/timer.h" +#include "sysdep/unix/timer.h" struct password_item { node n; diff --git a/nest/protocol.h b/nest/protocol.h index 19f5d070..61919a54 100644 --- a/nest/protocol.h +++ b/nest/protocol.h @@ -12,7 +12,7 @@ #include "lib/lists.h" #include "lib/resource.h" #include "lib/event.h" -#include "lib/timer.h" +#include "sysdep/unix/timer.h" #include "nest/route.h" #include "conf/conf.h" diff --git a/nest/route.h b/nest/route.h index 22fca331..a893841f 100644 --- a/nest/route.h +++ b/nest/route.h @@ -11,7 +11,7 @@ #include "lib/lists.h" #include "lib/resource.h" -#include "lib/timer.h" +#include "sysdep/unix/timer.h" //#include "nest/protocol.h" struct ea_list; diff --git a/proto/bfd/Makefile b/proto/bfd/Makefile index c28cedec..489216d8 100644 --- a/proto/bfd/Makefile +++ b/proto/bfd/Makefile @@ -1,5 +1,4 @@ -source=bfd.c packets.c io.c -root-rel=../../ -dir-name=proto/bfd - -include ../../Rules +src := bfd.c io.c packets.c +obj := $(src-o-files) +$(all-daemon) +$(cf-local) diff --git a/proto/bfd/io.h b/proto/bfd/io.h index 641ee054..45836f84 100644 --- a/proto/bfd/io.h +++ b/proto/bfd/io.h @@ -12,7 +12,7 @@ #include "lib/resource.h" #include "lib/event.h" #include "lib/socket.h" -// #include "lib/timer.h" +// #include "sysdep/unix/timer.h" typedef struct timer2 diff --git a/proto/bgp/Makefile b/proto/bgp/Makefile index a634cf0d..f4958867 100644 --- a/proto/bgp/Makefile +++ b/proto/bgp/Makefile @@ -1,5 +1,4 @@ -source=bgp.c attrs.c packets.c -root-rel=../../ -dir-name=proto/bgp - -include ../../Rules +src := attrs.c bgp.c packets.c +obj := $(src-o-files) +$(all-daemon) +$(cf-local) diff --git a/proto/ospf/Makefile b/proto/ospf/Makefile index f90222cf..fe52ed30 100644 --- a/proto/ospf/Makefile +++ b/proto/ospf/Makefile @@ -1,5 +1,4 @@ -source=ospf.c topology.c packet.c hello.c neighbor.c iface.c dbdes.c lsreq.c lsupd.c lsack.c lsalib.c rt.c -root-rel=../../ -dir-name=proto/ospf - -include ../../Rules +src := dbdes.c hello.c iface.c lsack.c lsalib.c lsreq.c lsupd.c neighbor.c ospf.c packet.c rt.c topology.c +obj := $(src-o-files) +$(all-daemon) +$(cf-local) diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index 3d70df7b..4f445f07 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -18,7 +18,7 @@ #include "lib/lists.h" #include "lib/slists.h" #include "lib/socket.h" -#include "lib/timer.h" +#include "sysdep/unix/timer.h" #include "lib/resource.h" #include "nest/protocol.h" #include "nest/iface.h" diff --git a/proto/pipe/Makefile b/proto/pipe/Makefile index 77de5b88..c258a3e5 100644 --- a/proto/pipe/Makefile +++ b/proto/pipe/Makefile @@ -1,6 +1,4 @@ -source=pipe.c -root-rel=../../ -dir-name=proto/pipe - -include ../../Rules - +src := pipe.c +obj := $(src-o-files) +$(all-daemon) +$(cf-local) diff --git a/proto/radv/Makefile b/proto/radv/Makefile index efc4d4af..3584a5f3 100644 --- a/proto/radv/Makefile +++ b/proto/radv/Makefile @@ -1,5 +1,4 @@ -source=radv.c packets.c -root-rel=../../ -dir-name=proto/radv - -include ../../Rules +src := packets.c radv.c +obj := $(src-o-files) +$(all-daemon) +$(cf-local) diff --git a/proto/radv/radv.h b/proto/radv/radv.h index f8aa421d..735aa218 100644 --- a/proto/radv/radv.h +++ b/proto/radv/radv.h @@ -13,7 +13,7 @@ #include "lib/ip.h" #include "lib/lists.h" #include "lib/socket.h" -#include "lib/timer.h" +#include "sysdep/unix/timer.h" #include "lib/resource.h" #include "nest/protocol.h" #include "nest/iface.h" diff --git a/proto/rip/Makefile b/proto/rip/Makefile index d2d3c987..6e645cc2 100644 --- a/proto/rip/Makefile +++ b/proto/rip/Makefile @@ -1,5 +1,4 @@ -source=rip.c packets.c -root-rel=../../ -dir-name=proto/rip - -include ../../Rules +src := packets.c rip.c +obj := $(src-o-files) +$(all-daemon) +$(cf-local) diff --git a/proto/rip/rip.h b/proto/rip/rip.h index d1c9933c..7ec7e24d 100644 --- a/proto/rip/rip.h +++ b/proto/rip/rip.h @@ -24,7 +24,7 @@ #include "lib/resource.h" #include "lib/socket.h" #include "lib/string.h" -#include "lib/timer.h" +#include "sysdep/unix/timer.h" #define RIP_V1 1 diff --git a/proto/static/Makefile b/proto/static/Makefile index 61fadbea..3ace39cf 100644 --- a/proto/static/Makefile +++ b/proto/static/Makefile @@ -1,6 +1,4 @@ -source=static.c -root-rel=../../ -dir-name=proto/static - -include ../../Rules - +src := static.c +obj := $(src-o-files) +$(all-daemon) +$(cf-local) diff --git a/sysdep/bsd/Makefile b/sysdep/bsd/Makefile new file mode 100644 index 00000000..ddc87239 --- /dev/null +++ b/sysdep/bsd/Makefile @@ -0,0 +1,5 @@ +src := krt-sock.c +obj := $(src-o-files) +$(all-daemon) +$(conf-y-targets): $(s)krt-sock.Y + diff --git a/sysdep/bsd/Modules b/sysdep/bsd/Modules deleted file mode 100644 index 96455db7..00000000 --- a/sysdep/bsd/Modules +++ /dev/null @@ -1,4 +0,0 @@ -krt-sock.c -krt-sock.Y -krt-sys.h -sysio.h diff --git a/sysdep/bsd/krt-sock.c b/sysdep/bsd/krt-sock.c index 5f2f1309..c6456838 100644 --- a/sysdep/bsd/krt-sock.c +++ b/sysdep/bsd/krt-sock.c @@ -28,9 +28,9 @@ #include "nest/route.h" #include "nest/protocol.h" #include "nest/iface.h" -#include "lib/timer.h" -#include "lib/unix.h" -#include "lib/krt.h" +#include "sysdep/unix/timer.h" +#include "sysdep/unix/unix.h" +#include "sysdep/unix/krt.h" #include "lib/string.h" #include "lib/socket.h" diff --git a/sysdep/cf/bsd.h b/sysdep/cf/bsd.h index 51beb42b..22c54277 100644 --- a/sysdep/cf/bsd.h +++ b/sysdep/cf/bsd.h @@ -15,6 +15,9 @@ #define CONFIG_NO_IFACE_BIND #define CONFIG_USE_HDRINCL +#define CONFIG_INCLUDE_SYSIO_H "sysdep/bsd/sysio.h" +#define CONFIG_INCLUDE_KRTSYS_H "sysdep/bsd/krt-sys.h" + /* Link: sysdep/unix Link: sysdep/bsd diff --git a/sysdep/cf/linux.h b/sysdep/cf/linux.h index 9e34f869..cec9499c 100644 --- a/sysdep/cf/linux.h +++ b/sysdep/cf/linux.h @@ -14,7 +14,12 @@ #define CONFIG_MC_PROPER_SRC #define CONFIG_UNIX_DONTROUTE +#define CONFIG_INCLUDE_SYSIO_H "sysdep/linux/sysio.h" +#define CONFIG_INCLUDE_KRTSYS_H "sysdep/linux/krt-sys.h" + #define CONFIG_RESTRICTED_PRIVILEGES +#define CONFIG_INCLUDE_SYSPRIV_H "sysdep/linux/syspriv.h" + /* Link: sysdep/linux diff --git a/sysdep/linux/Makefile b/sysdep/linux/Makefile new file mode 100644 index 00000000..23cf1d9d --- /dev/null +++ b/sysdep/linux/Makefile @@ -0,0 +1,4 @@ +src := netlink.c +obj := $(src-o-files) +$(all-daemon) +$(conf-y-targets): $(s)netlink.Y diff --git a/sysdep/linux/Modules b/sysdep/linux/Modules deleted file mode 100644 index 940660b6..00000000 --- a/sysdep/linux/Modules +++ /dev/null @@ -1,5 +0,0 @@ -krt-sys.h -netlink.c -netlink.Y -sysio.h -syspriv.h diff --git a/sysdep/linux/netlink.c b/sysdep/linux/netlink.c index 6240c177..6cf40484 100644 --- a/sysdep/linux/netlink.c +++ b/sysdep/linux/netlink.c @@ -20,9 +20,9 @@ #include "nest/protocol.h" #include "nest/iface.h" #include "lib/alloca.h" -#include "lib/timer.h" -#include "lib/unix.h" -#include "lib/krt.h" +#include "sysdep/unix/timer.h" +#include "sysdep/unix/unix.h" +#include "sysdep/unix/krt.h" #include "lib/socket.h" #include "lib/string.h" #include "lib/hash.h" diff --git a/sysdep/unix/Makefile b/sysdep/unix/Makefile new file mode 100644 index 00000000..c5d55431 --- /dev/null +++ b/sysdep/unix/Makefile @@ -0,0 +1,5 @@ +src := io.c krt.c log.c main.c random.c +obj := $(src-o-files) +$(all-daemon) +$(cf-local) +$(conf-y-targets): $(s)krt.Y diff --git a/sysdep/unix/Modules b/sysdep/unix/Modules deleted file mode 100644 index 2c6514df..00000000 --- a/sysdep/unix/Modules +++ /dev/null @@ -1,12 +0,0 @@ -log.c -main.c -timer.h -io.c -unix.h -endian.h -config.Y -random.c - -krt.c -krt.h -krt.Y diff --git a/sysdep/unix/config.Y b/sysdep/unix/config.Y index f9a92900..ebadd454 100644 --- a/sysdep/unix/config.Y +++ b/sysdep/unix/config.Y @@ -8,7 +8,7 @@ CF_HDR -#include "lib/unix.h" +#include "sysdep/unix/unix.h" #include CF_DECLS diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index cbfb47d5..afa51be7 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -31,14 +31,14 @@ #include "nest/bird.h" #include "lib/lists.h" #include "lib/resource.h" -#include "lib/timer.h" +#include "sysdep/unix/timer.h" #include "lib/socket.h" #include "lib/event.h" #include "lib/string.h" #include "nest/iface.h" -#include "lib/unix.h" -#include "lib/sysio.h" +#include "sysdep/unix/unix.h" +#include CONFIG_INCLUDE_SYSIO_H /* Maximum number of calls of tx handler for one socket in one * select iteration. Should be small enough to not monopolize CPU by diff --git a/sysdep/unix/krt.Y b/sysdep/unix/krt.Y index 1cd73502..91317d97 100644 --- a/sysdep/unix/krt.Y +++ b/sysdep/unix/krt.Y @@ -8,7 +8,7 @@ CF_HDR -#include "lib/krt.h" +#include "sysdep/unix/krt.h" CF_DEFINES diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c index 6b3b4eee..38f31235 100644 --- a/sysdep/unix/krt.c +++ b/sysdep/unix/krt.c @@ -56,7 +56,7 @@ #include "nest/route.h" #include "nest/protocol.h" #include "filter/filter.h" -#include "lib/timer.h" +#include "sysdep/unix/timer.h" #include "conf/conf.h" #include "lib/string.h" diff --git a/sysdep/unix/krt.h b/sysdep/unix/krt.h index e968ad57..cb404de3 100644 --- a/sysdep/unix/krt.h +++ b/sysdep/unix/krt.h @@ -15,7 +15,8 @@ struct krt_proto; struct kif_config; struct kif_proto; -#include "lib/krt-sys.h" +#include "sysdep/config.h" +#include CONFIG_INCLUDE_KRTSYS_H /* Flags stored in net->n.flags, rest are in nest/route.h */ @@ -111,7 +112,7 @@ struct kif_proto { struct kif_state sys; /* Sysdep state */ }; -struct kif_proto *kif_proto; +extern struct kif_proto *kif_proto; #define KIF_CF ((struct kif_config *)p->p.cf) diff --git a/sysdep/unix/log.c b/sysdep/unix/log.c index 7cb26360..8daff034 100644 --- a/sysdep/unix/log.c +++ b/sysdep/unix/log.c @@ -26,7 +26,7 @@ #include "nest/mrtdump.h" #include "lib/string.h" #include "lib/lists.h" -#include "lib/unix.h" +#include "sysdep/unix/unix.h" static FILE *dbgf; static list *current_log_list; diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c index 8796ab9c..14b3b2f6 100644 --- a/sysdep/unix/main.c +++ b/sysdep/unix/main.c @@ -69,7 +69,7 @@ async_dump(void) */ #ifdef CONFIG_RESTRICTED_PRIVILEGES -#include "lib/syspriv.h" +#include CONFIG_INCLUDE_SYSPRIV_H #else static inline void @@ -567,6 +567,10 @@ sysdep_shutdown_done(void) * Signals */ +volatile int async_config_flag; +volatile int async_dump_flag; +volatile int async_shutdown_flag; + static void handle_sighup(int sig UNUSED) { diff --git a/sysdep/unix/unix.h b/sysdep/unix/unix.h index 414b6ca4..80c99350 100644 --- a/sysdep/unix/unix.h +++ b/sysdep/unix/unix.h @@ -91,9 +91,9 @@ int sockaddr_read(sockaddr *sa, int af, ip_addr *a, struct iface **ifa, uint *po #define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) + strlen ((ptr)->sun_path)) #endif -volatile int async_config_flag; -volatile int async_dump_flag; -volatile int async_shutdown_flag; +extern volatile int async_config_flag; +extern volatile int async_dump_flag; +extern volatile int async_shutdown_flag; void io_init(void); void io_loop(void); diff --git a/tools/Makefile-top.in b/tools/Makefile-top.in deleted file mode 100644 index cf59f7a1..00000000 --- a/tools/Makefile-top.in +++ /dev/null @@ -1,20 +0,0 @@ -# Makefile for in place build of BIRD -# (c) 1999--2000 Martin Mares - -objdir=@objdir@ - -all depend tags install install-docs: - $(MAKE) -C $(objdir) $@ - -docs userdocs progdocs: - $(MAKE) -C doc $@ - -clean: - $(MAKE) -C $(objdir) clean - find . -name "*~" -or -name "*.[oa]" -or -name "\#*\#" -or -name TAGS -or -name core -or -name depend -or -name ".#*" | xargs rm -f - -distclean: clean - $(MAKE) -C doc distclean - rm -rf $(objdir) autom4te.cache - rm -f config.* configure sysdep/autoconf.h sysdep/paths.h Makefile - diff --git a/tools/Makefile.in b/tools/Makefile.in deleted file mode 100644 index 5de323ab..00000000 --- a/tools/Makefile.in +++ /dev/null @@ -1,97 +0,0 @@ -# Makefile for the BIRD Internet Routing Daemon -# (c) 1999--2000 Martin Mares - -include Rules - -.PHONY: all daemon birdc birdcl subdir depend clean distclean tags docs userdocs progdocs - -all: sysdep/paths.h .dep-stamp subdir daemon birdcl @CLIENT@ - -daemon: $(exedir)/bird - -birdc: $(exedir)/birdc - -birdcl: $(exedir)/birdcl - -bird-dep := $(addsuffix /all.o, $(static-dirs)) conf/all.o lib/birdlib.a - -$(bird-dep): sysdep/paths.h .dep-stamp subdir - -birdc-dep := client/birdc.o client/all.o lib/birdlib.a - -$(birdc-dep): sysdep/paths.h .dep-stamp subdir - -birdcl-dep := client/birdcl.o client/all.o lib/birdlib.a - -$(birdcl-dep): sysdep/paths.h .dep-stamp subdir - - -export client := @CLIENT@ - -depend: sysdep/paths.h .dir-stamp - set -e ; for a in $(dynamic-dirs) ; do $(MAKE) -C $$a $@ ; done - set -e ; for a in $(static-dirs) $(client-dirs) ; do $(MAKE) -C $$a -f $(srcdir_abs)/$$a/Makefile $@ ; done - -subdir: sysdep/paths.h .dir-stamp .dep-stamp - set -e ; for a in $(dynamic-dirs) ; do $(MAKE) -C $$a $@ ; done - set -e ; for a in $(static-dirs) $(client-dirs) ; do $(MAKE) -C $$a -f $(srcdir_abs)/$$a/Makefile $@ ; done - -$(exedir)/bird: $(bird-dep) - @echo LD $(LDFLAGS) -o $@ $^ $(LIBS) - @$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) - -$(exedir)/birdc: $(birdc-dep) - @echo LD $(LDFLAGS) -o $@ $^ $(LIBS) $(CLIENT_LIBS) - @$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(CLIENT_LIBS) - -$(exedir)/birdcl: $(birdcl-dep) - @echo LD $(LDFLAGS) -o $@ $^ $(LIBS) - @$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) - -.dir-stamp: sysdep/paths.h - mkdir -p $(static-dirs) $(client-dirs) $(doc-dirs) - touch .dir-stamp - -.dep-stamp: - $(MAKE) depend - touch .dep-stamp - -docs: userdocs progdocs - -userdocs progdocs: .dir-stamp - $(MAKE) -C doc -f $(srcdir_abs)/doc/Makefile $@ - -sysdep/paths.h: - echo >sysdep/paths.h "/* Generated by Makefile, don't edit manually! */" - echo >>sysdep/paths.h "#define PATH_CONFIG_FILE \"@CONFIG_FILE@\"" - echo >>sysdep/paths.h "#define PATH_CONTROL_SOCKET \"@CONTROL_SOCKET@\"" - if test -n "@iproutedir@" ; then echo >>sysdep/paths.h "#define PATH_IPROUTE_DIR \"@iproutedir@\"" ; fi - -tags: - cd $(srcdir) ; etags -lc `find $(static-dirs) $(addprefix $(objdir)/,$(dynamic-dirs)) $(client-dirs) -name *.[chY]` - -install: all - $(INSTALL) -d $(DESTDIR)/$(sbindir) $(DESTDIR)/$(sysconfdir) $(DESTDIR)/@runtimedir@ - $(INSTALL_PROGRAM) $(exedir)/bird $(DESTDIR)/$(sbindir)/bird - $(INSTALL_PROGRAM) $(exedir)/birdcl $(DESTDIR)/$(sbindir)/birdcl - if test -n "@CLIENT@" ; then \ - $(INSTALL_PROGRAM) $(exedir)/birdc $(DESTDIR)/$(sbindir)/birdc ; \ - fi - if ! test -f $(DESTDIR)/@CONFIG_FILE@ ; then \ - $(INSTALL_DATA) $(srcdir)/doc/bird.conf.example $(DESTDIR)/@CONFIG_FILE@ ; \ - else \ - echo "Not overwriting old bird.conf" ; \ - fi - -install-docs: - $(INSTALL) -d $(DESTDIR)/$(docdir) - $(INSTALL_DATA) $(srcdir)/doc/{bird,prog}{,-*}.html $(DESTDIR)/$(docdir)/ - -clean: - find . -name "*.[oa]" -o -name core -o -name depend -o -name "*.html" | xargs rm -f - rm -f conf/cf-lex.c conf/cf-parse.* conf/commands.h conf/keywords.h - rm -f $(exedir)/bird $(exedir)/birdcl $(exedir)/birdc $(exedir)/bird.ctl $(exedir)/bird6.ctl .dep-stamp - -distclean: clean - rm -f config.* configure sysdep/autoconf.h sysdep/paths.h Makefile Rules - rm -rf .dir-stamp $(clean-dirs) diff --git a/tools/Rules.in b/tools/Rules.in deleted file mode 100644 index f00c85d1..00000000 --- a/tools/Rules.in +++ /dev/null @@ -1,91 +0,0 @@ -# Makefile fragments for the BIRD Internet Routing Daemon -# (c) 1999--2000 Martin Mares - -srcdir=@srcdir_rel_mf@ -srcdir_abs := $(shell cd $(srcdir) ; pwd) -objdir=@objdir@ -exedir=@exedir@ - -protocols=@protocols@ -static-dirs := nest filter $(addprefix proto/,$(protocols)) -static-dir-paths := $(addprefix $(srcdir)/,$(static-dirs)) -dynamic-dirs := lib conf -dynamic-dir-paths := $(dynamic-dirs) -client-dirs := client -client-dir-paths := $(client-dirs) -doc-dirs := doc -doc-dir-paths := $(doc-dirs) - -all-dirs:=$(static-dirs) $(dynamic-dirs) $(client-dirs) $(doc-dirs) -clean-dirs:=$(all-dirs) proto sysdep - -CPPFLAGS=-I$(root-rel) -I$(srcdir) @CPPFLAGS@ -CFLAGS=$(CPPFLAGS) @CFLAGS@ -LDFLAGS=@LDFLAGS@ -LIBS=@LIBS@ -CLIENT_LIBS=@CLIENT_LIBS@ -CC=@CC@ -M4=@M4@ -BISON=@BISON@ -FLEX=@FLEX@ -RANLIB=@RANLIB@ -INSTALL=@INSTALL@ -INSTALL_PROGRAM=@INSTALL_PROGRAM@ -INSTALL_DATA=@INSTALL_DATA@ - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -sbindir=@sbindir@ -sysconfdir=@sysconfdir@ -localstatedir=@localstatedir@ -docdir=@prefix@/doc - -ifdef source - -objs := $(subst .c,.o,$(source)) - -ifdef dir-name -src-path := $(srcdir)/$(dir-name)/ -endif - -all: - cd $(root-rel) && make - -ifdef lib-dest - -subdir: $(lib-dest) - -$(lib-dest): $(objs) - rm -f $@ - ar rcs $@ $^ - $(RANLIB) $@ - -else - -subdir: all.o - -all.o: $(objs) -# $(LD) -r -o $@ $^ -# Changed to $(CC) because $(LD) has problems with crosscompiling - @echo LD -r -o $@ $^ - @$(CC) -nostdlib -r -o $@ $^ - -endif - -%.o: $(src-path)%.c - @echo CC -o $@ -c $< - @$(CC) $(CFLAGS) -o $@ -c $< - -ifndef source-dep -source-dep := $(source) -endif - -depend: - $(CC) $(CPPFLAGS) -MM $(addprefix $(src-path),$(source-dep)) >depend - -ifneq ($(wildcard depend),) -include depend -endif - -endif diff --git a/tools/mergedirs b/tools/mergedirs deleted file mode 100755 index fb48c6c7..00000000 --- a/tools/mergedirs +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh - -if [ -z "$4" ] ; then - echo "Usage: mergedirs " - exit 1 - fi -cpp=${CPP:-cc -E} -SRCDIR=$1 -shift -SRCREL=$1 -case $SRCDIR in - /*) ;; - *) SRCREL="../$SRCREL" ;; - esac -shift -OBJDIR=$1 -LIBDIR=$OBJDIR/lib -CONFDIR=$OBJDIR/conf -shift - -echo "Merging system-dependent modules ($@)" -MODULES=`for a in $@ ; do - cat $SRCDIR/sysdep/config.h $SRCDIR/$a/Modules | - $cpp -U unix -D MACROS_ONLY -I $OBJDIR - | - sed "/^[ ]*\$/d;/^#/d;s@\\(.*\\)@\\1 $a/\\1@" - done | - sort -k1,1 -u | - cut -d ' ' -f 2` -rm -rf $LIBDIR $CONFDIR -mkdir -p $LIBDIR $CONFDIR -for a in $MODULES ; do - b=`basename $a` - case $b in - *.h) ln -s $SRCREL/$a $LIBDIR/$b - ;; - *.c) OBJ=`echo $b | sed 's/\.c$/\.o/'` - OBJS="$OBJS $OBJ" - SRCS="$SRCS \\ - $b" - ln -s $SRCREL/$a $LIBDIR/$b - ;; - *.Y) CONFS="$CONFS\$(srcdir)/$a " - ln -s $SRCREL/$a $CONFDIR/$b - ;; - *) echo "$b: Unknown file type" - exit 1 - ;; - esac - done - -cat >$LIBDIR/Makefile <$CONFDIR/Makefile "s|@CONFS@|$CONFS|" -CONFS=`cd $SRCDIR ; ls conf/*.[chl]` -for a in $CONFS ; do - ln -s $SRCREL/$a $CONFDIR/ -done diff --git a/tools/progdoc b/tools/progdoc index ef44d3aa..fc4024bf 100755 --- a/tools/progdoc +++ b/tools/progdoc @@ -1,17 +1,18 @@ #!/usr/bin/perl $srcdir = $ARGV[0]; +$out = $ARGV[1]; -open(OUT, ">prog.sgml") || die "Cannot create output file"; -include("doc/prog-head.sgml"); -process(""); -include("doc/prog-foot.sgml"); +open(OUT, ">", $out) || die "Cannot create output file"; +process($srcdir); close OUT; +gen_deps(); exit 0; sub include { my $f = shift @_; - open(IN, "$srcdir/$f") || die "Unable to find $f"; + open(IN, "$f") || die "Unable to find $f"; + push(@deps, "$f"); while () { print OUT; } @@ -21,7 +22,8 @@ sub include { sub process { my $dir = shift @_; print "$dir/Doc\n"; - open(IN, "$srcdir/$dir/Doc") || die "Unable to read $dir/Doc"; + open(IN, "$dir/Doc") || die "Unable to read $dir/Doc"; + push(@deps, "$dir/Doc"); my @docfile = ; close IN; foreach $_ (@docfile) { @@ -36,7 +38,10 @@ sub process { print OUT "$arg\n"; } elsif ($cmd eq "S") { print " $arg\n"; - open(DOC, "cd $srcdir/$dir ; $srcdir/doc/kernel-doc -bird $arg |") || die "Unable to start kernel-doc"; + my @files = map("$dir/$_", split(' ', $arg)); + my $fargs = join(' ', @files); + open(DOC, "$srcdir/doc/kernel-doc -bird $fargs |") || die "Unable to start kernel-doc"; + push(@deps, @files); while () { print OUT; } close DOC; } elsif ($cmd eq "D") { @@ -45,3 +50,17 @@ sub process { } else { die "Unknown command: $cmd"; } } } + +sub gen_deps { + open(DEP, ">", "$out.d"); + print DEP "$out:"; + foreach $f (@deps) { + print DEP " \\\n $f"; + } + print DEP "\n\n"; + + foreach $f (@deps) { + print DEP "$f:\n\n"; + } + close DEP; +} From a8caff322f83f1303c408bbefc440aeea9e619a3 Mon Sep 17 00:00:00 2001 From: Jan Moskyto Matejka Date: Wed, 27 Apr 2016 14:45:14 +0200 Subject: [PATCH 3/3] Portability: Fixed C extension error generated by CLang. sysdep/linux/netlink.c:921:10: error: fields must have a constant size: 'variable length array in structure' extension will never be supported char buf[128 + KRT_METRICS_MAX*8 + nh_bufsize(a->nexthops)]; ^ 1 error generated. --- sysdep/linux/netlink.c | 66 +++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/sysdep/linux/netlink.c b/sysdep/linux/netlink.c index 6cf40484..7b1f2dda 100644 --- a/sysdep/linux/netlink.c +++ b/sysdep/linux/netlink.c @@ -6,6 +6,7 @@ * Can be freely distributed and used under the terms of the GNU GPL. */ +#include #include #include #include @@ -915,44 +916,49 @@ nl_send_route(struct krt_proto *p, rte *e, struct ea_list *eattrs, int new) eattr *ea; net *net = e->net; rta *a = e->attrs; + int bufsize = 128 + KRT_METRICS_MAX*8 + nh_bufsize(a->nexthops); + struct { struct nlmsghdr h; struct rtmsg r; - char buf[128 + KRT_METRICS_MAX*8 + nh_bufsize(a->nexthops)]; - } r; + char buf[0]; + } *r; + + int rsize = sizeof(*r) + bufsize; + r = alloca(rsize); DBG("nl_send_route(%N,new=%d)\n", net->n.addr, new); - bzero(&r.h, sizeof(r.h)); - bzero(&r.r, sizeof(r.r)); - r.h.nlmsg_type = new ? RTM_NEWROUTE : RTM_DELROUTE; - r.h.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); - r.h.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | (new ? NLM_F_CREATE|NLM_F_EXCL : 0); + bzero(&r->h, sizeof(r->h)); + bzero(&r->r, sizeof(r->r)); + r->h.nlmsg_type = new ? RTM_NEWROUTE : RTM_DELROUTE; + r->h.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); + r->h.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | (new ? NLM_F_CREATE|NLM_F_EXCL : 0); - r.r.rtm_family = p->af; - r.r.rtm_dst_len = net_pxlen(net->n.addr); - r.r.rtm_protocol = RTPROT_BIRD; - r.r.rtm_scope = RT_SCOPE_UNIVERSE; - nl_add_attr_ipa(&r.h, sizeof(r), RTA_DST, net_prefix(net->n.addr)); + r->r.rtm_family = p->af; + r->r.rtm_dst_len = net_pxlen(net->n.addr); + r->r.rtm_protocol = RTPROT_BIRD; + r->r.rtm_scope = RT_SCOPE_UNIVERSE; + nl_add_attr_ipa(&r->h, rsize, RTA_DST, net_prefix(net->n.addr)); if (krt_table_id(p) < 256) - r.r.rtm_table = krt_table_id(p); + r->r.rtm_table = krt_table_id(p); else - nl_add_attr_u32(&r.h, sizeof(r), RTA_TABLE, krt_table_id(p)); + nl_add_attr_u32(&r->h, rsize, RTA_TABLE, krt_table_id(p)); /* For route delete, we do not specify route attributes */ if (!new) - return nl_exchange(&r.h); + return nl_exchange(&r->h); if (ea = ea_find(eattrs, EA_KRT_METRIC)) - nl_add_attr_u32(&r.h, sizeof(r), RTA_PRIORITY, ea->u.data); + nl_add_attr_u32(&r->h, rsize, RTA_PRIORITY, ea->u.data); if (ea = ea_find(eattrs, EA_KRT_PREFSRC)) - nl_add_attr_ipa(&r.h, sizeof(r), RTA_PREFSRC, *(ip_addr *)ea->u.ptr->data); + nl_add_attr_ipa(&r->h, rsize, RTA_PREFSRC, *(ip_addr *)ea->u.ptr->data); if (ea = ea_find(eattrs, EA_KRT_REALM)) - nl_add_attr_u32(&r.h, sizeof(r), RTA_FLOW, ea->u.data); + nl_add_attr_u32(&r->h, rsize, RTA_FLOW, ea->u.data); u32 metrics[KRT_METRICS_MAX]; @@ -967,7 +973,7 @@ nl_send_route(struct krt_proto *p, rte *e, struct ea_list *eattrs, int new) } if (metrics[0]) - nl_add_metrics(&r.h, sizeof(r), metrics, KRT_METRICS_MAX); + nl_add_metrics(&r->h, rsize, metrics, KRT_METRICS_MAX); /* a->iface != NULL checked in krt_capable() for router and device routes */ @@ -975,32 +981,32 @@ nl_send_route(struct krt_proto *p, rte *e, struct ea_list *eattrs, int new) switch (a->dest) { case RTD_ROUTER: - r.r.rtm_type = RTN_UNICAST; - nl_add_attr_u32(&r.h, sizeof(r), RTA_OIF, a->iface->index); - nl_add_attr_ipa(&r.h, sizeof(r), RTA_GATEWAY, a->gw); + r->r.rtm_type = RTN_UNICAST; + nl_add_attr_u32(&r->h, rsize, RTA_OIF, a->iface->index); + nl_add_attr_ipa(&r->h, rsize, RTA_GATEWAY, a->gw); break; case RTD_DEVICE: - r.r.rtm_type = RTN_UNICAST; - nl_add_attr_u32(&r.h, sizeof(r), RTA_OIF, a->iface->index); + r->r.rtm_type = RTN_UNICAST; + nl_add_attr_u32(&r->h, rsize, RTA_OIF, a->iface->index); break; case RTD_BLACKHOLE: - r.r.rtm_type = RTN_BLACKHOLE; + r->r.rtm_type = RTN_BLACKHOLE; break; case RTD_UNREACHABLE: - r.r.rtm_type = RTN_UNREACHABLE; + r->r.rtm_type = RTN_UNREACHABLE; break; case RTD_PROHIBIT: - r.r.rtm_type = RTN_PROHIBIT; + r->r.rtm_type = RTN_PROHIBIT; break; case RTD_MULTIPATH: - r.r.rtm_type = RTN_UNICAST; - nl_add_multipath(&r.h, sizeof(r), a->nexthops); + r->r.rtm_type = RTN_UNICAST; + nl_add_multipath(&r->h, rsize, a->nexthops); break; default: bug("krt_capable inconsistent with nl_send_route"); } - return nl_exchange(&r.h); + return nl_exchange(&r->h); } void