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