summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2019-08-25 23:04:24 -0400
committerB Stack <bgstack15@gmail.com>2019-08-25 23:04:24 -0400
commitda08171e0c65e278feeb8393b5a8f7e79ea491c9 (patch)
tree728fd5de284626349bc9e9f5f48f30a83e0efc10 /Makefile
parentinitial commit (diff)
downloadcpp-master.tar.gz
cpp-master.tar.bz2
cpp-master.zip
at page 3.6HEADmaster
Improved the makefile for multifile project, including header files.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile12
1 files changed, 8 insertions, 4 deletions
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)
bgstack15