aboutsummaryrefslogtreecommitdiff
blob: decef83990f33f6757458ce2b99b5b0e07ba2ab2 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
.TH "EBUILD" "5" "July 2022" "Portage VERSION" "Portage"

.SH "NAME"
ebuild \- the internal format, variables, and functions in an ebuild script

.SH "DESCRIPTION"
The \fBebuild\fR(1) program accepts a single ebuild script as an argument.
This script contains variables and commands that specify how to download,
unpack, patch, compile, install and merge a particular software package from
its original sources.  In addition to all of this, the ebuild script can also
contain pre/post install/remove commands, as required.  All ebuild scripts are
written in bash.  The minimum version of Bash for an ebuild depends on the
EAPI version.

.SS "Dependencies"
A \fIdepend atom\fR is simply a dependency that is used by portage when
calculating relationships between packages.  Please note that if the atom has
not already been emerged, then the latest version available is matched.
.TP
.B Atom Bases
The base atom is just a full category/packagename. Another name for a full
category/packagename is a \fI"catpkg"\fR. You will find this shorthand\-name
used frequently in Gentoo. Here are some base atoms, a.k.a \fI"catpkgs"\fR:

.nf
.I 	net\-misc/dhcp
.I 	sys\-apps/sed
.I 	sys\-libs/zlib
.fi
.TP
.B Atom Versions
It is nice to be more specific and say that only certain versions of atoms are
acceptable.  Note that versions must be combined with a prefix (see below).
Hence you may add a version number as a postfix to the base.

\fBExamples\fR:
.nf
	sys\-apps/sed\fI\-4.0.5\fR
	sys\-libs/zlib\fI\-1.1.4\-r1\fR
	net\-misc/dhcp\fI\-3.0_p2\fR
.fi

Versions are normally made up of two or three numbers separated by periods,
such as 1.2 or 4.5.2.  This string may be followed by a character such as 1.2a
or 4.5.2z.  Note that this letter is \fInot\fR meant to indicate alpha, beta,
etc... status.  For that, use the optional suffix; either _alpha, _beta, _pre
(pre\-release), _rc (release candidate), or _p (patch).  This means for the
3rd pre\-release of a package, you would use something like 1.2_pre3.  The
suffixes here can be arbitrarily chained without limitation.
.TP
.B Atom Prefix Operators [> >= = <= <]
Sometimes you want to be able to depend on general versions rather than
specifying exact versions all the time.  Hence we provide standard boolean
operators:

\fBExamples\fR:
.nf
	\fI>\fRmedia\-libs/libgd\-1.6
	\fI>=\fRmedia\-libs/libgd\-1.6
	\fI=\fRmedia\-libs/libgd\-1.6
	\fI<=\fRmedia\-libs/libgd\-1.6
	\fI<\fRmedia\-libs/libgd\-1.6
.fi
.TP
.B Extended Atom Prefixes [!~] and Postfixes [*]
Now to get even fancier, we provide the ability to define blocking packages and
version range matching.  Also note that these extended prefixes/postfixes may
be combined in any way with the atom classes defined above.
.RS
.TP
.I ~
means match any revision of the base version specified.  So in the
example below, we would match versions '1.0.2a', '1.0.2a\-r1', '1.0.2a\-r2',
etc...

\fBExample\fR:
.nf
	\fI~\fRnet\-libs/libnet\-1.0.2a
.fi
.TP
.I !
means block packages from being installed at the same time.

\fBExample\fR:
.nf
	\fI!\fRapp\-text/dos2unix
.fi
.TP
.I !!
means block packages from being installed at the same time
and explicitly disallow them from being temporarily installed
simultaneously during a series of upgrades. This syntax is supported
beginning with \fBEAPI 2\fR.

\fBExample\fR:
.nf
	\fI!!\fR<sys\-apps/portage\-2.1.4_rc1
.fi
.TP
.I *
means match any version of the package so long as the specified base
is matched.  So with a version of '2*', we can match '2.1', '2.2', '2.2.1',
etc... and not match version '1.0', '3.0', '4.1', etc... The version part
that comes before the '*' must be a valid version in the absence of the '*'.
For example, '2' is a valid version and '2.' is not. Therefore, '2*' is
allowed and '2.*' is not.

\fBExamples\fR:
.nf
	=dev\-libs/glib\-2\fI*\fR
	\fI!\fR=net\-fs/samba\-2\fI*\fR
.fi
.RE
.TP
.B Atom Slots
Beginning with \fBEAPI 1\fR, any atom can be constrained to match a specific
\fBSLOT\fR. This is accomplished by appending a colon followed by a
\fBSLOT\fR:

\fBExamples\fR:
.nf
	x11\-libs/qt:3
	\fI~\fRx11\-libs/qt-3.3.8:3
	\fI>=\fRx11\-libs/qt-3.3.8:3
	\fI=\fRx11\-libs/qt-3.3*:3
.fi
.TP
.B Sub Slots
Beginning with \fBEAPI 5\fR, a slot dependency may contain an
optional sub\-slot part that follows the regular slot and is
delimited by a \fI/\fR character.

\fBExamples\fR:
.nf
	dev\-lang/perl:0/5.12
	dev\-libs/icu:0/0
	dev\-libs/icu:0/49
	dev\-libs/glib:2/2.30
.fi
.TP
.B Atom Slot Operators
Beginning with \fBEAPI 5\fR, slot operator dependency consists
of a colon followed by one of the following operators:
.RS
.TP
.I *
Indicates that any slot value is acceptable. In addition,
for runtime dependencies, indicates that the package will not
break if the matched package is uninstalled and replaced by
a different matching package in a different slot.

\fBExamples\fR:
.nf
	dev\-lang/perl:*
	dev\-libs/glib:*
	dev\-libs/icu:*
.fi
.TP
.I =
Indicates that any slot value is acceptable. In addition,
for runtime dependencies, indicates that the package will
break unless a matching package with slot and sub\-slot equal
to the slot and sub\-slot of the best installed version at the
time the package was installed is available.

\fBExamples\fR:
.nf
	dev\-libs/glib:=
	dev\-lang/perl:=
	dev\-libs/icu:=
.fi
.TP
.I slot=
Indicates that only a specific slot value is acceptable, and
otherwise behaves identically to the plain equals slot operator.

\fBExamples\fR:
.nf
	dev\-lang/perl:0=
	dev\-libs/glib:2=
	dev\-libs/icu:0=
.fi
.PP
To implement the equals slot operator, the package manager
will need to store the slot/sub\-slot pair of the best installed
version of the matching package. This syntax is only for package
manager use and must not be used by ebuilds. The package manager
may do this by inserting the appropriate slot/sub\-slot pair
between the colon and equals sign when saving the package's
dependencies. The sub\-slot part must not be omitted here
(when the SLOT variable omits the sub\-slot part, the package
is considered to have an implicit sub\-slot which is equal to
the regular slot).

\fBExamples\fR:
.nf
	dev\-lang/perl:0/5.12=
	dev\-libs/glib:2/2.30=
	dev\-libs/icu:0/0=
	dev\-libs/icu:0/49=
.fi
.RE
.TP
.B Atom USE
Beginning with \fBEAPI 2\fR, any atom can be constrained to match specific
\fBUSE\fR flag settings. When used together with \fBSLOT\fR dependencies,
\fBUSE\fR dependencies appear on the right hand side of \fBSLOT\fR
dependencies.
.RS
.TP
.B Unconditional USE Dependencies
.TS
l l
__
l l.
Example	Meaning
foo[bar]	foo must have bar enabled
foo[bar,baz]	foo must have both bar and baz enabled
foo[\-bar,baz]	foo must have bar disabled and baz enabled
.TE
.TP
.B Conditional USE Dependencies
.TS
l l
__
l l.
Compact Form	Equivalent Expanded Form
foo[bar?]	bar? ( foo[bar] ) !bar? ( foo )
foo[!bar?]	bar? ( foo ) !bar? ( foo[\-bar] )
foo[bar=]	bar? ( foo[bar] ) !bar? ( foo[\-bar] )
foo[!bar=]	bar? ( foo[\-bar] ) !bar? ( foo[bar] )
.TE
.RE
.TP
.B Atom USE defaults
Beginning with \fBEAPI 4\fR, \fBUSE\fR dependencies may specify default
assumptions about values for flags that may or may not be missing from
the \fBIUSE\fR of the matched package. Such defaults are specified by
immediately following a flag with either \fI(+)\fR or \fI(\-)\fR. Use
\fI(+)\fR to behave as if a missing flag is present and enabled, or
\fI(\-)\fR to behave as if it is present and disabled:

