-
Notifications
You must be signed in to change notification settings - Fork 392
/
Makefile
1108 lines (964 loc) · 36.8 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Makefile for Taulabs project
.DEFAULT_GOAL := help
WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST)))
ROOT_DIR := $(realpath $(WHEREAMI)/ )
# import macros common to all supported build systems
include $(ROOT_DIR)/make/system-id.mk
# configure some directories that are relative to wherever ROOT_DIR is located
TOOLS_DIR := $(ROOT_DIR)/tools
BUILD_DIR := $(ROOT_DIR)/build
DL_DIR := $(ROOT_DIR)/downloads
export RM := rm
export CCACHE_BIN := $(shell which ccache 2>/dev/null)
# import macros that are OS specific
include $(ROOT_DIR)/make/$(OSFAMILY).mk
# include the tools makefile
include $(ROOT_DIR)/make/tools.mk
# make sure this isn't being run as root, not relevant for windows
ifndef WINDOWS
# Deal with unreasonable requests
# See: http://xkcd.com/149/
ifeq ($(MAKECMDGOALS),me a sandwich)
ifeq ($(shell whoami),root)
$(error Okay)
else
$(error What? Make it yourself)
endif
endif
# Seriously though, you shouldn't ever run this as root
ifeq ($(shell whoami),root)
$(error You should not be running this as root)
endif
endif
# Function for converting an absolute path to one relative
# to the top of the source tree.
toprel = $(subst $(realpath $(ROOT_DIR))/,,$(abspath $(1)))
# Clean out undesirable variables from the environment and command-line
# to remove the chance that they will cause problems with our build
define SANITIZE_VAR
$(if $(filter-out undefined,$(origin $(1))),
$(info *NOTE* Sanitized $(2) variable '$(1)' from $(origin $(1)))
MAKEOVERRIDES = $(filter-out $(1)=%,$(MAKEOVERRIDES))
override $(1) :=
unexport $(1)
)
endef
# These specific variables can influence gcc in unexpected (and undesirable) ways
SANITIZE_GCC_VARS := TMPDIR GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH
SANITIZE_GCC_VARS += CFLAGS CPATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH OBJC_INCLUDE_PATH DEPENDENCIES_OUTPUT
SANITIZE_GCC_VARS += ARCHFLAGS
$(foreach var, $(SANITIZE_GCC_VARS), $(eval $(call SANITIZE_VAR,$(var),disallowed)))
# These specific variables used to be valid but now they make no sense
SANITIZE_DEPRECATED_VARS := USE_BOOTLOADER
$(foreach var, $(SANITIZE_DEPRECATED_VARS), $(eval $(call SANITIZE_VAR,$(var),deprecated)))
# Decide on a verbosity level based on the V= parameter
export AT := @
ifndef V
export V0 :=
export V1 := $(AT)
else ifeq ($(V), 0)
export V0 := $(AT)
export V1 := $(AT)
else ifeq ($(V), 1)
endif
ALL_BOARDS :=
include $(ROOT_DIR)/flight/targets/*/target-defs.mk
# OpenPilot GCS build configuration (debug | release)
GCS_BUILD_CONF ?= debug
# And the flight build configuration (debug | default | release)
export FLIGHT_BUILD_CONF ?= default
##############################
#
# Check that environmental variables are sane
#
##############################
# Checking for $(ANDROIDGCS_BUILD_CONF) to be sane
ifdef ANDROIDGCS_BUILD_CONF
ifneq ($(ANDROIDGCS_BUILD_CONF), release)
ifneq ($(ANDROIDGCS_BUILD_CONF), debug)
$(error Only debug or release are allowed for ANDROIDGCS_BUILD_CONF)
endif
endif
endif
# Checking for $(GCS_BUILD_CONF) to be sane
ifdef GCS_BUILD_CONF
ifneq ($(GCS_BUILD_CONF), release)
ifneq ($(GCS_BUILD_CONF), debug)
$(error Only debug or release are allowed for GCS_BUILD_CONF)
endif
endif
endif
ifdef FLIGHT_BUILD_CONF
ifneq ($(FLIGHT_BUILD_CONF), release)
ifneq ($(FLIGHT_BUILD_CONF), debug)
ifneq ($(FLIGHT_BUILD_CONF), default)
$(error Only debug or release are allowed for FLIGHT_BUILD_CONF)
endif
endif
endif
endif
##############################
#
# Help instructions
#
##############################
.PHONY: help
help:
@echo
@echo " This Makefile is known to work on Linux and Mac in a standard shell environment."
@echo " It also works on Windows by following the instructions in make/winx86/README.txt."
@echo
@echo " Here is a summary of the available targets:"
@echo
@echo " [Tool Installers]"
@echo " qt_sdk_install - Install the Qt tools"
@echo " arm_sdk_install - Install the GNU ARM gcc toolchain"
@echo " openocd_install - Install the OpenOCD SWD/JTAG daemon"
@echo " \$$OPENOCD_FTDI - Set to no in order not to install legacy FTDI support for OpenOCD."
@echo " stm32flash_install - Install the stm32flash tool for unbricking boards"
@echo " dfuutil_install - Install the dfu-util tool for unbricking F4-based boards"
@echo " android_sdk_install - Install the Android SDK tools"
@echo " gtest_install - Install the google unit test suite"
@echo " astyle_install - Install the astyle code formatter (deprecated)"
@echo " uncrustify_install - Install the uncrustify code formatter"
@echo " openssl_install - Install the openssl libraries on windows machines"
@echo
@echo " [Big Hammer]"
@echo " all - Generate UAVObjects, build openpilot firmware and gcs"
@echo " all_flight - Build all firmware, bootloaders and bootloader updaters"
@echo " all_fw - Build only firmware for all boards"
@echo " all_bl - Build only bootloaders for all boards"
@echo " all_bu - Build only bootloader updaters for all boards"
@echo
@echo " all_clean - Remove your build directory ($(BUILD_DIR))"
@echo " all_flight_clean - Remove all firmware, bootloaders and bootloader updaters"
@echo " all_fw_clean - Remove firmware for all boards"
@echo " all_bl_clean - Remove bootlaoders for all boards"
@echo " all_bu_clean - Remove bootloader updaters for all boards"
@echo
@echo " all_<board> - Build all available images for <board>"
@echo " all_<board>_clean - Remove all available images for <board>"
@echo
@echo " all_ut - Build all unit tests"
@echo " all_ut_tap - Run all unit tests and capture all TAP output to files"
@echo " all_ut_run - Run all unit tests and dump TAP output to console"
@echo
@echo " [Firmware]"
@echo " <board> - Build firmware for <board>"
@echo " supported boards are ($(ALL_BOARDS))"
@echo " fw_<board> - Build firmware for <board>"
@echo " supported boards are ($(FW_BOARDS))"
@echo " fw_<board>_clean - Remove firmware for <board>"
@echo " fw_<board>_program - Use OpenOCD + SWD/JTAG to write firmware to <board>"
@echo " fw_<board>_wipe - Use OpenOCD + SWD/JTAG to wipe entire firmware section on <board>"
@echo
@echo " [Bootloader]"
@echo " bl_<board> - Build bootloader for <board>"
@echo " supported boards are ($(BL_BOARDS))"
@echo " bl_<board>_clean - Remove bootloader for <board>"
@echo " bl_<board>_program - Use OpenOCD + SWD/JTAG to write bootloader to <board>"
@echo
@echo " [Entire Flash]"
@echo " ef_<board> - Build entire flash image for <board>"
@echo " supported boards are ($(EF_BOARDS))"
@echo " ef_<board>_clean - Remove entire flash image for <board>"
@echo " ef_<board>_program - Use OpenOCD + SWD/JTAG to write entire flash image to <board>"
@echo
@echo " [Bootloader Updater]"
@echo " bu_<board> - Build bootloader updater for <board>"
@echo " supported boards are ($(BU_BOARDS))"
@echo " bu_<board>_clean - Remove bootloader updater for <board>"
@echo
@echo " [Unbrick a board]"
@echo " unbrick_<board> - Use the STM32's built in boot ROM to write a bootloader to <board>"
@echo " supported boards are ($(BL_BOARDS))"
@echo " [Unit tests]"
@echo " ut_<test> - Build unit test <test>"
@echo " ut_<test>_tap - Run test and capture TAP output into a file"
@echo " ut_<test>_run - Run test and dump TAP output to console"
@echo
@echo " [Simulation]"
@echo " simulation - Build host simulation firmware"
@echo " simulation_clean - Delete all build output for the simulation"
@echo
@echo " [GCS]"
@echo " gcs - Build the Ground Control System (GCS) application"
@echo " GCS_QMAKE_OPTS= - Optional build flags with the following arguments:"
@echo " \"CONFIG+=LIGHTWEIGHT_GCS\" - Build a lightweight GCS suitable for low-powered platforms"
@echo " \"CONFIG+=SDL\" - Enable joystick and gamepad support"
@echo " \"CONFIG+=OSG\" - Enable OpenSceneGraph support"
@echo " \"CONFIG+=KML\" - Enable KML file support"
@echo " gcs_clean - Remove the Ground Control System (GCS) application"
@echo
@echo " [AndroidGCS]"
@echo " androidgcs - Build the Ground Control System (GCS) application"
@echo " androidgcs_install - Use ADB to install the Ground Control System (GCS) application"
@echo " androidgcs_run - Run the Ground Control System (GCS) application"
@echo " androidgcs_clean - Remove the Ground Control System (GCS) application"
@echo
@echo " [UAVObjects]"
@echo " uavobjects - Generate source files from the UAVObject definition XML files"
@echo " uavobjects_test - parse xml-files - check for valid, duplicate ObjId's, ... "
@echo
@echo " [Package]"
@echo " package - Executes a make all_clean and then generates a complete package build for"
@echo " standalone - Executes a make all_clean and compiles a package without packaging"
@echo " the GCS and all target board firmwares."
@echo
@echo " [Misc]"
@echo " astyle_flight FILE=<name> - Executes the astyle code formatter to reformat"
@echo " a c source file (deprecated)"
@echo " uncrustify_flight FILE=<name> - Executes uncrustify to reformat a c source"
@echo " file according to the flight code style"
@echo
@echo " Hint: Add V=1 to your command line to see verbose build output."
@echo
@echo " Note: All tools will be installed into $(TOOLS_DIR)"
@echo " All build output will be placed in $(BUILD_DIR)"
@echo
.PHONY: all
all: all_ground all_flight
.PHONY: all_clean
all_clean:
[ ! -d "$(BUILD_DIR)" ] || $(RM) -r "$(BUILD_DIR)"
$(DL_DIR):
mkdir -p $@
$(TOOLS_DIR):
mkdir -p $@
$(BUILD_DIR):
mkdir -p $@
##############################
#
# GCS related components
#
##############################
USE_MSVC ?= NO
ifeq ($(USE_MSVC), YES)
QT_SPEC=win32-msvc2013
endif
.PHONY: all_ground
all_ground: gcs
ifndef WINDOWS
# unfortunately the silent linking command is broken on windows
ifeq ($(V), 1)
GCS_SILENT :=
else
GCS_SILENT := silent
endif
endif
.PHONY: gcs
gcs: uavobjects
ifeq ($(USE_MSVC), NO)
$(V1) mkdir -p $(BUILD_DIR)/ground/$@
$(V1) ( cd $(BUILD_DIR)/ground/$@ && \
PYTHON=$(PYTHON) $(QMAKE) $(ROOT_DIR)/ground/gcs/gcs.pro -spec $(QT_SPEC) -r CONFIG+="$(GCS_BUILD_CONF) $(GCS_SILENT)" $(GCS_QMAKE_OPTS) && \
$(MAKE) --no-print-directory -w ; \
)
else
$(V1) mkdir -p $(BUILD_DIR)/ground/$@
$(V1) ( cd $(BUILD_DIR)/ground/$@ && \
PYTHON=$(PYTHON) $(QMAKE) $(ROOT_DIR)/ground/gcs/gcs.pro -spec $(QT_SPEC) -r CONFIG+="$(GCS_BUILD_CONF) $(GCS_SILENT)" $(GCS_QMAKE_OPTS) && \
MAKEFLAGS= jom $(JOM_OPTIONS); \
)
endif
# Workaround for qmake bug that prevents copying the application icon
ifneq (,$(filter $(UNAME), Darwin))
$(V1) ( cd $(BUILD_DIR)/ground/gcs/src/app && \
$(MAKE) ../../bin/Tau\ Labs\ GCS.app/Contents/Resources/taulabs.icns && \
$(MAKE) ../../bin/Tau\ Labs\ GCS.app/Contents/Info.plist ; \
)
endif
.PHONY: gcs_clean
gcs_clean:
$(V0) @echo " CLEAN $@"
$(V1) [ ! -d "$(BUILD_DIR)/ground/gcs" ] || $(RM) -r "$(BUILD_DIR)/ground/gcs"
ifndef WINDOWS
# unfortunately the silent linking command is broken on windows
ifeq ($(V), 1)
UAVOGEN_SILENT :=
else
UAVOGEN_SILENT := silent
endif
endif
.PHONY: uavobjgenerator
uavobjgenerator:
$(V1) mkdir -p $(BUILD_DIR)/ground/$@
ifeq ($(USE_MSVC), NO)
$(V1) ( cd $(BUILD_DIR)/ground/$@ && \
PYTHON=$(PYTHON) $(QMAKE) $(ROOT_DIR)/ground/uavobjgenerator/uavobjgenerator.pro -spec $(QT_SPEC) -r CONFIG+="debug $(UAVOGEN_SILENT)" && \
$(MAKE) --no-print-directory -w; \
)
else
$(V1) ( cd $(BUILD_DIR)/ground/$@ && \
PYTHON=$(PYTHON) $(QMAKE) $(ROOT_DIR)/ground/uavobjgenerator/uavobjgenerator.pro -spec $(QT_SPEC) -r CONFIG+="debug $(UAVOGEN_SILENT)" && \
MAKEFLAGS= jom $(JOM_OPTIONS); \
)
endif
UAVOBJ_XML_DIR := $(ROOT_DIR)/shared/uavobjectdefinition
UAVOBJ_OUT_DIR := $(BUILD_DIR)/uavobject-synthetics
uavobjects: uavobjgenerator
$(V1) mkdir -p $(UAVOBJ_OUT_DIR)
$(V1) ( cd $(UAVOBJ_OUT_DIR) && \
$(UAVOBJGENERATOR) $(UAVOBJ_XML_DIR) $(ROOT_DIR) ; \
)
uavobjects_test: uavobjgenerator
$(V1) $(UAVOBJGENERATOR) -v -none $(UAVOBJ_XML_DIR) $(ROOT_DIR)
uavobjects_clean: uavobjects_armsoftfp_clean uavobjects_armhardfp_clean
$(V0) @echo " CLEAN $@"
$(V1) [ ! -d "$(UAVOBJ_OUT_DIR)" ] || $(RM) -r "$(UAVOBJ_OUT_DIR)"
##############################
#
# Matlab related components
#
##############################
MATLAB_OUT_DIR := $(BUILD_DIR)/matlab
$(MATLAB_OUT_DIR):
$(V1) mkdir -p $@
FORCE:
$(MATLAB_OUT_DIR)/LogConvert.m: $(MATLAB_OUT_DIR) uavobjects FORCE
$(V1) $(PYTHON) $(ROOT_DIR)/make/scripts/version-info.py \
--path=$(ROOT_DIR) \
--template=$(BUILD_DIR)/uavobject-synthetics/matlab/LogConvert.m.pass1 \
--outfile=$@ \
--uavodir=$(ROOT_DIR)/shared/uavobjectdefinition
.PHONY: matlab
matlab: uavobjects $(MATLAB_OUT_DIR)/LogConvert.m
################################
#
# Android GCS related components
#
################################
ANDROIDGCS_BUILD_CONF ?= debug
# Build the output directory for the Android GCS build
ANDROIDGCS_OUT_DIR := $(BUILD_DIR)/androidgcs
$(ANDROIDGCS_OUT_DIR):
$(V1) mkdir -p $@
# Build the asset directory for the android assets
ANDROIDGCS_ASSETS_DIR := $(ANDROIDGCS_OUT_DIR)/assets
$(ANDROIDGCS_ASSETS_DIR)/uavos:
$(V1) mkdir -p $@
ifeq ($(V), 1)
ANT_QUIET := -d
ANDROID_SILENT :=
else
ANT_QUIET := -q
ANDROID_SILENT := -s
endif
.PHONY: androidgcs
androidgcs: $(ANDROIDGCS_OUT_DIR)/bin/androidgcs-$(ANDROIDGCS_BUILD_CONF).apk
$(ANDROIDGCS_OUT_DIR)/bin/androidgcs-$(ANDROIDGCS_BUILD_CONF).apk: uavo-collections_java
$(V0) @echo " ANDROID $(call toprel, $(ANDROIDGCS_OUT_DIR))"
$(V1) mkdir -p $(ANDROIDGCS_OUT_DIR)
$(V1) $(ANDROID) $(ANDROID_SILENT) update project --subprojects --target 'Google Inc.:Google APIs:19' --name androidgcs --path ./androidgcs
$(V1) ant -f ./androidgcs/google-play-services_lib/build.xml \
$(ANT_QUIET) debug
$(V1) ant -f ./androidgcs/build.xml \
$(ANT_QUIET) \
-Dout.dir="../$(call toprel, $(ANDROIDGCS_OUT_DIR)/bin)" \
-Dgen.absolute.dir="$(ANDROIDGCS_OUT_DIR)/gen" \
$(ANDROIDGCS_BUILD_CONF)
.PHONY: androidgcs_run
androidgcs_run: androidgcs_install
$(V0) @echo " AGCS RUN "
$(V1) $(ANDROID_ADB) shell am start -n org.taulabs.androidgcs/.HomePage
.PHONY: androidgcs_install
androidgcs_install: $(ANDROIDGCS_OUT_DIR)/bin/androidgcs-$(ANDROIDGCS_BUILD_CONF).apk
$(V0) @echo " AGCS INST "
$(V1) $(ANDROID_ADB) install -r $(ANDROIDGCS_OUT_DIR)/bin/androidgcs-$(ANDROIDGCS_BUILD_CONF).apk
.PHONY: androidgcs_clean
androidgcs_clean:
$(V0) @echo " CLEAN $@"
$(V1) [ ! -d "$(ANDROIDGCS_OUT_DIR)" ] || $(RM) -r "$(ANDROIDGCS_OUT_DIR)"
# We want to take snapshots of the UAVOs at each point that they change
# to allow the GCS to be compatible with as many versions as possible.
#
# Find the git hashes of each commit that changes uavobjects with:
# git log --format=%h -- shared/uavobjectdefinition/ | head -n 6 | tr '\n' ' '
UAVO_GIT_VERSIONS := HEAD
# All versions includes a pseudo collection called "working" which represents
# the UAVOs in the source tree
UAVO_ALL_VERSIONS := $(sort $(UAVO_GIT_VERSIONS) srctree)
# This is where the UAVO collections are stored
UAVO_COLLECTION_DIR := $(BUILD_DIR)/uavo-collections
# $(1) git hash of a UAVO snapshot
define UAVO_COLLECTION_GIT_TEMPLATE
# Make the output directory that will contain all of the synthetics for the
# uavo collection referenced by the git hash $(1)
$$(UAVO_COLLECTION_DIR)/$(1):
$$(V1) mkdir -p $$(UAVO_COLLECTION_DIR)/$(1)
# Extract the snapshot of shared/uavobjectdefinition from git hash $(1)
$$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml.tar: | $$(UAVO_COLLECTION_DIR)/$(1)
$$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml.tar:
$$(V0) @echo " UAVOTAR $(1)"
$$(V1) git archive $(1) -o $$@ -- shared/uavobjectdefinition/
# Extract the uavo xml files from our snapshot
$$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml: $$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml.tar
$$(V0) @echo " UAVOUNTAR $(1)"
$$(V1) rm -rf $$@
$$(V1) mkdir -p $$@
$$(V1) tar -C $$(call toprel, $$@) -xf $$(call toprel, $$<) || rm -rf $$@
endef
# Map the current working directory into the set of UAVO collections
$(UAVO_COLLECTION_DIR)/srctree:
$(V1) mkdir -p $@
$(UAVO_COLLECTION_DIR)/srctree/uavo-xml: | $(UAVO_COLLECTION_DIR)/srctree
$(UAVO_COLLECTION_DIR)/srctree/uavo-xml: $(UAVOBJ_XML_DIR)
$(V1) ln -sf $(ROOT_DIR) $(UAVO_COLLECTION_DIR)/srctree/uavo-xml
# $(1) git hash (or symbolic name) of a UAVO snapshot
define UAVO_COLLECTION_BUILD_TEMPLATE
# This leaves us with a (broken) symlink that points to the full sha1sum of the collection
$$(UAVO_COLLECTION_DIR)/$(1)/uavohash: $$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml
# Compute the sha1 hash for this UAVO collection
# The sed bit truncates the UAVO hash to 16 hex digits
$$(V1) $(PYTHON) $$(ROOT_DIR)/make/scripts/version-info.py \
--path=$$(ROOT_DIR) \
--uavodir=$$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml/shared/uavobjectdefinition \
--format='$$$${UAVOSHA1TXT}' | \
sed -e 's|\(................\).*|\1|' > $$@
$$(V0) @echo " UAVOHASH $(1) ->" $$$$(cat $$(UAVO_COLLECTION_DIR)/$(1)/uavohash)
# Generate the java uavobjects for this UAVO collection
$$(UAVO_COLLECTION_DIR)/$(1)/java-build/java: $$(UAVO_COLLECTION_DIR)/$(1)/uavohash uavobjgenerator
$$(V0) @echo " UAVOJAVA $(1) " $$$$(cat $$(UAVO_COLLECTION_DIR)/$(1)/uavohash)
$$(V1) ( \
mkdir -p $$(UAVO_COLLECTION_DIR)/$(1)/java-build && \
cd $$(UAVO_COLLECTION_DIR)/$(1)/java-build && \
$$(UAVOBJGENERATOR) -java $$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml/shared/uavobjectdefinition $$(ROOT_DIR) ; \
)
# Build a jar file for this UAVO collection
$$(UAVO_COLLECTION_DIR)/$(1)/java-build/uavobjects.jar: | $$(ANDROIDGCS_ASSETS_DIR)/uavos
$$(UAVO_COLLECTION_DIR)/$(1)/java-build/uavobjects.jar: $$(UAVO_COLLECTION_DIR)/$(1)/java-build/java
$$(V0) @echo " UAVOJAR $(1) " $$$$(cat $$(UAVO_COLLECTION_DIR)/$(1)/uavohash)
$$(V1) ( \
HASH=$$$$(cat $$(UAVO_COLLECTION_DIR)/$(1)/uavohash) && \
cd $$(UAVO_COLLECTION_DIR)/$(1)/java-build && \
javac -source 1.6 -target 1.6 java/*.java \
$$(ROOT_DIR)/androidgcs/src/org/taulabs/uavtalk/UAVDataObject.java \
$$(ROOT_DIR)/androidgcs/src/org/taulabs/uavtalk/UAVObject*.java \
$$(ROOT_DIR)/androidgcs/src/org/taulabs/uavtalk/UAVMetaObject.java \
-d . && \
find ./org/taulabs/uavtalk/uavobjects -type f -name '*.class' > classlist.txt && \
jar cf tmp_uavobjects.jar @classlist.txt && \
$$(ANDROID_DX) \
--dex \
--output $$(ANDROIDGCS_ASSETS_DIR)/uavos/$$$${HASH}.jar \
tmp_uavobjects.jar && \
ln -sf $$(ANDROIDGCS_ASSETS_DIR)/uavos/$$$${HASH}.jar uavobjects.jar \
)
# Generate the matlab uavobjects for this UAVO collection
$$(UAVO_COLLECTION_DIR)/$(1)/matlab-build/matlab: $$(UAVO_COLLECTION_DIR)/$(1)/uavohash uavobjgenerator
$$(V0) @echo " UAVOMATLAB $(1) " $$$$(cat $$(UAVO_COLLECTION_DIR)/$(1)/uavohash)
$$(V1) mkdir -p $$@
$$(V1) ( \
cd $$(UAVO_COLLECTION_DIR)/$(1)/matlab-build && \
$$(UAVOBJGENERATOR) -matlab $$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml/shared/uavobjectdefinition $$(ROOT_DIR) ; \
)
# Build a jar file for this UAVO collection
$$(UAVO_COLLECTION_DIR)/$(1)/matlab-build/LogConvert.m: $$(UAVO_COLLECTION_DIR)/$(1)/matlab-build/matlab
$$(V0) @echo " UAVOMAT $(1) " $$$$(cat $$(UAVO_COLLECTION_DIR)/$(1)/uavohash)
$$(V1) ( \
HASH=$$$$(cat $$(UAVO_COLLECTION_DIR)/$(1)/uavohash) && \
cd $$(UAVO_COLLECTION_DIR)/$(1)/matlab-build && \
$(PYTHON) $(ROOT_DIR)/make/scripts/version-info.py \
--path=$$(ROOT_DIR) \
--template=$$(UAVO_COLLECTION_DIR)/$(1)/matlab-build/matlab/LogConvert.m.pass1 \
--outfile=$$@ \
--uavodir=$$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml/shared/uavobjectdefinition \
)
endef
# One of these for each element of UAVO_GIT_VERSIONS so we can extract the UAVOs from git
$(foreach githash, $(UAVO_GIT_VERSIONS), $(eval $(call UAVO_COLLECTION_GIT_TEMPLATE,$(githash))))
# One of these for each UAVO_ALL_VERSIONS which includes the ones in the srctree
$(foreach githash, $(UAVO_ALL_VERSIONS), $(eval $(call UAVO_COLLECTION_BUILD_TEMPLATE,$(githash))))
.PHONY: uavo-collections_java
uavo-collections_java: $(foreach githash, $(UAVO_ALL_VERSIONS), $(UAVO_COLLECTION_DIR)/$(githash)/java-build/uavobjects.jar)
.PHONY: uavo-collections_matlab
uavo-collections_matlab: $(foreach githash, $(UAVO_ALL_VERSIONS), $(UAVO_COLLECTION_DIR)/$(githash)/matlab-build/LogConvert.m)
.PHONY: uavo-collections
uavo-collections: uavo-collections_java
.PHONY: uavo-collections_clean
uavo-collections_clean:
$(V0) @echo " CLEAN $(UAVO_COLLECTION_DIR)"
$(V1) [ ! -d "$(UAVO_COLLECTION_DIR)" ] || $(RM) -r $(UAVO_COLLECTION_DIR)
##############################
#
# Flight related components
#
##############################
# Define some pointers to the various important pieces of the flight code
# to prevent these being repeated in every sub makefile
MAKE_INC_DIR := $(ROOT_DIR)/make
PIOS := $(ROOT_DIR)/flight/PiOS
FLIGHTLIB := $(ROOT_DIR)/flight/Libraries
OPMODULEDIR := $(ROOT_DIR)/flight/Modules
OPUAVOBJ := $(ROOT_DIR)/flight/UAVObjects
OPUAVTALK := $(ROOT_DIR)/flight/UAVTalk
DOXYGENDIR := $(ROOT_DIR)/flight/Doc/Doxygen
SHAREDAPIDIR := $(ROOT_DIR)/shared/api
OPUAVSYNTHDIR := $(BUILD_DIR)/uavobject-synthetics/flight
# $(1) = Canonical board name all in lower case (e.g. coptercontrol)
# $(2) = Unused
# $(3) = Short name for board (e.g. CC)
# $(4) = Host sim variant (e.g. posix)
# $(5) = Build output type (e.g. elf, exe)
.PHONY: simulation
simulation: sim_posix
# Legacy for people who were using the old target name
.PHONY: sim_posix_revolution
sim_posix_revolution: sim_posix
define SIM_TEMPLATE
sim_$(4): TARGET=sim_$(4)
sim_$(4): OUTDIR=$(BUILD_DIR)/$$(TARGET)
sim_$(4): BOARD_ROOT_DIR=$(ROOT_DIR)/flight/targets/$(1)
sim_$(4): uavobjects
$(V1) mkdir -p $$(OUTDIR)/dep
$(V1) cd $$(BOARD_ROOT_DIR)/fw && \
$$(MAKE) --no-print-directory \
--file=Makefile.$(4) \
BOARD_NAME=$(1) \
BOARD_SHORT_NAME=$(3) \
BUILD_TYPE=sm \
TCHAIN_PREFIX="" \
REMOVE_CMD="$(RM)" \
\
MAKE_INC_DIR=$(MAKE_INC_DIR) \
ROOT_DIR=$(ROOT_DIR) \
BOARD_ROOT_DIR=$$(BOARD_ROOT_DIR) \
BOARD_INFO_DIR=$$(BOARD_ROOT_DIR)/board-info \
TARGET=$$(TARGET) \
OUTDIR=$$(OUTDIR) \
\
PIOS=$(PIOS).$(4) \
FLIGHTLIB=$(FLIGHTLIB) \
OPMODULEDIR=$(OPMODULEDIR) \
OPUAVOBJ=$(OPUAVOBJ) \
OPUAVTALK=$(OPUAVTALK) \
DOXYGENDIR=$(DOXYGENDIR) \
OPUAVSYNTHDIR=$(OPUAVSYNTHDIR) \
SHAREDAPIDIR=$(SHAREDAPIDIR) \
\
$$*
.PHONY: sim_$(4)_clean
sim_$(4)_clean: TARGET=sim_$(4)
sim_$(4)_clean: OUTDIR=$(BUILD_DIR)/$$(TARGET)
sim_$(4)_clean:
$(V0) @echo " CLEAN $$@"
$(V1) [ ! -d "$$(OUTDIR)" ] || $(RM) -r "$$(OUTDIR)"
endef
# $(1) = Canonical board name all in lower case (e.g. coptercontrol)
# $(2) = Unused
# $(3) = Short name for board (e.g CC)
define FW_TEMPLATE
.PHONY: $(1) fw_$(1)
$(1): fw_$(1)_tlfw
fw_$(1): fw_$(1)_tlfw
fw_$(1)_%: TARGET=fw_$(1)
fw_$(1)_%: OUTDIR=$(BUILD_DIR)/$$(TARGET)
fw_$(1)_%: BOARD_ROOT_DIR=$(ROOT_DIR)/flight/targets/$(1)
fw_$(1)_%: uavobjects_armsoftfp uavobjects_armhardfp
$(V1) mkdir -p $$(OUTDIR)/dep
$(V1) cd $$(BOARD_ROOT_DIR)/fw && \
$$(MAKE) -r --no-print-directory \
BOARD_NAME=$(1) \
BOARD_SHORT_NAME=$(3) \
BUILD_TYPE=fw \
TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \
REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" \
\
MAKE_INC_DIR=$(MAKE_INC_DIR) \
ROOT_DIR=$(ROOT_DIR) \
BOARD_ROOT_DIR=$$(BOARD_ROOT_DIR) \
BOARD_INFO_DIR=$$(BOARD_ROOT_DIR)/board-info \
TARGET=$$(TARGET) \
OUTDIR=$$(OUTDIR) \
\
PIOS=$(PIOS) \
FLIGHTLIB=$(FLIGHTLIB) \
OPMODULEDIR=$(OPMODULEDIR) \
OPUAVOBJ=$(OPUAVOBJ) \
OPUAVTALK=$(OPUAVTALK) \
DOXYGENDIR=$(DOXYGENDIR) \
OPUAVSYNTHDIR=$(OPUAVSYNTHDIR) \
SHAREDAPIDIR=$(SHAREDAPIDIR) \
\
$$*
.PHONY: $(1)_clean
$(1)_clean: fw_$(1)_clean
fw_$(1)_clean: TARGET=fw_$(1)
fw_$(1)_clean: OUTDIR=$(BUILD_DIR)/$$(TARGET)
fw_$(1)_clean:
$(V0) @echo " CLEAN $$@"
$(V1) [ ! -d "$$(OUTDIR)" ] || $(RM) -r "$$(OUTDIR)"
endef
# $(1) = Canonical board name all in lower case (e.g. coptercontrol)
# $(2) = CPU arch (e.g. f1, f3, f4)
# $(3) = Short name for board (e.g CC)
define BL_TEMPLATE
.PHONY: bl_$(1)
bl_$(1): bl_$(1)_bin
bl_$(1)_%: TARGET=bl_$(1)
bl_$(1)_%: OUTDIR=$(BUILD_DIR)/$$(TARGET)
bl_$(1)_%: BOARD_ROOT_DIR=$(ROOT_DIR)/flight/targets/$(1)
bl_$(1)_%: BLSRCDIR=$(ROOT_DIR)/flight/targets/bl
bl_$(1)_%: BLCOMMONDIR=$$(BLSRCDIR)/common
bl_$(1)_%: BLARCHDIR=$$(BLSRCDIR)/$(2)
bl_$(1)_%: BLBOARDDIR=$$(BOARD_ROOT_DIR)/bl
bl_$(1)_%:
$(V1) mkdir -p $$(OUTDIR)/dep
$(V1) cd $$(BLARCHDIR) && \
$$(MAKE) -r --no-print-directory \
BOARD_NAME=$(1) \
BOARD_SHORT_NAME=$(3) \
BUILD_TYPE=bl \
TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \
REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" \
\
MAKE_INC_DIR=$(MAKE_INC_DIR) \
ROOT_DIR=$(ROOT_DIR) \
BOARD_ROOT_DIR=$$(BOARD_ROOT_DIR) \
BOARD_INFO_DIR=$$(BOARD_ROOT_DIR)/board-info \
TARGET=$$(TARGET) \
OUTDIR=$$(OUTDIR) \
\
PIOS=$(PIOS) \
FLIGHTLIB=$(FLIGHTLIB) \
BLCOMMONDIR=$$(BLCOMMONDIR) \
BLARCHDIR=$$(BLARCHDIR) \
BLBOARDDIR=$$(BLBOARDDIR) \
DOXYGENDIR=$(DOXYGENDIR) \
\
$$*
.PHONY: unbrick_$(1)
unbrick_$(1): TARGET=bl_$(1)
unbrick_$(1): OUTDIR=$(BUILD_DIR)/$$(TARGET)
unbrick_$(1): bl_$(1)_hex
$(if $(filter-out undefined,$(origin UNBRICK_TTY)),
$(V0) @echo " UNBRICK $(1) via $$(UNBRICK_TTY)"
$(V1) $(STM32FLASH_DIR)/stm32flash \
-w $$(OUTDIR)/bl_$(1).hex \
-g 0x0 \
$$(UNBRICK_TTY)
,
$(V0) @echo
$(V0) @echo "ERROR: You must specify UNBRICK_TTY=<serial-device> to use for unbricking."
$(V0) @echo " eg. $$(MAKE) $$@ UNBRICK_TTY=/dev/ttyUSB0"
)
.PHONY: bl_$(1)_clean
bl_$(1)_clean: TARGET=bl_$(1)
bl_$(1)_clean: OUTDIR=$(BUILD_DIR)/$$(TARGET)
bl_$(1)_clean:
$(V0) @echo " CLEAN $$@"
$(V1) [ ! -d "$$(OUTDIR)" ] || $(RM) -r "$$(OUTDIR)"
endef
# $(1) = Canonical board name all in lower case (e.g. coptercontrol)
# $(2) = Unused
# $(3) = Short name for board (e.g CC)
define BU_TEMPLATE
.PHONY: bu_$(1)
bu_$(1): bu_$(1)_tlfw
bu_$(1)_%: TARGET=bu_$(1)
bu_$(1)_%: OUTDIR=$(BUILD_DIR)/$$(TARGET)
bu_$(1)_%: BOARD_ROOT_DIR=$(ROOT_DIR)/flight/targets/$(1)
bu_$(1)_%: BUSRCDIR=$(ROOT_DIR)/flight/targets/bu
bu_$(1)_%: BUCOMMONDIR=$$(BUSRCDIR)/common
bu_$(1)_%: BUARCHDIR=$$(BUSRCDIR)/$(2)
bu_$(1)_%: BUBOARDDIR=$$(BOARD_ROOT_DIR)/bu
bu_$(1)_%: bl_$(1)_bin
$(V1) mkdir -p $$(OUTDIR)/dep
$(V1) cd $$(BUARCHDIR) && \
$$(MAKE) -r --no-print-directory \
BOARD_NAME=$(1) \
BOARD_SHORT_NAME=$(3) \
BUILD_TYPE=bu \
TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \
REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" \
\
MAKE_INC_DIR=$(MAKE_INC_DIR) \
ROOT_DIR=$(ROOT_DIR) \
BOARD_ROOT_DIR=$$(BOARD_ROOT_DIR) \
BOARD_INFO_DIR=$$(BOARD_ROOT_DIR)/board-info \
TARGET=$$(TARGET) \
OUTDIR=$$(OUTDIR) \
\
PIOS=$(PIOS) \
FLIGHTLIB=$(FLIGHTLIB) \
BUCOMMONDIR=$$(BUCOMMONDIR) \
BUARCHDIR=$$(BUARCHDIR) \
BUBOARDDIR=$$(BUBOARDDIR) \
DOXYGENDIR=$(DOXYGENDIR) \
\
$$*
.PHONY: bu_$(1)_clean
bu_$(1)_clean: TARGET=bu_$(1)
bu_$(1)_clean: OUTDIR=$(BUILD_DIR)/$$(TARGET)
bu_$(1)_clean:
$(V0) @echo " CLEAN $$@"
$(V1) [ ! -d "$$(OUTDIR)" ] || $(RM) -r "$$(OUTDIR)"
endef
# $(1) = Canonical board name all in lower case (e.g. coptercontrol)
define EF_TEMPLATE
.PHONY: ef_$(1)
ef_$(1): ef_$(1)_bin
ef_$(1)_%: TARGET=ef_$(1)
ef_$(1)_%: OUTDIR=$(BUILD_DIR)/$$(TARGET)
ef_$(1)_%: BOARD_ROOT_DIR=$(ROOT_DIR)/flight/targets/$(1)
ef_$(1)_%: bl_$(1)_bin fw_$(1)_tlfw
$(V1) mkdir -p $$(OUTDIR)/dep
$(V1) cd $(ROOT_DIR)/flight/targets/EntireFlash && \
$$(MAKE) -r --no-print-directory \
BOARD_NAME=$(1) \
BOARD_SHORT_NAME=$(3) \
BUILD_TYPE=ef \
TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \
REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" \
DFU_CMD="$(DFUUTIL_DIR)/bin/dfu-util" \
\
MAKE_INC_DIR=$(MAKE_INC_DIR) \
ROOT_DIR=$(ROOT_DIR) \
BOARD_ROOT_DIR=$$(BOARD_ROOT_DIR) \
BOARD_INFO_DIR=$$(BOARD_ROOT_DIR)/board-info \
TARGET=$$(TARGET) \
OUTDIR=$$(OUTDIR) \
\
$$*
.PHONY: ef_$(1)_clean
ef_$(1)_clean: TARGET=ef_$(1)
ef_$(1)_clean: OUTDIR=$(BUILD_DIR)/$$(TARGET)
ef_$(1)_clean:
$(V0) @echo " CLEAN $$@"
$(V1) [ ! -d "$$(OUTDIR)" ] || $(RM) -r "$$(OUTDIR)"
endef
# When building any of the "all_*" targets, tell all sub makefiles to display
# additional details on each line of output to describe which build and target
# that each line applies to.
ifneq ($(strip $(filter all_%,$(MAKECMDGOALS))),)
export ENABLE_MSG_EXTRA := yes
endif
ifneq (,$(filter sim_%, $(MAKECMDGOALS)))
export ENABLE_MSG_EXTRA := yes
endif
# When building more than one goal in a single make invocation, also
# enable the extra context for each output line
ifneq ($(word 2,$(MAKECMDGOALS)),)
export ENABLE_MSG_EXTRA := yes
endif
UAVOLIB_SOFT_OUT_DIR = $(BUILD_DIR)/uavobjects_armsoftfp
UAVOLIB_HARD_OUT_DIR = $(BUILD_DIR)/uavobjects_armhardfp
uavobjects_armsoftfp: TARGET=uavobjects_armsoftfp
uavobjects_armsoftfp: OUTDIR=$(UAVOLIB_SOFT_OUT_DIR)
uavobjects_armhardfp: TARGET=uavobjects_armhardfp
uavobjects_armhardfp: OUTDIR=$(UAVOLIB_HARD_OUT_DIR)
uavobjects_%: uavobjects
$(V1) mkdir -p $(OUTDIR)/dep
$(V1) cd $(ROOT_DIR)/flight/uavobjectlib && \
$(MAKE) -r --no-print-directory \
TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \
REMOVE_CMD="$(RM)" \
\
MAKE_INC_DIR=$(MAKE_INC_DIR) \
ROOT_DIR=$(ROOT_DIR) \
TARGET=$(TARGET) \
OUTDIR=$(OUTDIR) \
\
FLIGHTLIB=$(FLIGHTLIB) \
PIOS=$(PIOS) \
OPUAVOBJ=$(OPUAVOBJ) \
OPUAVTALK=$(OPUAVTALK) \
DOXYGENDIR=$(DOXYGENDIR) \
OPUAVSYNTHDIR=$(OPUAVSYNTHDIR) \
\
$@
.PHONY: uavobjects_armsoftfp_clean uavobjects_armhardfp_clean
uavobjects_armsoftfp_clean:
$(V0) @echo " CLEAN $@"
$(V1) [ ! -d "$(UAVOLIB_SOFT_OUT_DIR)" ] || $(RM) -r "$(UAVOLIB_SOFT_OUT_DIR)"
uavobjects_armhardfp_clean:
$(V0) @echo " CLEAN $@"
$(V1) [ ! -d "$(UAVOLIB_HARD_OUT_DIR)" ] || $(RM) -r "$(UAVOLIB_HARD_OUT_DIR)"
# $(1) = Canonical board name all in lower case (e.g. coptercontrol)
define BOARD_PHONY_TEMPLATE
.PHONY: all_$(1)
all_$(1): $$(filter fw_$(1), $$(FW_TARGETS))
all_$(1): $$(filter bl_$(1), $$(BL_TARGETS))
all_$(1): $$(filter bu_$(1), $$(BU_TARGETS))
all_$(1): $$(filter ef_$(1), $$(EF_TARGETS))
.PHONY: all_$(1)_clean
all_$(1)_clean: $$(addsuffix _clean, $$(filter fw_$(1), $$(FW_TARGETS)))
all_$(1)_clean: $$(addsuffix _clean, $$(filter bl_$(1), $$(BL_TARGETS)))
all_$(1)_clean: $$(addsuffix _clean, $$(filter bu_$(1), $$(BU_TARGETS)))
all_$(1)_clean: $$(addsuffix _clean, $$(filter ef_$(1), $$(EF_TARGETS)))
endef
# Start out assuming that we'll build fw, bl and bu for all boards
FW_BOARDS := $(ALL_BOARDS)
BL_BOARDS := $(filter-out naze32, $(ALL_BOARDS))
BU_BOARDS := $(BL_BOARDS)
EF_BOARDS := $(filter-out naze32, $(ALL_BOARDS))
# Sim targets are different for each host OS
ifeq ($(UNAME), Linux)
SIM_BOARDS := sim_posix
else ifeq ($(UNAME), Darwin)
SIM_BOARDS := sim_posix
else ifdef WINDOWS
SIM_BOARDS :=
else # unknown OS
SIM_BOARDS :=
endif
# Generate the targets for whatever boards are left in each list
FW_TARGETS := $(addprefix fw_, $(FW_BOARDS))
BL_TARGETS := $(addprefix bl_, $(BL_BOARDS))
BU_TARGETS := $(addprefix bu_, $(BU_BOARDS))
EF_TARGETS := $(addprefix ef_, $(EF_BOARDS))
.PHONY: all_fw all_fw_clean
all_fw: $(addsuffix _tlfw, $(FW_TARGETS))
all_fw_clean: $(addsuffix _clean, $(FW_TARGETS)) uavobjects_armsoftfp_clean uavobjects_armhardfp_clean
.PHONY: all_bl all_bl_clean
all_bl: $(addsuffix _bin, $(BL_TARGETS))
all_bl_clean: $(addsuffix _clean, $(BL_TARGETS))
.PHONY: all_bu all_bu_clean
all_bu: $(addsuffix _tlfw, $(BU_TARGETS))
all_bu_clean: $(addsuffix _clean, $(BU_TARGETS))
.PHONY: all_ef all_ef_clean
all_ef: $(EF_TARGETS)
all_ef_clean: $(addsuffix _clean, $(EF_TARGETS))
.PHONY: all_sim all_sim_clean
all_sim: $(SIM_BOARDS)
all_sim_clean: $(addsuffix _clean, $(SIM_BOARDS))
.PHONY: all_flight all_flight_clean
all_flight: all_fw all_bl all_bu all_ef all_sim
all_flight_clean: all_fw_clean all_bl_clean all_bu_clean all_ef_clean all_sim_clean
# Expand the groups of targets for each board
$(foreach board, $(ALL_BOARDS), $(eval $(call BOARD_PHONY_TEMPLATE,$(board))))
# Expand the bootloader updater rules
$(foreach board, $(BU_BOARDS), $(eval $(call BU_TEMPLATE,$(board),$($(board)_cpuarch),$($(board)_short))))
# Expand the firmware rules
$(foreach board, $(FW_BOARDS), $(eval $(call FW_TEMPLATE,$(board),$($(board)_friendly),$($(board)_short))))
# Expand the bootloader rules
$(foreach board, $(BL_BOARDS), $(eval $(call BL_TEMPLATE,$(board),$($(board)_cpuarch),$($(board)_short))))
# Expand the entire-flash rules
$(foreach board, $(EF_BOARDS), $(eval $(call EF_TEMPLATE,$(board),$($(board)_friendly),$($(board)_short))))
# Expand the available simulator rules
$(eval $(call SIM_TEMPLATE,simulation,Simulation,'sim ',posix,elf))
##############################
#
# Unit Tests
#
##############################
ALL_UNITTESTS := logfs i2c_vm misc_math coordinate_conversions error_correcting streamfs dsm timeutils
ALL_UNITTESTS += statistics
ALL_PYTHON_UNITTESTS := python_ut_test
UT_OUT_DIR := $(BUILD_DIR)/unit_tests
$(UT_OUT_DIR):
$(V1) mkdir -p $@
.PHONY: all_ut
all_ut: $(addsuffix _elf, $(addprefix ut_, $(ALL_UNITTESTS))) $(ALL_PYTHON_UNITTESTS)
# The all_ut_tap goal is a legacy alias for the all_ut_xml target so that Jenkins
# can still build old branches. This can be deleted in a few months when all
# branches are using the newer targets.
.PHONY: all_ut_tap
all_ut_tap: all_ut_xml
.PHONY: all_ut_xml
all_ut_xml: $(addsuffix _xml, $(addprefix ut_, $(ALL_UNITTESTS)))
.PHONY: all_ut_run
all_ut_run: $(addsuffix _run, $(addprefix ut_, $(ALL_UNITTESTS))) $(ALL_PYTHON_UNITTESTS)
.PHONY: all_ut_gcov
all_ut_gcov: | $(addsuffix _gcov, $(addprefix ut_, $(ALL_UNITTESTS)))
.PHONY: all_ut_clean
all_ut_clean:
$(V0) @echo " CLEAN $@"
$(V1) [ ! -d "$(UT_OUT_DIR)" ] || $(RM) -r "$(UT_OUT_DIR)"
# $(1) = Unit test name
define UT_TEMPLATE
.PHONY: ut_$(1)
ut_$(1): ut_$(1)_run