summaryrefslogtreecommitdiff
path: root/mk/tools/replace.mk
blob: 39f40a2881943e3b85a0183bad34b7e9e240f97a (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
# $NetBSD: replace.mk,v 1.107 2005/06/24 21:21:31 minskim Exp $
#
# Copyright (c) 2005 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Johnny C. Lam.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
#    must display the following acknowledgement:
#        This product includes software developed by the NetBSD
#        Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
#    contributors may be used to endorse or promote products derived
#    from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

#
# This Makefile fragment handles "replacements" of system-supplied
# tools with pkgsrc versions.
#
# The replacement tools are placed under ${TOOLS_DIR} so that they
# appear earlier in the search path when invoked using the bare name
# of the tool.
#
# "TOOLS_TOOL" variables, e.g. TOOLS_AWK, TOOLS_SED, etc. are set to
# the full command lines necessary to invoke the real tools on the
# filesystem, and represent the tools required by the package.
#
# "TOOL" variables, e.g. AWK, SED, etc. are set to the full command
# lines necessary to invoke the real tools on the filesystem, and
# represent the tools required by pkgsrc itself.
#
# The tools that could be replaced with pkgsrc counterparts (usually
# GNU versions of the tools) that are required by pkgsrc itself, i.e.
# in targets that are part of pkgsrc infrastructure or part of the
# package Makefile, should be listed as:
#
#	PKGSRC_USE_TOOLS+=	awk sed
#
# The tools that are required by the package itself, i.e. within the
# software's own build system, should be listed as:
#
#	USE_TOOLS+=	gawk gmake lex
#
# If a package requires yacc to generate a parser, then the package
# Makefile should contain one of the following two lines:
#
#	USE_TOOLS+=	yacc	# any yacc will do
#	USE_TOOLS+=	bison	# requires bison-specific features
#
# Adding either "yacc" or "bison" to USE_TOOLS will cause a "yacc" tool
# to be generated that may be used as a yacc-replacement.
#
# By default, any dependencies on the pkgsrc tools are build dependencies,
# but this may be changed by explicitly setting TOOLS_DEPMETHOD.<tool>,
# e.g.:
#
#	TOOLS_DEPMETHOD.tbl=	DEPENDS
#

# Continue to allow USE_PERL5 until packages have been taught to use the
# new syntax.
#
.if defined(USE_PERL5)
USE_TOOLS+=	perl
.  if empty(USE_PERL5:Mbuild)
TOOLS_DEPMETHOD.perl?=	DEPENDS
.  endif
.endif

# XXX Keep this hack here until the day that msgfmt and msgfmt-plurals
# XXX is handled directly by the tools framework.
# XXX
.if defined(USE_MSGFMT_PLURALS) && !empty(USE_MSGFMT_PLURALS:M[yY][eE][sS])
USE_TOOLS+=	perl
.endif

# bison implies "bison-yacc"
.if !empty(USE_TOOLS:Mbison)
USE_TOOLS+=	bison-yacc
.endif

######################################################################

# Create _USE_TOOLS, a sanitized version of PKGSRC_USE_TOOLS and
# USE_TOOLS that removes the ones that are overridden by superseding
# ones.
#
.if !defined(_USE_TOOLS)
_USE_TOOLS:=	${PKGSRC_USE_TOOLS} ${USE_TOOLS}
_USE_TOOLS:=	${_USE_TOOLS:O:u}
.  if !empty(USE_TOOLS:Mbison-yacc)	# bison-yacc > yacc
_USE_TOOLS:=	${_USE_TOOLS:Nyacc}
.  endif
.  if !empty(USE_TOOLS:Mflex)		# flex > lex
_USE_TOOLS:=	${_USE_TOOLS:Nlex}
.  endif
.  if !empty(USE_TOOLS:Mgawk)		# gawk > awk
_USE_TOOLS:=	${_USE_TOOLS:Nawk}
.  endif
.  if !empty(USE_TOOLS:Mgm4)		# gm4 > m4
_USE_TOOLS:=	${_USE_TOOLS:Nm4}
.  endif
.  if !empty(USE_TOOLS:Mgsed)		# gsed > sed
_USE_TOOLS:=	${_USE_TOOLS:Nsed}
.  endif
.endif
MAKEVARS+=	_USE_TOOLS

######################################################################

# _TOOLS_USE_PKGSRC.<tool> is "yes" or "no" depending on whether we're
# using a pkgsrc-supplied tool to replace the system-supplied one.  We
# use the system-supplied one if TOOLS_PLATFORM.<tool> is non-empty, or
# otherwise if this is a particular ${MACHINE_PLATFORM} listed above.
#
.for _t_ in ${_USE_TOOLS}
.  if defined(TOOLS_PLATFORM.${_t_}) && !empty(TOOLS_PLATFORM.${_t_})
_TOOLS_USE_PKGSRC.${_t_}?=	no
.  endif
_TOOLS_USE_PKGSRC.${_t_}?=	yes
.endfor

# TOOLS_DEPMETHOD.<tool> defaults to BUILD_DEPENDS.
.for _t_ in ${_USE_TOOLS}
TOOLS_DEPMETHOD.${_t_}?=	BUILD_DEPENDS
.endfor

######################################################################

# For each of the blocks below, we create either symlinks or wrappers
# for each of the tools requested.  We need to be careful that we don't
# get into dependency loops; do this by setting and checking the value
# of TOOLS_IGNORE.<tool>.  These blocks handle the case where we are
# using the pkgsrc-supplied tool.
#
# Always set the "TOOLS_TOOL" name for each tool to point to the real
# command, e.g., TOOLS_TBL, TOOLS_YACC, etc., provided that "TOOL" has
# been associated with <tool>.
#
.if !defined(TOOLS_IGNORE.[) && !empty(_USE_TOOLS:M\[)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.[=
.  elif !empty(_TOOLS_USE_PKGSRC.[:M[yY][eE][sS])
TOOLS_DEPENDS.[?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			[
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.[=coreutils
TOOLS_REAL_CMD.[=		${TOOLS_PREFIX.[}/bin/${GNU_PROGRAM_PREFIX}[
.  endif
.endif

.if !defined(TOOLS_IGNORE.awk) && !empty(_USE_TOOLS:Mawk)
.  if !empty(PKGPATH:Mlang/nawk)
MAKEFLAGS+=			TOOLS_IGNORE.awk=
.  elif !empty(_TOOLS_USE_PKGSRC.awk:M[yY][eE][sS])
TOOLS_DEPENDS.awk?=		nawk>=20040207:../../lang/nawk
TOOLS_CREATE+=			awk
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.awk=nawk
TOOLS_REAL_CMD.awk=		${TOOLS_PREFIX.awk}/bin/nawk
TOOLS_${_TOOLS_VARNAME.awk}=	${TOOLS_REAL_CMD.awk}
.  endif
.endif

.if !defined(TOOLS_IGNORE.basename) && !empty(_USE_TOOLS:Mbasename)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.basename=
.  elif !empty(_TOOLS_USE_PKGSRC.basename:M[yY][eE][sS])
TOOLS_DEPENDS.basename?=	coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			basename
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.basename=coreutils
TOOLS_REAL_CMD.basename=	${TOOLS_PREFIX.basename}/bin/${GNU_PROGRAM_PREFIX}basename
TOOLS_${_TOOLS_VARNAME.basename}=	${TOOLS_REAL_CMD.basename}
.  endif
.endif

.if !defined(TOOLS_IGNORE.bash) && !empty(_USE_TOOLS:Mbash)
.  if !empty(PKGPATH:Mshells/bash)
MAKEFLAGS+=			TOOLS_IGNORE.bash=
.  elif !empty(_TOOLS_USE_PKGSRC.bash:M[yY][eE][sS])
TOOLS_DEPENDS.bash?=		bash-[0-9]*:../../shells/bash
TOOLS_CREATE+=			bash
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.bash=bash
TOOLS_REAL_CMD.bash=		${TOOLS_PREFIX.bash}/bin/bash
TOOLS_${_TOOLS_VARNAME.bash}=	${TOOLS_REAL_CMD.bash}
.  endif
.endif

.if !defined(TOOLS_IGNORE.bdftopcf) && !empty(_USE_TOOLS:Mbdftopcf)
.  if !empty(PKGPATH:Mx11/XFree86-clients) || !empty(PKGPATH:Mx11/xorg-clients)
MAKEFLAGS+=			TOOLS_IGNORE.bdftopcf=
.  elif !empty(_TOOLS_USE_PKGSRC.bdftopcf:M[yY][eE][sS])
TOOLS_CREATE+=			bdftopcf
.    if defined(X11_TYPE) && !empty(X11_TYPE:MXFree86)
TOOLS_DEPENDS.bdftopcf?=	XFree86-clients>=4.4.0:../../x11/XFree86-clients
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.bdftopcf=imake
TOOLS_REAL_CMD.bdftopcf=	${TOOLS_PREFIX.bdftopcf}/${X11ROOT_PREFIX}/bin/bdftopcf
.    elif defined(X11_TYPE) && !empty(X11_TYPE:Mxorg)
TOOLS_DEPENDS.bdftopcf?=	xorg-clients>=6.8:../../x11/xorg-clients
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.bdftopcf=xorg-clients
TOOLS_REAL_CMD.bdftopcf=	${TOOLS_PREFIX.bdftopcf}/${X11ROOT_PREFIX}/bin/bdftopcf
.    else # !empty(X11_TYPE:Mnative)
TOOLS_REAL_CMD.bdftopcf=	${X11BASE}/bin/bdftopcf
.    endif
.  endif
.endif

.if !defined(TOOLS_IGNORE.bison) && !empty(_USE_TOOLS:Mbison)
.  if !empty(PKGPATH:Mdevel/bison)
MAKEFLAGS+=			TOOLS_IGNORE.bison=
.  elif !empty(_TOOLS_USE_PKGSRC.bison:M[yY][eE][sS])
TOOLS_DEPENDS.bison?=		bison>=1.0:../../devel/bison
TOOLS_CREATE+=			bison
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.bison=bison
TOOLS_REAL_CMD.bison=		${TOOLS_PREFIX.bison}/bin/bison
.  endif
.endif

.if !defined(TOOLS_IGNORE.bison-yacc) && !empty(_USE_TOOLS:Mbison-yacc)
.  if !empty(PKGPATH:Mdevel/bison)
MAKEFLAGS+=			TOOLS_IGNORE.bison-yacc=
.  elif !empty(_TOOLS_USE_PKGSRC.bison-yacc:M[yY][eE][sS])
TOOLS_DEPENDS.bison-yacc?=	bison>=1.0:../../devel/bison
TOOLS_CREATE+=			bison-yacc
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.bison-yacc=bison
TOOLS_REAL_CMD.bison-yacc=	${TOOLS_PREFIX.bison-yacc}/bin/bison
TOOLS_REAL_ARGS.bison-yacc=	-y
TOOLS_${_TOOLS_VARNAME.bison-yacc}=	\
	${TOOLS_REAL_CMD.bison-yacc} ${TOOLS_REAL_ARGS.bison-yacc}
.  endif
TOOLS_CMD.bison-yacc=		${TOOLS_DIR}/bin/yacc
.endif

.if !defined(TOOLS_IGNORE.bzcat) && !empty(_USE_TOOLS:Mbzcat)
.  if !empty(PKGPATH:Marchivers/bzip2)
MAKEFLAGS+=			TOOLS_IGNORE.bzcat=
.  elif !empty(_TOOLS_USE_PKGSRC.bzcat:M[yY][eE][sS])
TOOLS_DEPENDS.bzcat?=		bzip2>=0.9.0b:../../archivers/bzip2
TOOLS_CREATE+=			bzcat
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.bzcat=bzip2
TOOLS_REAL_CMD.bzcat=		${TOOLS_PREFIX.bzcat}/bin/bzcat
TOOLS_${_TOOLS_VARNAME.bzcat}=	${TOOLS_REAL_CMD.bzcat}
.  endif
.endif

.if !defined(TOOLS_IGNORE.cat) && !empty(_USE_TOOLS:Mcat)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.cat=
.  elif !empty(_TOOLS_USE_PKGSRC.cat:M[yY][eE][sS])
TOOLS_DEPENDS.cat?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			cat
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.cat=coreutils
TOOLS_REAL_CMD.cat=		${TOOLS_PREFIX.cat}/bin/${GNU_PROGRAM_PREFIX}cat
TOOLS_${_TOOLS_VARNAME.cat}=	${TOOLS_REAL_CMD.cat}
.  endif
.endif

.if !defined(TOOLS_IGNORE.chgrp) && !empty(_USE_TOOLS:Mchgrp)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.chgrp=
.  elif !empty(_TOOLS_USE_PKGSRC.chgrp:M[yY][eE][sS])
TOOLS_DEPENDS.chgrp?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			chgrp
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.chgrp=coreutils
TOOLS_REAL_CMD.chgrp=		${TOOLS_PREFIX.chgrp}/bin/${GNU_PROGRAM_PREFIX}chgrp
TOOLS_${_TOOLS_VARNAME.chgrp}=	${TOOLS_REAL_CMD.chgrp}
.  endif
.endif

.if !defined(TOOLS_IGNORE.chmod) && !empty(_USE_TOOLS:Mchmod)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.chmod=
.  elif !empty(_TOOLS_USE_PKGSRC.chmod:M[yY][eE][sS])
TOOLS_DEPENDS.chmod?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			chmod
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.chmod=coreutils
TOOLS_REAL_CMD.chmod=		${TOOLS_PREFIX.chmod}/bin/${GNU_PROGRAM_PREFIX}chmod
TOOLS_${_TOOLS_VARNAME.chmod}=	${TOOLS_REAL_CMD.chmod}
.  endif
.endif

.if !defined(TOOLS_IGNORE.chown) && !empty(_USE_TOOLS:Mchown)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.chown=
.  elif !empty(_TOOLS_USE_PKGSRC.chown:M[yY][eE][sS])
TOOLS_DEPENDS.chown?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			chown
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.chown=coreutils
TOOLS_REAL_CMD.chown=		${TOOLS_PREFIX.chown}/bin/${GNU_PROGRAM_PREFIX}chown
TOOLS_${_TOOLS_VARNAME.chown}=	${TOOLS_REAL_CMD.chown}
.  endif
.endif

.if !defined(TOOLS_IGNORE.cmp) && !empty(_USE_TOOLS:Mcmp)
.  if !empty(PKGPATH:Mdevel/diffutils)
MAKEFLAGS+=			TOOLS_IGNORE.cmp=
.  elif !empty(_TOOLS_USE_PKGSRC.cmp:M[yY][eE][sS])
TOOLS_DEPENDS.cmp?=		diffutils>=2.8.1:../../devel/diffutils
TOOLS_CREATE+=			cmp
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.cmp=diffutils
TOOLS_REAL_CMD.cmp=		${TOOLS_PREFIX.cmp}/bin/${GNU_PROGRAM_PREFIX}cmp
TOOLS_${_TOOLS_VARNAME.cmp}=	${TOOLS_REAL_CMD.cmp}
.  endif
.endif

.if !defined(TOOLS_IGNORE.cp) && !empty(_USE_TOOLS:Mcp)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.cp=
.  elif !empty(_TOOLS_USE_PKGSRC.cp:M[yY][eE][sS])
TOOLS_DEPENDS.cp?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			cp
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.cp=coreutils
TOOLS_REAL_CMD.cp=		${TOOLS_PREFIX.cp}/bin/${GNU_PROGRAM_PREFIX}cp
TOOLS_${_TOOLS_VARNAME.cp}=	${TOOLS_REAL_CMD.cp}
.  endif
.endif

.if !defined(TOOLS_IGNORE.csh) && !empty(_USE_TOOLS:Mcsh)
.  if !empty(PKGPATH:Mshells/tcsh)
MAKEFLAGS+=			TOOLS_IGNORE.csh=
.  elif !empty(_TOOLS_USE_PKGSRC.csh:M[yY][eE][sS])
TOOLS_DEPENDS.csh?=		tcsh-[0-9]*:../../shells/tcsh
TOOLS_CREATE+=			csh
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.csh=tcsh
TOOLS_REAL_CMD.csh=		${TOOLS_PREFIX.csh}/bin/tcsh
TOOLS_${_TOOLS_VARNAME.csh}=	${TOOLS_REAL_CMD.csh}
.  endif
.endif

.if !defined(TOOLS_IGNORE.cut) && !empty(_USE_TOOLS:Mcut)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.cut=
.  elif !empty(_TOOLS_USE_PKGSRC.cut:M[yY][eE][sS])
TOOLS_DEPENDS.cut?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			cut
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.cut=coreutils
TOOLS_REAL_CMD.cut=		${TOOLS_PREFIX.cut}/bin/${GNU_PROGRAM_PREFIX}cut
TOOLS_${_TOOLS_VARNAME.cut}=	${TOOLS_REAL_CMD.cut}
.  endif
.endif

.if !defined(TOOLS_IGNORE.date) && !empty(_USE_TOOLS:Mdate)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.date=
.  elif !empty(_TOOLS_USE_PKGSRC.date:M[yY][eE][sS])
TOOLS_DEPENDS.date?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			date
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.date=coreutils
TOOLS_REAL_CMD.date=		${TOOLS_PREFIX.date}/bin/${GNU_PROGRAM_PREFIX}date
TOOLS_${_TOOLS_VARNAME.date}=	${TOOLS_REAL_CMD.date}
.  endif
.endif

.if !defined(TOOLS_IGNORE.diff) && !empty(_USE_TOOLS:Mdiff)
.  if !empty(PKGPATH:Mdevel/diffutils)
MAKEFLAGS+=			TOOLS_IGNORE.diff=
.  elif !empty(_TOOLS_USE_PKGSRC.diff:M[yY][eE][sS])
TOOLS_DEPENDS.diff?=		diffutils>=2.8.1:../../devel/diffutils
TOOLS_CREATE+=			diff
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.diff=diffutils
TOOLS_REAL_CMD.diff=		${TOOLS_PREFIX.diff}/bin/${GNU_PROGRAM_PREFIX}diff
TOOLS_${_TOOLS_VARNAME.diff}=	${TOOLS_REAL_CMD.diff}
.  endif
.endif

.if !defined(TOOLS_IGNORE.dirname) && !empty(_USE_TOOLS:Mdirname)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.dirname=
.  elif !empty(_TOOLS_USE_PKGSRC.dirname:M[yY][eE][sS])
TOOLS_DEPENDS.dirname?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			dirname
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.dirname=coreutils
TOOLS_REAL_CMD.dirname=		${TOOLS_PREFIX.dirname}/bin/${GNU_PROGRAM_PREFIX}dirname
TOOLS_${_TOOLS_VARNAME.dirname}=	${TOOLS_REAL_CMD.dirname}
.  endif
.endif

.if !defined(TOOLS_IGNORE.echo) && !empty(_USE_TOOLS:Mecho)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.echo=
.  elif !empty(_TOOLS_USE_PKGSRC.echo:M[yY][eE][sS])
TOOLS_DEPENDS.echo?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			echo
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.echo=coreutils
TOOLS_REAL_CMD.echo=		${TOOLS_PREFIX.echo}/bin/${GNU_PROGRAM_PREFIX}echo
TOOLS_${_TOOLS_VARNAME.echo}=	${TOOLS_REAL_CMD.echo}
.  endif
.endif

.if !defined(TOOLS_IGNORE.egrep) && !empty(_USE_TOOLS:Megrep)
.  if !empty(PKGPATH:Mtextproc/grep)
MAKEFLAGS+=			TOOLS_IGNORE.egrep=
.  elif !empty(_TOOLS_USE_PKGSRC.egrep:M[yY][eE][sS])
TOOLS_DEPENDS.egrep?=		grep>=2.5.1:../../textproc/grep
TOOLS_CREATE+=			egrep
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.egrep=grep
TOOLS_REAL_CMD.egrep=		${TOOLS_PREFIX.egrep}/bin/${GNU_PROGRAM_PREFIX}egrep
TOOLS_${_TOOLS_VARNAME.egrep}=	${TOOLS_REAL_CMD.egrep}
.  endif
.endif

.if !defined(TOOLS_IGNORE.env) && !empty(_USE_TOOLS:Menv)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.env=
.  elif !empty(_TOOLS_USE_PKGSRC.env:M[yY][eE][sS])
TOOLS_DEPENDS.env?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			env
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.env=coreutilsj
TOOLS_REAL_CMD.env=		${TOOLS_PREFIX.env}/bin/${GNU_PROGRAM_PREFIX}env
TOOLS_${_TOOLS_VARNAME.env}=	${TOOLS_REAL_CMD.env}
.  endif
.endif

.if !defined(TOOLS_IGNORE.expr) && !empty(_USE_TOOLS:Mexpr)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.expr=
.  elif !empty(_TOOLS_USE_PKGSRC.expr:M[yY][eE][sS])
TOOLS_DEPENDS.expr?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			expr
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.expr=coreutils
TOOLS_REAL_CMD.expr=		${TOOLS_PREFIX.expr}/bin/${GNU_PROGRAM_PREFIX}expr
TOOLS_${_TOOLS_VARNAME.expr}=	${TOOLS_REAL_CMD.expr}
.  endif
.endif

.if !defined(TOOLS_IGNORE.false) && !empty(_USE_TOOLS:Mfalse)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.false=
.  elif !empty(_TOOLS_USE_PKGSRC.false:M[yY][eE][sS])
TOOLS_DEPENDS.false?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			false
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.false=coreutils
TOOLS_REAL_CMD.false=		${TOOLS_PREFIX.false}/bin/${GNU_PROGRAM_PREFIX}false
TOOLS_${_TOOLS_VARNAME.false}=	${TOOLS_REAL_CMD.false}
.  endif
.endif

.if !defined(TOOLS_IGNORE.fgrep) && !empty(_USE_TOOLS:Mfgrep)
.  if !empty(PKGPATH:Mtextproc/grep)
MAKEFLAGS+=			TOOLS_IGNORE.fgrep=
.  elif !empty(_TOOLS_USE_PKGSRC.fgrep:M[yY][eE][sS])
TOOLS_DEPENDS.fgrep?=		grep>=2.5.1:../../textproc/grep
TOOLS_CREATE+=			fgrep
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.fgrep=grep
TOOLS_REAL_CMD.fgrep=		${TOOLS_PREFIX.fgrep}/bin/${GNU_PROGRAM_PREFIX}fgrep
TOOLS_${_TOOLS_VARNAME.fgrep}=	${TOOLS_REAL_CMD.fgrep}
.  endif
.endif

.if !defined(TOOLS_IGNORE.file) && !empty(_USE_TOOLS:Mfile)
.  if !empty(PKGPATH:Msysutils/file)
MAKEFLAGS+=			TOOLS_IGNORE.file=
.  elif !empty(_TOOLS_USE_PKGSRC.file:M[yY][eE][sS])
TOOLS_DEPENDS.file?=		file>=4.13:../../sysutils/file
TOOLS_CREATE+=			file
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.file=file
TOOLS_REAL_CMD.file=		${TOOLS_PREFIX.file}/bin/file
TOOLS_${_TOOLS_VARNAME.file}=	${TOOLS_REAL_CMD.file}
.  endif
.endif

.if !defined(TOOLS_IGNORE.find) && !empty(_USE_TOOLS:Mfind)
.  if !empty(PKGPATH:Msysutils/findutils)
MAKEFLAGS+=			TOOLS_IGNORE.find=
.  elif !empty(_TOOLS_USE_PKGSRC.find:M[yY][eE][sS])
TOOLS_DEPENDS.find?=		findutils>=4.1:../../sysutils/findutils
TOOLS_CREATE+=			find
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.find=findutils
TOOLS_REAL_CMD.find=		${TOOLS_PREFIX.find}/bin/${GNU_PROGRAM_PREFIX}find
TOOLS_${_TOOLS_VARNAME.find}=	${TOOLS_REAL_CMD.find}
.  endif
.endif

.if !defined(TOOLS_IGNORE.flex) && !empty(_USE_TOOLS:Mflex)
.  if !empty(PKGPATH:Mdevel/flex)
MAKEFLAGS+=			TOOLS_IGNORE.flex=
.  elif !empty(_TOOLS_USE_PKGSRC.flex:M[yY][eE][sS])
.    include "../../devel/flex/buildlink3.mk"
_TOOLS_DEPENDS.flex=		# empty
.      for _dep_ in ${BUILDLINK_DEPENDS.flex}
_TOOLS_DEPENDS.flex+=		${_dep_}:${BUILDLINK_PKGSRCDIR.flex}
.      endfor
TOOLS_DEPENDS.flex?=		${_TOOLS_DEPENDS.flex}
TOOLS_CREATE+=			flex
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.flex=flex
TOOLS_REAL_CMD.flex=		${TOOLS_PREFIX.flex}/bin/flex
TOOLS_${_TOOLS_VARNAME.flex}=	${TOOLS_REAL_CMD.flex}
.  endif
TOOLS_ALIASES.flex=		lex
.endif

.if !defined(TOOLS_IGNORE.gawk) && !empty(_USE_TOOLS:Mgawk)
.  if !empty(PKGPATH:Mlang/gawk)
MAKEFLAGS+=			TOOLS_IGNORE.gawk=
.  elif !empty(_TOOLS_USE_PKGSRC.gawk:M[yY][eE][sS])
TOOLS_DEPENDS.gawk?=		gawk>=3.1.1:../../lang/gawk
TOOLS_CREATE+=			gawk
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.gawk=gawk
TOOLS_REAL_CMD.gawk=		${TOOLS_PREFIX.gawk}/bin/${GNU_PROGRAM_PREFIX}awk
TOOLS_${_TOOLS_VARNAME.gawk}=	${TOOLS_REAL_CMD.gawk}
.  endif
TOOLS_ALIASES.gawk=		awk
.endif

.if !defined(TOOLS_IGNORE.gm4) && !empty(_USE_TOOLS:Mgm4)
.  if !empty(PKGPATH:Mdevel/m4)
MAKEFLAGS+=			TOOLS_IGNORE.gm4=
.  elif !empty(_TOOLS_USE_PKGSRC.gm4:M[yY][eE][sS])
TOOLS_DEPENDS.gm4?=		m4>=1.4:../../devel/m4
TOOLS_CREATE+=			gm4
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.gm4=m4
TOOLS_REAL_CMD.gm4=		${TOOLS_PREFIX.gm4}/bin/gm4
TOOLS_${_TOOLS_VARNAME.gm4}=	${TOOLS_REAL_CMD.gm4}
.  endif
TOOLS_ALIASES.gm4=		m4
.endif

.if !defined(TOOLS_IGNORE.gmake) && !empty(_USE_TOOLS:Mgmake)
.  if !empty(PKGPATH:Mdevel/gmake)
MAKEFLAGS+=			TOOLS_IGNORE.gmake=
.  elif !empty(_TOOLS_USE_PKGSRC.gmake:M[yY][eE][sS])
TOOLS_DEPENDS.gmake?=		gmake>=3.78:../../devel/gmake
TOOLS_CREATE+=			gmake
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.gmake=gmake
TOOLS_REAL_CMD.gmake=		${TOOLS_PREFIX.gmake}/bin/gmake
TOOLS_${_TOOLS_VARNAME.gmake}=	${TOOLS_REAL_CMD.gmake}
.  endif
.endif

.if !defined(TOOLS_IGNORE.grep) && !empty(_USE_TOOLS:Mgrep)
.  if !empty(PKGPATH:Mtextproc/grep)
MAKEFLAGS+=			TOOLS_IGNORE.grep=
.  elif !empty(_TOOLS_USE_PKGSRC.grep:M[yY][eE][sS])
TOOLS_DEPENDS.grep?=		grep>=2.5.1:../../textproc/grep
TOOLS_CREATE+=			grep
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.grep=grep
TOOLS_REAL_CMD.grep=		${TOOLS_PREFIX.grep}/bin/${GNU_PROGRAM_PREFIX}grep
TOOLS_${_TOOLS_VARNAME.grep}=	${TOOLS_REAL_CMD.grep}
.  endif
.endif

.if !defined(TOOLS_IGNORE.gsed) && !empty(_USE_TOOLS:Mgsed)
.  if !empty(PKGPATH:Mtextproc/gsed)
MAKEFLAGS+=			TOOLS_IGNORE.gsed=
.  elif !empty(_TOOLS_USE_PKGSRC.gsed:M[yY][eE][sS])
TOOLS_DEPENDS.gsed?=		gsed>=3.0.2:../../textproc/gsed
TOOLS_CREATE+=			gsed
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.gsed=gsed
TOOLS_REAL_CMD.gsed=		${TOOLS_PREFIX.gsed}/bin/${GNU_PROGRAM_PREFIX}sed
TOOLS_${_TOOLS_VARNAME.gsed}=	${TOOLS_REAL_CMD.gsed}
.  endif
TOOLS_ALIASES.gsed=		sed
.endif

.if !defined(TOOLS_IGNORE.gtar) && !empty(_USE_TOOLS:Mgtar)
.  if !empty(PKGPATH:Marchivers/gtar-base)
MAKEFLAGS+=			TOOLS_IGNORE.gtar=
.  elif !empty(_TOOLS_USE_PKGSRC.gtar:M[yY][eE][sS])
TOOLS_DEPENDS.gtar?=		gtar-base>=1.13.25:../../archivers/gtar-base
TOOLS_CREATE+=			gtar
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.gtar=gtar-base
TOOLS_REAL_CMD.gtar=		${TOOLS_PREFIX.gtar}/bin/${GNU_PROGRAM_PREFIX}tar
TOOLS_${_TOOLS_VARNAME.gtar}=	${TOOLS_REAL_CMD.gtar}
.  endif
.endif

.if !defined(TOOLS_IGNORE.gunzip) && !empty(_USE_TOOLS:Mgunzip)
.  if !empty(PKGPATH:Marchivers/gzip-base)
MAKEFLAGS+=			TOOLS_IGNORE.gunzip=
.  elif !empty(_TOOLS_USE_PKGSRC.gunzip:M[yY][eE][sS])
TOOLS_DEPENDS.gunzip?=		gzip-base>=1.2.4b:../../archivers/gzip-base
TOOLS_CREATE+=			gunzip
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.gunzip=gzip-base
TOOLS_REAL_CMD.gunzip=		${TOOLS_PREFIX.gunzip}/bin/gunzip
TOOLS_REAL_ARGS.gunzip=		-f
TOOLS_${_TOOLS_VARNAME.gunzip}=	${TOOLS_REAL_CMD.gunzip} ${TOOLS_REAL_ARGS.gunzip}
.  endif
.endif

.if !defined(TOOLS_IGNORE.gzcat) && !empty(_USE_TOOLS:Mgzcat)
.  if !empty(PKGPATH:Marchivers/gzip-base)
MAKEFLAGS+=			TOOLS_IGNORE.gzcat=
.  elif !empty(_TOOLS_USE_PKGSRC.gzcat:M[yY][eE][sS])
TOOLS_DEPENDS.gzcat?=		gzip-base>=1.2.4b:../../archivers/gzip-base
TOOLS_CREATE+=			gzcat
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.gzcat=gzip-base
TOOLS_REAL_CMD.gzcat=		${TOOLS_PREFIX.gzcat}/bin/zcat
TOOLS_${_TOOLS_VARNAME.gzcat}=	${TOOLS_REAL_CMD.gzcat}
.  endif
.endif

.if !defined(TOOLS_IGNORE.gzip) && !empty(_USE_TOOLS:Mgzip)
.  if !empty(PKGPATH:Marchivers/gzip-base)
MAKEFLAGS+=			TOOLS_IGNORE.gzip=
.  elif !empty(_TOOLS_USE_PKGSRC.gzip:M[yY][eE][sS])
TOOLS_DEPENDS.gzip?=		gzip-base>=1.2.4b:../../archivers/gzip-base
TOOLS_CREATE+=			gzip
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.gzip=gzip-base
TOOLS_REAL_CMD.gzip=		${TOOLS_PREFIX.gzip}/bin/gzip
TOOLS_REAL_ARGS.gzip=		-nf ${GZIP}
TOOLS_${_TOOLS_VARNAME.gzip}=	${TOOLS_REAL_CMD.gzip} ${TOOLS_REAL_ARGS.gzip}
.  endif
.endif

.if !defined(TOOLS_IGNORE.head) && !empty(_USE_TOOLS:Mhead)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.head=
.  elif !empty(_TOOLS_USE_PKGSRC.head:M[yY][eE][sS])
TOOLS_DEPENDS.head?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			head
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.head=coreutils
TOOLS_REAL_CMD.head=		${TOOLS_PREFIX.head}/bin/${GNU_PROGRAM_PREFIX}head
TOOLS_${_TOOLS_VARNAME.head}=	${TOOLS_REAL_CMD.head}
.  endif
.endif

.if !defined(TOOLS_IGNORE.hostname) && !empty(_USE_TOOLS:Mhostname)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.hostname=
.  elif !empty(_TOOLS_USE_PKGSRC.hostname:M[yY][eE][sS])
TOOLS_DEPENDS.hostname?=	coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			hostname
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.hostname=coreutils
TOOLS_REAL_CMD.hostname=	${TOOLS_PREFIX.hostname}/bin/${GNU_PROGRAM_PREFIX}hostname
TOOLS_${_TOOLS_VARNAME.hostname}=	${TOOLS_REAL_CMD.hostname}
.  endif
.endif

.if !defined(TOOLS_IGNORE.id) && !empty(_USE_TOOLS:Mid)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.id=
.  elif !empty(_TOOLS_USE_PKGSRC.id:M[yY][eE][sS])
TOOLS_DEPENDS.id?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			id
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.id=coreutils
TOOLS_REAL_CMD.id=		${TOOLS_PREFIX.id}/bin/${GNU_PROGRAM_PREFIX}id
TOOLS_${_TOOLS_VARNAME.id}=	${TOOLS_REAL_CMD.id}
.  endif
.endif

.if !defined(TOOLS_IGNORE.imake) && !empty(_USE_TOOLS:Mimake)
.  if !empty(PKGPATH:Mx11/imake) || !empty(PKGPATH:Mx11/xorg-imake)
MAKEFLAGS+=			TOOLS_IGNORE.imake=
.  elif !empty(_TOOLS_USE_PKGSRC.imake:M[yY][eE][sS])
TOOLS_CREATE+=			imake
.    if defined(X11_TYPE) && !empty(X11_TYPE:MXFree86)
TOOLS_DEPENDS.imake?=		imake>=4.4.0:../../x11/imake
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.imake=imake
TOOLS_REAL_CMD.imake=		${TOOLS_PREFIX.imake}/${X11ROOT_PREFIX}/bin/imake
.    elif defined(X11_TYPE) && !empty(X11_TYPE:Mxorg)
TOOLS_DEPENDS.imake?=		xorg-imake>=6.8:../../x11/xorg-imake
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.imake=xorg-imake
TOOLS_REAL_CMD.imake=		${TOOLS_PREFIX.imake}/${X11ROOT_PREFIX}/bin/imake
.    else # !empty(X11_TYPE:Mnative)
TOOLS_REAL_CMD.imake=		${X11BASE}/bin/imake
.    endif
TOOLS_${_TOOLS_VARNAME.imake}=	${TOOLS_REAL_CMD.imake} ${TOOLS_REAL_ARGS.imake}
.  endif
.endif

.if !defined(TOOLS_IGNORE.install) && !empty(_USE_TOOLS:Minstall)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.install=
.  elif !empty(_TOOLS_USE_PKGSRC.install:M[yY][eE][sS])
TOOLS_DEPENDS.install?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			install
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.install=coreutils
TOOLS_REAL_CMD.install=		${TOOLS_PREFIX.install}/bin/${GNU_PROGRAM_PREFIX}install
TOOLS_${_TOOLS_VARNAME.install}=	${TOOLS_REAL_CMD.install}
.  endif
.endif

.if !defined(TOOLS_IGNORE.lex) && !empty(_USE_TOOLS:Mlex)
.  if !empty(PKGPATH:Mdevel/flex)
MAKEFLAGS+=			TOOLS_IGNORE.lex=
.  elif !empty(_TOOLS_USE_PKGSRC.lex:M[yY][eE][sS])
.    include "../../devel/flex/buildlink3.mk"
_TOOLS_DEPENDS.lex=		# empty
.      for _dep_ in ${BUILDLINK_DEPENDS.flex}
_TOOLS_DEPENDS.lex+=		${_dep_}:${BUILDLINK_PKGSRCDIR.flex}
.      endfor
TOOLS_DEPENDS.lex?=		${_TOOLS_DEPENDS.lex}
TOOLS_CREATE+=			lex
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.lex=flex
TOOLS_REAL_CMD.lex=		${TOOLS_PREFIX.lex}/bin/flex
TOOLS_${_TOOLS_VARNAME.lex}=	${TOOLS_REAL_CMD.lex}
.  endif
.endif

.if !defined(TOOLS_IGNORE.lha) && !empty(_USE_TOOLS:Mlha)
.  if !empty(PKGPATH:Marchivers/lha)
MAKEFLAGS+=			TOOLS_IGNORE.lha=
.  elif !empty(_TOOLS_USE_PKGSRC.lha:M[yY][eE][sS])
TOOLS_DEPENDS.lha?=		lha>=114.9:../../archivers/lha
TOOLS_CREATE+=			lha
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.lha=lha
TOOLS_REAL_CMD.lha=		${TOOLS_PREFIX.lha}/bin/lha
TOOLS_${_TOOLS_VARNAME.lha}=	${TOOLS_REAL_CMD.lha}
.  endif
.endif

.if !defined(TOOLS_IGNORE.ln) && !empty(_USE_TOOLS:Mln)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.ln=
.  elif !empty(_TOOLS_USE_PKGSRC.ln:M[yY][eE][sS])
TOOLS_DEPENDS.ln?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			ln
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.ln=coreutils
TOOLS_REAL_CMD.ln=		${TOOLS_PREFIX.ln}/bin/${GNU_PROGRAM_PREFIX}ln
TOOLS_${_TOOLS_VARNAME.ln}=	${TOOLS_REAL_CMD.ln}
.  endif
.endif

.if !defined(TOOLS_IGNORE.ls) && !empty(_USE_TOOLS:Mls)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.ls=
.  elif !empty(_TOOLS_USE_PKGSRC.ls:M[yY][eE][sS])
TOOLS_DEPENDS.ls?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			ls
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.ls=coreutils
TOOLS_REAL_CMD.ls=		${TOOLS_PREFIX.ls}/bin/${GNU_PROGRAM_PREFIX}ls
TOOLS_${_TOOLS_VARNAME.ls}=	${TOOLS_REAL_CMD.ls}
.  endif
.endif

.if !defined(TOOLS_IGNORE.m4) && !empty(_USE_TOOLS:Mm4)
.  if !empty(PKGPATH:Mdevel/m4)
MAKEFLAGS+=			TOOLS_IGNORE.m4=
.  elif !empty(_TOOLS_USE_PKGSRC.m4:M[yY][eE][sS])
TOOLS_DEPENDS.m4?=		m4>=1.4:../../devel/m4
TOOLS_CREATE+=			m4
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.m4=m4
TOOLS_REAL_CMD.m4=		${TOOLS_PREFIX.m4}/bin/gm4
TOOLS_${_TOOLS_VARNAME.m4}=	${TOOLS_REAL_CMD.m4}
.  endif
.endif

.if !defined(TOOLS_IGNORE.mail) && !empty(_USE_TOOLS:Mmail)
.  if !empty(PKGPATH:Mmail/nail)
MAKEFLAGS+=			TOOLS_IGNORE.mail=
.  elif !empty(_TOOLS_USE_PKGSRC.mail:M[yY][eE][sS])
TOOLS_DEPENDS.mail?=		nail>=11.22:../../mail/nail
TOOLS_CREATE+=			mail
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.mail=nail
TOOLS_REAL_CMD.mail=		${TOOLS_PREFIX.mail}/bin/nail
TOOLS_${_TOOLS_VARNAME.mail}=	${TOOLS_REAL_CMD.mail}
.  endif
.endif

.if !defined(TOOLS_IGNORE.mkdir) && !empty(_USE_TOOLS:Mmkdir)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.mkdir=
.  elif !empty(_TOOLS_USE_PKGSRC.mkdir:M[yY][eE][sS])
TOOLS_DEPENDS.mkdir?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			mkdir
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.mkdir=coreutils
TOOLS_REAL_CMD.mkdir=		${TOOLS_PREFIX.mkdir}/bin/${GNU_PROGRAM_PREFIX}mkdir
TOOLS_REAL_ARGS.mkdir=		-p
TOOLS_${_TOOLS_VARNAME.mkdir}=	${TOOLS_REAL_CMD.mkdir} ${TOOLS_REAL_ARGS.mkdir}
.  endif
.endif

.if !defined(TOOLS_IGNORE.mktemp) && !empty(_USE_TOOLS:Mmktemp)
.  if !empty(PKGPATH:Msysutils/mktemp)
MAKEFLAGS+=			TOOLS_IGNORE.mktemp=
.  elif !empty(_TOOLS_USE_PKGSRC.mktemp:M[yY][eE][sS])
TOOLS_DEPENDS.mktemp?=		mktemp>=1.5:../../sysutils/mktemp
TOOLS_CREATE+=			mktemp
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.mktemp=mktemp
TOOLS_REAL_CMD.mktemp=		${TOOLS_PREFIX.mktemp}/bin/mktemp
TOOLS_${_TOOLS_VARNAME.mktemp}=	${TOOLS_REAL_CMD.mktemp}
.  endif
.endif

.if !defined(TOOLS_IGNORE.mtree) && !empty(_USE_TOOLS:Mmtree)
.  if !empty(PKGPATH:Mpkgtools/mtree)
MAKEFLAGS+=			TOOLS_IGNORE.mtree=
.  elif !empty(_TOOLS_USE_PKGSRC.mtree:M[yY][eE][sS])
#
# This is installed by pkgsrc bootstrap, and is never registered, so
# comment out the dependency on it.
#
#TOOLS_DEPENDS.mtree?=		mtree>=20040722:../../pkgtools/mtree
TOOLS_CREATE+=			mtree
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.mtree=mtree
TOOLS_REAL_CMD.mtree=		${TOOLS_PREFIX.mtree}/bin/mtree
TOOLS_${_TOOLS_VARNAME.mtree}=	${TOOLS_REAL_CMD.mtree}
.  endif
.endif

.if !defined(TOOLS_IGNORE.mv) && !empty(_USE_TOOLS:Mmv)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.mv=
.  elif !empty(_TOOLS_USE_PKGSRC.mv:M[yY][eE][sS])
TOOLS_DEPENDS.mv?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			mv
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.mv=coreutils
TOOLS_REAL_CMD.mv=		${TOOLS_PREFIX.mv}/bin/${GNU_PROGRAM_PREFIX}mv
TOOLS_${_TOOLS_VARNAME.mv}=	${TOOLS_REAL_CMD.mv}
.  endif
.endif

.if !defined(TOOLS_IGNORE.nice) && !empty(_USE_TOOLS:Mnice)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.nice=
.  elif !empty(_TOOLS_USE_PKGSRC.nice:M[yY][eE][sS])
TOOLS_DEPENDS.nice?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			nice
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.nice=coreutils
TOOLS_REAL_CMD.nice=		${TOOLS_PREFIX.nice}/bin/${GNU_PROGRAM_PREFIX}nice
TOOLS_${_TOOLS_VARNAME.nice}=	${TOOLS_REAL_CMD.nice}
.  endif
.endif

.if !defined(TOOLS_IGNORE.nroff) && !empty(_USE_TOOLS:Mnroff)
.  if !empty(PKGPATH:Mtextproc/groff)
MAKEFLAGS+=			TOOLS_IGNORE.nroff=
.  elif !empty(_TOOLS_USE_PKGSRC.nroff:M[yY][eE][sS])
TOOLS_DEPENDS.nroff?=		groff>=1.19nb4:../../textproc/groff
TOOLS_CREATE+=			nroff
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.nroff=groff
TOOLS_REAL_CMD.nroff=		${TOOLS_PREFIX.nroff}/bin/nroff
TOOLS_${_TOOLS_VARNAME.nroff}=	${TOOLS_REAL_CMD.nroff}
.  endif
.endif

.if !defined(TOOLS_IGNORE.patch) && !empty(_USE_TOOLS:Mpatch)
.  if !empty(PKGPATH:Mdevel/patch)
MAKEFLAGS+=			TOOLS_IGNORE.patch=
.  elif !empty(_TOOLS_USE_PKGSRC.patch:M[yY][eE][sS])
TOOLS_DEPENDS.patch?=		patch>=2.2:../../devel/patch
TOOLS_CREATE+=			patch
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.patch=patch
TOOLS_REAL_CMD.patch=		${TOOLS_PREFIX.patch}/bin/gpatch
TOOLS_${_TOOLS_VARNAME.patch}=	${TOOLS_REAL_CMD.patch}
.  endif
.endif

.if !defined(TOOLS_IGNORE.pax) && !empty(_USE_TOOLS:Mpax)
.  if !empty(PKGPATH:Marchivers/pax)
MAKEFLAGS+=			TOOLS_IGNORE.pax=
.  elif !empty(_TOOLS_USE_PKGSRC.pax:M[yY][eE][sS])
#
# This is installed by pkgsrc bootstrap, and is never registered, so
# comment out the dependency on it.
#
#TOOLS_DEPENDS.pax?=		pax>=20040802:../../archivers/pax
TOOLS_CREATE+=			pax
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.pax=pax
TOOLS_REAL_CMD.pax=		${TOOLS_PREFIX.pax}/bin/pax
TOOLS_${_TOOLS_VARNAME.pax}=	${TOOLS_REAL_CMD.pax}
.  endif
.endif

.if !defined(TOOLS_IGNORE.perl) && !empty(_USE_TOOLS:Mperl)
.  if !empty(PKGPATH:Mlang/perl5)
MAKEFLAGS+=			TOOLS_IGNORE.perl=
.  elif !empty(_TOOLS_USE_PKGSRC.perl:M[yY][eE][sS])
.    include "../../lang/perl5/version.mk"
TOOLS_DEPENDS.perl?=		{perl>=${PERL5_REQD},perl-thread>=${PERL5_REQD}}:../../lang/perl5
TOOLS_CREATE+=			perl
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.perl=perl
TOOLS_REAL_CMD.perl=		${TOOLS_PREFIX.perl}/bin/perl
TOOLS_${_TOOLS_VARNAME.perl}=	${TOOLS_REAL_CMD.perl}
.  endif
.endif

.if !defined(TOOLS_IGNORE.pwd) && !empty(_USE_TOOLS:Mpwd)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.pwd=
.  elif !empty(_TOOLS_USE_PKGSRC.pwd:M[yY][eE][sS])
TOOLS_DEPENDS.pwd?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			pwd
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.pwd=coreutils
TOOLS_REAL_CMD.pwd=		${TOOLS_PREFIX.pwd}/bin/${GNU_PROGRAM_PREFIX}pwd
TOOLS_${_TOOLS_VARNAME.pwd}=	${TOOLS_REAL_CMD.pwd}
.  endif
.endif

.if !defined(TOOLS_IGNORE.rm) && !empty(_USE_TOOLS:Mrm)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.rm=
.  elif !empty(_TOOLS_USE_PKGSRC.rm:M[yY][eE][sS])
TOOLS_DEPENDS.rm?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			rm
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.rm=coreutils
TOOLS_REAL_CMD.rm=		${TOOLS_PREFIX.rm}/bin/${GNU_PROGRAM_PREFIX}rm
TOOLS_${_TOOLS_VARNAME.rm}=	${TOOLS_REAL_CMD.rm}
.  endif
.endif

.if !defined(TOOLS_IGNORE.rmdir) && !empty(_USE_TOOLS:Mrmdir)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.rmdir=
.  elif !empty(_TOOLS_USE_PKGSRC.rmdir:M[yY][eE][sS])
TOOLS_DEPENDS.rmdir?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			rmdir
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.rmdir=coreutils
TOOLS_REAL_CMD.rmdir=		${TOOLS_PREFIX.rmdir}/bin/${GNU_PROGRAM_PREFIX}rmdir
TOOLS_${_TOOLS_VARNAME.rmdir}=	${TOOLS_REAL_CMD.rmdir}
.  endif
.endif

.if !defined(TOOLS_IGNORE.sed) && !empty(_USE_TOOLS:Msed)
.  if !empty(PKGPATH:Mtextproc/nbsed)
MAKEFLAGS+=			TOOLS_IGNORE.sed=
.  elif !empty(_TOOLS_USE_PKGSRC.sed:M[yY][eE][sS])
TOOLS_DEPENDS.sed?=		nbsed>=20040821:../../textproc/nbsed
TOOLS_CREATE+=			sed
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.sed=nbsed
TOOLS_REAL_CMD.sed=		${TOOLS_PREFIX.nbsed}/bin/nbsed
TOOLS_${_TOOLS_VARNAME.sed}=	${TOOLS_REAL_CMD.sed}
.  endif
.endif

.if !defined(TOOLS_IGNORE.sh) && !empty(_USE_TOOLS:Msh)
.  if !empty(PKGPATH:Mshells/pdksh)
MAKEFLAGS+=			TOOLS_IGNORE.sh=
.  elif !empty(_TOOLS_USE_PKGSRC.sh:M[yY][eE][sS])
TOOLS_DEPENDS.sh?=		pdksh>=5.2.14:../../shells/pdksh
TOOLS_CREATE+=			sh
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.sh=pdksh
TOOLS_REAL_CMD.sh=		${TOOLS_PREFIX.sh}/bin/pdksh
TOOLS_${_TOOLS_VARNAME.sh}=	${TOOLS_REAL_CMD.sh}
.  endif
TOOLS_CMD.sh=			${TOOLS_DIR}/bin/sh
.endif

.if !defined(TOOLS_IGNORE.shlock) && !empty(_USE_TOOLS:Mshlock)
.  if !empty(PKGPATH:Mpkgtools/shlock)
MAKEFLAGS+=			TOOLS_IGNORE.shlock=
.  elif !empty(_TOOLS_USE_PKGSRC.shlock:M[yY][eE][sS])
TOOLS_DEPENDS.shlock?=		shlock>=20020114:../../pkgtools/shlock
TOOLS_CREATE+=			shlock
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.shlock=shlock
TOOLS_REAL_CMD.shlock=		${TOOLS_PREFIX.shlock}/bin/shlock
TOOLS_${_TOOLS_VARNAME.shlock}=	${TOOLS_REAL_CMD.shlock}
.  endif
.endif

.if !defined(TOOLS_IGNORE.sort) && !empty(_USE_TOOLS:Msort)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.sort=
.  elif !empty(_TOOLS_USE_PKGSRC.sort:M[yY][eE][sS])
TOOLS_DEPENDS.sort?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			sort
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.sort=coreutils
TOOLS_REAL_CMD.sort=		${TOOLS_PREFIX.sort}/bin/${GNU_PROGRAM_PREFIX}sort
TOOLS_${_TOOLS_VARNAME.sort}=	${TOOLS_REAL_CMD.sort}
.  endif
.endif

.if !defined(TOOLS_IGNORE.tail) && !empty(_USE_TOOLS:Mtail)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.tail=
.  elif !empty(_TOOLS_USE_PKGSRC.tail:M[yY][eE][sS])
TOOLS_DEPENDS.tail?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			tail
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.tail=coreutils
TOOLS_REAL_CMD.tail=		${TOOLS_PREFIX.tail}/bin/${GNU_PROGRAM_PREFIX}tail
TOOLS_${_TOOLS_VARNAME.tail}=	${TOOLS_REAL_CMD.tail}
.  endif
.endif

.if !defined(TOOLS_IGNORE.tar) && !empty(_USE_TOOLS:Mtar)
.  if !empty(PKGPATH:Marchivers/pax)
MAKEFLAGS+=			TOOLS_IGNORE.tar=
.  elif !empty(_TOOLS_USE_PKGSRC.tar:M[yY][eE][sS])
#
# This is installed by pkgsrc bootstrap, and is never registered, so
# comment out the dependency on it.
#
#TOOLS_DEPENDS.tar?=		pax>=20040802:../../archivers/pax
TOOLS_CREATE+=			tar
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.tar=pax
TOOLS_REAL_CMD.tar=		${TOOLS_PREFIX.tar}/bin/tar
TOOLS_${_TOOLS_VARNAME.tar}=	${TOOLS_REAL_CMD.tar}
.  endif
.endif

.if !defined(TOOLS_IGNORE.tbl) && !empty(_USE_TOOLS:Mtbl)
.  if !empty(PKGPATH:Mtextproc/groff)
MAKEFLAGS+=			TOOLS_IGNORE.tbl=
.  elif !empty(_TOOLS_USE_PKGSRC.tbl:M[yY][eE][sS])
TOOLS_DEPENDS.tbl?=		groff>=1.19nb4:../../textproc/groff
TOOLS_CREATE+=			tbl
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.tbl=groff
TOOLS_REAL_CMD.tbl=		${TOOLS_PREFIX.tbl}/bin/tbl
TOOLS_${_TOOLS_VARNAME.tbl}=	${TOOLS_REAL_CMD.tbl}
.  endif
.endif

.if !defined(TOOLS_IGNORE.tee) && !empty(_USE_TOOLS:Mtee)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.tee=
.  elif !empty(_TOOLS_USE_PKGSRC.tee:M[yY][eE][sS])
TOOLS_DEPENDS.tee?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			tee
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.tee=coreutils
TOOLS_REAL_CMD.tee=		${TOOLS_PREFIX.tee}/bin/${GNU_PROGRAM_PREFIX}tee
TOOLS_${_TOOLS_VARNAME.tee}=	${TOOLS_REAL_CMD.tee}
.  endif
.endif

.if !defined(TOOLS_IGNORE.test) && !empty(_USE_TOOLS:Mtest)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.test=
.  elif !empty(_TOOLS_USE_PKGSRC.test:M[yY][eE][sS])
TOOLS_DEPENDS.test?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			test
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.test=coreutils
TOOLS_REAL_CMD.test=		${TOOLS_PREFIX.test}/bin/${GNU_PROGRAM_PREFIX}test
TOOLS_${_TOOLS_VARNAME.test}=	${TOOLS_REAL_CMD.test}
.  endif
.endif

.if !defined(TOOLS_IGNORE.touch) && !empty(_USE_TOOLS:Mtouch)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.touch=
.  elif !empty(_TOOLS_USE_PKGSRC.touch:M[yY][eE][sS])
TOOLS_DEPENDS.touch?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			touch
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.touch=coreutils
TOOLS_REAL_CMD.touch=		${TOOLS_PREFIX.touch}/bin/${GNU_PROGRAM_PREFIX}touch
TOOLS_${_TOOLS_VARNAME.touch}=	${TOOLS_REAL_CMD.touch}
.  endif
.endif

.if !defined(TOOLS_IGNORE.tr) && !empty(_USE_TOOLS:Mtr)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.tr=
.  elif !empty(_TOOLS_USE_PKGSRC.tr:M[yY][eE][sS])
TOOLS_DEPENDS.tr?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			tr
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.tr=coreutils
TOOLS_REAL_CMD.tr=		${TOOLS_PREFIX.tr}/bin/${GNU_PROGRAM_PREFIX}tr
TOOLS_${_TOOLS_VARNAME.tr}=	${TOOLS_REAL_CMD.tr}
.  endif
.endif

.if !defined(TOOLS_IGNORE.true) && !empty(_USE_TOOLS:Mtrue)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.true=
.  elif !empty(_TOOLS_USE_PKGSRC.true:M[yY][eE][sS])
TOOLS_DEPENDS.true?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			true
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.true=coreutils
TOOLS_REAL_CMD.true=		${TOOLS_PREFIX.true}/bin/${GNU_PROGRAM_PREFIX}true
TOOLS_${_TOOLS_VARNAME.true}=	${TOOLS_REAL_CMD.true}
.  endif
.endif

.if !defined(TOOLS_IGNORE.tsort) && !empty(_USE_TOOLS:Mtsort)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.tsort=
.  elif !empty(_TOOLS_USE_PKGSRC.tsort:M[yY][eE][sS])
TOOLS_DEPENDS.tsort?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			tsort
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.tsort=coreutils
TOOLS_REAL_CMD.tsort=		${TOOLS_PREFIX.tsort}/bin/${GNU_PROGRAM_PREFIX}tsort
TOOLS_${_TOOLS_VARNAME.tsort}=	${TOOLS_REAL_CMD.tsort}
.  endif
.endif

.if !defined(TOOLS_IGNORE.unrar) && !empty(_USE_TOOLS:Munrar)
.  if !empty(PKGPATH:Marchivers/unrar)
MAKEFLAGS+=			TOOLS_IGNORE.unrar=
.  elif !empty(_TOOLS_USE_PKGSRC.unrar:M[yY][eE][sS])
TOOLS_DEPENDS.unrar?=		unrar>=3.3.4:../../archivers/unrar
TOOLS_CREATE+=			unrar
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.unrar=unrar
TOOLS_REAL_CMD.unrar=		${TOOLS_PREFIX.unrar}/bin/unrar
TOOLS_${_TOOLS_VARNAME.unrar}=	${TOOLS_REAL_CMD.unrar}
.  endif
.endif

.if !defined(TOOLS_IGNORE.unzip) && !empty(_USE_TOOLS:Munzip)
.  if !empty(PKGPATH:Marchivers/unzip)
MAKEFLAGS+=			TOOLS_IGNORE.unzip=
.  elif !empty(_TOOLS_USE_PKGSRC.unzip:M[yY][eE][sS])
TOOLS_DEPENDS.unzip?=		unzip-[0-9]*:../../archivers/unzip
TOOLS_CREATE+=			unzip
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.unzip=unzip
TOOLS_REAL_CMD.unzip=		${TOOLS_PREFIX.unzip}/bin/unzip
TOOLS_${_TOOLS_VARNAME.unzip}=	${TOOLS_REAL_CMD.unzip}
.  endif
.endif

.if !defined(TOOLS_IGNORE.unzoo) && !empty(_USE_TOOLS:Munzoo)
.  if !empty(PKGPATH:Marchivers/unzoo)
MAKEFLAGS+=			TOOLS_IGNORE.unzoo=
.  elif !empty(_TOOLS_USE_PKGSRC.unzoo:M[yY][eE][sS])
TOOLS_DEPENDS.unzoo?=		unzoo-[0-9]*:../../archivers/unzoo
TOOLS_CREATE+=			unzoo
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.unzoo=unzoo
TOOLS_REAL_CMD.unzoo=		${TOOLS_PREFIX.unzoo}/bin/unzoo
TOOLS_${_TOOLS_VARNAME.unzoo}=	${TOOLS_REAL_CMD.unzoo}
.  endif
.endif

.if !defined(TOOLS_IGNORE.wc) && !empty(_USE_TOOLS:Mwc)
.  if !empty(PKGPATH:Msysutils/coreutils)
MAKEFLAGS+=			TOOLS_IGNORE.wc=
.  elif !empty(_TOOLS_USE_PKGSRC.wc:M[yY][eE][sS])
TOOLS_DEPENDS.wc?=		coreutils>=5.2.1:../../sysutils/coreutils
TOOLS_CREATE+=			wc
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.wc=coreutils
TOOLS_REAL_CMD.wc=		${TOOLS_PREFIX.wc}/bin/${GNU_PROGRAM_PREFIX}wc
TOOLS_${_TOOLS_VARNAME.wc}=	${TOOLS_REAL_CMD.wc}
.  endif
.endif

.if !defined(TOOLS_IGNORE.xargs) && !empty(_USE_TOOLS:Mxargs)
.  if !empty(PKGPATH:Msysutils/findutils)
MAKEFLAGS+=			TOOLS_IGNORE.xargs=
.  elif !empty(_TOOLS_USE_PKGSRC.xargs:M[yY][eE][sS])
TOOLS_DEPENDS.xargs?=		findutils>=4.1:../../sysutils/findutils
TOOLS_CREATE+=			xargs
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.xargs=findutils
TOOLS_REAL_CMD.xargs=		${TOOLS_PREFIX.xargs}/bin/${GNU_PROGRAM_PREFIX}xargs
TOOLS_REAL_ARGS.xargs=		-r	# don't run command if stdin is empty
TOOLS_${_TOOLS_VARNAME.xargs}=	${TOOLS_REAL_CMD.xargs} ${TOOLS_REAL_ARGS.xargs}
.  endif
.endif

.if !defined(TOOLS_IGNORE.xmkmf) && !empty(_USE_TOOLS:Mxmkmf)
.  if !empty(PKGPATH:Mx11/imake) || !empty(PKGPATH:Mx11/xorg-imake)
MAKEFLAGS+=			TOOLS_IGNORE.xmkmf=
.  elif !empty(_TOOLS_USE_PKGSRC.xmkmf:M[yY][eE][sS])
TOOLS_CREATE+=			xmkmf
.    if defined(X11_TYPE) && !empty(X11_TYPE:MXFree86)
TOOLS_DEPENDS.xmkmf?=		imake>=4.4.0:../../x11/imake
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.xmkmf=imake
TOOLS_REAL_CMD.xmkmf=		${TOOLS_PREFIX.xmkmf}/${X11ROOT_PREFIX}/bin/xmkmf
.    elif defined(X11_TYPE) && !empty(X11_TYPE:Mxorg)
TOOLS_DEPENDS.xmkmf?=		xorg-imake>=6.8:../../x11/xorg-imake
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.xmkmf=xorg-imake
TOOLS_REAL_CMD.xmkmf=		${TOOLS_PREFIX.xmkmf}/${X11ROOT_PREFIX}/bin/xmkmf
.    else # !empty(X11_TYPE:Mnative)
TOOLS_REAL_CMD.xmkmf=		${X11BASE}/bin/xmkmf
.    endif
#
# If we're using xpkgwedge, then we need to invoke the special xmkmf
# script that will find imake config files in both ${PREFIX} and in
# ${X11BASE}.
#
.    if !empty(USE_XPKGWEDGE:M[yY][eE][sS])
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.xpkgwedge=xpkgwedge
TOOLS_REAL_CMD.xmkmf=		${TOOLS_PREFIX.xpkgwedge}/bin/pkgxmkmf
.    endif
TOOLS_${_TOOLS_VARNAME.xmkmf}=	${TOOLS_REAL_CMD.xmkmf} ${TOOLS_REAL_ARGS.xmkmf}
.  endif
.endif

.if !defined(TOOLS_IGNORE.yacc) && !empty(_USE_TOOLS:Myacc)
.  if !empty(PKGPATH:Mdevel/bison)
MAKEFLAGS+=			TOOLS_IGNORE.yacc=
.  elif !empty(_TOOLS_USE_PKGSRC.yacc:M[yY][eE][sS])
TOOLS_DEPENDS.yacc?=		bison>=1.0:../../devel/bison
TOOLS_CREATE+=			yacc
TOOLS_FIND_PREFIX+=		TOOLS_PREFIX.yacc=bison
TOOLS_REAL_CMD.yacc=		${TOOLS_PREFIX.yacc}/bin/bison
TOOLS_REAL_ARGS.yacc=		-y
TOOLS_${_TOOLS_VARNAME.yacc}=	${TOOLS_REAL_CMD.yacc} ${TOOLS_REAL_ARGS.yacc}
.  endif
.endif

# Compute the locations of the pkgsrc-supplied tools.
FIND_PREFIX:=	${TOOLS_FIND_PREFIX}
.include "../../mk/find-prefix.mk"

######################################################################

# Add the dependencies for each pkgsrc-supplied tool.
#
.for _t_ in ${_USE_TOOLS}
.  if defined(TOOLS_DEPMETHOD.${_t_}) && defined(TOOLS_DEPENDS.${_t_})
.    for _dep_ in ${TOOLS_DEPENDS.${_t_}}
.      if empty(${TOOLS_DEPMETHOD.${_t_}}:C/\:.*$//:M${_dep_:C/\:.*$//})
${TOOLS_DEPMETHOD.${_t_}}+=	${_dep_}
.      endif
.    endfor
.  endif
.endfor

######################################################################

# For each tool that pkgsrc requires, make sure that the "TOOL" name
# points to the real command, e.g., AWK, SED, etc., provided that
# "TOOL" has been associated with <tool>.
#
.for _t_ in ${PKGSRC_USE_TOOLS:O:u}
_TOOLS_USE_PKGSRC.${_t_}?=	no
.  if defined(_TOOLS_VARNAME.${_t_})
.    if !empty(_TOOLS_USE_PKGSRC.${_t_}:M[nN][oO])
.      if defined(TOOLS_PLATFORM.${_t_}) && !empty(TOOLS_PLATFORM.${_t_})
${_TOOLS_VARNAME.${_t_}}=	${TOOLS_PLATFORM.${_t_}}
.      endif
.    else
${_TOOLS_VARNAME.${_t_}}=	${TOOLS_${_TOOLS_VARNAME.${_t_}}}
.    endif
.  endif
.endfor

######################################################################

# If we are using the system-supplied tool, create symlinks or wrappers
# for each of the tools requested.
#
# Set TOOLS_REAL_CMD.<tool> appropriately in the case where we are
# using the system-supplied tool.  Here, we first check to see if
# TOOLS_PLATFORM.<tool> is defined.  If it is, then use that as the
# path to the real command and extract any arguments into
# TOOLS_REAL_ARGS.<tool>.
#
# Always set the "TOOLS_TOOL" name for each tool to point to the real
# command, e.g., TOOLS_TBL, TOOLS_YACC, etc., provided that "TOOL" has
# been associated with <tool>.  If the "TOOL" name is undefined, then
# set it to the same value to provide a simple name for use by package
# Makefiles.
#
.for _t_ in ${_USE_TOOLS}
.  if !defined(TOOLS_IGNORE.${_t_}) && \
      !empty(_TOOLS_USE_PKGSRC.${_t_}:M[nN][oO])
.    if defined(TOOLS_PLATFORM.${_t_}) && !empty(TOOLS_PLATFORM.${_t_})
TOOLS_REAL_CMD.${_t_}?=		\
	${TOOLS_PLATFORM.${_t_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//}
TOOLS_REAL_ARGS.${_t_}?=	\
	${TOOLS_PLATFORM.${_t_}:C/^/_asdf_/1:N_asdf_*}
.      if defined(_TOOLS_VARNAME.${_t_})
TOOLS_${_TOOLS_VARNAME.${_t_}}=	${TOOLS_PLATFORM.${_t_}}
.      endif
TOOLS_CREATE+=			${_t_}
.    elif defined(_TOOLS_VARNAME.${_t_})
.      if defined(TOOLS_REAL_CMD.${_t_})
TOOLS_${_TOOLS_VARNAME.${_t_}}=	${TOOLS_REAL_CMD.${_t_}} ${TOOLS_REAL_ARGS.${_t_}}
.      else
TOOLS_${_TOOLS_VARNAME.${_t_}}=	${_TOOLS_VARNAME.${_t_}}_not_defined_
.      endif
.    endif
.  endif
.  if defined(_TOOLS_VARNAME.${_t_})
.    if defined(TOOLS_${_TOOLS_VARNAME.${_t_}})
.      for _v_ in ${_TOOLS_VARNAME.${_t_}}
${_v_}?=	${TOOLS_${_TOOLS_VARNAME.${_t_}}}
.      endfor
.    endif
.  endif
.endfor

######################################################################

# For packages that use GNU configure scripts, pass the real command
# paths for the tools that the package uses through the shell environment.
# We do this since these paths may be hardcoded into package scripts,
# and if they're not pre-specified, then they'll be searched for in the
# PATH, which would find the ones in ${TOOLS_DIR}.
#
.if defined(GNU_CONFIGURE)
.  for _t_ in ${_USE_TOOLS}
.    if defined(TOOLS_${_TOOLS_VARNAME.${_t_}})
.      for _v_ in ${_TOOLS_VARNAME_GNU.${_t_}}
CONFIGURE_ENV+=		${_v_}=${TOOLS_${_TOOLS_VARNAME.${_t_}}:Q}
.      endfor
.    endif
.  endfor
.endif