-
Notifications
You must be signed in to change notification settings - Fork 139
/
makefile
1571 lines (1398 loc) · 57.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
#!/usr/bin/make -f
#
# This is the FB makefile that builds the compiler (fbc) and the runtime
# libraries (rtlib -> libfb[mt] and fbrt0.o, gfxlib2 -> libfbgfx[mt]). It will
# also take care of moving the resulting binaries into the proper directory
# layout, allowing the new FB setup to be tested right away, without being
# installed elsewhere.
#
# Building the compiler requires a working FB installation, because it's written
# in FB itself. rtlib/gfxlib2 are written in C and some ASM and have several
# dependencies on external libraries depending on the target system.
# (for example: ncurses/libtinfo, gpm, Linux headers, X11, OpenGL, DirectX)
# More info: http://www.freebasic.net/wiki/wikka.php?wakka=DevBuild
#
# What will be built:
#
# compiler:
# src/compiler/*.bas -> fbc[.exe]
#
# rtlib:
# src/rtlib/static/fbrt0.c
# -> fbrt0.o
# -> fbrt0pic.o, -fPIC version (Unixes)
# src/rtlib/static/fbrt1.c (profiling)
# -> fbrt1.o
# -> fbrt1pic.o, -fPIC version (Unixes)
# src/rtlib/static/fbrt2.c (profiling gas64)
# -> fbrt2.o
# -> fbrt2pic.o, -fPIC version (Unixes)
#
# all *.c and *.s files in
# src/rtlib/
# src/rtlib/$(TARGET_OS)
# src/rtlib/$(TARGET_ARCH)
# -> libfb.a
# -> libfbmt.a, -DENABLE_MT (threadsafe) version (except for DOS)
# -> libfbpic.a, -fPIC version (Unixes)
# -> libfbmtpic.a, threadsafe and -fPIC (Unixes)
#
# contrib/djgpp/libc/...
# -> libc.a, fixed libc for DOS/DJGPP (see contrib/djgpp/ for more info)
#
# fbrt:
# src/fbrt/*.bas -> src/fbrt/obj/$(FBTARGET)/*.o
# src/fbrt/*.bas -> src/fbrt/obj/$(FBTARGET)/mt/*.o
# combine missing object modules from:
# src/rtlib/obj/$(FBTARGET)/*.o -> src/fbrt/obj/$(FBTARGET)/*.o
# src/rtlib/obj/$(FBTARGET)/mt/*.o -> src/fbrt/obj/$(FBTARGET)/mt/*.o
# -> libfbrt.a
# -> libfbrtmt.a
# -> libfbrtpic.a
# -> libfbrtmtpic.a
#
# gfxlib2:
# all *.c and *.s files in
# src/gfxlib2/
# src/gfxlib2/$(TARGET_OS)
# src/gfxlib2/$(TARGET_ARCH)
# -> libfbgfx.a
# -> libfbgfxmt.a, -DENABLE_MT (threadsafe) version (except for DOS)
# -> libfbgfxpic.a, -fPIC version (Unixes)
# -> libfbgfxmtpic.a, threadsafe and -fPIC (Unixes)
#
# commands:
#
# <none>|all build everything
# compiler|rtlib|gfxlib2 build specific component only
# fbrt build fbc source runtime replacement
# clean[-component] remove built files
# install[-component] install into $(prefix)
# uninstall[-component] remove from $(prefix)
#
# install-includes (additional commands for just the FB includes,
# uninstall-includes which don't need to be built)
#
# gitdist Create source code packages using "git archive"
# bindist Create binary FB release packages from current build directory content
# mingw-libs Standalone: Copy libraries from MinGW toolchain into lib/win32/ etc.
#
# unit-tests (Convenience wrappers around tests/Makefile, running the tests
# log-tests using the newly built fbc)
# warning-tests
# clean-tests
#
# bootstrap-dist Create source package with precompiled fbc sources
# bootstrap-dist-arm Create source package with precompiled fbc sources for arm and aarch64 only
# bootstrap Build fbc from the precompiled sources (only if precompiled sources exist)
# bootstrap-minimal Build fbc from the precompiled sources (only if precompiled sources exist) with only the minimal features needed to compile another fbc
#
# makefile configuration:
# FB[C|L]FLAGS to set -g -exx etc. for the compiler build and/or link
# CFLAGS same for the rtlib and gfxlib2 build
# prefix install/uninstall directory, default: /usr/local
# TARGET GNU triplet for cross-compiling
# MULTILIB "32", "64" or empty for cross-compiling using a gcc multilib toolchain
# FBC, CC, AR fbc, gcc, ar programs (TARGET may be prefixed to CC/AR)
# V=1 to see full command lines
# ENABLE_STANDALONE=1 build source tree into self-contained FB installation
# ENABLE_PREFIX=1 use "-d ENABLE_PREFIX=$(prefix)" to hard-code the prefix into fbc
# ENABLE_SUFFIX=-0.24 append a string like "-0.24" to fbc/FB dir names,
# and use "-d ENABLE_SUFFIX=$(ENABLE_SUFFIX)" (non-standalone only)
# ENABLE_LIB64=1 use prefix/lib64/ instead of prefix/lib/ for 64bit libs (non-standalone only)
# ENABLE_STRIPALL=1 use "-d ENABLE_STRIPALL" with all targets
# ENABLE_STRIPALL=0 disable "-d ENABLE_STRIPALL" with all targets
# FBSHA1=1 determine the sha-1 of the current commit in repo and store it in the compiler
# FBSHA1=some-sha-1 explicitly indicate the sha-1 to store in the compiler
# FBFORKID=name tells fbc to set a custom value for __FB_BUILD_FORK_ID__
# FBPACKAGE bindist: The package/archive file name without path or extension
# FBPACKTARGET bindist: Override only the FBTARGET part used in package naming
# FBPACKSUFFIX bindist: Allows adding a custom suffix to the normal package name (and the toplevel dir in the archive)
# FBMANIFEST bindist: The manifest file name without path or extension
# FBVERSION bindist/gitdist: FB version number
# DISABLE_DOCS bindist: Don't package readme/changelog/manpage/examples
# BUILD_PREFIX automatically set depending on the target but can override for special builds where the
# build tools have different file naming than the target to build (i.e. cross compiling)
# DISABLE_GAS64_DEBUG use "-d DISABLE_GAS64_DEBUG" (see below)
# DISABLE_STDCXX_PATH tells fbc to not search for some libstdc++/libc++ depending on target platform
# DEFAULT_CPUTYPE_X86=<FB_CPUTYPE> set default x86 cpu type to one of FB_CPU_TYPE
# DEFAULT_CPUTYPE_ARM=<FB_CPUTYPE> set default arm cpu type to one of FB_CPUTYPE
# compiler source code configuration (FBCFLAGS, FBLFLAGS):
# -d ENABLE_STANDALONE build for a self-contained installation
# -d ENABLE_SUFFIX=-0.24 assume FB's lib dir uses the given suffix (non-standalone only)
# -d ENABLE_PREFIX=/some/path hard-code specific $(prefix) into fbc
# -d ENABLE_LIB64 use prefix/lib64/ instead of prefix/lib/ for 64bit libs (non-standalone only)
# -d ENABLE_STRIPALL configure fbc to pass down '--strip-all' to linker by default
# -d FBSHA1=some-sha-1 store 'some-sha-1' in the compiler for version information
# -d DISABLE_GAS64_DEBUG disable gas64 debugging comments in asm files even if __FB_DEBUG__ is defined (-g)
# -d DISABLE_STDCXX_PATH tells fbc to not search for some libstdc++/libc++ depending on target platform
# -d BUILD_FB_DEFAULT_CPUTYPE_X86=<FB_CPUTYPE> set default x86 cpu type to one of FB_CPUTYPE
# -d BUILD_FB_DEFAULT_CPUTYPE_ARM=<FB_CPUTYPE> set default arm cpu type to one of FB_CPUTYPE
# -d FBFORKID="name" tells fbc to set a custom value for __FB_BUILD_FORK_ID__
#
# internal makefile configuration (but can override):
# libsubdir override the library directory - default is set depending on TARGET
# objsubdir override object file directory - default is set depending on TARGET
# fbcobjdir override compiler object directory - default is set depending on TARGET
#
# fbrt source code configuration (FBRTCFLAGS, FBRTLFLAGS)
#
# rtlib/gfxlib2 source code configuration (CFLAGS):
# -DDISABLE_X11 build without X11 headers (disables X11 gfx driver)
# -DDISABLE_GPM build without gpm.h (disables GetMouse in the Linux terminal (TERM=linux),
# although the TERM=xterm variant keeps working)
# -DDISABLE_FFI build without ffi.h (disables ThreadCall)
# -DDISABLE_OPENGL build without OpenGL headers (disables OpenGL gfx drivers)
# -DDISABLE_FBDEV build without Linux framebuffer device headers (disables Linux fbdev gfx driver)
# -DDISABLE_D3D10 build without DirectX 10 driver(disable D2D driver in windows)
# -DDISABLE_NCURSES build without libtinfo or ncurses (disables console commands)
# -DDISABLE_LANGINFO build without locale info (affects Unix only; makes no difference unless you
# call setlocale() manually). Does not remove setlocale(LC_CTYPE, "") call.
# -DDISABLE_WCHAR build without wchar_t type or functions. wstring becomes ASCII only (fbc needs to match this).
#
# makefile variables may either be set on the make command line,
# or (in a more permanent way) inside a 'config.mk' file before
# the makefile variable set-up is evaluated. makefile variables
# already defined in this makefile can also be augmented / modified
# inside a 'config-post.mk' file which is included after all the
# variable set-up, but before the build rules.
#
# The makefile searches the sources based on its location, but builds into
# the current directory. It's possible to build in a separate directory by
# running the makefile via "make -f ../path/to/fbc/makefile" from the desired
# build directory.
#
# The makefile supports only one compiler build per build directory, but
# possibly multiple rtlib/gfxlib2 builds, each for a different target.
# This matches how FB works: one fbc per host, plus one rtlib/gfxlib2 per
# target. For example:
# 1) Build host FB setup
# $ make
# 2) Add rtlib/gfxlib2 for some additional target
# $ make rtlib gfxlib2 TARGET=i686-w64-mingw32
#
FBC := fbc
CFLAGS := -Wfatal-errors -O2
# Avoid gcc exception handling bloat
CFLAGS += -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables
FBFLAGS := -maxerr 1
AS = $(BUILD_PREFIX)as
AR = $(BUILD_PREFIX)ar
CC = $(BUILD_PREFIX)gcc
prefix := /usr/local
# Determine the makefile's directory, this may be a relative path when
# building in a separate build directory via e.g. "make -f ../fbc/makefile".
# MAKEFILE_LIST did not exist in GNU make 3.79.1 (it was only added in 3.80),
# so DJGPP users have to set MAKEFILE_LIST or rootdir manually in order to build
# in a separate directory.
rootdir := $(dir $(MAKEFILE_LIST))
# Prune ./ prefix for beauty
ifeq ($(rootdir),./)
rootdir :=
endif
srcdir := $(rootdir)src
include $(rootdir)version.mk
-include config.mk
#
# We need to know target OS/architecture names to select the proper
# rtlib/fbrt/gfxlib2 source directories.
#
# If TARGET is given, we try to parse it to determine TARGET_OS/TARGET_ARCH.
# Otherwise we rely on "uname" and "uname -m".
#
ifdef TARGET
# Parse TARGET
triplet := $(subst -, ,$(TARGET))
ifeq ($(BUILD_PREFIX),)
BUILD_PREFIX := $(TARGET)-
endif
ifndef TARGET_OS
ifneq ($(filter android%,$(triplet)),)
TARGET_OS := android
else ifneq ($(filter cygwin%,$(triplet)),)
TARGET_OS := cygwin
else ifneq ($(filter darwin%,$(triplet)),)
TARGET_OS := darwin
else ifneq ($(filter djgpp%,$(triplet)),)
TARGET_OS := dos
else ifneq ($(filter msdos%,$(triplet)),)
TARGET_OS := dos
else ifneq ($(filter freebsd%,$(triplet)),)
TARGET_OS := freebsd
else ifneq ($(filter dragonfly%,$(triplet)),)
TARGET_OS := dragonfly
else ifneq ($(filter linux%,$(triplet)),)
# GNU/Linux. arm-linux-androideabi is not.
TARGET_OS := linux
else ifneq ($(filter mingw%,$(triplet)),)
TARGET_OS := win32
else ifneq ($(filter netbsd%,$(triplet)),)
TARGET_OS := netbsd
else ifneq ($(filter openbsd%,$(triplet)),)
TARGET_OS := openbsd
else ifneq ($(filter solaris%,$(triplet)),)
TARGET_OS := solaris
else ifneq ($(filter xbox%,$(triplet)),)
TARGET_OS := xbox
endif
ifneq ($(filter emscripten%,$(triplet)),)
TARGET_OS := js
AS = llvm-as
AR = emar
CC = emcc
endif
endif
ifndef TARGET_ARCH
# arch = iif(has >= 2 words, first word, empty)
# 'i686 pc linux gnu' -> 'i686'
# 'mingw32' -> ''
TARGET_ARCH := $(if $(word 2,$(triplet)),$(firstword $(triplet)))
endif
else
# No TARGET given, so try to detect the native system with 'uname'
ifndef TARGET_OS
uname := $(shell uname)
ifneq ($(findstring CYGWIN,$(uname)),)
TARGET_OS := cygwin
else ifeq ($(uname),Darwin)
TARGET_OS := darwin
else ifeq ($(uname),FreeBSD)
TARGET_OS := freebsd
else ifeq ($(uname),DragonFly)
TARGET_OS := dragonfly
else ifeq ($(uname),Linux)
TARGET_OS := linux
else ifneq ($(findstring MINGW,$(uname)),)
TARGET_OS := win32
else ifneq ($(findstring MSYS_NT,$(uname)),)
TARGET_OS := win32
else ifeq ($(uname),MS-DOS)
TARGET_OS := dos
else ifeq ($(uname),NetBSD)
TARGET_OS := netbsd
else ifeq ($(uname),OpenBSD)
TARGET_OS := openbsd
else ifeq ($(uname),SunOS)
TARGET_OS := solaris
endif
endif
ifndef TARGET_ARCH
# For DJGPP, always use x86 (DJGPP's uname -m returns just "pc")
ifeq ($(TARGET_OS),dos)
TARGET_ARCH := x86
# For Solaris, always use x86_64
else ifeq ($(TARGET_OS),solaris)
TARGET_ARCH := x86_64
# For DragonFly, always use x86_64
else ifeq ($(TARGET_OS),dragonfly)
TARGET_ARCH := x86_64
# For MSYS2, use default compilers (uname -m returns MSYS2's shell
# architecture). For example, from win 7:
#
# host shell uname -s -m default gcc target
# ------ ------- -------------------- ------------------
# msys32 msys2 MSYS_NT-6.1-WOW i686 n/a
# msys32 mingw32 MINGW32_NT-6.1-WOW i686 i686-w64-mingw32
# msys32 mingw64 MINGW64_NT-6.1-WOW i686 x86_64-w64-mingw32
# msys64 msys2 MSYS_NT-6.1 x86_64 n/a
# msys64 mingw32 MINGW32_NT-6.1 x86_64 i686-w64-mingw32
# msys64 mingw64 MINGW64_NT-6.1 x86_64 x86_64-w64-mingw32
#
# on WinXP...
# host shell uname -s -m default gcc target
# ------ ------- -------------------- ------------------
# mingw cmd.exe MINGW32_NT-5.1 i686 mingw32
#
else ifneq ($(findstring MINGW32,$(uname)),)
# host is WinXP, then don't include DirectX 10 driver
ifneq ($(findstring NT-5,$(uname)),)
DISABLE_D3D10 := 1
endif
TARGET_ARCH := x86
else ifneq ($(findstring MINGW64,$(uname)),)
TARGET_ARCH := x86_64
# anything, trust 'uname -m', we have no other choice
else
TARGET_ARCH = $(shell uname -m)
endif
endif
endif
ifndef TARGET_OS
$(error couldn't identify TARGET_OS automatically)
endif
ifndef TARGET_ARCH
$(error couldn't identify TARGET_ARCH automatically)
endif
# Normalize TARGET_ARCH to x86
ifneq ($(filter 386 486 586 686 i386 i486 i586 i686,$(TARGET_ARCH)),)
TARGET_ARCH := x86
endif
# Normalize TARGET_ARCH to arm
ifneq ($(filter arm%,$(TARGET_ARCH)),)
TARGET_ARCH := arm
endif
# Normalize TARGET_ARCH to powerpc
ifneq ($(filter ppc powerpc,$(TARGET_ARCH)),)
TARGET_ARCH := powerpc
endif
# Normalize TARGET_ARCH to powerpc64
ifneq ($(filter ppc% powerpc%,$(TARGET_ARCH)),)
TARGET_ARCH := powerpc64
endif
# Normalize TARGET_ARCH to powerpc64le
ifneq ($(filter ppc%le powerpc%le,$(TARGET_ARCH)),)
TARGET_ARCH := powerpc64le
endif
# Normalize TARGET_ARCH to x86_64 (e.g., FreeBSD's uname -m returns "amd64"
# instead of "x86_64" like Linux)
ifneq ($(filter amd64 x86-64,$(TARGET_ARCH)),)
TARGET_ARCH := x86_64
endif
# Switch TARGET_ARCH depending on MULTILIB
ifeq ($(MULTILIB),32)
ifeq ($(TARGET_ARCH),x86_64)
TARGET_ARCH := x86
endif
else ifeq ($(MULTILIB),64)
ifeq ($(TARGET_ARCH),x86)
TARGET_ARCH := x86_64
endif
endif
ifeq ($(TARGET_OS),dos)
FBNAME := freebas$(ENABLE_SUFFIX)
FB_LDSCRIPT := i386go32.x
else
FBNAME := freebasic$(ENABLE_SUFFIX)
FB_LDSCRIPT := fbextra.x
endif
# ENABLE_PIC for every system where we need separate
# -fPIC versions of FB libs besides the normal ones
ifneq ($(filter android freebsd dragonfly freebsd linux netbsd openbsd solaris,$(TARGET_OS)),)
ENABLE_PIC := YesPlease
endif
ifneq ($(TARGET_OS),android)
# Everything is PIC on Android by default, so don't produce two sets of libraries
ENABLE_NONPIC := YesPlease
endif
# disable .ident directive on windows targets
# when present, identification strings are added to every object module and
# each .ident instance adds to the resulting executable even if the strings
# are identical
ifneq ($(filter win32 win64,$(TARGET_OS)),)
CFLAGS += -fno-ident
endif
ifneq ($(filter cygwin dos win32,$(TARGET_OS)),)
EXEEXT := .exe
INSTALL_PROGRAM := cp
INSTALL_FILE := cp
else
INSTALL_PROGRAM := install
INSTALL_FILE := install -m 644
endif
#
# Determine FB target name:
# dos, win32, win64, xbox, linux-x86, linux-x86_64, ...
#
# Some use a simple free-form name
ifeq ($(TARGET_OS),dos)
FBTARGET := dos
else ifeq ($(TARGET_OS),xbox)
FBTARGET := xbox
else ifeq ($(TARGET_OS),win32)
ifeq ($(TARGET_ARCH),x86_64)
FBTARGET := win64
else
FBTARGET := win32
endif
endif
# The rest uses the <os>-<cpufamily> format
ifndef FBTARGET
FBTARGET := $(TARGET_OS)-$(TARGET_ARCH)
endif
# In newer fbc release versions we have more variants of packages built
# for specific systems than was traditionally built for releases in the past.
# FBPACKTARGET will alter the package name for the release without altering
# the FBTARGET name used for sub directories and target identification
# elsewhere in the makefile. FBPACKTARGET allows us to build a package for a
# specific system with an alternate package name without having to repack the
# package for a different package name later.
#
ifndef FBPACKTARGET
FBPACKTARGET := $(FBTARGET)
endif
#
# Determine directory layout for .o files and final binaries.
#
ifeq ($(libsubdir),)
libsubdir := $(FBTARGET)
endif
ifeq ($(objsubdir),)
objsubdir := $(libsubdir)
endif
ifdef ENABLE_STANDALONE
# Traditional standalone layout: fbc.exe at toplevel, libs in lib/<fbtarget>/,
# includes in inc/
FBC_EXE := fbc$(EXEEXT)
FBCNEW_EXE := fbc-new$(EXEEXT)
libdir := lib/$(libsubdir)
PREFIX_FBC_EXE := $(prefix)/fbc$(EXEEXT)
prefixbindir := $(prefix)
prefixincdir := $(prefix)/inc
prefixlibdir := $(prefix)/$(libdir)
else
# With ENABLE_LIB64, put 64bit libs into
# lib64/freebasic/<fbtarget>/
# instead of the default
# lib/freebasic/<fbtarget>/
libdirname := lib
ifdef ENABLE_LIB64
ifneq ($(filter x86_64 aarch64,$(TARGET_ARCH)),)
libdirname := lib64
endif
endif
# Normal (non-standalone) setup: bin/fbc, include/freebasic/, lib[64]/freebasic/<fbtarget>/.
FBC_EXE := bin/fbc$(ENABLE_SUFFIX)$(EXEEXT)
FBCNEW_EXE := bin/fbc$(ENABLE_SUFFIX)-new$(EXEEXT)
libdir := $(libdirname)/$(FBNAME)/$(libsubdir)
PREFIX_FBC_EXE := $(prefix)/bin/fbc$(ENABLE_SUFFIX)$(EXEEXT)
prefixbindir := $(prefix)/bin
prefixincdir := $(prefix)/include/$(FBNAME)
prefixlibdir := $(prefix)/$(libdir)
endif
ifeq ($(fbcobjdir),)
fbcobjdir := src/compiler/obj/$(FBTARGET)
endif
libfbobjdir := src/rtlib/obj/$(objsubdir)
libfbpicobjdir := src/rtlib/obj/$(objsubdir)/pic
libfbmtobjdir := src/rtlib/obj/$(objsubdir)/mt
libfbmtpicobjdir := src/rtlib/obj/$(objsubdir)/mt/pic
libfbrtobjdir := src/fbrt/obj/$(objsubdir)
libfbrtpicobjdir := src/fbrt/obj/$(objsubdir)/pic
libfbrtmtobjdir := src/fbrt/obj/$(objsubdir)/mt
libfbrtmtpicobjdir := src/fbrt/obj/$(objsubdir)/mt/pic
libfbgfxobjdir := src/gfxlib2/obj/$(objsubdir)
libfbgfxpicobjdir := src/gfxlib2/obj/$(objsubdir)/pic
libfbgfxmtobjdir := src/gfxlib2/obj/$(objsubdir)/mt
libfbgfxmtpicobjdir := src/gfxlib2/obj/$(objsubdir)/mt/pic
djgpplibcobjdir := contrib/djgpp/libc/crt0/obj/$(objsubdir)
# If cross-compiling, use -target
ifdef TARGET
ALLFBCFLAGS += -target $(TARGET)
ALLFBLFLAGS += -target $(TARGET)
ALLFBRTCFLAGS += -target $(TARGET)
ALLFBRTLFLAGS += -target $(TARGET)
endif
ifdef MULTILIB
ALLFBCFLAGS += -arch $(MULTILIB)
ALLFBLFLAGS += -arch $(MULTILIB)
ALLFBRTCFLAGS += -arch $(MULTILIB)
ALLFBRTLFLAGS += -arch $(MULTILIB)
ifneq ($(TARGET_ARCH),arm)
ALLCFLAGS += -m$(MULTILIB)
endif
endif
ALLFBCFLAGS += -e -m fbc -w pedantic
ALLFBLFLAGS += -e -m fbc -w pedantic
ALLFBRTCFLAGS += -e -m nomain
ALLFBRTLFLAGS += -e -m nomain
ALLCFLAGS += -Wall -Wextra -Wno-unused-parameter -Werror-implicit-function-declaration
ifneq ($(filter bootstrap-minimal, $(MAKECMDGOALS)),)
# Disable features not needed to compile a minimal bootstrap fbc
ALLCFLAGS += -DDISABLE_GPM -DDISABLE_FFI -DDISABLE_X11
endif
ifeq ($(TARGET_OS),dos)
ALLCFLAGS += -DDISABLE_WCHAR -DDISABLE_FFI
endif
ifeq ($(TARGET_OS),android)
# These aren't available
# Android has very limited locale support in the NDK -- only the C locale is supported.
# Locale information is available from Java. The CrystaX alternative NDK has locale support.
ALLCFLAGS += -DDISABLE_NCURSES -DDISABLE_X11 -DDISABLE_FFI -DDISABLE_LANGINFO
endif
ifeq ($(TARGET_OS),xbox)
ifeq ($(OPENXDK),)
$(error Please set OPENXDK=<OpenXDK directory>)
endif
MINGWGCCLIBDIR := $(dir $(shell $(CC) -print-file-name=libgcc.a))
ALLCFLAGS += -ffreestanding -nostdinc -fno-exceptions -march=i386 \
-I$(OPENXDK)/i386-pc-xbox/include \
-I$(OPENXDK)/include \
-I$(MINGWGCCLIBDIR)/include
# src/rtlib/fb_config.h cannot auto-detect this
ALLCFLAGS += -DHOST_XBOX
# Assume no libffi for now (does it work on Xbox?)
ALLCFLAGS += -DDISABLE_FFI
# -DENABLE_MT parts of rtlib XBox code aren't finished
DISABLE_MT := YesPlease
endif
ifeq ($(TARGET_OS),netbsd)
ALLCFLAGS += -I/usr/X11R7/include \
-I/usr/pkg/include
endif
ifeq ($(TARGET_OS),solaris)
ALLCFLAGS += -I/usr/lib/amd64/libffi-3.2.1/include
endif
ifeq ($(TARGET_OS),darwin)
ALLCFLAGS += -I/opt/X11/include -I/usr/include/ffi
ifdef ENABLE_XQUARTZ
ALLFBCFLAGS += -d ENABLE_XQUARTZ
else
ALLCFLAGS += -DDISABLE_X11
endif
endif
ifneq ($(filter cygwin win32,$(TARGET_OS)),)
# Increase compiler's available stack size, it uses lots of recursion
ALLFBLFLAGS += -t 2048
endif
ifeq ($(TARGET_OS),js)
DISABLE_MT := YesPlease
endif
# Pass the configuration defines on to the compiler source code
ifdef ENABLE_STANDALONE
ALLFBCFLAGS += -d ENABLE_STANDALONE
endif
ifdef FBSHA1
ifeq ($(FBSHA1),1)
ALLFBCFLAGS += -d 'FBSHA1="$(shell git rev-parse HEAD)"'
BOOTFBCFLAGS += -d 'FBSHA1="$(shell git rev-parse HEAD)"'
else
ALLFBCFLAGS += -d 'FBSHA1="$(FBSHA1)"'
BOOTFBCFLAGS += -d 'FBSHA1="$(FBSHA1)"'
endif
endif
ifdef FBFORKID
ifneq ($(FBFORKID),)
ALLFBCFLAGS += -d 'FBFORKID=$(FBFORKID)'
BOOTFBCFLAGS += -d 'FBFORKID=$(FBFORKID)'
endif
endif
ifdef ENABLE_SUFFIX
ALLFBCFLAGS += -d 'ENABLE_SUFFIX="$(ENABLE_SUFFIX)"'
endif
ifdef ENABLE_PREFIX
ALLFBCFLAGS += -d 'ENABLE_PREFIX="$(prefix)"'
endif
ifdef ENABLE_LIB64
ALLFBCFLAGS += -d ENABLE_LIB64
endif
ifdef ENABLE_STRIPALL
ifneq ($(ENABLE_STRIPALL),0)
ALLFBCFLAGS += -d ENABLE_STRIPALL
endif
else
# by default dos and windows use --strip-all
ifneq ($(filter dos win32,$(TARGET_OS)),)
ALLFBCFLAGS += -d ENABLE_STRIPALL
endif
endif
ifdef DISABLE_GAS64_DEBUG
ALLFBCFLAGS += -d DISABLE_GAS64_DEBUG
endif
ifdef DEFAULT_CPUTYPE_X86
ALLFBCFLAGS += -d BUILD_FB_DEFAULT_CPUTYPE_X86=$(DEFAULT_CPUTYPE_X86)
BOOTFBCFLAGS += -d BUILD_FB_DEFAULT_CPUTYPE_X86=$(DEFAULT_CPUTYPE_X86)
endif
ifdef DEFAULT_CPUTYPE_ARM
ALLFBCFLAGS += -d BUILD_FB_DEFAULT_CPUTYPE_ARM=$(DEFAULT_CPUTYPE_ARM)
BOOTFBCFLAGS += -d BUILD_FB_DEFAULT_CPUTYPE_ARM=$(DEFAULT_CPUTYPE_ARM)
endif
ifdef DISABLE_STDCXX_PATH
ALLFBCFLAGS += -d DISABLE_STDCXX_PATH
endif
ALLFBCFLAGS += $(FBCFLAGS) $(FBFLAGS)
ALLFBLFLAGS += $(FBLFLAGS) $(FBFLAGS)
ALLFBRTCFLAGS += $(FBRTCFLAGS) $(FBFLAGS)
ALLFBRTLFLAGS += $(FBRTLFLAGS) $(FBFLAGS)
ALLCFLAGS += $(CFLAGS)
# compiler headers and modules
FBC_BI := $(wildcard $(srcdir)/compiler/*.bi)
FBC_BAS := $(sort $(wildcard $(srcdir)/compiler/*.bas))
FBC_BAS := $(patsubst $(srcdir)/compiler/%.bas,$(fbcobjdir)/%.o,$(FBC_BAS))
# rtlib/gfxlib2 headers and modules
RTLIB_DIRS := $(srcdir)/rtlib $(srcdir)/rtlib/$(TARGET_OS) $(srcdir)/rtlib/$(TARGET_ARCH)
ifeq ($(TARGET_OS),cygwin)
RTLIB_DIRS += $(srcdir)/rtlib/win32
endif
ifneq ($(filter android darwin freebsd dragonfly linux netbsd openbsd solaris,$(TARGET_OS)),)
RTLIB_DIRS += $(srcdir)/rtlib/unix
endif
GFXLIB2_DIRS := $(patsubst $(srcdir)/rtlib%,$(srcdir)/gfxlib2%,$(RTLIB_DIRS))
# fbrt headers and modules
FBRT_DIRS := $(srcdir)/fbrt $(srcdir)/fbrt/$(TARGET_OS) $(srcdir)/fbrt/$(TARGET_ARCH)
ifeq ($(TARGET_OS),cygwin)
FBRT_DIRS += $(srcdir)/fbrt/win32
endif
ifneq ($(filter darwin freebsd dragonfly linux netbsd openbsd solaris,$(TARGET_OS)),)
FBRT_DIRS += $(srcdir)/fbrt/unix
endif
LIBFB_H := $(sort $(foreach i,$(RTLIB_DIRS),$(wildcard $(i)/*.h)))
LIBFB_C := $(sort $(foreach i,$(RTLIB_DIRS),$(patsubst $(i)/%.c,$(libfbobjdir)/%.o,$(wildcard $(i)/*.c))))
LIBFB_S := $(sort $(foreach i,$(RTLIB_DIRS),$(patsubst $(i)/%.s,$(libfbobjdir)/%.o,$(wildcard $(i)/*.s))))
LIBFBPIC_C := $(patsubst $(libfbobjdir)/%,$(libfbpicobjdir)/%,$(LIBFB_C))
LIBFBPIC_S := $(patsubst $(libfbobjdir)/%,$(libfbpicobjdir)/%,$(LIBFB_S))
LIBFBMT_C := $(patsubst $(libfbobjdir)/%,$(libfbmtobjdir)/%,$(LIBFB_C))
LIBFBMT_S := $(patsubst $(libfbobjdir)/%,$(libfbmtobjdir)/%,$(LIBFB_S))
LIBFBMTPIC_C := $(patsubst $(libfbobjdir)/%,$(libfbmtpicobjdir)/%,$(LIBFB_C))
LIBFBMTPIC_S := $(patsubst $(libfbobjdir)/%,$(libfbmtpicobjdir)/%,$(LIBFB_S))
# LIBFBRT_BI - src/fbrt/*.bi - include files
# LIBFBRT_BAS - src/fbrt/obj/<target>/*.o files sourced from *.bas
# LIBFBRT_S - src/fbrt/obj/<target>/*.o files sourced from *.S
# LIBFBRT_C - src/rtlib/obj/<target>/*.o files not found in src/fbrt/obj/<target>/*.o
# LIBFBRTPIC_C - src/rtlib/obj/<target>/mt/*.o files not found in src/fbrt/obj/<target>/mt/*.o
# LIBFBRTMT_C - src/rtlib/obj/<target>/pic/*.o files not found in src/fbrt/obj/<target>/pic/*.o
# LIBFBRTMTPIC_C - src/rtlib/obj/<target>/mt/pic/*.o files not found in src/fbrt/obj/<target>/mt/pic/*.o
LIBFBRT_BI := $(sort $(foreach i,$(FBRT_DIRS),$(wildcard $(i)/*.bi)))
LIBFBRT_BAS := $(sort $(foreach i,$(FBRT_DIRS),$(patsubst $(i)/%.bas,$(libfbrtobjdir)/%.o,$(wildcard $(i)/*.bas))))
LIBFBRT_S := $(sort $(foreach i,$(FBRT_DIRS),$(patsubst $(i)/%.s,$(libfbrtobjdir)/%.o,$(wildcard $(i)/*.s))))
LIBFBRTPIC_BAS := $(patsubst $(libfbrtobjdir)/%,$(libfbrtpicobjdir)/%,$(LIBFBRT_BAS))
LIBFBRTMT_BAS := $(patsubst $(libfbrtobjdir)/%,$(libfbrtmtobjdir)/%,$(LIBFBRT_BAS))
LIBFBRTMT_S := $(patsubst $(libfbrtobjdir)/%,$(libfbrtmtobjdir)/%,$(LIBFBRT_S))
LIBFBRTMTPIC_BAS := $(patsubst $(libfbrtobjdir)/%,$(libfbrtmtpicobjdir)/%,$(LIBFBRT_BAS))
# Remove all .o files from rtlib list that can be derived from a .bas file rather than a .c file
LIBFBRT_C := $(patsubst %,$(libfbobjdir)/%,$(filter-out $(patsubst $(libfbrtobjdir)/%,%,$(LIBFBRT_BAS)), $(patsubst $(libfbobjdir)/%,%,$(LIBFB_C))))
LIBFBRTPIC_C := $(patsubst %,$(libfbpicobjdir)/%,$(filter-out $(patsubst $(libfbrtpicobjdir)/%,%,$(LIBFBRTPIC_BAS)), $(patsubst $(libfb[ocobjdir)/%,%,$(LIBFBPIC_C))))
LIBFBRTMT_C := $(patsubst %,$(libfbmtobjdir)/%,$(filter-out $(patsubst $(libfbrtmtobjdir)/%,%,$(LIBFBRTMT_BAS)), $(patsubst $(libfbmtobjdir)/%,%,$(LIBFBMT_C))))
LIBFBRTMTPIC_C := $(patsubst %,$(libfbmtpicobjdir)/%,$(filter-out $(patsubst $(libfbrtmtpicobjdir)/%,%,$(LIBFBRTMTPIC_BAS)), $(patsubst $(libfbmtpicobjdir)/%,%,$(LIBFBMTPIC_C))))
LIBFBGFX_H := $(sort $(foreach i,$(GFXLIB2_DIRS),$(wildcard $(i)/*.h)) $(LIBFB_H))
LIBFBGFX_C := $(sort $(foreach i,$(GFXLIB2_DIRS),$(patsubst $(i)/%.c,$(libfbgfxobjdir)/%.o,$(wildcard $(i)/*.c))))
LIBFBGFX_S := $(sort $(foreach i,$(GFXLIB2_DIRS),$(patsubst $(i)/%.s,$(libfbgfxobjdir)/%.o,$(wildcard $(i)/*.s))))
LIBFBGFXPIC_C := $(patsubst $(libfbgfxobjdir)/%,$(libfbgfxpicobjdir)/%,$(LIBFBGFX_C))
LIBFBGFXMT_C := $(patsubst $(libfbgfxobjdir)/%,$(libfbgfxmtobjdir)/%,$(LIBFBGFX_C))
LIBFBGFXMT_S := $(patsubst $(libfbgfxobjdir)/%,$(libfbgfxmtobjdir)/%,$(LIBFBGFX_S))
LIBFBGFXMTPIC_C := $(patsubst $(libfbgfxobjdir)/%,$(libfbgfxmtpicobjdir)/%,$(LIBFBGFX_C))
RTL_LIBS := $(libdir)/$(FB_LDSCRIPT)
ifdef ENABLE_NONPIC
RTL_LIBS += $(libdir)/fbrt0.o $(libdir)/fbrt1.o $(libdir)/fbrt2.o $(libdir)/libfb.a
FBRTL_LIBS += $(libdir)/libfbrt.a
GFX_LIBS += $(libdir)/libfbgfx.a
endif
ifdef ENABLE_PIC
RTL_LIBS += $(libdir)/fbrt0pic.o $(libdir)/fbrt1pic.o $(libdir)/fbrt2pic.o $(libdir)/libfbpic.a
FBRTL_LIBS += $(libdir)/libfbrtpic.a
GFX_LIBS += $(libdir)/libfbgfxpic.a
endif
ifndef DISABLE_MT
ifdef ENABLE_NONPIC
RTL_LIBS += $(libdir)/libfbmt.a
FBRTL_LIBS += $(libdir)/libfbrtmt.a
GFX_LIBS += $(libdir)/libfbgfxmt.a
endif
ifdef ENABLE_PIC
RTL_LIBS += $(libdir)/libfbmtpic.a
FBRTL_LIBS += $(libdir)/libfbrtmtpic.a
GFX_LIBS += $(libdir)/libfbgfxmtpic.a
endif
endif
ifeq ($(TARGET_OS),dos)
RTL_LIBS += $(libdir)/libc.a
endif
ifeq ($(TARGET_OS),js)
RTL_LIBS += $(libdir)/termlib_min.js
RTL_LIBS += $(libdir)/fb_rtlib.js
RTL_LIBS += $(libdir)/fb_shell.html
endif
#
# Build rules
#
VPATH = $(RTLIB_DIRS) $(FBRT_DIRS) $(GFXLIB2_DIRS)
# We don't want to use any of make's built-in suffixes/rules
.SUFFIXES:
ifndef V
QUIET_FBC = @echo "FBC $@";
QUIET_LINK = @echo "LINK $@";
QUIET_CC = @echo "CC $@";
QUIET_CPPAS = @echo "CPPAS $@";
QUIET_AS = @echo "AS $@";
QUIET_AR = @echo "AR $@";
QUIET = @
endif
# allow optionally including config-post
-include config-post.mk
################################################################################
.PHONY: all
all: compiler rtlib gfxlib2
$(fbcobjdir) \
$(libfbobjdir) \
$(libfbpicobjdir) \
$(libfbmtobjdir) \
$(libfbmtpicobjdir) \
$(libfbrtobjdir) \
$(libfbrtpicobjdir) \
$(libfbrtmtobjdir) \
$(libfbrtmtpicobjdir) \
$(libfbgfxobjdir) \
$(libfbgfxpicobjdir) \
$(libfbgfxmtobjdir) \
$(libfbgfxmtpicobjdir) \
$(djgpplibcobjdir) \
bin $(libdir):
mkdir -p $@
################################################################################
.PHONY: compiler
compiler: $(FBC_EXE)
$(FBC_EXE): $(FBC_BAS) | bin
$(QUIET_LINK)$(FBC) $(ALLFBLFLAGS) -x $(FBCNEW_EXE) $^
$(QUIET)mv $(FBCNEW_EXE) $@
$(FBC_BAS): $(fbcobjdir)/%.o: $(srcdir)/compiler/%.bas $(FBC_BI) | $(fbcobjdir)
$(QUIET_FBC)$(FBC) $(ALLFBCFLAGS) -c $< -o $@
################################################################################
.PHONY: rtlib
rtlib: $(RTL_LIBS)
$(libdir)/fbextra.x: $(rootdir)lib/fbextra.x | $(libdir)
cp $< $@
$(libdir)/i386go32.x: $(rootdir)contrib/djgpp/i386go32.x | $(libdir)
cp $< $@
$(libdir)/fbrt0.o: $(srcdir)/rtlib/static/fbrt0.c $(LIBFB_H) | $(libdir)
$(QUIET_CC)$(CC) $(ALLCFLAGS) -c $< -o $@
$(libdir)/fbrt0pic.o: $(srcdir)/rtlib/static/fbrt0.c $(LIBFB_H) | $(libdir)
$(QUIET_CC)$(CC) -fPIC $(ALLCFLAGS) -c $< -o $@
$(libdir)/fbrt1.o: $(srcdir)/rtlib/static/fbrt1.c $(LIBFB_H) | $(libdir)
$(QUIET_CC)$(CC) $(ALLCFLAGS) -c $< -o $@
$(libdir)/fbrt1pic.o: $(srcdir)/rtlib/static/fbrt1.c $(LIBFB_H) | $(libdir)
$(QUIET_CC)$(CC) -fPIC $(ALLCFLAGS) -c $< -o $@
$(libdir)/fbrt2.o: $(srcdir)/rtlib/static/fbrt2.c $(LIBFB_H) | $(libdir)
$(QUIET_CC)$(CC) $(ALLCFLAGS) -c $< -o $@
$(libdir)/fbrt2pic.o: $(srcdir)/rtlib/static/fbrt2.c $(LIBFB_H) | $(libdir)
$(QUIET_CC)$(CC) -fPIC $(ALLCFLAGS) -c $< -o $@
$(libdir)/libfb.a: $(LIBFB_C) $(LIBFB_S) | $(libdir)
$(libdir)/termlib_min.js: $(rootdir)lib/termlib_min.js | $(libdir)
cp $< $@
$(libdir)/fb_rtlib.js: $(rootdir)lib/fb_rtlib.js | $(libdir)
cp $< $@
$(libdir)/fb_shell.html: $(rootdir)lib/fb_shell.html | $(libdir)
cp $< $@
$(libdir)/libfb.a: $(LIBFB_C) $(LIBFB_S) | $(libdir)
ifeq ($(TARGET_OS),dos)
# Avoid hitting the command line length limit (the libfb.a ar command line
# is very long...)
$(QUIET)rm -f $@
$(QUIET_AR)$(AR) rcs $@ $(libfbobjdir)/*.o
else ifneq ($(findstring MSYS_NT,$(shell uname)),)
$(QUIET)rm -f $@
$(QUIET_AR)$(AR) rcs $@ $(libfbobjdir)/*.o
else
$(QUIET_AR)rm -f $@; $(AR) rcs $@ $^
endif
$(LIBFB_C): $(libfbobjdir)/%.o: %.c $(LIBFB_H) | $(libfbobjdir)
$(QUIET_CC)$(CC) $(ALLCFLAGS) -c $< -o $@
$(LIBFB_S): $(libfbobjdir)/%.o: %.s $(LIBFB_H) | $(libfbobjdir)
$(QUIET_CPPAS)$(CC) -x assembler-with-cpp $(ALLCFLAGS) -c $< -o $@
$(libdir)/libfbpic.a: $(LIBFBPIC_C) $(LIBFBPIC_S) | $(libdir)
$(QUIET_AR)rm -f $@; $(AR) rcs $@ $^
$(LIBFBPIC_C): $(libfbpicobjdir)/%.o: %.c $(LIBFB_H) | $(libfbpicobjdir)
$(QUIET_CC)$(CC) -fPIC $(ALLCFLAGS) -c $< -o $@
$(LIBFBPIC_S): $(libfbpicobjdir)/%.o: %.s $(LIBFB_H) | $(libfbpicobjdir)
$(QUIET_CPPAS)$(CC) -x assembler-with-cpp -DENABLE_PIC $(ALLCFLAGS) -c $< -o $@
$(libdir)/libfbmt.a: $(LIBFBMT_C) $(LIBFBMT_S) | $(libdir)
ifeq ($(TARGET_OS),dos)
# Avoid hitting the command line length limit (the libfb.a ar command line
# is very long...)
$(QUIET)rm -f $@
$(QUIET_AR)$(AR) rcs $@ $(libfbmtobjdir)/*.o
else ifneq ($(findstring MSYS_NT,$(shell uname)),)
$(QUIET)rm -f $@
$(QUIET_AR)$(AR) rcs $@ $(libfbmtobjdir)/*.o
else
$(QUIET_AR)rm -f $@; $(AR) rcs $@ $^
endif
$(LIBFBMT_C): $(libfbmtobjdir)/%.o: %.c $(LIBFB_H) | $(libfbmtobjdir)
$(QUIET_CC)$(CC) -DENABLE_MT $(ALLCFLAGS) -c $< -o $@
$(LIBFBMT_S): $(libfbmtobjdir)/%.o: %.s $(LIBFB_H) | $(libfbmtobjdir)
$(QUIET_CPPAS)$(CC) -x assembler-with-cpp -DENABLE_MT $(ALLCFLAGS) -c $< -o $@
$(libdir)/libfbmtpic.a: $(LIBFBMTPIC_C) $(LIBFBMTPIC_S) | $(libdir)
$(QUIET_AR)rm -f $@; $(AR) rcs $@ $^
$(LIBFBMTPIC_C): $(libfbmtpicobjdir)/%.o: %.c $(LIBFB_H) | $(libfbmtpicobjdir)
$(QUIET_CC)$(CC) -DENABLE_MT -fPIC $(ALLCFLAGS) -c $< -o $@
$(LIBFBMTPIC_S): $(libfbmtpicobjdir)/%.o: %.s $(LIBFB_H) | $(libfbmtpicobjdir)
$(QUIET_CPPAS)$(CC) -x assembler-with-cpp -DENABLE_MT -DENABLE_PIC $(ALLCFLAGS) -c $< -o $@
ifeq ($(TARGET_OS),dos)
djgpplibc := $(shell $(CC) -print-file-name=libc.a)
libcmaino := $(djgpplibcobjdir)/_main.o
$(libcmaino): $(rootdir)contrib/djgpp/libc/crt0/_main.c | $(djgpplibcobjdir)
$(QUIET_CC)$(CC) $(ALLCFLAGS) -c $< -o $@
$(libdir)/libc.a: $(djgpplibc) $(libcmaino) | $(libdir)
cp $(djgpplibc) $@
$(QUIET_AR)ar rs $@ $(libcmaino)
endif
################################################################################
# require that lbfb.a be built first
.PHONY: fbrt
fbrt: $(RTL_LIBS) $(FBRTL_LIBS)
$(libdir)/libfbrt.a: $(LIBFBRT_BAS) $(LIBFBRT_S) $(LIBFBRT_C) | $(libdir)
ifeq ($(TARGET_OS),dos)
# Avoid hitting the command line length limit (the libfbrt.a ar command line
# is very long...)
$(QUIET)rm -f $@
ifneq ($(LIBFBRT_C),)
$(QUIET)cp $(LIBFBRT_C) $(libfbrtobjdir)
endif
$(QUIET_AR)$(AR) rcs $@ $(libfbrtobjdir)/*.o
else ifneq ($(findstring MSYS_NT,$(shell uname)),)
$(QUIET)rm -f $@
ifneq ($(LIBFBRT_C),)
$(QUIET)cp $(LIBFBRT_C) $(libfbrtobjdir)
endif
$(QUIET_AR)$(AR) rcs $@ $(libfbrtobjdir)/*.o
else
ifneq ($(LIBFBRT_C),)
$(QUIET_AR)rm -f $@; cp $(LIBFBRT_C) $(libfbrtobjdir); $(AR) rcs $@ $^
else
$(QUIET_AR)rm -f $@; $(AR) rcs $@ $^
endif
endif
$(LIBFBRT_BAS): $(libfbrtobjdir)/%.o: %.bas $(LIBFBRT_BI) | $(libfbrtobjdir)
$(QUIET_FBC)$(FBC) $(ALLFBRTCFLAGS) -c $< -o $@
$(LIBFBRT_S): $(libfbrtobjdir)/%.o: %.s $(LIBFBRT_BI) | $(libfbrtobjdir)
$(QUIET_CPPAS)$(CC) -x assembler-with-cpp $(ALLCFLAGS) -c $< -o $@
$(libdir)/libfbrtpic.a: $(LIBFBRTPIC_BAS) $(LIBFBRTPIC_C) | $(libdir)
$(QUIET_AR)rm -f $@; $(LIBFBRTPIC_C) $(libfbrtpicobjdir); $(AR) rcs $@ $^
$(LIBFBRTPIC_BAS): $(libfbrtpicobjdir)/%.o: %.bas $(LIBFBRT_BI) | $(libfbrtpicobjdir)
$(QUIET_FBC)$(FBC) -pic $(ALLFBRTCFLAGS) -c $< -o $@
$(libdir)/libfbrtmt.a: $(LIBFBRTMT_BAS) $(LIBFBRTMT_C) $(LIBFBRTMT_S) | $(libdir)
ifeq ($(TARGET_OS),dos)
# Avoid hitting the command line length limit (the libfbrt.a ar command line
# is very long...)
$(QUIET)rm -f $@
ifneq ($(LIBFBRTMT_C),)
$(QUIET)cp $(LIBFBRTMT_C) $(libfbrtmtobjdir)
endif
$(QUIET_AR)$(AR) rcs $@ $(libfbrtmtobjdir)/*.o
else ifneq ($(findstring MSYS_NT,$(shell uname)),)
$(QUIET)rm -f $@
ifneq ($(LIBFBRTMT_C),)
$(QUIET)cp $(LIBFBRTMT_C) $(libfbrtmtobjdir)
endif
$(QUIET_AR)$(AR) rcs $@ $(libfbrtmtobjdir)/*.o
else
ifneq ($(LIBFBRTMT_C),)
$(QUIET_AR)rm -f $@; cp $(LIBFBRTMT_C) $(libfbrtmtobjdir); $(AR) rcs $@ $^
else
$(QUIET_AR)rm -f $@; $(AR) rcs $@ $^
endif
endif
$(LIBFBRTMT_BAS): $(libfbrtmtobjdir)/%.o: %.bas $(LIBFBRT_BI) | $(libfbrtmtobjdir)
$(QUIET_FBC)$(FBC) -mt -d ENABLE_MT $(ALLFBRTCFLAGS) -c $< -o $@
$(LIBFBRTMT_S): $(libfbrtmtobjdir)/%.o: %.s $(LIBFBRT_BI) | $(libfbrtmtobjdir)
$(QUIET_CPPAS)$(CC) -x assembler-with-cpp -DENABLE_MT $(ALLCFLAGS) -c $< -o $@
$(libdir)/libfbrtmtpic.a: $(LIBFBRTMTPIC_BAS) $(LIBFBRTMTPIC_C) | $(libdir)
$(QUIET_AR)rm -f $@; cp $(LIBFBRTMTPIC_C) $(libfbrtmtpicobjdir); $(AR) rcs $@ $^
$(LIBFBMTRTPIC_BAS): $(libfbrtmtpicobjdir)/%.o: %.c $(LIBFBRT_BI) | $(libfbrtmtpicobjdir)
$(QUIET_CC)$(FBC) -mt -pic $(ALLFBRTCFLAGS) -c $< -o $@
################################################################################
.PHONY: gfxlib2
gfxlib2: $(GFX_LIBS)
$(libdir)/libfbgfx.a: $(LIBFBGFX_C) $(LIBFBGFX_S) | $(libdir)
$(QUIET_AR)rm -f $@; $(AR) rcs $@ $^
$(LIBFBGFX_C): $(libfbgfxobjdir)/%.o: %.c $(LIBFBGFX_H) | $(libfbgfxobjdir)
$(QUIET_CC)$(CC) $(ALLCFLAGS) -c $< -o $@
$(LIBFBGFX_S): $(libfbgfxobjdir)/%.o: %.s $(LIBFBGFX_H) | $(libfbgfxobjdir)
$(QUIET_CPPAS)$(CC) -x assembler-with-cpp $(ALLCFLAGS) -c $< -o $@
$(libdir)/libfbgfxpic.a: $(LIBFBGFXPIC_C) | $(libdir)
$(QUIET_AR)rm -f $@; $(AR) rcs $@ $^
$(LIBFBGFXPIC_C): $(libfbgfxpicobjdir)/%.o: %.c $(LIBFBGFX_H) | $(libfbgfxpicobjdir)
$(QUIET_CC)$(CC) -fPIC $(ALLCFLAGS) -c $< -o $@
$(libdir)/libfbgfxmt.a: $(LIBFBGFXMT_C) $(LIBFBGFXMT_S) | $(libdir)
$(QUIET_AR)rm -f $@; $(AR) rcs $@ $^