Questions tagged [make]

For questions pertaining to make, a utility that automates the build process by managing dependencies amongst targets. Use this tag for questions about make itself or questions about issues arising from using the make command-line utility.

The make utility is driven by optional configuration files (makefiles) and built-in rules that take components and create an output file, typically an executable file. The configuration files and built-in rules define how to create an output file from the given input files. The rules consist of a target, dependencies, and commands to execute to create the output file. If the output exists and is newer than all the dependency files, no action is taken.

For example, if creating an executable file hello.exe requires two source files, hello.c and hello.h then a makefile could look like this:

hello.exe: hello.c hello.h
    cc hello.c -i hello.h -o hello

If the timestamps for hello.c and hello.h are older than for hello.exe then the cc command is executed. There are numerous macros predefined that for simple tasks a simple makefile (or even no makefile) is needed.

Further reading

Why can't gcc find libevent when building tmux from source?

What is the purpose of the 'install' command?

make fatal error: openssl/sha.h: No such file or directory

External References

Tutorial

Wikipedia Makefile

make specification (The Open Group Base Specifications Issue 7, 2018 edition)

969 questions
83
votes
8 answers

Makefile include env file

I'm trying to include some env vars into a Makefile. The env file looks like: FOO=bar BAZ=quux Note there's no leading export to each env var. If I add the leading export and just include the env file in the Makefile, everything works as it should.…
Michael Irwin
  • 933
  • 1
  • 6
  • 5
78
votes
6 answers

How to determine the maximum number to pass to make -j option?

I want to compile as fast as possible. Go figure. And would like to automate the choice of the number following the -j option. How can I programmatically choose that value, e.g. in a shell script? Is the output of nproc equivalent to the number…
tarabyte
  • 4,166
  • 10
  • 36
  • 48
70
votes
9 answers

Why can't gcc find libevent when building tmux from source?

I want to install tmux on a machine where I don't have root access. I already compiled libevent and installed it in $HOME/.bin-libevent and now I want to compile tmux, but configure always ends with configure: error: "libevent not found", even…
volker
  • 703
  • 1
  • 6
  • 4
55
votes
1 answer

make fatal error: openssl/sha.h: No such file or directory

I'm trying to compile a program that, according to the documentation, requires the "OpenSSL library". I have OpenSSL installed, and it's still giving me the error openssl/sha.h: No such file or directory. Is there some other library that has to be…
tkbx
  • 10,597
  • 13
  • 35
  • 41
54
votes
4 answers

What is the purpose of the 'install' command?

I've seen the install command used in a lot of Makefiles, and its existence and usage are kind of confusing. From the manpages, it seems like a knockoff of cp with less features, but I assume it wouldn't be used unless it had some advantage over cp.…
azernik
  • 661
  • 1
  • 5
  • 6
46
votes
9 answers

jemalloc and other errors making redis on centos 6.4

I am setting up a new, dedicated, centos 6.4 system with redis. I have installed redis many times, but have never hit this issue (and have never been on centos 6.4 before). cd redis-2.6.16 sudo make install error: MAKE jemalloc cd jemalloc &&…
42
votes
1 answer

How does this Makefile makes C program without even specifying a compiler?

I was using a Makefile from the book "Advanced Linux Programming (2001)" [code]. It was strange for me to see that GNU make does compile the code correctly, without even specifying a compiler in the Makefile. It's like baking without any…
Ho1
  • 2,552
  • 3
  • 20
  • 25
41
votes
3 answers

What are .in files?

Sometimes in the sources of projects I see "*.in" files. For example, a bunch of "Makefile.in"s. What are they for and/or what does the ".in" part mean? I assume that this has something to do with autoconf or make or something like those, but I'm…
strugee
  • 14,723
  • 17
  • 73
  • 119
40
votes
3 answers

How to list all targets in make?

Let's say you have a project structure with lots of Makefiles and there is a top level Makefile that includes all the other. How can you list all the possible targets? I know writing make and then tabbing to get the suggestions would generally do…
Sogartar
  • 561
  • 1
  • 4
  • 6
39
votes
4 answers

How to display dependencies given in a makefile as a tree?

Problem I want to see the dependencies for one or more targets of a makefile. So I am looking for a program that can parse makefiles and then will represent the dependencies in some tree-like format (indentation, ascii-art, ...) or as a graph (dot,…
Lucas
  • 2,805
  • 1
  • 14
  • 24
36
votes
10 answers

Why are programs not distributed in compiled format?

But they give instructions like cd downloaded_program ./configure make install This creates the ELF that is needed, and probably some .so files. Why not put those inside a zip file for download, like with windows apps? Is there any reason why they…
kitty
  • 417
  • 4
  • 3
34
votes
4 answers

Don't stop make'ing if a command fails, but check exit status

I am trying to instruct GNU Make 3.81 to not stop if a command fails (so I prefix the command with -) but I also want to check the exit status on the next command and print a more informative message. However my Makefile below fails: $ cat Makefile…
Marcus Junius Brutus
  • 4,427
  • 11
  • 43
  • 63
33
votes
2 answers

Checking environment variables' value in Makefile

I have a Makefile target, in which I have to check the value of an environment variable. But, I don't get the exact syntax of it. Tried hard, but can't find it. Any help is appreciated. Environment variable name: TEST, its value:…
ATP
  • 635
  • 2
  • 7
  • 9
32
votes
10 answers

How do I change which version of Qt is used for qmake?

I feel like there should be a simple way of doing this, but my googlefu is failing so I'd really appreciate some info on how to switch (or even permanently change) which version of Qt is used when doing qmake. If I ask which version I get the…
Tamsyn Michael
  • 453
  • 1
  • 4
  • 8
31
votes
1 answer

What happens in each step of the Linux kernel-building process?

I've read many tutorials about how to build custom kernels and boot Ubuntu using those kernels, and successfully followed the guides and booted custom kernels, but I have no understanding about what each of the command in the guides do and what is…
AnkurVj
  • 993
  • 3
  • 13
  • 22
1
2 3
64 65