Compare commits

..

2 Commits

1 changed files with 54 additions and 14 deletions

View File

@ -1,25 +1,65 @@
# Compiler flags # Build folder
CFLAGS = -std=c++17 -O3 BUILD_DIR = build
# Defaul target # Source files
all: build_dir json2bin_converter SOURCES = \
src/main.cpp \
src/bin.cpp
# Output file name
OUTPUT = 2D_Engine_Casio_Tool
# Compiler and flags
CXX = g++
CXXFLAGS = -std=c++17 -g
LDFLAGS =
# Deduce objects
OBJECTS = $(SOURCES:%.cpp=$(BUILD_DIR)/%.o)
# Verbose mode
ifeq ($(VERBOSE), 1)
Q :=
else
Q := @
endif
# Colors
GREEN := \033[0;32m
YELLOW := \033[1;33m
RESET := \033[0m
# Total number of files to process
TOTAL_FILES := $(shell echo $$(($(words $(SOURCES))+1)))
CURRENT_FILE = 0
# Default targets
all: $(BUILD_DIR) $(OUTPUT) end
# Create build directory # Create build directory
build_dir: $(BUILD_DIR):
mkdir -p build $(Q)mkdir -p $(dir $(OBJECTS))
# Link target # Link target
json2bin_converter: build/main.o build/bin.o $(OUTPUT): $(OBJECTS)
g++ -o json2bin_converter build/main.o build/bin.o @echo "[100%] $(YELLOW)Linking $(OUTPUT)$(RESET)"
$(Q)$(CXX) $(LDFLAGS) -o $@ $(OBJECTS)
# Compile objects # Build .o files from .cpp
build/main.o: src/main.cpp src/bin.hpp src/json/json.hpp $(BUILD_DIR)/%.o: %.cpp
g++ $(CFLAGS) -c src/main.cpp -o build/main.o $(eval CURRENT_FILE := $(shell echo $$(($(CURRENT_FILE)+1))))
$(eval PERCENTAGE := $(shell echo $$(($(CURRENT_FILE)*100/$(TOTAL_FILES)))))
@echo "[$(PERCENTAGE)%] $(GREEN)Building $@$(RESET)"
$(Q)mkdir -p $(dir $@)
$(Q)$(CXX) $(CXXFLAGS) -MMD -MP -c $< -o $@
build/bin.o: src/bin.cpp src/bin.hpp src/json/json.hpp # Source files dependencies
g++ $(CFLAGS) -c src/bin.cpp -o build/bin.o -include $(OBJECTS:.o=.d)
end:
@echo "Built target $(OUTPUT)"
# Clean # Clean
.PHONY: clean .PHONY: clean
clean: clean:
rm -rf build/* json2bin_converter $(Q)rm -rf $(BUILD_DIR)