make dependency and Makefile

Hello. Please explain to me what is dependency in Makefile.

secondly I have made Makefile but cannot use make -f . How to use it?

Third what is make [OPTION] [TARGET]

Thanks
Last edited on
Read this, please come back if you still have questions.
http://www.cplusplus.com/articles/jTbCpfjN/
Makefile contains rules
In general, a rule looks like this:

     targets : prerequisites
             recipe
             ...

Your third question was about the command line synopsis. Some parts are optional, and shown in brackets.
You could just run:
make

If the current working directory has a file named "Makefile", then make assumes it is such and interprets its rules. It will follow do the default target, i.e. the first target; the first rule.

If you have multiple rules, i.e. targets, you can ask for specific. For example, you could have a later target named "clean" and its commands would execute, if you do:
make clean

You must have been reading the manual of make and it does list some options. They are optional; learn what they do and use them when needed.


A rule can list prerequisites. Those are other targets that this target depends on. They will be done first, unless they are already up to date. In other words, this target depends on those other targets.
I have seen make manual and just to be sure I see one option got many substitutes:

for example -f option got this: -f FILE, --file=FILE, --makefile=FILE

are -f --file --makefile all do same thing?
Yes
Topic archived. No new replies allowed.