[09/13] vis: Reorder Makefile for better readability

Message ID 1305985517-3763-9-git-send-email-sven@narfation.org (mailing list archive)
State Accepted, archived
Commit af2e7bac96c304e9942563c3534e6af242f18647
Headers

Commit Message

Sven Eckelmann May 21, 2011, 1:45 p.m. UTC
  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(-)
  

Patch

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