forked from bebbo/amiga-gcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
1412 lines (1124 loc) · 58 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 based Amiga compiler setup.
# (c) Stefan "Bebbo" Franke in 2018
#
# Riding a dead horse...
# =================================================
include disable_implicite_rules.mk
# =================================================
# variables
# =================================================
$(eval SHELL = $(shell which bash 2>/dev/null) )
PREFIX ?= /opt/amiga
export PATH := $(PREFIX)/bin:$(PATH)
TARGET ?= m68k-amigaos
UNAME_S := $(shell uname -s)
BUILD := $(shell pwd)/build-$(UNAME_S)-$(TARGET)
PROJECTS := $(shell pwd)/projects
DOWNLOAD := $(shell pwd)/download
__BUILDDIR := $(shell mkdir -p $(BUILD))
__PROJECTDIR := $(shell mkdir -p $(PROJECTS))
__DOWNLOADDIR := $(shell mkdir -p $(DOWNLOAD))
GCC_VERSION ?= $(shell cat 2>/dev/null $(PROJECTS)/gcc/gcc/BASE-VER)
ifeq ($(UNAME_S), Darwin)
SED := gsed
else ifeq ($(UNAME_S), FreeBSD)
SED := gsed
else
SED := sed
endif
# get git urls and branches from .repos file
$(shell [ ! -f .repos ] && cp default-repos .repos)
modules := $(shell cat .repos | $(SED) -e 's/[[:blank:]]\+/ /g' | cut -d' ' -f1)
get_url = $(shell grep $(1) .repos | $(SED) -e 's/[[:blank:]]\+/ /g' | cut -d' ' -f2)
get_branch = $(shell grep $(1) .repos | $(SED) -e 's/[[:blank:]]\+/ /g' | cut -d' ' -f3)
$(foreach modu,$(modules),$(eval $(modu)_URL=$(call get_url,$(modu))))
$(foreach modu,$(modules),$(eval $(modu)_BRANCH=$(call get_branch,$(modu))))
ifneq ($(NDK),3.9)
NDK_URL := http://aminet.net/dev/misc/NDK3.2.lha
NDK_ARC_NAME := NDK3.2
NDK_FOLDER_NAME := NDK3.2
NDK_FOLDER_NAME_H := NDK3.2/Include_H
NDK_FOLDER_NAME_I := NDK3.2/Include_I
NDK_FOLDER_NAME_FD := NDK3.2/FD
NDK_FOLDER_NAME_SFD := NDK3.2/SFD
NDK_FOLDER_NAME_LIBS := NDK3.2/lib
else
NDK_URL := http://hp.alinea-computer.de/AmigaOS/NDK39.lha
NDK_ARC_NAME := NDK3.9
NDK_FOLDER_NAME := NDK_3.9/Include
NDK_FOLDER_NAME_H := NDK_3.9/Include/include_h
NDK_FOLDER_NAME_I := NDK_3.9/Include/include_i
NDK_FOLDER_NAME_FD := NDK_3.9/Include/fd
NDK_FOLDER_NAME_SFD := NDK_3.9/Include/sfd
NDK_FOLDER_NAME_LIBS := NDK_3.9/Include/linker_libs
endif
CFLAGS ?= -Os
CXXFLAGS ?= $(CFLAGS)
CFLAGS_FOR_TARGET ?= -O2 -fomit-frame-pointer
CXXFLAGS_FOR_TARGET ?= $(CFLAGS_FOR_TARGET) -fno-exceptions -fno-rtti
E:=CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CFLAGS_FOR_BUILD="$(CFLAGS)" CXXFLAGS_FOR_BUILD="$(CXXFLAGS)" CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" CXXFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)"
THREADS ?= no
# =================================================
# determine exe extension for cygwin
$(eval MYMAKE = $(shell which $(MAKE) 2>/dev/null) )
$(eval MYMAKEEXE = $(shell which "$(MYMAKE:%=%.exe)" 2>/dev/null) )
EXEEXT:=$(MYMAKEEXE:%=.exe)
# Files for GMP, MPC and MPFR
GMP := gmp-6.1.2
GMPFILE := $(GMP).tar.bz2
MPC := mpc-1.0.3
MPCFILE := $(MPC).tar.gz
MPFR := mpfr-3.1.6
MPFRFILE := $(MPFR).tar.bz2
# =================================================
# pretty output ^^
# =================================================
TEEEE := >&
ifeq ($(sdk),)
__LINIT := $(shell rm .state 2>/dev/null)
endif
$(eval has_flock = $(shell which flock 2>/dev/null))
ifeq ($(has_flock),)
FLOCK := echo >/dev/null
else
FLOCK := $(has_flock)
endif
L0 = @__p=
L00 = __p=
ifneq ($(VERBOSE),)
verbose = $(VERBOSE)
endif
ifeq ($(verbose),)
L1 = ; ($(FLOCK) 200; echo -e \\033[33m$$__p...\\033[0m >>.state; echo -ne \\033[33m$$__p...\\033[0m ) 200>.lock; mkdir -p log; __l="log/$$__p.log" ; (
L2 = )$(TEEEE) "$$__l"; __r=$$?; ($(FLOCK) 200; if (( $$__r > 0 )); then \
echo -e \\n\\033[K\\033[31m$$__p...failed\\033[0m; \
$(SED) -n '1,/\*\*\*/p' "$$__l" | tail -n 100; \
echo -e \\033[31m$$__p...failed\\033[0m; \
echo -e use \\033[1mless \"$$__l\"\\033[0m to view the full log and search for \*\*\*; \
else echo -e \\n\\033[K\\033[32m$$__p...done\\033[0m; fi \
;grep -v "$$__p" .state >.state0 2>/dev/null; mv .state0 .state ;echo -n $$(cat .state | paste -sd " " -); ) 200>.lock; [[ $$__r -gt 0 ]] && exit $$__r; echo -n ""
else
L1 = ;(
L2 = )
endif
# =================================================
# download files
# =================================================
define get-file
$(L0)"downloading $(1)"$(L1) cd $(DOWNLOAD); \
mv $(3) $(3).bak; \
wget $(2) -O $(3).neu; \
if [ -s $(3).neu ]; then \
if [ "$$(cmp --silent $(3).neu $(3).bak); echo $$?" == 0 ]; then \
mv $(3).bak $(3); \
rm $(3).neu; \
else \
mv $(3).neu $(3); \
rm -f $(3).bak; \
fi \
else \
rm $(3).neu; \
fi; \
cd .. $(L2)
endef
# =================================================
.PHONY: x init
x:
@if [ "$(sdk)" == "" ]; then \
$(MAKE) help; \
else \
$(MAKE) sdk; \
fi
# =================================================
# help
# =================================================
.PHONY: help
help:
@echo "make help display this help"
@echo "make info print prefix and other flags"
@echo "make all build and install all"
@echo "make min build and install the minimal to use gcc"
@echo "make tmx build and install the vbcc toolchain for Termux"
@echo "make <target> builds a target: binutils, gcc, gprof, fd2sfd, fd2pragma, ira, sfdc, vasm, vbcc, vlink, libnix, ixemul, libgcc, clib2, libdebug, libSDL12, libpthread, ndk, ndk13"
@echo "make clean remove the build folder"
@echo "make clean-<target> remove the target's build folder"
@echo "make drop-prefix remove all content from the prefix folder"
@echo "make update perform git pull for all targets"
@echo "make update-<target> perform git pull for the given target"
@echo "make sdk=<sdk> install the sdk <sdk>"
@echo "make all-sdk install all sdks"
@echo "make l print the last log entry for each project"
@echo "make b print the branch for each project"
@echo "make r print the remote for each project"
@echo "make v [date=<date>] checkout all projects for a given date, checkout to branch if no date given"
@echo "make branch branch=<branch> mod=<module> switch the module to the given branch"
@echo ""
@echo "the optional parameter THREADS=posix will build it with thread support"
# =================================================
# all
# =================================================
.PHONY: all gcc gdb gprof binutils fd2sfd fd2pragma ira sfdc vasm libnix ixemul libgcc clib2 libdebug libpthread ndk ndk13 min tmx
all: gcc binutils gdb gprof fd2sfd fd2pragma ira sfdc vasm libnix ixemul libgcc clib2 libdebug libpthread ndk ndk13 libSDL12
min: binutils gcc gprof libnix libgcc
tmx: ndk ndk13 vasm vlink vbcc
# =================================================
# clean
# =================================================
ifneq ($(OWNMPC),)
.PHONY: clean-gmp clean-mpc clean-mpfr
clean: clean-gmp clean-mpc clean-mpfr
endif
.PHONY: drop-prefix clean clean-gcc clean-binutils clean-fd2sfd clean-fd2pragma clean-ira clean-sfdc clean-vasm clean-vbcc clean-vlink clean-libnix clean-ixemul clean-libgcc clean-clib2 clean-libdebug clean-libpthread clean-newlib clean-ndk
clean: clean-gcc clean-binutils clean-fd2sfd clean-fd2pragma clean-ira clean-sfdc clean-vasm clean-vbcc clean-vlink clean-libnix clean-ixemul clean-clib2 clean-libdebug clean-libpthread clean-newlib clean-ndk clean-gmp clean-mpc clean-mpfr clean-libSDL12
rm -rf $(BUILD)
rm -rf *.log
mkdir -p $(BUILD)
clean-gcc:
rm -rf $(BUILD)/gcc
clean-gmp:
rm -rf $(PROJECTS)/gcc/gmp
clean-mpc:
rm -rf $(PROJECTS)/gcc/mpc
clean-mpfr:
rm -rf $(PROJECTS)/gcc/mpfr
clean-libgcc:
rm -rf $(BUILD)/gcc/$(TARGET)
rm -rf $(BUILD)/gcc/_libgcc_done
clean-binutils:
rm -rf $(BUILD)/binutils
clean-gprof:
rm -rf $(BUILD)/binutils/gprof
clean-fd2sfd:
rm -rf $(BUILD)/fd2sfd
clean-fd2pragma:
rm -rf $(BUILD)/fd2pragma
clean-ira:
rm -rf $(BUILD)/ira
clean-sfdc:
rm -rf $(BUILD)/sfdc
clean-vasm:
rm -rf $(BUILD)/vasm
clean-vbcc:
rm -rf $(BUILD)/vbcc
clean-vlink:
rm -rf $(BUILD)/vlink
clean-ndk:
rm -rf $(BUILD)/ndk*
clean-libnix:
rm -rf $(BUILD)/libnix
clean-ixemul:
rm -rf $(BUILD)/ixemul
clean-clib2:
rm -rf $(BUILD)/clib2
clean-libdebug:
rm -rf $(BUILD)/libdebug
clean-libpthread:
rm -rf $(BUILD)/libpthread
clean-newlib:
rm -rf $(BUILD)/newlib
# drop-prefix drops the files from prefix folder
drop-prefix:
rm -rf $(PREFIX)/bin
rm -rf $(PREFIX)/etc
rm -rf $(PREFIX)/info
rm -rf $(PREFIX)/libexec
rm -rf $(PREFIX)/lib/gcc
rm -rf $(PREFIX)/$(TARGET)
rm -rf $(PREFIX)/man
rm -rf $(PREFIX)/share
@mkdir -p $(PREFIX)/bin
# =================================================
# update all projects
# =================================================
.PHONY: update update-gcc update-binutils update-fd2sfd update-fd2pragma update-ira update-sfdc update-vasm update-vbcc update-vlink update-libnix update-ixemul update-clib2 update-libdebug update-libSDL12 update-libpthread update-ndk update-newlib update-netinclude
update: update-gcc update-binutils update-fd2sfd update-fd2pragma update-ira update-sfdc update-vasm update-vbcc update-vlink update-libnix update-ixemul update-clib2 update-libdebug update-libSDL12 update-libpthread update-ndk update-newlib update-netinclude
+$(MAKE) -B $(DOWNLOAD)/vbcc_target_m68k-amigaos.lha
+$(MAKE) -B $(DOWNLOAD)/vbcc_target_m68k-kick13.lha
+$(MAKE) -B $(DOWNLOAD)/$(NDK_ARC_NAME).lha
+$(MAKE) -B $(DOWNLOAD)/ixemul-sdk.lha
+$(MAKE) -B $(DOWNLOAD)/$(ZLIB).tar.xz
+$(MAKE) -B $(DOWNLOAD)/$(LIBPNG).tar.xz
+$(MAKE) -B $(DOWNLOAD)/$(LIBFREETYPE).tar.xz
+$(MAKE) -B $(DOWNLOAD)/$(LIBSDLMIXER).tar.gz
+$(MAKE) -B $(DOWNLOAD)/$(LIBSDLTTF).tar.gz
update-gcc: $(PROJECTS)/gcc/configure
@cd $(PROJECTS)/gcc && git pull || (export DEPTH=16; while true; do echo "trying depth=$$DEPTH"; git pull --depth $$DEPTH && break; export DEPTH=$$(($$DEPTH+$$DEPTH));done)
update-binutils: $(PROJECTS)/binutils/configure
@cd $(PROJECTS)/binutils && git pull || (export DEPTH=16; while true; do echo "trying depth=$$DEPTH"; git pull --depth $$DEPTH && break; export DEPTH=$$(($$DEPTH+$$DEPTH));done)
update-fd2sfd: $(PROJECTS)/fd2sfd/configure
@cd $(PROJECTS)/fd2sfd && git pull
update-fd2pragma: $(PROJECTS)/fd2pragma/makefile
@cd $(PROJECTS)/fd2pragma && git pull
update-ira: $(PROJECTS)/ira/Makefile
@cd $(PROJECTS)/ira && git pull
update-sfdc: $(PROJECTS)/sfdc/configure
@cd $(PROJECTS)/sfdc && git pull
update-vasm: $(PROJECTS)/vasm/Makefile
@cd $(PROJECTS)/vasm && git pull
update-vbcc: $(PROJECTS)/vbcc/Makefile
@cd $(PROJECTS)/vbcc && git pull
update-vlink: $(PROJECTS)/vlink/Makefile
@cd $(PROJECTS)/vlink && git pull
update-libnix: $(PROJECTS)/libnix/Makefile.gcc6
@cd $(PROJECTS)/libnix && git pull
update-ixemul: $(PROJECTS)/ixemul/configure
@cd $(PROJECTS)/ixemul && git pull
update-clib2: $(PROJECTS)/clib2/LICENSE
@cd $(PROJECTS)/clib2 && git pull
update-libdebug: $(PROJECTS)/libdebug/configure
@cd $(PROJECTS)/libdebug && git pull
update-libSDL12: $(PROJECTS)/libSDL12/Makefile
@cd $(PROJECTS)/libSDL12 && git pull
update-libpthread: $(PROJECTS)/aros-stuff/pthreads/Makefile
@cd $(PROJECTS)/aros-stuff && git pull
update-ndk: $(DOWNLOAD)/$(NDK_ARC_NAME).lha
$(MAKE) $(PROJECTS)/$(NDK_FOLDER_NAME).info
update-newlib: $(PROJECTS)/newlib-cygwin/newlib/configure
@cd $(PROJECTS)/newlib-cygwin && git pull
update-netinclude: $(PROJECTS)/amiga-netinclude/README.md
@cd $(PROJECTS)/amiga-netinclude && git pull
update-gmp:
if [ -a $(DOWNLOAD)/$(GMPFILE) ]; \
then rm -rf $(PROJECTS)/$(GMP); rm -rf $(PROJECTS)/gcc/gmp; \
else cd $(DOWNLOAD) && wget ftp://ftp.gnu.org/gnu/gmp/$(GMPFILE); \
fi;
@cd $(PROJECTS) && tar xf $(DOWNLOAD)/$(GMPFILE)
update-mpc:
if [ -a $(DOWNLOAD)/$(MPCFILE) ]; \
then rm -rf projcts/$(MPC); rm -rf $(PROJECTS)/gcc/mpc; \
else cd $(DOWNLOAD) && wget ftp://ftp.gnu.org/gnu/mpc/$(MPCFILE); \
fi;
@cd $(PROJECTS) && tar xf $(DOWNLOAD)/$(MPCFILE)
update-mpfr:
if [ -a $(DOWNLOAD)/$(MPFRFILE) ]; \
then rm -rf $(PROJECTS)/$(MPFR); rm -rf $(PROJECTS)/gcc/mpfr; \
else cd $(DOWNLOAD) && wget ftp://ftp.gnu.org/gnu/mpfr/$(MPFRFILE); \
fi;
@cd $(PROJECTS) && tar xf $(DOWNLOAD)/$(MPFRFILE)
# =================================================
# B I N
# =================================================
# =================================================
# binutils
# =================================================
CONFIG_BINUTILS =--prefix=$(PREFIX) --target=$(TARGET) --disable-werror --enable-tui --disable-nls
ifneq (m68k-elf,$(TARGET))
CONFIG_BINUTILS += --disable-plugins
endif
# FreeBSD, OSX : libs added by the command brew install gmp
ifeq (Darwin, $(findstring Darwin, $(UNAME_S)))
BREW_PREFIX := $$(brew --prefix)
CONFIG_BINUTILS += --with-libgmp-prefix=$(BREW_PREFIX)
endif
ifeq (FreeBSD, $(findstring FreeBSD, $(UNAME_S)))
PORTS_PREFIX?=/usr/local
CONFIG_BINUTILS += --with-libgmp-prefix=$(PORTS_PREFIX)
endif
BINUTILS_CMD := $(TARGET)-addr2line $(TARGET)-ar $(TARGET)-as $(TARGET)-c++filt \
$(TARGET)-ld $(TARGET)-nm $(TARGET)-objcopy $(TARGET)-objdump $(TARGET)-ranlib \
$(TARGET)-readelf $(TARGET)-size $(TARGET)-strings $(TARGET)-strip
BINUTILS := $(patsubst %,$(PREFIX)/bin/%$(EXEEXT), $(BINUTILS_CMD))
BINUTILS_DIR := . bfd gas ld binutils opcodes
BINUTILSD := $(patsubst %,$(PROJECTS)/binutils/%, $(BINUTILS_DIR))
ALL_GDB := all-gdb
INSTALL_GDB := install-gdb
binutils: $(BUILD)/binutils/_done
$(BUILD)/binutils/_done: $(BUILD)/binutils/Makefile $(shell find 2>/dev/null $(PROJECTS)/binutils -not \( -path $(PROJECTS)/binutils/.git -prune \) -not \( -path $(PROJECTS)/binutils/gprof -prune \) -type f)
@touch -t 0001010000 $(PROJECTS)/binutils/binutils/arparse.y
@touch -t 0001010000 $(PROJECTS)/binutils/binutils/arlex.l
@touch -t 0001010000 $(PROJECTS)/binutils/ld/ldgram.y
@touch -t 0001010000 $(PROJECTS)/binutils/intl/plural.y
$(L0)"make binutils bfd"$(L1)$(MAKE) -C $(BUILD)/binutils all-bfd $(L2)
$(L0)"make binutils gas"$(L1)$(MAKE) -C $(BUILD)/binutils all-gas $(L2)
$(L0)"make binutils binutils"$(L1)$(MAKE) -C $(BUILD)/binutils all-binutils $(L2)
$(L0)"make binutils ld"$(L1)$(MAKE) -C $(BUILD)/binutils all-ld $(L2)
$(L0)"install binutils"$(L1)$(MAKE) -C $(BUILD)/binutils install-gas install-binutils install-ld $(L2)
@echo "done" >$@
$(BUILD)/binutils/Makefile: $(PROJECTS)/binutils/configure
@mkdir -p $(BUILD)/binutils
$(L0)"configure binutils"$(L1) cd $(BUILD)/binutils && $(E) $(PROJECTS)/binutils/configure $(CONFIG_BINUTILS) $(L2)
$(PROJECTS)/binutils/configure:
@cd $(PROJECTS) && git clone -b $(binutils_BRANCH) --depth 16 $(binutils_URL) binutils
# =================================================
# gdb
# =================================================
gdb: $(BUILD)/binutils/_gdb
$(BUILD)/binutils/_gdb: $(BUILD)/binutils/_done
$(L0)"make binutils configure gdb"$(L1)$(MAKE) -C $(BUILD)/binutils configure-gdb $(L2)
$(L0)"make binutils gdb libs"$(L1)$(MAKE) -C $(BUILD)/binutils/gdb all-lib $(L2)
$(L0)"make binutils gdb"$(L1)$(MAKE) -C $(BUILD)/binutils $(ALL_GDB) $(L2)
$(L0)"install binutils gdb"$(L1)$(MAKE) -C $(BUILD)/binutils install-gas install-binutils install-ld $(INSTALL_GDB) $(L2)
@echo "done" >$@
# =================================================
# gprof
# =================================================
CONFIG_GRPOF := --prefix=$(PREFIX) --target=$(TARGET) --disable-werror
gprof: $(BUILD)/binutils/_gprof
$(BUILD)/binutils/_gprof: $(BUILD)/binutils/gprof/Makefile $(shell find 2>/dev/null $(PROJECTS)/binutils/gprof -type f)
$(L0)"make gprof"$(L1)$(MAKE) -C $(BUILD)/binutils/gprof all $(L2)
$(L0)"install gprof"$(L1)$(MAKE) -C $(BUILD)/binutils/gprof install $(L2)
@echo "done" >$@
$(BUILD)/binutils/gprof/Makefile: $(PROJECTS)/binutils/configure $(BUILD)/binutils/_done
@mkdir -p $(BUILD)/binutils/gprof
$(L0)"configure gprof"$(L1) cd $(BUILD)/binutils/gprof && $(E) $(PROJECTS)/binutils/gprof/configure $(CONFIG_GRPOF) $(L2)
# =================================================
# gcc
# =================================================
CONFIG_GCC = --prefix=$(PREFIX) --target=$(TARGET) --enable-languages=c,c++,objc,$(ADDLANG) --enable-version-specific-runtime-libs --disable-libssp --disable-nls \
--with-headers=$(PROJECTS)/newlib-cygwin/newlib/libc/sys/amigaos/include/ --disable-shared --enable-threads=$(THREADS) \
--with-stage1-ldflags="-dynamic-libgcc -dynamic-libstdc++" --with-boot-ldflags="-dynamic-libgcc -dynamic-libstdc++"
# FreeBSD, OSX : libs added by the command brew install gmp mpfr libmpc
ifeq (Darwin, $(findstring Darwin, $(UNAME_S)))
BREW_PREFIX := $$(brew --prefix)
CONFIG_GCC += --with-gmp=$(BREW_PREFIX) \
--with-mpfr=$(BREW_PREFIX) \
--with-mpc=$(BREW_PREFIX)
endif
ifeq (FreeBSD, $(findstring FreeBSD, $(UNAME_S)))
PORTS_PREFIX?=/usr/local
CONFIG_GCC += --with-gmp=$(PORTS_PREFIX) \
--with-mpfr=$(PORTS_PREFIX) \
--with-mpc=$(PORTS_PREFIX)
endif
GCC_CMD := $(TARGET)-c++ $(TARGET)-g++ $(TARGET)-gcc-$(GCC_VERSION) $(TARGET)-gcc-nm \
$(TARGET)-gcov $(TARGET)-gcov-tool $(TARGET)-cpp $(TARGET)-gcc $(TARGET)-gcc-ar \
$(TARGET)-gcc-ranlib $(TARGET)-gcov-dump
GCC := $(patsubst %,$(PREFIX)/bin/%$(EXEEXT), $(GCC_CMD))
GCC_DIR := . gcc gcc/c gcc/c-family gcc/cp gcc/objc gcc/config/m68k libiberty libcpp libdecnumber
GCCD := $(patsubst %,$(PROJECTS)/gcc/%, $(GCC_DIR))
gcc: $(BUILD)/gcc/_done
$(BUILD)/gcc/_done: $(BUILD)/gcc/Makefile $(shell find 2>/dev/null $(GCCD) -maxdepth 1 -type f )
$(L0)"make gcc"$(L1) $(MAKE) -C $(BUILD)/gcc all-gcc $(L2)
$(L0)"install gcc"$(L1) $(MAKE) -C $(BUILD)/gcc install-gcc $(L2)
@echo "done" >$@
$(BUILD)/gcc/Makefile: $(PROJECTS)/gcc/configure $(BUILD)/binutils/_done
@mkdir -p $(BUILD)/gcc
ifneq ($(OWNGMP),)
@mkdir -p $(PROJECTS)/gcc/gmp
@mkdir -p $(PROJECTS)/gcc/mpc
@mkdir -p $(PROJECTS)/gcc/mpfr
@rsync -a --no-group $(PROJECTS)/$(GMP)/* $(PROJECTS)/gcc/gmp
@rsync -a --no-group $(PROJECTS)/$(MPC)/* $(PROJECTS)/gcc/mpc
@rsync -a --no-group $(PROJECTS)/$(MPFR)/* $(PROJECTS)/gcc/mpfr
endif
$(L0)"configure gcc"$(L1) cd $(BUILD)/gcc && $(E) $(PROJECTS)/gcc/configure $(CONFIG_GCC) $(L2)
$(PROJECTS)/gcc/configure:
@cd $(PROJECTS) && git clone -b $(gcc_BRANCH) --depth 16 $(gcc_URL)
# =================================================
# fd2sfd
# =================================================
CONFIG_FD2SFD := --prefix=$(PREFIX) --target=$(TARGET)
fd2sfd: $(BUILD)/fd2sfd/_done
$(BUILD)/fd2sfd/_done: $(PREFIX)/bin/fd2sfd
@echo "done" >$@
$(PREFIX)/bin/fd2sfd: $(BUILD)/fd2sfd/Makefile $(shell find 2>/dev/null $(PROJECTS)/fd2sfd -not \( -path $(PROJECTS)/fd2sfd/.git -prune \) -type f)
$(L0)"make fd2sfd"$(L1) $(MAKE) -C $(BUILD)/fd2sfd all $(L2)
@mkdir -p $(PREFIX)/bin/
$(L0)"install fd2sfd"$(L1) $(MAKE) -C $(BUILD)/fd2sfd install $(L2)
$(BUILD)/fd2sfd/Makefile: $(PROJECTS)/fd2sfd/configure
@mkdir -p $(BUILD)/fd2sfd
$(L0)"configure fd2sfd"$(L1) cd $(BUILD)/fd2sfd && $(E) $(PROJECTS)/fd2sfd/configure $(CONFIG_FD2SFD) $(L2)
$(PROJECTS)/fd2sfd/configure:
@cd $(PROJECTS) && git clone -b $(fd2sfd_BRANCH) --depth 4 $(fd2sfd_URL)
for i in $$(find patches/fd2sfd/ -type f); \
do if [[ "$$i" == *.diff ]] ; \
then j=$${i:8}; patch -N "$(PROJECTS)/$${j%.diff}" "$$i"; fi ; done
# =================================================
# fd2pragma
# =================================================
fd2pragma: $(BUILD)/fd2pragma/_done
$(BUILD)/fd2pragma/_done: $(PREFIX)/bin/fd2pragma
@echo "done" >$@
$(PREFIX)/bin/fd2pragma: $(BUILD)/fd2pragma/fd2pragma
@mkdir -p $(PREFIX)/bin/
$(L0)"install fd2sfd"$(L1) install $(BUILD)/fd2pragma/fd2pragma $(PREFIX)/bin/ $(L2)
$(BUILD)/fd2pragma/fd2pragma: $(PROJECTS)/fd2pragma/makefile $(shell find 2>/dev/null $(PROJECTS)/fd2pragma -not \( -path $(PROJECTS)/fd2pragma/.git -prune \) -type f)
@mkdir -p $(BUILD)/fd2pragma
$(L0)"make fd2sfd"$(L1) cd $(PROJECTS)/fd2pragma && $(CC) -o $@ $(CFLAGS) fd2pragma.c $(L2)
$(PROJECTS)/fd2pragma/makefile:
@cd $(PROJECTS) && git clone -b $(fd2pragma_BRANCH) --depth 4 $(fd2pragma_URL)
# =================================================
# ira
# =================================================
ira: $(BUILD)/ira/_done
$(BUILD)/ira/_done: $(PREFIX)/bin/ira
@echo "done" >$@
$(PREFIX)/bin/ira: $(BUILD)/ira/ira
@mkdir -p $(PREFIX)/bin/
$(L0)"install ira"$(L1) install $(BUILD)/ira/ira $(PREFIX)/bin/ $(L2)
$(BUILD)/ira/ira: $(PROJECTS)/ira/Makefile $(shell find 2>/dev/null $(PROJECTS)/ira -not \( -path $(PROJECTS)/ira/.git -prune \) -type f)
@mkdir -p $(BUILD)/ira
$(L0)"make ira"$(L1) cd $(PROJECTS)/ira && $(CC) -o $@ $(CFLAGS) *.c -std=c99 $(L2)
$(PROJECTS)/ira/Makefile:
@cd $(PROJECTS) && git clone -b $(ira_BRANCH) --depth 4 $(ira_URL)
# =================================================
# sfdc
# =================================================
CONFIG_SFDC := --prefix=$(PREFIX) --target=$(TARGET)
sfdc: $(BUILD)/sfdc/_done
$(BUILD)/sfdc/_done: $(PREFIX)/bin/sfdc
@echo "done" >$@
$(PREFIX)/bin/sfdc: $(BUILD)/sfdc/Makefile
$(L0)"make sfdc"$(L1) $(MAKE) -C $(BUILD)/sfdc sfdc $(L2)
@mkdir -p $(PREFIX)/bin/
$(L0)"install sfdc"$(L1) install $(BUILD)/sfdc/sfdc $(PREFIX)/bin $(L2)
$(BUILD)/sfdc/Makefile: $(PROJECTS)/sfdc/configure $(shell find 2>/dev/null $(PROJECTS)/sfdc -not \( -path $(PROJECTS)/sfdc/.git -prune \) -type f)
@rsync -a --no-group $(PROJECTS)/sfdc $(BUILD)/ --exclude .git
$(L0)"configure sfdc"$(L1) cd $(BUILD)/sfdc && $(E) $(BUILD)/sfdc/configure $(CONFIG_SFDC) $(L2)
$(PROJECTS)/sfdc/configure:
@cd $(PROJECTS) && git clone -b $(sfdc_BRANCH) --depth 4 $(sfdc_URL)
# =================================================
# vasm
# =================================================
VASM_CMD := vasmm68k_mot
VASM := $(patsubst %,$(PREFIX)/bin/%$(EXEEXT), $(VASM_CMD))
vasm: $(BUILD)/vasm/_done
$(BUILD)/vasm/_done: $(BUILD)/vasm/Makefile
$(L0)"make vasm"$(L1) $(MAKE) -C $(BUILD)/vasm CPU=m68k SYNTAX=mot $(L2)
@mkdir -p $(PREFIX)/bin/
$(L0)"install vasm"$(L1) install $(BUILD)/vasm/vasmm68k_mot $(PREFIX)/bin/ ;\
install $(BUILD)/vasm/vobjdump $(PREFIX)/bin/ $(L2)
@echo "done" >$@
$(BUILD)/vasm/Makefile: $(PROJECTS)/vasm/Makefile $(shell find 2>/dev/null $(PROJECTS)/vasm -not \( -path $(PROJECTS)/vasm/.git -prune \) -type f)
@rsync -a --no-group $(PROJECTS)/vasm $(BUILD)/ --exclude .git
@touch $(BUILD)/vasm/Makefile
$(PROJECTS)/vasm/Makefile:
@cd $(PROJECTS) && git clone -b $(vasm_BRANCH) --depth 4 $(vasm_URL)
# =================================================
# vbcc
# =================================================
VBCC_CMD := vbccm68k vprof vc
VBCC := $(patsubst %,$(PREFIX)/bin/%$(EXEEXT), $(VBCC_CMD))
vbcc: $(BUILD)/vbcc/_done
$(BUILD)/vbcc/_done: $(BUILD)/vbcc/Makefile
$(L0)"make vbcc dtgen"$(L1) TARGET=m68k $(MAKE) -C $(BUILD)/vbcc bin/dtgen $(L2)
@cd $(BUILD)/vbcc && echo -e "y\\ny\\nsigned char\\ny\\nunsigned char\\nn\\ny\\nsigned short\\nn\\ny\\nunsigned short\\nn\\ny\\nsigned int\\nn\\ny\\nunsigned int\\nn\\ny\\nsigned long long\\nn\\ny\\nunsigned long long\\nn\\ny\\nfloat\\nn\\ny\\ndouble\\n" >c.txt
$(L0)"run vbcc dtgen"$(L1) cd $(BUILD)/vbcc && bin/dtgen machines/m68k/machine.dt machines/m68k/dt.h machines/m68k/dt.c <c.txt $(L2)
$(L0)"make vbcc"$(L1) TARGET=m68k $(MAKE) -C $(BUILD)/vbcc $(L2)
@mkdir -p $(PREFIX)/bin/
@rm -rf $(BUILD)/vbcc/bin/*.dSYM
$(L0)"install vbcc"$(L1) install $(BUILD)/vbcc/bin/v* $(PREFIX)/bin/ $(L2)
@echo "done" >$@
$(BUILD)/vbcc/Makefile: $(PROJECTS)/vbcc/Makefile $(shell find 2>/dev/null $(PROJECTS)/vbcc -not \( -path $(PROJECTS)/vbcc/.git -prune \) -type f)
@rsync -a --no-group $(PROJECTS)/vbcc $(BUILD)/ --exclude .git
@mkdir -p $(BUILD)/vbcc/bin
@touch $(BUILD)/vbcc/Makefile
$(PROJECTS)/vbcc/Makefile:
@cd $(PROJECTS) && git clone -b $(vbcc_BRANCH) --depth 4 $(vbcc_URL)
# =================================================
# vlink
# =================================================
VLINK_CMD := vlink
VLINK := $(patsubst %,$(PREFIX)/bin/%$(EXEEXT), $(VLINK_CMD))
vlink: $(BUILD)/vlink/_done vbcc-target
$(BUILD)/vlink/_done: $(BUILD)/vlink/Makefile $(shell find 2>/dev/null $(PROJECTS)/vlink -not \( -path $(PROJECTS)/vlink/.git -prune \) -type f)
$(L0)"make vlink"$(L1) cd $(BUILD)/vlink && TARGET=m68k $(MAKE) $(L2)
@mkdir -p $(PREFIX)/bin/
$(L0)"install vlink"$(L1) install $(BUILD)/vlink/vlink $(PREFIX)/bin/ $(L2)
@echo "done" >$@
$(BUILD)/vlink/Makefile: $(PROJECTS)/vlink/Makefile
@rsync -a --no-group $(PROJECTS)/vlink $(BUILD)/ --exclude .git
$(PROJECTS)/vlink/Makefile:
@cd $(PROJECTS) && git clone -b $(vlink_BRANCH) --depth 4 $(vlink_URL)
.PHONY: lha
lha: $(BUILD)/_lha_done
$(BUILD)/_lha_done:
@if [ ! -e "$$(which lha 2>/dev/null)" ]; then \
cd $(BUILD) && rm -rf lha; \
$(L00)"clone lha"$(L1) git clone -b $(lha_BRANCH) $(lha_URL); $(L2); \
cd lha; \
$(L00)"configure lha"$(L1) aclocal; autoheader; automake -a; autoconf; ./configure; $(L2); \
$(L00)"make lha"$(L1) make all; $(L2); \
$(L00)"install lha"$(L1) mkdir -p $(PREFIX)/bin/; install src/lha$(EXEEXT) $(PREFIX)/bin/lha$(EXEEXT); $(L2); \
fi
@echo "done" >$@
.PHONY: vbcc-target
vbcc-target: $(BUILD)/vbcc_target_$(TARGET)/_done $(BUILD)/vbcc_target_m68k-kick13/_done
$(BUILD)/vbcc_target_m68k-kick13/_done: $(BUILD)/vbcc_target_m68k-kick13.info patches/vc.config $(BUILD)/vasm/_done
@mkdir -p $(PREFIX)/m68k-kick13/vbcc/include
$(L0)"copying vbcc headers"$(L1) rsync --no-group $(BUILD)/vbcc_target_m68k-kick13/targets/m68k-kick13/include/* $(PREFIX)/m68k-kick13/vbcc/include $(L2)
@mkdir -p $(PREFIX)/m68k-kick13/vbcc/lib
$(L0)"copying vbcc headers"$(L1) rsync --no-group $(BUILD)/vbcc_target_m68k-kick13/targets/m68k-kick13/lib/* $(PREFIX)/m68k-kick13/vbcc/lib $(L2)
@echo "done" >$@
$(L0)"creating vbcc kick13 config"$(L1) $(SED) -e "s|PREFIX|$(PREFIX)|g" patches/kick13.config >$(BUILD)/vasm/kick13.config ;\
install $(BUILD)/vasm/kick13.config $(PREFIX)/bin/ $(L2)
$(BUILD)/vbcc_target_m68k-amigaos/_done: $(BUILD)/vbcc_target_m68k-amigaos.info $(BUILD)/vasm/_done
@mkdir -p $(PREFIX)/m68k-amigaos/vbcc/include
$(L0)"copying vbcc headers"$(L1) rsync --no-group $(BUILD)/vbcc_target_m68k-amigaos/targets/m68k-amigaos/include/* $(PREFIX)/m68k-amigaos/vbcc/include $(L2)
@mkdir -p $(PREFIX)/m68k-amigaos/vbcc/lib
$(L0)"copying vbcc headers"$(L1) rsync --no-group $(BUILD)/vbcc_target_m68k-amigaos/targets/m68k-amigaos/lib/* $(PREFIX)/m68k-amigaos/vbcc/lib $(L2)
@echo "done" >$@
$(L0)"creating vbcc config"$(L1) $(SED) -e "s|PREFIX|$(PREFIX)|g" patches/vc.config >$(BUILD)/vasm/vc.config ;\
install $(BUILD)/vasm/vc.config $(PREFIX)/bin/ $(L2)
$(BUILD)/vbcc_target_m68k-kick13.info: $(DOWNLOAD)/vbcc_target_m68k-kick13.lha $(BUILD)/_lha_done
$(L0)"unpack vbcc_target_m68k-kick13"$(L1) cd $(BUILD) && lha xf $(DOWNLOAD)/vbcc_target_m68k-kick13.lha $(L2)
@touch $(BUILD)/vbcc_target_m68k-kick13.info
$(BUILD)/vbcc_target_m68k-amigaos.info: $(DOWNLOAD)/vbcc_target_m68k-amigaos.lha $(BUILD)/_lha_done
$(L0)"unpack vbcc_target_m68k-amigaos"$(L1) cd $(BUILD) && lha xf $(DOWNLOAD)/vbcc_target_m68k-amigaos.lha $(L2)
@touch $(BUILD)/vbcc_target_m68k-amigaos.info
$(DOWNLOAD)/vbcc_target_m68k-kick13.lha:
$(call get-file,vbcc_target13,http://aminet.net/dev/c/vbcc_target_m68k-kick13.lha,vbcc_target_m68k-kick13.lha)
$(DOWNLOAD)/vbcc_target_m68k-amigaos.lha:
$(call get-file,vbcc_target,http://aminet.net/dev/c/vbcc_target_m68k-amiga.lha,vbcc_target_m68k-amigaos.lha)
# =================================================
# L I B R A R I E S
# =================================================
# =================================================
# NDK - no git
# =================================================
NDK_INCLUDE = $(shell find 2>/dev/null $(PROJECTS)/$(NDK_FOLDER_NAME_H) -type f)
NDK_INCLUDE_SFD = $(shell find 2>/dev/null $(PROJECTS)/$(NDK_FOLDER_NAME_SFD) -type f -name *.sfd)
NDK_INCLUDE_INLINE = $(patsubst $(PROJECTS)/$(NDK_FOLDER_NAME_SFD)/%_lib.sfd,$(PREFIX)/$(TARGET)/ndk-include/inline/%.h,$(NDK_INCLUDE_SFD))
NDK_INCLUDE_INLINE_VBCC = $(patsubst $(PROJECTS)/$(NDK_FOLDER_NAME_SFD)/%_lib.sfd,$(PREFIX)/$(TARGET)/ndk-include/inline/%_protos.h,$(NDK_INCLUDE_SFD))
NDK_INCLUDE_LVO = $(patsubst $(PROJECTS)/$(NDK_FOLDER_NAME_SFD)/%_lib.sfd,$(PREFIX)/$(TARGET)/ndk-include/lvo/%_lib.i,$(NDK_INCLUDE_SFD))
NDK_INCLUDE_PROTO = $(patsubst $(PROJECTS)/$(NDK_FOLDER_NAME_SFD)/%_lib.sfd,$(PREFIX)/$(TARGET)/ndk-include/proto/%.h,$(NDK_INCLUDE_SFD))
SYS_INCLUDE2 = $(filter-out $(NDK_INCLUDE_PROTO),$(patsubst $(PROJECTS)/$(NDK_FOLDER_NAME_H)/%,$(PREFIX)/$(TARGET)/ndk-include/%, $(NDK_INCLUDE)))
.PHONY: ndk-inline ndk-inline-vbcc ndk-lvo ndk-proto
ndk: $(BUILD)/ndk-include_ndk
$(BUILD)/ndk-include_ndk: $(BUILD)/ndk-include_ndk0 $(NDK_INCLUDE_INLINE) $(NDK_INCLUDE_INLINE_VBCC) $(NDK_INCLUDE_LVO) $(NDK_INCLUDE_PROTO) $(PROJECTS)/fd2sfd/configure $(PROJECTS)/fd2pragma/makefile
$(MAKE) ndk_inc=1 ndk-proto ndk-lvo ndk-inline ndk-inline-vbcc
@mkdir -p $(BUILD)/ndk-include/
@echo "done" >$@
$(BUILD)/ndk-include_ndk0: $(PROJECTS)/$(NDK_FOLDER_NAME).info $(NDK_INCLUDE) $(BUILD)/fd2sfd/_done $(BUILD)/fd2pragma/_done
@mkdir -p $(PREFIX)/$(TARGET)/ndk-include
@rsync -a --no-group $(PROJECTS)/$(NDK_FOLDER_NAME_H)/* $(PREFIX)/$(TARGET)/ndk-include --exclude proto --exclude inline
$(L0)"STDARGing ndk"$(L1) for i in $$(find $(PREFIX)/$(TARGET)/ndk-include/clib/*protos.h -type f); do \
echo $$i; \
LC_CTYPE=C $(SED) -i.bak -E 's/([a-zA-Z0-9 _]*)([[:blank:]]+|\*)([a-zA-Z0-9_]+)\(/\1\2 __stdargs \3(/g' $$i; \
rm $$i.bak; done $(L2)
@rsync -a --no-group $(PROJECTS)/$(NDK_FOLDER_NAME_I)/* $(PREFIX)/$(TARGET)/ndk-include
@mkdir -p $(PREFIX)/$(TARGET)/ndk/lib/fd
@mkdir -p $(PREFIX)/$(TARGET)/ndk/lib/sfd
@mkdir -p $(PREFIX)/$(TARGET)/ndk/lib/libs
@rsync -a --no-group $(PROJECTS)/$(NDK_FOLDER_NAME_FD)/* $(PREFIX)/$(TARGET)/ndk/lib/fd
@rsync -a --no-group $(PROJECTS)/$(NDK_FOLDER_NAME_SFD)/* $(PREFIX)/$(TARGET)/ndk/lib/sfd
@rsync -a --no-group $(PROJECTS)/$(NDK_FOLDER_NAME_LIBS)/* $(PREFIX)/$(TARGET)/ndk/lib/libs
@mkdir -p $(PREFIX)/$(TARGET)/ndk-include/proto
@cp -p $(PROJECTS)/$(NDK_FOLDER_NAME_H)/proto/alib.h $(PREFIX)/$(TARGET)/ndk-include/proto
@cp -p $(PROJECTS)/$(NDK_FOLDER_NAME_H)/proto/cardres.h $(PREFIX)/$(TARGET)/ndk-include/proto
@mkdir -p $(PREFIX)/$(TARGET)/ndk-include/inline
@cp -p $(PROJECTS)/fd2sfd/cross/share/m68k-amigaos/alib.h $(PREFIX)/$(TARGET)/ndk-include/inline
@cp -p $(PROJECTS)/fd2pragma/Include/inline/stubs.h $(PREFIX)/$(TARGET)/ndk-include/inline
@cp -p $(PROJECTS)/fd2pragma/Include/inline/macros.h $(PREFIX)/$(TARGET)/ndk-include/inline
@mkdir -p $(BUILD)/ndk-include/
@echo "done" >$@
ndk-inline: $(NDK_INCLUDE_INLINE) sfdc $(BUILD)/ndk-include_inline
$(NDK_INCLUDE_INLINE): $(PREFIX)/bin/sfdc $(NDK_INCLUDE_SFD) $(BUILD)/ndk-include_inline $(BUILD)/ndk-include_lvo $(BUILD)/ndk-include_proto $(BUILD)/ndk-include_ndk0
$(L0)"sfdc inline $(@F)"$(L1) sfdc --target=m68k-amigaos --mode=macros --output=$@ $(patsubst $(PREFIX)/$(TARGET)/ndk-include/inline/%.h,$(PROJECTS)/$(NDK_FOLDER_NAME_SFD)/%_lib.sfd,$@) $(L2)
ndk-inline-vbcc: $(NDK_INCLUDE_INLINE_VBCC) sfdc $(BUILD)/ndk-include_inline
$(NDK_INCLUDE_INLINE_VBCC): $(PREFIX)/bin/sfdc $(NDK_INCLUDE_SFD) $(BUILD)/ndk-include_inline $(BUILD)/ndk-include_lvo $(BUILD)/ndk-include_proto $(BUILD)/ndk-include_ndk0
$(L0)"sfdc inline vbcc $(@F)"$(L1) sfdc --target=m68kvbcc-amigaos --mode=macros --output=$@ $(patsubst $(PREFIX)/$(TARGET)/ndk-include/inline/%_protos.h,$(PROJECTS)/$(NDK_FOLDER_NAME_SFD)/%_lib.sfd,$@) $(L2)
ndk-lvo: $(NDK_INCLUDE_LVO) sfdc
$(NDK_INCLUDE_LVO): $(PREFIX)/bin/sfdc $(NDK_INCLUDE_SFD) $(BUILD)/ndk-include_lvo $(BUILD)/ndk-include_ndk0
$(L0)"sfdc lvo $(@F)"$(L1) sfdc --target=m68k-amigaos --mode=lvo --output=$@ $(patsubst $(PREFIX)/$(TARGET)/ndk-include/lvo/%_lib.i,$(PROJECTS)/$(NDK_FOLDER_NAME_SFD)/%_lib.sfd,$@) $(L2)
ndk-proto: $(NDK_INCLUDE_PROTO) sfdc
$(NDK_INCLUDE_PROTO): $(PREFIX)/bin/sfdc $(NDK_INCLUDE_SFD) $(BUILD)/ndk-include_proto $(BUILD)/ndk-include_ndk0
$(L0)"sfdc proto $(@F)"$(L1) sfdc --target=m68k-amigaos --mode=proto --output=$@ $(patsubst $(PREFIX)/$(TARGET)/ndk-include/proto/%.h,$(PROJECTS)/$(NDK_FOLDER_NAME_SFD)/%_lib.sfd,$@) $(L2)
$(BUILD)/ndk-include_inline: $(PROJECTS)/$(NDK_FOLDER_NAME).info
@mkdir -p $(PREFIX)/$(TARGET)/ndk-include/inline
@mkdir -p $(BUILD)/ndk-include/
@echo "done" >$@
$(BUILD)/ndk-include_lvo: $(PROJECTS)/$(NDK_FOLDER_NAME).info
@mkdir -p $(PREFIX)/$(TARGET)/ndk-include/lvo
@mkdir -p $(PREFIX)/$(TARGET)/ndk13-include/lvo
@mkdir -p $(BUILD)/ndk-include/
@echo "done" >$@
$(BUILD)/ndk-include_proto: $(PROJECTS)/$(NDK_FOLDER_NAME).info
@mkdir -p $(PREFIX)/$(TARGET)/ndk-include/proto
@mkdir -p $(PREFIX)/$(TARGET)/ndk13-include/proto
@mkdir -p $(BUILD)/ndk-include/
@echo "done" >$@
$(PROJECTS)/$(NDK_FOLDER_NAME).info: $(BUILD)/_lha_done $(DOWNLOAD)/$(NDK_ARC_NAME).lha $(shell find 2>/dev/null patches/$(NDK_FOLDER_NAME)/ -type f)
$(L0)"unpack ndk"$(L1) cd $(PROJECTS) && if [[ $(NDK_ARC_NAME) == "NDK3.2" ]] ; \
then mkdir NDK3.2 ; cd NDK3.2 ; fi ; \
lha xf $(DOWNLOAD)/$(NDK_ARC_NAME).lha $(L2)
@touch -t 0001010000 $(DOWNLOAD)/$(NDK_ARC_NAME).lha
$(L0)"patch ndk"$(L1) for i in $$(find patches/$(NDK_FOLDER_NAME)/ -type f); do \
if [[ "$$i" == *.diff ]] ; \
then j=$${i:8}; patch -N "$(PROJECTS)/$${j%.diff}" "$$i"; \
else cp -pv "$$i" "$(PROJECTS)/$${i:8}"; fi ; done $(L2)
@touch $(PROJECTS)/$(NDK_FOLDER_NAME).info
$(DOWNLOAD)/$(NDK_ARC_NAME).lha:
$(call get-file,$(NDK_ARC_NAME),$(NDK_URL),$(NDK_ARC_NAME).lha)
# =================================================
# NDK1.3 - emulated from NDK
# =================================================
.PHONY: ndk_13
ndk13: $(BUILD)/ndk-include_ndk13
$(BUILD)/ndk-include_ndk13: $(BUILD)/ndk-include_ndk $(BUILD)/fd2sfd/_done $(BUILD)/sfdc/_done
@while read p; do p=$$(echo $$p|tr -d '\n'); mkdir -p $(PREFIX)/$(TARGET)/ndk13-include/$$(dirname $$p); cp $(PREFIX)/$(TARGET)/ndk-include/$$p $(PREFIX)/$(TARGET)/ndk13-include/$$p; done < patches/ndk13/hfiles
$(L0)"extract ndk13"$(L1) while read p; do p=$$(echo $$p|tr -d '\n'); \
mkdir -p $(PREFIX)/$(TARGET)/ndk13-include/$$(dirname $$p); \
if grep V36 $(PREFIX)/$(TARGET)/ndk-include/$$p; then \
LC_CTYPE=C $(SED) -n -e '/#ifndef[[:space:]]*CLIB/,/V36/p' $(PREFIX)/$(TARGET)/ndk-include/$$p | $(SED) -e 's/__stdargs//g' >$(PREFIX)/$(TARGET)/ndk13-include/$$p; \
echo -e "#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n#endif" >>$(PREFIX)/$(TARGET)/ndk13-include/$$p; \
else LC_CTYPE=C $(SED) $(PREFIX)/$(TARGET)/ndk-include/$$p -e 's/__stdargs//g' >$(PREFIX)/$(TARGET)/ndk13-include/$$p; fi \
done < patches/ndk13/chfiles $(L2)
@while read p; do p=$$(echo $$p|tr -d '\n'); mkdir -p $(PREFIX)/$(TARGET)/ndk13-include/$$(dirname $$p); echo "" >$(PREFIX)/$(TARGET)/ndk13-include/$$p; done < patches/ndk13/ehfiles
@echo '#undef EXECNAME' > $(PREFIX)/$(TARGET)/ndk13-include/exec/execname.h
@echo '#define EXECNAME "exec.library"' >> $(PREFIX)/$(TARGET)/ndk13-include/exec/execname.h
@mkdir -p $(PREFIX)/$(TARGET)/ndk/lib/fd13
@while read p; do p=$$(echo $$p|tr -d '\n'); LC_CTYPE=C $(SED) -n -e '/##base/,/V36/P' $(PREFIX)/$(TARGET)/ndk/lib/fd/$$p >$(PREFIX)/$(TARGET)/ndk/lib/fd13/$$p; done < patches/ndk13/fdfiles
@mkdir -p $(PREFIX)/$(TARGET)/ndk/lib/sfd13
@for i in $(PREFIX)/$(TARGET)/ndk/lib/fd13/*; do fd2sfd $$i $(PREFIX)/$(TARGET)/ndk13-include/clib/$$(basename $$i _lib.fd)_protos.h > $(PREFIX)/$(TARGET)/ndk/lib/sfd13/$$(basename $$i .fd).sfd; done
$(L0)"macros+protos ndk13"$(L1) for i in $(PREFIX)/$(TARGET)/ndk/lib/sfd13/*; do \
sfdc --target=m68k-amigaos --mode=macros --output=$(PREFIX)/$(TARGET)/ndk13-include/inline/$$(basename $$i _lib.sfd).h $$i; \
sfdc --target=m68k-amigaos --mode=proto --output=$(PREFIX)/$(TARGET)/ndk13-include/proto/$$(basename $$i _lib.sfd).h $$i; \
done $(L2)
$(L0)"STDARGing ndk13"$(L1) for i in $$(find $(PREFIX)/$(TARGET)/ndk13-include/clib/*protos.h -type f); do \
echo $$i; \
LC_CTYPE=C $(SED) -i.bak -E 's/([a-zA-Z0-9 _]*)([[:blank:]]+|\*)([a-zA-Z0-9_]+)\(/\1\2 __stdargs \3(/g' $$i; \
rm $$i.bak; done $(L2)
@echo "done" >$@
# =================================================
# netinclude
# =================================================
.PHONY: netinclude
netinclude: $(BUILD)/_netinclude
$(BUILD)/_netinclude: $(PROJECTS)/amiga-netinclude/README.md $(BUILD)/ndk-include_ndk $(shell find 2>/dev/null $(PROJECTS)/amiga-netinclude/include -type f)
@mkdir -p $(PREFIX)/$(TARGET)/ndk-include
@rsync -a --no-group $(PROJECTS)/amiga-netinclude/include/* $(PREFIX)/$(TARGET)/ndk-include
@echo "done" >$@
$(PROJECTS)/amiga-netinclude/README.md:
@cd $(PROJECTS) && git clone -b $(amiga-netinclude_BRANCH) --depth 4 $(amiga-netinclude_URL)
# =================================================
# libamiga
# =================================================
LIBAMIGA := $(PREFIX)/$(TARGET)/lib/libamiga.a
LIBBAMIGA := $(PREFIX)/$(TARGET)/lib/libb/libamiga.a
libamiga: $(LIBAMIGA) $(LIBBAMIGA)
@echo "built $(LIBAMIGA) and $(LIBBAMIGA)"
$(LIBAMIGA):
@mkdir -p $(@D)
#@cp $(PROJECTS)/$(NDK_FOLDER_NAME_LIBS)/amiga.lib $@
@cp lib/libamiga.a $@
$(LIBBAMIGA):
@mkdir -p $(@D)
@cp lib/libb/libamiga.a $@
# =================================================
# libnix
# =================================================
LIBNIX_SRC = $(shell find 2>/dev/null $(PROJECTS)/libnix -not \( -path $(PROJECTS)/libnix/.git -prune \) -not \( -path $(PROJECTS)/libnix/sources/stubs/libbases -prune \) -not \( -path $(PROJECTS)/libnix/sources/stubs/libnames -prune \) -type f)
libnix: $(BUILD)/libnix/_done
$(BUILD)/libnix/_done: $(BUILD)/newlib/_done $(BUILD)/ndk-include_ndk $(BUILD)/ndk-include_ndk13 $(BUILD)/_netinclude $(BUILD)/binutils/_done $(BUILD)/gcc/_done $(PROJECTS)/libnix/Makefile.gcc6 $(LIBAMIGA) $(LIBNIX_SRC)
@mkdir -p $(PREFIX)/$(TARGET)/libnix/lib/libnix
@mkdir -p $(BUILD)/libnix
@mkdir -p $(PREFIX)/lib/gcc/$(TARGET)/$(GCC_VERSION)
@if [ ! -e $(PREFIX)/lib/gcc/$(TARGET)/$(GCC_VERSION)/libgcc.a ]; then $(PREFIX)/bin/$(TARGET)-ar rcs $(PREFIX)/lib/gcc/$(TARGET)/$(GCC_VERSION)/libgcc.a; fi
$(L0)"make libnix"$(L1) CFLAGS="$(CFLAGS_FOR_TARGET)" $(MAKE) -C $(BUILD)/libnix -f $(PROJECTS)/libnix/Makefile.gcc6 root=$(PROJECTS)/libnix all $(L2)
$(L0)"install libnix"$(L1) $(MAKE) -C $(BUILD)/libnix -f $(PROJECTS)/libnix/Makefile.gcc6 root=$(PROJECTS)/libnix install $(L2)
@rsync --delete -a --no-group $(PROJECTS)/libnix/sources/headers/* $(PREFIX)/$(TARGET)/libnix/include/
@echo "done" >$@
$(PROJECTS)/libnix/Makefile.gcc6:
@cd $(PROJECTS) && git clone -b $(libnix_BRANCH) --depth 4 $(libnix_URL)
# =================================================
# gcc libs
# =================================================
LIBGCCS_NAMES := libgcov.a libstdc++.a libsupc++.a
LIBGCCS := $(patsubst %,$(PREFIX)/lib/gcc/$(TARGET)/$(GCC_VERSION)/%,$(LIBGCCS_NAMES))
libgcc: $(BUILD)/gcc/_libgcc_done
$(BUILD)/gcc/_libgcc_done: $(BUILD)/libnix/_done $(BUILD)/libpthread/_done $(LIBAMIGA) $(shell find 2>/dev/null $(PROJECTS)/gcc/libgcc -type f)
$(L0)"make libgcc"$(L1) $(MAKE) -C $(BUILD)/gcc all-target $(L2)
$(L0)"install libgcc"$(L1) $(MAKE) -C $(BUILD)/gcc install-target $(L2)
@echo "done" >$@
# =================================================
# clib2
# =================================================
clib2: $(BUILD)/clib2/_done
$(BUILD)/clib2/_done: $(PROJECTS)/clib2/LICENSE $(shell find 2>/dev/null $(PROJECTS)/clib2 -not \( -path $(PROJECTS)/clib2/.git -prune \) -type f) $(BUILD)/libnix/_done $(LIBAMIGA)
@mkdir -p $(BUILD)/clib2/
@rsync -a --no-group $(PROJECTS)/clib2/library/* $(BUILD)/clib2
@cd $(BUILD)/clib2 && find * -name lib\*.a -delete
$(L0)"make clib2"$(L1) $(MAKE) -C $(BUILD)/clib2 -f GNUmakefile.68k -j1 $(L2)
@mkdir -p $(PREFIX)/$(TARGET)/clib2
@rsync -a --no-group $(BUILD)/clib2/include $(PREFIX)/$(TARGET)/clib2
@rsync -a --no-group $(BUILD)/clib2/lib $(PREFIX)/$(TARGET)/clib2
@echo "done" >$@
$(PROJECTS)/clib2/LICENSE:
@cd $(PROJECTS) && git clone -b $(clib2_BRANCH) --depth 4 $(clib2_URL)
# =================================================
# libdebug
# =================================================
CONFIG_LIBDEBUG := --prefix=$(PREFIX) --target=$(TARGET) --host=$(TARGET)
libdebug: $(BUILD)/libdebug/_done
$(BUILD)/libdebug/_done: $(BUILD)/libdebug/Makefile
$(L0)"make libdebug"$(L1) $(MAKE) -C $(BUILD)/libdebug $(L2)
@cp $(BUILD)/libdebug/libdebug.a $(PREFIX)/$(TARGET)/lib/
@echo "done" >$@
$(BUILD)/libdebug/Makefile: $(BUILD)/libnix/_done $(PROJECTS)/libdebug/configure $(shell find 2>/dev/null $(PROJECTS)/libdebug -not \( -path $(PROJECTS)/libdebug/.git -prune \) -type f)
@mkdir -p $(BUILD)/libdebug
$(L0)"configure libdebug"$(L1) cd $(BUILD)/libdebug && LD=$(TARGET)-ld CC=$(TARGET)-gcc CFLAGS="$(CFLAGS_FOR_TARGET)" $(PROJECTS)/libdebug/configure $(CONFIG_LIBDEBUG) $(L2)
$(PROJECTS)/libdebug/configure:
@cd $(PROJECTS) && git clone -b $(libdebug_BRANCH) --depth 4 $(libdebug_URL)
@touch -t 0001010000 $(PROJECTS)/libdebug/configure.ac
# =================================================
# libpthread
# =================================================
libpthread: $(BUILD)/libpthread/_done
$(BUILD)/libpthread/_done: $(BUILD)/libpthread/Makefile
@rsync -a --no-group --exclude=debug.h $(BUILD)/libpthread/*.h $(PREFIX)/$(TARGET)/include/
$(L0)"make libpthread"$(L1) cd $(BUILD)/libpthread && $(MAKE) -f Makefile.gcc6 $(L2)
$(L0)"install libpthread lib"$(L1) cp $(BUILD)/libpthread/lib/libpthread.a $(PREFIX)/$(TARGET)/lib/ $(L2)
$(L0)"install libpthread libb"$(L1) cp $(BUILD)/libpthread/libb/libpthread.a $(PREFIX)/$(TARGET)/lib/libb/ $(L2)
$(L0)"install libpthread libm020"$(L1) cp $(BUILD)/libpthread/libm020/libpthread.a $(PREFIX)/$(TARGET)/lib/libm020/ $(L2)
$(L0)"install libpthread libm020bb"$(L1) cp $(BUILD)/libpthread/libm020bb/libpthread.a $(PREFIX)/$(TARGET)/lib/libb/libm020/ $(L2)
$(L0)"install libpthread libm020bb32"$(L1) cp $(BUILD)/libpthread/libm020bb32/libpthread.a $(PREFIX)/$(TARGET)/lib/libb32/libm020/ $(L2)
@echo "done" >$@
$(BUILD)/libpthread/Makefile: $(BUILD)/libnix/_done $(PROJECTS)/aros-stuff/pthreads/Makefile $(shell find 2>/dev/null $(PROJECTS)/aros-stuff/pthreads -type f)
@mkdir -p $(BUILD)/libpthread
@rsync -a --no-group $(PROJECTS)/aros-stuff/pthreads/* $(BUILD)/libpthread
@touch $(BUILD)/libpthread/Makefile
$(PROJECTS)/aros-stuff/pthreads/Makefile:
@cd $(PROJECTS) && git clone -b $(aros-stuff_BRANCH) --depth 4 $(aros-stuff_URL)
# =================================================
# newlib
# =================================================
NEWLIB_CONFIG := CC=$(TARGET)-gcc CXX=$(TARGET)-g++
NEWLIB_FILES = $(shell find 2>/dev/null $(PROJECTS)/newlib-cygwin/newlib -type f)
.PHONY: newlib
newlib: $(BUILD)/newlib/_done
$(BUILD)/newlib/_done: $(BUILD)/newlib/newlib/libc.a
@echo "done" >$@
$(BUILD)/newlib/newlib/libc.a: $(BUILD)/newlib/newlib/Makefile $(NEWLIB_FILES)
@rsync -a --no-group $(PROJECTS)/newlib-cygwin/newlib/libc/include/ $(PREFIX)/$(TARGET)/sys-include
@rsync -a --no-group $(PROJECTS)/newlib-cygwin/newlib/libc/sys/amigaos/include/stabs.h $(PREFIX)/$(TARGET)/sys-include
$(L0)"make newlib"$(L1) $(MAKE) -C $(BUILD)/newlib/newlib $(L2)
$(L0)"install newlib"$(L1) $(MAKE) -C $(BUILD)/newlib/newlib install $(L2)
@for x in $$(find $(PREFIX)/$(TARGET)/lib/* -name libm.a); do ln -sf $$x $${x%*m.a}__m__.a; done
@touch $@
$(BUILD)/newlib/newlib/Makefile: $(PROJECTS)/newlib-cygwin/newlib/configure $(BUILD)/ndk-include_ndk $(BUILD)/gcc/_done
@mkdir -p $(BUILD)/newlib/newlib
@if [ ! -f "$(BUILD)/newlib/newlib/Makefile" ]; then \
$(L00)"configure newlib"$(L1) cd $(BUILD)/newlib/newlib && $(NEWLIB_CONFIG) CFLAGS="$(CFLAGS_FOR_TARGET)" CC_FOR_BUILD="$(CC)" CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" $(PROJECTS)/newlib-cygwin/newlib/configure --host=$(TARGET) --prefix=$(PREFIX) --enable-newlib-io-long-long --enable-newlib-io-c99-formats --enable-newlib-reent-small --enable-newlib-mb --enable-newlib-long-time_t $(L2) \
; else touch "$(BUILD)/newlib/newlib/Makefile"; fi
$(PROJECTS)/newlib-cygwin/newlib/configure:
@cd $(PROJECTS) && git clone -b $(newlib-cygwin_BRANCH) --depth 4 $(newlib-cygwin_URL)
# =================================================
# ixemul