Simplified Makefiles output notation.
This commit is contained in:
parent
c89ea61fa3
commit
fe9020b9b7
8
Makefile
8
Makefile
|
|
@ -4,13 +4,13 @@ SHELL = /usr/bin/env bash
|
||||||
BUILD_DIR = build
|
BUILD_DIR = build
|
||||||
|
|
||||||
# Source output target name
|
# Source output target name
|
||||||
SOURCE_OUTPUT := 2D_Engine
|
SOURCE_OUTPUT := $(BUILD_DIR)/2D_Engine
|
||||||
|
|
||||||
# Core output target name
|
# Core output target name
|
||||||
CORE_OUTPUT := libcore.a
|
CORE_OUTPUT := $(BUILD_DIR)/libcore.a
|
||||||
|
|
||||||
# Assets output
|
# Assets output
|
||||||
ASSET_OUTPUT := game.data
|
ASSET_OUTPUT := $(BUILD_DIR)/game.data
|
||||||
|
|
||||||
# Verbosity
|
# Verbosity
|
||||||
Q := @
|
Q := @
|
||||||
|
|
@ -44,4 +44,4 @@ clean:
|
||||||
# Run executable
|
# Run executable
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run: all
|
run: all
|
||||||
$(Q)./$(BUILD_DIR)/$(SOURCE_OUTPUT)
|
$(Q)./$(SOURCE_OUTPUT)
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,17 @@ ASSETS := $(ASSETS:%=$(ASSETS_DIR)/%)
|
||||||
|
|
||||||
ASSET_BUILDER_DIR = $(ASSETS_DIR)/asset_builder/src
|
ASSET_BUILDER_DIR = $(ASSETS_DIR)/asset_builder/src
|
||||||
|
|
||||||
ASSET_BUILDER_OUTPUT = asset_builder
|
ASSET_BUILDER_OUTPUT = $(BUILD_DIR)/$(ASSETS_DIR)/asset_builder/asset_builder
|
||||||
|
|
||||||
build_assets: setup_asset asset_end
|
build_assets: setup_asset build_asset_builder asset_end
|
||||||
|
|
||||||
include $(ASSET_BUILDER_DIR)/Makefile
|
include $(ASSET_BUILDER_DIR)/Makefile
|
||||||
|
|
||||||
setup_asset:
|
setup_asset:
|
||||||
@echo "Building $(ASSET_OUTPUT)"
|
@echo "Building $(notdir $(ASSET_OUTPUT))"
|
||||||
$(Q)mkdir -p $(dir $(ASSETS))
|
|
||||||
|
|
||||||
$(BUILD_DIR)/$(ASSET_OUTPUT): build_asset_builder
|
$(ASSET_OUTPUT): $(ASSET_BUILDER_OUTPUT)
|
||||||
$(Q)$(BUILD_DIR)/$(ASSET_BUILDER_DIR)/$(ASSET_BUILDER_OUTPUT) $@ $(ASSETS)
|
$(Q)$^ $@ $(ASSETS)
|
||||||
|
|
||||||
asset_end: $(BUILD_DIR)/$(ASSET_OUTPUT)
|
asset_end: $(ASSET_OUTPUT)
|
||||||
@echo "Built target $(ASSET_OUTPUT)"
|
@echo "Built target $(notdir $(ASSET_OUTPUT))"
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ build_asset_builder: asset_builder_setup count_asset_builder_build asset_builder
|
||||||
|
|
||||||
# Source build directories
|
# Source build directories
|
||||||
asset_builder_setup:
|
asset_builder_setup:
|
||||||
@echo "Building Asset Builder"
|
@echo "Building $(notdir $(ASSET_BUILDER_OUTPUT))"
|
||||||
$(Q)mkdir -p $(dir $(ASSET_BUILDER_OBJECTS))
|
$(Q)mkdir -p $(dir $(ASSET_BUILDER_OBJECTS))
|
||||||
|
|
||||||
# Count nb of files to build
|
# Count nb of files to build
|
||||||
|
|
@ -37,7 +37,7 @@ count_asset_builder_build:
|
||||||
$(eval export TOTAL_ASSET_BUILDER_FILES := $(shell echo $$(($$(make -n $(ASSET_BUILDER_OBJECTS) 2>/dev/null | grep -c "Building") + 1))))
|
$(eval export TOTAL_ASSET_BUILDER_FILES := $(shell echo $$(($$(make -n $(ASSET_BUILDER_OBJECTS) 2>/dev/null | grep -c "Building") + 1))))
|
||||||
|
|
||||||
# Link asset builder target
|
# Link asset builder target
|
||||||
$(BUILD_DIR)/$(ASSET_BUILDER_DIR)/$(ASSET_BUILDER_OUTPUT): $(ASSET_BUILDER_OBJECTS)
|
$(ASSET_BUILDER_OUTPUT): $(ASSET_BUILDER_OBJECTS)
|
||||||
@echo -e "[100%] $(YELLOW)Linking $(ASSET_BUILDER_OUTPUT)$(RESET)"
|
@echo -e "[100%] $(YELLOW)Linking $(ASSET_BUILDER_OUTPUT)$(RESET)"
|
||||||
$(Q)$(SRC_CC) $(ASSET_BUILDER_OBJECTS) -o $@ $(ASSET_BUILDER_LDFLAGS)
|
$(Q)$(SRC_CC) $(ASSET_BUILDER_OBJECTS) -o $@ $(ASSET_BUILDER_LDFLAGS)
|
||||||
|
|
||||||
|
|
@ -49,8 +49,8 @@ $(BUILD_DIR)/$(ASSET_BUILDER_DIR)/%.o: $(ASSET_BUILDER_DIR)/%.c
|
||||||
$(Q)$(SRC_CC) $(SRC_CFLAGS) $(ASSET_BUILDER_INCLUDE_DIRS:%=-I%) -MMD -MP -c $< -o $@
|
$(Q)$(SRC_CC) $(SRC_CFLAGS) $(ASSET_BUILDER_INCLUDE_DIRS:%=-I%) -MMD -MP -c $< -o $@
|
||||||
|
|
||||||
# Print ending message
|
# Print ending message
|
||||||
asset_builder_end: $(BUILD_DIR)/$(ASSET_BUILDER_DIR)/$(ASSET_BUILDER_OUTPUT)
|
asset_builder_end: $(ASSET_BUILDER_OUTPUT)
|
||||||
@echo "Built target $(ASSET_BUILDER_OUTPUT)"
|
@echo "Built target $(notdir $(ASSET_BUILDER_OUTPUT))"
|
||||||
|
|
||||||
# Source files dependencies
|
# Source files dependencies
|
||||||
-include $(ASSET_BUILDER_OBJECTS:.o=.d)
|
-include $(ASSET_BUILDER_OBJECTS:.o=.d)
|
||||||
|
|
|
||||||
10
src/Makefile
10
src/Makefile
|
|
@ -34,7 +34,7 @@ build_src: src_setup count_src_build src_end
|
||||||
|
|
||||||
# Source build directories
|
# Source build directories
|
||||||
src_setup:
|
src_setup:
|
||||||
@echo "Building Source"
|
@echo "Building $(notdir $(SOURCE_OUTPUT))"
|
||||||
$(Q)mkdir -p $(dir $(SOURCE_OBJECTS))
|
$(Q)mkdir -p $(dir $(SOURCE_OBJECTS))
|
||||||
|
|
||||||
# Count nb of files to build
|
# Count nb of files to build
|
||||||
|
|
@ -42,9 +42,9 @@ count_src_build:
|
||||||
$(eval export TOTAL_SRC_FILES := $(shell echo $$(($$(make -n $(SOURCE_OBJECTS) 2>/dev/null | grep -c "Building") + 1))))
|
$(eval export TOTAL_SRC_FILES := $(shell echo $$(($$(make -n $(SOURCE_OBJECTS) 2>/dev/null | grep -c "Building") + 1))))
|
||||||
|
|
||||||
# Link game target
|
# Link game target
|
||||||
$(BUILD_DIR)/$(SOURCE_OUTPUT): $(SOURCE_OBJECTS) $(BUILD_DIR)/$(CORE_OUTPUT)
|
$(SOURCE_OUTPUT): $(SOURCE_OBJECTS) $(CORE_OUTPUT)
|
||||||
@echo -e "[100%] $(YELLOW)Linking $(SOURCE_OUTPUT)$(RESET)"
|
@echo -e "[100%] $(YELLOW)Linking $(SOURCE_OUTPUT)$(RESET)"
|
||||||
$(Q)$(SRC_CC) $(SOURCE_OBJECTS) -L./$(BUILD_DIR) $(BUILD_DIR)/$(CORE_OUTPUT) $(CORE_DEPS_FLAGS) -o $@ $(SRC_LDFLAGS)
|
$(Q)$(SRC_CC) $(SOURCE_OBJECTS) -L./$(BUILD_DIR) $(CORE_OUTPUT) $(CORE_DEPS_FLAGS) -o $@ $(SRC_LDFLAGS)
|
||||||
|
|
||||||
# Build .o files
|
# Build .o files
|
||||||
$(BUILD_DIR)/$(SOURCE_DIR)/%.o: $(SOURCE_DIR)/%.c
|
$(BUILD_DIR)/$(SOURCE_DIR)/%.o: $(SOURCE_DIR)/%.c
|
||||||
|
|
@ -54,8 +54,8 @@ $(BUILD_DIR)/$(SOURCE_DIR)/%.o: $(SOURCE_DIR)/%.c
|
||||||
$(Q)$(SRC_CC) $(SRC_CFLAGS) $(SRC_INCLUDE_DIRS:%=-I%) -MMD -MP -c $< -o $@
|
$(Q)$(SRC_CC) $(SRC_CFLAGS) $(SRC_INCLUDE_DIRS:%=-I%) -MMD -MP -c $< -o $@
|
||||||
|
|
||||||
# Print ending message
|
# Print ending message
|
||||||
src_end: $(BUILD_DIR)/$(SOURCE_OUTPUT)
|
src_end: $(SOURCE_OUTPUT)
|
||||||
@echo "Built target $(SOURCE_OUTPUT)"
|
@echo "Built target $(notdir $(SOURCE_OUTPUT))"
|
||||||
|
|
||||||
# Source files dependencies
|
# Source files dependencies
|
||||||
-include $(SOURCE_OBJECTS:.o=.d)
|
-include $(SOURCE_OBJECTS:.o=.d)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue