diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/gnu_make/utilities-in-makefiles.html | |
new repository
Diffstat (limited to 'devdocs/gnu_make/utilities-in-makefiles.html')
| -rw-r--r-- | devdocs/gnu_make/utilities-in-makefiles.html | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/devdocs/gnu_make/utilities-in-makefiles.html b/devdocs/gnu_make/utilities-in-makefiles.html new file mode 100644 index 00000000..60dd10c0 --- /dev/null +++ b/devdocs/gnu_make/utilities-in-makefiles.html @@ -0,0 +1,17 @@ + <h1 class="section">Utilities in Makefiles</h1> <p>Write the Makefile commands (and any shell scripts, such as <code>configure</code>) to run under <code>sh</code> (both the traditional Bourne shell and the <small>POSIX</small> shell), not <code>csh</code>. Don’t use any special features of <code>ksh</code> or <code>bash</code>, or <small>POSIX</small> features not widely supported in traditional Bourne <code>sh</code>. </p> <p>The <code>configure</code> script and the Makefile rules for building and installation should not use any utilities directly except these: </p> <div class="example"> <pre class="example">awk cat cmp cp diff echo egrep expr false grep install-info ln ls +mkdir mv printf pwd rm rmdir sed sleep sort tar test touch tr true +</pre> +</div> <p>Compression programs such as <code>gzip</code> can be used in the <code>dist</code> rule. </p> <p>Generally, stick to the widely-supported (usually <small>POSIX</small>-specified) options and features of these programs. For example, don’t use ‘<samp>mkdir -p</samp>’, convenient as it may be, because a few systems don’t support it at all and with others, it is not safe for parallel execution. For a list of known incompatibilities, see <a href="https://www.gnu.org/software/autoconf/manual/html_node/Portable-Shell.html#Portable-Shell">Portable Shell Programming</a> in <cite>Autoconf</cite>. </p> <p>It is a good idea to avoid creating symbolic links in makefiles, since a few file systems don’t support them. </p> <p>The Makefile rules for building and installation can also use compilers and related programs, but should do so via <code>make</code> variables so that the user can substitute alternatives. Here are some of the programs we mean: </p> <div class="example"> <pre class="example">ar bison cc flex install ld ldconfig lex +make makeinfo ranlib texi2dvi yacc +</pre> +</div> <p>Use the following <code>make</code> variables to run those programs: </p> <div class="example"> <pre class="example">$(AR) $(BISON) $(CC) $(FLEX) $(INSTALL) $(LD) $(LDCONFIG) $(LEX) +$(MAKE) $(MAKEINFO) $(RANLIB) $(TEXI2DVI) $(YACC) +</pre> +</div> <p>When you use <code>ranlib</code> or <code>ldconfig</code>, you should make sure nothing bad happens if the system does not have the program in question. Arrange to ignore an error from that command, and print a message before the command to tell the user that failure of this command does not mean a problem. (The Autoconf ‘<samp>AC_PROG_RANLIB</samp>’ macro can help with this.) </p> <p>If you use symbolic links, you should implement a fallback for systems that don’t have symbolic links. </p> <p>Additional utilities that can be used via Make variables are: </p> <div class="example"> <pre class="example">chgrp chmod chown mknod +</pre> +</div> <p>It is ok to use other utilities in Makefile portions (or scripts) intended only for particular systems where you know those utilities exist. </p><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 Free Software Foundation, Inc. <br>Licensed under the GNU Free Documentation License.<br> + <a href="https://www.gnu.org/software/make/manual/html_node/Utilities-in-Makefiles.html" class="_attribution-link">https://www.gnu.org/software/make/manual/html_node/Utilities-in-Makefiles.html</a> + </p> +</div> |
