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
|
# $NetBSD: gcc.mk,v 1.142 2013/07/09 10:13:43 jperkin Exp $
#
# This is the compiler definition for the GNU Compiler Collection.
#
# User-settable variables:
#
# GCCBASE
# If using a native GCC and the compiler is not in $PATH then
# this should be set to the base installation directory.
#
# USE_NATIVE_GCC
# When set to "yes", the native gcc is used, no matter which
# compiler version a package requires.
#
# USE_PKGSRC_GCC
# Force using the appropriate version of GCC from pkgsrc based on
# GCC_REQD instead of the native compiler.
#
# This should be disabled only for debugging.
#
# USE_PKGSRC_GCC_RUNTIME
# When set to "yes", the runtime gcc libraries (libgcc, libstdc++
# etc) will be used from pkgsrc rather than the native compiler.
#
# Package-settable variables:
#
# GCC_REQD
# The minimum version of the GNU Compiler Collection that is
# required to build this package. Setting this variable doesn't
# change the compiler that is used for building packages. See
# ONLY_FOR_COMPILER for that purpose. This is a list of version
# numbers, of which the maximum version is the definitive one.
#
# NOTE: Be conservative when setting GCC_REQD, as lang/gcc3 is
# known not to build on some platforms, e.g. Darwin. If gcc3 is
# required, set GCC_REQD=3.0 so that we do not try to pull in
# lang/gcc3 unnecessarily and have it fail.
#
# USE_GCC_RUNTIME
# Packages which build shared libraries but do not use libtool to
# do so should define this variable. It is used to determine whether
# the gcc runtime should be depended upon when a user has enabled
# USE_PKGSRC_GCC_RUNTIME.
#
# System-defined variables:
#
# CC_VERSION
# A string of the form "gcc-4.3.2"
#
# CC_VERSION_STRING
# The same(?) as CC_VERSION. FIXME: What's the difference between
# the two?
#
# Keywords: gcc
#
.if !defined(COMPILER_GCC_MK)
COMPILER_GCC_MK= defined
_VARGROUPS+= gcc
_USER_VARS.gcc= USE_NATIVE_GCC USE_PKGSRC_GCC
_PKG_VARS.gcc= GCC_REQD
_SYS_VARS.gcc= CC_VERSION CC_VERSION_STRING LANGUAGES.gcc
_DEF_VARS.gcc= \
CCPATH CPPPATH CXXPATH \
F77PATH FCPATH \
ADAPATH GMKPATH GLKPATH GDBPATH CHPPATH GLSPATH GNTPATH PRPPATH \
IMAKEOPTS \
LDFLAGS \
PKG_CC PKG_CPP PKG_CXX PKG_FC \
PKG_ADA PKG_GMK PKG_GLK PKG_GDB PKG_CHP PKG_GLK PKG_GNT PKG_PRP \
_CC _COMPILER_RPATH_FLAG _COMPILER_STRIP_VARS \
_GCCBINDIR _GCC_ARCHDIR _GCC_BIN_PREFIX _GCC_CC \
_GCC_CPP _GCC_CXX _GCC_DEPENDENCY _GCC_DEPENDS \
_GCC_FC _GCC_LDFLAGS _GCC_LIBDIRS _GCC_PKG \
_GCC_PKGBASE _GCC_PKGSRCDIR _GCC_PKG_SATISFIES_DEP \
_GCC_PREFIX _GCC_REQD _GCC_STRICTEST_REQD _GCC_SUBPREFIX \
_GCC_TEST_DEPENDS _GCC_NEEDS_A_FORTRAN _GCC_VARS _GCC_VERSION \
_GCC_VERSION_STRING \
_GCC_ADA _GCC_GMK _GCC_GLK _GCC_GDB _GCC_CHP _GCC_GLS _GCC_GNT _GCC_PRP \
_IGNORE_GCC _IGNORE_GCC3CXX _IGNORE_GCC3F77 _IGNORE_GCC3OBJC \
_IS_BUILTIN_GCC \
_LANGUAGES.gcc \
_LINKER_RPATH_FLAG \
_NEED_GCC2 _NEED_GCC3 _NEED_GCC34 _NEED_GCC44 _NEED_NEWER_GCC \
_PKGSRC_GCC_VERSION \
_USE_GCC_SHLIB _USE_PKGSRC_GCC \
_WRAP_EXTRA_ARGS.CC
.include "../../mk/bsd.prefs.mk"
USE_NATIVE_GCC?= no
USE_PKGSRC_GCC?= no
USE_PKGSRC_GCC_RUNTIME?=no
GCC_REQD+= 2.8.0
# gcc2 doesn't support c99 and amd64
.if !empty(USE_LANGUAGES:Mc99) || ${MACHINE_ARCH} == "x86_64"
GCC_REQD+= 3.0
.endif
# Only one compiler defined here supports Ada: lang/gcc-aux
# If the Ada language is requested, force lang/gcc-aux to be selected
.if !empty(USE_LANGUAGES:Mada)
GCC_REQD+= 20120614
.endif
# _GCC_DIST_VERSION is the highest version of GCC installed by the pkgsrc
# without the PKGREVISIONs.
_GCC_DIST_NAME:= gcc48
.include "../../lang/${_GCC_DIST_NAME}/version.mk"
_GCC_DIST_VERSION:= ${${_GCC_DIST_NAME:tu}_DIST_VERSION}
# _GCC2_PATTERNS matches N s.t. N <= 2.95.3.
_GCC2_PATTERNS= [0-1].* 2.[0-9] 2.[0-9].* 2.[1-8][0-9] 2.[1-8][0-9].* \
2.9[0-4] 2.9[0-4].* 2.95 2.95.[0-3]
# _GCC3_PATTERNS matches N s.t. 2.95.3 < N < 3.4.
_GCC3_PATTERNS= 2.95.[4-9]* 2.95.[1-9][0-9]* 2.9[6-9] 2.9[6-9].* \
2.[1-9][0-9][0-9]* 3.[0-3] 3.[0-3].*
# _GCC34_PATTERNS matches N s.t. 3.4 <= N < 4.
_GCC34_PATTERNS= 3.[4-9] 3.[4-9].* 3.[1-9][0-9]*
# _GCC44_PATTERNS matches N s.t. 4.4 <= N < 4.5.
_GCC44_PATTERNS= 4.4 4.4.*
# _GCC45_PATTERNS matches N s.t. 4.5 <= N < 4.6.
_GCC45_PATTERNS= 4.5 4.5.*
# _GCC46_PATTERNS matches N s.t. 4.6 <= N < 4.7.
_GCC46_PATTERNS= 4.6 4.6.*
# _GCC47_PATTERNS matches N s.t. 4.7 <= N < 4.8.
_GCC47_PATTERNS= 4.7 4.7.*
# _GCC48_PATTERNS matches N s.t. 4.8 <= N.
_GCC48_PATTERNS= 4.[8-9] 4.[8-9].* 4.[1-9][0-9]* [5-9]*
# _GCC_AUX_PATTERNS matches 8-digit date YYYYMMDD*
_GCC_AUX_PATTERNS= 20[1-2][0-9][0-1][0-9][0-3][0-9]*
# _CC is the full path to the compiler named by ${CC} if it can be found.
.if !defined(_CC)
_CC:= ${CC:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//}
. if !empty(GCCBASE) && exists(${GCCBASE}/bin)
_EXTRA_CC_DIRS= ${GCCBASE}/bin
. endif
. for _dir_ in ${_EXTRA_CC_DIRS} ${PATH:C/\:/ /g}
. if empty(_CC:M/*)
. if exists(${_dir_}/${CC:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//})
_CC:= ${_dir_}/${CC:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//}
. endif
. endif
. endfor
MAKEFLAGS+= _CC=${_CC:Q}
.endif
.if !defined(_GCC_VERSION)
#
# FIXME: Ideally we'd use PKGSRC_SETENV here, but not enough of the tools
# infrastructure is loaded for SETENV to be defined when mk/compiler.mk is
# included first. LC_ALL is required here for similar reasons, as ALL_ENV
# is not defined at this stage.
#
_GCC_VERSION_STRING!= \
( env LC_ALL=C ${_CC} -v 2>&1 | ${GREP} 'gcc version') 2>/dev/null || ${ECHO} 0
. if !empty(_GCC_VERSION_STRING:Megcs*)
_GCC_VERSION= 2.8.1 # egcs is considered to be gcc-2.8.1.
. elif !empty(DRAGONFLY_CCVER) && ${OPSYS} == "DragonFly"
_GCC_VERSION!= env CCVER=${DRAGONFLY_CCVER} ${_CC} -dumpversion
. elif !empty(_GCC_VERSION_STRING:Mgcc*)
_GCC_VERSION!= ${_CC} -dumpversion
. else
_GCC_VERSION= 0
. endif
.endif
_GCC_PKG= gcc-${_GCC_VERSION:C/-.*$//}
.if !empty(_CC:M${LOCALBASE}/*)
_IS_BUILTIN_GCC= NO
GCC_REQD+= ${_GCC_VERSION}
.else
. if !empty(_CC:M/*)
#
# GCC in older versions of Darwin report "Apple Computer ... based on gcc
# version ...", so we can't just grep for "^gcc".
#
. if ${_GCC_VERSION} != "0"
_IS_BUILTIN_GCC= YES
. else
_IS_BUILTIN_GCC= NO
. endif
. else
_IS_BUILTIN_GCC= NO
. endif
.endif
# Distill the GCC_REQD list into a single _GCC_REQD value that is the
# highest version of GCC required.
#
_GCC_STRICTEST_REQD?= none
.for _version_ in ${GCC_REQD}
. for _pkg_ in gcc-${_version_}
. if ${_GCC_STRICTEST_REQD} == "none"
_GCC_PKG_SATISFIES_DEP= YES
. for _vers_ in ${GCC_REQD}
. if !empty(_GCC_PKG_SATISFIES_DEP:M[yY][eE][sS])
_GCC_PKG_SATISFIES_DEP!= \
if ${PKG_ADMIN} pmatch 'gcc>=${_vers_}' ${_pkg_} 2>/dev/null; then \
${ECHO} "YES"; \
else \
${ECHO} "NO"; \
fi
. endif
. endfor
. if !empty(_GCC_PKG_SATISFIES_DEP:M[yY][eE][sS])
_GCC_STRICTEST_REQD= ${_version_}
. endif
. endif
. endfor
.endfor
_GCC_REQD= ${_GCC_STRICTEST_REQD}
# Determine whether we require GCC-2.x or GCC-3.x by examining _GCC_REQD.
_NEED_GCC2?= no
.for _pattern_ in ${_GCC2_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC2= yes
. endif
.endfor
_NEED_GCC3?= no
.for _pattern_ in ${_GCC3_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC3= yes
. endif
.endfor
_NEED_GCC34?= no
.for _pattern_ in ${_GCC34_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC34= yes
. endif
.endfor
_NEED_GCC44?= no
.for _pattern_ in ${_GCC44_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC44= yes
. endif
.endfor
_NEED_GCC45?= no
.for _pattern_ in ${_GCC45_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC45= yes
. endif
.endfor
_NEED_GCC46?= no
.for _pattern_ in ${_GCC46_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC46= yes
. endif
.endfor
_NEED_GCC47?= no
.for _pattern_ in ${_GCC47_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC47= yes
. endif
.endfor
_NEED_GCC48?= no
.for _pattern_ in ${_GCC48_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC48= yes
. endif
.endfor
_NEED_GCC_AUX?= no
.for _pattern_ in ${_GCC_AUX_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC_AUX= yes
_NEED_NEWER_GCC=NO
. endif
.endfor
.if !empty(_NEED_GCC2:M[nN][oO]) && !empty(_NEED_GCC3:M[nN][oO]) && \
!empty(_NEED_GCC34:M[nN][oO]) && !empty(_NEED_GCC44:M[nN][oO]) && \
!empty(_NEED_GCC45:M[nN][oO]) && !empty(_NEED_GCC46:M[nN][oO]) && \
!empty(_NEED_GCC47:M[nN][oO]) && !empty(_NEED_GCC48:M[nN][oO]) && \
!empty(_NEED_GCC_AUX:M[nN][oO])
_NEED_GCC48= yes
.endif
# Assume by default that GCC will only provide a C compiler.
LANGUAGES.gcc?= c
.if !empty(_NEED_GCC2:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran77 objc
.elif !empty(_NEED_GCC3:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran77 java objc
.elif !empty(_NEED_GCC34:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran77 objc
.elif !empty(_NEED_GCC44:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran fortran77 java objc
.elif !empty(_NEED_GCC45:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran fortran77 java objc
.elif !empty(_NEED_GCC46:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran fortran77 java objc
.elif !empty(_NEED_GCC47:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++
.elif !empty(_NEED_GCC48:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++
.elif !empty(_NEED_GCC_AUX:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran fortran77 objc ada
.endif
_LANGUAGES.gcc= # empty
.for _lang_ in ${USE_LANGUAGES}
_LANGUAGES.gcc+= ${LANGUAGES.gcc:M${_lang_}}
.endfor
.if !empty(USE_LANGUAGES:Mc99)
_WRAP_EXTRA_ARGS.CC+= -std=gnu99
.endif
# GCC has this annoying behaviour where it advocates in a multi-line
# banner the use of "#include" over "#import" when including headers.
# This generates a huge number of warnings when building practically all
# Objective-C code where it is convention to use "#import". Suppress
# the warning if we're building Objective-C code using GCC.
#
.if !empty(_LANGUAGES.gcc:Mobjc)
CFLAGS+= -Wno-import
.endif
.if !empty(_NEED_GCC2:M[yY][eE][sS])
#
# We require gcc-2.x in the lang/gcc directory.
#
_GCC_PKGBASE= gcc
. if !empty(PKGPATH:Mlang/gcc)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
_GCC_PKGSRCDIR= ../../lang/gcc
_GCC_DEPENDENCY= gcc>=${_GCC_REQD}:../../lang/gcc
. if !empty(_LANGUAGES.gcc:Mc++) || \
!empty(_LANGUAGES.gcc:Mfortran77) || \
!empty(_LANGUAGES.gcc:Mobjc)
_USE_GCC_SHLIB?= yes
. endif
. endif
.elif !empty(_NEED_GCC3:M[yY][eE][sS])
#
# We require gcc-3.x in the lang/gcc3-* directories.
#
_GCC_PKGBASE= gcc3-c
. if !empty(PKGPATH:Mlang/gcc3-c)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc:Mc)
_GCC_PKGSRCDIR= ../../lang/gcc3-c
_GCC_DEPENDENCY= gcc3-c>=${_GCC_REQD}:../../lang/gcc3-c
. endif
.elif !empty(_NEED_GCC34:M[yY][eE][sS])
#
# We require gcc-3.4.x in the lang/gcc34 directory.
#
_GCC_PKGBASE= gcc34
. if !empty(PKGPATH:Mlang/gcc34)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
_GCC_PKGSRCDIR= ../../lang/gcc34
_GCC_DEPENDENCY= gcc34>=${_GCC_REQD}:../../lang/gcc34
. if !empty(_LANGUAGES.gcc:Mc++) || \
!empty(_LANGUAGES.gcc:Mfortran77) || \
!empty(_LANGUAGES.gcc:Mobjc)
_USE_GCC_SHLIB?= yes
. endif
. endif
.elif !empty(_NEED_GCC44:M[yY][eE][sS])
#
# We require gcc-4.4.x in the lang/gcc44 directory.
#
_GCC_PKGBASE= gcc44
. if !empty(PKGPATH:Mlang/gcc44)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
_GCC_PKGSRCDIR= ../../lang/gcc44
_GCC_DEPENDENCY= gcc44>=${_GCC_REQD}:../../lang/gcc44
. if !empty(_LANGUAGES.gcc:Mc++) || \
!empty(_LANGUAGES.gcc:Mfortran) || \
!empty(_LANGUAGES.gcc:Mfortran77) || \
!empty(_LANGUAGES.gcc:Mobjc)
_USE_GCC_SHLIB?= yes
. endif
. endif
.elif !empty(_NEED_GCC45:M[yY][eE][sS])
#
# We require gcc-4.5.x in the lang/gcc45 directory.
#
_GCC_PKGBASE= gcc45
. if !empty(PKGPATH:Mlang/gcc45)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
_GCC_PKGSRCDIR= ../../lang/gcc45
_GCC_DEPENDENCY= gcc45>=${_GCC_REQD}:../../lang/gcc45
. if !empty(_LANGUAGES.gcc:Mc++) || \
!empty(_LANGUAGES.gcc:Mfortran) || \
!empty(_LANGUAGES.gcc:Mfortran77) || \
!empty(_LANGUAGES.gcc:Mobjc)
_USE_GCC_SHLIB?= yes
. endif
. endif
.elif !empty(_NEED_GCC46:M[yY][eE][sS])
#
# We require gcc-4.6.x in the lang/gcc46 directory.
#
_GCC_PKGBASE= gcc46
. if !empty(PKGPATH:Mlang/gcc46)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
_GCC_PKGSRCDIR= ../../lang/gcc46
_GCC_DEPENDENCY= gcc46>=${_GCC_REQD}:../../lang/gcc46
. if !empty(_LANGUAGES.gcc:Mc++) || \
!empty(_LANGUAGES.gcc:Mfortran) || \
!empty(_LANGUAGES.gcc:Mfortran77) || \
!empty(_LANGUAGES.gcc:Mobjc)
_USE_GCC_SHLIB?= yes
. endif
. endif
.elif !empty(_NEED_GCC47:M[yY][eE][sS])
#
# We require gcc-4.7.x in the lang/gcc47 directory.
#
_GCC_PKGBASE= gcc47
. if !empty(PKGPATH:Mlang/gcc47)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
_GCC_PKGSRCDIR= ../../lang/gcc47
_GCC_DEPENDENCY= gcc47>=${_GCC_REQD}:../../lang/gcc47
. if !empty(_LANGUAGES.gcc:Mc++) || \
!empty(_LANGUAGES.gcc:Mfortran) || \
!empty(_LANGUAGES.gcc:Mfortran77) || \
!empty(_LANGUAGES.gcc:Mgo) || \
!empty(_LANGUAGES.gcc:Mobjc) || \
!empty(_LANGUAGES.gcc:Mobj-c++)
_USE_GCC_SHLIB?= yes
. endif
. endif
.elif !empty(_NEED_GCC48:M[yY][eE][sS])
#
# We require gcc-4.8.x in the lang/gcc48 directory.
#
_GCC_PKGBASE= gcc48
. if !empty(PKGPATH:Mlang/gcc48)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
_GCC_PKGSRCDIR= ../../lang/gcc48
_GCC_DEPENDENCY= gcc48>=${_GCC_REQD}:../../lang/gcc48
. if !empty(_LANGUAGES.gcc:Mc++) || \
!empty(_LANGUAGES.gcc:Mfortran) || \
!empty(_LANGUAGES.gcc:Mfortran77) || \
!empty(_LANGUAGES.gcc:Mgo) || \
!empty(_LANGUAGES.gcc:Mobjc) || \
!empty(_LANGUAGES.gcc:Mobj-c++)
_USE_GCC_SHLIB?= yes
. endif
. endif
.elif !empty(_NEED_GCC_AUX:M[yY][eE][sS])
#
# We require Ada-capable compiler in the lang/gcc-aux directory.
#
_GCC_PKGBASE= gcc-aux
. if !empty(PKGPATH:Mlang/gcc-aux)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
_GCC_PKGSRCDIR= ../../lang/gcc-aux
_GCC_DEPENDENCY= gcc-aux>=${_GCC_REQD}:../../lang/gcc-aux
. if !empty(_LANGUAGES.gcc:Mc++) || \
!empty(_LANGUAGES.gcc:Mfortran) || \
!empty(_LANGUAGES.gcc:Mfortran77) || \
!empty(_LANGUAGES.gcc:Mada) || \
!empty(_LANGUAGES.gcc:Mobjc)
_USE_GCC_SHLIB?= yes
. endif
. endif
.endif
_GCC_DEPENDS= ${_GCC_PKGBASE}>=${_GCC_REQD}
.if !empty(_NEED_GCC3:M[yY][eE][sS])
. if !empty(PKGPATH:Mlang/gcc3-c++)
_IGNORE_GCC3CXX= yes
MAKEFLAGS+= _IGNORE_GCC3CXX=yes
. endif
. if !defined(_IGNORE_GCC3CXX) && !empty(_LANGUAGES.gcc:Mc++)
_GCC_PKGSRCDIR+= ../../lang/gcc3-c++
_GCC_DEPENDENCY+= gcc3-c++>=${_GCC_REQD}:../../lang/gcc3-c++
_USE_GCC_SHLIB?= yes
. endif
. if !empty(PKGPATH:Mlang/gcc3-f77)
_IGNORE_GCC3F77= yes
MAKEFLAGS+= _IGNORE_GCC3F77=yes
. endif
. if !defined(_IGNORE_GCC3F77) && !empty(_LANGUAGES.gcc:Mfortran77)
_GCC_PKGSRCDIR+= ../../lang/gcc3-f77
_GCC_DEPENDENCY+= gcc3-f77>=${_GCC_REQD}:../../lang/gcc3-f77
_USE_GCC_SHLIB?= yes
. endif
. if !empty(PKGPATH:Mlang/gcc3-objc)
_IGNORE_GCC3OBJC= yes
MAKEFLAGS+= _IGNORE_GCC3OBJC=yes
. endif
. if !defined(_IGNORE_GCC3OBJC) && !empty(_LANGUAGES.gcc:Mobjc)
_GCC_PKGSRCDIR+= ../../lang/gcc3-objc
_GCC_DEPENDENCY+= gcc3-objc>=${_GCC_REQD}:../../lang/gcc3-objc
_USE_GCC_SHLIB?= yes
. endif
.endif
# When not using the GNU linker, gcc will always link shared libraries against
# the shared version of libgcc, and so _USE_GCC_SHLIB needs to be enabled on
# platforms with non-GNU linkers, such as SunOS.
#
# However, we cannot simply do this by default as it will create circular
# dependencies in packages which are required to build gcc itself, and so we
# enable it based on USE_LIBTOOL for the majority of packages, and support
# USE_GCC_RUNTIME for packages which create shared libraries but do not use
# libtool to do so.
#
.if ${OPSYS} == "SunOS" && (defined(USE_LIBTOOL) || defined(USE_GCC_RUNTIME))
_USE_GCC_SHLIB= yes
.endif
.if !empty(USE_NATIVE_GCC:M[yY][eE][sS]) && !empty(_IS_BUILTIN_GCC:M[yY][eE][sS])
_USE_PKGSRC_GCC= no
.elif !empty(USE_PKGSRC_GCC:M[yY][eE][sS])
# For environments where there is an external gcc too, but pkgsrc
# should use the pkgsrc one for consistency.
_USE_PKGSRC_GCC= yes
.endif
.if defined(_IGNORE_GCC)
_USE_PKGSRC_GCC= NO
.endif
.if !defined(_USE_PKGSRC_GCC)
_USE_PKGSRC_GCC= YES
. if !empty(_IS_BUILTIN_GCC:M[yY][eE][sS])
_GCC_TEST_DEPENDS= gcc>=${_GCC_REQD}
_USE_PKGSRC_GCC!= \
if ${PKG_ADMIN} pmatch '${_GCC_TEST_DEPENDS}' ${_GCC_PKG} 2>/dev/null; then \
${ECHO} "NO"; \
else \
${ECHO} "YES"; \
fi
. endif
.endif
# Check if any of the versions of GCC in pkgsrc can satisfy the _GCC_REQD
# requirement.
#
.if !defined(_NEED_NEWER_GCC)
_PKGSRC_GCC_VERSION= ${_GCC_PKGBASE}-${_GCC_DIST_VERSION}
_NEED_NEWER_GCC!= \
if ${PKG_ADMIN} pmatch '${_GCC_DEPENDS}' ${_PKGSRC_GCC_VERSION} 2>/dev/null; then \
${ECHO} "NO"; \
else \
${ECHO} "YES"; \
fi
#MAKEFLAGS+= _NEED_NEWER_GCC=${_NEED_NEWER_GCC}
.endif
.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS]) && \
!empty(_NEED_NEWER_GCC:M[yY][eE][sS])
PKG_FAIL_REASON= "Unable to satisfy dependency: ${_GCC_DEPENDS}"
.endif
# GNU ld option used to set the rpath
_LINKER_RPATH_FLAG= -R
# GCC passes rpath directives to the linker using "-Wl,-R".
_COMPILER_RPATH_FLAG= -Wl,${_LINKER_RPATH_FLAG}
.if !empty(MACHINE_ARCH:Mmips*)
_COMPILER_ABI_FLAG.32= -mabi=n32 # ABI == "32" == "n32"
_COMPILER_ABI_FLAG.n32= -mabi=n32
_COMPILER_ABI_FLAG.o32= -mabi=32
_COMPILER_ABI_FLAG.64= -mabi=64
. if defined(ABI) && !empty(ABI)
MABIFLAG= ${_COMPILER_ABI_FLAG.${ABI}}
. endif
.endif
.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS])
#
# Ensure that the correct rpath is passed to the linker if we need to
# link against gcc shared libs.
#
_GCC_SUBPREFIX!= \
if ${PKG_INFO} -qe ${_GCC_PKGBASE}; then \
${PKG_INFO} -f ${_GCC_PKGBASE} | \
${GREP} "File:.*bin/gcc" | \
${GREP} -v "/gcc[0-9][0-9]*-.*" | \
${SED} -e "s/.*File: *//;s/bin\/gcc.*//;q"; \
else \
case ${_CC} in \
${LOCALBASE}/*) \
subprefix="${_CC:H:S/\/bin$//:S/${LOCALBASE}\///:S/${LOCALBASE}//}"; \
case "$${subprefix}" in \
"") ${ECHO} "$${subprefix}" ;; \
*) ${ECHO} "$${subprefix}/" ;; \
esac; \
;; \
*) \
${ECHO} "_GCC_SUBPREFIX_not_found/"; \
;; \
esac; \
fi
_GCC_PREFIX= ${LOCALBASE}/${_GCC_SUBPREFIX}
_GCC_ARCHDIR!= \
if [ -x ${_GCC_PREFIX}bin/gcc ]; then \
${DIRNAME} `${_GCC_PREFIX}bin/gcc ${MABIFLAG} -print-libgcc-file-name 2>/dev/null`; \
else \
${ECHO} "_GCC_ARCHDIR_not_found"; \
fi
. if empty(_GCC_ARCHDIR:M*not_found*)
. if defined(MABIFLAG) && !empty(MABIFLAG)
_GCC_PREFIX:= ${_GCC_ARCHDIR:H:H:H:H:H}/
_GCC_SUBPREFIX:= ${_GCC_ARCHDIR:H:H:H:H:H:T}/
. else
_GCC_PREFIX:= ${_GCC_ARCHDIR:H:H:H:H}/
_GCC_SUBPREFIX:= ${_GCC_ARCHDIR:H:H:H:H:T}/
. endif
. endif
_GCC_LIBDIRS= ${_GCC_ARCHDIR} ${_GCC_PREFIX}lib
_GCC_LDFLAGS= # empty
. for _dir_ in ${_GCC_LIBDIRS:N*not_found*}
_GCC_LDFLAGS+= -L${_dir_} ${COMPILER_RPATH_FLAG}${_dir_}
. endfor
LDFLAGS+= ${_GCC_LDFLAGS}
.endif
# Point the variables that specify the compiler to the installed
# GCC executables.
#
_GCC_DIR= ${WRKDIR}/.gcc
_GCC_VARS= # empty
.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS])
_GCCBINDIR= ${_GCC_PREFIX}bin
.elif !empty(_IS_BUILTIN_GCC:M[yY][eE][sS])
_GCCBINDIR= ${_CC:H}
.endif
.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
_GCC_BIN_PREFIX= ${MACHINE_GNU_PLATFORM}-
.endif
.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}gcc)
_GCC_VARS+= CC
_GCC_CC= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gcc
_ALIASES.CC= cc gcc
CCPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gcc
PKG_CC:= ${_GCC_CC}
.endif
.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}cpp)
_GCC_VARS+= CPP
_GCC_CPP= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}cpp
_ALIASES.CPP= cpp
CPPPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}cpp
PKG_CPP:= ${_GCC_CPP}
.endif
.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}g++)
_GCC_VARS+= CXX
_GCC_CXX= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}g++
_ALIASES.CXX= c++ g++
CXXPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}g++
PKG_CXX:= ${_GCC_CXX}
.endif
.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}g77)
_GCC_VARS+= FC
_GCC_FC= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}g77
_ALIASES.FC= f77 g77
FCPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}g77
F77PATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}g77
PKG_FC:= ${_GCC_FC}
PKGSRC_FORTRAN?= g77
.endif
.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}gfortran)
_GCC_VARS+= FC
_GCC_FC= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gfortran
_ALIASES.FC= gfortran
FCPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gfortran
F77PATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gfortran
PKG_FC:= ${_GCC_FC}
PKGSRC_FORTRAN?= gfortran
.endif
.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}ada)
_GCC_VARS+= ADA GMK GLK GBD CHP PRP GLS GNT
_GCC_ADA= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}ada
_GCC_GMK= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatmake
_GCC_GLK= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatlink
_GCC_GBD= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatbind
_GCC_CHP= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatchop
_GCC_PRP= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatprep
_GCC_GLS= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatls
_GCC_GNT= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnat
_ALIASES.ADA= ada
_ALIASES.GMK= gnatmake
_ALIASES.GLK= gnatlink
_ALIASES.GBD= gnatbind
_ALIASES.CHP= gnatchop
_ALIASES.PRP= gnatprep
_ALIASES.GLS= gnatls
_ALIASES.GNT= gnat
ADAPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}ada
GMKPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatmake
GLKPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatlink
GBDPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatbind
CHPPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatchop
PRPPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatprep
GLSPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatls
GNTPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnat
PKG_ADA:= ${_GCC_ADA}
PKG_GMK:= ${_GCC_GMK}
PKG_GLK:= ${_GCC_GLK}
PKG_GBD:= ${_GCC_GBD}
PKG_CHP:= ${_GCC_CHP}
PKG_PRP:= ${_GCC_PRP}
PKG_GLS:= ${_GCC_GLS}
PKG_GNT:= ${_GCC_GNT}
PKGSRC_ADA?= ada
PKGSRC_GMK?= gnatmake
PKGSRC_GLK?= gnatlink
PKGSRC_GBD?= gnatbind
PKGSRC_CHP?= gnatchop
PKGSRC_PRP?= gnatprep
PKGSRC_GLS?= gnatls
PKGSRC_GNT?= gnat
.endif
_COMPILER_STRIP_VARS+= ${_GCC_VARS}
# Pass the required flags to imake to tell it we're using gcc on Solaris.
.if ${OPSYS} == "SunOS"
IMAKEOPTS+= -DHasGcc2=YES -DHasGcc2ForCplusplus=YES
.endif
.if ${OPSYS} == "Darwin" || ${OPSYS} == "Linux" || ${OPSYS} == "SunOS"
_COMPILER_ABI_FLAG.32= -m32
_COMPILER_ABI_FLAG.64= -m64
.endif
.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS])
. if exists(${CCPATH})
CC_VERSION_STRING!= ${CCPATH} -v 2>&1
CC_VERSION!= \
if ${CCPATH} -dumpversion > /dev/null 2>&1; then \
${ECHO} "gcc-`${CCPATH} -dumpversion`"; \
else \
${ECHO} "gcc-${_GCC_REQD}"; \
fi
. else
CC_VERSION_STRING= ${CC_VERSION}
CC_VERSION= gcc-${_GCC_REQD}
. endif
.else
CC_VERSION_STRING= ${CC_VERSION}
CC_VERSION= ${_GCC_PKG}
.endif
# Prepend the path to the compiler to the PATH.
.if !empty(_LANGUAGES.gcc)
PREPEND_PATH+= ${_GCC_DIR}/bin
.endif
# Add the dependency on GCC.
.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS])
. for _dir_ in ${_GCC_PKGSRCDIR}
. include "${_dir_}/buildlink3.mk"
. endfor
.endif
# Add dependency on GCC libraries if requested.
.if (defined(_USE_GCC_SHLIB) && !empty(_USE_GCC_SHLIB:M[Yy][Ee][Ss])) && !empty(USE_PKGSRC_GCC_RUNTIME:M[Yy][Ee][Ss])
# Special case packages which are themselves a dependency of gcc runtime.
. if empty(PKGPATH:Mdevel/libtool-base) && empty(PKGPATH:Mdevel/binutils) && empty(PKGPATH:Mlang/gcc??)
. if !empty(CC_VERSION:Mgcc-4.7*)
. include "../../lang/gcc47-libs/buildlink3.mk"
. elif !empty(CC_VERSION:Mgcc-4.8*)
. include "../../lang/gcc48-libs/buildlink3.mk"
. else
PKG_FAIL_REASON= "No USE_PKGSRC_GCC_RUNTIME support for ${CC_VERSION}"
. endif
. endif
.endif
.for _var_ in ${_GCC_VARS}
. if !target(${_GCC_${_var_}})
override-tools: ${_GCC_${_var_}}
${_GCC_${_var_}}:
${RUN}${MKDIR} ${.TARGET:H}
. if !empty(COMPILER_USE_SYMLINKS:M[Yy][Ee][Ss])
${RUN}${RM} -f ${.TARGET}
${RUN}${LN} -s ${_GCCBINDIR}/${.TARGET:T} ${.TARGET}
. else
${RUN} \
(${ECHO} '#!${TOOLS_SHELL}'; \
${ECHO} 'exec ${_GCCBINDIR}/${.TARGET:T} "$$@"'; \
) > ${.TARGET}
${RUN}${CHMOD} +x ${.TARGET}
. endif
. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//}
${RUN} \
if [ ! -x "${_alias_}" ]; then \
${LN} -f -s ${.TARGET:T} ${_alias_}; \
fi
. endfor
. endif
.endfor
# On systems without a Fortran compiler, pull one in if needed.
# The default is g95 as it supports a modern dialect, but it can
# be overridden in mk.conf to use only f2c.
#
PKGSRC_FORTRAN?=g95
_GCC_NEEDS_A_FORTRAN= no
.if empty(_USE_PKGSRC_GCC:M[yY][eE][sS]) && !exists(${FCPATH})
_GCC_NEEDS_A_FORTRAN= yes
.else
. for _pattern_ in 0.* 1.[0-4] 1.[0-4].*
. if !empty(MACHINE_PLATFORM:MNetBSD-${_pattern_}-*)
_GCC_NEEDS_A_FORTRAN= yes
. endif
. endfor
.endif
.if !empty(_GCC_NEEDS_A_FORTRAN:M[yY][eE][sS])
. include "../../mk/compiler/${PKGSRC_FORTRAN}.mk"
.endif
.endif # COMPILER_GCC_MK
|