@@ -8,8 +8,16 @@ PLATFORM := $(basename $(notdir $(lastword $(PLATFORM_MK))))
88PLATFORM_UC := $(shell echo "$(PLATFORM ) " | tr '[:lower:]' '[:upper:]')
99$(info Building for PLATFORM=$(PLATFORM))
1010
11+ # Add GIT_VERSION macro define to CFLAGS, includes tag if available,
12+ # short commit hash, appends '*' if changes haven't been commited
13+ CFLAGS += -DGIT_VERSION='\"$(shell git rev-parse --short HEAD)$(shell git status --porcelain | grep -q '^[ MADRCU]' && echo '* ') \"'
14+
1115include $(MWD ) /../Makefile
1216
17+ # Add GIT_VERSION macro define to CFLAGS, includes tag if available,
18+ # short commit hash, appends '*' if changes haven't been commited
19+ CFLAGS += -DGIT_VERSION='\"$(shell git rev-parse --short HEAD)$(shell git status --porcelain | grep -q '^[ MADRCU]' && echo '* ') \"'
20+
1321IS_LIBRARY := $(if $(filter % .lib,$(PRODUCT ) ) ,1,0)
1422ifeq ($(IS_LIBRARY ) ,1)
1523 PRODUCT_BASE = $(basename $(PRODUCT ) )
@@ -33,6 +41,10 @@ ifneq ($(strip $(LD_$(TOOLCHAIN_UC))),)
3341LD_DEFAULT = $(LD_$(TOOLCHAIN_UC ) )
3442endif
3543
44+ ifneq ($(strip $(PC_$(TOOLCHAIN_UC ) ) ) ,)
45+ PC_DEFAULT = $(PC_$(TOOLCHAIN_UC ) )
46+ endif
47+
3648R2R_PD := $(R2R_DIR ) /$(PLATFORM )
3749OBJ_DIR := $(BUILD_DIR ) /$(PLATFORM )
3850CACHE_PLATFORM := $(CACHE_DIR ) /$(PLATFORM )
@@ -60,16 +72,16 @@ SRC_DIRS_EXPANDED := $(call expand_platform_pattern,$(SRC_DIRS))
6072CFILES := $(foreach dir,$(SRC_DIRS_EXPANDED ) ,$(wildcard $(dir ) /* .c) )
6173AFILES := $(foreach dir,$(SRC_DIRS_EXPANDED ) ,$(wildcard $(dir ) /* .s) ) \
6274 $(foreach dir,$(SRC_DIRS_EXPANDED ) ,$(wildcard $(dir ) /* .asm) )
75+ PFILES := $(foreach dir,$(SRC_DIRS_EXPANDED ) ,$(wildcard $(dir ) /* .pas) )
6376
6477# Need two steps: AFILES may be .s or .asm; `make` swaps one suffix at a time
6578NORM_AFILES := $(AFILES:.asm=.s )
66- OBJS := $(addprefix $(OBJ_DIR ) /, $(notdir $(CFILES:.c=.o ) $(NORM_AFILES:.s=.o ) ) )
79+ OBJS := $(addprefix $(OBJ_DIR ) /, $(notdir $(CFILES:.c=.o ) $(NORM_AFILES:.s=.o ) $( PFILES:.pas=.o ) ) )
6780
6881$(BUILD_EXEC ) :: $(OBJS ) $(EXECUTABLE_EXTRA_DEPS_$(PLATFORM_UC ) ) | $(R2R_PD )
6982 $(call link-bin,$@ ,$(OBJS ) )
7083 @$(MAKE ) -f $(PLATFORM_MK ) $(PLATFORM ) /executable-post
7184
72- $(info LIBRARY=$(BUILD_LIB))
7385$(BUILD_LIB ) :: $(OBJS ) $(LIBRARY_EXTRA_DEPS_$(PLATFORM_UC ) ) | $(R2R_PD )
7486 $(call link-lib,$@ ,$(OBJS ) )
7587 @$(MAKE ) -f $(PLATFORM_MK ) $(PLATFORM ) /library-post
@@ -85,10 +97,13 @@ $(OBJ_DIR)/%.o: %.s | $(OBJ_DIR)
8597 $(call assemble,$@ ,$< )
8698$(OBJ_DIR ) /% .o : % .asm | $(OBJ_DIR )
8799 $(call assemble,$@ ,$< )
100+ $(OBJ_DIR ) /% .o : % .pas | $(OBJ_DIR )
101+ $(call compile-pas,$@ ,$< )
88102
89103vpath % .c $(SRC_DIRS_EXPANDED )
90104vpath % .s $(SRC_DIRS_EXPANDED )
91105vpath % .asm $(SRC_DIRS_EXPANDED )
106+ vpath % .pas $(SRC_DIRS_EXPANDED )
92107
93108.PHONY : clean debug r2r $(PLATFORM ) /r2r disk $(PLATFORM ) /disk
94109
0 commit comments