Indiana University Bloomington

School of Informatics and Computing


Computer Science Program







 Home

 Contacts

 Courses

 Academics

 Careers

 Research

 People

 Calendar

 Resources

 Facilities
   FAQ
   System Notices
   Help
   Hardware
   Software
   Network
   Policies
   Lindley Hall

"Make" Utility Basics

1.) Why Use a Make Utility

Using the GUI provided in the mon68k or sim68k tool works well for projects that can be built with a relatively small number of files (2 or 3 max).  When the number of files in the build gets larger, switching over to using a "make" utility will generally save time.  One of the main benefits of using a "make" utility is that the make utility will keep track of dependencies between your files and rebuild only the files that need to be rebuilt. For example, if you have a program that is broken up among 5 files, you change 2 files, and then you want to rebuild the program, the "make" utility will check the time/date stamp on each of the files, determine that two are out of date, re-assemble the two modified files, and then re-link the application.

Both the GNU make utility "make" and the Microsoft make utility "nmake" are loaded on the machines in the lab. There are a few differences, but the utilities have basically the same function. Both utilities are in the path on lab machines in LH035.

2.) Makefile Construction

The make utility is dependent on a file called a "makefile" to define the dependencies between the files in your application.  When you invoke make (GNU) or nmake (Microsoft), the utility looks for a file named makefile in the current directory by default. If the name of the makefile is other than this, you can pass it as a command line argument to the make utility. Below is an example of the contents of a simple makefile.

drv_main.o: drv_main.s
     drv_main.s -o drv_main.o

This line can be described more generally by the following:

target:dependency
     command to execute if a comparison of the target and the dependencies indicate that  the target is out of date.

In the case of the above example with drv_main, if drv_main.s is younger than drv_main.o (ie. it has been edited), the command " drv_main.s -o drv_main.o" will cause the assembler to rebuild drv_main.o to bring it up to date. "" is just a string replacement mechanism for the make utility. The variables get replaced with a string defined in the makefile like "FOO = foobar". In this case, gets replaced by as68000 (SDS assembler) and gets replaced by the different assembler flags.

Note: For the GNU "make" utility, the white space in front of the command to execute must be a <tab>. For the "nmake" utility, spaced will also work.  I have been using nmake to build my programs, so my examples will have spaces before the command. Change these to a <tab> if you want to use GNU make.

3.) For More Info ....

You can use the unix man page for make. If you want to do more complex things with the make utility, there is also a book out on just this utility. I have not personally read this book.  Here is a URL to where you can purchase the book.  Link to Publisher of Make Utility Book

3.) Example

Here is an example of a simple makefile.
 makefile (1k)

# Makefile to build the IDP68040 application "motor_drv"
# Bryce Himebaugh 9/20/99

# set up define statements for the SDS assembler and linker then setup the flags for the tools.
AS = as68000
LK = linker
AFLAGS= -V 40 -o list= -s -x -f
LKFLAGS = -f link.spc -L d:\sds74\lib68040

all: drv.out

drv_main.o: drv_main.s
     drv_main.s -o drv_main.o

global.o: global.s
     global.s -o global.o

mctrl.o: mctrl.s
     mctrl.s -o mctrl.o

wspd.o: wspd.s
     wspd.s -o wspd.o

schedule.o: schedule.s
    schedule.s -o schedule.o

timer.o: timer.s
     timer.s -o timer.o

pwm.o: pwm.s
     pwm.s -o pwm.o

vector.o: vector.s
     vector.s -o vector.o

drv.out: drv_main.o global.o wspd.o schedule.o timer.o pwm.o vector.o mctrl.o in_file.spc link.spc
     -o drv.out -F in_file.spc
 
 
 
 
 
 
 
 
 
 








Valid HTML 4.01!