-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
1875 lines (1580 loc) · 58.4 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
VERSION_MAJ = 1
VERSION_MIN = 663
# Caution: software update mechanism depends on format of first two lines in this file
#
# Makefile for KiwiSDR project
#
# Copyright (c) 2014-2023 John Seamons, ZL4VO/KF6VO
#
# This Makefile can be run on both a build machine (I use a MacBook Pro) and the
# BeagleBone Black target (Debian release).
#
#
# installing FFTW:
# to create /usr/local/lib/libfftw3f.a (the 'f' in '3f' means single precision)
#
# Mac:
# download the sources from fftw.org
# ./configure --enable-single
# make
# (sudo) make install
#
# BeagleBone Black, Debian:
# the Makefile automatically installs the package using apt-get
#
################################
# build environment detection
################################
include Makefile.comp.inc
# for any config-specific options/dependencies
-include ../kiwi.config/Makefile.kiwi.inc
REPO_USER := flydog-sdr
REPO_NAME := FlyDog_SDR_GPS
REPO_GIT := $(REPO_USER)/$(REPO_NAME).git
REPO := https://github.com/$(REPO_GIT)
ifeq ($(DEBIAN_DEVSYS),$(DEBIAN))
# enough parallel make jobs to overcome core stalls from filesystem or nfs delays
ifeq ($(BBAI_64),true)
# 4 GB DRAM
MAKE_ARGS := -j 2
else ifeq ($(BBAI),true)
# 1 GB DRAM, but not all of it allocated to arm cpu by device tree
# 2 parallel compiles can run out of memory on BBAI when kiwid also loaded
#MAKE_ARGS := -j 2
MAKE_ARGS :=
else ifeq ($(RPI),true)
# fixme: test, but presumably the 1GB (min) of DRAM on RPi 3B & 4 would support this many
MAKE_ARGS := -j 4
else
ifeq ($(DEBIAN_VERSION),7)
# Debian 7 gcc runs out of memory compiling edata_always*.cpp in parallel
MAKE_ARGS :=
else
MAKE_ARGS :=
endif
endif
else
# choices when building on development machine
ifeq ($(XC),-DXC)
# BBAI, DEBIAN_VERSION etc are taken from the mounted KiwiSDR root file system
MAKE_ARGS := -j 7
else
MAKE_ARGS := -j
endif
endif
# uncomment when using debugger so variables are not always optimized away
ifeq ($(DEBIAN_DEVSYS),$(DEBIAN))
# OPT = 0
endif
KIWI_XC_REMOTE_FS ?= ${HOME}/mnt
KIWI_XC_HOST ?= kiwisdr
KIWI_XC_HOST_PORT ?= 22
################################
# "all" target must be first
################################
.PHONY: all
all: check_detect make_prereq
@make $(MAKE_ARGS) build_makefile_inc
@make $(MAKE_ARGS) make_all
.PHONY: skip
skip: skip_cert_check check_detect make_prereq
@make $(MAKE_ARGS) build_makefile_inc
@make $(MAKE_ARGS) make_all
.PHONY: debug
debug: check_detect make_prereq
@make $(MAKE_ARGS) DEBUG=-DDEBUG build_makefile_inc
@make $(MAKE_ARGS) DEBUG=-DDEBUG make_all
.PHONY: check_detect
check_detect:
ifeq ($(BAD_DEV_DETECT),true)
@echo "bad device detect"
@echo "BBAI_64 = $(BBAI_64)"
@echo "BBAI = $(BBAI)"
@echo "RPI = $(RPI)"
@echo "BBG_BBB = $(BBG_BBB)"
@echo "DEBIAN_VERSION = $(DEBIAN_VERSION)"
@exit -1
endif
ifeq ($(BAD_DEB_DETECT),true)
@echo "bad Debian version detect"
@echo "DEBIAN_VERSION = $(DEBIAN_VERSION)"
@exit -1
endif
ifeq ($(DEBIAN_DEVSYS),$(DEVSYS))
.PHONY: xc
ifeq ($(XC),)
xc:
@if [ ! -f $(KIWI_XC_REMOTE_FS)/ID.txt ] && \
[ ! -f $(KIWI_XC_REMOTE_FS)/boot/config.txt ]; then \
echo "ERROR: remote filesystem $(KIWI_XC_REMOTE_FS) not mounted?"; \
exit -1; \
fi
@make XC=-DXC $@
else
xc: make_prereq
@echo KIWI_XC_HOST = $(KIWI_XC_HOST)
@echo KIWI_XC_HOST_PORT = $(KIWI_XC_HOST_PORT)
@echo KIWI_XC_REMOTE_FS = $(KIWI_XC_REMOTE_FS)
@echo KIWI_XC_COPY_SOURCES = $(KIWI_XC_COPY_SOURCES)
@make $(MAKE_ARGS) build_makefile_inc
@make $(MAKE_ARGS) make_all
endif
endif
################################
# build files/directories
################################
# The built files (generated .cpp/.h files, binaries etc.) are placed outside of the source tree
# into the BUILD_DIR. This is so NFS can be used to share the sources between the
# development machine and the Kiwi Beagle. If the build files were also shared there would
# be file overwrites on one machine when you built on the other (and lots of unnecessary NFS copying
# back and forth. See the nfs and nfsup aliases in /root/.bashrc for NFS setup details.
BUILD_DIR := ../build
OBJ_DIR := $(BUILD_DIR)/obj
OBJ_DIR_O3 := $(BUILD_DIR)/obj_O3
KEEP_DIR := $(BUILD_DIR)/obj_keep
GEN_DIR := $(BUILD_DIR)/gen
TOOLS_DIR := $(BUILD_DIR)/tools
DIR_DATA = /tmp/kiwi.data
ifeq ($(OPT),0)
OBJ_DIR_DEFAULT = $(OBJ_DIR)
else ifeq ($(OPT),1)
OBJ_DIR_DEFAULT = $(OBJ_DIR)
else
OBJ_DIR_DEFAULT = $(OBJ_DIR_O3)
endif
PKGS =
PKGS_O3 = pkgs/utf8 pkgs/mongoose pkgs/jsmn pkgs/sha256 pkgs/TNT_JAMA
# Each extension can have an optional Makefile:
# The extension can opt-out of being included via EXT_SKIP (e.g. BBAI only, not Debian 7 etc.)
# EXT_SUBDIRS define any sub-dirs within the extension.
# EXT_DEFINES set any additional defines for the extension.
# Same for additional required libs via LIBS_DEP and LIBS.
# All of these should be appended to using "+="
EXT_SKIP =
EXT_SUBDIRS =
EXT_DEFINES =
LIBS_DEP =
LIBS =
PVT_EXT_DIR = ../extensions
PVT_EXT_DIRS = $(sort $(dir $(wildcard $(PVT_EXT_DIR)/*/extensions/*/)))
# included first to get value of OTHER_DIR before INT_EXT_DIRS definition
-include $(wildcard $(addsuffix Makefile,$(PVT_EXT_DIRS)))
ifeq ($(OTHER_DIR),)
INT_EXT_DIRS1 = $(sort $(dir extensions/ $(wildcard extensions/*/)))
EXT_SKIP1 = $(addsuffix /,$(addprefix extensions/,$(EXT_SKIP)))
INT_EXT_DIRS = $(subst $(EXT_SKIP1),,$(INT_EXT_DIRS1))
else
INT_EXT_DIRS1 = extensions/
EXT_SKIP1 =
INT_EXT_DIRS = extensions/
OTHER_INC = rx/kiwi rx/CuteSDR rx/csdr rx/Teensy rx/wdsp gps \
extensions/wspr extensions/noise_blank extensions/noise_filter
endif
# extension-specific makefiles and makefile for the extension init generator
# PVT listed before INT so they can set EXT_SKIP etc.
-include $(wildcard $(addsuffix Makefile,$(INT_EXT_DIRS)))
EXT_DIRS = $(PVT_EXT_DIRS) $(INT_EXT_DIRS)
PVT_EXTS = $(subst $(PVT_EXT_DIR)/,,$(wildcard $(PVT_EXT_DIR)/*))
INT_EXTS = $(subst /,,$(subst extensions/,,$(wildcard $(INT_EXT_DIRS))))
EXTS = $(INT_EXTS) $(PVT_EXTS)
ifeq ($(OTHER_DIR),)
GPS = gps gps/ka9q-fec gps/GNSS-SDRLIB
-include rx/Makefile
else
GPS =
RX = rx
endif
ifneq ($(RPI),true)
_DIRS = pru $(PKGS)
endif
_DIR_PLATFORMS = $(addprefix platform/, ${PLATFORMS})
_DIRS_O3 += . $(PKGS_O3) platform/common $(_DIR_PLATFORMS) $(EXT_DIRS) $(EXT_SUBDIRS) \
$(RX) $(GPS) dev ui init support net web arch/$(ARCH)
ifeq ($(OPT),0)
DIRS = $(_DIRS) $(_DIRS_O3)
DIRS_O3 =
else ifeq ($(OPT),1)
DIRS = $(_DIRS) $(_DIRS_O3)
DIRS_O3 =
else
DIRS = $(_DIRS)
DIRS_O3 = $(_DIRS_O3)
endif
VPATH = $(DIRS) $(DIRS_O3) $(EXT_SUBDIRS_KEEP)
I += -I$(GEN_DIR) $(addprefix -I,$(DIRS)) $(addprefix -I,$(DIRS_O3)) $(addprefix -I,$(OTHER_INC)) $(addprefix -I,$(EXT_SUBDIRS_KEEP)) -I/usr/local/include $(EXT_I)
H = $(wildcard $(addsuffix /*.h,$(DIRS))) $(wildcard $(addsuffix /*.h,$(DIRS_O3)))
CPP_F = $(wildcard $(addsuffix /*.cpp,$(DIRS))) $(wildcard $(addsuffix /*.c,$(DIRS)))
CPP_F_O3 = $(wildcard $(addsuffix /*.cpp,$(DIRS_O3))) $(wildcard $(addsuffix /*.c,$(DIRS_O3)))
CFILES_KEEP = $(wildcard $(addsuffix /*.cpp,$(EXT_SUBDIRS_KEEP)))
# remove generated files
CFILES = $(subst web/web.cpp,,$(CPP_F))
CFILES_O3 = $(subst web/web.cpp,,$(CPP_F_O3))
ifeq ($(DEBIAN_DEVSYS),$(DEVSYS))
ifeq ($(XC),-DXC)
LIBS += -lfftw3f -lutil
DIR_CFG = /root/kiwi.config
CFG_PREFIX =
ifeq ($(DEBIAN_10_AND_LATER),true)
# USE_SSL isn't compatible with gdb. So for now we revert to USE_CRYPT
INT_FLAGS += -DUSE_CRYPT
LIBS += -lcrypt
# INT_FLAGS += -DUSE_SSL
# LIBS += -lssl
else
INT_FLAGS += -DUSE_CRYPT
LIBS += -lcrypt
endif
else
# development machine, compile simulation version
LIBS += -L/usr/local/lib -lfftw3f
LIBS_DEP += /usr/local/lib/libfftw3f.a
CMD_DEPS =
DIR_CFG = unix_env/kiwi.config
CFG_PREFIX = dist.
endif
else
# host machine, only build the FPGA-using version
LIBS += -lfftw3f -lutil
LIBS_DEP += /usr/lib/$(LIB_ARCH)/libfftw3f.a
CMD_DEPS = $(CMD_DEPS_DEBIAN) /usr/sbin/avahi-autoipd /usr/bin/upnpc /usr/bin/dig /usr/bin/pgmtoppm /sbin/ethtool /usr/bin/sshpass
CMD_DEPS += /usr/bin/killall /usr/bin/dtc /usr/bin/curl /usr/bin/wget /usr/bin/htop /usr/bin/colordiff
DIR_CFG = /root/kiwi.config
CFG_PREFIX =
ifeq ($(DEBIAN_VERSION),10)
CMD_DEPS += /usr/bin/connmanctl
endif
# currently a bug where -lcrypt and -lssl can't be used together for some reason (crash at startup)
ifeq ($(DEBIAN_10_AND_LATER),true)
# USE_SSL isn't compatible with gdb. So for now we revert to USE_CRYPT
INT_FLAGS += -DUSE_CRYPT
LIBS += -lcrypt
# INT_FLAGS += -DUSE_SSL
# LIBS += -lssl
CMD_DEPS += /usr/include/openssl/ssl.h
else
INT_FLAGS += -DUSE_CRYPT
LIBS += -lcrypt
endif
ifeq ($(BBAI_64),true)
CMD_DEPS += /usr/bin/cpufreq-info
endif
ifeq ($(BBAI),true)
CMD_DEPS += /usr/bin/cpufreq-info
endif
# -lrt required for clock_gettime() on Debian 7; see clock_gettime(2) man page
# jq command isn't available on Debian 7
ifeq ($(DEBIAN_VERSION),7)
LIBS += -lrt
else
CMD_DEPS += /usr/bin/jq
endif
endif
################################
# package install
################################
# install packages for needed libraries or commands
# some of these are prefixed with "-" to keep update from failing if there is damage to /var/lib/dpkg/info
ifeq ($(DEBIAN_DEVSYS),$(DEBIAN))
# runs only once per update of the .keyringN.dep filename
KEYRING := $(DIR_CFG)/.keyring4.dep
$(KEYRING):
@echo "KEYRING.."
ifeq ($(DEBIAN_VERSION),7)
@echo "switch to using Debian 7 (Wheezy) archive repo"
-cp /etc/apt/sources.list /etc/apt/sources.list.orig
-sed -e 's/ftp\.us/archive/' < /etc/apt/sources.list >/tmp/sources.list
-mv /tmp/sources.list /etc/apt/sources.list
endif
ifeq ($(DEBIAN_VERSION),8)
@echo "switch to using Debian 8 (Jessie) archive repo"
-cp /etc/apt/sources.list /etc/apt/sources.list.orig
-cp unix_env/sources.D8.new.list /etc/apt/sources.list
-cp unix_env/sources.D8.new.list /etc/apt/
-cp unix_env/sources.D8.upgrade.list /etc/apt/
endif
ifeq ($(DEBIAN_VERSION),9)
@echo "switch to using Debian 9 (Stretch) archive repo"
-cp /etc/apt/sources.list /etc/apt/sources.list.orig
-cp unix_env/sources.D9.new.list /etc/apt/sources.list
endif
-apt-get -y $(APT_GET_FORCE) update
-apt-get -y $(APT_GET_FORCE) install debian-archive-keyring
-apt-get -y $(APT_GET_FORCE) update
@mkdir -p $(DIR_CFG)
touch $(KEYRING)
# runs once-per-boot
INSTALL_CERTIFICATES := /tmp/.kiwi-ca-certs
$(INSTALL_CERTIFICATES):
@echo "INSTALL_CERTIFICATES.."
make $(KEYRING)
-apt-get -y $(APT_GET_FORCE) install ca-certificates
-apt-get -y $(APT_GET_FORCE) update
touch $(INSTALL_CERTIFICATES)
.PHONY: skip_cert_check
skip_cert_check:
touch $(INSTALL_CERTIFICATES)
/usr/lib/$(LIB_ARCH)/libfftw3f.a:
apt-get -y $(APT_GET_FORCE) install libfftw3-dev
/usr/bin/clang:
-apt-get -y $(APT_GET_FORCE) update
apt-get -y $(APT_GET_FORCE) install clang
# NB not a typo: "clang-6.0" vs "clang-7"
/usr/bin/clang-6.0:
# With D8 now archived, clang-6.0 must be obtained from the archived D9 backports.
# But that repo makes use of an interactive script that requires noninteractive handling.
-apt-get -y $(APT_GET_FORCE) update
(UCF_FORCE_CONFOLD=1 DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y $(APT_GET_FORCE) install clang-6.0)
/usr/bin/clang-7:
-apt-get -y $(APT_GET_FORCE) update
apt-get -y $(APT_GET_FORCE) install clang-7
/usr/bin/clang-8:
-apt-get -y $(APT_GET_FORCE) update
apt-get -y $(APT_GET_FORCE) install clang-8
/usr/bin/clang-11:
-apt-get -y $(APT_GET_FORCE) update
apt-get -y $(APT_GET_FORCE) install clang-11
/usr/bin/curl:
-apt-get -y $(APT_GET_FORCE) install curl
/usr/bin/wget:
-apt-get -y $(APT_GET_FORCE) install wget
/usr/bin/htop:
-apt-get -y $(APT_GET_FORCE) install htop
/usr/bin/colordiff:
-apt-get -y $(APT_GET_FORCE) install colordiff
/usr/sbin/avahi-autoipd:
#-apt-get -y $(APT_GET_FORCE) install avahi-daemon avahi-utils libnss-mdns avahi-autoipd
/usr/bin/upnpc:
#-apt-get -y $(APT_GET_FORCE) install miniupnpc
/usr/bin/dig:
-apt-get -y $(APT_GET_FORCE) install dnsutils
/usr/bin/pgmtoppm:
-apt-get -y $(APT_GET_FORCE) install netpbm
/sbin/ethtool:
#-apt-get -y $(APT_GET_FORCE) install ethtool
/usr/bin/sshpass:
-apt-get -y $(APT_GET_FORCE) install sshpass
/usr/bin/killall:
-apt-get -y $(APT_GET_FORCE) install psmisc
/usr/bin/dtc:
#-apt-get -y $(APT_GET_FORCE) install device-tree-compiler
ifeq ($(DEBIAN_VERSION),10)
/usr/bin/connmanctl:
#-apt-get -y $(APT_GET_FORCE) install connman
endif
ifeq ($(DEBIAN_10_AND_LATER),true)
/usr/include/openssl/ssl.h:
-apt-get -y install openssl libssl1.1 libssl-dev
endif
ifeq ($(BBAI_64),true)
/usr/bin/cpufreq-info:
#-apt-get -y install cpufrequtils
endif
ifeq ($(BBAI),true)
/usr/bin/cpufreq-info:
#-apt-get -y install cpufrequtils
endif
ifneq ($(DEBIAN_VERSION),7)
/usr/bin/jq:
-apt-get -y $(APT_GET_FORCE) install jq
endif
endif
################################
# dependencies
################################
#SRC_DEPS = Makefile
SRC_DEPS =
BIN_DEPS = KiwiSDR.rx4.wf4.bit KiwiSDR.rx8.wf2.bit KiwiSDR.rx3.wf3.bit KiwiSDR.rx14.wf0.bit KiwiSDR.other.bit
#BIN_DEPS =
DEVEL_DEPS = $(OBJ_DIR_DEFAULT)/web_devel.o $(KEEP_DIR)/edata_always.o $(KEEP_DIR)/edata_always2.o
EMBED_DEPS = $(OBJ_DIR_DEFAULT)/web_embed.o $(OBJ_DIR)/edata_embed.o $(KEEP_DIR)/edata_always.o $(KEEP_DIR)/edata_always2.o
EXTS_DEPS = $(OBJ_DIR)/ext_init.o
# these MUST be run by single-threaded make before use of -j in sub makes
GEN_ASM = $(GEN_DIR)/kiwi.gen.h verilog/kiwi.gen.vh
GEN_OTHER_ASM = $(GEN_DIR)/other.gen.h verilog/other.gen.vh
OUT_ASM = $(GEN_DIR)/kiwi.aout
GEN_VERILOG = $(addprefix verilog/rx/,cic_rx1_12k.vh cic_rx1_20k.vh cic_rx2_12k.vh cic_rx2_20k.vh cic_rx3_12k.vh cic_rx3_20k.vh cic_wf1.vh cic_wf2.vh)
GEN_NOIP2 = $(GEN_DIR)/noip2
SUB_MAKE_DEPS = $(INSTALL_CERTIFICATES) $(GEN_DIR) $(CMD_DEPS) $(LIBS_DEP) $(GEN_ASM) $(GEN_OTHER_ASM) $(GEN_OTHER) $(OUT_ASM) $(GEN_VERILOG) $(GEN_NOIP2)
.PHONY: make_prereq
make_prereq: DISABLE_WS $(SUB_MAKE_DEPS)
@echo "make_prereq DONE"
.PHONY: make_all
make_all: $(BUILD_DIR)/kiwi.bin
@echo "make_all DONE"
################################
# flags
################################
VERSION = -DVERSION_MAJ=$(VERSION_MAJ) -DVERSION_MIN=$(VERSION_MIN)
VER = v$(VERSION_MAJ).$(VERSION_MIN)
V = -Dv$(VERSION_MAJ)_$(VERSION_MIN)
INT_FLAGS += $(VERSION) -DKIWI -DKIWISDR
INT_FLAGS += -DARCH_$(ARCH) -DCPU_$(CPU) -DARCH_CPU=$(CPU) -DARCH_CPU_S=STRINGIFY\($(CPU)\) $(addprefix -DPLATFORM_,$(PLATFORMS))
INT_FLAGS += -DARCH_DIR=STRINGIFY\($(ARCH_DIR)\)
INT_FLAGS += -DDIR_CFG=STRINGIFY\($(DIR_CFG)\) -DDIR_DATA=STRINGIFY\($(DIR_DATA)\) -DCFG_PREFIX=STRINGIFY\($(CFG_PREFIX)\)
INT_FLAGS += -DBUILD_DIR=STRINGIFY\($(BUILD_DIR)\) -DREPO_NAME=STRINGIFY\($(REPO_NAME)\) -DREPO_GIT=STRINGIFY\($(REPO_GIT)\)
################################
# build included makefile
################################
MF_INC := $(GEN_DIR)/Makefile.inc
START_MF_INC = | tee $(MF_INC) 2>&1
APPEND_MF_INC = | tee -a $(MF_INC) 2>&1
.PHONY: build_makefile_inc
build_makefile_inc:
# consolidate flags into indirect Makefile since Make will be re-invoked
@echo "----------------"
@echo "building" $(MF_INC)
@echo $(VER)
ifeq ($(DEBIAN_DEVSYS),$(DEBIAN))
@echo "Debian $(DEBIAN_VERSION)"
endif
@echo PROJECT = $(PROJECT)
@echo ARCH = $(ARCH)
@echo CPU = $(CPU)
@echo PLATFORMS = $(PLATFORMS)
@echo DEBUG = $(DEBUG)
@echo GDB = $(GDB)
@echo XC = $(XC)
@echo
#
@echo $(I) $(START_MF_INC)
#
@echo $(APPEND_MF_INC)
@echo $(CFLAGS) $(APPEND_MF_INC)
#
@echo $(APPEND_MF_INC)
@echo $(EXT_DEFINES) $(APPEND_MF_INC)
#
@echo $(APPEND_MF_INC)
@echo $(INT_FLAGS) $(APPEND_MF_INC)
#
@echo "----------------"
################################
# Makefile dependencies
################################
# dependence on VERSION_{MAJ,MIN}
MAKEFILE_DEPS = main.cpp
MF_FILES = $(addsuffix .o,$(basename $(notdir $(MAKEFILE_DEPS))))
MF_OBJ = $(addprefix $(OBJ_DIR)/,$(MF_FILES))
MF_O3 = $(wildcard $(addprefix $(OBJ_DIR_O3)/,$(MF_FILES)))
$(MF_OBJ) $(MF_O3): Makefile
################################
# PRU (not currently used)
################################
PASM_INCLUDES = $(wildcard pru/pasm/*.h)
PASM_SOURCE = $(wildcard pru/pasm/*.c)
pas: $(PASM_INCLUDES) $(PASM_SOURCE) Makefile
$(CC) -Wall -D_UNIX_ -I./pru/pasm $(PASM_SOURCE) -o pas
pru/pru_realtime.bin: pas pru/pru_realtime.p pru/pru_realtime.h pru/pru_realtime.hp
(cd pru; ../pas -V3 -b -L -l -D_PASM_ -D$(SETUP) pru_realtime.p)
################################
# FPGA embedded CPU
################################
# OTHER_DIR set in Makefile of an extension wanting USE_OTHER FPGA framework
ifeq ($(OTHER_DIR),)
PROJECT = "KiwiSDR"
else
OTHER_DIR2 = -x $(OTHER_DIR)
OTHER_CONFIG = $(subst ../../,../,$(OTHER_DIR)/other.config)
endif
$(GEN_ASM): kiwi.config verilog/kiwi.inline.vh $(wildcard e_cpu/asm/*)
(cd e_cpu; make OTHER_DIR="$(OTHER_DIR2)")
$(GEN_OTHER_ASM): $(OTHER_CONFIG) e_cpu/other.config $(wildcard e_cpu/asm/*)
(cd e_cpu; make gen_other OTHER_DIR="$(OTHER_DIR2)")
$(OUT_ASM): $(wildcard e_cpu/*.asm)
(cd e_cpu; make no_gen OTHER_DIR="$(OTHER_DIR2)")
asm_binary:
(cd e_cpu; make binary OTHER_DIR="$(OTHER_DIR2)")
asm_debug:
(cd e_cpu; make debug OTHER_DIR="$(OTHER_DIR2)")
asm_stat:
(cd e_cpu; make stat OTHER_DIR="$(OTHER_DIR2)")
################################
# noip.com DDNS DUC
################################
$(GEN_NOIP2): pkgs/noip2/noip2.c
(cd pkgs/noip2; make)
################################
# web server content
################################
#
# How the file optimization strategy works:
#
# FIXME
# talk about: optim website used, NFS_READ_ONLY, EDATA_DEVEL bypass mode (including -fopt argument)
# x should not be embedding version # in min file, but adding on demand like plain file
# what to do about version number in .gz files though?
# no "-zip" for html files because of possible %[] substitution (replace %[] substitutions)
#
# TODO
# x concat embed
# EDATA_ALWAYS/2
# x jpg/png crush in file_optim
# x clean target that removes .min .gz
#
# CHECK
# does google analytics html head insert still work?
# x ant_switch still works?
# x update from v1.2 still works?
# mobile works okay?
#
#
# 1) file_optim program is used to create minified and possibly gzipped versions of web server
# content files (e.g. .js .css .html .jpg .png) Because the optimized versions of individual
# files are included in the distro the minimization process, which uses an external website and
# is very time consuming, is not performed by individual Kiwis as part of the update process.
# But file_optim is run as part of the standard Makefile rules to account for any changes a user
# may make as part of their own development (i.e. so a make install will continue to work for them)
#
# 2) Web server code has been modified to lookup optimized alternatives first, i.e. a reference to
# xxx.js will cause lookups in order to: xxx.min.js.gz, xxx.min.js then finally xxx.js
#
# 3) Packaging of files. All files are left available individually to support EDATA_DEVEL development.
# But for EDATA_EMBED production the minified versions of many files (typically .js and .css) are
# concatenated together and gzipped as a single package file.
#
# 4) There are special cases. All the mapping-related files are packaged together so they can be
# loaded on-demand by the TDoA extension and admin GPS tab. Extension files are not packaged so they
# can be loaded on-demand.
#
#
# constituents of edata_embed:
# extensions/*/*.min.{js,css}[.gz]
# kiwi/{admin,mfg}.min.html
# kiwi/{admin,admin_sdr,mfg}.min.js[.gz] don't package: conflict with each other
# kiwi/kiwi_js_load.min.js don't package: used by dynamic loader
# kiwisdr.min.{js,css}.gz generated package: font-awesome, text-security, w3, w3-ext, openwebrx, kiwi
# openwebrx/{index}.min.html
# openwebrx/robots.txt
# pkgs/js/*.min.js[.gz]
# pkgs/xdLocalStorage/*
# pkgs_maps/pkgs_maps.min.{js,css}[.gz] generated package
#
#
# DANGER: old $(TOOLS_DIR)/files_optim in v1.289 prints "panic: argc" when given the args presented
# from the v1.290 Makefile when invoked by the Makefile inline $(shell ...)
# So in v1.290 change name of utility to "file_optim" (NB: "file" not "files") so old files_optim will not be invoked.
# This is an issue because a download & make clean of a new version doesn't remove the old $(TOOLS_DIR)
#
# files optimizer
FILE_OPTIM = $(TOOLS_DIR)/file_optim
FILE_OPTIM_SRC = tools/file_optim.cpp
$(FILE_OPTIM): $(FILE_OPTIM_SRC)
# use $(I) here, not full $(MF_INC)
@echo "$(CC) ... -g $(FILE_OPTIM_SRC) -o $@"
@$(CC) $(I) -g $(FILE_OPTIM_SRC) -o $@
-include $(wildcard web/*/Makefile)
-include $(wildcard web/extensions/*/Makefile)
-include web/Makefile
# NB: $(FILE_OPTIM) *MUST* be here so "make install" builds EDATA_EMBED properly when NFS_READ_ONLY == yes
#EDATA_DEP = web/kiwi/Makefile web/openwebrx/Makefile web/pkgs/Makefile web/extensions/Makefile $(wildcard extensions/*/Makefile) $(FILE_OPTIM)
EDATA_DEP = web/kiwi/Makefile web/openwebrx/Makefile web/pkgs/Makefile web/extensions/Makefile $(FILE_OPTIM)
.PHONY: foptim_gen foptim_list foptim_clean clean_min clean_gz
# NEVER let target Kiwis contact external optimization site via foptim_gen.
# If customers are developing they need to do a "make install" on a development machine
# OR a "make fopt/foptim" on the Kiwi to explicitly build the optimized files (but only if not NFS_READ_ONLY)
ifeq ($(DEBIAN_DEVSYS),$(DEVSYS))
foptim_gen: foptim_files_embed foptim_ext foptim_files_maps
@echo
else
foptim_gen:
endif
ifeq ($(NFS_READ_ONLY),yes)
fopt foptim:
@echo "can't do fopt/foptim because of NFS_READ_ONLY=$(NFS_READ_ONLY)"
@echo "(assumed foptim_gen performed on development machine with a make install)"
else
fopt foptim: foptim_files_embed foptim_ext foptim_files_maps
endif
foptim_list: loptim_embed loptim_ext loptim_maps
CLEAN_MIN_GZ_2 = $(wildcard $(CLEAN_MIN_GZ))
ifeq ($(CLEAN_MIN_GZ_2),)
foptim_clean clean_min clean_gz: roptim_embed roptim_ext roptim_maps
@echo "nothing to clean"
else
foptim_clean clean_min clean_gz: roptim_embed roptim_ext roptim_maps
@echo "removing:"
@-ls -la $(CLEAN_MIN_GZ_2)
@-rm $(CLEAN_MIN_GZ_2)
endif
FILES_EMBED_SORTED_NW = $(sort $(EMBED_NW) $(EXT_EMBED_NW) $(PKGS_MAPS_EMBED_NW))
FILES_ALWAYS_SORTED_NW = $(sort $(FILES_ALWAYS))
FILES_ALWAYS2_SORTED_NW = $(sort $(FILES_ALWAYS2))
EDATA_EMBED = $(GEN_DIR)/edata_embed.cpp
EDATA_ALWAYS = $(GEN_DIR)/edata_always.cpp
EDATA_ALWAYS2 = $(GEN_DIR)/edata_always2.cpp
$(EDATA_EMBED): $(EDATA_DEP) $(addprefix web/,$(FILES_EMBED_SORTED_NW))
(cd web; perl mkdata.pl edata_embed $(FILES_EMBED_SORTED_NW) >../$(EDATA_EMBED))
$(EDATA_ALWAYS): $(EDATA_DEP) $(addprefix web/,$(FILES_ALWAYS_SORTED_NW))
(cd web; perl mkdata.pl edata_always $(FILES_ALWAYS_SORTED_NW) >../$(EDATA_ALWAYS))
$(EDATA_ALWAYS2): $(EDATA_DEP) $(addprefix web/,$(FILES_ALWAYS2_SORTED_NW))
(cd web; perl mkdata.pl edata_always2 $(FILES_ALWAYS2_SORTED_NW) >../$(EDATA_ALWAYS2))
################################
# vars
################################
.PHONY: vars
vars: make_prereq
make $(MAKE_ARGS) make_vars
.PHONY: make_vars
make_vars: check_detect
@echo version $(VER)
@echo
@echo UNAME = $(UNAME)
@echo DEBIAN_DEVSYS = $(DEBIAN_DEVSYS)
@echo DEBIAN_VERSION = $(DEBIAN_VERSION)
@echo DEBIAN_10_AND_LATER = $(DEBIAN_10_AND_LATER)
@echo DEBIAN_12_AND_LATER = $(DEBIAN_12_AND_LATER)
@echo
@echo BBAI_64 = $(BBAI_64)
@echo BBAI = $(BBAI)
@echo RPI = $(RPI)
@echo BBG_BBB = $(BBG_BBB)
@echo
@echo PROJECT = $(PROJECT)
@echo ARCH = $(ARCH)
@echo CPU = $(CPU)
@echo PLATFORMS = $(PLATFORMS)
@echo
@echo REPO_USER = $(REPO_USER)
@echo REPO_GIT = $(REPO_GIT)
@echo REPO = $(REPO)
@echo
@echo BUILD_DIR = $(BUILD_DIR)
@echo OTHER_DIR = $(OTHER_DIR)
@echo EXISTS_OTHER_BITFILE = $(shell test -f $(V_DIR)/KiwiSDR.other.bit && echo true)
@echo OBJ_DIR = $(OBJ_DIR)
@echo OBJ_DIR_O3 = $(OBJ_DIR_O3)
@echo OBJ_DIR_DEFAULT = $(OBJ_DIR_DEFAULT)
@echo CMD_DEPS = $(CMD_DEPS)
@echo OPT = $(OPT)
@echo CFLAGS = $(CFLAGS)
@echo CPP_FLAGS = $(CPP_FLAGS)
@echo
@echo DEPS = $(OBJECTS:.o=.d)
@echo
@echo SRC_DEPS = $(SRC_DEPS)
@echo
@echo BIN_DEPS = $(BIN_DEPS)
@echo
@echo LIBS_DEP = $(LIBS_DEP)
@echo
@echo SUB_MAKE_DEPS = $(SUB_MAKE_DEPS)
@echo
@echo DTS_DEP_SRC = $(DTS_DEP_SRC)
@echo DTS_DEP_SRC2 = $(DTS_DEP_SRC2)
@echo DTS_DEP_DST = $(DTS_DEP_DST)
@echo DTS_DEP_DST2 = $(DTS_DEP_DST2)
@echo
@echo GEN_ASM = $(GEN_ASM)
@echo
@echo GEN_OTHER_ASM = $(GEN_OTHER_ASM)
@echo
@echo FILES_EMBED = $(FILES_EMBED)
@echo
@echo FILES_EXT = $(FILES_EXT)
@echo
@echo FILES_ALWAYS = $(FILES_ALWAYS)
@echo
@echo FILES_ALWAYS2 = $(FILES_ALWAYS2)
@echo
@echo EXT_SKIP = $(EXT_SKIP)
@echo
@echo EXT_SKIP1 = $(EXT_SKIP1)
@echo
@echo INT_EXT_DIRS1 = $(INT_EXT_DIRS1)
@echo
@echo INT_EXT_DIRS = $(INT_EXT_DIRS)
@echo
@echo PVT_EXT_DIRS = $(PVT_EXT_DIRS)
@echo
@echo EXT_SUBDIRS = $(EXT_SUBDIRS)
@echo
@echo EXT_DIRS = $(EXT_DIRS)
@echo
@echo PVT_EXTS = $(PVT_EXTS)
@echo
@echo INT_EXTS = $(INT_EXTS)
@echo
@echo EXTS = $(EXTS)
@echo
@echo DIRS = $(DIRS)
@echo
@echo DIRS_O3 = $(DIRS_O3)
@echo
@echo VPATH = $(VPATH)
@echo
@echo I = $(I)
@echo
@echo CFILES = $(CFILES)
@echo
@echo CFILES_O3 = $(CFILES_O3)
@echo
@echo CFILES_KEEP = $(CFILES_KEEP)
@echo
@echo OBJECTS = $(OBJECTS)
@echo
@echo O3_OBJECTS = $(O3_OBJECTS)
@echo
@echo KEEP_OBJECTS = $(KEEP_OBJECTS)
@echo
@echo EXT_OBJECTS = $(EXT_OBJECTS)
@echo
@echo MF_FILES = $(MF_FILES)
@echo
@echo MF_OBJ = $(MF_OBJ)
@echo
@echo MF_O3 = $(MF_O3)
@echo
@echo PKGS = $(PKGS)
.PHONY: makefiles
makefiles:
@echo
@echo $(MF_INC)
@cat $(MF_INC)
.PHONY: build_log blog
build_log blog:
@-tail -n 500 -f /root/build.log
################################
# general build rules
################################
CSRC = $(notdir $(CFILES))
OBJECTS1 = $(CSRC:%.c=$(OBJ_DIR)/%.o)
OBJECTS = $(OBJECTS1:%.cpp=$(OBJ_DIR)/%.o)
CSRC_O3 = $(notdir $(CFILES_O3))
O3_OBJECTS1 = $(CSRC_O3:%.c=$(OBJ_DIR_O3)/%.o)
O3_OBJECTS = $(O3_OBJECTS1:%.cpp=$(OBJ_DIR_O3)/%.o)
CSRC_KEEP = $(notdir $(CFILES_KEEP))
KEEP_OBJECTS1 = $(CSRC_KEEP:%.c=$(KEEP_DIR)/%.o)
KEEP_OBJECTS = $(KEEP_OBJECTS1:%.cpp=$(KEEP_DIR)/%.o)
ALL_OBJECTS = $(OBJECTS) $(O3_OBJECTS) $(KEEP_OBJECTS)
# pull in dependency info for *existing* .o files
-include $(OBJECTS:.o=.d)
-include $(O3_OBJECTS:.o=.d)
-include $(KEEP_OBJECTS:.o=.d)
-include $(DEVEL_DEPS:.o=.d)
-include $(EMBED_DEPS:.o=.d)
-include $(EXTS_DEPS:.o=.d)
ifeq ($(DEBIAN_DEVSYS),$(DEBIAN))
# FIXME: isn't there a better way to do this in GNU make?
EXISTS_RX4_WF4 := $(shell test -f KiwiSDR.rx4.wf4.bit && echo true)
ifeq ($(EXISTS_RX4_WF4),true)
else
KiwiSDR.rx4.wf4.bit:
endif
EXISTS_RX8_WF2 := $(shell test -f KiwiSDR.rx8.wf2.bit && echo true)
ifeq ($(EXISTS_RX8_WF2),true)
else
KiwiSDR.rx8.wf2.bit:
endif
EXISTS_RX3_WF3 := $(shell test -f KiwiSDR.rx3.wf3.bit && echo true)
ifeq ($(EXISTS_RX3_WF3),true)
else
KiwiSDR.rx3.wf3.bit:
endif
EXISTS_RX14_WF0 := $(shell test -f KiwiSDR.rx14.wf0.bit && echo true)
ifeq ($(EXISTS_RX14_WF0),true)
else
KiwiSDR.rx14.wf0.bit:
endif
EXISTS_OTHER := $(shell test -f KiwiSDR.other.bit && echo true)
ifeq ($(EXISTS_OTHER),true)
else
KiwiSDR.other.bit:
endif
endif
#
# IMPORTANT
#
# By not including foptim_gen in the dependency list for the development build target $(BUILD_DIR)/kiwi.bin
# the external optimization site won't be called all the time as incremental changes are made to
# the js/css/html/image files.
#
# But this means a "make install" must be performed on the *development machine* prior to installation
# on targets or before uploading as a software release.
# Previously doing a "make install" on the development machine made no sense and was flagged as an error.
#
$(BUILD_DIR)/kiwi.bin: $(OBJ_DIR) $(OBJ_DIR_O3) $(KEEP_DIR) $(ALL_OBJECTS) $(BIN_DEPS) $(DEVEL_DEPS) $(EXTS_DEPS)
ifneq ($(SAN),1)
ifeq ($(KIWI_SKIP_LINK),true)
@echo "DEVSYS: SKIP OF KIWI.BIN LINK STEP"
touch $@
else
@echo $(CPP) $(LDFLAGS) "..." $(DEVEL_DEPS) $(EXTS_DEPS) $(LIBS) -o $(BUILD_OBJ)
@$(CPP) $(LDFLAGS) $(ALL_OBJECTS) $(DEVEL_DEPS) $(EXTS_DEPS) $(LIBS) -o $(BUILD_OBJ)
endif
else
@echo loader skipped for static analysis
endif
$(BUILD_DIR)/kiwid.bin: foptim_gen $(OBJ_DIR) $(OBJ_DIR_O3) $(KEEP_DIR) $(ALL_OBJECTS) $(BIN_DEPS) $(EMBED_DEPS) $(EXTS_DEPS)
ifneq ($(SAN),1)
ifeq ($(KIWI_SKIP_LINK),true)
@echo "DEVSYS: SKIP OF KIWID.BIN LINK STEP"
touch $@
else
@echo $(CPP) $(LDFLAGS) "..." $(EMBED_DEPS) $(EXTS_DEPS) $(LIBS) -o $@
@$(CPP) $(LDFLAGS) $(ALL_OBJECTS) $(EMBED_DEPS) $(EXTS_DEPS) $(LIBS) -o $@
endif
else
@echo loader skipped for static analysis
endif
# auto generation of dependency info, see:
# http://scottmcpeak.com/autodepend/autodepend.html
# http://make.mad-scientist.net/papers/advanced-auto-dependency-generation
df = $(basename $@)
POST_PROCESS_DEPS = \
@mv -f $(df).d $(df).d.tmp; \
sed -e 's|.*:|$(df).o:|' < $(df).d.tmp > $(df).d; \
sed -e 's/.*://' -e 's/\\$$//' < $(df).d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $(df).d; \
rm -f $(df).d.tmp
# special
OPTS_VIS_UNOPT = $(strip $(V) $(DEBUG) $(XC) $(VIS_UNOPT))
OPTS_VIS_OPT = $(strip $(V) $(DEBUG) $(XC) $(VIS_OPT))
$(OBJ_DIR_DEFAULT)/web_devel.o: web/web.cpp config.h
$(CPP) $(OPTS_VIS_UNOPT) @$(MF_INC) $(CPP_FLAGS) -DEDATA_DEVEL -c -o $@ $<
$(POST_PROCESS_DEPS)
$(OBJ_DIR_DEFAULT)/web_embed.o: web/web.cpp config.h
$(CPP) $(OPTS_VIS_UNOPT) @$(MF_INC) $(CPP_FLAGS) -DEDATA_EMBED -c -o $@ $<
$(POST_PROCESS_DEPS)
$(OBJ_DIR)/edata_embed.o: $(EDATA_EMBED)
$(CPP) $(OPTS_VIS_UNOPT) @$(MF_INC) $(CPP_FLAGS) -c -o $@ $<
$(POST_PROCESS_DEPS)
$(KEEP_DIR)/edata_always.o: $(EDATA_ALWAYS)
$(CPP) $(OPTS_VIS_UNOPT) @$(MF_INC) $(CPP_FLAGS) -c -o $@ $<
$(POST_PROCESS_DEPS)
$(KEEP_DIR)/edata_always2.o: $(EDATA_ALWAYS2)
$(CPP) $(OPTS_VIS_UNOPT) @$(MF_INC) $(CPP_FLAGS) -c -o $@ $<
$(POST_PROCESS_DEPS)
$(OBJ_DIR)/ext_init.o: $(GEN_DIR)/ext_init.cpp
$(CPP) $(OPTS_VIS_UNOPT) @$(MF_INC) $(CPP_FLAGS) -c -o $@ $<
$(POST_PROCESS_DEPS)