-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
92 lines (78 loc) · 2.07 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#==============================
# Gavin Lyons 12-2023
# Make file to build Fractal Creator Program
# URL:: https://github.com/gavinlyonsrepo/Fractal_creator
# Run make help for options
#==============================
SRC=src/
CC=g++
LDFLAGS= -L /usr/lib/x86_64-linux-gnu
CFLAGS = -std=c++2a -Iinclude/ -c -Wall -Wextra
MD=mkdir
BUILD=Build
SRCS = $(wildcard $(SRC)/*.cpp)
OBJS = $(patsubst $(SRC)/%.cpp, $(BUILD)/%.o, $(SRCS))
BIN=./Bin
EXENAME=fcsim
TARGET=$(BIN)/$(EXENAME)
PREFIX=/usr/local/bin
# The --no-print-directory option of make tells make not to print the message about entering
# and leaving the working directory.
MAKEFLAGS += --no-print-directory
# Main task, makes build directory, updates your objects, builds your executable
.PHONY: all
all: clean build
# Task producing target from built files
$(TARGET): $(OBJS) $(BUILD)
@echo 'MAKE EXE FILE'
$(CXX) $(OBJS) -o $@ $(LDFLAGS)
@echo '[DONE!]'
# Compile all cpp files
$(BUILD)/%.o : $(SRC)/%.cpp $(BUILD)
@echo 'MAKE OBJECT FILE'
$(CXX) $(CFLAGS) $< -o $@
# Build task
.PHONY: build
build:
@echo
@echo '[BUILDING:!]'
@echo $(SRC)
$(MD) -vp $(BIN)
$(MD) -vp $(BUILD)
$(MAKE) $(TARGET)
@echo '***************'
# Run task
.PHONY: run
run:
$(TARGET)
# Clean task :: removes obj and executbale
.PHONY: clean
clean:
@echo
@echo '[CLEANUP!]'
rm -rvf $(BUILD) $(BIN)
@echo '[DONE!]'
# Help task :: explains the options
.PHONY: help
help:
@echo '[HELP!]'
@echo "make - Cleans + builds project"
@echo "make clean - Cleans : Removes object file folder and executable"
@echo "make build - Complies and Builds project"
@echo "make run - Runs exe"
@echo "make install - Installs exe, may need sudo"
@echo "make uninstall - Uninstalls exe, may need sudo"
@echo "make help - Prints help message"
@echo '***************'
#install exe
.PHONY: install
install:
@echo "[INSTALL EXE]"
cp -v $(TARGET) $(PREFIX)/$(EXENAME)
@echo "*****************"
# Uninstall the exe
.PHONY: uninstall
uninstall:
@echo "[UNINSTALL EXE]"
@rm -vf $(PREFIX)/$(EXENAME)
@echo "******************"