Home Articles GNU Make Basics

GNU Make Basics

PDF Print E-mail

Build Engineers need to know a lot about different tools. You might think that having a strong understanding of Ant or Make will suffice, but the fact is that every now and then you may have to work with legacy build systems written using Makefiles. Make has been around a long time and used on many platforms. Now don't get the idea that GNU Make is a legacy tool itself. GNU Make has been and continues to be a modern and robust build tool.QuotationGNU Make has been and continues to be a modern and robust build tool.Quotation
If you want to be a qualified build engineer then this excellent tool must be in your skillset.


You can download a copy of GNU Make from the GNU website.

Getting Started

Makefiles contain directives that are generally of the form:

> target: dependency
>       commands       [1]

Let's start with a simple C++ program to print out hello world.
(If you are blind and trying to read this code via a reader then drop me an email and I will send it to you - This e-mail address is being protected from spambots. You need JavaScript enabled to view it . I used to be blind and glad to network with other blinks :-)

Simple c++ program

This code simply prints out the message "Hello World!".

Both Ant and Maven use XML, while Make uses directives in a slightly different format.

The Makefile to build this simple program looks like

Make Hello

(Hey if you are blind looking at this through a reader just send me an email and I will send you the code directly - This e-mail address is being protected from spambots. You need JavaScript enabled to view it )

Running the Makefile and viewing the results

Running the makefile

You will notice that Make created the hello executable (shown in green). The hello.o is a binary object file derived as an intermediate step from the hello.cpp (which is the source code shown above).

Here is an example of a Makefile with two dependencies. In this example, we will compile a C Language program [2].

Make example

In this example, Make first creates util.o from util.c and main.o from main.c. Next, Make links main.o and util.o to create the main executable.



[1] Managing Projects with GNU Make by Robert Mecklenburg, O'Reilly Media Inc., p. 4

[2] The C Programming Language by Brian Kernighan and Dennis Ritchie, Bell Telephone Laboratories, Inc. 1988

More articles by this author

Micro Focus Completes Acquisition of Serena Software, Inc. Application Lifecycle Management Acquisition Boosts Micro Focus’s DevOps Capability ROCKVILLE, Md., May 2, 2016 /PRNewswire/ -- Micro Focus (LSE: MCRO.L) today announced the completion of its acquisition of Serena Software, a leading provider of Application Lifecycle Management (ALM) software, under the terms of the definitive agreement disclosed on March 22, 2016. "Our customers continue to look at DevOps as a way to deploy critical applications and services quickly and with greater reliability to meet business demands," said Stephen Murdoch, CEO, Micro Focus. "The Serena acquisition extends our ability to help customers meet these challenges so they can drive greater innovation faster with lower risk." According to industry analyst firm Gartner, "DevOps implementations utilize technology, especially automation tools, that can leverage an increasingly programmable and dynamic infrastructure from a life cycle perspective."1  The experience and expertise which the Serena business brings will enable Micro Focus to help its customers develop and release applications and services faster, with greater speed and accuracy. Serena adds capabilities in software application development; software configuration and change management; and business process management to Micro Focus's portfolio of ALM solutions spanning mainframe environments, distributed systems and cloud. The combination of Micro Focus and Serena allows companies to better: Design and build business applications and services with greater accuracy, reliability and predictability; Continuously deploy existing core business applications on a wider variety of platforms to meet changing business needs; and Improve the speed and efficiency of new business services through automated release and deployment solutions. About Serena Software Serena is among the largest Application Lifecycle Management vendors with more than 2,500 enterprise customers. Serena helps the highly regulated large enterprise move fast without breaking things – increasing velocity of the software development lifecycle while enhancing security, compliance, and performance. More information is available at www.serena.com. About Micro Focus Micro Focus (LSE: MCRO.L) is a global enterprise software company helping customers innovate faster with lower risk. Our software helps customers build, operate and secure IT systems that bring together existing business logic and applications with emerging technologies to meet increasingly complex business demands. For more information, visit: www.microfocus.com. 1I&O Must Combine ITIL and DevOps to Deliver Business Value for Bimodal IT," by George Spafford and Ian Head, March 18, 2016.
Hi, I am excited to invite you to subscribe to our new online publication which provides guidance on Configuration Management Best Practices, Agile Application Lifecycle Management (including videos) and, of course DevOps. Our publication explains hands-on best practices required to implement just enough process to ensure that you can build software and systems that are reliable and secure. Based upon our new book, Agile Application Lifecycle Management - Using DevOps to Drive Process Improvement, the Agile ALM DevOps Journal seeks to promote a dialogue that is really needed in the industry today. We will discuss practical approaches to implementing the Agile ALM using DevOps best practices including continuous integration, delivery and deployment. We will also discuss process improvement strategies that work in large organizations that must comply with federal regulatory guidelines, along with smaller teams that may very well grow as they become successful. We are taking this journey together and our goal is to ensure that you have a voice and can share your experiences along with learning from other colleagues too. Enjoy Leslie Sachs's amazing column: Personality Matters and Bob Aiello's column: Behaviorally Speaking. We will also report on major incidents where organizations clearly need to improve on their ability to develop and deliver software effectively, including the recent Southwest systems glitches which resulted in thousands of flights being cancelled and thousands more being delayed. We will also bring you exciting technical product announcements such as jfrog's new xray, which helps to scan your runtime objects, including docker images, for vulnerabilities. This is an exciting time to be in the technology field. Join the revolution! You can submit your articles for publication to share your own knowledge and experience!  Subscribe to receive your copy and register so that you can comment online Bob Aiello http://www.linkedin.com/in/BobAiello @bobaiello, @agilealmdevops, @cmbestpractices This e-mail address is being protected from spambots. You need JavaScript enabled to view it  
Copyright © 2017 CM Best Practices. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.

Product News

Live Online Training