mirror of
https://github.com/niellun/FastCarPlay.git
synced 2026-06-07 09:38:25 +02:00
62 lines
1.7 KiB
Makefile
62 lines
1.7 KiB
Makefile
# Compiler
|
|
CXX := g++
|
|
SRC_DIR := ./src
|
|
OUT_DIR := ./out
|
|
RES_DIR := $(SRC_DIR)/resource
|
|
GEN_DIR := $(SRC_DIR)/autogen
|
|
BUILD_DIR := $(OUT_DIR)/$(BUILD_TYPE)
|
|
|
|
# File lists
|
|
SRCS := $(shell find $(SRC_DIR) -type f -name '*.cpp')
|
|
OBJS=$(patsubst $(SRC_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRCS))
|
|
|
|
RES := $(shell find $(RES_DIR) -type f ! -name '*.h' ! -name '.*' -name '*.*')
|
|
RES_SRC := $(patsubst $(RES_DIR)/%,$(GEN_DIR)/%.cpp,$(RES))
|
|
|
|
# Targets
|
|
TARGET_NAME := app
|
|
|
|
# Build types
|
|
.PHONY: all debug release clean build
|
|
|
|
all: debug
|
|
|
|
LDOPTIONS := -lSDL2 -lSDL2_ttf -lavformat -lavcodec -lavutil -lswscale -lusb-1.0 -lssl -lcrypto
|
|
LDFLAGS :=
|
|
CXXCOMMON := -Wall -std=c++17 -Isrc
|
|
|
|
debug: BUILD_TYPE := debug
|
|
debug: CXXFLAGS := -g -O0 -DPROTOCOL_DEBUG -fsanitize=address -fno-omit-frame-pointer
|
|
debug: LDFLAGS += -fsanitize=address -fno-omit-frame-pointer
|
|
debug: TARGET := $(TARGET_NAME)-debug
|
|
debug: prepare
|
|
|
|
release: BUILD_TYPE := release
|
|
release: CXXFLAGS := -O3 -ffast-math -march=native -fno-plt -fno-rtti -flto -fdata-sections -ffunction-sections -DNDEBUG
|
|
release: LDFLAGS += -O3 -ffast-math -march=native -Wl, -flto
|
|
release: TARGET := $(TARGET_NAME)
|
|
release: prepare
|
|
|
|
prepare: $(RES_SRC)
|
|
$(MAKE) BUILD_TYPE=$(BUILD_TYPE) TARGET=$(OUT_DIR)/$(TARGET) CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" build
|
|
|
|
build: $(TARGET)
|
|
|
|
$(GEN_DIR)/%.cpp: $(RES_DIR)/%
|
|
@mkdir -p $(GEN_DIR)
|
|
xxd -i -n $(basename $(notdir $<)) $< > $@
|
|
|
|
$(TARGET): $(OBJS)
|
|
@mkdir -p $(OUT_DIR)
|
|
$(CXX) $(LDFLAGS) $(OBJS) -o $(TARGET) $(LDOPTIONS)
|
|
@echo "Build complete: $(TARGET)"
|
|
|
|
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
|
|
@mkdir -p $(dir $@)
|
|
$(CXX) $(CXXCOMMON) $(CXXFLAGS) -c $< -o $@
|
|
|
|
clean:
|
|
@rm -rf $(OUT_DIR)
|
|
@rm -rf $(GEN_DIR)
|
|
@echo "Clean complete"
|