Rev 53 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 28 | mjames | 1 | ########################################################################################################################## |
| 55 | mjames | 2 | # File automatically-generated by tool: [projectgenerator] version: [4.4.0-B60] date: [Fri Apr 25 10:13:37 BST 2025] |
| 28 | mjames | 3 | ########################################################################################################################## |
| 2 | mjames | 4 | |
| 28 | mjames | 5 | # ------------------------------------------------ |
| 6 | # Generic Makefile (based on gcc) |
||
| 7 | # |
||
| 8 | # ChangeLog : |
||
| 9 | # 2017-02-10 - Several enhancements + project update mode |
||
| 10 | # 2015-07-22 - first version |
||
| 11 | # ------------------------------------------------ |
||
| 2 | mjames | 12 | |
| 28 | mjames | 13 | ###################################### |
| 14 | # target |
||
| 15 | ###################################### |
||
| 16 | TARGET = EngineBay2 |
||
| 2 | mjames | 17 | |
| 18 | |||
| 28 | mjames | 19 | ###################################### |
| 20 | # building variables |
||
| 21 | ###################################### |
||
| 22 | # debug build? |
||
| 23 | DEBUG = 1 |
||
| 24 | # optimization |
||
| 39 | mjames | 25 | OPT = -Og |
| 2 | mjames | 26 | |
| 27 | |||
| 28 | mjames | 28 | ####################################### |
| 29 | # paths |
||
| 30 | ####################################### |
||
| 31 | # Build path |
||
| 32 | BUILD_DIR = build |
||
| 2 | mjames | 33 | |
| 28 | mjames | 34 | ###################################### |
| 35 | # source |
||
| 36 | ###################################### |
||
| 37 | # C sources |
||
| 38 | C_SOURCES = \ |
||
| 37 | mjames | 39 | Core/Src/main.c \ |
| 40 | Core/Src/stm32f1xx_it.c \ |
||
| 46 | mjames | 41 | Core/Src/stm32f1xx_hal_msp.c \ |
| 42 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c \ |
||
| 43 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c \ |
||
| 44 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c \ |
||
| 45 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c \ |
||
| 46 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c \ |
||
| 47 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c \ |
||
| 48 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c \ |
||
| 49 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \ |
||
| 50 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c \ |
||
| 51 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c \ |
||
| 52 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c \ |
||
| 53 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c \ |
||
| 54 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c \ |
||
| 55 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c \ |
||
| 56 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c \ |
||
| 57 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c \ |
||
| 58 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \ |
||
| 59 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c \ |
||
| 53 | mjames | 60 | Core/Src/system_stm32f1xx.c \ |
| 55 | mjames | 61 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_iwdg.c \ |
| 62 | Core/Src/sysmem.c \ |
||
| 63 | Core/Src/syscalls.c |
||
| 2 | mjames | 64 | |
| 28 | mjames | 65 | # ASM sources |
| 66 | ASM_SOURCES = \ |
||
| 39 | mjames | 67 | startup_stm32f103xb.s |
| 2 | mjames | 68 | |
| 69 | |||
| 28 | mjames | 70 | ####################################### |
| 71 | # binaries |
||
| 72 | ####################################### |
||
| 73 | PREFIX = arm-none-eabi- |
||
| 74 | # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx) |
||
| 75 | # either it can be added to the PATH environment variable. |
||
| 76 | ifdef GCC_PATH |
||
| 77 | CC = $(GCC_PATH)/$(PREFIX)gcc |
||
| 78 | AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp |
||
| 79 | CP = $(GCC_PATH)/$(PREFIX)objcopy |
||
| 80 | SZ = $(GCC_PATH)/$(PREFIX)size |
||
| 48 | mjames | 81 | ## User added |
| 82 | CXX = $(GCC_PATH)/$(PREFIX)g++ |
||
| 28 | mjames | 83 | else |
| 84 | CC = $(PREFIX)gcc |
||
| 85 | AS = $(PREFIX)gcc -x assembler-with-cpp |
||
| 86 | CP = $(PREFIX)objcopy |
||
| 87 | SZ = $(PREFIX)size |
||
| 48 | mjames | 88 | ## User added |
| 89 | CXX = $(PREFIX)g++ |
||
| 28 | mjames | 90 | endif |
| 91 | HEX = $(CP) -O ihex |
||
| 92 | BIN = $(CP) -O binary -S |
||
| 93 | |||
| 94 | ####################################### |
||
| 95 | # CFLAGS |
||
| 96 | ####################################### |
||
| 97 | # cpu |
||
| 98 | CPU = -mcpu=cortex-m3 |
||
| 2 | mjames | 99 | |
| 28 | mjames | 100 | # fpu |
| 101 | # NONE for Cortex-M0/M0+/M3 |
||
| 2 | mjames | 102 | |
| 28 | mjames | 103 | # float-abi |
| 2 | mjames | 104 | |
| 105 | |||
| 28 | mjames | 106 | # mcu |
| 107 | MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI) |
||
| 2 | mjames | 108 | |
| 28 | mjames | 109 | # macros for gcc |
| 110 | # AS defines |
||
| 111 | AS_DEFS = |
||
| 2 | mjames | 112 | |
| 28 | mjames | 113 | # C defines |
| 114 | C_DEFS = \ |
||
| 115 | -DUSE_HAL_DRIVER \ |
||
| 37 | mjames | 116 | -DSTM32F103xB |
| 2 | mjames | 117 | |
| 118 | |||
| 28 | mjames | 119 | # AS includes |
| 120 | AS_INCLUDES = |
||
| 2 | mjames | 121 | |
| 28 | mjames | 122 | # C includes |
| 123 | C_INCLUDES = \ |
||
| 37 | mjames | 124 | -ICore/Inc \ |
| 125 | -IDrivers/STM32F1xx_HAL_Driver/Inc \ |
||
| 126 | -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \ |
||
| 46 | mjames | 127 | -IDrivers/CMSIS/Device/ST/STM32F1xx/Include \ |
| 128 | -IDrivers/CMSIS/Include |
||
| 48 | mjames | 129 | ############################################# |
| 55 | mjames | 130 | ########################################################################################### User added |
| 48 | mjames | 131 | # C++ sources |
| 132 | CPP_SOURCES += |
||
| 2 | mjames | 133 | |
| 28 | mjames | 134 | ####################################################### |
| 135 | # Additional code |
||
| 2 | mjames | 136 | |
| 37 | mjames | 137 | C_INCLUDES += -IInc |
| 28 | mjames | 138 | C_SOURCES += Src/misc.c |
| 2 | mjames | 139 | |
| 140 | |||
| 28 | mjames | 141 | # PLX code library |
| 142 | LIBPLX=../libPLX |
||
| 143 | include $(LIBPLX)/libPLX.mk |
||
| 2 | mjames | 144 | |
| 37 | mjames | 145 | # Using UART1 with LibSerial. |
| 146 | C_DEFS += -DSERIAL_UART1 |
||
| 2 | mjames | 147 | |
| 28 | mjames | 148 | LIBSERIAL=../libSerial |
| 149 | include $(LIBSERIAL)/libSerial.mk |
||
| 2 | mjames | 150 | |
| 48 | mjames | 151 | # Get the common RPM timing code |
| 152 | LIBIGNTIMING=../libIgnTiming |
||
| 153 | include $(LIBIGNTIMING)/libIgnTiming.mk |
||
| 2 | mjames | 154 | |
| 28 | mjames | 155 | # compile gcc flags |
| 156 | ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections |
||
| 2 | mjames | 157 | |
| 46 | mjames | 158 | CFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections |
| 2 | mjames | 159 | |
| 28 | mjames | 160 | ifeq ($(DEBUG), 1) |
| 161 | CFLAGS += -g -gdwarf-2 |
||
| 162 | endif |
||
| 2 | mjames | 163 | |
| 164 | |||
| 28 | mjames | 165 | # Generate dependency information |
| 166 | CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" |
||
| 48 | mjames | 167 | ## User added |
| 168 | CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions |
||
| 2 | mjames | 169 | |
| 170 | |||
| 28 | mjames | 171 | ####################################### |
| 172 | # LDFLAGS |
||
| 173 | ####################################### |
||
| 174 | # link script |
||
| 37 | mjames | 175 | LDSCRIPT = STM32F103C8Tx_FLASH.ld |
| 2 | mjames | 176 | |
| 28 | mjames | 177 | # libraries |
| 53 | mjames | 178 | LIBS += -lc -lm -lnosys |
| 179 | LIBDIR += |
||
| 28 | mjames | 180 | LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections |
| 2 | mjames | 181 | |
| 28 | mjames | 182 | # default action: build all |
| 183 | all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin |
||
| 2 | mjames | 184 | |
| 185 | |||
| 28 | mjames | 186 | ####################################### |
| 187 | # build the application |
||
| 188 | ####################################### |
||
| 189 | # list of objects |
||
| 190 | OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) |
||
| 191 | vpath %.c $(sort $(dir $(C_SOURCES))) |
||
| 192 | # list of ASM program objects |
||
| 193 | OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) |
||
| 194 | vpath %.s $(sort $(dir $(ASM_SOURCES))) |
||
| 48 | mjames | 195 | ## User added List of C++ compiled objects |
| 196 | OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o))) |
||
| 197 | vpath %.cpp $(sort $(dir $(CPP_SOURCES))) |
||
| 2 | mjames | 198 | |
| 48 | mjames | 199 | ## User added C++ compilation rule |
| 200 | $(BUILD_DIR)/%.o: %.cpp Makefile | $(BUILD_DIR) |
||
| 201 | $(CXX) -c $(CXXFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ |
||
| 28 | mjames | 202 | $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) |
| 203 | $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ |
||
| 2 | mjames | 204 | |
| 28 | mjames | 205 | $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) |
| 206 | $(AS) -c $(CFLAGS) $< -o $@ |
||
| 9 | mjames | 207 | |
| 28 | mjames | 208 | $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile |
| 209 | $(CC) $(OBJECTS) $(LDFLAGS) -o $@ |
||
| 210 | $(SZ) $@ |
||
| 9 | mjames | 211 | |
| 28 | mjames | 212 | $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) |
| 213 | $(HEX) $< $@ |
||
| 2 | mjames | 214 | |
| 28 | mjames | 215 | $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) |
| 216 | $(BIN) $< $@ |
||
| 9 | mjames | 217 | |
| 28 | mjames | 218 | $(BUILD_DIR): |
| 219 | mkdir $@ |
||
| 2 | mjames | 220 | |
| 28 | mjames | 221 | ####################################### |
| 222 | # clean up |
||
| 223 | ####################################### |
||
| 224 | clean: |
||
| 50 | mjames | 225 | -del -R $(BUILD_DIR) |
| 28 | mjames | 226 | |
| 227 | ####################################### |
||
| 228 | # dependencies |
||
| 229 | ####################################### |
||
| 230 | -include $(wildcard $(BUILD_DIR)/*.d) |
||
| 2 | mjames | 231 | |
| 53 | mjames | 232 | # *** EOF *** |