[MK] Drink a cup of coffee, write a Makefile

Source: Internet
Author: User

Makefile is a tool for organizing programs under Linux, and its command is make.

(The initials m/m all can)

"Makefile"

The main melody written by Makefile:

Target: [Prerequisities] (TAB) [command]

"Make"

Learn about the supported features and options:

Mans  Make Make--help  # Quick View formats and options        

Usage examples:

 Make-S-f  build.mk                     all make # Default read Makefile, default target is the first target in the file

Process

Make command to read Makefile and target;

Check that the target's dependencies are updated, have the command executed, and do not indicate that the destination file is up to date.

A statistical controbuter of Makefile:

# Original code: HTTPS://github.com/youzan/zan/blob/master/makefile"\  make <option> authors"--format='%an <%aE>'  Sort -u > [email protected]

@ Cancel show command at Terminal.

[email protected] is equivalent to the current target.

$^ all dependencies of the current target.

$< the first one in the current target dependency.

"Variable use"

Reference (=), Mutual influence:

Jack ==default:                -

Expand (: =), take only the values of the preceding variables:

Jack ==default:               - 

"Pseudo-target"

Hellomake:      gcc -o hellomake hellomake.c func.c-i.create    :touch  clean#. Phony:cleanclean:    rm -F Hellomake

Analyze the above file:

Make, do not specify target default is Hellomake.

Make create and execute the command ' touch clean '.

Make clean, no dependent changes detected, prompting the target file clean is up to date.

Obviously, make clean has unintended effect, in order to avoid such conflicts, it is necessary to exclude target from becoming the destination file;

Open the comment. Phony:clean is used to mark the pseudo target clean, please execute the command below clean.

Added

Makefile implied rules

A Simple Makefile Tutorial

Link:http://www.cnblogs.com/farwish/p/6148023.html

[MK] drink a cup of coffee, write a Makefile

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.