# Hey Emacs, this is a -*- makefile -*-

# Installation of the files in the system tree

PREFIX=/
DESTDIR=$(PREFIX)/usr/share/paparazzi
INSTALL=install -o root
INSTALLDATA=install -o root -m 644

install : install_files
# post_install

install_files: install_data install_conf install_bin install_libs install_tools install_airborne_sources

post_install :
	debian/paparazzi-bin.postinst

install_data:
	$(INSTALL) -d $(DESTDIR)/data/maps
	$(INSTALLDATA) data/maps/muret_UTM.xml data/maps/muret_UTM.gif $(DESTDIR)/data/maps
	$(INSTALL) -d $(DESTDIR)/data/pictures/gcs_icons
	$(INSTALLDATA) data/pictures/*.gif data/pictures/*.svg data/pictures/*.jpg data/pictures/*.png $(DESTDIR)/data/pictures
	$(INSTALLDATA) data/pictures/gcs_icons/*.png $(DESTDIR)/data/pictures/gcs_icons
	$(INSTALL) -d $(PREFIX)/usr/share/pixmaps
	$(INSTALLDATA) data/pictures/penguin_icon.png $(PREFIX)/usr/share/pixmaps/paparazzi.png
	$(INSTALL) -d $(DESTDIR)/data/srtm


install_conf:
	$(INSTALL) -d $(DESTDIR)/conf
	$(INSTALLDATA) conf/conf.xml.example $(DESTDIR)/conf/conf.xml
	$(INSTALLDATA) conf/control_panel.xml.example $(DESTDIR)/conf/control_panel.xml
	$(INSTALLDATA) conf/messages.xml $(DESTDIR)/conf/
	$(INSTALLDATA) conf/messages.dtd $(DESTDIR)/conf/
	$(INSTALLDATA) conf/gui.xml $(DESTDIR)/conf/
	$(INSTALL) -d $(DESTDIR)/conf/airframes
	$(INSTALLDATA) conf/airframes/airframe.dtd $(DESTDIR)/conf/airframes
	$(INSTALLDATA) conf/airframes/microjet_example.xml $(DESTDIR)/conf/airframes
	$(INSTALLDATA) conf/airframes/twinstar_example.xml $(DESTDIR)/conf/airframes
	$(INSTALLDATA) conf/airframes/twinjet_example.xml $(DESTDIR)/conf/airframes
	$(INSTALLDATA) conf/airframes/example_twog_analogimu.xml $(DESTDIR)/conf/airframes
	$(INSTALL) -d $(DESTDIR)/conf/autopilot
	$(INSTALLDATA) conf/autopilot/*.makefile $(DESTDIR)/conf/autopilot
	$(INSTALLDATA) conf/autopilot/*.h $(DESTDIR)/conf/autopilot
	$(INSTALL) -d $(DESTDIR)/conf/autopilot/subsystems
	$(INSTALLDATA) conf/autopilot/subsystems/*.makefile $(DESTDIR)/conf/autopilot/subsystems
	$(INSTALL) -d $(DESTDIR)/conf/autopilot/subsystems/fixedwing
	$(INSTALLDATA) conf/autopilot/subsystems/fixedwing/*.makefile $(DESTDIR)/conf/autopilot/subsystems/fixedwing
	$(INSTALL) -d $(DESTDIR)/conf/autopilot/subsystems/rotorcraft
	$(INSTALLDATA) conf/autopilot/subsystems/rotorcraft/*.makefile $(DESTDIR)/conf/autopilot/subsystems/rotorcraft
	$(INSTALL) -d $(DESTDIR)/conf/autopilot/subsystems/shared
	$(INSTALLDATA) conf/autopilot/subsystems/shared/*.makefile $(DESTDIR)/conf/autopilot/subsystems/shared
	$(INSTALL) -d $(DESTDIR)/conf/flight_plans
	$(INSTALLDATA) conf/flight_plans/*.dtd $(DESTDIR)/conf/flight_plans
	$(INSTALLDATA) conf/flight_plans/*.xml $(DESTDIR)/conf/flight_plans
	$(INSTALL) -d $(DESTDIR)/conf/modules
	$(INSTALLDATA) conf/modules/*.dtd $(DESTDIR)/conf/modules
	$(INSTALLDATA) conf/modules/*.xml $(DESTDIR)/conf/modules
	$(INSTALL) -d $(DESTDIR)/conf/gps
	$(INSTALLDATA) conf/gps/Makefile $(DESTDIR)/conf/gps
	$(INSTALLDATA) conf/gps/ublox_conf.c $(DESTDIR)/conf/gps
	$(INSTALLDATA) conf/gps/README $(DESTDIR)/conf/gps
	$(INSTALLDATA) conf/gps/*.inf $(DESTDIR)/conf/gps
	$(INSTALLDATA) conf/gps/*.txt $(DESTDIR)/conf/gps
	$(INSTALL) -d $(DESTDIR)/conf/radios
	$(INSTALLDATA) conf/radios/radio.dtd $(DESTDIR)/conf/radios
	$(INSTALLDATA) conf/radios/*.xml $(DESTDIR)/conf/radios
	$(INSTALL) -d $(DESTDIR)/conf/telemetry
	$(INSTALLDATA) conf/telemetry/telemetry.dtd $(DESTDIR)/conf/telemetry
	$(INSTALLDATA) conf/telemetry/*.xml $(DESTDIR)/conf/telemetry
	$(INSTALL) -d $(DESTDIR)/conf/settings
	$(INSTALLDATA) conf/settings/settings.dtd $(DESTDIR)/conf/settings
	$(INSTALLDATA) conf/settings/*.xml $(DESTDIR)/conf/settings
	$(INSTALL) -d $(DESTDIR)/conf/gcs
	$(INSTALLDATA) conf/gcs/layout.dtd $(DESTDIR)/conf/gcs
	$(INSTALLDATA) conf/gcs/*.xml $(DESTDIR)/conf/gcs
	$(INSTALL) -d $(PREFIX)/etc/udev/rules.d
	$(INSTALLDATA) conf/system/udev/rules/*.rules $(PREFIX)/etc/udev/rules.d
	$(INSTALL) -d $(PREFIX)/etc/modprobe.d
	$(INSTALLDATA) conf/system/modprobe.d/paparazzi $(PREFIX)/etc/modprobe.d
	$(INSTALL) -d $(PREFIX)/usr/share/applications
	$(INSTALLDATA) debian/paparazzi.desktop $(PREFIX)/usr/share/applications


install_bin:
	$(INSTALL) -d $(PREFIX)/usr/bin/
	$(INSTALL) -d $(DESTDIR)/sw/supervision
	$(INSTALL) sw/supervision/paparazzicenter.glade $(DESTDIR)/sw/supervision
	$(INSTALL) sw/supervision/*.cmo $(DESTDIR)/sw/supervision
	$(INSTALL) paparazzi-make $(PREFIX)/usr/bin/
	$(INSTALLDATA) -d $(DESTDIR)/sw/simulator
	$(INSTALL) sw/simulator/*.cmo $(DESTDIR)/sw/simulator
	$(INSTALL) sw/simulator/pprzsim-launch $(DESTDIR)/sw/simulator
	$(INSTALL) -d  $(DESTDIR)/sw/ground_segment/cockpit
	$(INSTALL) -d  $(DESTDIR)/sw/ground_segment/tmtc
	$(INSTALL) -d  $(DESTDIR)/sw/ground_segment/multimon
	$(INSTALLDATA) sw/ground_segment/cockpit/*.cmo $(DESTDIR)/sw/ground_segment/cockpit
	$(INSTALLDATA) sw/ground_segment/cockpit/gcs.glade $(DESTDIR)/sw/ground_segment/cockpit
	$(INSTALLDATA) sw/ground_segment/tmtc/*.cmo $(DESTDIR)/sw/ground_segment/tmtc
	$(INSTALL) sw/ground_segment/tmtc/boa $(DESTDIR)/sw/ground_segment/tmtc
	$(INSTALLDATA) sw/ground_segment/multimon/multimon.cma $(DESTDIR)/sw/ground_segment/multimon
	$(INSTALLDATA) sw/ground_segment/multimon/libmultimon.a $(DESTDIR)/sw/ground_segment/multimon
	$(INSTALLDATA) sw/ground_segment/multimon/dllmultimon.so $(DESTDIR)/sw/ground_segment/multimon
	$(INSTALL) -d  $(DESTDIR)/sw/logalizer
	$(INSTALLDATA) sw/logalizer/*.cm[ox] $(DESTDIR)/sw/logalizer
	$(INSTALLDATA) sw/logalizer/*.o $(DESTDIR)/sw/logalizer
	$(INSTALLDATA) sw/logalizer/export.glade $(DESTDIR)/sw/logalizer
	ln -sf ../share/paparazzi/sw/supervision/paparazzicenter $(PREFIX)/usr/bin/paparazzi

install_libs:
	$(INSTALL) -d $(DESTDIR)/sw/lib/ocaml
	$(INSTALLDATA) sw/lib/ocaml/*.cma $(DESTDIR)/sw/lib/ocaml
	$(INSTALLDATA) sw/lib/ocaml/*.cmxa $(DESTDIR)/sw/lib/ocaml
	$(INSTALLDATA) sw/lib/ocaml/*.so $(DESTDIR)/sw/lib/ocaml
	$(INSTALLDATA) sw/lib/ocaml/*.a $(DESTDIR)/sw/lib/ocaml
	$(INSTALLDATA) sw/lib/ocaml/*.cmi $(DESTDIR)/sw/lib/ocaml
	$(INSTALLDATA) sw/lib/ocaml/myGtkInit.cmo $(DESTDIR)/sw/lib/ocaml
	$(INSTALLDATA) sw/lib/ocaml/widgets.glade $(DESTDIR)/sw/lib/ocaml

install_tools:
	$(INSTALLDATA) Makefile.ac $(DESTDIR)
	$(INSTALLDATA) conf/Makefile* $(DESTDIR)/conf
	$(INSTALL) -d $(DESTDIR)/sw/tools/
	$(INSTALL) sw/tools/*.out $(DESTDIR)/sw/tools/
	rm -f $(DESTDIR)/sw/tools/gen_flight_plan.out
	$(INSTALLDATA) sw/tools/fp_proc.cmo $(DESTDIR)/sw/tools
	$(INSTALLDATA) sw/tools/gen_flight_plan.cmo $(DESTDIR)/sw/tools
	$(INSTALLDATA) sw/tools/gen_aircraft.ml $(DESTDIR)/sw/tools/
	$(INSTALLDATA) sw/tools/gen_airframe.ml $(DESTDIR)/sw/tools/
	$(INSTALLDATA) sw/tools/gen_messages.ml $(DESTDIR)/sw/tools/
	$(INSTALLDATA) sw/tools/gen_periodic.ml $(DESTDIR)/sw/tools/
	$(INSTALLDATA) sw/tools/gen_radio.ml $(DESTDIR)/sw/tools/
	$(INSTALLDATA) sw/tools/gen_settings.ml $(DESTDIR)/sw/tools/
	$(INSTALLDATA) sw/tools/gen_ubx.ml $(DESTDIR)/sw/tools/
	$(INSTALLDATA) sw/tools/gen_mtk.ml $(DESTDIR)/sw/tools/
	$(INSTALLDATA) sw/tools/gen_xsens.ml $(DESTDIR)/sw/tools/
	$(INSTALLDATA) sw/tools/gen_modules.ml $(DESTDIR)/sw/tools/
	$(INSTALLDATA) sw/tools/gen_common.cmo $(DESTDIR)/sw/tools/
	$(INSTALL) -d $(DESTDIR)/sw/tools/calibration
	$(INSTALLDATA) sw/tools/calibration/calibrate.py $(DESTDIR)/sw/tools/calibration
	$(INSTALLDATA) sw/tools/calibration/calibrate_gyro.py $(DESTDIR)/sw/tools/calibration
	$(INSTALLDATA) sw/tools/calibration/calibration_utils.py $(DESTDIR)/sw/tools/calibration
	$(INSTALLDATA) sw/tools/calibration/README $(DESTDIR)/sw/tools/calibration
	$(INSTALL) -d $(DESTDIR)/sw/ground_segment/lpc21iap
	$(INSTALL) sw/ground_segment/lpc21iap/lpc21iap $(DESTDIR)/sw/ground_segment/lpc21iap/
	$(INSTALL) -d $(DESTDIR)/sw/simulator
	$(INSTALLDATA) sw/simulator/sitl.cma  $(DESTDIR)/sw/simulator
	$(INSTALLDATA) sw/simulator/simsitl.ml  $(DESTDIR)/sw/simulator
	$(INSTALLDATA) sw/simulator/sim.cmi  $(DESTDIR)/sw/simulator
	$(INSTALLDATA) sw/simulator/sitl.cmi  $(DESTDIR)/sw/simulator
	$(INSTALLDATA) sw/simulator/libsitl.a  $(DESTDIR)/sw/simulator
	$(INSTALL) sw/simulator/simhitl  $(DESTDIR)/sw/simulator

install_airborne_sources:
	$(INSTALL) -d $(DESTDIR)/sw/
	tar -cf - sw/airborne/ | tar -C $(DESTDIR) -xf -
	$(INSTALL) -d $(DESTDIR)/sw/include
	$(INSTALLDATA) sw/include/std.h $(DESTDIR)/sw/include
	$(INSTALLDATA) var/include/*.h $(DESTDIR)/sw/include
