From 1452221aca8851df029702e8a71be339005bd5fd Mon Sep 17 00:00:00 2001 From: Andrew Scheller Date: Fri, 11 Apr 2014 00:02:10 +0100 Subject: Auto-generate the stmhal/pybcdc_inf header file from static files The USB VID&PID are automatically extracted from usbd_desc_cdc_msc.c and inserted into pybcdc_inf.template, ensuring that the same USB IDs get used everywhere --- stmhal/Makefile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'stmhal/Makefile') diff --git a/stmhal/Makefile b/stmhal/Makefile index 978918994..f0d132520 100644 --- a/stmhal/Makefile +++ b/stmhal/Makefile @@ -210,6 +210,14 @@ PREFIX_FILE = boards/stm32f4xx-prefix.c GEN_PINS_SRC = $(BUILD)/pins_$(BOARD).c GEN_PINS_HDR = $(BUILD)/pins.h +INSERT_USB_IDS = ../tools/insert-usb-ids.py +FILE2H = ../tools/file2h.py + +USB_IDS_FILE = usbd_desc_cdc_msc.c +CDCINF_TEMPLATE = pybcdc.inf_template +GEN_CDCINF_FILE = $(BUILD)/pybcdc.inf +GEN_CDCINF_HEADER = $(BUILD)/pybcdc_inf.h + # Making OBJ use an order-only depenedency on the generated pins.h file # has the side effect of making the pins.h file before we actually compile # any of the objects. The normal dependency generation will deal with the @@ -217,6 +225,8 @@ GEN_PINS_HDR = $(BUILD)/pins.h # which source files might need it. $(OBJ): | $(BUILD)/pins.h +$(BUILD)/main.o: $(GEN_CDCINF_HEADER) + # Use a pattern rule here so that make will only call make-pins.py once to make # both pins_$(BOARD).c and pins.h $(BUILD)/%_$(BOARD).c $(BUILD)/%.h: boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) @@ -226,4 +236,12 @@ $(BUILD)/%_$(BOARD).c $(BUILD)/%.h: boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE $(BUILD)/pins_$(BOARD).o: $(BUILD)/pins_$(BOARD).c $(call compile_c) +$(GEN_CDCINF_HEADER): $(GEN_CDCINF_FILE) $(FILE2H) + $(ECHO) "Create $@" + $(Q)$(PYTHON) $(FILE2H) $< > $@ + +$(GEN_CDCINF_FILE): $(CDCINF_TEMPLATE) $(INSERT_USB_IDS) $(USB_IDS_FILE) + $(ECHO) "Create $@" + $(Q)$(PYTHON) $(INSERT_USB_IDS) $(USB_IDS_FILE) $< > $@ + include ../py/mkrules.mk -- cgit v1.2.3