home *** CD-ROM | disk | FTP | other *** search
- MAKE: Brought to you by John Toebes and Jack Rouse of
-
- |_o_o|\\ The Dave Baker Ed Burnette
- |. o.| || Software Stan Chow Jay Denebeim
- | . | || Distillery Gordon Keener Jack Rouse
- | o | || John Toebes Doug Walker
- | . |//
- ====== BBS:(919)-471-6436 300/1200/2400
-
- US Snail:
- The Software Distillery
- 235 Trillingham Lane
- Cary, NC 27511
-
- USENET:
- mcnc!rti-sel!sas!toebes
-
- =========================================================================
-
- MAKING IT WITH MAKE MAKE is a UN*X utility which allows you to keep
- track of your source files no matter how large
- For the Lazy and Ingenious or complicated your project gets. Suppose you
- have two source files for a C program: main.c
- and subs.c. Let's also say they both #include foofile.h. If you change main.c,
- you must recompile main.c and relink. If you change foofile.h, you must re-
- compile both main.c and subs.c. This isn't too bad with only two files, but
- just try to keep track of, say, eight source files...ten...a hundred. MAKE is
- designed to help you whether you have one, ten, or one hundred source files.<
-
- The principle behind MAKE is that you specify all the commands required to pro-
- duce your program in a file (called 'makefile'). When you want to produce an
- up-to-date version of your program, you
- program: main.o subs.o simply type 'make'; MAKE looks at the
- blink from main.o,subs.o to program system dates on your source files, de-
- echo "all done!" termines which must be recompiled, then
- recompiles them and relinks your execut-
- main.o: main.c foofile.h able! A makefile for our simple program
- lc main.c with two source files is shown at left.
-
- subs.o: subs.c foofile.h This simple script tells MAKE that the
- lc subs.o file PROGRAM depends (:) on the files
- main.o and subs.o, and that to make the
- file PROGRAM you execute the 'blink' command on the second line. You can have
- as many filenames separated by blanks as you wish after the colon. Commands,
- if present, must start with a blank or tab. You may have as many commands as
- you wish.
-
- Note that there are entries for main.o, subs.o, and foofile.h. MAKE will see
- that PROGRAM depends on main.o, and main.o depends on main.c; it will check the
- dates on main.o and main.c to see if the 'lc main.c' (compile) command should
- be performed before it links PROGRAM.
-
- Instead of entering an lc command for each .c file you have, you can instead
- enter a special dependency that looks like the one at left, below. This tells
- MAKE that whenever it sees an .o file, it must see a dependency upon
- .c.o: a .c file with the same prefixed name. You are relieved of any need
- lc $*.c to put this dependency in every makefile; instead, MAKE allows you
- to put it in a file called "builtins.make" in your C: directory. If
- the expression "$*" is seen in a builtin dependency, MAKE replaces it with the
- file name being processed (minus the .c or .o extension, of course).
-
- Now that your makefile is entered, how do you use it to make PROGRAM? Quite
- simple. Just type 'make'. MAKE looks in the makefile and sees that PROGRAM is
- the first file listed; it therefore assumes that you mean to make PROGRAM. It
- then does whatever is necessary to bring PROGRAM up to date. But what if you
- just want to compile 'main.c'? Also simple. Type 'make main.o'. MAKE takes the
- argument and figures out how to make it from the makefile.
-
- In fact, if you have typed in the .c.o dependency above, you can MAKE FARKLE.O
- when FARKLE is not even mentioned in the makefile. As you can see, MAKE is
- worth its weight in saved keystrokes alone!
-
- There are several useful command line options on MAKE: "make -n ..." prints the
- commands needed to bring "file" up to date to the screen but will not execute
- them. This is great if you just want to see how out-of-date your stuff is. A
- "make -k ..." tells MAKE that it should proceed as far as it can without stop-
- ping. If a command fails, MAKE quits without this flag; with the flag, MAKE
- continues until it needs the output file from the failed command.
-
- This means that if you compile 50 files and number 27 fails, numbers 28 to 50
- are compiled before MAKE needs the .o file for number 27. Last, "make -f <file-
- name>" tells MAKE to get its instructions from <filename>, not from "makefile."
-
- MAKE observes ^C interrupts; hit ^C and everything stops. It also observes ^D
- interrupts; hit ^D and MAKE quits after the current command is executed.<
-
- FOR THE ADVANCED USER: There is a limited ability to define macros in a make-
- file. Macros are of the form NAME = STRING. Whenever the string $(NAME) is seen
- in a makefile, STRING is put in its place. For example, you
- LC = lc $* can use the macros at left. This allows you to change your de-
- LCD = lc -d $* fault compiler options rapidly by simply changing the last line
- .c.o: to read $(LCD) [with a -d option] in place of $(LC).
- $(LC)
- Normally, MAKE types each line to the screen before executing
- it. If you prefer silent execution, preface a command with an '@'. Example:<
-
- program: program.o
- @echo "Linking program. . ."
- @blink from lib:c.o,program.o to program verbose lib lib:lc.lib
-
- Enjoy MAKE as much as I do! Many thanks to John Toebes and Jack Rouse for MAKE-
- ing it available!
-