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