[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/<ac>/nps/<src file>
So e.g. /home/<user>/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
This commit is contained in:
Felix Ruess
2015-03-02 16:08:46 +01:00
parent f6e129069a
commit a4b0e34db7
2 changed files with 11 additions and 19 deletions
+5 -15
View File
@@ -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
@@ -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 \