\fBExamples\fR:
.nf
	media\-video/ffmpeg[threads(+)]
	media\-video/ffmpeg[-threads(\-)]
.fi
.TP
.B Dynamic Dependencies
Sometimes programs may depend on different things depending on the USE
variable.  Portage offers a few options to handle this.  Note that when
using the following syntaxes, each case is considered as 1 Atom in the
scope it appears.  That means that each Atom both conditionally include
multiple Atoms and be nested to an infinite depth.
.RS
.TP
.B usevar? ( Atom )
To include the jpeg library when the user has jpeg in \fBUSE\fR, simply use the
following syntax:

jpeg? ( media\-libs/libjpeg-turbo )
.TP
.B !usevar? ( Atom )
If you want to include a package only if the user does not have a certain
option in their \fBUSE\fR variable, then use the following syntax:

!nophysfs? ( dev\-games/physfs )

This is often useful for those times when you want to want to add optional
support for a feature and have it enabled by default.
.TP
.B usevar? ( Atom if true ) !usevar? ( Atom if false )
For functionality like the tertiary operator found in C you must use
two statements, one normal and one inverted.  If a package uses
GTK3 or GTK2, but not both, then you can handle that like this:

gtk3? ( =x11\-libs/gtk+\-3* ) !gtk3? ( =x11\-libs/gtk+\-2* )

That way the default is the superior GTK3 library.
.TP
.B || ( Atom Atom ... )
When a package can work with a few different packages but a virtual is not
appropriate, this syntax can easily be used.

\fBExample\fR:
.nf
|| (
	app\-games/unreal\-tournament
	app\-games/unreal\-tournament\-goty
)
.fi

Here we see that unreal\-tournament has a normal version and it has a goty
version.  Since they provide the same base set of files, another package can
use either.  Adding a virtual is inappropriate due to the small scope of it.

Another good example is when a package can be built with multiple video
interfaces, but it can only ever have just one.

\fBExample\fR:
.nf
|| (
	sdl? ( media\-libs/libsdl )
	svga? ( media\-libs/svgalib )
	opengl? ( virtual/opengl )
	ggi? ( media\-libs/libggi )
	virtual/x11
)
.fi

Here only one of the packages will be chosen, and the order of preference is
determined by the order in which they appear.  So sdl has the best chance of
being chosen, followed by svga, then opengl, then ggi, with a default of X if
the user does not specify any of the previous choices.

Note that if any of the packages listed are already merged, the package manager
will use that to consider the dependency satisfied.

