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.*
*.lss
*.d

View File

@ -16,6 +16,11 @@ DEFINES = -DSTM32F407xx -DSTM32F4XX -DARM_MATH_CM4
mapfile = dafuqishappening
##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
@ -35,8 +40,8 @@ CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 -nostartfiles -Wall -O0 -g3
####################################################################################
OBJ = $(CFILES:%.c=%.c.o)
ASOBJ = $(ASFILES:%.S=%.S.o)
OBJ = $(CFILES:%.c=%.o)
ASOBJ = $(ASFILES:%.S=%.o)
default: $(target).elf
@ -44,35 +49,40 @@ default: $(target).elf
%.bin: %.elf
$(OBJCOPY) -O binary $^ $@
$(QUIET)$(OBJCOPY) -O binary $^ $@
%.hex: %.elf
$(OBJCOPY) -O ihex $^ $@
$(QUIET)$(OBJCOPY) -O ihex $^ $@
#Linking
$(target).elf: $(OBJ) $(ASOBJ)
$(CC) $(LFLAGS) $(LIBRARYPATH) -o $@ $^ $(LIBRARIES)
$(SIZE) $@
@echo !!! Calling linker $@
$(QUIET)$(CC) $(LFLAGS) $(LIBRARYPATH) -o $@ $^ $(LIBRARIES)
$(QUIET)$(SIZE) $@
#Compiling
%.c.o: %.c
$(CC) $(CFLAGS) $(INCLUDEPATH) $(DEFINES) -o $@ $<
$(OBJ):
@echo !!! Calling Compiler $@
$(QUIET)$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ $(@:%.o=%.c)
%.S.o: %.S
$(CC) $(CFLAGS) $(INCLUDEPATH) $(DEFINES) -o $@ $<
$(ASOBJ):
@echo !!! Calling Assembler $@
$(QUIET)$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ $(@:%.o=%.S)
.PHONY: qtproject clean mrproper objcopy disassemble
disassemble: $(target).elf
$(OBJDUMP) -D -s $< > $(target).lss
$(QUIET)$(OBJDUMP) -D -s $< > $(target).lss
objcopy: $(target).bin $(target).hex
mrproper:
rm -f $(target).pro
$(QUIET)rm -f $(target).pro
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:
echo -e "TEMPLATE = app\nCONFIG -= console app_bundle qt" > $(target).pro
echo -e "SOURCES += $(CFILES) $(ASFILES)" >> $(target).pro
@ -83,4 +93,5 @@ qtproject:
echo -ne "\nDEFINES += " >> $(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****/

View File

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

2
main.c
View File

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