I'm trying to use makefile, my problem is that I have a directory, with an src
directory and a Makefile
. I also use a tmp
directory what I also have to create.
It has object files in it. And for performance, I try not to delete these when debugging.
If I create a rule for tmp to create it, it always rebuilds all the C files.
So how to do this?
相关问题
- CMakeList file to generate LLVM bitcode file from
- Makefile to compile lists of source files
- Have make fail if unit tests fail
- C++ - Compiling multiple files
- Undefined symbols for architecture x86_64: (Mac OS
相关文章
- How to arrange a Makefile to compile a kernel modu
- Makefile and use of $$
- Makefile: all vs default targets
- Automake Variables to tidy up Makefile.am
- How do I check the exit status of a Makefile shell
- Marking a makefile dependency as optional or other
- How to instruct Makefile to use different compiler
- Why does this makefile execute a target on 'ma
There are a number of ways. It depends on what version of
make
you're using and what operating system you're using.The one thing you must NEVER do is use a directory as a simple prerequisite. The rules the filesystem uses to update the modified time on directories do not work well with
make
.For simple
make
on a POSIX system, you can pre-create the directory in the rule to perform the compilation:If you have GNU make you have two options. The simplest one is simply to force the directory to be created when the makefile is read in before anything else happens, by adding a line like this:
The is easy, fast, and reliable. Its only downside is that the directory will be created always, even if it's not needed. Nevertheless this is the way I usually do it.
The most fancy way, if you have a new-enough GNU make, is to use order-only prerequisites:
This forces the
obj
target to be built before theobj/foo.o
target, but the timestamp onobj
is ignored when determining whetherobj/foo.o
is out of date.