| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | .\" $NetBSD: make.1,v 1.338 2022/09/09 05:27:32 rillig Exp $ | | 1 | .\" $NetBSD: make.1,v 1.339 2022/09/09 06:23:36 rillig Exp $ |
2 | .\" | | 2 | .\" |
3 | .\" Copyright (c) 1990, 1993 | | 3 | .\" Copyright (c) 1990, 1993 |
4 | .\" The Regents of the University of California. All rights reserved. | | 4 | .\" The Regents of the University of California. All rights reserved. |
5 | .\" | | 5 | .\" |
6 | .\" Redistribution and use in source and binary forms, with or without | | 6 | .\" Redistribution and use in source and binary forms, with or without |
7 | .\" modification, are permitted provided that the following conditions | | 7 | .\" modification, are permitted provided that the following conditions |
8 | .\" are met: | | 8 | .\" are met: |
9 | .\" 1. Redistributions of source code must retain the above copyright | | 9 | .\" 1. Redistributions of source code must retain the above copyright |
10 | .\" notice, this list of conditions and the following disclaimer. | | 10 | .\" notice, this list of conditions and the following disclaimer. |
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 11 | .\" 2. Redistributions in binary form must reproduce the above copyright |
12 | .\" notice, this list of conditions and the following disclaimer in the | | 12 | .\" notice, this list of conditions and the following disclaimer in the |
13 | .\" documentation and/or other materials provided with the distribution. | | 13 | .\" documentation and/or other materials provided with the distribution. |
14 | .\" 3. Neither the name of the University nor the names of its contributors | | 14 | .\" 3. Neither the name of the University nor the names of its contributors |
| @@ -846,35 +846,34 @@ A path to the directory where | | | @@ -846,35 +846,34 @@ A path to the directory where |
846 | was executed. | | 846 | was executed. |
847 | Refer to the description of | | 847 | Refer to the description of |
848 | .Sq Va PWD | | 848 | .Sq Va PWD |
849 | for more details. | | 849 | for more details. |
850 | .It Va .INCLUDEDFROMDIR | | 850 | .It Va .INCLUDEDFROMDIR |
851 | The directory of the file this Makefile was included from. | | 851 | The directory of the file this Makefile was included from. |
852 | .It Va .INCLUDEDFROMFILE | | 852 | .It Va .INCLUDEDFROMFILE |
853 | The filename of the file this Makefile was included from. | | 853 | The filename of the file this Makefile was included from. |
854 | .It Va MAKE | | 854 | .It Va MAKE |
855 | The name that | | 855 | The name that |
856 | .Nm | | 856 | .Nm |
857 | was executed with | | 857 | was executed with |
858 | .Pq Va argv[0] . | | 858 | .Pq Va argv[0] . |
859 | For compatibility | | 859 | For compatibility, |
860 | .Nm | | 860 | .Nm |
861 | also sets | | 861 | also sets |
862 | .Va .MAKE | | 862 | .Va .MAKE |
863 | with the same value. | | 863 | with the same value. |
864 | The preferred variable to use is the environment variable | | 864 | The preferred variable to use is the environment variable |
865 | .Ev MAKE | | 865 | .Ev MAKE |
866 | because it is more compatible with other versions of | | 866 | because it is more compatible with other make variants |
867 | .Nm | | | |
868 | and cannot be confused with the special target with the same name. | | 867 | and cannot be confused with the special target with the same name. |
869 | .It Va .MAKE.DEPENDFILE | | 868 | .It Va .MAKE.DEPENDFILE |
870 | Names the makefile (default | | 869 | Names the makefile (default |
871 | .Sq Pa .depend ) | | 870 | .Sq Pa .depend ) |
872 | from which generated dependencies are read. | | 871 | from which generated dependencies are read. |
873 | .It Va .MAKE.EXPAND_VARIABLES | | 872 | .It Va .MAKE.EXPAND_VARIABLES |
874 | A boolean that controls the default behavior of the | | 873 | A boolean that controls the default behavior of the |
875 | .Fl V | | 874 | .Fl V |
876 | option. | | 875 | option. |
877 | If true, variable values printed with | | 876 | If true, variable values printed with |
878 | .Fl V | | 877 | .Fl V |
879 | are fully expanded; if false, the raw variable contents (which may | | 878 | are fully expanded; if false, the raw variable contents (which may |
880 | include additional unexpanded variable references) are shown. | | 879 | include additional unexpanded variable references) are shown. |
| @@ -910,82 +909,80 @@ If set to | | | @@ -910,82 +909,80 @@ If set to |
910 | apparent variable assignments in dependency lines are | | 909 | apparent variable assignments in dependency lines are |
911 | treated as normal sources. | | 910 | treated as normal sources. |
912 | .It Va MAKEFLAGS | | 911 | .It Va MAKEFLAGS |
913 | The environment variable | | 912 | The environment variable |
914 | .Sq Ev MAKEFLAGS | | 913 | .Sq Ev MAKEFLAGS |
915 | may contain anything that | | 914 | may contain anything that |
916 | may be specified on | | 915 | may be specified on |
917 | .Nm Ns 's | | 916 | .Nm Ns 's |
918 | command line. | | 917 | command line. |
919 | Anything specified on | | 918 | Anything specified on |
920 | .Nm Ns 's | | 919 | .Nm Ns 's |
921 | command line is appended to the | | 920 | command line is appended to the |
922 | .Va MAKEFLAGS | | 921 | .Va MAKEFLAGS |
923 | variable which is then | | 922 | variable, which is then added to the environment for all programs that |
924 | entered into the environment for all programs which | | | |
925 | .Nm | | 923 | .Nm |
926 | executes. | | 924 | executes. |
927 | .It Va .MAKE.LEVEL | | 925 | .It Va .MAKE.LEVEL |
928 | The recursion depth of | | 926 | The recursion depth of |
929 | .Nm . | | 927 | .Nm . |
930 | The initial instance of | | 928 | The top-level instance of |
931 | .Nm | | 929 | .Nm |
932 | is 0, and an incremented value is put into the environment | | 930 | has level 0, and each child make has its parent level plus 1. |
933 | to be seen by the next generation. | | | |
934 | This allows tests like: | | 931 | This allows tests like: |
935 | .Li .if ${.MAKE.LEVEL} == 0 | | 932 | .Li .if ${.MAKE.LEVEL} == 0 |
936 | to protect things which should only be evaluated in the initial instance of | | 933 | to protect things which should only be evaluated in the top-level instance of |
937 | .Nm . | | 934 | .Nm . |
938 | .It Va .MAKE.MAKEFILE_PREFERENCE | | 935 | .It Va .MAKE.MAKEFILE_PREFERENCE |
939 | The ordered list of makefile names | | 936 | The ordered list of makefile names |
940 | (default | | 937 | (default |
941 | .Sq Pa makefile , | | 938 | .Sq Pa makefile , |
942 | .Sq Pa Makefile ) | | 939 | .Sq Pa Makefile ) |
943 | that | | 940 | that |
944 | .Nm | | 941 | .Nm |
945 | looks for. | | 942 | looks for. |
946 | .It Va .MAKE.MAKEFILES | | 943 | .It Va .MAKE.MAKEFILES |
947 | The list of makefiles read by | | 944 | The list of makefiles read by |
948 | .Nm , | | 945 | .Nm , |
949 | which is useful for tracking dependencies. | | 946 | which is useful for tracking dependencies. |
950 | Each makefile is recorded only once, regardless of the number of times read. | | 947 | Each makefile is recorded only once, regardless of the number of times read. |
951 | .It Va .MAKE.MODE | | 948 | .It Va .MAKE.MODE |
952 | Processed after reading all makefiles. | | 949 | Processed after reading all makefiles. |
953 | Can affect the mode that | | 950 | Affects the mode that |
954 | .Nm | | 951 | .Nm |
955 | runs in. | | 952 | runs in. |
956 | It can contain a number of keywords: | | 953 | It can contain a number of keywords: |
957 | .Bl -hang -width missing-filemon=bf. | | 954 | .Bl -hang -width missing-filemon=bf. |
958 | .It Cm compat | | 955 | .It Cm compat |
959 | Like | | 956 | Like |
960 | .Fl B , | | 957 | .Fl B , |
961 | puts | | 958 | puts |
962 | .Nm | | 959 | .Nm |
963 | into | | 960 | into |
964 | .Dq compat | | 961 | .Dq compat |
965 | mode. | | 962 | mode. |
966 | .It Cm meta | | 963 | .It Cm meta |
967 | Puts | | 964 | Puts |
968 | .Nm | | 965 | .Nm |
969 | into | | 966 | into |
970 | .Dq meta | | 967 | .Dq meta |
971 | mode, where meta files are created for each target | | 968 | mode, where meta files are created for each target |
972 | to capture the command run, the output generated and if | | 969 | to capture the command run, the output generated, and if |
973 | .Xr filemon 4 | | 970 | .Xr filemon 4 |
974 | is available, the system calls which are of interest to | | 971 | is available, the system calls which are of interest to |
975 | .Nm . | | 972 | .Nm . |
976 | The captured output can be very useful when diagnosing errors. | | 973 | The captured output can be useful when diagnosing errors. |
977 | .It Cm curdirOk= Ns Ar bf | | 974 | .It Cm curdirOk= Ns Ar bf |
978 | Normally | | 975 | By default, |
979 | .Nm | | 976 | .Nm |
980 | does not create | | 977 | does not create |
981 | .Pa .meta | | 978 | .Pa .meta |
982 | files in | | 979 | files in |
983 | .Sq Va .CURDIR . | | 980 | .Sq Va .CURDIR . |
984 | This can be overridden by setting | | 981 | This can be overridden by setting |
985 | .Va bf | | 982 | .Va bf |
986 | to a value which represents true. | | 983 | to a value which represents true. |
987 | .It Cm missing-meta= Ns Ar bf | | 984 | .It Cm missing-meta= Ns Ar bf |
988 | If | | 985 | If |
989 | .Va bf | | 986 | .Va bf |
990 | is true, a missing | | 987 | is true, a missing |
991 | .Pa .meta | | 988 | .Pa .meta |
| @@ -1140,27 +1137,27 @@ and | | | @@ -1140,27 +1137,27 @@ and |
1140 | to the path of the meta file (if any) describing the failed target. | | 1137 | to the path of the meta file (if any) describing the failed target. |
1141 | It then prints its name and the value of | | 1138 | It then prints its name and the value of |
1142 | .Sq Va .CURDIR | | 1139 | .Sq Va .CURDIR |
1143 | as well as the value of any variables named in | | 1140 | as well as the value of any variables named in |
1144 | .Sq Va MAKE_PRINT_VAR_ON_ERROR . | | 1141 | .Sq Va MAKE_PRINT_VAR_ON_ERROR . |
1145 | .It Va .newline | | 1142 | .It Va .newline |
1146 | This variable is simply assigned a newline character as its value. | | 1143 | This variable is simply assigned a newline character as its value. |
1147 | This allows expansions using the | | 1144 | This allows expansions using the |
1148 | .Cm \&:@ | | 1145 | .Cm \&:@ |
1149 | modifier to put a newline between | | 1146 | modifier to put a newline between |
1150 | iterations of the loop rather than a space. | | 1147 | iterations of the loop rather than a space. |
1151 | For example, the printing of | | 1148 | For example, the printing of |
1152 | .Sq Va MAKE_PRINT_VAR_ON_ERROR | | 1149 | .Sq Va MAKE_PRINT_VAR_ON_ERROR |
1153 | could be done as ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v:Q}'${.newline}@}. | | 1150 | could be done as ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}. |
1154 | .It Va .OBJDIR | | 1151 | .It Va .OBJDIR |
1155 | A path to the directory where the targets are built. | | 1152 | A path to the directory where the targets are built. |
1156 | Its value is determined by trying to | | 1153 | Its value is determined by trying to |
1157 | .Xr chdir 2 | | 1154 | .Xr chdir 2 |
1158 | to the following directories in order and using the first match: | | 1155 | to the following directories in order and using the first match: |
1159 | .Bl -enum | | 1156 | .Bl -enum |
1160 | .It | | 1157 | .It |
1161 | .Ev ${MAKEOBJDIRPREFIX}${.CURDIR} | | 1158 | .Ev ${MAKEOBJDIRPREFIX}${.CURDIR} |
1162 | .Pp | | 1159 | .Pp |
1163 | (Only if | | 1160 | (Only if |
1164 | .Sq Ev MAKEOBJDIRPREFIX | | 1161 | .Sq Ev MAKEOBJDIRPREFIX |
1165 | is set in the environment or on the command line.) | | 1162 | is set in the environment or on the command line.) |
1166 | .It | | 1163 | .It |
| @@ -1196,42 +1193,42 @@ changes to the specified directory if it | | | @@ -1196,42 +1193,42 @@ changes to the specified directory if it |
1196 | and | | 1193 | and |
1197 | .Sq Va PWD | | 1194 | .Sq Va PWD |
1198 | to that directory before executing any targets. | | 1195 | to that directory before executing any targets. |
1199 | .Pp | | 1196 | .Pp |
1200 | Except in the case of an explicit | | 1197 | Except in the case of an explicit |
1201 | .Sq Ic .OBJDIR | | 1198 | .Sq Ic .OBJDIR |
1202 | target, | | 1199 | target, |
1203 | .Nm | | 1200 | .Nm |
1204 | checks that the specified directory is writable and ignores it if not. | | 1201 | checks that the specified directory is writable and ignores it if not. |
1205 | This check can be skipped by setting the environment variable | | 1202 | This check can be skipped by setting the environment variable |
1206 | .Sq Ev MAKE_OBJDIR_CHECK_WRITABLE | | 1203 | .Sq Ev MAKE_OBJDIR_CHECK_WRITABLE |
1207 | to "no". | | 1204 | to "no". |
1208 | .It Va .PARSEDIR | | 1205 | .It Va .PARSEDIR |
1209 | A path to the directory of the current makefile being parsed. | | 1206 | The directory name of the current makefile being parsed. |
1210 | .It Va .PARSEFILE | | 1207 | .It Va .PARSEFILE |
1211 | The basename of the current makefile being parsed. | | 1208 | The basename of the current makefile being parsed. |
1212 | This variable and | | 1209 | This variable and |
1213 | .Sq Va .PARSEDIR | | 1210 | .Sq Va .PARSEDIR |
1214 | are both set only while the makefiles are being parsed. | | 1211 | are both set only while the makefiles are being parsed. |
1215 | If you want to retain their current values, assign them to a variable | | 1212 | To retain their current values, |
1216 | using assignment with expansion | | 1213 | assign them to a variable using assignment with expansion |
1217 | .Sq Cm \&:= . | | 1214 | .Sq Cm \&:= . |
1218 | .It Va .PATH | | 1215 | .It Va .PATH |
1219 | The space-separated list of directories that | | 1216 | The space-separated list of directories that |
1220 | .Nm | | 1217 | .Nm |
1221 | searches for files. | | 1218 | searches for files. |
1222 | The search list should be updated using the target | | 1219 | To update this search list, use the special target |
1223 | .Sq Ic .PATH | | 1220 | .Sq Ic .PATH |
1224 | rather than the variable. | | 1221 | rather than modifying the variable directly. |
1225 | .It Va PWD | | 1222 | .It Va PWD |
1226 | Alternate path to the current directory. | | 1223 | Alternate path to the current directory. |
1227 | .Nm | | 1224 | .Nm |
1228 | normally sets | | 1225 | normally sets |
1229 | .Sq Va .CURDIR | | 1226 | .Sq Va .CURDIR |
1230 | to the canonical path given by | | 1227 | to the canonical path given by |
1231 | .Xr getcwd 3 . | | 1228 | .Xr getcwd 3 . |
1232 | However, if the environment variable | | 1229 | However, if the environment variable |
1233 | .Sq Ev PWD | | 1230 | .Sq Ev PWD |
1234 | is set and gives a path to the current directory, | | 1231 | is set and gives a path to the current directory, |
1235 | .Nm | | 1232 | .Nm |
1236 | sets | | 1233 | sets |
1237 | .Sq Va .CURDIR | | 1234 | .Sq Va .CURDIR |
| @@ -1248,29 +1245,29 @@ is set to the value of | | | @@ -1248,29 +1245,29 @@ is set to the value of |
1248 | .Sq Va .OBJDIR | | 1245 | .Sq Va .OBJDIR |
1249 | for all programs which | | 1246 | for all programs which |
1250 | .Nm | | 1247 | .Nm |
1251 | executes. | | 1248 | executes. |
1252 | .It Va .SHELL | | 1249 | .It Va .SHELL |
1253 | The pathname of the shell used to run target scripts. | | 1250 | The pathname of the shell used to run target scripts. |
1254 | It is read-only. | | 1251 | It is read-only. |
1255 | .It Va .SUFFIXES | | 1252 | .It Va .SUFFIXES |
1256 | The list of known suffixes. | | 1253 | The list of known suffixes. |
1257 | It is read-only. | | 1254 | It is read-only. |
1258 | .It Va .TARGETS | | 1255 | .It Va .TARGETS |
1259 | The list of targets explicitly specified on the command line, if any. | | 1256 | The list of targets explicitly specified on the command line, if any. |
1260 | .It Va VPATH | | 1257 | .It Va VPATH |
1261 | Colon-separated | | 1258 | The colon-separated |
1262 | .Pq Dq \&: | | 1259 | .Pq Dq \&: |
1263 | lists of directories that | | 1260 | list of directories that |
1264 | .Nm | | 1261 | .Nm |
1265 | searches for files. | | 1262 | searches for files. |
1266 | The variable is supported for compatibility with old make programs only, | | 1263 | The variable is supported for compatibility with old make programs only, |
1267 | use | | 1264 | use |
1268 | .Sq Va .PATH | | 1265 | .Sq Va .PATH |
1269 | instead. | | 1266 | instead. |
1270 | .El | | 1267 | .El |
1271 | .Ss Variable modifiers | | 1268 | .Ss Variable modifiers |
1272 | The general format of a variable expansion is: | | 1269 | The general format of a variable expansion is: |
1273 | .Pp | | 1270 | .Pp |
1274 | .Sm off | | 1271 | .Sm off |
1275 | .D1 Ic \&${ Ar variable\| Oo Ic \&: Ar modifier\| Oo Ic \&: Ar ... Oc Oc Ic \&} | | 1272 | .D1 Ic \&${ Ar variable\| Oo Ic \&: Ar modifier\| Oo Ic \&: Ar ... Oc Oc Ic \&} |
1276 | .Sm on | | 1273 | .Sm on |
| @@ -1287,27 +1284,26 @@ A list of indirect modifiers can be spec | | | @@ -1287,27 +1284,26 @@ A list of indirect modifiers can be spec |
1287 | .Ic \&${ Ar variable Ic \&:${ Ar modifier_variable Ic \&} Oo Ic \&: Ar ... Oc Ic \&} | | 1284 | .Ic \&${ Ar variable Ic \&:${ Ar modifier_variable Ic \&} Oo Ic \&: Ar ... Oc Ic \&} |
1288 | .Sm on | | 1285 | .Sm on |
1289 | .Ed | | 1286 | .Ed |
1290 | .Pp | | 1287 | .Pp |
1291 | In this case, the first modifier in the | | 1288 | In this case, the first modifier in the |
1292 | .Ar modifier_variable | | 1289 | .Ar modifier_variable |
1293 | does not start with a colon, | | 1290 | does not start with a colon, |
1294 | since that colon already occurs in the referencing variable. | | 1291 | since that colon already occurs in the referencing variable. |
1295 | If any of the modifiers in the | | 1292 | If any of the modifiers in the |
1296 | .Ar modifier_variable | | 1293 | .Ar modifier_variable |
1297 | contains a dollar sign | | 1294 | contains a dollar sign |
1298 | .Pq Ql $ , | | 1295 | .Pq Ql $ , |
1299 | these must be doubled to avoid early expansion. | | 1296 | these must be doubled to avoid early expansion. |
1300 | .\" XXX: This is only close to the truth, see the table in varmod.mk. | | | |
1301 | .Pp | | 1297 | .Pp |
1302 | Some modifiers interpret the expression value as a single string, | | 1298 | Some modifiers interpret the expression value as a single string, |
1303 | others treat the expression value as a whitespace-separated list of words. | | 1299 | others treat the expression value as a whitespace-separated list of words. |
1304 | When splitting a string into words, | | 1300 | When splitting a string into words, |
1305 | whitespace can be escaped using double quotes, single quotes and backslashes, | | 1301 | whitespace can be escaped using double quotes, single quotes and backslashes, |
1306 | like in the shell. | | 1302 | like in the shell. |
1307 | The quotes and backslashes are retained in the words. | | 1303 | The quotes and backslashes are retained in the words. |
1308 | .Pp | | 1304 | .Pp |
1309 | The supported modifiers are: | | 1305 | The supported modifiers are: |
1310 | .Bl -tag -width EEE | | 1306 | .Bl -tag -width EEE |
1311 | .It Cm \&:E | | 1307 | .It Cm \&:E |
1312 | Replaces each word in the variable with its suffix. | | 1308 | Replaces each word in the variable with its suffix. |
1313 | .It Cm \&:H | | 1309 | .It Cm \&:H |
| @@ -1410,34 +1406,34 @@ value is not provided or is 0, the curre | | | @@ -1410,34 +1406,34 @@ value is not provided or is 0, the curre |
1410 | .It Cm \&:hash | | 1406 | .It Cm \&:hash |
1411 | Computes a 32-bit hash of the value and encodes it as 8 hex digits. | | 1407 | Computes a 32-bit hash of the value and encodes it as 8 hex digits. |
1412 | .It Cm \&:localtime Ns Oo Cm = Ns Ar timestamp Oc | | 1408 | .It Cm \&:localtime Ns Oo Cm = Ns Ar timestamp Oc |
1413 | The value is interpreted as a format string for | | 1409 | The value is interpreted as a format string for |
1414 | .Xr strftime 3 , | | 1410 | .Xr strftime 3 , |
1415 | using | | 1411 | using |
1416 | .Xr localtime 3 , | | 1412 | .Xr localtime 3 , |
1417 | producing the formatted timestamp. | | 1413 | producing the formatted timestamp. |
1418 | If a | | 1414 | If a |
1419 | .Ar timestamp | | 1415 | .Ar timestamp |
1420 | value is not provided or is 0, the current time is used. | | 1416 | value is not provided or is 0, the current time is used. |
1421 | .It Cm \&:tA | | 1417 | .It Cm \&:tA |
1422 | Attempts to convert the value to an absolute path using | | 1418 | Attempts to convert the value to an absolute path using |
1423 | .Xr realpath 3 , | | 1419 | .Xr realpath 3 . |
1424 | if that fails, the value is unchanged. | | 1420 | If that fails, the value is unchanged. |
1425 | .It Cm \&:tl | | 1421 | .It Cm \&:tl |
1426 | Converts the value to lower-case letters. | | 1422 | Converts the value to lower-case letters. |
1427 | .It Cm \&:ts Ns Ar c | | 1423 | .It Cm \&:ts Ns Ar c |
1428 | When joining the words after a modifier that treats the value as words, | | 1424 | When joining the words after a modifier that treats the value as words, |
1429 | the words are normally separated by a space. | | 1425 | the words are normally separated by a space. |
1430 | This modifier sets the separator to the character | | 1426 | This modifier changes the separator to the character |
1431 | .Ar c . | | 1427 | .Ar c . |
1432 | If | | 1428 | If |
1433 | .Ar c | | 1429 | .Ar c |
1434 | is omitted, no separator is used. | | 1430 | is omitted, no separator is used. |
1435 | The common escapes (including octal numeric codes) work as expected. | | 1431 | The common escapes (including octal numeric codes) work as expected. |
1436 | .It Cm \&:tu | | 1432 | .It Cm \&:tu |
1437 | Converts the value to upper-case letters. | | 1433 | Converts the value to upper-case letters. |
1438 | .It Cm \&:tW | | 1434 | .It Cm \&:tW |
1439 | Causes subsequent modifiers to treat the value as a single word | | 1435 | Causes subsequent modifiers to treat the value as a single word |
1440 | (possibly containing embedded whitespace). | | 1436 | (possibly containing embedded whitespace). |
1441 | See also | | 1437 | See also |
1442 | .Sq Cm \&:[*] . | | 1438 | .Sq Cm \&:[*] . |
1443 | .It Cm \&:tw | | 1439 | .It Cm \&:tw |
| @@ -1620,28 +1616,28 @@ This is the loop expansion mechanism fro | | | @@ -1620,28 +1616,28 @@ This is the loop expansion mechanism fro |
1620 | Environment (ODE) make. | | 1616 | Environment (ODE) make. |
1621 | Unlike | | 1617 | Unlike |
1622 | .Cm \&.for | | 1618 | .Cm \&.for |
1623 | loops, expansion occurs at the time of reference. | | 1619 | loops, expansion occurs at the time of reference. |
1624 | For each word in the value, assign the word to the variable named | | 1620 | For each word in the value, assign the word to the variable named |
1625 | .Ar varname | | 1621 | .Ar varname |
1626 | and evaluate | | 1622 | and evaluate |
1627 | .Ar string . | | 1623 | .Ar string . |
1628 | The ODE convention is that | | 1624 | The ODE convention is that |
1629 | .Ar varname | | 1625 | .Ar varname |
1630 | should start and end with a period, for example: | | 1626 | should start and end with a period, for example: |
1631 | .Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@} | | 1627 | .Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@} |
1632 | .Pp | | 1628 | .Pp |
1633 | However, a single-character variable is often more readable: | | 1629 | However, a single-letter variable is often more readable: |
1634 | .Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v:Q}'${.newline}@} | | 1630 | .Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@} |
1635 | .It Cm \&:_ Ns Oo Cm = Ns Ar var Oc | | 1631 | .It Cm \&:_ Ns Oo Cm = Ns Ar var Oc |
1636 | Saves the current variable value in | | 1632 | Saves the current variable value in |
1637 | .Ql $_ | | 1633 | .Ql $_ |
1638 | or the named | | 1634 | or the named |
1639 | .Ar var | | 1635 | .Ar var |
1640 | for later reference. | | 1636 | for later reference. |
1641 | Example usage: | | 1637 | Example usage: |
1642 | .Bd -literal -offset indent | | 1638 | .Bd -literal -offset indent |
1643 | M_cmpv.units = 1 1000 1000000 | | 1639 | M_cmpv.units = 1 1000 1000000 |
1644 | M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \&\\ | | 1640 | M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \&\\ |
1645 | \\* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh | | 1641 | \\* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh |
1646 | | | 1642 | |
1647 | .Dv .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}} | | 1643 | .Dv .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}} |
| @@ -1663,48 +1659,43 @@ It is handy for setting per-target CFLAG | | | @@ -1663,48 +1659,43 @@ It is handy for setting per-target CFLAG |
1663 | .Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}} | | 1659 | .Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}} |
1664 | If a value is only required if the variable is undefined, use: | | 1660 | If a value is only required if the variable is undefined, use: |
1665 | .Dl ${VAR:D:Unewval} | | 1661 | .Dl ${VAR:D:Unewval} |
1666 | .It Cm \&:D\| Ns Ar newval | | 1662 | .It Cm \&:D\| Ns Ar newval |
1667 | If the variable is defined, | | 1663 | If the variable is defined, |
1668 | .Ar newval | | 1664 | .Ar newval |
1669 | is the value. | | 1665 | is the value. |
1670 | .It Cm \&:L | | 1666 | .It Cm \&:L |
1671 | The name of the variable is the value. | | 1667 | The name of the variable is the value. |
1672 | .It Cm \&:P | | 1668 | .It Cm \&:P |
1673 | The path of the node which has the same name as the variable is the value. | | 1669 | The path of the node which has the same name as the variable is the value. |
1674 | If no such node exists or its path is null, the name of the variable is used. | | 1670 | If no such node exists or its path is null, the name of the variable is used. |
1675 | In order for this modifier to work, the name (node) must at least have | | 1671 | In order for this modifier to work, the name (node) must at least have |
1676 | appeared on the rhs of a dependency. | | 1672 | appeared on the right-hand side of a dependency. |
1677 | .Sm off | | 1673 | .Sm off |
1678 | .It Cm \&:\&! Ar cmd\| Cm \&! | | 1674 | .It Cm \&:\&! Ar cmd\| Cm \&! |
1679 | .Sm on | | 1675 | .Sm on |
1680 | The output of running | | 1676 | The output of running |
1681 | .Ar cmd | | 1677 | .Ar cmd |
1682 | is the value. | | 1678 | is the value. |
1683 | .It Cm \&:sh | | 1679 | .It Cm \&:sh |
1684 | If the variable is non-empty, it is run as a command and the output | | 1680 | The value is run as a command, and the output becomes the new value. |
1685 | becomes the new value. | | | |
1686 | .It Cm \&::= Ns Ar str | | 1681 | .It Cm \&::= Ns Ar str |
1687 | The variable is assigned the value | | 1682 | The variable is assigned the value |
1688 | .Ar str | | 1683 | .Ar str |
1689 | after substitution. | | 1684 | after substitution. |
1690 | This modifier and its variations are useful in obscure situations | | 1685 | This modifier and its variations are useful in obscure situations |
1691 | such as wanting to set a variable when shell commands are being parsed. | | 1686 | such as wanting to set a variable |
1692 | These assignment modifiers always expand to nothing, | | 1687 | at a point where a target's shell commands are being parsed. |
1693 | so if they appear in a rule line by themselves, | | 1688 | These assignment modifiers always expand to nothing. |
1694 | they should be preceded with something, | | | |
1695 | to keep | | | |
1696 | .Nm | | | |
1697 | happy. | | | |
1698 | .Pp | | 1689 | .Pp |
1699 | The | | 1690 | The |
1700 | .Sq Cm \&:: | | 1691 | .Sq Cm \&:: |
1701 | helps avoid false matches with the | | 1692 | helps avoid false matches with the |
1702 | .At V | | 1693 | .At V |
1703 | style | | 1694 | style |
1704 | .Cm \&:= | | 1695 | .Cm \&:= |
1705 | modifier and since substitution always occurs, the | | 1696 | modifier and since substitution always occurs, the |
1706 | .Cm \&::= | | 1697 | .Cm \&::= |
1707 | form is vaguely appropriate. | | 1698 | form is vaguely appropriate. |
1708 | .It Cm \&::?= Ns Ar str | | 1699 | .It Cm \&::?= Ns Ar str |
1709 | As for | | 1700 | As for |
1710 | .Cm \&::= | | 1701 | .Cm \&::= |
| @@ -1948,27 +1939,26 @@ End the body of the conditional. | | | @@ -1948,27 +1939,26 @@ End the body of the conditional. |
1948 | .El | | 1939 | .El |
1949 | .Pp | | 1940 | .Pp |
1950 | The | | 1941 | The |
1951 | .Ar operator | | 1942 | .Ar operator |
1952 | may be any one of the following: | | 1943 | may be any one of the following: |
1953 | .Bl -tag -width "Cm XX" | | 1944 | .Bl -tag -width "Cm XX" |
1954 | .It Cm \&|\&| | | 1945 | .It Cm \&|\&| |
1955 | Logical OR. | | 1946 | Logical OR. |
1956 | .It Cm \&&& | | 1947 | .It Cm \&&& |
1957 | Logical AND; of higher precedence than | | 1948 | Logical AND; of higher precedence than |
1958 | .Dq \&|\&| . | | 1949 | .Dq \&|\&| . |
1959 | .El | | 1950 | .El |
1960 | .Pp | | 1951 | .Pp |
1961 | As in C, | | | |
1962 | .Nm | | 1952 | .Nm |
1963 | only evaluates a conditional as far as is necessary to determine its value. | | 1953 | only evaluates a conditional as far as is necessary to determine its value. |
1964 | Parentheses can be used to override the operator precedence. | | 1954 | Parentheses can be used to override the operator precedence. |
1965 | The boolean operator | | 1955 | The boolean operator |
1966 | .Sq Ic \&! | | 1956 | .Sq Ic \&! |
1967 | may be used to logically negate an entire | | 1957 | may be used to logically negate an entire |
1968 | conditional. | | 1958 | conditional. |
1969 | It is of higher precedence than | | 1959 | It is of higher precedence than |
1970 | .Sq Ic \&&& . | | 1960 | .Sq Ic \&&& . |
1971 | .Pp | | 1961 | .Pp |
1972 | The value of | | 1962 | The value of |
1973 | .Ar expression | | 1963 | .Ar expression |
1974 | may be any of the following: | | 1964 | may be any of the following: |
| @@ -2017,51 +2007,51 @@ Numeric comparisons may also use the ope | | | @@ -2017,51 +2007,51 @@ Numeric comparisons may also use the ope |
2017 | .Sq Ic \&< , | | 2007 | .Sq Ic \&< , |
2018 | .Sq Ic \&<= , | | 2008 | .Sq Ic \&<= , |
2019 | .Sq Ic \&> | | 2009 | .Sq Ic \&> |
2020 | and | | 2010 | and |
2021 | .Sq Ic \&>= . | | 2011 | .Sq Ic \&>= . |
2022 | .Pp | | 2012 | .Pp |
2023 | If the comparison has neither a comparison operator nor a right side, | | 2013 | If the comparison has neither a comparison operator nor a right side, |
2024 | the expression evaluates to true if it is nonempty | | 2014 | the expression evaluates to true if it is nonempty |
2025 | and its numeric value (if any) is not zero. | | 2015 | and its numeric value (if any) is not zero. |
2026 | .Pp | | 2016 | .Pp |
2027 | When | | 2017 | When |
2028 | .Nm | | 2018 | .Nm |
2029 | is evaluating one of these conditional expressions, and it encounters | | 2019 | is evaluating one of these conditional expressions, and it encounters |
2030 | a (white-space separated) word it doesn't recognize, either the | | 2020 | a (whitespace separated) word it doesn't recognize, either the |
2031 | .Dq make | | 2021 | .Dq make |
2032 | or | | 2022 | or |
2033 | .Dq defined | | 2023 | .Dq defined |
2034 | expression is applied to it, depending on the form of the conditional. | | 2024 | function is applied to it, depending on the form of the conditional. |
2035 | If the form is | | 2025 | If the form is |
2036 | .Sq Ic .ifdef , | | 2026 | .Sq Ic .ifdef , |
2037 | .Sq Ic .ifndef , | | 2027 | .Sq Ic .ifndef |
2038 | or | | 2028 | or |
2039 | .Sq Ic .if | | 2029 | .Sq Ic .if , |
2040 | the | | 2030 | the |
2041 | .Dq defined | | 2031 | .Dq defined |
2042 | expression is applied. | | 2032 | function is applied. |
2043 | Similarly, if the form is | | 2033 | Similarly, if the form is |
2044 | .Sq Ic .ifmake | | 2034 | .Sq Ic .ifmake |
2045 | or | | 2035 | or |
2046 | .Sq Ic .ifnmake , | | 2036 | .Sq Ic .ifnmake , |
2047 | the | | 2037 | the |
2048 | .Dq make | | 2038 | .Dq make |
2049 | expression is applied. | | 2039 | function is applied. |
2050 | .Pp | | 2040 | .Pp |
2051 | If the conditional evaluates to true the parsing of the makefile continues | | 2041 | If the conditional evaluates to true, |
2052 | as before. | | 2042 | parsing of the makefile continues as before. |
2053 | If it evaluates to false, the following lines are skipped. | | 2043 | If it evaluates to false, the following lines are skipped. |
2054 | In both cases this continues until a | | 2044 | In both cases, this continues until the corresponding |
2055 | .Sq Ic .else | | 2045 | .Sq Ic .else |
2056 | or | | 2046 | or |
2057 | .Sq Ic .endif | | 2047 | .Sq Ic .endif |
2058 | is found. | | 2048 | is found. |
2059 | .Pp | | 2049 | .Pp |
2060 | For loops are typically used to apply a set of rules to a list of files. | | 2050 | For loops are typically used to apply a set of rules to a list of files. |
2061 | The syntax of a for loop is: | | 2051 | The syntax of a for loop is: |
2062 | .Pp | | 2052 | .Pp |
2063 | .Bl -tag -compact -width Ds | | 2053 | .Bl -tag -compact -width Ds |
2064 | .It Ic \&.for Ar variable Oo Ar variable ... Oc Ic in Ar expression | | 2054 | .It Ic \&.for Ar variable Oo Ar variable ... Oc Ic in Ar expression |
2065 | .It Aq make-lines | | 2055 | .It Aq make-lines |
2066 | .It Ic \&.endfor | | 2056 | .It Ic \&.endfor |
2067 | .El | | 2057 | .El |