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: - vis: Remove obsolete creation of source packages - vis: Remove subversion/svk revision information
Makefile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile index c808391..6867a5f 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ endif endif
CC = gcc -CFLAGS += -pedantic -Wall -W -O1 -g3 -std=gnu99 +CFLAGS += -pedantic -Wall -W -std=gnu99 EXTRA_CFLAGS = -DDEBUG_MALLOC -DMEMORY_USAGE -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: - vis: Remove obsolete creation of source packages - vis: Remove subversion/svk revision information
Makefile | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile index 6867a5f..b3a7963 100644 --- a/Makefile +++ b/Makefile @@ -49,11 +49,7 @@ REVISION= $(shell if [ -d .git ]; then \ fi) REVISION_VERSION="\ $(REVISION)"
-NUM_CPUS = $(shell NUM_CPUS=`cat /proc/cpuinfo | grep -v 'model name' | grep processor | tail -1 | awk -F' ' '{print $$3}'`;echo `expr $$NUM_CPUS + 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: - vis: Remove obsolete creation of source packages - vis: Remove subversion/svk revision information
Makefile | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile index b3a7963..f7bcef9 100644 --- a/Makefile +++ b/Makefile @@ -32,17 +32,11 @@ LDFLAGS += -lpthread
SBINDIR = $(INSTALL_PREFIX)/usr/sbin
-LOG_BRANCH= trunk/vis - -SRC_FILES= "(.c)|(.h)|(Makefile)|(INSTALL)|(LIESMICH)|(README)|(THANKS)|(TRASH)|(Doxyfile)|(./posix)|(./linux)|(./bsd)|(./man)|(./doc)" - SRC_C= allocate.c hash.c list-batman.c vis.c udp_server.c SRC_H= allocate.h hash.h list-batman.h vis.h vis-types.h SRC_O= $(SRC_C:.c=.o)
-PACKAGE_NAME= vis BINARY_NAME= vis -SOURCE_VERSION_HEADER= vis.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: - vis: Remove obsolete creation of source packages - vis: Remove subversion/svk revision information
Makefile | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile index f7bcef9..a18aa72 100644 --- a/Makefile +++ b/Makefile @@ -32,9 +32,8 @@ LDFLAGS += -lpthread
SBINDIR = $(INSTALL_PREFIX)/usr/sbin
-SRC_C= allocate.c hash.c list-batman.c vis.c udp_server.c -SRC_H= allocate.h hash.h list-batman.h vis.h vis-types.h -SRC_O= $(SRC_C:.c=.o) +OBJ = allocate.o hash.o list-batman.o vis.o udp_server.o +DEP = $(OBJ:.o=.d)
BINARY_NAME= vis
@@ -45,16 +44,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 - rm -f `find . -name '*.d' -print` + 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: - vis: Remove obsolete creation of source packages - vis: Remove subversion/svk revision information
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 a18aa72..d9b011c --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +#!/usr/bin/make -f +# -*- makefile -*- # # Copyright (C) 2006-2009 BATMAN 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: - vis: Remove obsolete creation of source packages - vis: Remove subversion/svk revision information
Makefile | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile index d9b011c..5cbff33 100755 --- a/Makefile +++ b/Makefile @@ -59,3 +59,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: - vis: Remove obsolete creation of source packages - vis: Remove subversion/svk revision information
Makefile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile index 5cbff33..2817292 100755 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ ifndef V endif endif
-CC = gcc +CC ?= gcc CFLAGS += -pedantic -Wall -W -std=gnu99 EXTRA_CFLAGS = -DDEBUG_MALLOC -DMEMORY_USAGE -DREVISION_VERSION=$(REVISION_VERSION) LDFLAGS += -lpthread
Signed-off-by: Sven Eckelmann sven@narfation.org --- This patch depends on other patches submitted earlier: - vis: Remove obsolete creation of source packages - vis: Remove subversion/svk revision information
Makefile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile index 2817292..75d59cc 100755 --- a/Makefile +++ b/Makefile @@ -56,7 +56,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: - vis: Remove obsolete creation of source packages - vis: Remove subversion/svk revision information
Makefile | 39 ++++++++++++++++++++++++--------------- 1 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/Makefile b/Makefile index 75d59cc..da966ac 100755 --- a/Makefile +++ b/Makefile @@ -18,6 +18,16 @@ # 02110-1301, USA #
+# vis build +BINARY_NAME= vis +OBJ = allocate.o hash.o list-batman.o vis.o udp_server.o + +# vis flags and options +CFLAGS += -pedantic -Wall -W -std=gnu99 +EXTRA_CFLAGS = -DDEBUG_MALLOC -DMEMORY_USAGE -DREVISION_VERSION=$(REVISION_VERSION) +LDFLAGS += -lpthread + +# disable verbose output ifneq ($(findstring $(MAKEFLAGS),s),s) ifndef V Q_CC = @echo ' ' CC $@; @@ -27,31 +37,26 @@ ifndef V endif endif
+# standard build tools CC ?= gcc -CFLAGS += -pedantic -Wall -W -std=gnu99 -EXTRA_CFLAGS = -DDEBUG_MALLOC -DMEMORY_USAGE -DREVISION_VERSION=$(REVISION_VERSION) -LDFLAGS += -lpthread
+# standard install paths SBINDIR = $(INSTALL_PREFIX)/usr/sbin
-OBJ = allocate.o hash.o list-batman.o vis.o udp_server.o -DEP = $(OBJ:.o=.d) - -BINARY_NAME= vis - -REVISION= $(shell if [ -d .git ]; then \ - echo $$(git describe --always --dirty 2> /dev/null || echo "[unknown]"); \ - fi) +# 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) @@ -60,4 +65,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: - vis: Remove obsolete creation of source packages - vis: Remove subversion/svk revision information
Makefile | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile index da966ac..b34d2e8 100755 --- a/Makefile +++ b/Makefile @@ -23,9 +23,9 @@ BINARY_NAME= vis OBJ = allocate.o hash.o list-batman.o vis.o udp_server.o
# vis flags and options -CFLAGS += -pedantic -Wall -W -std=gnu99 -EXTRA_CFLAGS = -DDEBUG_MALLOC -DMEMORY_USAGE -DREVISION_VERSION=$(REVISION_VERSION) -LDFLAGS += -lpthread +CFLAGS += -pedantic -Wall -W -std=gnu99 -MD +CPPFLAGS += -DDEBUG_MALLOC -DMEMORY_USAGE -DREVISION_VERSION=$(REVISION_VERSION) +LDLIBS += -lpthread
# disable verbose output ifneq ($(findstring $(MAKEFLAGS),s),s) @@ -39,6 +39,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 @@ -53,10 +55,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: - vis: Remove obsolete creation of source packages - vis: Remove subversion/svk revision information
Makefile | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile index b34d2e8..bd20b1c 100755 --- a/Makefile +++ b/Makefile @@ -39,6 +39,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)
@@ -61,11 +64,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: - vis: Remove obsolete creation of source packages - vis: Remove subversion/svk revision information
Makefile | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile index bd20b1c..2ecf090 100755 --- a/Makefile +++ b/Makefile @@ -46,7 +46,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) @@ -67,8 +67,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: - vis: Remove obsolete creation of source packages - vis: Remove subversion/svk revision information
Makefile | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile index 2ecf090..745b6e3 100755 --- a/Makefile +++ b/Makefile @@ -46,7 +46,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)
b.a.t.m.a.n@lists.open-mesh.org