Optimize Makefiles (add auto-dependencies),

and convert basic/ into a lib like the other subdirs
This commit is contained in:
Stefan `Sec` Zehl 2011-07-09 20:17:00 +02:00
parent 2985d1b9f5
commit f941dd5451
8 changed files with 83 additions and 73 deletions

1
firmware/.gitignore vendored
View File

@ -3,3 +3,4 @@ firmware.elf
lpc1xxx/memory.ld lpc1xxx/memory.ld
applications/wrapper.c applications/wrapper.c
lcd/allfonts.h lcd/allfonts.h
Makefile.dep

View File

@ -1,15 +1,21 @@
VPATH = VPATH =
OBJS = main.o OBJS =
LIBS =
########################################################################## ##########################################################################
# Project-specific files # Project-specific files
########################################################################## ##########################################################################
VPATH += VPATH +=
OBJS += OBJS += main.o
OBJS += basic/basic.o basic/reinvoke_isp.o basic/delayms.o basic/voltage.o
OBJS += basic/keyin.o basic/uuid.o basic/crc.o LIBS += lcd/liblcd.a
LIBS += core/libcore.a lcd/liblcd.a applications/libapp.a filesystem/libfat.a usb/libusb.a funk/libfunk.a LIBS += basic/libbasic.a
LIBS += core/libcore.a
LIBS += applications/libapp.a
LIBS += filesystem/libfat.a
LIBS += usb/libusb.a
LIBS += funk/libfunk.a
########################################################################## ##########################################################################
# GNU GCC compiler flags # GNU GCC compiler flags
@ -32,9 +38,12 @@ LDLIBS += -Lfunk -lfunk
LDLIBS += -Llcd -llcd LDLIBS += -Llcd -llcd
LDLIBS += -Lusb -lusb LDLIBS += -Lusb -lusb
LDLIBS += -Lfilesystem -lfat LDLIBS += -Lfilesystem -lfat
LDLIBS += -Lbasic -lbasic
LDLIBS += -Lcore -lcore LDLIBS += -Lcore -lcore
OCFLAGS = --strip-unneeded OCFLAGS = --strip-unneeded
SUBDIRS?= $(foreach lib,$(LIBS),$(dir $(lib)))
LD_PATH = lpc1xxx LD_PATH = lpc1xxx
LD_SCRIPT = $(LD_PATH)/linkscript.ld LD_SCRIPT = $(LD_PATH)/linkscript.ld
LD_TEMP = $(LD_PATH)/memory.ld LD_TEMP = $(LD_PATH)/memory.ld
@ -51,36 +60,22 @@ loadables: $(OUTFILE).bin
clean: clean:
rm -f $(OBJS) $(LD_TEMP) $(OUTFILE).elf $(OUTFILE).bin $(OUTFILE).hex rm -f $(OBJS) $(LD_TEMP) $(OUTFILE).elf $(OUTFILE).bin $(OUTFILE).hex
@cd core && $(MAKE) clean for dir in $(SUBDIRS); do \
@cd ../tools/bootloader && $(MAKE) clean $(MAKE) --no-print-directory -C $$dir clean; \
@cd lcd && $(MAKE) clean done
@cd applications && $(MAKE) clean
@cd filesystem && $(MAKE) clean
@cd usb && $(MAKE) clean
@cd loadable && $(MAKE) clean
### Internal targets ### Internal targets
%.o : %.c %.o : %.c
$(CC) $(CFLAGS) -o $@ $< $(CC) $(CFLAGS) -o $@ $<
core/libcore.a: core/projectconfig.h ### Make all libraries...
cd core && $(MAKE) ROOT_PATH=../$(ROOT_PATH) .PHONY: subdirs $(SUBDIRS)
lcd/liblcd.a lcd/render.o lcd/display.o: subdirs: $(SUBDIRS)
cd lcd && $(MAKE) ROOT_PATH=../$(ROOT_PATH)
applications/libapp.a: $(SUBDIRS):
cd applications && $(MAKE) ROOT_PATH=../$(ROOT_PATH) $(MAKE) ROOT_PATH=../$(ROOT_PATH) --no-print-directory -C $@
filesystem/libfat.a:
cd filesystem && $(MAKE) ROOT_PATH=../$(ROOT_PATH)
usb/libusb.a:
cd usb && $(MAKE) ROOT_PATH=../$(ROOT_PATH)
funk/libfunk.a:
cd funk && $(MAKE) ROOT_PATH=../$(ROOT_PATH)
../tools/bootloader/lpcfix: ../tools/bootloader/lpcfix:
cd ../tools/bootloader && $(MAKE) cd ../tools/bootloader && $(MAKE)
@ -93,7 +88,7 @@ $(LD_TEMP):
-@echo "}" >> $(LD_TEMP) -@echo "}" >> $(LD_TEMP)
-@echo "INCLUDE $(LD_SCRIPT)" >> $(LD_TEMP) -@echo "INCLUDE $(LD_SCRIPT)" >> $(LD_TEMP)
$(OUTFILE).elf: $(OBJS) $(SYS_OBJS) $(LIBS) $(LPCFIX) $(LD_TEMP) $(OUTFILE).elf: $(OBJS) $(SYS_OBJS) $(SUBDIRS) $(LPCFIX) $(LD_TEMP)
$(CC) $(LDFLAGS) -T $(LD_TEMP) -o $(OUTFILE).elf $(OBJS) $(LDLIBS) $(CC) $(LDFLAGS) -T $(LD_TEMP) -o $(OUTFILE).elf $(OBJS) $(LDLIBS)
-@echo "" -@echo ""
$(SIZE) $(OUTFILE).elf $(SIZE) $(OUTFILE).elf
@ -104,5 +99,5 @@ $(OUTFILE).elf: $(OBJS) $(SYS_OBJS) $(LIBS) $(LPCFIX) $(LD_TEMP)
-@echo "" -@echo ""
$(LPCFIX) -c $@ $(LPCFIX) -c $@
.PHONY: $(LD_TEMP) lcd/liblcd.a applications/libapp.a filesystem/libfat.a usb/libusb.a funk/libfunk.a .PHONY: $(LD_TEMP)

