Makefiles follow this format (Makefiles should always use tabs instead of spaces, since it is required in most (if not all) implementations of
operations to build target
- The target is what you're willing to build/compile/create. There may be several of them, and they should be built in the Makefile order, unless dependencies need to be met first. The first target in your file is called the default target, it is what
make tries to build when you call it without arguments.
- The dependencies are the different pieces required to build a target.
In this Makefile, you have two targets:
lex.yy.c is a dependency required to build
test, it'll be built first from
test.l. Once it is generated, it'll be possible to compile
- Tries to build
- Unresolved dependency.
lex.yy.c does not exist (or has been updated), it needs to be built first.
- Reading operations to build
flex test.l :
lex.yy.c is built.
- All dependencies for
test are met. Running
g++ lex.yy.c -ll -o test.
test is created.
Additional info: For more information about makefiles, I would recommend The Linux Development Platform by Rafeeq Ur Rehman. Chapter 4: Using GNU Make.