Makefile will see force in many places.

Source: Internet
Author: User

Force is seen in many places in the Makefile of the kernel, such as:

# vmlinux image-including Updated kernel symbols
Vmlinux: $ (vmlinux-lds) $ (vmlinux-init) $ (vmlinux-main) VMLINUX.O $ (KALLSYMS.O) force


It is actually a pseudo-target:


Phony +=force
Force:

# Declare the contents of the.  Phony variable as phony. We Keep that
# information in a variable so we can use it in if_changed and friends.
. Phony: $ (phony)

As seen from the above, force has no rules to rely on, and there are no executable commands underneath it.

If a rule has no command or dependency, and its target is not an existing file name, the target is always considered up-to-date when the rule is executed. In other words, once this rule is executed, make will assume that the target it represents has been updated. When such a target (force) is relied upon as a rule (as in Vmlinux:), the command defined as a dependent rule is always executed because the dependency is always considered to be updated.
For example, the above vmlinux: at each make, the following commands are always executed:

Ifdef Config_headers_check
$ (Q) $ (make)-F $ (srctree)/makefile Headers_check
endif
Ifdef config_samples
$ (Q) $ (make) $ (build) =samples
endif
Ifdef CONFIG_BUILD_DOCSRC
$ (Q) $ (make) $ (build) =documentation
endif
$ (call Vmlinux-modpost)
$ (call if_changed_rule,vmlinux__)
$ (Q) rm-f. old_version

This can be clearly seen with an intuitive example, such as 1 Makefile files:

HELLOWORLD:FILE1.O FILE2.O
GCC file1.o file2.o-o HelloWorld

file1.o:file1.c file2.h
Gcc-c File1.c-o FILE1.O

FILE2.O:FILE2.C file2.h
Gcc-c File2.c-o FILE2.O

Clean
RM-RF *.O HelloWorld

Phony +=force
Force:

. Phony: $ (phony)

After you perform make, observe the file generation time:


[Beyes@slinux makefile]$ LL
Total 32
-rw-rw-r--. 1 beyes beyes 129 APR 19:00 file1.c
-rw-rw-r--. 1 beyes beyes 924 Apr 20:20 FILE1.O
-rw-rw-r--. 1 Beyes beyes 108 APR 19:01 file2.c
-rw-rw-r--. 1 beyes beyes 139 APR 18:49 file2.h
-rw-rw-r--. 1 beyes beyes 880 Apr 20:20 file2.o
-rwxrwxr-x. 1 beyes beyes 4786 Apr 20:20 HelloWorld
-rw-rw-r--. 1 beyes beyes 246 APR 20:20 Makefile

HelloWorld file generation time is 20:20
If the above Makefile file helloworld:file1.o file2.o This sentence with force, then after a few minutes to make, then observe the HelloWorld generation time, you can see is regenerated, of course The output of the command at execution time can also know that the command was executed again:

[Beyes@slinux makefile]$ LL
Total 32
-rw-rw-r--. 1 beyes beyes 129 APR 19:00 file1.c
-rw-rw-r--. 1 beyes beyes 924 Apr 20:20 FILE1.O
-rw-rw-r--. 1 Beyes beyes 108 APR 19:01 file2.c
-rw-rw-r--. 1 beyes beyes 139 APR 18:49 file2.h
-rw-rw-r--. 1 beyes beyes 880 Apr 20:20 file2.o
-rwxrwxr-x. 1 beyes beyes 4786 Apr 20:26 HelloWorld
-rw-rw-r--. 1 beyes beyes 246 APR 20:20 Makefile

From:http://www.groad.net/bbs/read.php?tid-3392-fpage-3.html

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.