Something went wrong. Try again.
forked from cz-nic/bird
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290# Makefile for the BIRD Internet Routing Daemon# (c) 1999--2000 Martin Mares <mj@ucw.cz># (c) 2016--2025 Maria Matejka <mq@ucw.cz>
# Disable build-in rulesMAKEFLAGS += -r
# Variable definitionsCPPFLAGS=-I$(objdir) -I$(srcdir) @CPPFLAGS@CFLAGS=$(CPPFLAGS) @CFLAGS@LDFLAGS=@LDFLAGS@M4FLAGS=@M4FLAGS@BISONFLAGS=@BISONFLAGS@LIBS=@LIBS@DAEMON_LIBS=@DAEMON_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@PANDOC=@PANDOC@
client=$(addprefix $(exedir)/,@CLIENT@)daemon=$(exedir)/birdprotocols=@protocols@PROTO_BUILD := $(protocols) dev kif krt
prefix=@prefix@exec_prefix=@exec_prefix@bindir=@bindir@sbindir=@sbindir@sysconfdir=@sysconfdir@localstatedir=@localstatedir@runstatedir=@runstatedir@docdir=@prefix@/doc
srcdir := @srcdir@objdir := @objdir@exedir := @exedir@
# Find out which version we are actually building# This is rewritten by the release tools by hardcoded versionVERSION := $(strip $(shell $(srcdir)/tools/version))
CFLAGS += -DBIRD_VERSION='"$(VERSION)"'
ifeq ($(objdir),.) objdir := $(realpath .)endif
ifeq ($(VERBOSE),) E:=@ Q:=@else E:=@\# Q:=endif
ifneq ($(COLOR),) CFLAGS += -fdiagnostics-color=alwaysendif
# Meta rulesdocgoals := docs userdocs progdocstestgoals := check test tests tests_runcleangoals := clean distclean testsclean.PHONY: all daemon cli $(docgoals) $(testgoals) $(cleangoals) tags cscope prepare
all: daemon cli
daemon: $(daemon)cli: $(client)
$(daemon): LIBS += $(DAEMON_LIBS)
# Include directoriesdirs := client conf doc filter lib nest test gitlab $(addprefix proto/,$(protocols)) @sysdep_dirs@
# conf/Makefile declarations needed for all other modulesconf-lex-targets := $(addprefix $(objdir)/conf/,cf-lex.o)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))tests-target-files = $(patsubst %.c,$(o)%,$(tests_src))
all-daemon = $(daemon): $(obj)all-client = $(client): $(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 main Makefiles of the directoriesinclude $(addsuffix /Makefile,$(addprefix $(srcdir)/,$(dirs)))
# Generic rules# Object file rules$(objdir)/%.o: $(srcdir)/%.c | prepare $(E)echo CC -o $@ -c $< $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $<
$(objdir)/%.o: $(objdir)/%.c | prepare $(E)echo CC -o $@ -c $< $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $<
# Debug: Preprocessed source rules$(objdir)/%.E: $(srcdir)/%.c | prepare $(E)echo CC -o $@ -E $< $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -E $<
$(objdir)/%.E: $(objdir)/%.c | prepare $(E)echo CC -o $@ -E $< $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -E $<
# Debug: Assembler object rules$(objdir)/%.S: $(srcdir)/%.c | prepare $(E)echo CC -o $@ -S $< $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -S $<
$(objdir)/%.S: $(objdir)/%.c | prepare $(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 goalifneq ($(filter-out $(cleangoals),$(MAKECMDGOALS)),)-include $(DEPS)endif
# ## if the implicit goal is calledifeq ($(MAKECMDGOALS),)-include $(DEPS)endif
# Rule for pre-generating all generated includables# before compiling any C fileprepare: $(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 $@
$(client) $(daemon): $(E)echo LD $(LDFLAGS) -o $@ $^ $(LIBS) $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
$(objdir)/sysdep/paths.h: Makefile $(E)echo GEN $@ $(Q)echo >$@ "/* Generated by Makefile, don't edit manually! */" $(Q)echo >>$@ "#define PATH_CONFIG_FILE \"@CONFIG_FILE@\"" $(Q)echo >>$@ "#define PATH_CONTROL_SOCKET \"@CONTROL_SOCKET@\"" $(Q)if test -n "@iproutedir@" ; then echo >>$@ "#define PATH_IPROUTE_DIR \"@iproutedir@\"" ; fi
# Unit tests rules
tests_targets_ok = $(addsuffix .ok,$(tests_targets))
$(tests_targets): %: %.o $(tests_objs) | prepare $(E)echo LD $(LDFLAGS) -o $@ $< "..." $(LIBS) $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
# Hack to avoid problems with tests linking everything$(tests_targets): LIBS += $(DAEMON_LIBS)
$(tests_targets_ok): %.ok: % $(Q)$(if $(CROSSBUILD_ARCH),qemu-$(CROSSBUILD_ARCH) )$* 2>/dev/null && touch $*.ok $(if $(TEST_RETRY_VERBOSE), || ($(if $(CROSSBUILD_ARCH),qemu-$(CROSSBUILD_ARCH) )$* -ftv && false))
test: testsclean checkcheck: tests tests_runtests: $(tests_targets)tests_run: $(tests_targets_ok)
STATIC_CHECKERS_ENABLE := nullability.NullableDereferenced nullability.NullablePassedToNonnull nullability.NullableReturnedFromNonnull optin.portability.UnixAPI valist.CopyToSelf valist.Uninitialized valist.UnterminatedSTATIC_CHECKERS_DISABLE := deadcode.DeadStoresSTATIC_SCAN_FLAGS := -o $(objdir)/static-scan/ $(addprefix -enable-checker ,$(STATIC_CHECKERS_ENABLE)) $(addprefix -disable-checker ,$(STATIC_CHECKERS_DISABLE))
static-scan: $(E)echo Running static code analysis $(Q)$(MAKE) clean $(Q)scan-build $(STATIC_SCAN_FLAGS) $(MAKE) -$(MAKEFLAGS)
tags: cd $(srcdir) ; etags -lc `find $(dirs) -name '*.[chY]'`
cscope: cd $(srcdir) ; find $(dirs) -name '*.[chY]' > cscope.files ; cscope -b
# Install
install: all $(INSTALL) -d $(DESTDIR)/$(sbindir) $(DESTDIR)/$(sysconfdir) $(DESTDIR)/$(runstatedir) for BIN in bird @CLIENT@ ; do \ $(INSTALL_PROGRAM) $(exedir)/$$BIN $(DESTDIR)/$(sbindir)/$$BIN ; \ done 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)/
# Packagingarchive: tools/make-archive
deb: tools/make-deb
rpm: tools/make-rpm
# Cleanupclean:: rm -f $(objdir)/sysdep/paths.h $(objdir)/nest/proto-build.c rm -f $(addprefix $(exedir)/,bird birdc birdcl) find $(objdir) -name "*.[od]" -exec rm -f '{}' '+'
testsclean: rm -f $(tests_targets_ok)
ifeq ($(objdir),obj)distclean: clean rm -rf $(objdir) rm -f config.log config.status configure Makefileelsedistclean: clean rm -rf * .dir-stamp rm -f config.log config.status configure Makefileendif
# Help dumphelp: @echo "============================= BIRD make system =============================" @echo @echo "To build BIRD directly from sources, run './configure'. For more information" @echo "about that process, run './configure --help'." @echo "To build BIRD from Git repo, run 'autoreconf' before './configure'." @echo @echo "Source build options:" @echo " make all Build BIRD binaries." @echo " make test Build and run unit tests." @echo " make docs Build documentation." @echo @echo "Partial build options:" @echo " make obj/path/to/foo.o Build an object file, don't link." @echo " make obj/path/to/foo.E Run only the C preprocessor." @echo " make obj/path/to/foo.S Generate an assembler dump." @echo @echo "Development tools:" @echo " make static-scan Run CLang static analyzer." @echo " make tags Generate ETags cache." @echo " make cscope Generate CScope cache." @echo @echo "Auxiliary commands:" @echo " make help Show this help." @echo " make clean Cleanup the build directory. Useful after" @echo " major changes or branch switch." @echo " make distclean Cleanup everything so that you will have to" @echo " run './configure' again." @echo " make gitlab-local Re-generate .gitlab-ci.yml without venv" @echo " make gitlab-venv Re-generate .gitlab-ci.yml inside a tmp venv" @echo @echo "Distribution commands:" @echo " make install Install binaries into the system." @echo " make archive Create a release archive (TGZ). @echo " This must exist for 'make deb' and 'make rpm'." @echo " make deb Create a DEB package for the current system." @echo " make rpm Create an RPM package for the current system."