"Linux Learning" contains makefile simple applications for subdirectories

Source: Internet
Author: User

1. Directory structure

Practice6/ui/ui.h UI.C

Practice6/dal/dal.h DAL.C

Practice6/bll/bll.h BLL.C

Practice6/main.c

Pracitce6/makefile

2, makefile Writing and description

CC =gcc CFLAGS=-wall-g BIN= Main. outSubDir= $ (Shell ls-d */)//Call the shell command ls-d * * List the subdirectories of the current directory, not the files in the current directoryROOTSRC = $ (wildcard *.c)//$ (wildcard *.c) to find *.c files/folders from the current directoryRootobj = $ (rootsrc:%.c =%.o)//Replace the string ending with. C in the ROOTSRC string with the string ending in. O,%.c is the gnumake, equivalent to the Shell's *.cSUBSRC = $ (Shell find $ (subdir)-name'*.c')//call the shell command to find all files named *.c in subdirectories of the current directorySubobj = $ (subsrc:%.c =%.o)//Replace the string ending with. O in the SUBSRC string with the string ending in.$ (BIN): $ (rootobj) $ (subobj)//gcc generates main.out files$ (CC) $ (CFLAGS)-o [email protected] $^. C.O://indicates that the. c file depends on the. o File$ (CC) $ (CFLAGS)-C $<-o [Email protected]clean:rm-F $ (BIN) $ (rootobj) $ (subobj)

3. Process and

Not to be continued ...

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.