Make

What is Make?

Make is a computer program that performs a series of tasks in an intelligent way.  It is used to compile documents, other computer programs, and is suitable for any serialised work flow where intermediate tasks may be complete and skipped or not complete and must be done.

What’s the big deal?

Make is used to build many computer systems.  But there isn’t just one Make,  They are similar (in that they all try to do the same job in the same way), but different in important ways (because they don’t).

The two I’d like to look at there are BSD Make as it appears on FreeBSD and GNU Make.

BSD Make

This is the default make on BSD systems.

BSD Make has the basic mechanisms.  It knows how to define a target, and how to define the dependencies to create that target.  It also has a macro language that allows symbols to be constructed and defined withing the execution of make.

The BSD Make system doesn’t know how to build any particular thing.  It must be instructed what to do.

The BSD approach to using make is to define a set of standard include files that define rules for specific tasks.  You then include the appropriate make file for your project.  And that’s it.  Your project knows how to do everything it needs to do on your system; install, uninstall, build, clean, archive …

GNU Make

This is the default make on GNU/Linux and current versions Mac OS;s XCode.

A GNU idel is to create Unix-like tools that are a little bit easier to use.  GNU Make is made a little easier to use by building in rules for compiling programs.  It knows how to compile Pascal, C, C++, Fortran, …, programs.

To see the built in rules, run:

make -p

The GNU approach initially seems helpful.  The makefile simply describes dependencies and GNU Make fills in the blanks.  The problem is it can’t know everything.  It can’t know how to install on differing systems for example.

The fix is a whole new set programs collectively know as AutoTools.  It has AutoConfig, AutoMake and LibTool.

AutoTools are required because GNU Make needs system specific instructions.  It needs the same instructions athat BSD Make gets from system specific

Examples

This example shows the makefiles for a simple project I have lying around.

BSDmakefile

#
# BSDmakefile
#
PROG_CXX = goodlistener
SRCS = main.cc config.cc dispatch.cc
MAN = goodlistener.1
MAKEOBJDIR = work
CXXFLAGS=-g

.include <bsd.prog.mk>

#
# GNU make file
#
CXX = -g

all: goodlistener

goodlistener: main.o config.o dispatch.o
    $(LINK.cc) -o $@ $^

A word on some oather make systems.

PMake

This can be BSD’s Parallel Make or Polytron’s Make.

Parallel Make is described here: http://www.freebsd.org/doc/en/books/pmake/

Polytron Make knew how to look into a PVCS (Polytron Version Control System) archive to decide whether a check out was required.

IMake

http://en.wikipedia.org/wiki/Imake

NMake

NMake was published by Microsoft Corporation and was commonly used on MS-DOS.  Visual Studio is the preferred build environment that Microsoft provide.

And first there was Unix

<brief history of Make from CSRG>

BSD Make

<overview of BSD Make

– makefile names: BSDmakefile, Makefile, makefile

– Rules thru system config files: See Art of Unix Programming http://www.catb.org/esr/writings/taoup/html/ch01s06.html#id2877777

– One target per directory

– A Sample project>

GNU Make

<Overview of FSF/GNU Philosophy

NOT UNIX

compatible but better tools

Better because of built in rules.

– How to see built in rules

– A Sample project>

Advertisements

~ by kbw333 on April 25, 2013.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: