forked from ImanuelSG/N30-Walaoeh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
77 lines (58 loc) · 2.5 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
# Compiler & linker
CC = g++
# Directory
SOURCE_FOLDER = src/libs
OUTPUT_FOLDER = bin
TEST_FOLDER = unitTest
TEST_OUTPUT_FOLDER = bin/Test
WARNING_CFLAG = -Wall -Wextra -Werror
DEBUG_CFLAG = -fshort-wchar -g
CFLAGS = $(DEBUG_CFLAG) $(WARNING_CFLAG)
EXECUTABLE_FILENAME = Walaoeh
# Find all source files recursively
ALL_SRCS := $(filter-out $(SOURCE_FOLDER)/Toko/Sellable/Bangunan/main.cpp $(SOURCE_FOLDER)/Toko/Sellable/Hewan/main.cpp $(SOURCE_FOLDER)/Toko/Sellable/Tanaman/main.cpp $(SOURCE_FOLDER)/Toko/Sellable/Produk/ProdukHewan/main.cpp ,$(wildcard $(SOURCE_FOLDER)/*/*.cpp $(SOURCE_FOLDER)/*/*/*.cpp $(SOURCE_FOLDER)/*/*/*/*.cpp $(SOURCE_FOLDER)/*/*/*/*/*.cpp $(SOURCE_FOLDER)/pcolor/pcolor.c $(SOURCE_FOLDER)/Pemain/Storage/Storage.hpp))
# Create a list of object files from source files
OBJECTS := $(patsubst $(SOURCE_FOLDER)/%.cpp,$(OUTPUT_FOLDER)/%.o,$(ALL_SRCS))
# Main target to compile all sources and link them
compile: $(OBJECTS)
@echo "Linking object files..."
@$(CC) -std=c++17 -o $(OUTPUT_FOLDER)/$(EXECUTABLE_FILENAME) $(OBJECTS) ./src/main.cpp
@echo "Compilation done."
# Compile each source file into an object file
$(OUTPUT_FOLDER)/%.o: $(SOURCE_FOLDER)/%.cpp
@echo "Compiling $<..."
@mkdir -p $(@D)
@$(CC) -std=c++17 -c -o $@ $<
run:
@./$(OUTPUT_FOLDER)/$(EXECUTABLE_FILENAME)
all: compile run
# For testing purposes
$(TEST_OUTPUT_FOLDER)/%: $(OBJECTS) $(TEST_FOLDER)/%.cpp
@echo "Testing $*..."
@mkdir -p $(TEST_OUTPUT_FOLDER)
@$(CC) -std=c++17 -o $@ $(OBJECTS) $(TEST_FOLDER)/$*.cpp
testBangunan: $(TEST_OUTPUT_FOLDER)/testBangunan
@./$(TEST_OUTPUT_FOLDER)/testBangunan
testProdukHewan: $(TEST_OUTPUT_FOLDER)/testProdukHewan
@./$(TEST_OUTPUT_FOLDER)/testProdukHewan
testHewan: $(TEST_OUTPUT_FOLDER)/testHewan
@./$(TEST_OUTPUT_FOLDER)/testHewan
testParser: $(TEST_OUTPUT_FOLDER)/testParser
@./$(TEST_OUTPUT_FOLDER)/testParser
testTanaman: $(TEST_OUTPUT_FOLDER)/testTanaman
@./$(TEST_OUTPUT_FOLDER)/testTanaman
testStorage: $(TEST_OUTPUT_FOLDER)/testStorage
@./$(TEST_OUTPUT_FOLDER)/testStorage
testPemain: $(TEST_OUTPUT_FOLDER)/testPemain
@./$(TEST_OUTPUT_FOLDER)/testPemain
testPetani: $(TEST_OUTPUT_FOLDER)/testPetani
@./$(TEST_OUTPUT_FOLDER)/testPetani
testGameWorld: $(TEST_OUTPUT_FOLDER)/testGameWorld
@./$(TEST_OUTPUT_FOLDER)/testGameWorld
testToko: $(TEST_OUTPUT_FOLDER)/testToko
@./$(TEST_OUTPUT_FOLDER)/testToko
testPeternak: $(TEST_OUTPUT_FOLDER)/testPeternak
@./$(TEST_OUTPUT_FOLDER)/testPeternak
clean:
@rm -rf $(OUTPUT_FOLDER)/*
@echo "Clean done."