Skip to content

Commit

Permalink
[build system] clean up makefiles and fix dependencies, parallel buil…
Browse files Browse the repository at this point in the history
…d with make -j 8 seems to work now
  • Loading branch information
flixr committed Nov 10, 2012
1 parent 3dd4353 commit 8bff1b4
Show file tree
Hide file tree
Showing 26 changed files with 438 additions and 239 deletions.
198 changes: 100 additions & 98 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Hey Emacs, this is a -*- makefile -*-
#
# Paparazzi main $Id$
# Copyright (C) 2004 Pascal Brisset Antoine Drouin
#
# This file is part of paparazzi.
Expand Down Expand Up @@ -38,18 +37,49 @@ ifeq ($(PAPARAZZI_HOME),)
PAPARAZZI_HOME=$(PAPARAZZI_SRC)
endif

# export the PAPARAZZI environment to sub-make
export PAPARAZZI_SRC
export PAPARAZZI_HOME

OCAML=$(shell which ocaml)
OCAMLRUN=$(shell which ocamlrun)
BUILD_DATETIME:=$(shell date +%Y%m%d-%H%M%S)

#
# define some paths
#
LIB=sw/lib
STATICINCLUDE =$(PAPARAZZI_HOME)/var/include
CONF=$(PAPARAZZI_SRC)/conf
AIRBORNE=sw/airborne
SIMULATOR=sw/simulator
MULTIMON=sw/ground_segment/multimon
COCKPIT=sw/ground_segment/cockpit
TMTC=sw/ground_segment/tmtc
MULTIMON=sw/ground_segment/multimon
TOOLS=$(PAPARAZZI_SRC)/sw/tools
EXT=sw/ext

#
# build some stuff in subdirs
# nothing should depend on these...
#
PPRZCENTER=sw/supervision
MISC=sw/ground_segment/misc
LOGALIZER=sw/logalizer
SIMULATOR=sw/simulator
EXT=sw/ext
MAKE=make PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME)
CONF=$(PAPARAZZI_SRC)/conf
STATICINCLUDE =$(PAPARAZZI_HOME)/var/include

SUBDIRS = $(PPRZCENTER) $(MISC) $(LOGALIZER)

#
# xml files used as input for header generation
#
MESSAGES_XML = $(CONF)/messages.xml
UBX_XML = $(CONF)/ubx.xml
MTK_XML = $(CONF)/mtk.xml
XSENS_XML = $(CONF)/xsens_MTi-G.xml

#
# generated header files
#
MESSAGES_H=$(STATICINCLUDE)/messages.h
MESSAGES2_H=$(STATICINCLUDE)/messages2.h
UBX_PROTOCOL_H=$(STATICINCLUDE)/ubx_protocol.h
Expand All @@ -58,79 +88,72 @@ XSENS_PROTOCOL_H=$(STATICINCLUDE)/xsens_protocol.h
DL_PROTOCOL_H=$(STATICINCLUDE)/dl_protocol.h
DL_PROTOCOL2_H=$(STATICINCLUDE)/dl_protocol2.h
ABI_MESSAGES_H=$(STATICINCLUDE)/abi_messages.h
MESSAGES_XML = $(CONF)/messages.xml
UBX_XML = $(CONF)/ubx.xml
MTK_XML = $(CONF)/mtk.xml
XSENS_XML = $(CONF)/xsens_MTi-G.xml
TOOLS=$(PAPARAZZI_SRC)/sw/tools
OCAML=$(shell which ocaml)
OCAMLRUN=$(shell which ocamlrun)
BUILD_DATETIME:=$(shell date +%Y%m%d-%H%M%S)

GEN_HEADERS = $(MESSAGES_H) $(MESSAGES2_H) $(UBX_PROTOCOL_H) $(MTK_PROTOCOL_H) $(XSENS_PROTOCOL_H) $(DL_PROTOCOL_H) $(DL_PROTOCOL2_H) $(ABI_MESSAGES_H)

all: print_build_version conf commands static

all: print_build_version update_google_version conf ext lib subdirs lpctools commands static

print_build_version:
@echo "------------------------------------------------------------"
@echo "Building Paparazzi version" $(shell ./paparazzi_version)
@echo "------------------------------------------------------------"

static: lib center tools cockpit multimon tmtc misc logalizer lpc21iap sim_static static_h usb_lib ext
update_google_version:
-$(MAKE) -C data/maps

