forked from ProcursusTeam/Procursus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
1401 lines (1250 loc) · 72.3 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
ifeq ($(firstword $(subst ., ,$(MAKE_VERSION))),3)
$(error Install latest make from Procursus - sudo apt install make)
endif
export LANG := C
ifeq ($(shell LANG=C /usr/bin/env bash --version | grep -iq 'version 5' && echo 1),1)
SHELL := /usr/bin/env bash
else
$(error Install bash 5.0)
endif
# Unset sysroot, we manage that ourselves.
SYSROOT :=
UNAME := $(shell uname -s)
UNAME_M := $(shell uname -m)
SUBPROJECTS += $(STRAPPROJECTS)
ifneq ($(shell umask),0022)
$(error Please run `umask 022` before running this)
endif
RELATIVE_RPATH := 0
MEMO_TARGET ?= darwin-arm64
MEMO_CFVER ?= 1700
# iOS 13.0 == 1665.15.
CFVER_WHOLE := $(shell echo $(MEMO_CFVER) | cut -d. -f1)
ifeq ($(shell [ "$(CFVER_WHOLE)" -ge 1800 ] && [ "$(CFVER_WHOLE)" -lt 1900 ] && echo 1),1)
IPHONEOS_DEPLOYMENT_TARGET := 15.0
APPLETVOS_DEPLOYMENT_TARGET := 15.0
AUDIOOS_DEPLOYMENT_TARGET := 15.0
BRIDGEOS_DEPLOYMENT_TARGET := 6.0
WATCHOS_DEPLOYMENT_TARGET := 8.0
MACOSX_DEPLOYMENT_TARGET := 12.0
DARWIN_DEPLOYMENT_VERSION := 21
MACOSX_SUITE_NAME := monterey
override MEMO_CFVER := 1800
else ifeq ($(shell [ "$(CFVER_WHOLE)" -ge 1700 ] && [ "$(CFVER_WHOLE)" -lt 1800 ] && echo 1),1)
IPHONEOS_DEPLOYMENT_TARGET := 14.0
APPLETVOS_DEPLOYMENT_TARGET := 14.0
AUDIOOS_DEPLOYMENT_TARGET := 14.0
BRIDGEOS_DEPLOYMENT_TARGET := 5.0
WATCHOS_DEPLOYMENT_TARGET := 7.0
MACOSX_DEPLOYMENT_TARGET := 11.0
DARWIN_DEPLOYMENT_VERSION := 20
MACOSX_SUITE_NAME := big_sur
override MEMO_CFVER := 1700
else ifeq ($(shell [ "$(CFVER_WHOLE)" -ge 1600 ] && [ "$(CFVER_WHOLE)" -lt 1700 ] && echo 1),1)
IPHONEOS_DEPLOYMENT_TARGET := 13.0
APPLETVOS_DEPLOYMENT_TARGET := 13.0
AUDIOOS_DEPLOYMENT_TARGET := 13.0
BRIDGEOS_DEPLOYMENT_TARGET := 4.0
WATCHOS_DEPLOYMENT_TARGET := 6.0
MACOSX_DEPLOYMENT_TARGET := 10.15
DARWIN_DEPLOYMENT_VERSION := 19
override MEMO_CFVER := 1600
else ifeq ($(shell [ "$(CFVER_WHOLE)" -ge 1500 ] && [ "$(CFVER_WHOLE)" -lt 1600 ] && echo 1),1)
IPHONEOS_DEPLOYMENT_TARGET := 12.0
APPLETVOS_DEPLOYMENT_TARGET := 12.0
AUDIOOS_DEPLOYMENT_TARGET := 12.0
BRIDGEOS_DEPLOYMENT_TARGET := 3.0
WATCHOS_DEPLOYMENT_TARGET := 5.0
MACOSX_DEPLOYMENT_TARGET := 10.14
DARWIN_DEPLOYMENT_VERSION := 18
override MEMO_CFVER := 1500
else
$(error Unsupported CoreFoundation version)
endif
export MACOSX_DEPLOYMENT_TARGET
ifeq ($(shell [ "$(MEMO_TARGET)" = "iphoneos-arm64" ] || [ "$(MEMO_TARGET)" = "iphoneos-arm64-ramdisk" ] && echo 1),1)
ifneq ($(MEMO_QUIET),1)
$(warning Building for iOS)
endif # ($(MEMO_QUIET),1)
MEMO_ARCH := arm64
PLATFORM := iphoneos
DEB_ARCH := iphoneos-arm
GNU_HOST_TRIPLE := aarch64-apple-darwin
PLATFORM_VERSION_MIN := -miphoneos-version-min=$(IPHONEOS_DEPLOYMENT_TARGET)
RUST_TARGET := aarch64-apple-ios
LLVM_TARGET := arm64-apple-ios$(IPHONEOS_DEPLOYMENT_TARGET)
MEMO_PREFIX ?=
MEMO_SUB_PREFIX ?= /usr
MEMO_ALT_PREFIX ?= /local
MEMO_LAUNCHCTL_PREFIX ?= $(MEMO_PREFIX)
GNU_PREFIX :=
ON_DEVICE_SDK_PATH := $(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/SDKs/iPhoneOS.sdk
BARE_PLATFORM := iPhoneOS
export IPHONEOS_DEPLOYMENT_TARGET
else ifeq ($(MEMO_TARGET),iphoneos-arm64-rootless)
ifneq ($(MEMO_QUIET),1)
$(warning Building for iOS with rootless prefix)
endif # ($(MEMO_QUIET),1)
MEMO_ARCH := arm64
PLATFORM := iphoneos
DEB_ARCH := iphoneos-arm64
GNU_HOST_TRIPLE := aarch64-apple-darwin
PLATFORM_VERSION_MIN := -miphoneos-version-min=$(IPHONEOS_DEPLOYMENT_TARGET)
RUST_TARGET := aarch64-apple-ios
LLVM_TARGET := arm64-apple-ios$(IPHONEOS_DEPLOYMENT_TARGET)
MEMO_PREFIX ?= /private/preboot/procursus
MEMO_SUB_PREFIX ?= /usr
MEMO_ALT_PREFIX ?=
MEMO_LAUNCHCTL_PREFIX ?= $(MEMO_PREFIX)
GNU_PREFIX :=
ON_DEVICE_SDK_PATH := $(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/SDKs/iPhoneOS.sdk
BARE_PLATFORM := iPhoneOS
export IPHONEOS_DEPLOYMENT_TARGET
else ifeq ($(MEMO_TARGET),iphoneos-arm64e-rootless)
ifneq ($(MEMO_QUIET),1)
$(warning Building for iOS arm64e with rootless prefix)
endif # ($(MEMO_QUIET),1)
MEMO_ARCH := arm64e
PLATFORM := iphoneos
DEB_ARCH := iphoneos-arm64e
GNU_HOST_TRIPLE := aarch64-apple-darwin
PLATFORM_VERSION_MIN := -miphoneos-version-min=$(IPHONEOS_DEPLOYMENT_TARGET)
RUST_TARGET := aarch64-apple-ios
LLVM_TARGET := arm64e-apple-ios$(IPHONEOS_DEPLOYMENT_TARGET)
MEMO_PREFIX ?= /private/preboot/procursus
MEMO_SUB_PREFIX ?= /usr
MEMO_ALT_PREFIX ?=
MEMO_LAUNCHCTL_PREFIX ?= $(MEMO_PREFIX)
GNU_PREFIX :=
ON_DEVICE_SDK_PATH := $(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/SDKs/iPhoneOS.sdk
BARE_PLATFORM := iPhoneOS
export IPHONEOS_DEPLOYMENT_TARGET
else ifeq ($(MEMO_TARGET),iphoneos-arm64e)
ifneq ($(MEMO_QUIET),1)
$(warning Building for iOS arm64e)
endif # ($(MEMO_QUIET),1)
MEMO_ARCH := arm64e
PLATFORM := iphoneos
DEB_ARCH := iphoneos-arm64e
GNU_HOST_TRIPLE := aarch64-apple-darwin
PLATFORM_VERSION_MIN := -miphoneos-version-min=$(IPHONEOS_DEPLOYMENT_TARGET)
RUST_TARGET := aarch64-apple-ios
LLVM_TARGET := arm64e-apple-ios$(IPHONEOS_DEPLOYMENT_TARGET)
MEMO_PREFIX ?=
MEMO_SUB_PREFIX ?= /usr
MEMO_ALT_PREFIX ?= /local
MEMO_LAUNCHCTL_PREFIX ?= $(MEMO_PREFIX)
GNU_PREFIX :=
ON_DEVICE_SDK_PATH := $(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/SDKs/iPhoneOS.sdk
BARE_PLATFORM := iPhoneOS
export IPHONEOS_DEPLOYMENT_TARGET
else ifeq ($(MEMO_TARGET),appletvos-arm64)
ifneq ($(MEMO_QUIET),1)
$(warning Building for tvOS)
endif # ($(MEMO_QUIET),1)
MEMO_ARCH := arm64
PLATFORM := appletvos
DEB_ARCH := appletvos-arm64
GNU_HOST_TRIPLE := aarch64-apple-darwin
PLATFORM_VERSION_MIN := -mappletvos-version-min=$(APPLETVOS_DEPLOYMENT_TARGET)
RUST_TARGET := aarch64-apple-tvos
LLVM_TARGET := arm64-apple-tvos$(APPLETVOS_DEPLOYMENT_TARGET)
MEMO_PREFIX ?=
MEMO_SUB_PREFIX ?= /usr
MEMO_ALT_PREFIX ?= /local
MEMO_LAUNCHCTL_PREFIX ?= $(MEMO_PREFIX)
GNU_PREFIX :=
ON_DEVICE_SDK_PATH := $(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/SDKs/AppleTVOS.sdk
BARE_PLATFORM := AppleTVOS
export APPLETVOS_DEPLOYMENT_TARGET
else ifeq ($(MEMO_TARGET),appletvos-arm64e)
ifneq ($(MEMO_QUIET),1)
$(warning Building for tvOS arm64e)
endif # ($(MEMO_QUIET),1)
MEMO_ARCH := arm64e
PLATFORM := appletvos
DEB_ARCH := appletvos-arm64e
GNU_HOST_TRIPLE := aarch64-apple-darwin
PLATFORM_VERSION_MIN := -mappletvos-version-min=$(APPLETVOS_DEPLOYMENT_TARGET)
RUST_TARGET := aarch64-apple-tvos
LLVM_TARGET := arm64e-apple-tvos$(APPLETVOS_DEPLOYMENT_TARGET)
MEMO_PREFIX ?=
MEMO_SUB_PREFIX ?= /usr
MEMO_ALT_PREFIX ?= /local
MEMO_LAUNCHCTL_PREFIX ?= $(MEMO_PREFIX)
GNU_PREFIX :=
ON_DEVICE_SDK_PATH := $(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/SDKs/AppleTVOS.sdk
BARE_PLATFORM := AppleTVOS
export APPLETVOS_DEPLOYMENT_TARGET
else ifeq ($(MEMO_TARGET),audioos-arm64)
ifneq ($(MEMO_QUIET),1)
$(warning Building for audioOS)
endif # ($(MEMO_QUIET),1)
MEMO_ARCH := arm64
PLATFORM := appletvos # Platform-wise, audioos ~ appletvos (although some frameworks and stuff may be missing)
DEB_ARCH := audioos-arm64
GNU_HOST_TRIPLE := aarch64-apple-darwin
PLATFORM_VERSION_MIN := -mappletvos-version-min=$(APPLETVOS_DEPLOYMENT_TARGET)
RUST_TARGET := aarch64-apple-tvos
LLVM_TARGET := arm64-apple-tvos$(APPLETVOS_DEPLOYMENT_TARGET)
MEMO_PREFIX ?=
MEMO_SUB_PREFIX ?= /usr
MEMO_ALT_PREFIX ?= /local
MEMO_LAUNCHCTL_PREFIX ?= $(MEMO_PREFIX)
GNU_PREFIX :=
ON_DEVICE_SDK_PATH := $(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/SDKs/AppleTVOS.sdk
BARE_PLATFORM := AppleTVOS
export AUDIOOS_DEPLOYMENT_TARGET
else ifeq ($(MEMO_TARGET),bridgeos-arm64)
ifneq ($(MEMO_QUIET),1)
$(warning Building for BridgeOS)
endif # ($(MEMO_QUIET),1)
MEMO_ARCH := arm64
PLATFORM := iphoneos # find me a BridgeOS.sdk and you win.
DEB_ARCH := bridgeos-arm64
GNU_HOST_TRIPLE := aarch64-apple-darwin
PLATFORM_VERSION_MIN := --target=arm64-apple-bridgeos$(BRIDGEOS_DEPLOYMENT_TARGET)
RUST_TARGET := aarch64-apple-bridgeos
LLVM_TARGET := arm64-apple-bridgeos$(BRIDGEOS_DEPLOYMENT_TARGET)
MEMO_PREFIX ?=
MEMO_SUB_PREFIX ?= /usr
MEMO_ALT_PREFIX ?= /local
MEMO_LAUNCHCTL_PREFIX ?= $(MEMO_PREFIX)
GNU_PREFIX :=
ON_DEVICE_SDK_PATH := $(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/SDKs/BridgeOS.sdk
BARE_PLATFORM := BridgeOS
export BRIDGEOS_DEPLOYMENT_TARGET
else ifeq ($(MEMO_TARGET),watchos-arm64_32)
ifneq ($(MEMO_QUIET),1)
$(warning Building for WatchOS)
endif # ($(MEMO_QUIET),1)
MEMO_ARCH := arm64_32
PLATFORM := watchos
DEB_ARCH := watchos-arm64-32
GNU_HOST_TRIPLE := aarch64-apple-darwin
PLATFORM_VERSION_MIN := -mwatchos-version-min=$(WATCHOS_DEPLOYMENT_TARGET)
RUST_TARGET := aarch64-apple-watchos
LLVM_TARGET := arm64-apple-watchos$(WATCHOS_DEPLOYMENT_TARGET)
MEMO_PREFIX ?=
MEMO_SUB_PREFIX ?= /usr
MEMO_ALT_PREFIX ?= /local
MEMO_LAUNCHCTL_PREFIX ?= $(MEMO_PREFIX)
GNU_PREFIX :=
ON_DEVICE_SDK_PATH := $(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/SDKs/WatchOS.sdk
BARE_PLATFORM := WatchOS
export WATCHOS_DEPLOYMENT_TARGET
else ifeq ($(shell [ "$(MEMO_TARGET)" = "watchos-armv7k" ] || [ "$(MEMO_TARGET)" = "watchos-armv7k-ramdisk" ] && echo 1),1)
ifneq ($(MEMO_QUIET),1)
$(warning Building for WatchOS)
endif # ($(MEMO_QUIET),1)
MEMO_ARCH := armv7k
PLATFORM := watchos
DEB_ARCH := watchos-armv7k
GNU_HOST_TRIPLE := armv7k-apple-darwin
PLATFORM_VERSION_MIN := -mwatchos-version-min=$(WATCHOS_DEPLOYMENT_TARGET)
RUST_TARGET := armv7k-apple-watchos
LLVM_TARGET := armv7k-apple-watchos$(WATCHOS_DEPLOYMENT_TARGET)
MEMO_PREFIX ?=
MEMO_SUB_PREFIX ?= /usr
MEMO_ALT_PREFIX ?= /local
MEMO_LAUNCHCTL_PREFIX ?= $(MEMO_PREFIX)
GNU_PREFIX :=
ON_DEVICE_SDK_PATH := $(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/SDKs/WatchOS.sdk
BARE_PLATFORM := WatchOS
export WATCHOS_DEPLOYMENT_TARGET
else ifeq ($(MEMO_TARGET),darwin-arm64e)
ifneq ($(MEMO_QUIET),1)
$(warning Building for macOS arm64e)
endif # ($(MEMO_QUIET),1)
MEMO_ARCH := arm64e
PLATFORM := macosx
DEB_ARCH := darwin-arm64e
GNU_HOST_TRIPLE := aarch64-apple-darwin
RUST_TARGET := $(GNU_HOST_TRIPLE)
LLVM_TARGET := arm64e-apple-macos$(MACOSX_DEPLOYMENT_TARGET)
PLATFORM_VERSION_MIN := -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET)
MEMO_PREFIX ?= /opt/procursus
MEMO_SUB_PREFIX ?=
MEMO_ALT_PREFIX ?=
MEMO_LAUNCHCTL_PREFIX ?=
GNU_PREFIX := g
ON_DEVICE_SDK_PATH := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
BARE_PLATFORM := MacOSX
else ifeq ($(MEMO_TARGET),darwin-arm64)
ifneq ($(MEMO_QUIET),1)
$(warning Building for macOS arm64)
endif # ($(MEMO_QUIET),1)
MEMO_ARCH := arm64
PLATFORM := macosx
DEB_ARCH := darwin-arm64
GNU_HOST_TRIPLE := aarch64-apple-darwin
RUST_TARGET := $(GNU_HOST_TRIPLE)
LLVM_TARGET := arm64-apple-macos$(MACOSX_DEPLOYMENT_TARGET)
PLATFORM_VERSION_MIN := -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET)
MEMO_PREFIX ?= /opt/procursus
MEMO_SUB_PREFIX ?=
MEMO_ALT_PREFIX ?=
MEMO_LAUNCHCTL_PREFIX ?=
GNU_PREFIX := g
ON_DEVICE_SDK_PATH := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
BARE_PLATFORM := MacOSX
else ifeq ($(MEMO_TARGET),darwin-amd64)
ifneq ($(MEMO_QUIET),1)
$(warning Building for macOS amd64)
endif # ($(MEMO_QUIET),1)
MEMO_ARCH := x86_64
PLATFORM := macosx
DEB_ARCH := darwin-amd64
GNU_HOST_TRIPLE := x86_64-apple-darwin
RUST_TARGET := $(GNU_HOST_TRIPLE)
LLVM_TARGET := x86_64-apple-macos$(MACOSX_DEPLOYMENT_TARGET)
PLATFORM_VERSION_MIN := -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET)
MEMO_PREFIX ?= /opt/procursus
MEMO_SUB_PREFIX ?=
MEMO_ALT_PREFIX ?=
MEMO_LAUNCHCTL_PREFIX ?=
GNU_PREFIX := g
ON_DEVICE_SDK_PATH := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
BARE_PLATFORM := MacOSX
else
$(error Platform not supported)
endif
ifeq ($(UNAME),Linux)
ifneq ($(MEMO_QUIET),1)
$(warning Building on GNU Linux)
endif # ($(MEMO_QUIET),1)
TARGET_SYSROOT ?= $(HOME)/cctools/SDK/$(BARE_PLATFORM).sdk
MACOSX_SYSROOT ?= $(HOME)/cctools/SDK/MacOSX.sdk
CC := $(GNU_HOST_TRIPLE)-clang
CXX := $(GNU_HOST_TRIPLE)-clang++
CPP := $(GNU_HOST_TRIPLE)-clang -E
AR := $(GNU_HOST_TRIPLE)-ar
LD := $(GNU_HOST_TRIPLE)-ld
RANLIB := $(GNU_HOST_TRIPLE)-ranlib
STRINGS := $(GNU_HOST_TRIPLE)-strings
STRIP := $(GNU_HOST_TRIPLE)-strip
I_N_T := $(GNU_HOST_TRIPLE)-install_name_tool
NM := $(GNU_HOST_TRIPLE)-nm
LIPO := $(GNU_HOST_TRIPLE)-lipo
OTOOL := $(GNU_HOST_TRIPLE)-otool
LIBTOOL := $(GNU_HOST_TRIPLE)-libtool
CFLAGS_FOR_BUILD := -O2 -pipe
CPPFLAGS_FOR_BUILD := -O2 -pipe
CXXFLAGS_FOR_BUILD := -O2 -pipe
LDFLAGS_FOR_BUILD := -O2 -pipe
else ifeq ($(UNAME),FreeBSD)
ifneq ($(MEMO_QUIET),1)
$(warning Building on FreeBSD)
endif # ($(MEMO_QUIET),1)
TARGET_SYSROOT ?= $(HOME)/cctools/SDK/$(BARE_PLATFORM).sdk
MACOSX_SYSROOT ?= $(HOME)/cctools/SDK/MacOSX.sdk
CC := $(GNU_HOST_TRIPLE)-clang
CXX := $(GNU_HOST_TRIPLE)-clang++
CPP := $(GNU_HOST_TRIPLE)-clang -E
AR := $(GNU_HOST_TRIPLE)-ar
LD := $(GNU_HOST_TRIPLE)-ld
RANLIB := $(GNU_HOST_TRIPLE)-ranlib
STRINGS := $(GNU_HOST_TRIPLE)-strings
STRIP := $(GNU_HOST_TRIPLE)-strip
I_N_T := $(GNU_HOST_TRIPLE)-install_name_tool
NM := $(GNU_HOST_TRIPLE)-nm
LIPO := $(GNU_HOST_TRIPLE)-lipo
OTOOL := $(GNU_HOST_TRIPLE)-otool
LIBTOOL := $(GNU_HOST_TRIPLE)-libtool
PATH := $(GNUBINDIR):$(PATH)
CFLAGS_FOR_BUILD :=
CPPFLAGS_FOR_BUILD :=
CXXFLAGS_FOR_BUILD :=
LDFLAGS_FOR_BUILD :=
else ifeq ($(UNAME),Darwin)
ifeq ($(shell sw_vers -productName),macOS) # Swap to Mac OS X for devices older than Big Sur
ifneq ($(MEMO_QUIET),1)
$(warning Building on MacOS)
endif # ($(MEMO_QUIET),1)
TARGET_SYSROOT ?= $(shell xcrun --sdk $(PLATFORM) --show-sdk-path)
MACOSX_SYSROOT ?= $(shell xcrun --show-sdk-path)
CC := $(shell xcrun --sdk $(PLATFORM) --find cc)
CXX := $(shell xcrun --sdk $(PLATFORM) --find c++)
CPP := $(shell xcrun --sdk $(PLATFORM) --find cc) -E
PATH := /opt/procursus/bin:/opt/procursus/libexec/gnubin:/usr/bin:$(PATH)
CFLAGS_FOR_BUILD := -arch $(shell uname -m) -mmacosx-version-min=$(shell sw_vers -productVersion) -isysroot $(MACOSX_SYSROOT)
CPPFLAGS_FOR_BUILD := -arch $(shell uname -m) -mmacosx-version-min=$(shell sw_vers -productVersion) -isysroot $(MACOSX_SYSROOT)
CXXFLAGS_FOR_BUILD := -arch $(shell uname -m) -mmacosx-version-min=$(shell sw_vers -productVersion) -isysroot $(MACOSX_SYSROOT)
LDFLAGS_FOR_BUILD := -arch $(shell uname -m) -mmacosx-version-min=$(shell sw_vers -productVersion) -isysroot $(MACOSX_SYSROOT)
else
ifneq ($(MEMO_QUIET),1)
$(warning Building on iOS)
endif # ($(MEMO_QUIET),1)
TARGET_SYSROOT ?= /usr/share/SDKs/$(BARE_PLATFORM).sdk
MACOSX_SYSROOT ?= /usr/share/SDKs/MacOSX.sdk
CC := $(shell command -v cc)
CXX := $(shell command -v c++)
CPP := $(shell command -v cc) -E
PATH := /usr/bin:$(PATH)
CFLAGS_FOR_BUILD := -arch $(shell uname -p) -miphoneos-version-min=$(shell sw_vers -productVersion)
CPPFLAGS_FOR_BUILD := -arch $(shell uname -p) -miphoneos-version-min=$(shell sw_vers -productVersion)
CXXFLAGS_FOR_BUILD := -arch $(shell uname -p) -miphoneos-version-min=$(shell sw_vers -productVersion)
LDFLAGS_FOR_BUILD := -arch $(shell uname -p) -miphoneos-version-min=$(shell sw_vers -productVersion)
endif
AR := $(shell command -v ar)
LD := $(shell command -v ld)
RANLIB := $(shell command -v ranlib)
STRINGS := $(shell command -v strings)
STRIP := $(shell command -v strip)
NM := $(shell command -v nm)
LIPO := $(shell command -v lipo)
OTOOL := $(shell command -v otool)
I_N_T := $(shell command -v install_name_tool)
LIBTOOL := $(shell command -v libtool)
else
$(error Please use macOS, iOS, Linux, or FreeBSD to build)
endif
CC_FOR_BUILD := $(shell command -v cc) $(CFLAGS_FOR_BUILD)
CPP_FOR_BUILD := $(shell command -v cc) -E $(CPPFLAGS_FOR_BUILD)
CXX_FOR_BUILD := $(shell command -v c++) $(CXXFLAGS_FOR_BUILD)
AR_FOR_BUILD := $(shell command -v ar)
export CC_FOR_BUILD CPP_FOR_BUILD CXX_FOR_BUILD AR_FOR_BUILD
DEB_MAINTAINER ?= Procursus Team <support@procurs.us>
MEMO_REPO_URI ?= https://apt.procurs.us
MEMO_PGP_SIGN_KEY ?= C59F3798A305ADD7E7E6C7256430292CF9551B0E
CODESIGN_IDENTITY ?= -
MEMO_LDID_EXTRA_FLAGS ?=
MEMO_CODESIGN_EXTRA_FLAGS ?=
LDID := ldid -Cadhoc $(MEMO_LDID_EXTRA_FLAGS)
# Root
BUILD_ROOT ?= $(PWD)
# Downloaded source files
BUILD_SOURCE := $(BUILD_ROOT)/build_source
# Base headers/libs (e.g. patched from SDK)
BUILD_BASE := $(BUILD_ROOT)/build_base/$(MEMO_TARGET)/$(MEMO_CFVER)
# Dpkg info storage area
BUILD_INFO ?= $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))/build_info
# Miscellaneous Procursus files
BUILD_MISC ?= $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))/build_misc
# Patch storage area
BUILD_PATCH ?= $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))/build_patch
# Extracted source working directory
BUILD_WORK := $(BUILD_ROOT)/build_work/$(MEMO_TARGET)/$(MEMO_CFVER)
# Bootstrap working area
BUILD_STAGE := $(BUILD_ROOT)/build_stage/$(MEMO_TARGET)/$(MEMO_CFVER)
# Final output
BUILD_DIST := $(BUILD_ROOT)/build_dist/$(MEMO_TARGET)/$(MEMO_CFVER)
# Actual bootrap staging
BUILD_STRAP := $(BUILD_ROOT)/build_strap/$(MEMO_TARGET)/$(MEMO_CFVER)
# Extra scripts for the buildsystem
BUILD_TOOLS ?= $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))/build_tools
ifeq ($(DEBUG),1)
OPTIMIZATION_FLAGS := -g -O0
else ifeq ($(MEMO_TARGET),bridgeos-arm64)
OPTIMIZATION_FLAGS := -Oz
else
OPTIMIZATION_FLAGS := -Os
ifeq ($(UNAME),Darwin)
OPTIMIZATION_FLAGS += -flto=thin
else ifeq ($(MEMO_FORCE_LTO),1)
OPTIMIZATION_FLAGS += -flto=thin
# This flag will prevent ld64 from deleting the object file needed for dsymutil to work.
# I'm not setting this on macOS because I am unsure if it is needed.
# See: clang(1)
OPTIMIZATION_FLAGS += -Wl,-object_path_lto,/tmp/lto.o
endif
endif
ifdef ($(MEMO_ALT_LTO_LIB))
OPTIMIZATION_FLAGS += -lto_library $(MEMO_ALT_LTO_LIB)
endif
CFLAGS := $(OPTIMIZATION_FLAGS) -arch $(MEMO_ARCH) -isysroot $(TARGET_SYSROOT) $(PLATFORM_VERSION_MIN) -isystem $(BUILD_BASE)$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/include -isystem $(BUILD_BASE)$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)$(MEMO_ALT_PREFIX)/include -F$(BUILD_BASE)$(MEMO_PREFIX)/System/Library/Frameworks -F$(BUILD_BASE)$(MEMO_PREFIX)/Library/Frameworks
CXXFLAGS := $(CFLAGS)
CPPFLAGS := -arch $(MEMO_ARCH) $(PLATFORM_VERSION_MIN) -isysroot $(TARGET_SYSROOT) -isystem $(BUILD_BASE)$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/include -isystem $(BUILD_BASE)$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)$(MEMO_ALT_PREFIX)/include -Wno-error-implicit-function-declaration
LDFLAGS := $(OPTIMIZATION_FLAGS) -arch $(MEMO_ARCH) -isysroot $(TARGET_SYSROOT) $(PLATFORM_VERSION_MIN) -L$(BUILD_BASE)$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/lib -L$(BUILD_BASE)$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)$(MEMO_ALT_PREFIX)/lib -F$(BUILD_BASE)$(MEMO_PREFIX)/System/Library/Frameworks -F$(BUILD_BASE)$(MEMO_PREFIX)/Library/Frameworks
PKG_CONFIG_PATH :=
ACLOCAL_PATH := $(BUILD_BASE)$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/aclocal
ifeq ($(MEMO_TARGET),bridgeos-arm64)
CFLAGS += -Wno-incompatible-sysroot
CXXFLAGS += -Wno-incompatible-sysroot
endif
# Link everything to libiosexec, as it's preinstalled on every Procursus system.
ifeq (,$(findstring darwin,$(MEMO_TARGET)))
ifneq ($(MEMO_NO_IOSEXEC),1)
LDFLAGS += -liosexec
else
CFLAGS += -DLIBIOSEXEC_INTERNAL
endif
endif
MEMO_MANPAGE_COMPRESSION := zstd
ifeq ($(MEMO_MANPAGE_COMPRESSION),zstd)
MEMO_MANPAGE_SUFFIX := .zst
MEMO_MANPAGE_COMPCMD := zstd
MEMO_MANPAGE_COMPFLGS += -19 --rm
else ifeq ($(MEMO_MANPAGE_COMPRESSION),xz)
MEMO_MANPAGE_SUFFIX := .xz
MEMO_MANPAGE_COMPCMD := xz
MEMO_MANPAGE_COMPFLGS := -T0
else ifeq ($(MEMO_MANPAGE_COMPRESSION),gzip)
MEMO_MANPAGE_SUFFIX := .gz
MEMO_MANPAGE_COMPCMD := gzip
MEMO_MANPAGE_COMPFLGS := -9
else ifeq ($(MEMO_MANPAGE_COMPRESSION),lz4)
MEMO_MANPAGE_SUFFIX := .lz4
MEMO_MANPAGE_COMPCMD := lz4
else ifeq ($(MEMO_MANPAGE_COMPRESSION),lzop)
MEMO_MANPAGE_SUFFIX := .lzop
MEMO_MANPAGE_COMPCMD := lzop
MEMO_MANPAGE_COMPFLGS := -U
else ifeq ($(MEMO_MANPAGE_COMPRESSION),none)
MEMO_MANPAGE_SUFFIX :=
MEMO_MANPAGE_COMPCMD := true
endif
DEFAULT_CMAKE_FLAGS := \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CROSSCOMPILING=true \
-DCMAKE_SYSTEM_NAME=Darwin \
-DCMAKE_SYSTEM_PROCESSOR="$(shell echo $(GNU_HOST_TRIPLE) | cut -f1 -d-)" \
-DCMAKE_C_FLAGS="$(CFLAGS)" \
-DCMAKE_CXX_FLAGS="$(CXXFLAGS)" \
-DCMAKE_FIND_ROOT_PATH="$(BUILD_BASE)" \
-DPKG_CONFIG_EXECUTABLE="$(BUILD_TOOLS)/cross-pkg-config" \
-DCMAKE_INSTALL_NAME_TOOL="$(I_N_T)" \
-DCMAKE_INSTALL_PREFIX="$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)" \
-DCMAKE_INSTALL_NAME_DIR="$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/lib" \
-DCMAKE_INSTALL_RPATH="$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)" \
-DCMAKE_INSTALL_SYSCONFDIR="$(MEMO_PREFIX)/etc" \
-DCMAKE_OSX_SYSROOT="$(TARGET_SYSROOT)" \
-DCMAKE_OSX_ARCHITECTURES="$(MEMO_ARCH)"
BUILD_CONFIGURE_FLAGS := \
--build=$$($(BUILD_MISC)/config.guess) \
--host=$$($(BUILD_MISC)/config.guess) \
--disable-dependency-tracking \
CC="$(CC_FOR_BUILD)" \
CXX="$(CXX_FOR_BUILD)" \
CPP="$(CPP_FOR_BUILD)" \
CFLAGS="$(CFLAGS_FOR_BUILD)" \
CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
CPPFLAGS="$(CPPFLAGS_FOR_BUILD)" \
LDFLAGS="$(LDFLAGS_FOR_BUILD)"
DEFAULT_CONFIGURE_FLAGS := \
--build=$$($(BUILD_MISC)/config.guess) \
--host=$(GNU_HOST_TRIPLE) \
--prefix=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX) \
--localstatedir=$(MEMO_PREFIX)/var \
--sysconfdir=$(MEMO_PREFIX)/etc \
--bindir=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/bin \
--mandir=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/man \
--enable-silent-rules \
--disable-dependency-tracking \
--enable-shared \
--enable-static
DEFAULT_PERL_MAKE_FLAGS := \
INSTALLSITEARCH=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/lib/perl5/$(PERL_MAJOR) \
INSTALLARCHLIB=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/lib/perl5/$(PERL_MAJOR) \
INSTALLVENDORARCH=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/lib/perl5/$(PERL_MAJOR) \
INSTALLPRIVLIB=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/perl5 \
INSTALLSITELIB=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/perl5 \
INSTALLVENDORLIB=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/perl5 \
PERL_LIB=$(BUILD_STAGE)/perl/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/lib/perl5/$(PERL_MAJOR) \
PERL_ARCHLIB=$(BUILD_STAGE)/perl/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/lib/perl5/$(PERL_MAJOR) \
PERL_ARCHLIBDEP=$(BUILD_STAGE)/perl/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/lib/perl5/$(PERL_MAJOR) \
PERL_INC=$(BUILD_STAGE)/perl/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/lib/perl5/$(PERL_MAJOR)/CORE \
PERL_INCDEP=$(BUILD_STAGE)/perl/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/lib/perl5/$(PERL_MAJOR)/CORE \
PREFIX=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX) \
INSTALLMAN1DIR=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/man/man1 \
INSTALLSITEMAN1DIR=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/man/man1 \
INSTALLVENDORMAN1DIR=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/man/man1 \
INSTALLMAN3DIR=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/man/man3 \
INSTALLSITEMAN3DIR=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/man/man3 \
INSTALLVENDORMAN3DIR=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/man/man3 \
PERL="$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/bin/perl" \
CCFLAGS="$(CFLAGS)" \
LDDLFLAGS="$(LDFLAGS) -shared"
DEFAULT_PERL_BUILD_FLAGS := \
cc=$(CC) \
ld=$(CC) \
destdir=$(BUILD_STAGE)/libmodule-build-perl \
install_base=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX) \
install_path=lib=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/perl5 \
install_path=arch=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/lib/perl5/$(PERL_MAJOR) \
install_path=bin=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/bin \
install_path=script=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/bin \
install_path=libdoc=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/man/man3 \
install_path=bindoc=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/man/man1 \
install_path=html=$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/doc/perl5
DEFAULT_GOLANG_FLAGS := \
GOOS=$(shell echo $(RUST_TARGET) | cut -f3 -d-) \
GOARCH=$(shell echo $(MEMO_TARGET) | cut -f2 -d-) \
CGO_CFLAGS="$(shell echo $(CFLAGS) | sed 's|$(OPTIMIZATION_FLAGS)||')" \
CGO_CXXFLAGS="$(shell echo $(CXXFLAGS) | sed 's|$(OPTIMIZATION_FLAGS)||')" \
CGO_CPPFLAGS="$(CPPFLAGS)" \
CGO_LDFLAGS="$(shell echo $(LDFLAGS) | sed 's|$(OPTIMIZATION_FLAGS)||')" \
CGO_ENABLED=1 \
CC="$(CC)" \
CXX="$(CXX)" \
CPP="$(CPP)"
DEFAULT_SETUP_PY_ENV := \
unset MACOSX_DEPLOYMENT_TARGET && \
CFLAGS="$(CFLAGS) -I$(BUILD_STAGE)/python3/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/include/$$(ls $(BUILD_STAGE)/python3/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/include)" \
CXXFLAGS="$(CXXFLAGS) -I$(BUILD_STAGE)/python3/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/include/$$(ls $(BUILD_STAGE)/python3/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/include)" \
CPPFLAGS="$(CPPFLAGS) -I$(BUILD_STAGE)/python3/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/include/$$(ls $(BUILD_STAGE)/python3/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/include)"
DEFAULT_RUST_FLAGS := \
SDKROOT="$(TARGET_SYSROOT)" \
PKG_CONFIG="$(RUST_TARGET)-pkg-config"
export PLATFORM MEMO_ARCH TARGET_SYSROOT MACOSX_SYSROOT GNU_HOST_TRIPLE MEMO_PREFIX MEMO_SUB_PREFIX MEMO_ALT_PREFIX
export CC CXX AR LD CPP RANLIB STRIP NM LIPO OTOOL I_N_T INSTALL
export BUILD_ROOT BUILD_BASE BUILD_INFO BUILD_WORK BUILD_STAGE BUILD_DIST BUILD_STRAP BUILD_TOOLS
export DEB_ARCH DEB_ORIGIN DEB_MAINTAINER
export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS ACLOCAL_PATH PKG_CONFIG_PATH
export DEFAULT_CMAKE_FLAGS DEFAULT_CONFIGURE_FLAGS DEFAULT_PERL_MAKE_FLAGS DEFAULT_PERL_BUILD_FLAGS DEFAULT_GOLANG_FLAGS
HAS_COMMAND = $(shell type $(1) >/dev/null 2>&1 && echo 1)
ifeq ($(NO_PGP),1)
ifneq ($(MEMO_QUIET),1)
PGP_VERIFY = echo "Skipping verification of $(1) because NO_PGP was set to 1."
else # ($(MEMO_QUIET),1)
PGP_VERIFY =
endif # ($(MEMO_QUIET),1)
else
PGP_VERIFY = KEY=$$(gpg --verify --status-fd 1 $(BUILD_SOURCE)/$(1).$(if $(2),$(2),sig) | grep NO_PUBKEY | cut -f3 -d' '); \
if [ ! -z "$$KEY" ]; then \
gpg --keyserver hkps://keyserver.ubuntu.com/ --recv-keys $$KEY; \
fi; \
gpg --verify $(BUILD_SOURCE)/$(1).$(if $(2),$(2),sig) $(BUILD_SOURCE)/$(1) 2>&1 | grep -q 'Good signature'
endif
CHECKSUM_VERIFY = if [ "$(1)" = "sha1" ]; then \
HASH=$$(sha1sum "$(BUILD_SOURCE)/$(2)" | cut -d " " -f1 | tr -d \n); \
elif [ "$(1)" = "sha256" ]; then \
HASH=$$(sha256sum "$(BUILD_SOURCE)/$(2)" | cut -d " " -f1 | tr -d \n); \
elif [ "$(1)" = "sha512" ]; then \
HASH=$$(sha512sum "$(BUILD_SOURCE)/$(2)" | cut -d " " -f1 | tr -d \n); \
fi; \
if [ "$(3)" = "" ]; then \
[ "$$(cut -d" " -f 1 "$(BUILD_SOURCE)/$(2).$(1)")" = "$$HASH" ] || (echo "$(2) - Invalid Hash" && exit 1); \
else \
[ "$(3)" = "$$HASH" ] || (echo "$(2) - Invalid Hash" && exit 1); \
fi
EXTRACT_TAR = -if [ ! -d $(BUILD_WORK)/$(3) ] || [ "$(4)" = "1" ]; then \
cd $(BUILD_WORK) && \
tar -xf $(BUILD_SOURCE)/$(1) && \
mkdir -p $(3); \
cp -a $(2)/. $(3); \
rm -rf $(2); \
fi
DO_PATCH = cd $(BUILD_PATCH)/$(1); \
for PATCHFILE in *; do \
if [ ! -f $(BUILD_WORK)/$(2)/$(notdir $$PATCHFILE).done ]; then \
sed -e 's|@MEMO_PREFIX@|$(MEMO_PREFIX)|g' -e 's|@MEMO_SUB_PREFIX@|$(MEMO_SUB_PREFIX)|g' -e 's|@MEMO_ALT_PREFIX@|$(MEMO_ALT_PREFIX)|g' $$PATCHFILE | patch -sN -d $(BUILD_WORK)/$(2) $(3) && \
touch $(BUILD_WORK)/$(2)/$(notdir $$PATCHFILE).done; \
fi; \
done
ifeq (,$(findstring darwin,$(MEMO_TARGET)))
SIGN = for file in $$(find $(BUILD_DIST)/$(1) -type f -exec sh -c "file -ib '{}' | grep -q 'x-mach-binary; charset=binary'" \; -print); do \
if [ $${file\#\#*.} = "dylib" ] || [ $${file\#\#*.} = "bundle" ] || [ $${file\#\#*.} = "so" ]; then \
$(LDID) -S $$file; \
else \
$(LDID) -S$(BUILD_MISC)/entitlements/$(2) $$file; \
fi; \
done; \
find $(BUILD_DIST)/$(1) -name '.ldid*' -type f -delete
else
SIGN = CODESIGN_FLAGS="--sign $(CODESIGN_IDENTITY) --force --deep "; \
if [ "$(CODESIGN_IDENTITY)" != "-" ]; then \
CODESIGN_FLAGS+="--timestamp "; \
if [ "$(4)" != "nohardened" ]; then \
CODESIGN_FLAGS+="-o kill,hard "; \
fi; \
if [ -n "$(3)" ]; then \
CODESIGN_FLAGS+="--entitlements $(BUILD_MISC)/entitlements/$(3) "; \
fi; \
fi; \
for file in $$(find $(BUILD_DIST)/$(1) -type f -exec sh -c "file -ib '{}' | grep -q 'x-mach-binary; charset=binary'" \; -print); do \
codesign --remove $$file &> /dev/null; \
codesign $(MEMO_CODESIGN_EXTRA_FLAGS) $$CODESIGN_FLAGS $$file &> /dev/null; \
done
endif
###
#
# TODO: Please cleanup the PACK function, it's so horrible.
#
###
AFTER_BUILD = \
if [ ! -z "$(2)" ]; then \
pkg="$(2)"; \
else \
pkg="$@"; \
fi; \
if [ ! -z "$(MEMO_PREFIX)" ] && [ -d "$(BUILD_STAGE)/$$pkg/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)" ]; then \
rm -f $(BUILD_STAGE)/$$pkg/._lib_cache && touch $(BUILD_STAGE)/$$pkg/._lib_cache; \
for file in $$(find $(BUILD_STAGE)/$$pkg -type f -exec sh -c "file -ib '{}' | grep -q 'x-mach-binary; charset=binary'" \; -print); do \
INSTALL_NAME=$$(otool -D $$file | grep -v ":$$"); \
if [ ! -z "$$INSTALL_NAME" ]; then \
$(I_N_T) -id @rpath/$$(basename $$INSTALL_NAME) $$file; \
echo "$$INSTALL_NAME" >> $(BUILD_STAGE)/$$pkg/._lib_cache; \
fi; \
done; \
fi; \
for file in $$(find $(BUILD_STAGE)/$$pkg -type f -exec sh -c "file -ib '{}' | grep -q 'x-mach-binary; charset=binary'" \; -print); do \
if [ "$(RELATIVE_RPATH)" = "1" ]; then \
$(I_N_T) -add_rpath "@loader_path/$$(realpath --relative-to=$$(dirname $$file) $(BUILD_STAGE)/$$pkg/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX))/lib" $$file; \
else \
$(I_N_T) -add_rpath "$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/lib" $$file; \
fi; \
if [ -f $(BUILD_STAGE)/$$pkg/._lib_cache ]; then \
cat $(BUILD_STAGE)/$$pkg/._lib_cache | while read line; do \
$(I_N_T) -change $$line @rpath/$$(basename $$line) $$file; \
done; \
fi; \
$(STRIP) -x $$file; \
done; \
rm -f $(BUILD_STAGE)/$$pkg/._lib_cache; \
find $(BUILD_STAGE)/$$pkg/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/man -type f -name '*.gz$$' -exec gunzip '{}' \; 2> /dev/null; \
find $(BUILD_STAGE)/$$pkg/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/man -type f -name '*.xz$$' -exec unxz '{}' \; 2> /dev/null; \
find $(BUILD_STAGE)/$$pkg/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/man -type f -name '*.zst$$' -exec unzstd '{}' \; 2> /dev/null; \
if [ "$(MEMO_NO_DOC_COMPRESS)" != 1 ]; then \
find $(BUILD_STAGE)/$$pkg/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/man -type f -exec $(MEMO_MANPAGE_COMPCMD) $(MEMO_MANPAGE_COMPFLGS) '{}' \; 2> /dev/null; \
find $(BUILD_STAGE)/$$pkg/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/man -type l -exec bash -c '$(LN_S) $$(readlink "{}" | sed -e "s/\.gz$$//" -e "s/\.xz$$//" -e "s/\.zst$$//")$(MEMO_MANPAGE_SUFFIX) "{}"$(MEMO_MANPAGE_SUFFIX); rm -f "{}"' \; -delete 2> /dev/null; \
else \
find $(BUILD_STAGE)/$$pkg/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/man -type l -exec bash -c '$(LN_S) $$(readlink "{}" | sed -e "s/\.gz$$//" -e "s/\.xz$$//" -e "s/\.zst$$//") "{}"' \; 2> /dev/null; \
fi; \
if [ "$(1)" = "copy" ]; then \
cp -af $(BUILD_STAGE)/$$pkg/* $(BUILD_BASE); \
fi; \
[ -d $(BUILD_WORK)/$$pkg/ ] || mkdir $(BUILD_WORK)/$$pkg/; \
touch $(BUILD_WORK)/$$pkg/.build_complete; \
find $(BUILD_BASE) -name '*.la' -type f -delete
PACK = \
if [ -z "$(4)" ]; then \
find $(BUILD_DIST)/$(1) -name '*.la' -type f -delete; \
fi; \
rm -f $(BUILD_DIST)/$(1)/.build_complete; \
rm -rf $(BUILD_DIST)/$(1)/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/{info,doc}; \
for file in AUTHORS COPYING LICENSE NEWS README THANKS TODO; do \
if [ -f "$(BUILD_WORK)/$$(echo $@ | sed 's/-package//')/$$file" ]; then \
mkdir -p $(BUILD_DIST)/$(1)/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/doc/$(1); \
cp -aL $(BUILD_WORK)/$$(echo $@ | sed 's/-package//')/$$file $(BUILD_DIST)/$(1)/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/doc/$(1); \
if [ "$(MEMO_NO_DOC_COMPRESS)" != 1 ]; then \
if [ ! "$$file" = "AUTHORS" ] && [ ! "$$file" = "COPYING" ] && [ ! "$$file" = "LICENSE" ]; then \
zstd -19 --rm $(BUILD_DIST)/$(1)/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/doc/$(1)/$$file 2> /dev/null; \
fi; \
fi; \
fi; \
done; \
if [ -z $(3) ]; then \
if [ ! "$(MEMO_QUIET)" == "1" ]; then \
echo Setting $(1) owner to 0:0.; \
fi; \
$(FAKEROOT) chown -R 0:0 $(BUILD_DIST)/$(1)/* &>/dev/null; \
elif [ $(3) = "2" ]; then \
if [ ! "$(MEMO_QUIET)" == "1" ]; then \
echo $(1) owner set within individual makefile.; \
fi; \
fi; \
if [ -d "$(BUILD_DIST)/$(1)/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/locale" ] && [ ! "$(shell grep Package: $(BUILD_INFO)/$(1).control | cut -f2 -d ' ')" = "gettext-localizations" ]; then \
rm -rf $(BUILD_DIST)/$(1)/$(MEMO_PREFIX)$(MEMO_SUB_PREFIX)/share/locale/*/LC_{MONETARY,TIME,COLLATE,CTYPE,NUMERIC}; \
fi; \
SIZE=$$(du -sk $(BUILD_DIST)/$(1) | cut -f 1); \
mkdir -p $(BUILD_DIST)/$(1)/DEBIAN; \
for i in control postinst preinst postrm prerm extrainst_ conffiles triggers; do \
for n in $$i $$i.$(PLATFORM) $$i.$(PLATFORM); do \
if [ -f "$(BUILD_INFO)/$(1).$$n.rootless" ] && [ ! -z "$(findstring rootless,$(MEMO_TARGET))" ]; then \
sed -e 's|@MEMO_PREFIX@|$(MEMO_PREFIX)|g' \
-e 's|@MEMO_SUB_PREFIX@|$(MEMO_SUB_PREFIX)|g' \
-e 's|@MEMO_ALT_PREFIX@|$(MEMO_ALT_PREFIX)|g' \
-e 's|@MEMO_LAUNCHCTL_PREFIX@|$(MEMO_LAUNCHCTL_PREFIX)|g' \
-e 's|@GNU_PREFIX@|$(GNU_PREFIX)|g' \
-e 's|@BARE_PLATFORM@|$(BARE_PLATFORM)|g' \
-e 's/@$(2)@/$($(2))/g' \
-e 's/@DEB_MAINTAINER@/$(DEB_MAINTAINER)/g' \
-e 's/@MEMO_MANPAGE_SUFFIX@/$(MEMO_MANPAGE_SUFFIX)/g' \
-e 's/@DEB_ARCH@/$(DEB_ARCH)/g' < $(BUILD_INFO)/$(1).$$n.rootless > $(BUILD_DIST)/$(1)/DEBIAN/$$i; \
elif [ -f "$(BUILD_INFO)/$(1).$$n" ]; then \
sed -e 's|@MEMO_PREFIX@|$(MEMO_PREFIX)|g' \
-e 's|@MEMO_SUB_PREFIX@|$(MEMO_SUB_PREFIX)|g' \
-e 's|@MEMO_ALT_PREFIX@|$(MEMO_ALT_PREFIX)|g' \
-e 's|@MEMO_LAUNCHCTL_PREFIX@|$(MEMO_LAUNCHCTL_PREFIX)|g' \
-e 's|@GNU_PREFIX@|$(GNU_PREFIX)|g' \
-e 's|@BARE_PLATFORM@|$(BARE_PLATFORM)|g' \
-e 's/@$(2)@/$($(2))/g' \
-e 's/@DEB_MAINTAINER@/$(DEB_MAINTAINER)/g' \
-e 's/@MEMO_MANPAGE_SUFFIX@/$(MEMO_MANPAGE_SUFFIX)/g' \
-e 's/@DEB_ARCH@/$(DEB_ARCH)/g' < $(BUILD_INFO)/$(1).$$n > $(BUILD_DIST)/$(1)/DEBIAN/$$i; \
fi; \
done; \
done; \
sed -i '$$a\' $(BUILD_DIST)/$(1)/DEBIAN/control; \
cd $(BUILD_DIST)/$(1) && find . -type f ! -regex '.*.hg.*' ! -regex '.*?debian-binary.*' ! -regex '.*?DEBIAN.*' -printf '"%P" ' | xargs md5sum > $(BUILD_DIST)/$(1)/DEBIAN/md5sums; \
$(FAKEROOT) chmod 0755 $(BUILD_DIST)/$(1)/DEBIAN/*; \
if [ ! "$(MEMO_QUIET)" == "1" ]; then \
echo "Installed-Size: $$SIZE"; \
fi; \
echo "Installed-Size: $$SIZE" >> $(BUILD_DIST)/$(1)/DEBIAN/control; \
find $(BUILD_DIST)/$(1) -name '.DS_Store' -type f -delete; \
$(FAKEROOT) $(DPKG_DEB) -b $(BUILD_DIST)/$(1) $(BUILD_DIST)/$$(grep Package: $(BUILD_DIST)/$(1)/DEBIAN/control | cut -f2 -d ' ')_$($(2))_$$(grep Architecture: $(BUILD_DIST)/$(1)/DEBIAN/control | cut -f2 -d ' ').deb
GITHUB_ARCHIVE = -if [ $(5) ]; then \
[ ! -f "$(BUILD_SOURCE)/$(5)-$(3).tar.gz" ] && \
wget -q -nc -O$(BUILD_SOURCE)/$(5)-$(3).tar.gz \
https://github.com/$(1)/$(2)/archive/$(4).tar.gz; \
else \
[ ! -f "$(BUILD_SOURCE)/$(2)-$(3).tar.gz" ] && \
wget -q -nc -O$(BUILD_SOURCE)/$(2)-$(3).tar.gz \
https://github.com/$(1)/$(2)/archive/$(4).tar.gz; \
fi
GIT_CLONE = if [ ! -d "$(BUILD_WORK)/$(3)" ]; then \
git clone -c advice.detachedHead=false --depth 1 --branch "$(2)" --recursive "$(1)" "$(BUILD_WORK)/$(3)"; \
fi
###
#
# Fix this dep checking section dumbass
#
###
ifneq ($(call HAS_COMMAND,wget),1)
$(error Install wget)
endif
ifneq ($(call HAS_COMMAND,triehash),1)
$(error Install triehash)
endif
ifneq ($(shell PATH="$(PATH)" tar --version | grep -q GNU && echo 1),1)
$(error Install GNU tar)
endif
ifneq ($(shell PATH="$(PATH)" sed --version | grep -q GNU && echo 1),1)
$(error Install GNU sed)
endif
ifneq ($(shell PATH="$(PATH)" grep --version | grep -q GNU && echo 1),1)
$(error Install GNU grep)
endif
ifeq (,$(findstring darwin,$(MEMO_TARGET)))
ifneq ($(call HAS_COMMAND,ldid),1)
$(error Install ldid)
endif
endif
ifeq ($(call HAS_COMMAND,libtoolize),1)
LIBTOOLIZE := libtoolize
else ifeq ($(call HAS_COMMAND,glibtoolize),1)
LIBTOOLIZE := glibtoolize
else
#$(error Install libtool)
endif
ifneq ($(call HAS_COMMAND,xz),1)
$(error Install xz-utils)
endif
ifneq ($(call HAS_COMMAND,gpg),1)
$(error Install GnuPG gpg)
endif
ifneq ($(call HAS_COMMAND,dirmngr),1)
$(error Install GnuPG dirmngr)
endif
ifneq ($(call HAS_COMMAND,cmake),1)
$(error Install cmake)
endif
ifneq ($(call HAS_COMMAND,pkg-config),1)
$(error Install pkg-config)
endif
ifneq ($(call HAS_COMMAND,automake),1)
$(error Install automake)
endif
ifneq ($(call HAS_COMMAND,autom4te),1)
$(error Install autoconf)
endif
ifneq ($(call HAS_COMMAND,m4),1)
$(error Install m4)
endif
ifneq ($(shell PATH="$(PATH)" groff --version | grep -q 'version 1.2' && echo 1),1)
$(error Install newer groff)
endif
ifneq ($(shell PATH="$(PATH)" patch --version | grep -q 'GNU patch' && echo 1),1)
$(error Install GNU patch)
endif
ifneq ($(shell PATH="$(PATH)" find --version | grep -q 'GNU find' && echo 1),1)
$(error Install GNU findutils)
endif
ifeq ($(shell PATH="$(PATH)" install --version | grep -q 'GNU coreutils' && echo 1),1)
export INSTALL := $(shell PATH="$(PATH)" which install) --strip-program=$(STRIP)
export LN_S := ln -sf
export LN_SR := ln -sfr
else
$(error Install GNU coreutils)
endif
ifneq ($(shell PATH="$(PATH)" file -bi $(BUILD_MISC)/launchctl/launchctl.1700 | grep -q 'x-mach-binary; charset=binary' && echo 1),1)
$(error Install better file from Procursus - sudo apt install file)
endif
ifneq ($(call HAS_COMMAND,fakeroot),1)
$(error Install fakeroot)
endif
ifneq ($(call HAS_COMMAND,zstd),1)
$(error Install zstd)
endif
ifeq ($(shell dpkg-deb --help | grep -qi "zstd" && echo 1),1)
DPKG_TYPE ?= zstd
else
DPKG_TYPE ?= gzip
endif
ifeq ($(call HAS_COMMAND,dpkg-deb),1)
DPKG_DEB := dpkg-deb -Z$(DPKG_TYPE)
else
$(error Install dpkg-deb)
endif
ifneq ($(call HAS_COMMAND,autopoint),1)
$(error Install autopoint)
endif
ifneq ($(shell tic -V | grep -q 'ncurses 6' && echo 1),1)
$(error Install ncurses 6)
endif
ifneq (,$(wildcard /opt/procursus/share/xml/docbook/stylesheet/docbook-xsl))
DOCBOOK_XSL := /opt/procursus/share/xml/docbook/stylesheet/docbook-xsl
export XML_CATALOG_FILES=/opt/procursus/etc/xml/catalog
else ifneq (,$(wildcard /usr/share/xml/docbook/stylesheet/docbook-xsl))
DOCBOOK_XSL := /usr/share/xml/docbook/stylesheet/docbook-xsl
export XML_CATALOG_FILES=/etc/xml/catalog
else ifneq (,$(wildcard /usr/local/share/xsl/docbook))
DOCBOOK_XSL := /usr/local/share/xsl/docbook
else ifneq (,$(wildcard /usr/share/xsl/docbook))
DOCBOOK_XSL := /usr/share/xsl/docbook
else ifneq (,$(wildcard /usr/share/xml/docbook/xsl-stylesheets-1.79.2))
DOCBOOK_XSL := /usr/share/xml/docbook/xsl-stylesheets-1.79.2
else
$(error Install docbook-xsl)
endif
ifneq ($(call HAS_COMMAND,yacc),1)
$(error Install bison)