From 0eb7349cad9804117243da47c229a895046b7c1c Mon Sep 17 00:00:00 2001 From: Alexander Koch Date: Thu, 16 Jun 2016 20:14:52 +0200 Subject: [PATCH 1/2] Improve makefile - Define PHONY targets - Set optimization level O2 - Move C++ standard flag to CFLAGS - Remove superfluous targets --- makefile | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/makefile b/makefile index b82510e..a205390 100644 --- a/makefile +++ b/makefile @@ -1,18 +1,17 @@ CC=g++ -CFLAGS= -LDFLAGS=-std=gnu++11 -lusb-1.0 +CFLAGS=-Wall -O2 -std=gnu++11 +LDFLAGS=-lusb-1.0 +PROGN=g810-led -all: make bin/g810-led +.PHONY: all clean -make: - rm -rf bin - mkdir bin +all: bin/$(PROGN) -bin/g810-led: src/main.cpp src/classes/* - $(CC) -o $@ $^ $(LDFLAGS) + +bin/$(PROGN): src/main.cpp src/classes/*.cpp + @mkdir -p bin + $(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS) clean: - rm -rf *.o + rm -rf bin -mrproper: clean - rm -rf $(EXEC) From 31ad202d59c116058a465fb6baaf2ae761fc0ae2 Mon Sep 17 00:00:00 2001 From: Alexander Koch Date: Thu, 16 Jun 2016 20:20:28 +0200 Subject: [PATCH 2/2] makefile: Add debug build target Add phony target to provide debugging symbols in binary. Usable via 'make debug'. --- makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/makefile b/makefile index a205390..6a24c9b 100644 --- a/makefile +++ b/makefile @@ -3,15 +3,17 @@ CFLAGS=-Wall -O2 -std=gnu++11 LDFLAGS=-lusb-1.0 PROGN=g810-led -.PHONY: all clean +.PHONY: all debug clean all: bin/$(PROGN) - bin/$(PROGN): src/main.cpp src/classes/*.cpp @mkdir -p bin $(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS) +debug: CFLAGS += -g +debug: bin/$(PROGN) + clean: rm -rf bin