Rev 50 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 28 | mjames | 1 | ########################################################################################################################## |
| 53 | mjames | 2 | # File automatically-generated by tool: [projectgenerator] version: [4.1.0] date: [Mon Aug 07 21:03:53 BST 2023] |
| 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 \ |
| 61 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_iwdg.c |
||
| 2 | mjames | 62 | |
| 28 | mjames | 63 | # ASM sources |
| 64 | ASM_SOURCES = \ |
||
| 39 | mjames | 65 | startup_stm32f103xb.s |
| 2 | mjames | 66 | |
| 67 | |||
| 28 | mjames | 68 | ####################################### |
| 69 | # binaries |
||
| 70 | ####################################### |
||
| 71 | PREFIX = arm-none-eabi- |
||
| 72 | # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx) |
||
| 73 | # either it can be added to the PATH environment variable. |
||
| 74 | ifdef GCC_PATH |
||
| 75 | CC = $(GCC_PATH)/$(PREFIX)gcc |
||
| 76 | AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp |
||
| 77 | CP = $(GCC_PATH)/$(PREFIX)objcopy |
||
| 78 | SZ = $(GCC_PATH)/$(PREFIX)size |
||
| 48 | mjames | 79 | ## User added |
| 80 | CXX = $(GCC_PATH)/$(PREFIX)g++ |
||
| 28 | mjames | 81 | else |
| 82 | CC = $(PREFIX)gcc |
||
| 83 | AS = $(PREFIX)gcc -x assembler-with-cpp |
||
| 84 | CP = $(PREFIX)objcopy |
||
| 85 | SZ = $(PREFIX)size |
||
| 48 | mjames | 86 | ## User added |
| 87 | CXX = $(PREFIX)g++ |
||
| 28 | mjames | 88 | endif |
| 89 | HEX = $(CP) -O ihex |
||
| 90 | BIN = $(CP) -O binary -S |
||
| 91 | |||
| 92 | ####################################### |
||
| 93 | # CFLAGS |
||
| 94 | ####################################### |
||
| 95 | # cpu |
||
| 96 | CPU = -mcpu=cortex-m3 |
||
| 2 | mjames | 97 | |
| 28 | mjames | 98 | # fpu |
| 99 | # NONE for Cortex-M0/M0+/M3 |
||
| 2 | mjames | 100 | |
| 28 | mjames | 101 | # float-abi |
| 2 | mjames | 102 | |
| 103 | |||
| 28 | mjames | 104 | # mcu |
| 105 | MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI) |
||
| 2 | mjames | 106 | |
| 28 | mjames | 107 | # macros for gcc |
| 108 | # AS defines |
||
| 109 | AS_DEFS = |
||
| 2 | mjames | 110 | |
| 28 | mjames | 111 | # C defines |
| 112 | C_DEFS = \ |
||
| 113 | -DUSE_HAL_DRIVER \ |
||
| 37 | mjames | 114 | -DSTM32F103xB |
| 2 | mjames | 115 | |
| 116 | |||
| 28 | mjames | 117 | # AS includes |
| 118 | AS_INCLUDES = |
||
| 2 | mjames | 119 | |
| 28 | mjames | 120 | # C includes |
| 121 | C_INCLUDES = \ |
||
| 37 | mjames | 122 | -ICore/Inc \ |
| 123 | -IDrivers/STM32F1xx_HAL_Driver/Inc \ |
||
| 124 | -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \ |
||
| 46 | mjames | 125 | -IDrivers/CMSIS/Device/ST/STM32F1xx/Include \ |
| 126 | -IDrivers/CMSIS/Include |
||
| 48 | mjames | 127 | ############################################# |
| 53 | mjames | 128 | ############################################## User added |
| 48 | mjames | 129 | # C++ sources |
| 130 | CPP_SOURCES += |
||
| 2 | mjames | 131 | |
| 28 | mjames | 132 | ####################################################### |
| 133 | # Additional code |
||
| 2 | mjames | 134 | |
| 37 | mjames | 135 | C_INCLUDES += -IInc |
| 28 | mjames | 136 | C_SOURCES += Src/misc.c |
| 2 | mjames | 137 | |
| 138 | |||
| 28 | mjames | 139 | # PLX code library |
| 140 | LIBPLX=../libPLX |
||
| 141 | include $(LIBPLX)/libPLX.mk |
||
| 2 | mjames | 142 | |
| 37 | mjames | 143 | # Using UART1 with LibSerial. |
| 144 | C_DEFS += -DSERIAL_UART1 |
||
| 2 | mjames | 145 | |
| 28 | mjames | 146 | LIBSERIAL=../libSerial |
| 147 | include $(LIBSERIAL)/libSerial.mk |
||
| 2 | mjames | 148 | |
| 48 | mjames | 149 | # Get the common RPM timing code |
| 150 | LIBIGNTIMING=../libIgnTiming |
||
| 151 | include $(LIBIGNTIMING)/libIgnTiming.mk |
||
| 2 | mjames | 152 | |
| 28 | mjames | 153 | # compile gcc flags |
| 154 | ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections |
||
| 2 | mjames | 155 | |
| 46 | mjames | 156 | CFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections |
| 2 | mjames | 157 | |
| 28 | mjames | 158 | ifeq ($(DEBUG), 1) |
| 159 | CFLAGS += -g -gdwarf-2 |
||
| 160 | endif |
||
| 2 | mjames | 161 | |
| 162 | |||
| 28 | mjames | 163 | # Generate dependency information |
| 164 | CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" |
||
| 48 | mjames | 165 | ## User added |
| 166 | CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions |
||
| 2 | mjames | 167 | |
| 168 | |||
| 28 | mjames | 169 | ####################################### |
| 170 | # LDFLAGS |
||
| 171 | ####################################### |
||
| 172 | # link script |
||
| 37 | mjames | 173 | LDSCRIPT = STM32F103C8Tx_FLASH.ld |
| 2 | mjames | 174 | |
| 28 | mjames | 175 | # libraries |
| 53 | mjames | 176 | LIBS += -lc -lm -lnosys |
| 177 | LIBDIR += |
||
| 28 | mjames | 178 | LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections |
| 2 | mjames | 179 | |
| 28 | mjames | 180 | # default action: build all |
| 181 | all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin |
||
| 2 | mjames | 182 | |
| 183 | |||
| 28 | mjames | 184 | ####################################### |
| 185 | # build the application |
||
| 186 | ####################################### |
||
| 187 | # list of objects |
||
| 188 | OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) |
||
| 189 | vpath %.c $(sort $(dir $(C_SOURCES))) |
||
| 190 | # list of ASM program objects |
||
| 191 | OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) |
||
| 192 | vpath %.s $(sort $(dir $(ASM_SOURCES))) |
||
| 48 | mjames | 193 | ## User added List of C++ compiled objects |
| 194 | OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o))) |
||
| 195 | vpath %.cpp $(sort $(dir $(CPP_SOURCES))) |
||
| 2 | mjames | 196 | |
| 48 | mjames | 197 | ## User added C++ compilation rule |
| 198 | $(BUILD_DIR)/%.o: %.cpp Makefile | $(BUILD_DIR) |
||
| 199 | $(CXX) -c $(CXXFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ |
||
| 28 | mjames | 200 | $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) |
| 201 | $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ |
||
| 2 | mjames | 202 | |
| 28 | mjames | 203 | $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) |
| 204 | $(AS) -c $(CFLAGS) $< -o $@ |
||
| 9 | mjames | 205 | |
| 28 | mjames | 206 | $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile |
| 207 | $(CC) $(OBJECTS) $(LDFLAGS) -o $@ |
||
| 208 | $(SZ) $@ |
||
| 9 | mjames | 209 | |
| 28 | mjames | 210 | $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) |
| 211 | $(HEX) $< $@ |
||
| 2 | mjames | 212 | |
| 28 | mjames | 213 | $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) |
| 214 | $(BIN) $< $@ |
||
| 9 | mjames | 215 | |
| 28 | mjames | 216 | $(BUILD_DIR): |
| 217 | mkdir $@ |
||
| 2 | mjames | 218 | |
| 28 | mjames | 219 | ####################################### |
| 220 | # clean up |
||
| 221 | ####################################### |
||
| 222 | clean: |
||
| 50 | mjames | 223 | -del -R $(BUILD_DIR) |
| 28 | mjames | 224 | |
| 225 | ####################################### |
||
| 226 | # dependencies |
||
| 227 | ####################################### |
||
| 228 | -include $(wildcard $(BUILD_DIR)/*.d) |
||
| 2 | mjames | 229 | |
| 53 | mjames | 230 | # *** EOF *** |