Build system fixes

Put version.h in build directory
Fixed out of source build not being completely out-of-source (version.h)
This commit is contained in:
Keith Rothman 2013-10-04 22:37:41 -07:00
commit d0d2dad9ae
2 changed files with 19 additions and 9 deletions

View file

@ -9,9 +9,17 @@ include(Version)
set(VERSION "${VERSION_INFO}")
# .dirstamp needs to touched before version.h so that fx3_firmware/makefile
# doesn't try to rebuild version.h.
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/version.h.in
${CMAKE_CURRENT_SOURCE_DIR}/version.h
${CMAKE_CURRENT_BINARY_DIR}/build/.dirstamp
@ONLY
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/version.h.in
${CMAKE_CURRENT_BINARY_DIR}/build/version.h
@ONLY
)

View file

@ -22,7 +22,8 @@ OBJ := $(addprefix $(OUTPUT_DIR)/,$(SRC:.c=.o)) \
CFLAGS := -Wall -Wextra -Wno-unused-parameter \
$(TOOLCHAIN_CFLAGS) \
$(EXTRA_CFLAGS)
$(EXTRA_CFLAGS) \
-I$(OUTPUT_DIR)
ifdef DEBUG
CFLAGS += -O0 -ggdb3 -DDEBUG
@ -33,10 +34,11 @@ endif
LDFLAGS := $(TOOLCHAIN_LDFLAGS) -Map $(MAP)
all: version $(IMG)
all: $(OUTPUT_DIR)/version.h $(IMG)
$(OUTPUT_DIR)/.dirstamp:
-mkdir $(OUTPUT_DIR)
@mkdir -p $(OUTPUT_DIR)
@touch $(OUTPUT_DIR)/.dirstamp
$(OUTPUT_DIR)/%.o: %.c
$(CC) -c $(CFLAGS) -o $@ $^
@ -57,14 +59,14 @@ $(OUTPUT_DIR)/cyfxtx.o: $(OUTPUT_DIR)/%.o : $(TOOLCHAIN_DEPS_DIR)/%.c
$(OUTPUT_DIR)/$(TOOLCHAIN_DEPS_OBJ_A): $(OUTPUT_DIR)/%.o : $(TOOLCHAIN_DEPS_DIR)/%.S
$(call build_toolchain_dep,$<,$@)
version:
cmake .
rm -fr CMakeFiles CMakeCache.txt cmake_install.cmake Makefile
$(OUTPUT_DIR)/version.h: $(OUTPUT_DIR)/.dirstamp version.h.in
cd $(OUTPUT_DIR) && \
cmake $(CURDIR)
-@cp $(OUTPUT_DIR)/build/version.h $(OUTPUT_DIR)/version.h
clean:
$(RM) -f $(ELF) $(IMG) $(MAP) $(OBJ) $(TOOLCHAIN_OBJ) version.h
realclean: clean
$(RM) -rf $(OUTPUT_DIR)
realclean: clean
.PHONY: clean realclean