Distributions like Gentoo or Debian have to strip the options regarding the optimisation levels and debugging information to fulfil their policies. There is currently no valid reason why the Makefile should override it.
Signed-off-by: Sven Eckelmann sven@narfation.org --- This patch depends on other patches submitted earlier: - batmand: Fix FTBFS on second build attempt - batmand: Remove obsolete creation of source packages - batmand: Remove subversion/svk revision information - batmand: Use nproc to get number of available processors
Makefile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile index 4df2872..49342ac 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ endif #NO_POLICY_ROUTING = -DNO_POLICY_ROUTING
CC = gcc -CFLAGS += -pedantic -Wall -W -Os -g3 -std=gnu99 +CFLAGS += -pedantic -Wall -W -std=gnu99 EXTRA_CFLAGS = -DDEBUG_MALLOC -DMEMORY_USAGE -DPROFILE_DATA $(NO_POLICY_ROUTING) -DREVISION_VERSION=$(REVISION_VERSION) LDFLAGS += -lpthread
Distributions like Gentoo and Debian have policies which make it necessary to use some kind of environmental variable to control the parallel build.
Signed-off-by: Sven Eckelmann sven@narfation.org --- This patch depends on other patches submitted earlier: - batmand: Fix FTBFS on second build attempt - batmand: Remove obsolete creation of source packages - batmand: Remove subversion/svk revision information - batmand: Use nproc to get number of available processors
Makefile | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile index 49342ac..f8864d0 100644 --- a/Makefile +++ b/Makefile @@ -77,11 +77,8 @@ REVISION= $(shell if [ -d .git ]; then \ fi) REVISION_VERSION ="\ $(REVISION)"
-NUM_CPUS = $(shell nproc 2> /dev/null || echo 1)
- -all: - $(MAKE) -j $(NUM_CPUS) $(BINARY_NAME) +all: $(BINARY_NAME)
$(BINARY_NAME): $(SRC_O) $(SRC_H) Makefile $(Q_LD)$(CC) -o $@ $(SRC_O) $(LDFLAGS)
Signed-off-by: Sven Eckelmann sven@narfation.org --- This patch depends on other patches submitted earlier: - batmand: Fix FTBFS on second build attempt - batmand: Remove obsolete creation of source packages - batmand: Remove subversion/svk revision information - batmand: Use nproc to get number of available processors
Makefile | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile index f8864d0..ce94472 100644 --- a/Makefile +++ b/Makefile @@ -60,17 +60,11 @@ ifeq ($(UNAME),OpenBSD) OS_C = $(BSD_C) $(POSIX_C) endif
-LOG_BRANCH = trunk/batman - -SRC_FILES = "(.c)|(.h)|(Makefile)|(INSTALL)|(LIESMICH)|(README)|(THANKS)|(TRASH)|(Doxyfile)|(./posix)|(./linux)|(./bsd)|(./man)|(./doc)" - SRC_C= batman.c originator.c schedule.c list-batman.c allocate.c bitarray.c hash.c profile.c ring_buffer.c hna.c $(OS_C) SRC_H= batman.h originator.h schedule.h list-batman.h os.h allocate.h bitarray.h hash.h profile.h packet.h types.h ring_buffer.h hna.h SRC_O= $(SRC_C:.c=.o)
-PACKAGE_NAME = batmand BINARY_NAME = batmand -SOURCE_VERSION_HEADER = batman.h
REVISION= $(shell if [ -d .git ]; then \ echo $$(git describe --always --dirty 2> /dev/null || echo "[unknown]"); \
The information about header and source files aren't needed by the Makefile. Only the dependencies to headers provide useful information, but these are automatically included by the generated *.d files.
Signed-off-by: Sven Eckelmann sven@narfation.org --- This patch depends on other patches submitted earlier: - batmand: Fix FTBFS on second build attempt - batmand: Remove obsolete creation of source packages - batmand: Remove subversion/svk revision information - batmand: Use nproc to get number of available processors
Makefile | 29 ++++++++++++++--------------- 1 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/Makefile b/Makefile index ce94472..3ac2885 100644 --- a/Makefile +++ b/Makefile @@ -36,33 +36,33 @@ LDFLAGS += -lpthread SBINDIR = $(INSTALL_PREFIX)/usr/sbin
UNAME = $(shell uname) -POSIX_C = posix/init.c posix/posix.c posix/tunnel.c posix/unix_socket.c -BSD_C = bsd/route.c bsd/tun.c bsd/kernel.c bsd/compat.c +POSIX_OBJ = posix/init.o posix/posix.o posix/tunnel.o posix/unix_socket.o +BSD_OBJ = bsd/route.o bsd/tun.o bsd/kernel.o bsd/compat.o +LINUX_OBJ = linux/route.o linux/tun.o linux/kernel.o
ifeq ($(UNAME),Linux) -OS_C = linux/route.c linux/tun.c linux/kernel.c $(POSIX_C) +OS_OBJ = $(LINUX_OBJ) $(POSIX_OBJ) endif
ifeq ($(UNAME),Darwin) -OS_C = $(BSD_C) $(POSIX_C) +OS_OBJ = $(BSD_OBJ) $(POSIX_OBJ) endif
ifeq ($(UNAME),GNU/kFreeBSD) -OS_C = $(BSD_C) $(POSIX_C) +OS_OBJ = $(BSD_OBJ) $(POSIX_OBJ) LDFLAGS += -lfreebsd -lbsd endif
ifeq ($(UNAME),FreeBSD) -OS_C = $(BSD_C) $(POSIX_C) +OS_OBJ = $(BSD_OBJ) $(POSIX_OBJ) endif
ifeq ($(UNAME),OpenBSD) -OS_C = $(BSD_C) $(POSIX_C) +OS_OBJ = $(BSD_OBJ) $(POSIX_OBJ) endif
-SRC_C= batman.c originator.c schedule.c list-batman.c allocate.c bitarray.c hash.c profile.c ring_buffer.c hna.c $(OS_C) -SRC_H= batman.h originator.h schedule.h list-batman.h os.h allocate.h bitarray.h hash.h profile.h packet.h types.h ring_buffer.h hna.h -SRC_O= $(SRC_C:.c=.o) +OBJ = batman.o originator.o schedule.o list-batman.o allocate.o bitarray.o hash.o profile.o ring_buffer.o hna.o $(OS_OBJ) +DEP = $(OBJ:.o=.d)
BINARY_NAME = batmand
@@ -74,16 +74,15 @@ REVISION_VERSION ="\ $(REVISION)"
all: $(BINARY_NAME)
-$(BINARY_NAME): $(SRC_O) $(SRC_H) Makefile - $(Q_LD)$(CC) -o $@ $(SRC_O) $(LDFLAGS) +$(BINARY_NAME): $(OBJ) Makefile + $(Q_LD)$(CC) -o $@ $(OBJ) $(LDFLAGS)
.c.o: $(Q_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -MD -c $< -o $@ --include $(SRC_C:.c=.d) +-include $(DEP)
clean: - rm -f $(BINARY_NAME) *.o posix/*.o linux/*.o bsd/*.o - rm -f *.d posix/*.d linux/*.d bsd/*.d + rm -f $(BINARY_NAME) $(OBJ) $(DEP)
install: mkdir -p $(SBINDIR)
Signed-off-by: Sven Eckelmann sven@narfation.org --- This patch depends on other patches submitted earlier: - batmand: Fix FTBFS on second build attempt - batmand: Remove obsolete creation of source packages - batmand: Remove subversion/svk revision information - batmand: Use nproc to get number of available processors
Makefile | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) mode change 100644 => 100755 Makefile
diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 index 3ac2885..2514c2d --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +#!/usr/bin/make -f +# -*- makefile -*- # # Copyright (C) 2006-2009 B.A.T.M.A.N. contributors #
Normally makefile targets should create an output with the same name as the target. It is necessary to mark them as PHONY to prevent that the virtual target like all, clean or install aren't executed when a file with the same name exists.
Signed-off-by: Sven Eckelmann sven@narfation.org --- This patch depends on other patches submitted earlier: - batmand: Fix FTBFS on second build attempt - batmand: Remove obsolete creation of source packages - batmand: Remove subversion/svk revision information - batmand: Use nproc to get number of available processors
Makefile | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile index 2514c2d..3b517da 100755 --- a/Makefile +++ b/Makefile @@ -89,3 +89,5 @@ clean: install: mkdir -p $(SBINDIR) install -m 0755 $(BINARY_NAME) $(SBINDIR) + +.PHONY: all clean install
It is possible that a build environment specifies the CC different than gcc (for example gcc-4.6). The Makefile should only set it when the compiler wasn't explicitely set.
Signed-off-by: Sven Eckelmann sven@narfation.org --- This patch depends on other patches submitted earlier: - batmand: Fix FTBFS on second build attempt - batmand: Remove obsolete creation of source packages - batmand: Remove subversion/svk revision information - batmand: Use nproc to get number of available processors
Makefile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile index 3b517da..804bdd4 100755 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ endif # activate this variable to deactivate policy routing for backward compatibility #NO_POLICY_ROUTING = -DNO_POLICY_ROUTING
-CC = gcc +CC ?= gcc CFLAGS += -pedantic -Wall -W -std=gnu99 EXTRA_CFLAGS = -DDEBUG_MALLOC -DMEMORY_USAGE -DPROFILE_DATA $(NO_POLICY_ROUTING) -DREVISION_VERSION=$(REVISION_VERSION) LDFLAGS += -lpthread
Signed-off-by: Sven Eckelmann sven@narfation.org --- This patch depends on other patches submitted earlier: - batmand: Fix FTBFS on second build attempt - batmand: Remove obsolete creation of source packages - batmand: Remove subversion/svk revision information - batmand: Use nproc to get number of available processors
Makefile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile index 804bdd4..df2f5b2 100755 --- a/Makefile +++ b/Makefile @@ -86,7 +86,7 @@ $(BINARY_NAME): $(OBJ) Makefile clean: rm -f $(BINARY_NAME) $(OBJ) $(DEP)
-install: +install: $(BINARY_NAME) mkdir -p $(SBINDIR) install -m 0755 $(BINARY_NAME) $(SBINDIR)
Signed-off-by: Sven Eckelmann sven@narfation.org --- This patch depends on other patches submitted earlier: - batmand: Fix FTBFS on second build attempt - batmand: Remove obsolete creation of source packages - batmand: Remove subversion/svk revision information - batmand: Use nproc to get number of available processors
Makefile | 65 +++++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 37 insertions(+), 28 deletions(-)
diff --git a/Makefile b/Makefile index df2f5b2..a25f3fc 100755 --- a/Makefile +++ b/Makefile @@ -18,24 +18,8 @@ # 02110-1301, USA #
-ifneq ($(findstring $(MAKEFLAGS),s),s) -ifndef V - Q_CC = @echo ' ' CC $@; - Q_LD = @echo ' ' LD $@; - export Q_CC - export Q_LD -endif -endif - -# activate this variable to deactivate policy routing for backward compatibility -#NO_POLICY_ROUTING = -DNO_POLICY_ROUTING - -CC ?= gcc -CFLAGS += -pedantic -Wall -W -std=gnu99 -EXTRA_CFLAGS = -DDEBUG_MALLOC -DMEMORY_USAGE -DPROFILE_DATA $(NO_POLICY_ROUTING) -DREVISION_VERSION=$(REVISION_VERSION) -LDFLAGS += -lpthread - -SBINDIR = $(INSTALL_PREFIX)/usr/sbin +# batmand build +BINARY_NAME = batmand
UNAME = $(shell uname) POSIX_OBJ = posix/init.o posix/posix.o posix/tunnel.o posix/unix_socket.o @@ -64,24 +48,45 @@ OS_OBJ = $(BSD_OBJ) $(POSIX_OBJ) endif
OBJ = batman.o originator.o schedule.o list-batman.o allocate.o bitarray.o hash.o profile.o ring_buffer.o hna.o $(OS_OBJ) -DEP = $(OBJ:.o=.d)
-BINARY_NAME = batmand +# activate this variable to deactivate policy routing for backward compatibility +#NO_POLICY_ROUTING = -DNO_POLICY_ROUTING
-REVISION= $(shell if [ -d .git ]; then \ - echo $$(git describe --always --dirty 2> /dev/null || echo "[unknown]"); \ - fi) +# batmand flags and options +CFLAGS += -pedantic -Wall -W -std=gnu99 +EXTRA_CFLAGS = -DDEBUG_MALLOC -DMEMORY_USAGE -DPROFILE_DATA $(NO_POLICY_ROUTING) -DREVISION_VERSION=$(REVISION_VERSION) +LDFLAGS += -lpthread + +# disable verbose output +ifneq ($(findstring $(MAKEFLAGS),s),s) +ifndef V + Q_CC = @echo ' ' CC $@; + Q_LD = @echo ' ' LD $@; + export Q_CC + export Q_LD +endif +endif + +# standard build tools +CC ?= gcc + +# standard install paths +SBINDIR = $(INSTALL_PREFIX)/usr/sbin + +# try to generate revision +REVISION = $(shell if [ -d .git ]; then echo $$(git describe --always --dirty 2> /dev/null || echo "[unknown]"); fi) REVISION_VERSION ="\ $(REVISION)"
- +# default target all: $(BINARY_NAME)
-$(BINARY_NAME): $(OBJ) Makefile - $(Q_LD)$(CC) -o $@ $(OBJ) $(LDFLAGS) - +# standard build rules +.SUFFIXES: .o .c .c.o: $(Q_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -MD -c $< -o $@ --include $(DEP) + +$(BINARY_NAME): $(OBJ) Makefile + $(Q_LD)$(CC) -o $@ $(OBJ) $(LDFLAGS)
clean: rm -f $(BINARY_NAME) $(OBJ) $(DEP) @@ -90,4 +95,8 @@ install: $(BINARY_NAME) mkdir -p $(SBINDIR) install -m 0755 $(BINARY_NAME) $(SBINDIR)
+# load dependencies +DEP = $(OBJ:.o=.d) +-include $(DEP) + .PHONY: all clean install
User expect a specific naming inside makefile rules which they can modify by changing environment variables or providing them explicitely as parameters of the make call. The naming was extracted from the gnu make standard rules database.
Signed-off-by: Sven Eckelmann sven@narfation.org --- This patch depends on other patches submitted earlier: - batmand: Fix FTBFS on second build attempt - batmand: Remove obsolete creation of source packages - batmand: Remove subversion/svk revision information - batmand: Use nproc to get number of available processors
Makefile | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile index a25f3fc..a0a7f88 100755 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ endif
ifeq ($(UNAME),GNU/kFreeBSD) OS_OBJ = $(BSD_OBJ) $(POSIX_OBJ) -LDFLAGS += -lfreebsd -lbsd +LDLIBS += -lfreebsd -lbsd endif
ifeq ($(UNAME),FreeBSD) @@ -53,9 +53,9 @@ OBJ = batman.o originator.o schedule.o list-batman.o allocate.o bitarray.o hash. #NO_POLICY_ROUTING = -DNO_POLICY_ROUTING
# batmand flags and options -CFLAGS += -pedantic -Wall -W -std=gnu99 -EXTRA_CFLAGS = -DDEBUG_MALLOC -DMEMORY_USAGE -DPROFILE_DATA $(NO_POLICY_ROUTING) -DREVISION_VERSION=$(REVISION_VERSION) -LDFLAGS += -lpthread +CFLAGS += -pedantic -Wall -W -std=gnu99 -MD +CPPFLAGS = -DDEBUG_MALLOC -DMEMORY_USAGE -DPROFILE_DATA $(NO_POLICY_ROUTING) -DREVISION_VERSION=$(REVISION_VERSION) +LDLIBS += -lpthread
# disable verbose output ifneq ($(findstring $(MAKEFLAGS),s),s) @@ -69,6 +69,8 @@ endif
# standard build tools CC ?= gcc +COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c +LINK.o = $(Q_LD)$(CC) $(LDFLAGS) $(TARGET_ARCH)
# standard install paths SBINDIR = $(INSTALL_PREFIX)/usr/sbin @@ -83,10 +85,10 @@ all: $(BINARY_NAME) # standard build rules .SUFFIXES: .o .c .c.o: - $(Q_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -MD -c $< -o $@ + $(COMPILE.c) -o $@ $<
-$(BINARY_NAME): $(OBJ) Makefile - $(Q_LD)$(CC) -o $@ $(OBJ) $(LDFLAGS) +$(BINARY_NAME): $(OBJ) + $(LINK.o) $^ $(LDLIBS) -o $@
clean: rm -f $(BINARY_NAME) $(OBJ) $(DEP)
Signed-off-by: Sven Eckelmann sven@narfation.org --- This patch depends on other patches submitted earlier: - batmand: Fix FTBFS on second build attempt - batmand: Remove obsolete creation of source packages - batmand: Remove subversion/svk revision information - batmand: Use nproc to get number of available processors
Makefile | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile index a0a7f88..6c77fe7 100755 --- a/Makefile +++ b/Makefile @@ -69,6 +69,9 @@ endif
# standard build tools CC ?= gcc +RM ?= rm -f +INSTALL ?= install +MKDIR ?= mkdir -p COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c LINK.o = $(Q_LD)$(CC) $(LDFLAGS) $(TARGET_ARCH)
@@ -91,11 +94,11 @@ $(BINARY_NAME): $(OBJ) $(LINK.o) $^ $(LDLIBS) -o $@
clean: - rm -f $(BINARY_NAME) $(OBJ) $(DEP) + $(RM) $(BINARY_NAME) $(OBJ) $(DEP)
install: $(BINARY_NAME) - mkdir -p $(SBINDIR) - install -m 0755 $(BINARY_NAME) $(SBINDIR) + $(MKDIR) $(SBINDIR) + $(INSTALL) -m 0755 $(BINARY_NAME) $(SBINDIR)
# load dependencies DEP = $(OBJ:.o=.d)
Makefile generators like cmake or configure (generated by autotools) usually use DESTDIR to allow the modification of the "root" path without affecting other build steps.
Signed-off-by: Sven Eckelmann sven@narfation.org --- This patch depends on other patches submitted earlier: - batmand: Fix FTBFS on second build attempt - batmand: Remove obsolete creation of source packages - batmand: Remove subversion/svk revision information - batmand: Use nproc to get number of available processors
Makefile | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile index 6c77fe7..4f64373 100755 --- a/Makefile +++ b/Makefile @@ -76,7 +76,7 @@ COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c LINK.o = $(Q_LD)$(CC) $(LDFLAGS) $(TARGET_ARCH)
# standard install paths -SBINDIR = $(INSTALL_PREFIX)/usr/sbin +SBINDIR = /usr/sbin
# try to generate revision REVISION = $(shell if [ -d .git ]; then echo $$(git describe --always --dirty 2> /dev/null || echo "[unknown]"); fi) @@ -97,8 +97,8 @@ clean: $(RM) $(BINARY_NAME) $(OBJ) $(DEP)
install: $(BINARY_NAME) - $(MKDIR) $(SBINDIR) - $(INSTALL) -m 0755 $(BINARY_NAME) $(SBINDIR) + $(MKDIR) $(DESTDIR)$(SBINDIR) + $(INSTALL) -m 0755 $(BINARY_NAME) $(DESTDIR)$(SBINDIR)
# load dependencies DEP = $(OBJ:.o=.d)
cmake and configure (generated by autotools) use a prefix configuration which is by default /usr/local to define to which all other paths are relative to. SBINDIR is then defined as $PREFIX/sbin but can also be redefined.
Signed-off-by: Sven Eckelmann sven@narfation.org --- This patch depends on other patches submitted earlier: - batmand: Fix FTBFS on second build attempt - batmand: Remove obsolete creation of source packages - batmand: Remove subversion/svk revision information - batmand: Use nproc to get number of available processors
Makefile | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile index 4f64373..21a379c 100755 --- a/Makefile +++ b/Makefile @@ -76,7 +76,8 @@ COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c LINK.o = $(Q_LD)$(CC) $(LDFLAGS) $(TARGET_ARCH)
# standard install paths -SBINDIR = /usr/sbin +PREFIX = /usr/local +SBINDIR = $(PREFIX)/sbin
# try to generate revision REVISION = $(shell if [ -d .git ]; then echo $$(git describe --always --dirty 2> /dev/null || echo "[unknown]"); fi)
Signed-off-by: Sven Eckelmann sven@narfation.org --- This patch depends on other patches submitted earlier: - batmand: Fix FTBFS on second build attempt - batmand: Remove obsolete creation of source packages - batmand: Remove subversion/svk revision information - batmand: Use nproc to get number of available processors
Makefile | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile index 21a379c..4f6fe64 100755 --- a/Makefile +++ b/Makefile @@ -48,6 +48,7 @@ OS_OBJ = $(BSD_OBJ) $(POSIX_OBJ) endif
OBJ = batman.o originator.o schedule.o list-batman.o allocate.o bitarray.o hash.o profile.o ring_buffer.o hna.o $(OS_OBJ) +MANPAGE = man/batmand.8
# activate this variable to deactivate policy routing for backward compatibility #NO_POLICY_ROUTING = -DNO_POLICY_ROUTING @@ -78,6 +79,7 @@ LINK.o = $(Q_LD)$(CC) $(LDFLAGS) $(TARGET_ARCH) # standard install paths PREFIX = /usr/local SBINDIR = $(PREFIX)/sbin +MANDIR = $(PREFIX)/share/man
# try to generate revision REVISION = $(shell if [ -d .git ]; then echo $$(git describe --always --dirty 2> /dev/null || echo "[unknown]"); fi) @@ -99,7 +101,9 @@ clean:
install: $(BINARY_NAME) $(MKDIR) $(DESTDIR)$(SBINDIR) + $(MKDIR) $(DESTDIR)$(MANDIR)/man8 $(INSTALL) -m 0755 $(BINARY_NAME) $(DESTDIR)$(SBINDIR) + $(INSTALL) -m 0644 $(MANPAGE) $(DESTDIR)$(MANDIR)/man8
# load dependencies DEP = $(OBJ:.o=.d)
b.a.t.m.a.n@lists.open-mesh.org