From 51accc5fb08c37dc69ff8c5baa0740777673725a Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Thu, 17 Jan 2013 15:22:53 +0100 Subject: [PATCH] [build_system] removing duplicates for all airborne targets should work now. pkg-config and the like need to be expanded via $(shell instead of using backquotes. No spaces between -I and dir for generated module includes" --- conf/firmwares/subsystems/fixedwing/autopilot.makefile | 4 ++-- .../subsystems/rotorcraft/fdm_jsbsim.makefile | 10 +++++----- sw/airborne/Makefile | 9 +++++++++ sw/airborne/fms/Makefile | 4 ++-- sw/airborne/test/ahrs/Makefile | 4 ++-- sw/tools/gen_aircraft.ml | 4 ++-- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/conf/firmwares/subsystems/fixedwing/autopilot.makefile b/conf/firmwares/subsystems/fixedwing/autopilot.makefile index b92c3581316..b1e0f91fa58 100644 --- a/conf/firmwares/subsystems/fixedwing/autopilot.makefile +++ b/conf/firmwares/subsystems/fixedwing/autopilot.makefile @@ -219,8 +219,8 @@ jsbsim.CFLAGS += -DSITL jsbsim.srcs += $(SIMDIR)/sim_ac_jsbsim.c $(SIMDIR)/sim_ac_fw.c $(SIMDIR)/sim_ac_flightgear.c # external libraries -jsbsim.CFLAGS += -I$(SIMDIR) -I/usr/include -I$(JSBSIM_INC) -I$(OCAMLLIBDIR) `pkg-config glib-2.0 --cflags` -jsbsim.LDFLAGS += `pkg-config glib-2.0 --libs` -lglibivy -lm -L/usr/lib -lJSBSim +jsbsim.CFLAGS += -I$(SIMDIR) -I/usr/include -I$(JSBSIM_INC) -I$(OCAMLLIBDIR) $(shell pkg-config glib-2.0 --cflags) +jsbsim.LDFLAGS += $(shell pkg-config glib-2.0 --libs) -lglibivy -lm -L/usr/lib -lJSBSim jsbsim.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=IvyTransport jsbsim.srcs += subsystems/datalink/downlink.c $(SRC_FIRMWARE)/datalink.c $(SRC_ARCH)/jsbsim_hw.c $(SRC_ARCH)/jsbsim_ir.c $(SRC_ARCH)/jsbsim_gps.c $(SRC_ARCH)/jsbsim_ahrs.c $(SRC_ARCH)/ivy_transport.c $(SRC_ARCH)/jsbsim_transport.c diff --git a/conf/firmwares/subsystems/rotorcraft/fdm_jsbsim.makefile b/conf/firmwares/subsystems/rotorcraft/fdm_jsbsim.makefile index 4f060952890..2499018d7a5 100644 --- a/conf/firmwares/subsystems/rotorcraft/fdm_jsbsim.makefile +++ b/conf/firmwares/subsystems/rotorcraft/fdm_jsbsim.makefile @@ -21,18 +21,18 @@ nps.ARCHDIR = sim nps.MAKEFILE = nps nps.CFLAGS += -DSITL -DUSE_NPS -nps.CFLAGS += `pkg-config glib-2.0 --cflags` -nps.LDFLAGS += `pkg-config glib-2.0 --libs` -lm -lglibivy -lgsl -lgslcblas +nps.CFLAGS += $(shell pkg-config glib-2.0 --cflags) +nps.LDFLAGS += $(shell pkg-config glib-2.0 --libs) -lm -lglibivy -lgsl -lgslcblas nps.CFLAGS += -I$(NPSDIR) -I$(SRC_FIRMWARE) -I$(SRC_BOARD) -I../simulator -I$(PAPARAZZI_HOME)/conf/simulator/nps -nps.LDFLAGS += `sdl-config --libs` +nps.LDFLAGS += $(shell sdl-config --libs) # use the paparazzi-jsbsim package if it is installed, otherwise look for JSBsim under /opt/jsbsim ifndef JSBSIM_PKG JSBSIM_PKG = $(shell pkg-config JSBSim --exists && echo 'yes') endif ifeq ($(JSBSIM_PKG), yes) - nps.CFLAGS += `pkg-config JSBSim --cflags` - nps.LDFLAGS += `pkg-config JSBSim --libs` + nps.CFLAGS += $(shell pkg-config JSBSim --cflags) + nps.LDFLAGS += $(shell pkg-config JSBSim --libs) else JSBSIM_PKG = no nps.CFLAGS += -I$(JSBSIM_INC) diff --git a/sw/airborne/Makefile b/sw/airborne/Makefile index 6103d785bed..ae60d2915f7 100644 --- a/sw/airborne/Makefile +++ b/sw/airborne/Makefile @@ -44,6 +44,15 @@ ifneq ($(MAKECMDGOALS),clean) include ../../conf/Makefile.$($(TARGET).ARCHDIR) endif endif + + # sort cflags and sources to throw out duplicates + # + #$(info CFLAGS_orig = $($(TARGET).CFLAGS)) + #$(info CFLAGS_sort = $(sort $($(TARGET).CFLAGS))) + #$(info srcs_orig = $($(TARGET).srcs)) + #$(info srcs_sort = $(sort $($(TARGET).srcs))) + $(TARGET).CFLAGS := $(sort $($(TARGET).CFLAGS)) + $(TARGET).srcs := $(sort $($(TARGET).srcs)) endif # check for obsolete MODEM_UART_NR and GPS_UART_NR makefile vars diff --git a/sw/airborne/fms/Makefile b/sw/airborne/fms/Makefile index 21795d25a33..6e568312f71 100644 --- a/sw/airborne/fms/Makefile +++ b/sw/airborne/fms/Makefile @@ -1,6 +1,6 @@ -CFLAGS = -Wall `pkg-config --cflags glib-2.0` -g -LDFLAGS = `pkg-config --libs glib-2.0` +CFLAGS = -Wall $(shell pkg-config --cflags glib-2.0) -g +LDFLAGS = $(shell pkg-config --libs glib-2.0) fms: fms_main.c fms_ap_link.c fms_serial_port.c fms_gs_link.c fms_network.c $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) diff --git a/sw/airborne/test/ahrs/Makefile b/sw/airborne/test/ahrs/Makefile index 9603fb946c4..7904f638e83 100644 --- a/sw/airborne/test/ahrs/Makefile +++ b/sw/airborne/test/ahrs/Makefile @@ -145,8 +145,8 @@ run_ahrs_on_synth: run_ahrs_on_synth.c $(RAOS_SRCS) $(AHRS_SRCS) @echo "Building run_ahrs_on_synth for $(AHRS_TYPE)" $(Q) $(CC) $(CFLAGS) $(AHRS_CFLAGS) -o $@ $^ $(LDFLAGS) -IVY_CFLAGS=-g -O2 -Wall `pkg-config glib-2.0 --cflags` -IVY_LDFLAGS=`pkg-config glib-2.0 --libs` -lglibivy +IVY_CFLAGS=-g -O2 -Wall $(shell pkg-config glib-2.0 --cflags) +IVY_LDFLAGS=$(shell pkg-config glib-2.0 --libs) -lglibivy run_ahrs_on_synth_ivy: run_ahrs_on_synth_ivy.c $(RAOS_SRCS) $(AHRS_SRCS) $(CC) $(CFLAGS) $(AHRS_CFLAGS) $(IVY_CFLAGS) -o $@ $^ $(LDFLAGS) $(IVY_LDFLAGS) diff --git a/sw/tools/gen_aircraft.ml b/sw/tools/gen_aircraft.ml index 964f416901a..0ffa0a5e72d 100644 --- a/sw/tools/gen_aircraft.ml +++ b/sw/tools/gen_aircraft.ml @@ -84,10 +84,10 @@ let dump_module_section = fun xml f -> let dir_list = Gen_common.get_modules_dir modules in (** let target_list = union_of_lists (List.map (fun (m,_) -> get_targets_of_module m) modules) in - List.iter (fun target -> fprintf f "%s.CFLAGS += -I modules -I arch/$(ARCH)/modules\n" target) target_list; + List.iter (fun target -> fprintf f "%s.CFLAGS += -Imodules -Iarch/$(ARCH)/modules\n" target) target_list; **) (** include modules directory for ALL targets and not just the defined ones **) - fprintf f "$(TARGET).CFLAGS += -I modules -I arch/$(ARCH)/modules\n"; + fprintf f "$(TARGET).CFLAGS += -Imodules -Iarch/$(ARCH)/modules\n"; List.iter (fun dir -> let dir_name = (String.uppercase dir)^"_DIR" in fprintf f "%s = modules/%s\n" dir_name dir) dir_list; (* parse each module *) List.iter (fun m ->