The Makefile

The Makefile - The Makefile Comments Rules Dependency Lines...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
The Makefile Comments Rules Dependency Lines Shell Lines Macros Macro Modifiers Inference Rules Response Files Makefile Directives Make reads its instructions from text files. An initialization file is read first, followed by the makefile. The initialization file holds instructions for all ―makes‖ and is used to customize the operation of Make. Make automatically reads the initialization file whenever it starts up. Typically the initialization file is named make.ini and it resides in the directory of make.exe and mkmf.exe . The name and location of the initialization file is discussed in detail on Page . The makefile has instructions for a specific project. The default name of the makefile is literally makefile , but the name can be specified with a command-line option. With a few exceptions, the initialization file holds the same kind of information as does a makefile. Both the initialization file and the makefile are composed of the following components: comments , dependency lines , directives , macros , response files , rules and shell lines . Continued Makefile Lines Lines in the makefile can be very long. For easier reading a long line can be broken up by putting \ enter ‖ as the last characters of this line and the rest of this (logical) line on the next (physical) line of the makefile. For example: first_part_of_line second_part_of_line is the same as: first_part_of_line \ second_part_of_line Comments [Top] The simplest makefile statement is a comment , which is indicated by the comment character # ‖. All text from the comment character to the end of the line is ignored. Here is a large comment as might appear in a makefile to describe its contents: # # Makefile for Opus Make 6.1 # # Compiler: Microsoft C 6.0 # Linker: Microsoft Link 5.10 #
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The comment character could also be used at the end of another makefile statement: some makefile statement # a comment Comments and Continued Makefile Lines If ― \ enter‖ appears on a commented line, the comment acts until the end of the line and the following line is still continued. For example: line_one \ line_two # more_line_two \ line_three is the same as: line_one line_two line_three Rules [Top] A rule tells Make both when and how to make a file. As an example, suppose your project involves compiling source files main.c and io.c then linking them to produce the executable project.exe . Withholding a detailed explanation for a bit, here is a makefile using Borland C which will manage the task of making project.exe : The Example Makefile project.exe : main.obj io.obj tlink c0s main.obj io.obj, project.exe,, cs /Lf:\bc\lib main.obj : main.c bcc ms c main.c io.obj : io.c bcc ms c io.c This makefile shows three rules, one each for making project.exe , main.obj , and io.obj . The rules as shown above are called explicit rules since they are supplied explicitly in the makefile. Make also has
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 10

The Makefile - The Makefile Comments Rules Dependency Lines...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online