conf: conf/conf.xml conf/control_panel.xml conf/maps.xml FORCE
conf: conf/conf.xml conf/control_panel.xml conf/maps.xml

conf/%.xml :conf/%.xml.example
[ -L $@ ] || [ -f $@ ] || cp $< $@

conf/maps.xml: conf/maps.xml.example FORCE
-cd data/maps; $(MAKE)
$(Q)if test ! -e $@; then cp $< $@; fi

FORCE:
static: cockpit tmtc tools sim_static static_h

lib:
cd $(LIB)/ocaml; $(MAKE)
$(MAKE) -C $(LIB)/ocaml

center: lib
cd sw/supervision; $(MAKE)
multimon:
$(MAKE) -C $(MULTIMON)

tools: lib
cd $(TOOLS); $(MAKE)
cockpit: lib
$(MAKE) -C $(COCKPIT)

logalizer: lib
cd $(LOGALIZER); $(MAKE)
tmtc: lib cockpit multimon
$(MAKE) -C $(TMTC)

sim_static : lib
cd $(SIMULATOR); $(MAKE) PAPARAZZI_SRC=$(PAPARAZZI_SRC)
tools: lib
$(MAKE) -C $(TOOLS)

cockpit: lib
cd $(COCKPIT); $(MAKE) all
sim_static: lib
$(MAKE) -C $(SIMULATOR)

tmtc: lib cockpit
cd $(TMTC); $(MAKE) all
ext:
$(MAKE) -C $(EXT)

misc:
cd $(MISC); $(MAKE) all
#
# make misc subdirs
#
subdirs: $(SUBDIRS)

multimon:
cd $(MULTIMON); $(MAKE)
$(SUBDIRS):
$(MAKE) -C $@

static_h: $(MESSAGES_H) $(MESSAGES2_H) $(UBX_PROTOCOL_H) $(MTK_PROTOCOL_H) $(XSENS_PROTOCOL_H) $(DL_PROTOCOL_H) $(DL_PROTOCOL2_H) $(ABI_MESSAGES_H)
$(PPRZCENTER): lib

usb_lib:
@[ -d sw/airborne/arch/lpc21/lpcusb ] && (cd sw/airborne/arch/lpc21/lpcusb; $(MAKE)) || echo "Not building usb_lib: sw/airborne/arch/lpc21/lpcusb directory missing"
$(LOGALIZER): lib

ext:
$(MAKE) -C$(EXT) all

$(MESSAGES_H) : $(MESSAGES_XML) $(CONF_XML) tools
static_h: $(GEN_HEADERS)

$(MESSAGES_H) : $(MESSAGES_XML) tools
$(Q)test -d $(STATICINCLUDE) || mkdir -p $(STATICINCLUDE)
@echo BUILD $@
$(Q)PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) $(TOOLS)/gen_messages.out $< telemetry > /tmp/msg.h
$(Q)mv /tmp/msg.h $@
$(Q)chmod a+r $@

$(MESSAGES2_H) : $(MESSAGES_XML) $(CONF_XML) tools
$(MESSAGES2_H) : $(MESSAGES_XML) tools
$(Q)test -d $(STATICINCLUDE) || mkdir -p $(STATICINCLUDE)
@echo BUILD $@
$(Q)PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) $(TOOLS)/gen_messages2.out $< telemetry > /tmp/msg2.h
Expand Down Expand Up @@ -167,48 +190,31 @@ $(ABI_MESSAGES_H) : $(MESSAGES_XML) tools
$(Q)PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME) $(TOOLS)/gen_abi.out $< airborne > /tmp/abi.h
$(Q)mv /tmp/abi.h $@


include Makefile.ac

sim : sim_static
ac_h ac fbw ap: static conf tools ext

sim: sim_static

ac_h ac1 ac2 ac3 ac fbw ap: static conf

##### preliminary hard wired arm7 bootloader rules
#
# Commands
#
# call with : make bl PROC=[TINY|FBW|AP|GENERIC]
bl:
cd $(AIRBORNE)/arch/lpc21/test/bootloader; $(MAKE) clean; $(MAKE)

BOOTLOADER_DEV=/dev/ttyUSB0
upload_bl bl.upload: bl
lpc21isp -control $(AIRBORNE)/arch/lpc21/test/bootloader/bl.hex $(BOOTLOADER_DEV) 38400 12000
# stuff to build and upload the lpc bootloader ...
include Makefile.lpctools
lpctools: lpc21iap usb_lib

