Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Commit

Permalink
makefile: Check for dirty submodules when building
Browse files Browse the repository at this point in the history
  • Loading branch information
kbeckmann committed Dec 29, 2020
1 parent ef5c49e commit fe85be3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ DEBUG ?= 1
# optimization
OPT ?= -Og

CHECK_DIRTY_SUBMODULE ?= 1

#######################################
# paths
Expand Down Expand Up @@ -242,11 +243,20 @@ Core/Inc/githash.h:
Core/Src/main.c: Core/Inc/githash.h
Core/Src/retro-go/rg_main.c: Core/Inc/githash.h

$(BUILD_DIR)/%.o: %.c Makefile.common Makefile $(LDSCRIPT) $(SDK_HEADERS) | $(BUILD_DIR)
ifeq (${CHECK_DIRTY_SUBMODULE},1)
CheckDirtySubmodules:
$(V)git submodule foreach "git diff --quiet" 2> /dev/null || \
(echo -e "\n\n\nYou are using dirty submodules.\nPlease sync the submodules by running 'git submodule update --init'\n\n(You may set CHECK_DIRTY_SUBMODULE=0 to suppress this warning)\n\n\n" && exit 1)
else
CheckDirtySubmodules:
endif
.PHONY: CheckDirtySubmodules

$(BUILD_DIR)/%.o: %.c Makefile.common Makefile $(LDSCRIPT) $(SDK_HEADERS) | $(BUILD_DIR) CheckDirtySubmodules
$(V)$(ECHO) [ CC ] $(notdir $<)
$(V)$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@

$(BUILD_DIR)/%.o: %.s Makefile.common Makefile $(LDSCRIPT) | $(BUILD_DIR)
$(BUILD_DIR)/%.o: %.s Makefile.common Makefile $(LDSCRIPT) | $(BUILD_DIR) CheckDirtySubmodules
$(V)$(ECHO) [ AS ] $(notdir $<)
$(V)$(AS) -c $(CFLAGS) $< -o $@

Expand Down

0 comments on commit fe85be3

Please sign in to comment.