From da08171e0c65e278feeb8393b5a8f7e79ea491c9 Mon Sep 17 00:00:00 2001 From: B Stack Date: Sun, 25 Aug 2019 23:04:24 -0400 Subject: at page 3.6 Improved the makefile for multifile project, including header files. --- Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 8a2f666..15de4d0 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +# references: +# BUILD_DIR and per-.cpp file https://spin.atomicobject.com/2016/08/26/makefile-c-projects/ awkbin :=$(shell which awk) cpbin :=$(shell which cp) echobin :=$(shell which echo) @@ -20,13 +22,15 @@ LDFLAGS = -g src = $(wildcard *.cpp) obj = $(src:.cpp=.o) -OUTEXE = helloworld +BUILD_DIR ?= . + +OUTEXE = mine all: $(OUTEXE) -# compile -$(obj): $(src) - $(CXX) -c $(CXXFLAGS) $< +# compile, which is not actually used? +$(BUILD_DIR)%.o: %.cpp + $(CXX) -c $(CXXFLAGS) $+ # link $(OUTEXE): $(obj) -- cgit