From a4b0e34db7c53f8e989ef9ca1b194629267493ce Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Mon, 2 Mar 2015 16:08:46 +0100 Subject: [PATCH] [build system] use VPATH to specify search path for NPS files add $(PAPARAZZI_SRC)/sw/simulator to VPATH, so that makes adds that to the search path. This makes it possible to add NPS sources as nps/foo.c to $(TARGET).srcs, and the object and dependency files will correctly be put into $(PAPARAZZI_HOME)/var/aircrafts//nps/ So e.g. /home//paparazzi/var/aircrafts/Quad_LisaM_2/nps/nps/nps_main.o While here, also generate the .d dependency files during the compilation run instead of a separate run. fixes #798 --- conf/Makefile.nps | 20 +++++-------------- .../subsystems/rotorcraft/fdm_jsbsim.makefile | 10 ++++++---- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/conf/Makefile.nps b/conf/Makefile.nps index ca309ef70a..b0a5b0e864 100644 --- a/conf/Makefile.nps +++ b/conf/Makefile.nps @@ -27,7 +27,6 @@ SRC_ARCH = arch/sim OPT ?= 2 -SIMDIR = $(PAPARAZZI_SRC)/sw/simulator # Launch with "make Q=''" to get full command display Q=@ @@ -91,29 +90,20 @@ $(OBJDIR)/%.s: %.cpp $(OBJDIR)/%.o: %.c $(OBJDIR)/../Makefile.ac @echo CC $@ $(Q)test -d $(dir $@) || mkdir -p $(dir $@) - $(Q)$(CC) $(CFLAGS) -c -o $@ $< + $(Q)$(CC) -MMD $(CFLAGS) -c -o $@ $< $(OBJDIR)/%.o: %.cpp $(OBJDIR)/../Makefile.ac @echo CXX $@ $(Q)test -d $(dir $@) || mkdir -p $(dir $@) - $(Q)$(CXX) $(CXXFLAGS) -c -o $@ $< + $(Q)$(CXX) -MMD $(CXXFLAGS) -c -o $@ $< .PHONY: all compile check_jsbsim + # # Dependencies # - -$(OBJDIR)/%.d: %.c - @echo DEP $@ - $(Q)test -d $(dir $@) || mkdir -p $(dir $@) - $(Q)$(CC) -MM -MG $(CFLAGS) $< | sed 's|\([^\.]*\.o\)|$(OBJDIR)/\1|' > $(OBJDIR)/$*.d - -$(OBJDIR)/%.d: %.cpp $(OBJDIR)/../Makefile.ac - @echo DEP $@ - $(Q)test -d $(dir $@) || mkdir -p $(dir $@) - $(Q)$(CXX) -MM -MG $(CXXFLAGS) $< | sed 's|\([^\.]*\.o\)|$(OBJDIR)/\1|' > $(OBJDIR)/$*.d - ifneq ($(MAKECMDGOALS),clean) --include $($(TARGET).objs:.o=.d) +DEPS = $(addprefix $(OBJDIR)/,$($(TARGET).srcs:.c=.d)) +-include $(DEPS) endif diff --git a/conf/firmwares/subsystems/rotorcraft/fdm_jsbsim.makefile b/conf/firmwares/subsystems/rotorcraft/fdm_jsbsim.makefile index c1f0e2f103..e80ce496d6 100644 --- a/conf/firmwares/subsystems/rotorcraft/fdm_jsbsim.makefile +++ b/conf/firmwares/subsystems/rotorcraft/fdm_jsbsim.makefile @@ -12,9 +12,6 @@ SRC_FIRMWARE=firmwares/rotorcraft SRC_BOARD=boards/$(BOARD) -NPSDIR = $(SIMDIR)/nps - - nps.ARCHDIR = sim # include Makefile.nps instead of Makefile.sim @@ -23,7 +20,7 @@ nps.MAKEFILE = nps nps.CFLAGS += -DSITL -DUSE_NPS nps.CFLAGS += $(shell pkg-config glib-2.0 --cflags) nps.LDFLAGS += $(shell pkg-config glib-2.0 --libs) -lm -lglibivy $(shell pcre-config --libs) -lgsl -lgslcblas -nps.CFLAGS += -I$(NPSDIR) -I$(SRC_FIRMWARE) -I$(SRC_BOARD) -I../simulator -I$(PAPARAZZI_HOME)/conf/simulator/nps +nps.CFLAGS += -I$(SRC_FIRMWARE) -I$(SRC_BOARD) -I$(PAPARAZZI_SRC)/sw/simulator/nps -I$(PAPARAZZI_HOME)/conf/simulator/nps nps.LDFLAGS += $(shell sdl-config --libs) # use the paparazzi-jsbsim package if it is installed, otherwise look for JSBsim under /opt/jsbsim @@ -37,7 +34,12 @@ else nps.LDFLAGS += -L$(JSBSIM_LIB) -lJSBSim endif +# +# add the simulator directory to the make searchpath +# +VPATH = $(PAPARAZZI_SRC)/sw/simulator +NPSDIR = nps nps.srcs += $(NPSDIR)/nps_main.c \ $(NPSDIR)/nps_fdm_jsbsim.cpp \ $(NPSDIR)/nps_random.c \