MakeFile基本使用

  1. 云栖社区>
  2. 博客>
  3. 正文

MakeFile基本使用

megachen 2018-06-08 17:34:00 浏览390
展开阅读全文

MakeFile Making

makefile demo

# Run this line when useing `make` command
# default is the target which is an output id in this makefile
# name after `:` are the dependent targets, when run this line `make` command will check if this target already exists in the makefile
# if not exists, `make` will run the dependent target line to create the target
# the second line is command area, in this area, you can run any valid command yout like, but because of it's target, we put the clang or
# gcc in the area
default: makefile
     clang main.c tools.c

# tools.o is an output target which is an global in this makefile
tools.o: default makefile
     clang tools.c -c

# app is an output target which is an global in this makefile
app: default tools.o
     clang main.o tools.o
# I'm sure if you use Linux or Unix now and then, and install some applications by source code, you must be familiar with this `clean`
# We often some clean action is the area, such as `rm -rf someconffile` and so on.
# There are three brothers named `clean`, `mrproper` and 'disclean' in a single makefile
clean:
    rm -rf main.o tools.o

disclean: clean
    rm -rf a.out

网友评论

登录后评论
0/500
评论
megachen
+ 关注