Optimize Makefiles (add auto-dependencies),
and convert basic/ into a lib like the other subdirs
This commit is contained in:
parent
2985d1b9f5
commit
f941dd5451
|
@ -3,3 +3,4 @@ firmware.elf
|
|||
lpc1xxx/memory.ld
|
||||
applications/wrapper.c
|
||||
lcd/allfonts.h
|
||||
Makefile.dep
|
||||
|
|
|
@ -1,15 +1,21 @@
|
|||
VPATH =
|
||||
OBJS = main.o
|
||||
OBJS =
|
||||
LIBS =
|
||||
|
||||
##########################################################################
|
||||
# Project-specific files
|
||||
##########################################################################
|
||||
|
||||
VPATH +=
|
||||
OBJS +=
|
||||
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 += core/libcore.a lcd/liblcd.a applications/libapp.a filesystem/libfat.a usb/libusb.a funk/libfunk.a
|
||||
OBJS += main.o
|
||||
|
||||
LIBS += lcd/liblcd.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
|
||||
|
@ -32,9 +38,12 @@ LDLIBS += -Lfunk -lfunk
|
|||
LDLIBS += -Llcd -llcd
|
||||
LDLIBS += -Lusb -lusb
|
||||
LDLIBS += -Lfilesystem -lfat
|
||||
LDLIBS += -Lbasic -lbasic
|
||||
LDLIBS += -Lcore -lcore
|
||||
OCFLAGS = --strip-unneeded
|
||||
|
||||
SUBDIRS?= $(foreach lib,$(LIBS),$(dir $(lib)))
|
||||
|
||||
LD_PATH = lpc1xxx
|
||||
LD_SCRIPT = $(LD_PATH)/linkscript.ld
|
||||
LD_TEMP = $(LD_PATH)/memory.ld
|
||||
|
@ -51,36 +60,22 @@ loadables: $(OUTFILE).bin
|
|||
|
||||
clean:
|
||||
rm -f $(OBJS) $(LD_TEMP) $(OUTFILE).elf $(OUTFILE).bin $(OUTFILE).hex
|
||||
@cd core && $(MAKE) clean
|
||||
@cd ../tools/bootloader && $(MAKE) clean
|
||||
@cd lcd && $(MAKE) clean
|
||||
@cd applications && $(MAKE) clean
|
||||
@cd filesystem && $(MAKE) clean
|
||||
@cd usb && $(MAKE) clean
|
||||
@cd loadable && $(MAKE) clean
|
||||
for dir in $(SUBDIRS); do \
|
||||
$(MAKE) --no-print-directory -C $$dir clean; \
|
||||
done
|
||||
|
||||
### Internal targets
|
||||
|
||||
%.o : %.c
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
core/libcore.a: core/projectconfig.h
|
||||
cd core && $(MAKE) ROOT_PATH=../$(ROOT_PATH)
|
||||
### Make all libraries...
|
||||
.PHONY: subdirs $(SUBDIRS)
|
||||
|
||||
lcd/liblcd.a lcd/render.o lcd/display.o:
|
||||
cd lcd && $(MAKE) ROOT_PATH=../$(ROOT_PATH)
|
||||
subdirs: $(SUBDIRS)
|
||||
|
||||
applications/libapp.a:
|
||||
cd applications && $(MAKE) ROOT_PATH=../$(ROOT_PATH)
|
||||
|
||||
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)
|
||||
$(SUBDIRS):
|
||||
$(MAKE) ROOT_PATH=../$(ROOT_PATH) --no-print-directory -C $@
|
||||
|
||||
../tools/bootloader/lpcfix:
|
||||
cd ../tools/bootloader && $(MAKE)
|
||||
|
@ -93,7 +88,7 @@ $(LD_TEMP):
|
|||
-@echo "}" >> $(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)
|
||||
-@echo ""
|
||||
$(SIZE) $(OUTFILE).elf
|
||||
|
@ -104,5 +99,5 @@ $(OUTFILE).elf: $(OBJS) $(SYS_OBJS) $(LIBS) $(LPCFIX) $(LD_TEMP)
|
|||
-@echo ""
|
||||
$(LPCFIX) -c $@
|
||||
|
||||
.PHONY: $(LD_TEMP) lcd/liblcd.a applications/libapp.a filesystem/libfat.a usb/libusb.a funk/libfunk.a
|
||||
.PHONY: $(LD_TEMP)
|
||||
|
||||
|
|
|
@ -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
|
||||
LDFLAGS = -nostartfiles
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -20,21 +20,8 @@ INCLUDE_PATHS = -I$(ROOT_PATH) -I../core -I.
|
|||
|
||||
include $(ROOT_PATH)/Makefile.inc
|
||||
|
||||
LIBFILE=lib$(LIBNAME).a
|
||||
##########################################################################
|
||||
# Compiler settings, parameters and flags
|
||||
# Actual work
|
||||
##########################################################################
|
||||
|
||||
all: $(LIBFILE)
|
||||
|
||||
$(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
|
||||
|
||||
include $(ROOT_PATH)/Makefile.util
|
||||
|
|
|
@ -16,21 +16,8 @@ INCLUDE_PATHS = -I$(ROOT_PATH) -I../core -I.
|
|||
|
||||
include $(ROOT_PATH)/Makefile.inc
|
||||
|
||||
LIBFILE=lib$(LIBNAME).a
|
||||
##########################################################################
|
||||
# Compiler settings, parameters and flags
|
||||
# Actual work
|
||||
##########################################################################
|
||||
|
||||
all: $(LIBFILE)
|
||||
|
||||
$(LIBFILE): $(OBJS)
|
||||
$(AR) rcs $@ $(OBJS)
|
||||
|
||||
%.o : %.c
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(LIBFILE)
|
||||
|
||||
nrf24l01p.o: nrf24l01p.c nrf24l01p.h
|
||||
|
||||
include $(ROOT_PATH)/Makefile.util
|
||||
|
|
|
@ -18,19 +18,8 @@ INCLUDE_PATHS = -I$(ROOT_PATH) -I../core -I.
|
|||
|
||||
include $(ROOT_PATH)/Makefile.inc
|
||||
|
||||
LIBFILE=lib$(LIBNAME).a
|
||||
##########################################################################
|
||||
# Compiler settings, parameters and flags
|
||||
# Actual work
|
||||
##########################################################################
|
||||
|
||||
all: $(LIBFILE)
|
||||
|
||||
$(LIBFILE): $(OBJS)
|
||||
$(AR) rcs $@ $(OBJS)
|
||||
|
||||
%.o : %.c
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) $(LIBFILE)
|
||||
|
||||
include $(ROOT_PATH)/Makefile.util
|
||||
|
|
Loading…
Reference in New Issue