-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (47 loc) · 1.63 KB
/
Makefile
File metadata and controls
62 lines (47 loc) · 1.63 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# the name of your executable
TARGET = Shaper.out
# launches your target in terminal
RUN = ./$(TARGET)
# directory for your source files
SRC_DIR = src
# directory for your object files
BUILD_DIR = bin
# add more CompilerFLAGS as your project requires
CFLAGS = -Wall -Wextra -O3
# add libraries for your project here
LDFLAGS =
# add library linker commands here (start with -l)
LOADLIBS = -lm -lSDL2 -ldl
# add library search paths here (start with -L)
LDLIBS =
# add include paths (start with -I)
INC =
# finds all your objects that corrispond to your .cpp files, system agnostic version
OBJECTS := $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(wildcard $(SRC_DIR)/*.c))
.PHONY: all
# makes build directory, updates your objects, builds your executable
all:
mkdir -p $(BUILD_DIR)
+$(MAKE) $(TARGET)
# updates your objects, builds your executable
$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) $(CFLAGS) -o $@ $(LOADLIBS) $(LDFLAGS) $(LDLIBS) $(INC)
# builds your objects
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@ $(LOADLIBS) $(LDFLAGS) $(LDLIBS) $(INC)
# deletes your built objects and executable
.PHONY: clean
clean:
-rm -rf $(BUILD_DIR) $(TARGET)
clear
# makes build direcotry, updates your objects, builds your executable, launches your program
.PHONY: run
run:
+$(MAKE) all
$(RUN)
# explains the only three options you should be using (unless you build more of your own)
.PHONY: help
help:
@echo "`make` - builds/updates everything, is ready to run with `$(RUN)` after completion"
@echo "`make clean` - removes object file folder and executable"
@echo "`make run` - builds/updates everything, runs immediately"