Managing Projects with GNU Make (Nutshell Handbooks)

     

When make needs to pass a command line to a subshell, it uses /bin/sh . You can change the shell by setting the make variable SHELL . Think carefully before doing this. Usually, the purpose of using make is to provide a tool for a community of developers to build a system from its source components . It is quite easy to create a makefile that fails in this goal by using tools that are not available or assumptions that are not true for other developers in the community. It is considered very bad form to use any shell other than /bin/sh in any widely distributed application (one distributed via anonymous ftp or open cvs). We'll discuss portability in more detail in Chapter 7.

There is another context for using make , however. Often, in closed development environments, the developers are working on a limited set of machines and operating systems with an approved group of developers. In fact, this is the environment I've most often found myself in. In this situation, it can make perfect sense to customize the environment make is expected to run under. Developers are instructed in how to set up their environment to work properly with the build and life goes on.

In environments such as this, I prefer to make some portability sacrifices "up front." I believe this can make the entire development process go much more smoothly. One such sacrifice is to explicitly set the SHELL variable to /usr/bin/bash . The bash shell is a portable, POSIX-compliant shell (and, therefore, a superset of sh ) and is the standard shell on GNU/Linux. Many portability problems in makefile s are due to using nonportable constructs in command scripts. This can be solved by explicitly using one standard shell rather than writing to the portable subset of sh . Paul Smith, the maintainer of GNU make , has a web page "Paul's Rules of Makefiles" (http://make.paulandlesley.org/rules.html) on which he states, "Don't hassle with writing portable makefiles, use a portable make instead!" I would also say, "Where possible, don't hassle with writing portable command scripts, use a portable shell (bash) instead." The bash shell runs on most operating systems including virtually all variants of Unix, Windows, BeOS, Amiga, and OS/2.

For the remainder of this book, I will note when a command script uses bash-specific features.

Категории