forked from d-ronin/dRonin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
1173 lines (991 loc) · 40 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 dRonin project
.DEFAULT_GOAL := help
WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST)))
export ROOT_DIR := $(realpath $(WHEREAMI)/ )
export BUILD_ALL_DEPENDENCIES := $(BUILD_ALL_DEPENDENCIES)
# 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
# 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
FW_FILES :=
GITVERSION := $(shell git describe --always --dirty --abbrev=9)
ALL_BOARDS :=
include $(ROOT_DIR)/flight/targets/*/target-defs.mk
# OpenPilot GCS build configuration (debug | release)
GCS_BUILD_CONF ?= debug ccache
# And the flight build configuration (debug | default | release)
export FLIGHT_BUILD_CONF ?= default
# Paths
UAVOBJ_XML_DIR := $(ROOT_DIR)/shared/uavobjectdefinition
UAVOBJ_OUT_DIR := $(BUILD_DIR)/uavobject-synthetics
export SHAREDUSBIDDIR:= $(BUILD_DIR)/shared/usb_ids
# Markers used in sequencing build steps
UAVOBJECT_MARKER := $(UAVOBJ_OUT_DIR)/.uav-marker
GCS_QMAKE_MARKER := $(BUILD_DIR)/ground/gcs/.make_marker
##############################
#
# 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 ($(filter release, $(GCS_BUILD_CONF)), release)
ifneq ($(filter debug, $(GCS_BUILD_CONF)), debug)
$(error Either debug or release are required 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 " zip_install - Install Info-Zip compression tool"
@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 " uncrustify_install - Install the uncrustify code formatter"
@echo " openssl_install - Install the openssl libraries on windows machines"
@echo " sdl_install - Install the SDL libraries"
ifndef WINDOWS
@echo " depot_tools_install - Install Google depot-tools for building breakpad tools"
endif
@echo " breakpad_install - Install Google Breakpad tools for GCS crash symbol generation"
@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 " fw_<board>_debug - Use OpenOCD + SWD/JTAG to setup a GDB server 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 " [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 " gcs_clazy - Perform checks on GCS code using KDE's clazy"
@echo " CLAZY_CHECKS= - Specify which checks to perform (see clazy docs), default is level0"
@echo " gcs_ts - Generate GCS translation files"
@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 " [Packaging]"
@echo " package_flight - Build and package the dRonin flight firmware only"
@echo " package_all_compress - Build and package all dRonin firmware and software"
@echo " package_installer - Builds a dRonin software installer"
@echo
@echo " Notes:"
@echo " - packages will be placed in $(PACKAGE_DIR)"
@echo
@echo " [Misc]"
@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 matlab
.PHONY: all_clean
all_clean:
[ ! -d "$(BUILD_DIR)" ] || $(RM) -rf "$(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-msvc2015
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
GCS_QMAKE_DEPS := $(shell find $(ROOT_DIR)/ground -name '*.pr?')
$(GCS_QMAKE_DEPS): ;
$(GCS_QMAKE_MARKER): $(UAVOBJECT_MARKER) $(GCS_QMAKE_DEPS) $(SHAREDUSBIDDIR)/board_usb_ids.h
$(V1) mkdir -p $(BUILD_DIR)/ground/gcs
$(V1) ( cd $(BUILD_DIR)/ground/gcs && \
PYTHON=$(PYTHON) $(QMAKE) $(ROOT_DIR)/ground/gcs/gcs.pro -spec $(QT_SPEC) -r CONFIG+="$(GCS_BUILD_CONF) $(GCS_SILENT)" $(GCS_QMAKE_OPTS) ; \
)
$(V1) touch $(GCS_QMAKE_MARKER)
.PHONY: gcs
gcs: $(GCS_QMAKE_MARKER) | tools_required_qt tools_required_breakpad
ifeq ($(USE_MSVC), NO)
cd $(BUILD_DIR)/ground/gcs && $(MAKE) --no-print-directory -w
else
cd $(BUILD_DIR)/ground/gcs && MAKEFLAGS= jom $(JOM_OPTIONS)
endif
.PHONY: gcs_clean
gcs_clean:
$(V0) @echo " CLEAN $@"
$(V1) [ ! -d "$(BUILD_DIR)/ground/gcs" ] || $(RM) -rf "$(BUILD_DIR)/ground/gcs"
.PHONY: gcs_ts
gcs_ts: tools_required_qt
$(V1) mkdir -p $(BUILD_DIR)/ground/gcs/share/translations
$(V1) ( cd $(BUILD_DIR)/ground/gcs/share/translations && \
PYTHON=$(PYTHON) $(QMAKE) $(ROOT_DIR)/ground/gcs/share/translations/translations.pro -spec $(QT_SPEC) -r CONFIG+="$(GCS_BUILD_CONF) $(GCS_SILENT)" $(GCS_QMAKE_OPTS) && \
$(MAKE) --no-print-directory -w ts ; \
)
# requires KDE's clazy
# need to disable ccache, gence build config = release
.PHONY: gcs_clazy
gcs_clazy: CLAZY_CHECKS ?= level0
gcs_clazy: $(UAVOBJECT_MARKER) | tools_required_qt
$(V1) which clazy >/dev/null 2>&1; if [ $$? -ne 0 ]; then echo "ERROR: clazy executable not found!"; exit 1; fi
$(V1) mkdir -p $(BUILD_DIR)/ground/$@
$(V1) ( cd $(BUILD_DIR)/ground/$@ && \
CLAZY_CHECKS=$(CLAZY_CHECKS) PYTHON=$(PYTHON) $(QMAKE) $(ROOT_DIR)/ground/gcs/gcs.pro -spec $(QT_CLANG_SPEC) QMAKE_CXX="clazy" -r CONFIG+="release $(GCS_SILENT)" $(GCS_QMAKE_OPTS) && \
$(MAKE) --no-print-directory -w ; \
)
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
UAVOBJECT_DEPS := $(shell find $(UAVOBJ_XML_DIR))
$(UAVOBJECT_DEPS): ;
$(UAVOBJECT_MARKER): $(UAVOBJECT_DEPS) | uavobjgenerator
$(V1) mkdir -p $(UAVOBJ_OUT_DIR)
$(V1) ( cd $(UAVOBJ_OUT_DIR) && \
$(UAVOBJGENERATOR) $(UAVOBJ_XML_DIR) $(ROOT_DIR) ; \
)
$(V1) touch $(UAVOBJECT_MARKER)
uavobjects: $(UAVOBJECT_MARKER)
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) -rf "$(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) $(UAVOBJECT_MARKER) 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: $(UAVOBJECT_MARKER) $(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.dronin.androidgcs/.MainActivity
.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) -rf "$(ANDROIDGCS_OUT_DIR)"
.PHONY: androidgcs_sign
# This is intended for manual/after the fact signing of a release artifact
# out of band from CI/release infrastructure. It can be made more elegant
# later as things mature. Better some documentation than no documentation.
androidgcs_sign:
$(V0) @echo " SIGNING $@"
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore dronin.keystore androidgcs-release-unsigned.apk dronin
$(ANDROID_SDK_DIR)/build-tools/20.0.0/zipalign -v 4 androidgcs-release-unsigned.apk androidgcs-release.apk
# 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.
#
# Supply the git hashes of all recent releases here. Note if UAVOs do not
# change in a hotfix the release does not need to be listed here.
UAVO_GIT_VERSIONS := HEAD \
Release-20170717 \
Release-20170213 \
Release-20161004.1 \
Release-20160720.1 \
Release-20160409.2 \
$(shell git log --merges --pretty=tformat:%h -n 18 shared/uavobjectdefinition/)
# 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/dronin/uavtalk/UAVDataObject.java \
$$(ROOT_DIR)/androidgcs/src/org/dronin/uavtalk/UAVObject*.java \
$$(ROOT_DIR)/androidgcs/src/org/dronin/uavtalk/UAVMetaObject.java \
-d . && \
find ./org/dronin/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) -rf $(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
export MAKE_INC_DIR := $(ROOT_DIR)/make
export PIOS := $(ROOT_DIR)/flight/PiOS
export FLIGHTLIB := $(ROOT_DIR)/flight/Libraries
export OPMODULEDIR := $(ROOT_DIR)/flight/Modules
export OPUAVOBJ := $(ROOT_DIR)/flight/UAVObjects
export OPUAVTALK := $(ROOT_DIR)/flight/UAVTalk
export DOXYGENDIR := $(ROOT_DIR)/Doxygen
export SHAREDAPIDIR := $(ROOT_DIR)/shared/api
export 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
ifneq ($(PI_CROSS_SIM)x,x)
export CROSS_SIM=pi
endif
ifeq ($(CROSS_SIM),pi)
SIMSUFFIX=-pi
else ifeq ($(CROSS_SIM),32)
SIMSUFFIX=-32
else ifneq ($(CROSS_SIM)x,x)
$(error Invalid value of CROSS_SIM)
endif
define SIM_TEMPLATE
.PHONY: sim
sim: TARGET=sim
sim: OUTDIR=$(BUILD_DIR)/$$(TARGET)
sim: BOARD_ROOT_DIR=$(ROOT_DIR)/flight/targets/$(1)
sim: $(UAVOBJECT_MARKER)
$(V1) mkdir -p $$(OUTDIR)/dep
$(V1) cd $$(BOARD_ROOT_DIR)/fw && \
$$(MAKE) --no-print-directory \
BOARD_NAME=$(1) \
BOARD_SHORT_NAME=$(3) \
BUILD_TYPE=fw \
REMOVE_CMD="$(RM)" \
\
ROOT_DIR=$(ROOT_DIR) \
BOARD_ROOT_DIR=$$(BOARD_ROOT_DIR) \
BOARD_INFO_DIR=$$(BOARD_ROOT_DIR)/board-info \
TARGET=$$(TARGET) \
OUTDIR=$$(OUTDIR)$(SIMSUFFIX) \
\
$$*
.PHONY: sim_clean
sim_clean: TARGET=sim
sim_clean: OUTDIR=$(BUILD_DIR)/$$(TARGET)
sim_clean:
$(V0) @echo " CLEAN $$@"
$(V1) [ ! -d "$$(OUTDIR)" ] || $(RM) -rf "$$(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_FILES += $(BUILD_DIR)/fw_$(1)/fw_$(1).tlfw
FW_FILES += $(BUILD_DIR)/fw_$(1)/fw_$(1).debug
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 flightlib_armsoftfp flightlib_armhardfp usb_id_header
$(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)" \
\
ROOT_DIR=$(ROOT_DIR) \
BOARD_ROOT_DIR=$$(BOARD_ROOT_DIR) \
BOARD_INFO_DIR=$$(BOARD_ROOT_DIR)/board-info \
TARGET=$$(TARGET) \
OUTDIR=$$(OUTDIR) \
\
$$*
.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) -rf "$$(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
FW_FILES += $(BUILD_DIR)/bl_$(1)/bl_$(1).bin
FW_FILES += $(BUILD_DIR)/bl_$(1)/bl_$(1).debug
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)_%: usb_id_header
$(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)" \
\
ROOT_DIR=$(ROOT_DIR) \
BOARD_ROOT_DIR=$$(BOARD_ROOT_DIR) \
BOARD_INFO_DIR=$$(BOARD_ROOT_DIR)/board-info \
TARGET=$$(TARGET) \
OUTDIR=$$(OUTDIR) \
BLCOMMONDIR=$$(BLCOMMONDIR) \
BLARCHDIR=$$(BLARCHDIR) \
BLBOARDDIR=$$(BLBOARDDIR) \
\
$$*
.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) -rf "$$(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
FW_FILES += $(BUILD_DIR)/bu_$(1)/bu_$(1).tlfw
FW_FILES += $(BUILD_DIR)/bu_$(1)/bu_$(1).debug
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 usb_id_header
$(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)" \
\
ROOT_DIR=$(ROOT_DIR) \
BOARD_ROOT_DIR=$$(BOARD_ROOT_DIR) \
BOARD_INFO_DIR=$$(BOARD_ROOT_DIR)/board-info \
TARGET=$$(TARGET) \
OUTDIR=$$(OUTDIR) \
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) -rf "$$(OUTDIR)"
endef
# $(1) = Canonical board name all in lower case (e.g. coptercontrol)
# $(2) = Friendly board name
# $(3) = Short board name
# $(4) = yes for bootloader, no for no bootloader
define EF_TEMPLATE
.PHONY: ef_$(1)
ef_$(1): ef_$(1)_hex
FW_FILES += $(BUILD_DIR)/ef_$(1)/ef_$(1).hex
ef_$(1)_%: TARGET=ef_$(1)
ef_$(1)_%: OUTDIR=$(BUILD_DIR)/$$(TARGET)
ef_$(1)_%: BOARD_ROOT_DIR=$(ROOT_DIR)/flight/targets/$(1)
# rule for bootloader, must come first
$(eval $(call EF_RULE,$(1),$(2),$(3),$(4),fw_$(1)_tlfw bl_$(1)_bin))
# rule for without bootloader
$(eval $(call EF_RULE,$(1),$(2),$(3),$(4),fw_$(1)_tlfw))
.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) -rf "$$(OUTDIR)"
endef
# $(1) = Canonical board name all in lower case (e.g. coptercontrol)
# $(2) = Friendly board name
# $(3) = Short board name
# $(4) = yes for bootloader, no for no bootloader
# $(5) = dependencies
define EF_RULE
ef_$(1)_%: $(5)
$(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 \
INCLUDE_BOOTLOADER=$(4) \
TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \
REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" \
DFU_CMD="$(DFUUTIL_DIR)/bin/dfu-util" \
\
ROOT_DIR=$(ROOT_DIR) \
BOARD_ROOT_DIR=$$(BOARD_ROOT_DIR) \
BOARD_INFO_DIR=$$(BOARD_ROOT_DIR)/board-info \
TARGET=$$(TARGET) \
OUTDIR=$$(OUTDIR) \
\
$$*
endef
# Always output information on the target and build type in the build summary
export ENABLE_MSG_EXTRA := yes
UAVOLIB_SOFT_OUT_DIR = $(BUILD_DIR)/uavobjects_armsoftfp
UAVOLIB_HARD_OUT_DIR = $(BUILD_DIR)/uavobjects_armhardfp
FLIGHTLIB_SOFT_OUT_DIR = $(BUILD_DIR)/flightlib_armsoftfp
FLIGHTLIB_HARD_OUT_DIR = $(BUILD_DIR)/flightlib_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)
flightlib_armsoftfp: TARGET=flightlib_armsoftfp
flightlib_armsoftfp: OUTDIR=$(FLIGHTLIB_SOFT_OUT_DIR)
flightlib_armhardfp: TARGET=flightlib_armhardfp
flightlib_armhardfp: OUTDIR=$(FLIGHTLIB_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)" \
\
ROOT_DIR=$(ROOT_DIR) \
TARGET=$(TARGET) \
OUTDIR=$(OUTDIR) \
\
$@
.PHONY: uavobjects_armsoftfp_clean uavobjects_armhardfp_clean
uavobjects_armsoftfp_clean:
$(V0) @echo " CLEAN $@"
$(V1) [ ! -d "$(UAVOLIB_SOFT_OUT_DIR)" ] || $(RM) -rf "$(UAVOLIB_SOFT_OUT_DIR)"
uavobjects_armhardfp_clean:
$(V0) @echo " CLEAN $@"
$(V1) [ ! -d "$(UAVOLIB_HARD_OUT_DIR)" ] || $(RM) -rf "$(UAVOLIB_HARD_OUT_DIR)"
flightlib_%: $(UAVOBJECT_MARKER)
$(V1) mkdir -p $(OUTDIR)/dep
$(V1) cd $(ROOT_DIR)/flight/flightlib && \
$(MAKE) -r --no-print-directory \
TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \
REMOVE_CMD="$(RM)" \
\
ROOT_DIR=$(ROOT_DIR) \
TARGET=$(TARGET) \
OUTDIR=$(OUTDIR) \
\
$@
.PHONY: flightlib_armsoftfp_clean flightlib_armhardfp_clean
flightlib_armsoftfp_clean:
$(V0) @echo " CLEAN $@"
$(V1) [ ! -d "$(FLIGHTLIB_SOFT_OUT_DIR)" ] || $(RM) -rf "$(FLIGHTLIB_SOFT_OUT_DIR)"
flightlib_armhardfp_clean:
$(V0) @echo " CLEAN $@"
$(V1) [ ! -d "$(FLIGHTLIB_HARD_OUT_DIR)" ] || $(RM) -rf "$(FLIGHTLIB_HARD_OUT_DIR)"
.PHONY: usb_id_header usb_id_udev usb_id_windriver
usb_id_header: $(SHAREDUSBIDDIR)/board_usb_ids.h
usb_id_udev: $(SHAREDUSBIDDIR)/dronin.udev
usb_id_windriver: $(SHAREDUSBIDDIR)/dronin_cdc.inf
$(SHAREDUSBIDDIR):
$(V1) mkdir -p "$@"
$(SHAREDUSBIDDIR)/board_usb_ids.h: | $(SHAREDUSBIDDIR)
$(SHAREDUSBIDDIR)/board_usb_ids.h: $(ROOT_DIR)/shared/usb_ids/usb_ids.json
$(V1) $(PYTHON) $(ROOT_DIR)/shared/usb_ids/generate_usb_files.py -i "$<" -c "$@"
$(SHAREDUSBIDDIR)/dronin.udev: | $(SHAREDUSBIDDIR)
$(SHAREDUSBIDDIR)/dronin.udev: $(ROOT_DIR)/shared/usb_ids/usb_ids.json
$(V1) $(PYTHON) $(ROOT_DIR)/shared/usb_ids/generate_usb_files.py -i "$<" -u "$@"
$(SHAREDUSBIDDIR)/dronin_cdc.inf: | $(SHAREDUSBIDDIR)
$(SHAREDUSBIDDIR)/dronin_cdc.inf: $(ROOT_DIR)/shared/usb_ids/usb_ids.json
$(V1) $(PYTHON) $(ROOT_DIR)/shared/usb_ids/generate_usb_files.py -i "$<" -d "$@"
# $(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
# Some boards don't use the bootloader
FW_BOARDS := $(ALL_BOARDS)
NOBL_BOARDS := $(strip $(foreach BOARD, $(ALL_BOARDS),$(if $(filter no,$($(BOARD)_bootloader)),$(BOARD))))
BL_BOARDS := $(filter-out $(NOBL_BOARDS), $(ALL_BOARDS))
BU_BOARDS := $(BL_BOARDS)
EF_BOARDS := $(ALL_BOARDS)
SIM_BOARDS := sim
# 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 flightlib_armsoftfp_clean flightlib_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: $(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))))