Using Borland's Command Line Tools |
|||||||||
|
|||||||||
|
The code from this page can be found here:
[Link to ZIP File] Make.exe is one of the tools provided. It is a powerful aid for building multi-file projects and has a built-in help summary. There are two sites which have help pages on make: Guide to Make (warning: may be offline) Make Documentation (note: pdf format) To see the help summary that make.exe generates give the command: make -? Make.exe uses a text file called a makefile as its information on how to build the project. In the makefile are descriptions of what the final and intermediate files are and which of them depends upon which others. Not all of these dependencies need be listed. Make can determine for itself on which header files an object file depends. Assume that we are using the files shown in the tlib example but are not using a library [Tlib Example Code]. In that example we see that the target file, 123.exe, depends upon the object files 123.obj, 1.obj, 2.obj, 3.obj Each of those *.obj files depends upon a *.cpp file of the same base name and upon the header file numbers.h "Depends upon" here means that if the file upon which it depends were changed, then the item would need to be rebuilt. In a makefile these relationships are expressed with rules. Each rule shows a target which is to be built and the list of dependencies or items upon which it depends. The first rule in the file is the one item which is to be built by using this make file. Other rules that follow are for intermediate files that must be created to get to where the all dependencies exist and are up to date. Each rule has an associated set of one or more command lines which will build its target. Which line is a rule and which is a command line is shown by starting rules in column 1, the leftmost column, and indenting command lines. Because large makefiles can be complex, comments are allowed in them. A comment is anything following (to the right of) the character '#'. You run make.exe by giving it a -f followed by the make file name. It assumes a default extension of .MAK so typing in that extension is optioal. The space after the -f is also optional. If the name of the file is MAKEFILE then you don't even need to specify the name! Here is a make file that constructs a text file and then writes it to the screen. Following it is a screen capture of the make being run.
------temp.mak-----
# main rule This make file will try to build the file temp.txt
#
temp.txt : 1.txt 2.txt
copy /v 1.txt+2.txt temp.txt
type temp.txt
# rule for how to create the file 1.txt
1.txt :
echo This is the first file >1.txt
2.txt :
echo This is the second file >2.txt
---screen capture of running make---
C:>make -f test
MAKE Version 5.2 Copyright (c) 1987, 1999 Inprise Corp.
echo This is the first file >1.txt
echo This is the second file >2.txt
copy /v 1.txt+2.txt temp.txt
1.txt
2.txt
1 file(s) copied
---screen capture showing the files created---
C:>type 1.txt
This is the first file
C:>type 2.txt
This is the second file
C:>type temp.txt
This is the first file
This is the second file
--------------------
|
|||||||||
| [Next Page: Make Files 2] | |||||||||