Skip to content

Commit

Permalink
Added new menuconfig target to build system (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
iWas-Coder committed May 22, 2024
1 parent 5159998 commit ec8a111
Showing 1 changed file with 54 additions and 10 deletions.
64 changes: 54 additions & 10 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
##################
# === MACROS === #
##################
MCONF_NAME = mconf
LAUNCHER_NAME = sk_launcher
GAME_NAME = sparky
TEST_ENGINE_NAME = carbon
Expand Down Expand Up @@ -65,6 +66,7 @@ CHECKDEPS_TYPES = uint8_t int8_t uint16_t int16_t uint32_t int32_t uint64_t int6
HDR_DIR = include
SRC_DIR = src
TEST_DIR = test
TOOLS_DIR = tools
BUILD_ROOT_DIR = build
BUILD_DEBUG_DIR = $(BUILD_ROOT_DIR)/debug
BUILD_RELEASE_DIR = $(BUILD_ROOT_DIR)/release
Expand All @@ -77,6 +79,7 @@ else
BUILD_DIR = $(BUILD_RELEASE_DIR)
endif
TEST_BUILD_DIR = $(BUILD_DIR)/$(TEST_DIR)
MCONF_BUILD_DIR = $(BUILD_DIR)/$(MCONF_NAME)
VENDOR_DIR = vendor
RAYLIB_SRC_DIR = $(VENDOR_DIR)/raylib/$(SRC_DIR)
RAYLIB_BUILD_DIR = $(BUILD_DIR)/raylib
Expand All @@ -95,6 +98,8 @@ TEST_SRCS := $(wildcard $(TEST_DIR)/$(SRC_DIR)/*.c)
TEST_OBJS := $(patsubst $(TEST_DIR)/$(SRC_DIR)/%.c, $(TEST_BUILD_DIR)/%.o, $(TEST_SRCS))
TEST_DEPS_OBJS := $(filter-out $(BUILD_DIR)/$(GAME_NAME).o, $(OBJS))
EDITOR_SRCS := $(wildcard $(SRC_DIR)/$(EDITOR_NAME)*.rs)
MCONF_SRCS := $(wildcard $(TOOLS_DIR)/$(MCONF_NAME)/$(SRC_DIR)/*.c)
MCONF_OBJS := $(patsubst $(TOOLS_DIR)/$(MCONF_NAME)/$(SRC_DIR)/%.c, $(MCONF_BUILD_DIR)/%.o, $(MCONF_SRCS))

# Build flags
MAKEFLAGS_JOBS := $(patsubst -j%, %, $(filter -j%, $(MAKEFLAGS)))
Expand Down Expand Up @@ -165,6 +170,10 @@ define TEST_CPPFLAGS
-I $(HDR_DIR) \
-I $(TEST_DIR)/$(HDR_DIR)
endef
define MCONF_CPPFLAGS
$(DISABLE_ASSERTS_OPTS) \
-I $(TOOLS_DIR)/$(MCONF_NAME)/$(HDR_DIR)
endef
define RAYLIB_CFLAGS
-std=gnu99 \
$(HIDE_WARNS_OPTS) \
Expand Down Expand Up @@ -201,6 +210,16 @@ define TEST_CFLAGS
$(RELEASE_OPTS) \
$(MACOS_SPECIFIC_CFLAGS_OPTS)
endef
define MCONF_CFLAGS
-std=c99 \
-Wall \
-Wextra \
-pedantic \
-Werror \
$(DEBUG_SYM_OPTS) \
$(RELEASE_OPTS) \
$(MACOS_SPECIFIC_CFLAGS_OPTS)
endef
define LDFLAGS
$(BUILDID_OPTS) \
$(STRIP_OPTS) \
Expand All @@ -227,6 +246,12 @@ define TEST_LDFLAGS
-llua \
-lm
endef
define MCONF_LDFLAGS
$(BUILDID_OPTS) \
$(STRIP_OPTS) \
$(RELEASE_OPTS) \
-ldialog
endef

# Build output
LAUNCHER_OUT = $(EXTRAS_BUILD_DIR)/lib$(LAUNCHER_NAME).a
Expand All @@ -239,13 +264,14 @@ else
endif
TEST_OUT = $(TEST_BUILD_DIR)/$(TEST_ENGINE_NAME)
EDITOR_OUT = $(EXTRAS_BUILD_DIR)/$(EDITOR_NAME)
MCONF_OUT = $(MCONF_BUILD_DIR)/$(MCONF_NAME)


###################
# === TARGETS === #
###################
.WAIT:
.PHONY: all checkdeps game check editor clean mrproper version help
.PHONY: all checkdeps menuconfig game check editor clean mrproper version help

all: checkdeps .WAIT $(BUILD_DIR) $(RAYLIB_BUILD_DIR) $(LUA_BUILD_DIR) game
@:
Expand Down Expand Up @@ -292,6 +318,22 @@ $(TEST_BUILD_DIR):
@echo " $(PPO_MKDIR) $@"
$(Q)mkdir -p $@

$(MCONF_BUILD_DIR):
@echo " $(PPO_MKDIR) $@"
$(Q)mkdir -p $@

menuconfig: checkdeps .WAIT $(BUILD_DIR) $(MCONF_BUILD_DIR) $(MCONF_OUT)
@printf "INFO: \033[1;35m$(MCONF_OUT) is ready ($(FULL_VERSION))\033[0m\n"
$(Q)./$(MCONF_OUT)

$(MCONF_OUT): $(MCONF_OBJS)
@echo " $(PPO_HOSTLD) $@"
$(Q)$(CC) $^ $(MCONF_LDFLAGS) -o $@

$(MCONF_BUILD_DIR)/%.o: $(TOOLS_DIR)/$(MCONF_NAME)/$(SRC_DIR)/%.c
@echo " $(PPO_HOSTCC) $@"
$(Q)$(CC) $(MCONF_CPPFLAGS) $(MCONF_CFLAGS) -c -MD $< -o $@

game: $(OUT)
@printf "INFO: \033[1;35m$(OUT) is ready ($(FULL_VERSION))\033[0m\n"

Expand Down Expand Up @@ -355,6 +397,7 @@ $(EDITOR_OUT): $(EDITOR_SRCS)
-include $(BUILD_DIR)/*.d
-include $(LUA_BUILD_DIR)/*.d
-include $(TEST_BUILD_DIR)/*.d
-include $(MCONF_BUILD_DIR)/*.d
-include $(RAYLIB_BUILD_DIR)/*.d
-include $(EXTRAS_BUILD_DIR)/*.d

Expand Down Expand Up @@ -384,15 +427,16 @@ version:
help:
@echo "Targets"
@echo "======="
@echo " all :: Build all targets marked with [*]"
@echo "* checkdeps :: Check dependencies for build process"
@echo "* game :: Build the bare game"
@echo " check :: Build and run the test engine"
@echo " editor :: Build the editor"
@echo " clean :: Remove the 'build' directory"
@echo " mrproper :: Remove and cleans everything"
@echo " version :: Show the current version string"
@echo " help :: Show this help and usage panel"
@echo " all :: Build all targets marked with [*]"
@echo "* checkdeps :: Check dependencies for build process"
@echo " menuconfig :: Edit build options with ncurses menu"
@echo "* game :: Build the bare game"
@echo " check :: Build and run the test engine"
@echo " editor :: Build the editor"
@echo " clean :: Remove the 'build' directory"
@echo " mrproper :: Remove and cleans everything"
@echo " version :: Show the current version string"
@echo " help :: Show this help and usage panel"
@echo
@echo "Execute 'make' or 'make all' to build all targets marked with [*]"
@echo "For further info see the ./README.org file"

0 comments on commit ec8a111

Please sign in to comment.