一.make中的路径搜索
问题:在实际的工程项目中,所有的源文件和头文件都放在同一个文件夹中吗?
实验1 : VPATH 引子
mhr@ubuntu:~/work/makefile1/17$ ll
total 28
drwxrwxr-x 4 mhr mhr 4096 Apr 22 00:46 ./
drwxrwxr-x 7 mhr mhr 4096 Apr 22 00:32 ../
drwxrwxrwx 2 mhr mhr 4096 Jan 23 2018 inc/
-rw-rw-r-- 1 mhr mhr 133 Apr 22 00:46 makefile
drwxrwxrwx 2 mhr mhr 4096 Jan 23 2018 src/
mhr@ubuntu:~/work/makefile1/17$
inc/func.h
#include <stdio.h>
#include "func.h"
void foo()
{
printf("void foo() : %s\n", "This file is from inc ...");
}
src/func.c
#include <stdio.h>
#include "func.h"
void foo()
{
printf("void foo() : %s\n", HELLO);
}
src/main.c
#include <stdio.h>
#include "func.h"
int main()
{
foo();
return 0;
}
makefile
OBJS := func.