JTAG_INTERFACE = olimex-jtag-tiny.cfg
#JTAG_INTERFACE = olimex-arm-usb-ocd.cfg

upload_jtag: bl
openocd -f interface/$(JTAG_INTERFACE) -f board/olimex_lpc_h2148.cfg -c init -c halt -c "flash write_image erase $(AIRBORNE)/arch/lpc21/test/bootloader/bl.hex" -c reset -c shutdown



lpc21iap:
cd sw/ground_segment/lpc21iap; $(MAKE)

upgrade_bl bl.upgrade: bl lpc21iap
$(PAPARAZZI_SRC)/sw/ground_segment/lpc21iap/lpc21iap $(AIRBORNE)/arch/lpc21/test/bootloader/bl_ram.elf
$(PAPARAZZI_SRC)/sw/ground_segment/lpc21iap/lpc21iap $(AIRBORNE)/arch/lpc21/test/bootloader/bl.elf

ms:
cd $(AIRBORNE)/arch/lpc21/lpcusb; $(MAKE)
cd $(AIRBORNE)/arch/lpc21/lpcusb/examples; $(MAKE)
commands: paparazzi sw/simulator/launchsitl

upload_ms ms.upload: ms
$(PAPARAZZI_SRC)/sw/ground_segment/lpc21iap/lpc21iap $(AIRBORNE)/arch/lpc21/lpcusb/examples/msc.elf
paparazzi:
cat src/paparazzi | sed s#OCAMLRUN#$(OCAMLRUN)# | sed s#OCAML#$(OCAML)# > $@
chmod a+x $@

#####
#####
sw/simulator/launchsitl:
cat src/$(@F) | sed s#OCAMLRUN#$(OCAMLRUN)# | sed s#OCAML#$(OCAML)# > $@
chmod a+x $@

run_sitl :
$(PAPARAZZI_HOME)/var/$(AIRCRAFT)/sim/simsitl
Expand All @@ -219,21 +225,16 @@ install :
uninstall :
$(MAKE) -f Makefile.install PREFIX=$(PREFIX) uninstall

DISTRO=lenny
deb :
chmod u+x debian/rules
cp debian/control.$(DISTRO) debian/control
cp debian/changelog.$(DISTRO) debian/changelog
dpkg-buildpackage $(DEBFLAGS) -Ivar -rfakeroot

fast_deb:
$(MAKE) deb OCAMLC=ocamlc.opt DEBFLAGS=-b
#
# Cleaning
#

clean:
$(Q)rm -fr dox build-stamp configure-stamp conf/%gconf.xml debian/files debian/paparazzi-base debian/paparazzi-bin
$(Q)rm -f $(MESSAGES_H) $(MESSAGES2_H) $(UBX_PROTOCOL_H) $(MTK_PROTOCOL_H) $(DL_PROTOCOL_H)
$(Q)rm -f $(GEN_HEADERS)
$(Q)find . -mindepth 2 -name Makefile -a ! -path "./sw/ext/*" -exec sh -c 'echo "Cleaning {}"; $(MAKE) -C `dirname {}` $@' \;
$(Q)make -C sw/ext clean
$(Q)$(MAKE) -C $(EXT) clean
$(Q)find . -name '*~' -exec rm -f {} \;
$(Q)rm -f paparazzi sw/simulator/launchsitl

Expand All @@ -256,26 +257,27 @@ dist_clean_irreversible: clean
ab_clean:
find sw/airborne -name '*~' -exec rm -f {} \;


#
# Tests
#

replace_current_conf_xml:
test conf/conf.xml && mv conf/conf.xml conf/conf.xml.backup.$(BUILD_DATETIME)
cp conf/tests_conf.xml conf/conf.xml

restore_conf_xml:
test conf/conf.xml.backup.$(BUILD_DATETIME) && mv conf/conf.xml.backup.$(BUILD_DATETIME) conf/conf.xml

commands: paparazzi sw/simulator/launchsitl

paparazzi:
cat src/paparazzi | sed s#OCAMLRUN#$(OCAMLRUN)# | sed s#OCAML#$(OCAML)# > $@
chmod a+x $@

sw/simulator/launchsitl:
cat src/$(@F) | sed s#OCAMLRUN#$(OCAMLRUN)# | sed s#OCAML#$(OCAML)# > $@
chmod a+x $@