.SS Variable Usage Notes
.RS
.IP \(bu 2
Variables defined in \fBmake.conf\fR(5) are available for use in
ebuilds (except Portage\-specific variables, which might be not supported by
other package managers).
.IP \(bu
When assigning values to variables in ebuilds, you \fIcannot have a
space\fR between the variable name and the equal sign.
.IP \(bu
Variable values should only contain characters that are members of the
\fBascii\fR(7) character set. This requirement is mandated by \fBGLEP 31\fR.
.RE

.SS "Variables Used In Ebuilds"
.TP
.B ARCH
This variable contains the official Gentoo\-specific acronym for the current
architecture of the running system. For an authoritative list please
review /var/db/repos/gentoo/profiles/arch.list.
.TP
.B P
This variable contains the package name without the ebuild revision.
This variable must NEVER be modified.

\fBExample\fR:
.nf
	x11\-base/xorg\-server\-1.20.5\-r2 \-\-> '\fIxorg\-server\-1.20.5\fR'
.fi
.TP
.B PN
Contains the name of the script without the version number.

\fBExample\fR:
.nf
	x11\-base/xorg\-server\-1.20.5\-r2 \-\-> '\fIxorg\-server\fR'
.fi
.TP
.B PV
Contains the version number without the revision.

\fBExample\fR:
.nf
	x11\-base/xorg\-server\-1.20.5\-r2 \-\-> '\fI1.20.5\fR'
.fi
.TP
.B PR
Contains the revision number or 'r0' if no revision number exists.

\fBExample\fR:
.nf
	x11\-base/xorg\-server\-1.20.5\-r2 \-\-> '\fIr2\fR'
.fi
.TP
.B PVR
Contains the version number with the revision (if non-zero).

\fBExample\fR:
.nf
	x11\-base/xorg\-server\-1.20.5 \-\-> '\fI1.20.5\fR'
	x11\-base/xorg\-server\-1.20.5\-r2 \-\-> '\fI1.20.5\-r2\fR'
.fi
.TP
.B PF
Contains the full package name \fBPN\fR\-\fBPVR\fR

\fBExamples\fR:
.nf
	x11\-base/xorg\-server\-1.20.5 \-\-> '\fIxorg\-server\-1.20.5\fR'
	x11\-base/xorg\-server\-1.20.5\-r2 \-\-> '\fIxorg\-server\-1.20.5\-r2\fR'
.fi
.TP
.B CATEGORY
Contains the package category name.

\fBExample\fR:
.nf
	x11\-base/xorg\-server\-1.20.5\-r2 \-\-> '\fIx11\-base\fR'
.fi
.TP
.B A
Contains all source files required for the package.  This variable must
not be defined. It is autogenerated from the \fBSRC_URI\fR variable.
.TP
.B WORKDIR\fR = \fI"${PORTAGE_TMPDIR}/portage/${CATEGORY}/${PF}/work"
Contains the path to the package build root.  Do not modify this variable.
.TP
.B FILESDIR\fR = \fI"${PORTAGE_TMPDIR}/${CATEGORY}/${PF}/files"
Contains the path to the directory in which package-specific auxiliary
files are located.  Do not modify this variable.
.TP
.B EBUILD_PHASE
Contains the abreviated name of the phase function that is
currently executing, such as "setup", "unpack", "compile", or
"preinst".
.TP
.B EBUILD_PHASE_FUNC
Beginning with \fBEAPI 5\fR, contains the full name of the phase
function that is currently executing, such as "pkg_setup",
"src_unpack", "src_compile", or "pkg_preinst".
.TP
.B EPREFIX
Beginning with \fBEAPI 3\fR, contains the offset
that this Portage was configured for during
installation.  The offset is sometimes necessary in an ebuild or eclass,
and is available in such cases as ${EPREFIX}.  EPREFIX does not contain
a trailing slash, therefore an absent offset is represented by the empty
string.  Do not modify this variable.
.TP
.B S\fR = \fI"${WORKDIR}/${P}"
Contains the path to the temporary \fIbuild directory\fR.  This variable
is used by the functions \fIsrc_compile\fR and \fIsrc_install\fR.  Both
are executed with \fIS\fR as the current directory.  This variable may
be modified to match the extraction directory of a tarball for the package.
.TP
.B T\fR = \fI"${PORTAGE_TMPDIR}/portage/${CATEGORY}/${PF}/temp"
Contains the path to a \fItemporary directory\fR.  You may use this for
whatever you like.
.TP
.B D\fR = \fI"${PORTAGE_TMPDIR}/portage/${CATEGORY}/${PF}/image/"
Contains the path to the temporary \fIinstall directory\fR.  Every write
operation that does not involve the helper tools and functions (found below)
should be prefixed with ${D}.
Beginning with \fBEAPI 3\fR, the offset prefix often needs
to be taken into account here, for which the variable
${ED} is provided (see below).
Note that with \fBEAPI 7\fR, any trailing slash
contained in this path will be automatically removed for ease of concatenating
paths within ebuilds.
Do not modify this variable.
.TP
.B ED\fR = \fI"${PORTAGE_TMPDIR}/portage/${CATEGORY}/${PF}/image/${EPREFIX}/"
Beginning with \fBEAPI 3\fR, contains the path
"${D%/}${EPREFIX}/" for convenience purposes.
For EAPI values prior to \fBEAPI 3\fR which do
not support ED, helpers use \fBD\fR where
they would otherwise use ED. Note that with \fBEAPI 7\fR, any trailing slash
contained in this path will be automatically removed for ease of concatenating
paths within ebuilds.
Do not modify this variable.
.TP
.B MERGE_TYPE
Beginning with \fBEAPI 4\fR, the MERGE_TYPE variable can be used to
query the current merge type. This variable will contain one of the
following possible values:

.RS
.TS
l l
__
l l.
Value	Meaning
binary	previously\-built which is scheduled for merge
buildonly	source\-build which is not scheduled for merge
source	source\-build which is scheduled for merge
.TE
.RE
.TP
.B PROVIDES_EXCLUDE\fR = \fI[space delimited list of fnmatch patterns]\fR
Sonames and file paths matched by these fnmatch patterns will be
excluded during genertion of \fBPROVIDES\fR metadata (see
\fBportage\fR(5)). Patterns are delimited by whitespace, and it is
possible to create patterns containing quoted whitespace.
.TP
.B PORTAGE_LOG_FILE
Contains the path of the build log. If \fBPORTAGE_LOGDIR\fR variable is unset then
PORTAGE_LOG_FILE=\fI"${T}/build.log"\fR.
.TP
.B PORTAGE_SOCKS5_PROXY
Contains the UNIX socket path to SOCKSv5 proxy providing host network
access. Available only when running inside network\-sandbox and a proxy
is available (see network\-sandbox in \fBmake.conf\fR(5)).
.TP
.B REPLACED_BY_VERSION
Beginning with \fBEAPI 4\fR, the REPLACED_BY_VERSION variable can be
used in pkg_prerm and pkg_postrm to query the package version that
is replacing the current package. If there is no replacement package,
the variable will be empty, otherwise it will contain a single version
number.
.TP
.B REPLACING_VERSIONS
Beginning with \fBEAPI 4\fR, the REPLACING_VERSIONS variable can be
used in pkg_pretend, pkg_setup, pkg_preinst and pkg_postinst to query
the package version(s) that the current package is replacing. If there
are no packages to replace, the variable will be empty, otherwise it
will contain a space\-separated list of version numbers corresponding
to the package version(s) being replaced. Typically, this variable will
not contain more than one version, but according to PMS it can contain
more.
.TP
.B REQUIRES_EXCLUDE\fR = \fI[space delimited list of fnmatch patterns]\fR
Sonames and file paths matched by these fnmatch patterns will be
excluded during generation of \fBREQUIRES\fR metadata (see
\fBportage\fR(5)). Patterns are delimited by whitespace, and it is
possible to create patterns containing quoted whitespace.
.TP
.B ROOT\fR = \fI"/"
Please note an important recent change regarding the ROOT variable -- in \fBEAPI 7\fR ebuilds,
this variable will default to "" rather than the traditional "/" within ebuilds
when pointing to the root filesystem, and when set to a non-root path
this variable will never contain a trailing slash. This has the added
convenience of eliminating the need to
specify "${ROOT%/}" when concatenating paths, making the use of ROOT
more elegant. This applies to the variables EROOT, D and ED as well. Please
make note that this will
mean that ebuilds must use different logic in conditionals to determine if
they are installing to the root filesystem -- use [[ "$ROOT" == "" ]] instead of
[[ "$ROOT" == "/" ]].

Contains the path that portage should use as the root of the live filesystem.
When packages wish to make changes to the live filesystem, they should do so in
the tree prefixed by ${ROOT}.  Often the offset prefix needs to be taken
into account here, for which the variable ${EROOT} is provided (see
below).  Do not modify this variable.
.TP
.B EROOT\fR = \fI"${ROOT%/}${EPREFIX}/"
Beginning with \fBEAPI 3\fR, contains
"${ROOT%/}${EPREFIX}/" for convenience
purposes. Do not modify this variable. Also see the important note regarding
ROOT with \fBEAPI 7\fR, above. As with ROOT, EROOT will be defined as ""
when set to the root filesystem and never have a trailing slash within an
ebuild.
.TP
.B BROOT\fR = \fI"${EPREFIX}"
Beginning with \fBEAPI 7\fR, the absolute path to the root directory
containing build dependencies satisfied by BDEPEND, typically
executable build tools. This includes any applicable offset prefix. Do
not modify this variable.
.TP
.B DESCRIPTION\fR = \fI"A happy little package"
Should contain a short description of the package.
.TP
.B EAPI\fR = \fI"0"
Defines the ebuild API version to which this package conforms. If not
defined then it defaults to "0". If portage does not recognize the
EAPI value then it will mask the package and refuse to perform any
operations with it since this means that a newer version of portage
needs to be installed first. For maximum backward compatiblity, a
package should conform to the lowest possible EAPI. Note that anyone
who uses the \fBebuild\fR(1) command with this package will be
required to have a version of portage that recognizes the EAPI to
which this package conforms.
.TP
.B SRC_URI\fR = \fI"https://example.com/path/${P}.tar.gz"
Contains a list of URIs for the required source files.  It can contain
multiple URIs for a single source file.  The list is processed in order
if the file was not found on any of the \fIGENTOO_MIRRORS\fR.
Beginning with \fBEAPI 2\fR, the output file name of a given URI may be
customized with a "->" operator on the right hand side, followed by the
desired output file name. All tokens, including the operator and output
file name, should be separated by whitespace.
.TP
.B HOMEPAGE\fR = \fI"https://example.com/"
Should contain a list of URIs for the sources main sites and other further
package dependent information.
.TP
.B KEYWORDS\fR = \fI[\-~][x86,ppc,sparc,mips,alpha,arm,hppa,...]
.P

KEYWORDS works in conjunction with ACCEPT_KEYWORDS (see \fBmake.conf\fR(5))
to implement a system of creating sets of different types of packages
which can then be masked or unmasked en masse. In the Gentoo Linux
project, they are used by the Gentoo arch teams to define what ebuilds
are included in a particular CPU architecture's set of stable and unstable
unmasked packages.

Here's how they work. For purposes of explanation, let's assume you have
a stable x86\-64bit system, typically referred to as "amd64".
ARCH would be defined as "amd64". If you were using the stable build of
Gentoo Linux, then ACCEPT_KEYWORDS would be set to "amd64" via profiles.
Any ebuild that then has
"amd64" in KEYWORDS will be unmasked by default.

On an "unstable"
amd64 system, ACCEPT_KEYWORDS will be set to "amd64 ~amd64", with the
tilde denoting "unstable." Then, if an ebuild has \fIeither\fR
"amd64" or "~amd64" in KEYWORDS, it will be keyword unmasked by default on
that system. Similarly, if an ebuild is known to not be compatible
with a particular architecture, the "\-" prefix ( i.e. "\-amd64") setting
can be specified to mask it only on that arch.
.P
If you are developing ebuilds for Gentoo Linux, there are certain
policies regarding KEYWORDS that you are expected to follow in order
to align with Gentoo's arch team workflow. The most important
policies are listed below:
.RS
.IP \(bu 2
If you do not know if an ebuild runs under a particular arch, then do not
specify it in KEYWORDS.
It will then be masked by default on that architecture.
.IP \(bu
If the ebuild is known not to work on an arch, disable that arch in KEYWORDS.
This would be done by specifying "\-ppc", for example. This will ensure that
it is explicitly keyword\-masked for that architecture.
.IP \(bu
When submitting an ebuild to Gentoo Linux, it is the project policy to only
have "~arch" set in KEYWORDS
for the architecture for which it has been successfully tested, and no more.
As the ebuild receives more testing, Gentoo arch teams will gradually expand
the KEYWORDS settings to "bump" the package to unstable, and possibly stable.

It is possible to customize the behavior of ACCEPT_KEYWORDS and KEYWORDS on
a per\-package basis using package.accept_keywords and package.keywords files
in profiles. See \fBportage\fR(5) for more information on using these files.
.RE
.P
Note that while other Gentoo\-based projects
have KEYWORDS and ACCEPT_KEYWORDS, they likely will not have exactly
the same policies regarding their use. Therefore, it is necessary that you
research their specific policies and how they differ from Gentoo.
.RE
.TP
.B SLOT
This sets the SLOT for packages that may need to have multiple versions
co\-exist.  By default you should set \fBSLOT\fR="0".  If you are unsure, then
do not fiddle with this until you seek some guidance from some guru.  This
value should \fINEVER\fR be left undefined.

Beginning with \fBEAPI 5\fR, the SLOT variable may contain
an optional sub\-slot part that follows the regular slot and
is delimited by a / character. The sub\-slot must be a valid
slot name. The sub\-slot is used to represent cases in which
an upgrade to a new version of a package with a different
sub\-slot may require dependent packages to be rebuilt. When
the sub\-slot part is omitted from the SLOT definition, the
package is considered to have an implicit sub\-slot which is
equal to the regular slot. Refer to the \fBAtom Slot
Operators\fR section for more information about sub\-slot
usage.
.TP
.B LICENSE
This should be a space delimited list of licenses that the package falls
under.  This \fB_must_\fR be set to a matching license in
/var/db/repos/gentoo/licenses/. If the license does not exist in the repository
yet, you must add it first.
.TP
.B IUSE
This should be a list of any and all USE flags that are leveraged within
your build script.  The only USE flags that should not be listed here are
arch related flags (see \fBKEYWORDS\fR). Beginning with \fBEAPI 1\fR, it
is possible to prefix flags with + or - in order to create default settings
that respectively enable or disable the corresponding \fBUSE\fR flags. For
details about \fBUSE\fR flag stacking order, refer to the \fBUSE_ORDER\fR
variable in \fBmake.conf\fR(5). Given the default \fBUSE_ORDER\fR setting,
negative IUSE default settings are effective only for negation of
repo\-level USE settings, since profile and user configuration settings
override them.
.TP
.B DEPEND
This should contain a list of all packages that are required for the program
to compile (aka \fIbuildtime\fR dependencies).  These are usually libraries and
headers.

Starting from \fBEAPI 7\fR, tools should go into the \fBBDEPEND\fR
variable instead, as \fBDEPEND\fR will only be installed into the
system being built and hence cannot be executed when cross-compiling.

You may use the syntax described above in the \fBDependencies\fR section.
.TP
.B RDEPEND
This should contain a list of all packages that are required for this
program to run (aka \fIruntime\fR dependencies).  These are usually libraries.

In \fBEAPI 3\fR or earlier, if this is not set, then it defaults to the value
of \fBDEPEND\fR. In \fBEAPI 4\fR or later, \fBRDEPEND\fR will never be
implicitly set.

You may use the syntax described above in the \fBDependencies\fR section.
.TP
.B BDEPEND
This should contain a list of all packages that are required to be
executable during compilation of this program (aka \fInative build\fR
dependencies).  These are usually tools, like interpreters or
(cross\-)compilers.  They will be installed into the system performing
the build.

This variable was formally introduced in \fBEAPI 7\fR but was
previously known as \fBHDEPEND\fR in the experimental
\fBEAPI 5-hdepend\fR.

You may use the syntax described above in the \fBDependencies\fR section.
.TP
.B IDEPEND
This should contain a list of all packages that are required to be
executable during merging of this package (aka \fInative install\-time\fR
dependencies).  These are usually post\-install tooling, like cache
generators.  They will be installed into the system performing
the merge.

This variable was introduced in \fBEAPI 8\fR.

You may use the syntax described above in the \fBDependencies\fR section.
.TP
.B PDEPEND
This should contain a list of all packages that should be merged after this
one (aka \fIpost\fR merge dependencies), but which may be installed by the
package manager at any time, if that is not possible.

.B ***WARNING***
.br
Use this only as last resort to break cyclic dependencies!

You may use the syntax described above in the \fBDependencies\fR section.
.TP
.B REQUIRED_USE
Beginning with \fBEAPI 4\fR, the \fBREQUIRED_USE\fR variable can be
used to specify combinations of \fBUSE\fR flags that are allowed
or not allowed. Elements can be nested when necessary.
.TS
l l
__
l l.
Behavior	Expression
If flag1 enabled then flag2 disabled	flag1? ( !flag2 )
If flag1 enabled then flag2 enabled	flag1? ( flag2 )
If flag1 disabled then flag2 enabled	!flag1? ( flag2 )
If flag1 disabled then flag2 disabled	!flag1? ( !flag2 )
Must enable any one or more (inclusive or)	|| ( flag1 flag2 flag3 )
Must enable exactly one but not more (exclusive or)	^^ ( flag1 flag2 flag3 )
May enable at most one (EAPI 5 or later)	?? ( flag1 flag2 flag3 )
.TE
.TP
.B RESTRICT\fR = \fI[strip,mirror,fetch,userpriv]
This should be a space delimited list of portage features to restrict.
You may use conditional syntax to vary restrictions as seen above in DEPEND.
.PD 0
.RS
.TP
.I binchecks
Disable all QA checks for binaries.  This should ONLY be used in packages
for which binary checks make no sense (linux\-headers and kernel\-sources, for
example, can safely be skipped since they have no binaries).  If the binary
checks need to be skipped for other reasons (such as proprietary binaries),
see the \fBQA CONTROL VARIABLES\fR section for more specific exemptions.
.TP
.I bindist
Distribution of built packages is restricted.
.TP
.I fetch
like \fImirror\fR but the files will not be fetched via \fBSRC_URI\fR either.
.TP
.I installsources
Disables installsources for specific packages. This is for packages with
binaries that are not compatible with debugedit.
.TP
.I mirror
files in \fBSRC_URI\fR will not be downloaded from the \fBGENTOO_MIRRORS\fR.
.TP
.I network\-sandbox
Disables the network namespace for specific packages.
Should not be used in the main Gentoo tree.
.TP
.I preserve\-libs
Disables preserve\-libs for specific packages. Note than when a package is
merged, RESTRICT=preserve\-libs applies if either the new instance or the
old instance sets RESTRICT=preserve\-libs.
.TP
.I primaryuri
fetch from URIs in \fBSRC_URI\fR before \fBGENTOO_MIRRORS\fR.
.TP
.I splitdebug
Disables splitdebug for specific packages. This is for packages with
binaries that trigger problems with splitdebug, such as file\-collisions
between symlinks in /usr/lib/debug/.build-id (triggered by bundled libraries).
.TP
.I strip
final binaries/libraries will not be stripped of debug symbols.
.TP
.I test
do not run src_test even if user has \fBFEATURES\fR=test.
.TP
.I userpriv
Disables userpriv for specific packages.
.RE
.PD 1
.TP
.B PROPERTIES\fR = \fI[interactive,live]
A space delimited list of properties, with conditional syntax support.
.PD 0
.RS
.TP
.I interactive
One or more ebuild phases will produce a prompt that requires user interaction.
.TP
.I live
The package uses live source code that may vary each time that the package
is installed.
.RE
.PD 1
.TP
.B DOCS
Beginning with \fBEAPI 4\fR, an array or space\-delimited list of documentation
files for the default src_install function to install using dodoc. If
undefined, a reasonable default list is used. See the documentation for
src_install below.
.TP
.B PATCHES
Beginning with \fBEAPI 6\fR, an array of patches for applying in the default
\fIsrc_prepare\fR function using \fIeapply\fR.


.SS "QA Control Variables:"
.TP
.B Usage Notes
Several QA variables are provided which allow an ebuild to manipulate some
of the QA checks performed by portage.  Use of these variables in ebuilds
should be kept to an absolute minimum otherwise they defeat the purpose
of the QA checks, and their use is subject to agreement of the QA team.
They are primarily intended for use by ebuilds that install closed\-source
binary objects that cannot be altered.

Note that objects that violate these rules may fail on some architectures.
.TP
.B QA_PREBUILT
This should contain a list of file paths, relative to the image
directory, of files that are pre\-built binaries. Paths
listed here will be appended to each of the QA_* variables
listed below. The paths may contain fnmatch\-like patterns
which will be internally translated to regular expressions for
the QA_* variables that support regular expressions instead
of fnmatch patterns. The translation mechanism simply replaces
"*" with ".*".
.TP
.B QA_TEXTRELS
This variable can be set to a list of file paths, relative to the image
directory, of files that contain text relocations that cannot be eliminated.
The paths may contain fnmatch patterns.

This variable is intended to be used on closed\-source binary objects that
cannot be altered.
.TP
.B QA_EXECSTACK
This should contain a list of file paths, relative to the image directory, of
objects that require executable stack in order to run.
The paths may contain fnmatch patterns.

This variable is intended to be used on objects that truly need executable
stack (i.e. not those marked to need it which in fact do not).
.TP
.B QA_WX_LOAD
This should contain a list of file paths, relative to the image directory, of
files that contain writable and executable segments.  These are rare.
The paths may contain fnmatch patterns.
.TP
.B QA_FLAGS_IGNORED
This should contain a list of file paths, relative to the image directory, of
files that do not contain .GCC.command.line sections or contain .hash sections.
The paths may contain regular expressions with escape\-quoted special
characters.

This variable is intended to be used on files of binary packages which ignore
CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, and LDFLAGS variables.
.TP
.B QA_MULTILIB_PATHS
This should contain a list of file paths, relative to the image directory, of
files that should be ignored for the multilib\-strict checks.
The paths may contain regular expressions with escape\-quoted special
characters.
.TP
.B QA_PRESTRIPPED
This should contain a list of file paths, relative to the image directory, of
files that contain pre-stripped binaries. The paths may contain regular
expressions with escape\-quoted special characters.
.TP
.B QA_SONAME
This should contain a list of file paths, relative to the image directory, of
shared libraries that lack SONAMEs. The paths may contain regular expressions
with escape\-quoted special characters.
.TP
.B QA_SONAME_NO_SYMLINK
This should contain a list of file paths, relative to the image directory, of
shared libraries that have SONAMEs but should not have a corresponding SONAME
symlink in the same directory. The paths may contain regular expressions
with escape\-quoted special characters.
.TP
.B QA_AM_MAINTAINER_MODE
This should contain a list of lines containing automake missing \-\-run
commands. The lines may contain regular expressions with escape\-quoted
special characters.
.TP
.B QA_CONFIGURE_OPTIONS
This should contain a list of configure options which trigger warnings about
unrecognized options. The options may contain regular expressions with
escape\-quoted special characters.
.TP
.B QA_DT_NEEDED
This should contain a list of file paths, relative to the image directory, of
shared libraries that lack NEEDED entries. The paths may contain regular
expressions with escape\-quoted special characters.
.TP
.B QA_DESKTOP_FILE
This should contain a list of file paths, relative to the image directory, of
desktop files which should not be validated. The paths may contain regular
expressions with escape\-quoted special characters.
.TP
.B QA_PKGCONFIG_VERSION
If set, then portage verifies that all pkg-config .pc files have a Version field
with the value of QA_PKGCONFIG_VERSION. For example, set
\fIQA_PKGCONFIG_VERSION=${PV}\fR if your package is expected to install all
pkg-config .pc files with a Version field containing PV.

.SH "PORTAGE DECLARATIONS"
.TP
.B inherit
Inherit is portage's maintenance of extra classes of functions that are
external to ebuilds and provided as inheritable capabilities and data. They
define functions and set data types as drop\-in replacements, expanded, and
simplified routines for extremely common tasks to streamline the build
process. Call to inherit cannot depend on conditions which can vary in given
ebuild. Specification of the eclasses contains only their name and not the
\fI.eclass\fR extension. Also note that the inherit statement must come
before other variable declarations unless these variables are used in global
scope of eclasses.

.SH "PHASE FUNCTIONS"
.TP
.B pkg_pretend
Beginning with \fBEAPI 4\fR, this function can be defined in order to
check that miscellaneous requirements are met. It is called as early
as possible, before any attempt is made to satisfy dependencies. If the
function detects a problem then it should call eerror and die. The
environment (variables, functions, temporary directories, etc..) that
is used to execute pkg_pretend is not saved and therefore is not
available in phases that execute afterwards.
.TP
.B pkg_nofetch
This function will be executed when the files in \fBSRC_URI\fR
cannot be fetched for any reason. If you turn on \fIfetch\fR in
\fBRESTRICT\fR, this is useful for displaying information to the
user on *how* to obtain said files. All
you have to do is output a message and let the function return.  Do not
end the function with a call to \fBdie\fR.
.TP
.B pkg_setup
This function can be used if the package needs specific setup actions or
checks to be preformed before anything else.
.br
Initial working directory: $PORTAGE_TMPDIR
.TP
.B src_unpack
This function is used to unpack all the sources in \fIA\fR to \fIWORKDIR\fR.
If not defined in the \fIebuild script\fR it calls \fIunpack ${A}\fR. Any
patches and other pre configure/compile modifications should be done here.
.br
Initial working directory: $WORKDIR
.TP
.B src_prepare
All preparation of source code, such as application of patches, should be done
here. This function is supported beginning with \fBEAPI 2\fR.
.br
Initial working directory: $S
.TP
.B src_configure
All necessary steps for configuration should be done here. This function is
supported beginning with \fBEAPI 2\fR.
.br
Initial working directory: $S
.TP
.B src_compile
With less than \fBEAPI 2\fR, all necessary steps for both configuration and
compilation should be done here. Beginning with \fBEAPI 2\fR, only compilation
steps should be done here.
.br
Initial working directory: $S
.TP
.B src_test
Run all package specific test cases. The default is to run
\'emake check\' followed \'emake test\'. Prior to \fBEAPI 5\fR,
the default src_test implementation will automatically pass the
\-j1 option as the last argument to emake, and beginning with
\fBEAPI 5\fR it will allow the tests to run in parallel.
.br
Initial working directory: $S
.TP
.B src_install
Should contain everything required to install the package in the temporary
\fIinstall directory\fR.
.br
Initial working directory: $S

Beginning with \fBEAPI 4\fR, if src_install is undefined then the
following default implementation is used:

.nf
src_install() {
    if [[ \-f Makefile || \-f GNUmakefile || \-f makefile ]] ; then
        emake DESTDIR="${D}" install
    fi

    if ! declare -p DOCS &>/dev/null ; then
        local d
        for d in README* ChangeLog AUTHORS NEWS TODO CHANGES \\
                THANKS BUGS FAQ CREDITS CHANGELOG ; do
            [[ \-s "${d}" ]] && dodoc "${d}"
        done
    elif [[ $(declare \-p DOCS) == "declare \-a "* ]] ; then
        dodoc "${DOCS[@]}"
    else
        dodoc ${DOCS}
    fi
}
.fi
.TP
.B pkg_preinst pkg_postinst
All modifications required on the live\-filesystem before and after the
package is merged should be placed here. Also commentary for the user
should be listed here as it will be displayed last.
.br
Initial working directory: $PWD
.TP
.B pkg_prerm pkg_postrm
Like the pkg_*inst functions but for unmerge.
.br
Initial working directory: $PWD
.TP
.B pkg_config
This function should contain optional basic configuration steps.
.br
Initial working directory: $PWD

.SH "HELPER FUNCTIONS"
.SS "Phases:"
.TP
.B default
Calls the default phase function implementation for the currently executing
phase. This function is supported beginning with \fBEAPI 2\fR.
.TP
.B default_*
Beginning with \fBEAPI 2\fR, the default pkg_nofetch and src_* phase
functions are accessible via a function having a name that begins with
default_ and ends with the respective phase function name. For example,
a call to a function with the name default_src_compile is equivalent to
a call to the default src_compile implementation.

.RS
.TS
l
_
l.
Default Phase Functions
default_pkg_nofetch
default_src_unpack
default_src_prepare
default_src_configure
default_src_compile
default_src_test
.TE
.RE

.SS "General:"
.TP
.B assert\fR \fI[reason]
Checks the value of the shell's PIPESTATUS array variable, and if any
component is non-zero (indicating failure), calls die with \fIreason\fR
as a failure message.
.TP
.B die\fR \fI[reason]
Causes the current emerge process to be aborted. The final display will
include \fIreason\fR.

Beginning with \fBEAPI 4\fR, all helpers automatically call \fBdie\fR
whenever some sort of error occurs. Helper calls may be prefixed with
the \fBnonfatal\fR helper in order to prevent errors from being fatal.
.TP
.B nonfatal\fR \fI<helper>
Execute \fIhelper\fR and \fIdo not\fR call die if it fails.
The \fBnonfatal\fR helper is available beginning with \fBEAPI 4\fR.
.TP
.B use\fR \fI<USE item>
If \fIUSE item\fR is in the \fBUSE\fR variable, the function will silently
return 0 (aka shell true).  If \fIUSE item\fR is not in the \fBUSE\fR
variable, the function will silently return 1 (aka shell false).  \fBusev\fR
is a verbose version of \fBuse\fR.
.RS
.TP
.I Example:
.nf
if use gnome ; then
	guiconf="\-\-enable\-gui=gnome \-\-with\-x"
elif use gtk ; then
	guiconf="\-\-enable\-gui=gtk \-\-with\-x"
elif use X ; then
	guiconf="\-\-enable\-gui=athena \-\-with\-x"
else
	# No gui version will be built
	guiconf=""
fi
.fi
.RE
.TP
.B usev\fR \fI<USE item>
Like \fBuse\fR, but also echoes \fIUSE item\fR when \fBuse\fR returns true.
.TP
.B usex\fR \fI<USE flag>\fR \fI[true output]\fR \fI[false output]\fR \fI[true \
suffix]\fR \fI[false suffix]
If USE flag is set, echo [true output][true suffix] (defaults to
"yes"), otherwise echo [false output][false suffix] (defaults to
"no"). The usex helper is available beginning with \fBEAPI 5\fR.
.TP
.B use_with\fR \fI<USE item>\fR \fI[configure name]\fR \fI[configure opt]
Useful for creating custom options to pass to a configure script. If \fIUSE
item\fR is in the \fBUSE\fR variable and a \fIconfigure opt\fR is specified,
then the string \fI\-\-with\-[configure name]=[configure opt]\fR will be
echoed. If \fIconfigure opt\fR is not specified, then just
\fI\-\-with\-[configure name]\fR will be echoed.  If \fIUSE item\fR is not in
the \fBUSE\fR variable, then the string \fI\-\-without\-[configure name]\fR
will be echoed. If \fIconfigure name\fR is not specified, then \fIUSE item\fR
will be used in its place. Beginning with \fBEAPI 4\fR, an empty \fIconfigure
opt\fR argument is recognized. In \fBEAPI 3\fR and earlier, an empty
\fIconfigure opt\fR argument is treated as if it weren't provided.
.RS
.TP
.I Examples:
.nf
USE="opengl"
myconf=$(use_with opengl)
(myconf now has the value "\-\-with\-opengl")

USE="jpeg"
myconf=$(use_with jpeg libjpeg)
(myconf now has the value "\-\-with\-libjpeg")

USE=""
myconf=$(use_with jpeg libjpeg)
(myconf now has the value "\-\-without\-libjpeg")

USE="sdl"
myconf=$(use_with sdl SDL all\-plugins)
(myconf now has the value "\-\-with\-SDL=all\-plugins")
.fi
.RE
.TP
.B use_enable\fR \fI<USE item>\fR \fI[configure name]\fR \fI[configure opt]
Same as \fBuse_with\fR above, except that the configure options are
\fI\-\-enable\-\fR instead of \fI\-\-with\-\fR and \fI\-\-disable\-\fR instead
of \fI\-\-without\-\fR. Beginning with \fBEAPI 4\fR, an empty \fIconfigure
opt\fR argument is recognized. In \fBEAPI 3\fR and earlier, an empty
\fIconfigure opt\fR argument is treated as if it weren't provided.
.TP
.B has\fR \fI<item>\fR \fI<item list>
If \fIitem\fR is in \fIitem list\fR, then \fBhas\fR returns
0. Otherwise, 1 is returned. There is another version, \fBhasv\fR, that
will conditionally echo \fIitem\fR.
.br
The \fIitem list\fR is delimited by the \fIIFS\fR variable.  This variable
has a default value of ' ', or a space.  It is a \fBbash\fR(1) setting.
.TP
.B hasv\fR \fI<item>\fR \fI<item list>
Like \fBhas\fR, but also echoes \fIitem\fR when \fBhas\fR returns true.  Banned
in \fBEAPI 8\fR.
.TP
.B has_version\fR \fI[\-b]\fR \fI[\-d]\fR \fI[\-r]\fR \fI[\-\-host\-root]\fR \fI<category/package\-version>
Check to see if \fIcategory/package\-version\fR is installed.  The
parameter accepts all values that are acceptable in the \fBDEPEND\fR
variable.  The function returns 0 if \fIcategory/package\-version\fR
is installed, 1 otherwise. The package is searched for in \fBROOT\fR
by default.

In \fBEAPI 5\fR and \fBEAPI 6\fR, the package is searched for in the
build host if the \fI\-\-host\-root\fR option is given.

In \fBEAPI 7\fR and later, the confusing \fI\-\-host\-root\fR option
has been replaced with \fI\-b\fR, which corresponds to a dependency
satisfied by \fBBDEPEND\fR in the build host.  Similarly, the
\fI\-d\fR option corresponds to \fBDEPEND\fR in \fBSYSROOT\fR and the
\fI\-r\fR option corresponds to \fBRDEPEND\fR in \fBROOT\fR.
.TP
.B best_version\fR \fI[\-b]\fR \fI[\-d]\fR \fI[\-r]\fR \fI[\-\-host\-root]\fR \fI<package name>
This function will look up \fIpackage name\fR in the database of
currently installed packages and echo the "best version" of the
package that is found or nothing if no version is installed.  The
package is searched for in \fBROOT\fR by default.  It accepts the same
options as \fBhas_version\fR.

Example:
.nf
	VERINS="$(best_version net\-ftp/glftpd)"
	(VERINS now has the value "net\-ftp/glftpd\-1.27" if glftpd\-1.27 is \
	installed)
.fi

.SS "Output:"
.TP
.B einfo\fR \fI"disposable message"
Same as \fBelog\fR, but should be used when the message isn't important to the
user (like progress or status messages during the build process).
.TP
.B elog\fR \fI"informative message"
If you need to display a message that you wish the user to read and take
notice of, then use \fBelog\fR.  It works just like \fBecho\fR(1), but
adds a little more to the output so as to catch the user's eye. The message
will also be logged by portage for later review.
.TP
.B ewarn\fR \fI"warning message"
Same as \fBeinfo\fR, but should be used when showing a warning to the user.
.TP
.B eqawarn\fR \fI"QA warning message"
Same as \fBeinfo\fR, but should be used when showing a QA warning to the user.
.TP
.B eerror\fR \fI"error message"
Same as \fBeinfo\fR, but should be used when showing an error to the user.
.TP
.B ebegin\fR \fI"helpful message"
Like \fBeinfo\fR, we output a \fIhelpful message\fR and then hint that the
following operation may take some time to complete.  Once the task is
finished, you need to call \fBeend\fR.
.TP
.B eend\fR \fI<status>\fR \fI["error message"]
Followup the \fBebegin\fR message with an appropriate "OK" or "!!" (for
errors) marker.  If \fIstatus\fR is non\-zero, then the additional \fIerror
message\fR is displayed.

.SS "Unpack:"
.TP
.B unpack\fR \fI<source>\fR \fI[list of more sources]
This function uncompresses and/or untars a list of sources into the current
directory. The function will append \fIsource\fR to the \fBDISTDIR\fR variable.

.SS "Prepare:"
.TP
.B eapply\fR \fI[patch options]\fR \fI<files|directories>
Applies patches to the \fB${WORKDIR}\fR with specified options. Default patch level is \fI\-p1\fR. If a directory specified, all patches from it with
\fI.patch\fR or \fI.diff\fR suffix are applied.
This function is available beginning with \fBEAPI 6\fR, replacing old
\fBepatch.eclass\fR(5) functions.
.TP
.B eapply_user
Applies user\-provided patches to the \fB${WORKDIR}\fR from Portage config
directory tree. For directory syntax and applying rules, see
\fI/etc/portage/patches/\fR section in \fBportage\fR(5). This function is
available beginning with \fBEAPI 6\fR, replacing old \fBepatch.eclass\fR(5)
functions.

.SS "Compile:"
.TP
.B econf\fR \fI[configure options]
This is used as a replacement for configure.  Performs:
.nf
${\fIECONF_SOURCE\fR:-.}/configure \\
	${CBUILD:+\-\-build=${CBUILD}} \\
	\-\-datadir="${EPREFIX}"/usr/share \\
	\-\-host=${CHOST} \\
	\-\-infodir="${EPREFIX}"/usr/share/info \\
	\-\-localstatedir="${EPREFIX}"/var/lib \\
	\-\-prefix="${EPREFIX}"/usr \\
	\-\-mandir="${EPREFIX}"/usr/share/man \\
	\-\-sysconfdir="${EPREFIX}"/etc \\
	${CTARGET:+\-\-target=${CTARGET}} \\
	\fI${EXTRA_ECONF}\fR \\
	\fIconfigure options\fR || die "econf failed"
.fi
Note that the \fIEXTRA_ECONF\fR is for users only, not for ebuild
writers.  If you wish to pass more options to configure, just pass the
extra arguments to \fBeconf\fR. Also note that \fBeconf\fR automatically
calls \fBdie\fR if the configure script fails.
Beginning with \fBEAPI 3\fR, \fBeconf\fR uses the \fB${EPREFIX}\fR
variable which is disregarded for prior \fBEAPI\fR values.
Beginning with \fBEAPI 4\fR, \fBeconf\fR adds
\fI\-\-disable\-dependency\-tracking\fR to the arguments if the
string \fIdisable\-dependency\-tracking\fR occurs in the output
of \fIconfigure \-\-help\fR.
Beginning with \fBEAPI 5\fR, \fBeconf\fR adds
\fIdisable\-silent\-rules\fR to the arguments if the
string \fIdisable\-silent\-rules\fR occurs in the output
of \fIconfigure \-\-help\fR.
Beginning with \fBEAPI 6\fR, \fBeconf\fR adds
\fIdocdir\fR and \fIhtmldir\fR if the corresponding string occurs
in the output of \fIconfigure \-\-help\fR.
Beginning with \fBEAPI 7\fR, \fBeconf\fR adds
\fIwith\-sysroot\fR to the arguments if the string
\fIwith\-sysroot\fR occurs in the output of \fIconfigure \-\-help\fR.
Beginning with \fBEAPI 8\fR, \fBeconf\fR adds
\fIdatarootdir\fR to the arguments if the string
\fIdatarootdir\fR occurs in the output of \fIconfigure \-\-help\fR.  Additionally,
in \fBEAPI 8\fR, \fBeconf\fR adds \fIdisable\-static\fR to the arguments
if the string \fIdisable\-static\fR or \fIenable\-static\fR occurs in the output
of \fIconfigure \-\-help\fR.
.TP
.B emake\fR \fI[make options]
This must be used in place of `make` in ebuilds.  Performs `${MAKE:-make}
${MAKEOPTS} \fImake options\fR ${EXTRA_EMAKE}`, and calls `die` automatically
starting with \fBEAPI 4\fR.

The \fBMAKEOPTS\fR variable is set by the user so they can enable features such
as parallel builds; see \fBmake.conf\fR(5) for more details.

The \fBEXTRA_EMAKE\fR knob is portage feature so developers can override things
while debugging ebuilds; it is not part of any EAPI specification.

.B ***WARNING***
.br
You must make sure your build is happy with parallel makes (make \-j2).  It
should be tested thoroughly as parallel makes are notorious for failing
_sometimes_ but not always.  If you determine that your package fails to build
in parallel, and you are unable to resolve the issue, then you should run
`\fBemake\fR \-j1` explicitly.  This is a last resort however as it can
significantly slow down builds on systems with lots of processors.

.SS "Install:"
.TP
.B einstall\fR \fI[make options]
This is used as a replacement for make install.  Performs:
.nf
make \\
	prefix=${ED}/usr \\
	datadir=${ED}/usr/share \\
	infodir=${ED}/usr/share/info \\
	localstatedir=${ED}/var/lib \\
	mandir=${ED}/usr/share/man \\
	sysconfdir=${ED}/etc \\
	\fI${EXTRA_EINSTALL}\fR \\
	\fImake options\fR \\
	install
.fi
Please do \fBnot\fR use this in place of 'emake install DESTDIR=${D}'.
That is the preferred way of installing make\-based packages.  Also, do
not utilize the \fIEXTRA_EINSTALL\fR variable since it is for users.  Banned
since \fBEAPI 6\fR.

.TP
.B docompress\fR \fI[\-x] <path> [list of more paths]
.RS
Beginning with \fBEAPI 4\fR, the \fBdocompress\fR helper is used to
manage lists of files to be included or excluded from optional compression.
If the first argument is \fB\-x\fR, add each of its subsequent arguments to
the exclusion list. Otherwise, add each argument to the inclusion list.
The inclusion list initially contains \fI/usr/share/doc\fR,
\fI/usr/share/info\fR, and \fI/usr/share/man\fR. The exclusion list
initially contains \fI/usr/share/doc/${PF}/html\fR.

The optional compression shall be carried out after \fBsrc_install\fR
has completed, and before the execution of any subsequent phase
function. For each item in the inclusion list, pretend it has the
value of the \fBD\fR variable prepended, then:

.RS
If it is a directory, act as if every file or directory immediately
under this directory were in the inclusion list.

If the item is a file, it may be compressed unless it has been
excluded as described below.

If the item does not exist, it is ignored.
.RE

Whether an item is to be excluded is determined as follows: For each
item in the exclusion list, pretend it has the value of the \fBD\fR
variable prepended, then:

.RS
If it is a directory, act as if every file or directory immediately
under this directory were in the exclusion list.

If the item is a file, it shall not be compressed.

If the item does not exist, it is ignored.
.RE
.RE
.TP
.B dosed\fR \fI"s:orig:change:g" <filename>
Beginning with \fBEAPI 4\fR, the \fBdosed\fR helper no longer exists. Ebuilds
should call \fBsed\fR(1) directly (and assume that it is GNU sed).

Performs sed in place on \fIfilename\fR inside ${ED}. If no expression is
given then \fI"s:${D}::g"\fR is used as the default expression.  Note
that this expression does \fBNOT\fR use the offset prefix.
.br
.BR 'dosed\ "s:/usr/local:/usr:g"\ /usr/bin/some\-script'
runs sed on ${ED}/usr/bin/some\-script
.TP
.B dodir\fR \fI<path> [more paths]
Creates directories inside of ${ED}.
.br
.BR 'dodir\ /usr/lib/apache'
creates ${ED}/usr/lib/apache.  Note that the do* functions will run
\fBdodir\fR for you. If this directory will be empty when it is merged,
then please use \fBkeepdir\fR instead.
.TP
.B diropts\fR \fI[options for install(1)]
Can be used to define options for the install function used in
\fBdodir\fR.  The default is \fI\-m0755\fR.
.TP
.B into\fR \fI<path>
Sets the root (\fIDESTTREE\fR) for other functions like \fBdobin\fR,
\fBdosbin\fR, \fBdoman\fR, \fBdoinfo\fR, \fBdolib\fR.
.br
The default root is /usr.
.TP
.B keepdir\fR \fI<path> [more paths]
Similar to \fBdodir\fR, but used to create directories that would otherwise
be empty. The treatment of completely\-empty directories is undefined by
PMS, and using \fBkeepdir\fR ensures that they are tracked.
.TP
.B dobin\fR \fI<binary> [list of more binaries]
Installs a \fIbinary\fR or a list of binaries into \fIDESTTREE\fR/bin.
Creates all necessary dirs.
.TP
.B dosbin\fR \fI<binary> [list of more binaries]
Installs a \fIbinary\fR or a list of binaries into \fIDESTTREE\fR/sbin.
Creates all necessary dirs.
.TP
.B doinitd\fR \fI<init.d script> [list of more init.d scripts]
Install Gentoo \fIinit.d scripts\fR.  They will be installed into the
correct location for Gentoo init.d scripts (/etc/init.d/).  Creates all
necessary dirs.
.TP
.B doconfd\fR \fI<conf.d file> [list of more conf.d file]
Install Gentoo \fIconf.d files\fR.  They will be installed into the
correct location for Gentoo conf.d files (/etc/conf.d/).  Creates all
necessary dirs.
.TP
.B doenvd\fR \fI<env.d entry> [list of more env.d entries]
Install Gentoo \fIenv.d entries\fR.  They will be installed into the
correct location for Gentoo env.d entries (/etc/env.d/).  Creates all
necessary dirs.

.PD 0
.TP
.B dolib\fR \fI<library>\fR \fI[list of more libraries]
.TP
.B dolib.a\fR \fI<library>\fR \fI[list of more libraries]
.TP
.B dolib.so\fR \fI<library>\fR \fI[list of more libraries]
.PD 1
Installs a library or a list of libraries into \fIDESTTREE\fR/lib.
Creates all necessary dirs.  dolib is banned in \fBEAPI 7\fR: use the more
specific \fBdolib.a\fR or \fBdolib.so\fR instead.
.TP
.B libopts\fR \fI[options for install(1)]
Can be used to define options for the install function used in
the \fBdolib\fR functions.  The default is \fI\-m0644\fR.  \fBlibopts\fR
is banned in \fBEAPI 7\fR.
.TP
.B doman\fR \fI[\-i18n=<locale>]\fR \fI<man\-page> [list of more man\-pages]
Installs manual\-pages into /usr/share/man/man[0\-9n] depending on the
manual file ending.  The files are compressed if they are not already.  You
can specify locale\-specific manpages with the \fI\-i18n\fR option.  Then the
man\-page will be installed into /usr/share/man/\fI<locale>\fR/man[0\-9n].
Beginning with \fBEAPI 2\fR, a locale\-specific manpage which contains a locale
in the file name will be installed in /usr/share/man/\fI<locale>\fR/man[0\-9n],
with the locale portion of the file name removed, and the \fI\-i18n\fR option
has no effect. For example, with \fBEAPI 2\fR, a manpage named
foo.\fI<locale>\fR.1 will be installed as
/usr/share/man/\fI<locale>\fR/man1/foo.1. Beginning with \fBEAPI 4\fR,
the \fI\-i18n\fR option takes precedence over the locale suffix of the
file name.

.PD 0
.TP
.B dohard\fR \fI<filename> <linkname>
Beginning with \fBEAPI 4\fR, the \fBdohard\fR helper no longer exists. Ebuilds
should call \fBln\fR(1) directly.
.TP
.B dosym\fR \fI[\-r] \fI<filename> <linkname>
.PD 1
Performs the ln command to create a symlink.  Setting \-r creates a relative
symlink.  The \-r option is available beginning with \fBEAPI 8\fR.
.TP
.B doheader\fR \fI[\-r] <file> [list of more files]
Installs the given header files into /usr/include/, by default
with file mode \fI0644\fR (this can be overridden with the
\fBinsopts\fR function). Setting \-r sets recursive. The
\fBdoheader\fR helper is available beginning with \fBEAPI 5\fR.
.TP
.B dohtml\fR \fI [\-a filetypes] [\-r] [\-x list\-of\-dirs\-to\-ignore] \
[list\-of\-files\-and\-dirs]
Installs the files in the list of files (space\-separated list) into
/usr/share/doc/${PF}/html provided the file ends in .htm, .html, .css, .js, \
.gif, .jpeg, .jpg, or .png.
Setting \fI\-a\fR limits what types of files will be included,
\fI\-A\fR appends to the default list, setting \fI\-x\fR sets which dirs to
exclude (CVS excluded by default), \fI\-p\fR sets a document prefix,
\fI\-r\fR sets recursive.
\fBdohtml\fR is banned in \fBEAPI 7\fR: use \fBdodoc\fR and \fBdocinto\fR instead.
.TP
.B doinfo\fR \fI<info\-file> [list of more info\-files]
Installs info\-pages into \fIDESTDIR\fR/info.  Files are automatically
gzipped.  Creates all necessary dirs.
.TP
.B domo\fR \fI<locale\-file> [list of more locale\-files]
Installs locale\-files into \fIDESTDIR\fR/usr/share/locale/[LANG]
depending on local\-file's ending.  Creates all necessary dirs.

.PD 0
.TP
.B fowners\fR \fI[-h|-H|-L|-P|-R] [user][:group] <file> [files]
.TP
.B fperms\fR \fI[-R] <permissions> <file> [files]
.PD 1
Performs chown (\fBfowners\fR) or chmod (\fBfperms\fR), applying
\fIpermissions\fR to \fIfiles\fR.
.TP
.B insinto\fR \fI[path]
Sets the destination path for the \fBdoins\fR function.
.br
The default path is /.
.TP
.B insopts\fR \fI[options for install(1)]
Can be used to define options for the install function used in
\fBdoins\fR.  The default is \fI\-m0644\fR.
.TP
.B doins\fR \fI[\-r] <file> [list of more files]
Installs files into the path controlled by \fBinsinto\fR.  This function
uses \fBinstall\fR(1).  Creates all necessary dirs.
Setting \-r sets recursive. Beginning with \fBEAPI 4\fR, both
\fBdoins\fR and \fBnewins\fR preserve symlinks. In \fBEAPI 3\fR and
earlier, symlinks are dereferenced rather than preserved.
.TP
.B exeinto\fR \fI[path]
Sets the destination path for the \fBdoexe\fR function.
.br
The default path is /.
.TP
.B exeopts\fR \fI[options for install(1)]
Can be used to define options for the install function used in \fBdoexe\fR.
The default is \fI\-m0755\fR.
.TP
.B doexe\fR \fI<executable> [list of more executables]
Installs executables into the path controlled by \fBexeinto\fR.  This function
uses \fBinstall\fR(1).  Creates all necessary dirs.  Behavior is undefined if
\fBexeinto\fR has not yet been called.
.TP
.B docinto\fR \fI[path]
Sets the subdir used by \fBdodoc\fR and \fBdohtml\fR
when installing into the document tree
(based in /usr/share/doc/${PF}/).  Default is no subdir, or just "".
.TP
.B dodoc\fR \fI[-r] <document> [list of more documents]
Installs a document or a list of documents into
/usr/share/doc/${PF}/\fI<docinto path>\fR.
Documents are marked for compression.  Creates all necessary dirs.
Beginning with \fBEAPI 4\fR, there is support for recursion, enabled by the
new \fI\-r\fR option.

.PD 0
.TP
.B newbin\fR \fI<old file> <new filename>
.TP
.B newsbin\fR \fI<old file> <new filename>
.TP
.B newinitd\fR \fI<old file> <new filename>
.TP
.B newconfd\fR \fI<old file> <new filename>
.TP
.B newenvd\fR \fI<old file> <new filename>
.TP
.B newlib.so\fR \fI<old file> <new filename>
.TP
.B newlib.a\fR \fI<old file> <new filename>
.TP
.B newman\fR \fI<old file> <new filename>
.TP
.B newins\fR \fI<old file> <new filename>
.TP
.B newexe\fR \fI<old file> <new filename>
.TP
.B newdoc\fR \fI<old file> <new filename>
.PD 1
All these functions act like the do* functions, but they only work with one
file and the file is installed as \fI[new filename]\fR.
Beginning with \fBEAPI 5\fR, standard input is read when the
first parameter is \- (a hyphen).

.SH "EXAMPLES"
.DS
.nf
# Copyright 1999\-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit another-eclass some-eclass

DESCRIPTION="Super\-useful stream editor (sed)"
HOMEPAGE="https://www.gnu.org/software/sed/"
SRC_URI="ftp://alpha.gnu.org/pub/gnu/${PN}/${P}.tar.gz"

LICENSE="GPL\-2"
SLOT="0"
KEYWORDS="~amd64"

BDEPEND="nls? ( sys-devel/gettext )"

src_configure() {
	econf \\
		\-\-bindir="${EPREFIX}"/bin
}

src_install() {
	emake DESTDIR="${D}" install
	dodoc NEWS README* THANKS AUTHORS BUGS ChangeLog
}
.fi
.DE

.SH "FILES"
.TP
The \fI/usr/lib/portage/bin/ebuild.sh\fR script.
.TP
The helper apps in \fI/usr/lib/portage/bin\fR.
.TP
.B /etc/portage/make.conf
Contains variables for the build\-process and overwrites those in
make.defaults.
.TP
.B /usr/share/portage/config/make.globals
Contains the default variables for the build\-process, you should edit
\fI/etc/portage/make.conf\fR instead.
.TP
.B /etc/portage/color.map
Contains variables customizing colors.

.SH "SEE ALSO"
.BR ebuild (1),
.BR make.conf (5),
.BR color.map (5)

.SH "REPORTING BUGS"
Please report bugs via https://bugs.gentoo.org/

.SH "AUTHORS"
.nf
Achim Gottinger <achim@gentoo.org>
Mark Guertin <gerk@gentoo.org>
Nicholas Jones <carpaski@gentoo.org>
Mike Frysinger <vapier@gentoo.org>
Arfrever Frehtes Taifersar Arahesis <arfrever@apache.org>
Fabian Groffen <grobian@gentoo.org>
.fi