View File

@ -42,4 +42,3 @@ CPU_TYPE = cortex-$(CORTEX_TYPE)
CFLAGS = -std=c99 -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -DRAMCODE=$(RAMCODE) -fno-builtin CFLAGS = -std=c99 -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -DRAMCODE=$(RAMCODE) -fno-builtin
LDFLAGS = -nostartfiles LDFLAGS = -nostartfiles

21
firmware/Makefile.util Normal file
View File

@ -0,0 +1,21 @@
LIBFILE?=lib$(LIBNAME).a
SRCS?= $(foreach mod,$(OBJS),$(subst .o,.c,$(mod)))
DEPFILE?=Makefile.dep
all: $(LIBFILE)
$(LIBFILE): $(OBJS)
$(AR) rcs $@ $(OBJS)
%.o : %.c
$(CC) $(CFLAGS) -o $@ $<
clean:
rm -f $(OBJS) $(LIBFILE) $(CLEANFILES)
depend:
@$(CC) $(CFLAGS) -MM -MF Makefile.dep $(SRCS)
include $(DEPFILE)
$(DEPFILE): depend

31
firmware/basic/Makefile Normal file
View File

@ -0,0 +1,31 @@
##########################################################################
# User configuration and firmware specific object files
##########################################################################
OBJS =
OBJS += basic.o
OBJS += reinvoke_isp.o
OBJS += delayms.o
OBJS += voltage.o
OBJS += keyin.o
OBJS += uuid.o
OBJS += crc.o
LIBNAME=basic
##########################################################################
# GNU GCC compiler flags
##########################################################################
ROOT_PATH?= ..
INCLUDE_PATHS = -I$(ROOT_PATH) -I../core -I.
include $(ROOT_PATH)/Makefile.inc
CFLAGS+=
##########################################################################
# Actual work
##########################################################################
include $(ROOT_PATH)/Makefile.util

View File

@ -20,21 +20,8 @@ INCLUDE_PATHS = -I$(ROOT_PATH) -I../core -I.
include $(ROOT_PATH)/Makefile.inc include $(ROOT_PATH)/Makefile.inc
LIBFILE=lib$(LIBNAME).a
########################################################################## ##########################################################################
# Compiler settings, parameters and flags # Actual work
########################################################################## ##########################################################################
all: $(LIBFILE) include $(ROOT_PATH)/Makefile.util
$(LIBFILE): $(OBJS)
$(AR) rcs $@ $(OBJS)
%.o : %.c
$(CC) $(CFLAGS) -o $@ $<
clean:
rm -f $(OBJS) $(LIBFILE)
ff.o: ff.c ffconf.h diskio.h ff.h integer.h

View File

@ -16,21 +16,8 @@ INCLUDE_PATHS = -I$(ROOT_PATH) -I../core -I.
include $(ROOT_PATH)/Makefile.inc include $(ROOT_PATH)/Makefile.inc
LIBFILE=lib$(LIBNAME).a
########################################################################## ##########################################################################
# Compiler settings, parameters and flags # Actual work
########################################################################## ##########################################################################
all: $(LIBFILE) include $(ROOT_PATH)/Makefile.util
$(LIBFILE): $(OBJS)
$(AR) rcs $@ $(OBJS)
%.o : %.c
$(CC) $(CFLAGS) -o $@ $<
clean:
rm -f $(OBJS) $(LIBFILE)
nrf24l01p.o: nrf24l01p.c nrf24l01p.h

View File

@ -18,19 +18,8 @@ INCLUDE_PATHS = -I$(ROOT_PATH) -I../core -I.
include $(ROOT_PATH)/Makefile.inc include $(ROOT_PATH)/Makefile.inc
LIBFILE=lib$(LIBNAME).a
########################################################################## ##########################################################################
# Compiler settings, parameters and flags # Actual work
########################################################################## ##########################################################################
all: $(LIBFILE) include $(ROOT_PATH)/Makefile.util
$(LIBFILE): $(OBJS)
$(AR) rcs $@ $(OBJS)
%.o : %.c
$(CC) $(CFLAGS) -o $@ $<
clean:
rm -f $(OBJS) $(LIBFILE)