run_tests:
cd tests; $(MAKE) test

test: all replace_current_conf_xml run_tests restore_conf_xml

.PHONY: all print_build_version clean cleanspaces ab_clean dist_clean distclean dist_clean_irreversible run_sitl install uninstall test replace_current_conf_xml run_tests restore_conf_xml

.PHONY: all print_build_version update_google_version \
subdirs $(SUBDIRS) conf ext lib multimon cockpit tmtc tools\
static sim_static lpctools \
commands run_sitl install uninstall \
clean cleanspaces ab_clean dist_clean distclean dist_clean_irreversible \
test replace_current_conf_xml run_tests restore_conf_xml
5 changes: 2 additions & 3 deletions Makefile.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Hey Emacs, this is a -*- makefile -*-
# Paparazzi main $Id$
#
# Copyright (C) 2004 Pascal Brisset Antoine Drouin
#
# This file is part of paparazzi.
Expand Down Expand Up @@ -47,7 +47,6 @@ SETTINGS_XML=$(ACINCLUDE)/settings.xml
SETTINGS_MODULES=$(ACINCLUDE)/settings_modules.xml
SETTINGS_TELEMETRY=$(ACINCLUDE)/settings_telemetry.xml
MAKEFILE_AC=$(ACINCLUDE)/Makefile.ac
MAKE=make PAPARAZZI_SRC=$(PAPARAZZI_SRC) PAPARAZZI_HOME=$(PAPARAZZI_HOME)
MODULES_H=$(AC_GENERATED)/modules.h
AIRCRAFT_MD5=$(AIRCRAFT_CONF_DIR)/aircraft.md5

Expand Down Expand Up @@ -183,4 +182,4 @@ clean_ac :
$(Q)if (expr "$(AIRCRAFT)"); then : ; else echo "AIRCRAFT undefined: type 'make AIRCRAFT=AircraftName ...'"; exit 1; fi
rm -fr $(PAPARAZZI_HOME)/var/$(AIRCRAFT)

.PHONY: all clean_ac print_version
.PHONY: all init all_ac_h all_ac_hclean_ac print_version
35 changes: 35 additions & 0 deletions Makefile.lpctools
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Hey Emacs, this is a -*- makefile -*-

usb_lib:
@[ -d sw/airborne/arch/lpc21/lpcusb ] && (cd sw/airborne/arch/lpc21/lpcusb; $(MAKE)) || echo "Not building usb_lib: sw/airborne/arch/lpc21/lpcusb directory missing"

bl:
cd $(AIRBORNE)/arch/lpc21/test/bootloader; $(MAKE) clean; $(MAKE)

BOOTLOADER_DEV=/dev/ttyUSB0
upload_bl bl.upload: bl
lpc21isp -control $(AIRBORNE)/arch/lpc21/test/bootloader/bl.hex $(BOOTLOADER_DEV) 38400 12000

JTAG_INTERFACE = olimex-jtag-tiny.cfg
#JTAG_INTERFACE = olimex-arm-usb-ocd.cfg

upload_jtag: bl
openocd -f interface/$(JTAG_INTERFACE) -f board/olimex_lpc_h2148.cfg -c init -c halt -c "flash write_image erase $(AIRBORNE)/arch/lpc21/test/bootloader/bl.hex" -c reset -c shutdown



lpc21iap:
$(MAKE) -C sw/ground_segment/lpc21iap

upgrade_bl bl.upgrade: bl lpc21iap
$(PAPARAZZI_SRC)/sw/ground_segment/lpc21iap/lpc21iap $(AIRBORNE)/arch/lpc21/test/bootloader/bl_ram.elf
$(PAPARAZZI_SRC)/sw/ground_segment/lpc21iap/lpc21iap $(AIRBORNE)/arch/lpc21/test/bootloader/bl.elf

ms:
$(MAKE) -C $(AIRBORNE)/arch/lpc21/lpcusb
$(MAKE) -C $(AIRBORNE)/arch/lpc21/lpcusb/examples

upload_ms ms.upload: ms
$(PAPARAZZI_SRC)/sw/ground_segment/lpc21iap/lpc21iap $(AIRBORNE)/arch/lpc21/lpcusb/examples/msc.elf

.PHONY: usb_lib bl upload_bl upload_jtag ms upload_ms lpc21iap upgrade_bl
Loading

0 comments on commit 8bff1b4

Please sign in to comment.