Skip to content

Commit

Permalink
make: Don't delete version.h in archives.
Browse files Browse the repository at this point in the history
When the code is cleaned in a source archive the version.h should not be
deleted. We detect if we are in an archive by checking if `.git` exists
in the top level directory.
  • Loading branch information
esden committed Apr 29, 2023
1 parent ce86b19 commit fdf37db
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,18 @@ endif

.PHONY: clean host_clean all_platforms clang-format FORCE


GIT_VERSION := $(shell if [ -d "../.git" ]; then git describe --always --dirty --tags; fi)

clean: host_clean
$(Q)echo " CLEAN"
-$(Q)$(RM) *.o *.d *.elf *~ $(TARGET) $(HOSTFILES)
-$(Q)$(RM) platforms/*/*.o platforms/*/*.d mapfile include/version.h
-$(Q)$(RM) platforms/*/*.o platforms/*/*.d mapfile
ifeq ($(GIT_VERSION),)
@echo Git not found, not deleting include/version.h
else
-$(Q)$(RM) include/version.h
endif

all_platforms:
$(Q)if [ ! -f ../libopencm3/Makefile ]; then \
Expand Down Expand Up @@ -188,7 +196,6 @@ all_platforms:

command.c: include/version.h

GIT_VERSION := $(shell git describe --always --dirty --tags)
VERSION_HEADER := \#define FIRMWARE_VERSION "$(GIT_VERSION)"

include/version.h: FORCE
Expand Down

0 comments on commit fdf37db

Please sign in to comment.