PRODUCT : dBASE IV NUMBER : 1490 VERSION : All OS : DOS DATE : October 25, 1993 PAGE : 1/5 TITLE : Overview of the MAKE utility _________________________________________________________________ OVERVIEW: Borland Technical Support receives many calls related to hardware usage and compatibility, dBASE utilities, interfacing with other systems, etc. As a service to our customers, frequently asked questions are tracked, and answers to many questions are available as Tech Info articles. DESCRIPTION: Included with the dBASE Compiler version 1.0 is Borland's MAKE utility which helps automate building applications. This article supplements the MAKE documentation and provides clear explanation of the utility. MAKE is a utility for managing various source files that make up a dBASE application. Developers using C, Pascal, and other languages commonly use MAKE utilities to build their applications. MAKE is a very popular tool in multiuser operating systems such as UNIX, in which different people work on different parts of the code. MAKE eases integration of the different parts of the code and building of the final application. When you build executable files, you need to combine the most recently compiled version of each source file. Forgetting to re-compile a module that has changed or that depends on something you've changed, can lead to problems. On the other hand, rebuilding everything just to be safe can waste a lot of time. MAKE solves these problems. MAKE looks at the time and date stamp of all the specified dependent files and the target to determine which files need updating. When you start MAKE, it looks for a file called BUILTINS.MAK containing "built-in" instructions to to be executed every time you run MAKE. This file is also supplied with the compiler, and can be PRODUCT : dBASE IV NUMBER : 1490 VERSION : All OS : DOS DATE : October 25, 1993 PAGE : 2/5 TITLE : Overview of the MAKE utility _________________________________________________________________ found in the directory where the compiler is installed. When MAKE is invoked, it searches for BUILTINS.MAK first in the current directory, then in the directory where MAKE.EXE is located. MAKEFILES: You can type the instructions for building your application in a text file using any text editor such as BRIEF or DOS 5.0 EDIT. When you start MAKE, it reads the instructions contained in a file called MAKEFILE. If you want to name this file something other than MAKEFILE, then use the command line option -f, when you invoke MAKE. For example, if you create a makefile called MYAPP.MAK, then MAKE can be invoked from the command line as follows: MAKE -f MYAPP A makefile contains instructions for building one or more targets. These instructions are usually referred to as "rules". Rules specify the source and target files, dependency information, and the necessary steps to build that target, in case the target does not exist or the target has an earlier time and date stamp than the source. If a makefile contains rules for more than one target, then when MAKE is invoked from the command line, the appropriate target must be specified. If no target is specified, then MAKE builds the first target and ignores the rest. Makefiles may also contain macros that perform text search and replacement. RULES: There are two types of rules that can be specified in a makefile. They are implicit rules_and explicit rules. Explicit rules specify a particular target, the files the target depends on, and action to build the target if necessary. Here is an example of an explicit rule: PRODUCT : dBASE IV NUMBER : 1490 VERSION : All OS : DOS DATE : October 25, 1993 PAGE : 3/5 TITLE : Overview of the MAKE utility _________________________________________________________________ Myapp.EXE: Myapp.DBO Main.DBO Hello.DBO BDC -EMyapp.EXE Myapp.PRG \ Main.PRG Hello.PRG # The above rule is an explicit rule. The first line in this explicit rule is known as dependency line. This line says that Myapp.EXE depends upon Myapp.DBO, Main.DBO, and Hello.DBO. The second line is known as command line. This line gives the instruction to build the target Myapp.EXE. For example, type: C: [Enter] It should be noted here that the command line must be indented_either with a tab or some spaces. A slash at the end of a line continues a statement on the next line. The next line that starts with a #, is a comment line. It is a good idea to include comments in the makefile that would enhance its readability. Implicit rules specify only file extensions and apply to all the files sharing those extensions. You can find samples of implicit rules in the BUILTINS.MAK file. For example, an implicit rule could be written as .Prg.DBO: BDC -c {$< } This implicit rule means that any file with a .DBO extension depends upon a like named file with a .PRG extension. If a .DBO has an earlier date and time stamp compared to a like-named .PRG, then use the BDC -c command to build the .DBO. The {$< } symbol is a file name macro that expands to path\dependent file+extension. PRODUCT : dBASE IV NUMBER : 1490 VERSION : All OS : DOS DATE : October 25, 1993 PAGE : 4/5 TITLE : Overview of the MAKE utility _________________________________________________________________ If you look at the explicit rule: Myapp.EXE: Myapp.DBO Main.DBO Hello.DBO BDC -EMyapp.EXE Myapp.PRG Main.PRG Hello.PRG The dependency line states that Myapp.EXE depends upon Myapp.DBO, Main.DBO, and Hello.DBO. If these .DBO files are not found in the directory, MAKE remembers the implicit rule that it has read from the BUILTINS.MAK file, recompiles the .PRG to produce the .DBO. MACROS: Macros perform text replacement and can specify complex file name expansion. For instance, you can use a single makefile to build two different versions of an application by specifying the source file directory with a macro. In a makefile, a macro must be defined before it is used anywhere in that file. Also the macro definition should start at the first column. A macro is defined as follows: MACRONAME = VALUE For example, we can define a macro for the object files that are given in the above explicit rule as follows: LISTOBJ = Myapp.DBO Main.DBO Hello.DBO The macro is used in a rule as follows Myapp.EXE: $(LISTOBJ) This expands to Myapp.EXE: Myapp.DBO Main.DBO Hello.DBO DIRECTIVES: The directives perform various control functions similar to the preprocessor directives in dBASE IV PRODUCT : dBASE IV NUMBER : 1490 VERSION : All OS : DOS DATE : October 25, 1993 PAGE : 5/5 TITLE : Overview of the MAKE utility _________________________________________________________________ 2.0. These are !if, !elif, !define, !undef, and so on. They are similar to the #if, #elif, #define, #undef directives available in dBASE IV 2.0 and 1.5. These directives are analogous to the directives available in the preprocessor of the dBASE compiler. There are other directives called "dot directives" that provide a way to "hard code" certain command line options into your makefile. For instance, the .nosilent directive, corresponds to the -s option, which prints commands before executing them. For more information about the directives, refer to the MAKE documentation. DISCLAIMER: The above code is provided as an example of using the dBASE language to extend dBASE menu functionality. Although the intent of this information is to help you as much as possible, further elaboration or customization cannot be provided through the standard technical support phone line. If you need extra assistance, please call 1-800-822-4269 and request document #1431. This article details many other sources of technical assistance and will be sent to your fax machine at no charge. You have the right to use this technical information subject to the terms of the No- Nonsense License Statement that you received with the Borland product to which this information pertains.