Home > Articles > Programming

This chapter is from the book

Praise and Criticism

Having been around for more than 30 years, the Make tool (GNU Make being a modern version) has had plenty of opportunity to gather praise and criticism. Clearly, Make offers many benefits; otherwise, it would no longer be the most popular tool for C/C++ development. On the other hand, plenty of empirical experience has shown that Make has a number of flaws.

Let's now review what users of Make have been saying. The following comments were either found on Internet web sites, published in books, or gathered via personal experience.

Praise

  • Wide support: Make (particularly GNU Make) is widely supported on a large number of operating systems. Most software engineers have at least a passing knowledge of makefile construction, and quite a few people consider themselves to be makefile experts. Part of this widespread knowledge results from universities teaching Make as a standard build tool. The significant number of legacy build systems using Make is also a contributing factor.

    If you were starting a new software project, the fact that so many developers are already familiar with Make would likely convince you to use the same tool again. In addition, numerous Make-related tools (such as automatic makefile generators, automatic parallelization tools, and makefile editors) are available either commercially or for free. Make is clearly the best-supported build tool, at least for C/C++ development.

  • Very fast tool: Being written in C, GNU Make is fast and highly optimized. Compared to other tools, GNU Make is extremely fast for computing and traversing the dependency graph. As a side note, some people counter this benefit by questioning whether speed is important if accuracy of the tool's dependency information can't be guaranteed.
  • Portable syntax: GNU Make has a portable syntax and is available on a wide range of platforms, including Microsoft Windows. Before the introduction of GNU Make, developers were required to write a makefile that was compatible with every operating system's variant of Make. They often were limited to using only the small subset of features that all Make implementations had in common. With GNU Make, the syntax is the same across all platforms, and you can use the entire set of the GNU Make's features.
  • Fully featured programming language: As a general-purpose dependency engine, Make can be used for any type of dependency analysis. As long as you can write a rule that maps input files to output files, there's no limit on the type of compilation you can perform. Whereas other build tools might focus on C, C++, Java, or C# compilation, Make enables you to compile any type of file (such as creating PDF files from TeX source).

    It's worth noting that GNU Make's language is Turing complete. This means that any program written in a general-purpose programming language can also be written as a GNU Make program. It would be incorrect to claim that "GNU Make can't do that" because any feature of any other build tool can be implemented in GNU Make. (Just ask a Make guru how it can be done.)

  • The first tool: Being the first build tool ever invented, Make paved the way for automated build systems. Newer tools would never have been able to improve on Make if it hadn't first demonstrated what was possible.

Criticism

