如何在Linux中创建makefile [英] how to create makefile in linux

查看:777
本文介绍了如何在Linux中创建makefile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

源文件位于名为"src"的目录中.
包含文件位于名为"include"的目录中
这两个目录位于名为工作"的目录下.

有1个或2个源文件,而2-3个包含文件.我们如何实现此目标??
我知道如何在单个目录中实现此目标,但是当包含文件和源文件位于不同目录中时,任何人都可以帮助我...

Source files are in a directory called ‘src’.
Include files are in a directory called ‘include’
These two directories are under a directory called ‘work’

There are 1 or 2 source files and 2-3 include files..How can we implement this???
I know how to implement this in a single directory,but any one let me help when include files and source files are in different directories...

推荐答案

我明确创建源和包含文件的变量,例如
I explicitely create variables for sources and include files, e.g.
SRCDIR = src
INCDIR = include
BINDIR = bin



并使用它来构建源,例如



and the use it to build sources, e.g.

...


(BINDIR)/foo:
(BINDIR)/foo:


(SRCDIR)/foo.c
(SRCDIR)/foo.c


这篇关于如何在Linux中创建makefile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