-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile
45 lines (35 loc) · 883 Bytes
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#OS Stuff
ifeq ($(OS),Windows_NT)
RM = del /Q /F
CP = copy /Y
ifdef ComSpec
SHELL := $(ComSpec)
endif
ifdef COMSPEC
SHELL := $(COMSPEC)
endif
else
RM = rm -rf
CP = cp -f
endif
#<------
#list all your programs/test exe output files here
#This makefile assumes that each executable corresponds to a
#*.cpp file with the same name, eg main.cpp -> main
#once you add a program that includes "Cubert.hpp", add it
# to the programs list separated by a space
programs = main test
#auto find correspeonding .cpp and .o files
cpp_files = $(programs:=.cpp) Cubert.cpp
o_files=$(programs:=.o) Cubert.o
#If you're on windows, it might add a .exe against your will
exe_files=$(programs:=.exe)
all: $(programs)
run: main
./main
.PHONY: clean
.SECONDARY: $(o_files)
%: %.o Cubert.o
g++ $(LDFLAGS) $+ $(LOADLIBES) $(LDLIBS) -o $@
clean:
-$(RM) $(o_files) $(programs) $(exe_files) -f