On the flip slide, there are many criticisms of the Make tool to be aware of:

  • Inconsistent language design: GNU Make's language has clearly grown over time, and the design hasn't always stayed consistent. Some of the language features (such as rules) were part of the original Make design, but many other features were added over time as people found a need. In addition, the syntax for each of the features isn't always consistent with the syntax of other features. This makes the language difficult for new developers to learn.

    Some of the common concerns include the following:

    • When writing a makefile rule, the shell commands must be indented by a tab character instead of by spaces. This syntactical rule has impacted almost everyone, especially if their editor automatically converts tabs to spaces.
    • All makefile variables are global, so it can be challenging to determine where a variable is defined and whether you're conflicting with a different variable that accidentally has the same name.
    • Some parts of the makefile syntax ignore whitespace; in other parts, whitespace must be included.
    • It can be confusing to determine which parts of a makefile enable you to write shell commands and which parts enable GNU Make functions.
    • When invoking shell commands within a Make rule, you need to be familiar with the syntax of each command being invoked. Often a lot of inconsistency arises in the command-line arguments and return values each tool provides.
    • For developers familiar with procedural programming (sequencing, loops, conditionals, and function calls), it can be challenging to write GNU Make code. In particular, it's difficult to fit together the necessary shell commands, GNU Make functions, and user-defined macros to achieve the desired effect.

    As a result of these syntax and semantic issues, a number of additional tools such as Automake and CMake (see Chapter 9, "CMake") automatically generate a makefile from a higher-level description. This alleviates the need to learn the GNU Make syntax.

  • No standard framework: Although this chapter discussed using inclusive Make to solve a number of build system problems, no standard framework can be used as a starting point. GNU Make provides a powerful set of language features, but it wasn't designed to work out-of-the-box for large software projects. In particular, the following important features must be implemented by hand:
    • Automatic dependency analysis for common languages such as C/C++. Without a good dependency system, the chance of introducing build failures is much higher.
    • Multidirectory support with a single dependency graph for the whole build tree.
    • C compiler flags that can be set on a per-directory or per-file basis.
    • A mechanism for rebuilding object files if the C compiler flags are modified.
    • A mechanism for abstracting out values such as SRCS, SUBDIRS, and CFLAGS, as was done with the Files.mk fragments.
    Unfortunately, anybody using GNU Make is required to implement these features for themselves or perhaps borrow an existing framework from some other software project. In reality, it's common to see each project using an entirely different framework that grows over time as new features are required. None of this is easy work.
  • Lack of portability: Although GNU Make provides a consistent syntax across all operating systems, it's unlikely that the syntax of the shell commands will be consistent. Each operating system is free to store its standard tools (such as ls, cat, sed, and grep) in whichever directory it likes, and it's free to implement whichever optional tool features it desires. Even with modern versions of UNIX and Linux, some amount of inconsistency always seems to arise between shell commands.

    To make things easier, follow a couple good practices:

    • Use the standard GNU versions of command-line tools instead of the operating system's own version. This at least guarantees that command options are consistent.
    • Use makefile conditionals (such as ifdef SOLARIS) to select an appropriate tool or tool path that works on each operating system, and then use a variable to access the tool instead of hard-coding the name. For example, use $(RM) foo.o instead of rm foo.o.
  • Challenging debugging: Many developers find it difficult to follow Make's flow of control when filenames are being pattern-matched against rules. In contrast to most other programming languages, the flow of control isn't sequential. This means that the next rule to be triggered could be defined at any point within the makefile system, including built-in rules and those included in Files.mk fragments. Before the use of the GNU Make debugger (a recent creation), developers were left to interpret confusing errors messages or to scan through complex listings of the dependency graph.
  • Language completeness versus ease of use: Even though any general-purpose program can be implemented within the GNU Make programming environment, the real question is how much work needs to be done to make that happen. As you've seen already, constructing a complete GNU Make framework isn't trivial and requires the author to have "guru" status. The authors must have a perfect understanding of GNU Make's flow of control, as well as an intimate knowledge of GNU Make's syntax and built-in functions. Finally, they need to have a handful of clever tricks to convince GNU Make to perform certain operations that aren't officially supported.

    If you decide to create an inclusive Make framework for yourself, be prepared to devote a large amount of time (months, not weeks). You need to support your development team on an ongoing basis when it requests that new functionality be added. After all this work, you'll end up with a solid build system, but be prepared for average software engineers to not have any understanding of how it works. After all, many people never get beyond the much simpler recursive Make systems, even with all the associated problems.

Evaluation

To summarize the GNU Make tool, let's evaluate it against the build system quality measurements discussed in Chapter 1, "Build System Overview."

  • Convenience: Poor. As you've seen, creating a fully functioning build system is difficult. This includes the detection of implicit dependencies and the traversal of a full build tree. Although a simple makefile is quick and easy to construct, the tool is much less convenient for nontrivial build systems.
  • Correctness: Poor. Because of the poor level of convenience, GNU Make is notorious for not producing a correct build image. It's possible to guarantee a correct build, although the effort to do so can be enormous.
  • Performance: Excellent. GNU Make is written in optimized C code and has an efficient algorithm for dependency analysis. Compared to other build tools discussed in later chapters, GNU Make is extremely fast.
  • Scalability: Excellent. As with the performance criteria, GNU Make is highly scalable. The assumption is that you've already created a makefile framework that adequately supports multiple directories.

As a general rule, consider using GNU Make for legacy software that already uses a Make-based build system. However, if you're writing a new build system for C/C++ software, first consider using SCons (Chapter 8) or CMake (Chapter 9). If you're writing a build system for Java, consider using Ant (Chapter 7). For C# code, use MSBuild (discussed briefly in Chapter 7). If none of these tools meets your needs, especially for performance reasons, writing a new build system using GNU Make is a possibility.

Note that these evaluation criteria are subjective in nature, so your value judgment could be quite different.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020