What does this man file mean?

I’m trying to learn how to use the make command, but I don’t understand what to do.
I was reading these lines:


Than I searched the -f option:

But I don’t understand how to read it. And how to use it.
For example, in -f what does --file=file means. And what do I do with it? What do I do with --makefile=FILE.

1 Like

You can read the man page here too:
http://manpages.ubuntu.com/manpages/xenial/man1/make.1.html
So you can use the flags in the command as make -f <file> …etc, but it’s easier to just use make <file>
Say you have a script script.c. If you want to compile it, you use make script
I doubt you will use the flags often, but for your peace of mind, try them all in the terminal.
-f or --file are used to read file as a makefile.
Here: ftp://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_3.html#SEC12

1 Like

Create a file calle Makefile. Put this in it:

all:
        echo "Hello I am all."

build:
        echo "Hello I am build."

IMPORTANT POINT! The 8 spaces I have here on the lines after build: and all: are actually 1 single TAB character. Don’t just copy paste this, write it with a text editor that puts a tab in there.

Now do this:

make
make all
make build

That’s basic Makefile. You can put multiple commands under each colon target all: and build:.

1 Like

Thank you guys.
My question was more about how to read the man page.
So in the -f line we have:
-f file (which is a command. I tried it out and it works)
–file=file ( what is this? how do I use it?)
–makefile=FILE (and what is this? and why FILE and not file?)
@io_io

Nice links.
Thank you.

1 Like

If you want to use a nonstandard name for your makefile, you can specify the makefile name with the -f' or–file’ option. The arguments -f name' or–file=name’ tell make to read the file name as the makefile. If you use more than one -f' or–file’ option, you can specify several makefiles. All the makefiles are effectively concatenated in the order specified. The default makefile names GNUmakefile',makefile’ and Makefile' are not checked automatically if you specify-f’ or `–file’.

So, if you just use a makefile named makefile or Makefile, you will never have to use those commands you find confusing.

1 Like