A complete set of practical Makefile reference templates
Source: Internet
Author: User
Article Title: a complete set of practical Makefile reference templates. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Recently, we often see people asking about makefile writing. Here is a complete example of an application system based on my experience for your reference.
The application system directory structure is as follows:
Code:
~ The content of the/makefile file is as follows:
Code:
All:
@ MakeSubDir () {for DIR in 'ls | grep 'lib'; ls | grep-v 'lib''; do if [-d $ {DIR}]; then cd $ {DIR}; MakeSubDir; if [-f makefile-o-f Makefile]; then echo ""; pwd; make all; fi; cd ..; fi; done ;}; MakeSubDir
. C. o: *. h $ (INC)/*. h
@ Echo "Compiling $ <..."
@ $ (CC)-c-I $ (INC) $ <
INFO:
@ Echo "make all-same with 'make' handle t this message"
@ Echo "make clear-remove object files"
@ Echo "make clean-remove all object and target files"
@ Echo ""
Clear: FORCE
@ Rm-f *. o
Clean: FORCE clear
@ Rm-f $ (PRODUCT)
FORCE:
Usage:
1. Use the 'make' command in the main directory to first create a function library and then create all the targets.
2. Use the 'Make tar 'command in the main directory to package the entire system. The generated file is named by date and time.
3. directly using the 'make' command in the lowest subdirectory will first give a usage prompt, and then create all the targets in the directory.
4. Use the 'Make all' command in the lowest-level subdirectory to directly create all targets in the directory without any prompts.
5. Use the 'Make clear' command in the lowest-level subdirectory to clear all. o files in this directory.
6. Use the 'Make clean' command in the lowest-level subdirectory to clear all. o files and all created targets in this directory.
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