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

Info icon This 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 th e 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 #
Image of page 1

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

View Full Document Right 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.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern