Update Makefile to use dependency files

This commit is contained in:
Mario Hüttel 2018-11-07 17:18:24 +01:00
parent e882607fe8
commit 03daeeeb36
5 changed files with 28 additions and 19 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ Debug
*.user *.user
*.user.* *.user.*
*.lss *.lss
*.d

View File

@ -16,6 +16,11 @@ DEFINES = -DSTM32F407xx -DSTM32F4XX -DARM_MATH_CM4
mapfile = dafuqishappening mapfile = dafuqishappening
##Custom Files### ##Custom Files###
ifneq ($(VERBOSE),true)
QUIET=@
else
QUIET=
endif
CFILES += fatfs/option/syscall.c fatfs/option/ccsbcs.c fatfs/diskio.c fatfs/ff.c fatfs/shimatta_sdio_driver/shimatta_sdio.c CFILES += fatfs/option/syscall.c fatfs/option/ccsbcs.c fatfs/diskio.c fatfs/ff.c fatfs/shimatta_sdio_driver/shimatta_sdio.c
@ -35,8 +40,8 @@ CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 -nostartfiles -Wall -O0 -g3
#################################################################################### ####################################################################################
OBJ = $(CFILES:%.c=%.c.o) OBJ = $(CFILES:%.c=%.o)
ASOBJ = $(ASFILES:%.S=%.S.o) ASOBJ = $(ASFILES:%.S=%.o)
default: $(target).elf default: $(target).elf
@ -44,35 +49,40 @@ default: $(target).elf
%.bin: %.elf %.bin: %.elf
$(OBJCOPY) -O binary $^ $@ $(QUIET)$(OBJCOPY) -O binary $^ $@
%.hex: %.elf %.hex: %.elf
$(OBJCOPY) -O ihex $^ $@ $(QUIET)$(OBJCOPY) -O ihex $^ $@
#Linking #Linking
$(target).elf: $(OBJ) $(ASOBJ) $(target).elf: $(OBJ) $(ASOBJ)
$(CC) $(LFLAGS) $(LIBRARYPATH) -o $@ $^ $(LIBRARIES) @echo !!! Calling linker $@
$(SIZE) $@ $(QUIET)$(CC) $(LFLAGS) $(LIBRARYPATH) -o $@ $^ $(LIBRARIES)
$(QUIET)$(SIZE) $@
#Compiling #Compiling
%.c.o: %.c $(OBJ):
$(CC) $(CFLAGS) $(INCLUDEPATH) $(DEFINES) -o $@ $< @echo !!! Calling Compiler $@
$(QUIET)$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ $(@:%.o=%.c)
%.S.o: %.S $(ASOBJ):
$(CC) $(CFLAGS) $(INCLUDEPATH) $(DEFINES) -o $@ $< @echo !!! Calling Assembler $@
$(QUIET)$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ $(@:%.o=%.S)
.PHONY: qtproject clean mrproper objcopy disassemble .PHONY: qtproject clean mrproper objcopy disassemble
disassemble: $(target).elf disassemble: $(target).elf
$(OBJDUMP) -D -s $< > $(target).lss $(QUIET)$(OBJDUMP) -D -s $< > $(target).lss
objcopy: $(target).bin $(target).hex objcopy: $(target).bin $(target).hex
mrproper: mrproper:
rm -f $(target).pro $(QUIET)rm -f $(target).pro
clean: clean:
rm -f $(target).elf $(target).bin $(target).hex $(OBJ) $(ASOBJ) $(mapfile).map $(target).lss @echo cleaning up
$(QUIET)rm -f $(target).elf $(target).bin $(target).hex $(OBJ) $(ASOBJ) $(mapfile).map $(target).lss $(CFILES:%.c=%.d) $(ASFILES:%.S=%.d)
qtproject: qtproject:
echo -e "TEMPLATE = app\nCONFIG -= console app_bundle qt" > $(target).pro echo -e "TEMPLATE = app\nCONFIG -= console app_bundle qt" > $(target).pro
echo -e "SOURCES += $(CFILES) $(ASFILES)" >> $(target).pro echo -e "SOURCES += $(CFILES) $(ASFILES)" >> $(target).pro
@ -83,4 +93,5 @@ qtproject:
echo -ne "\nDEFINES += " >> $(target).pro echo -ne "\nDEFINES += " >> $(target).pro
echo "$(DEFINES)" | sed "s/-D//g" >> $(target).pro echo "$(DEFINES)" | sed "s/-D//g" >> $(target).pro
-include $(CFILES:%.c=%.d) $(ASFILES:%.S=%.d)

View File

@ -97,3 +97,4 @@ extern void SystemCoreClockUpdate(void);
* @} * @}
*/ */
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/

View File

@ -11,7 +11,5 @@
void initUART(); void initUART();
void sendChar(char c); void sendChar(char c);
void sendString(char* s, int count); void sendString(char* s, int count);
#ifdef _P20N_
void yuri();
#endif
#endif /* UART_UART_H_ */ #endif /* UART_UART_H_ */

2
main.c
View File

@ -61,8 +61,6 @@ while(1);
} }
void HardFault_Handler(uint32_t *stack) { void HardFault_Handler(uint32_t *stack) {
// unsigned int stacked_r0; // unsigned int stacked_r0;
// unsigned int stacked_r1; // unsigned int stacked_r1;