From 5b07efdbeb8b6c6e7c3e5a86a2e55a2de345b579 Mon Sep 17 00:00:00 2001 From: px4dev Date: Sat, 12 Jan 2013 12:10:06 -0800 Subject: Automatically generate depdencies for source files as they are compiled, rather than using the NuttX dependency generator tool. --- apps/mathlib/Makefile | 10 +++++++--- apps/mk/app.mk | 26 +++++++++++++++----------- 2 files changed, 22 insertions(+), 14 deletions(-) (limited to 'apps') diff --git a/apps/mathlib/Makefile b/apps/mathlib/Makefile index e5fab1e35..e3aa9275e 100644 --- a/apps/mathlib/Makefile +++ b/apps/mathlib/Makefile @@ -31,8 +31,6 @@ # ############################################################################ -include $(TOPDIR)/.config - # # Math library # @@ -52,7 +50,13 @@ CXXHDRS = math/test/test.hpp \ math/Dcm.hpp \ math/Matrix.hpp -# XXX this really should be a CONFIG_* test +# +# In order to include .config we first have to save off the +# current makefile name, since app.mk needs it. +# +APP_MAKEFILE := $(lastword $(MAKEFILE_LIST)) +-include $(TOPDIR)/.config + ifeq ($(CONFIG_ARCH_CORTEXM4)$(CONFIG_ARCH_FPU),yy) INCLUDES += math/arm CXXSRCS += math/arm/Vector.cpp \ diff --git a/apps/mk/app.mk b/apps/mk/app.mk index 1d8b0e44c..c5a025394 100644 --- a/apps/mk/app.mk +++ b/apps/mk/app.mk @@ -81,7 +81,9 @@ # Work out who included us so we can report decent errors # THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST)) -PARENT_MAKEFILE := $(lastword $(filter-out $(THIS_MAKEFILE),$(MAKEFILE_LIST))) +ifeq ($(APP_MAKEFILE),) +APP_MAKEFILE := $(lastword $(filter-out $(THIS_MAKEFILE),$(MAKEFILE_LIST))) +endif ############################################################################ # Get configuration @@ -93,7 +95,7 @@ include $(APPDIR)/Make.defs ############################################################################ # Sanity-check the information we've been given and set any defaults # -SRCDIR ?= $(dir $(PARENT_MAKEFILE)) +SRCDIR ?= $(dir $(APP_MAKEFILE)) PRIORITY ?= SCHED_PRIORITY_DEFAULT STACKSIZE ?= CONFIG_PTHREAD_STACK_DEFAULT @@ -112,14 +114,14 @@ endif # there has to be a source file ifeq ($(ASRCS)$(CSRCS)$(CXXSRCS),) -$(error $(realpath $(PARENT_MAKEFILE)): at least one of ASRCS, CSRCS or CXXSRCS must be set) +$(error $(realpath $(APP_MAKEFILE)): at least one of ASRCS, CSRCS or CXXSRCS must be set) endif # check that C++ is configured if we have C++ source files and we are building ifneq ($(CXXSRCS),) ifneq ($(CONFIG_HAVE_CXX),y) ifeq ($(MAKECMDGOALS),build) -$(error $(realpath $(PARENT_MAKEFILE)): cannot set CXXSRCS if CONFIG_HAVE_CXX not set in configuration) +$(error $(realpath $(APP_MAKEFILE)): cannot set CXXSRCS if CONFIG_HAVE_CXX not set in configuration) endif endif endif @@ -153,6 +155,11 @@ COBJS = $(patsubst %.c,%.o,$(CSRCS)) CXXOBJS = $(patsubst %.cpp,%.o,$(CXXSRCS)) OBJS = $(AOBJS) $(COBJS) $(CXXOBJS) +# Automatic depdendency generation +DEPS = $(OBJS:$(OBJEXT)=.d) +CFLAGS += -MD +CXXFLAGS += -MD + # The prelinked object that we are ultimately going to build ifneq ($(APPNAME),) PRELINKOBJ = $(APPNAME).pre.o @@ -186,11 +193,8 @@ all: .built # # Source dependencies # -depend: .depend -.depend: $(MAKEFILE_LIST) $(SRCS) - @$(MKDEP) --dep-path . $(CC) -- $(CFLAGS) -- $(CSRCS) $(CHDRS) >Make.dep - @$(MKDEP) --dep-path . $(CXX) -- $(CXXFLAGS) -- $(CXXSRCS) $(CXXHDRS) >>Make.dep - @touch $@ +depend: + @exit 0 ifneq ($(APPNAME),) # @@ -223,10 +227,10 @@ $(CXXOBJS): %.o : %.cpp # Tidying up # clean: - @rm -f $(OBJS) $(PRELINKOBJ) Make.dep .built + @rm -f $(OBJS) $(DEPS) $(PRELINKOBJ) .built $(call CLEAN) distclean: clean @rm -f Make.dep .depend --include Make.dep +-include $(DEPS) -- cgit v1.2.3 From 1c63eda98bb89d0d206efb88195020f5822d7df8 Mon Sep 17 00:00:00 2001 From: px4dev Date: Sat, 12 Jan 2013 12:39:29 -0800 Subject: Objects depend on the makefile chain as well. --- apps/mk/app.mk | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'apps') diff --git a/apps/mk/app.mk b/apps/mk/app.mk index c5a025394..7cbdc3e62 100644 --- a/apps/mk/app.mk +++ b/apps/mk/app.mk @@ -167,13 +167,9 @@ else PRELINKOBJ = $(LIBNAME).pre.o endif -# The archive that the object file will be placed in # XXX does WINTOOL ever get set? ifeq ($(WINTOOL),y) INCDIROPT = -w - BIN = "$(shell cygpath -w $(APPDIR)/libapps$(LIBEXT))" -else - BIN = "$(APPDIR)/libapps$(LIBEXT)" endif ############################################################################ @@ -206,6 +202,7 @@ context: .context @touch $@ else context: + @exit 0 endif # @@ -214,13 +211,13 @@ endif $(PRELINKOBJ): $(OBJS) $(call PRELINK, $@, $(OBJS)) -$(AOBJS): %.o : %.S +$(AOBJS): %.o : %.S $(MAKEFILE_LIST) $(call ASSEMBLE, $<, $@) -$(COBJS): %.o : %.c +$(COBJS): %.o : %.c $(MAKEFILE_LIST) $(call COMPILE, $<, $@) -$(CXXOBJS): %.o : %.cpp +$(CXXOBJS): %.o : %.cpp $(MAKEFILE_LIST) $(call COMPILEXX, $<, $@) # -- cgit v1.2.3 From dba244a8d48b8367c8ca14abaf5ff3b46ab7ad08 Mon Sep 17 00:00:00 2001 From: px4dev Date: Sat, 12 Jan 2013 12:46:46 -0800 Subject: Fix a build breaker, remove C*HDRS as they aren't used. --- apps/controllib/Makefile | 7 ------- apps/mathlib/Makefile | 12 ------------ apps/mk/app.mk | 4 ++++ 3 files changed, 4 insertions(+), 19 deletions(-) (limited to 'apps') diff --git a/apps/controllib/Makefile b/apps/controllib/Makefile index 99cf91069..6749b805f 100644 --- a/apps/controllib/Makefile +++ b/apps/controllib/Makefile @@ -43,11 +43,4 @@ CXXSRCS = block/Block.cpp \ blocks.cpp \ fixedwing.cpp -CXXHDRS = block/Block.hpp \ - block/BlockParam.hpp \ - block/UOrbPublication.hpp \ - block/UOrbSubscription.hpp \ - blocks.hpp \ - fixedwing.hpp - include $(APPDIR)/mk/app.mk diff --git a/apps/mathlib/Makefile b/apps/mathlib/Makefile index e3aa9275e..7eebd6ae0 100644 --- a/apps/mathlib/Makefile +++ b/apps/mathlib/Makefile @@ -42,14 +42,6 @@ CXXSRCS = math/test/test.cpp \ math/Dcm.cpp \ math/Matrix.cpp -CXXHDRS = math/test/test.hpp \ - math/Vector.hpp \ - math/Vector3.hpp \ - math/EulerAngles.hpp \ - math/Quaternion.hpp \ - math/Dcm.hpp \ - math/Matrix.hpp - # # In order to include .config we first have to save off the # current makefile name, since app.mk needs it. @@ -61,14 +53,10 @@ ifeq ($(CONFIG_ARCH_CORTEXM4)$(CONFIG_ARCH_FPU),yy) INCLUDES += math/arm CXXSRCS += math/arm/Vector.cpp \ math/arm/Matrix.cpp -CXXHDRS += math/arm/Vector.hpp \ - math/arm/Matrix.hpp else INCLUDES += math/generic CXXSRCS += math/generic/Vector.cpp \ math/generic/Matrix.cpp -CXXHDRS += math/generic/Vector.hpp \ - math/generic/Matrix.hpp endif include $(APPDIR)/mk/app.mk diff --git a/apps/mk/app.mk b/apps/mk/app.mk index 7cbdc3e62..fa4a12cab 100644 --- a/apps/mk/app.mk +++ b/apps/mk/app.mk @@ -167,9 +167,13 @@ else PRELINKOBJ = $(LIBNAME).pre.o endif +# The archive the prelinked object will be linked into # XXX does WINTOOL ever get set? ifeq ($(WINTOOL),y) INCDIROPT = -w + BIN = "$(shell cygpath -w $(APPDIR)/libapps$(LIBEXT))" +else + BIN = "$(APPDIR)/libapps$(LIBEXT)" endif ############################################################################ -- cgit v1.2.3