Questions tagged [makefile]

A makefile is an input file for the build control language/tool make. It specifies targets and dependencies along with associated commands to perform (a.k.a. recipes) to update the targets.

A makefile is usually an input file for the build control language/tool make. The make utility and the corresponding makefile format is standardized by POSIX.

Common newbie mistakes:

Makefile variable assignment error in echo - running two distinct commands in a recipe and not realizing the shell from the first will exit and lose any changes to the environment.

Make implementations

More information

25125 questions
56
votes
2 answers

Confused about configure script and Makefile.in

I'm currently learning how to use the autoconf/automake toolchain. I seem to have a general understanding of the workflow here - basically you have a configure.ac script which generates an executable configure file. The generated configure script…
Siler
  • 8,976
  • 11
  • 64
  • 124
56
votes
4 answers

How to get exit status of a shell command used in GNU Makefile?

I have a makefile rule in while I am executing a linux tool. I need to check the exit status of the tool command, and if that command fails the make has to be aborted. I tried checking with $?, $$? \$? etc in the makefile. But they gives me syntax…
Lunar Mushrooms
  • 8,358
  • 18
  • 66
  • 88
56
votes
2 answers

Suppress and ignore output for Makefile?

I know that the @ prefix suppresses output from a shell command in Makefiles, and also that the - prefix will ignore errors from a shell command. Is there a way to combine the two, i.e. a prefix that suppresses output and ignores errors? I don't…
Andrew Lee
  • 2,543
  • 3
  • 20
  • 31
56
votes
1 answer

How to get the second dependency file using Automatic Variables in a Makefile?

I need to get the nth dependency file from a rule, something similar to $n in bash. I need this because I'd like to feed in individual dependency files as options to the build program. Here's an example: dep.o: dep.src config1.cfg config2.cfg …
Yu Zhou
  • 788
  • 6
  • 11
55
votes
3 answers

How do I properly escape data for a Makefile?

I'm dynamically generating config.mk with a bash script which will be used by a Makefile. The file is constructed with: cat > config.mk <
Lekensteyn
  • 64,486
  • 22
  • 159
  • 192
55
votes
3 answers

How to support both vcxproj to cmake on a project?

I'm developing cross-platform c++ project. The original idea is to work with msvc2010 and later compile for other systems with the help of CMake and Hudson. It doesn't seem to be convenient manually change CMake files after changes in studio…
tikkerey
  • 663
  • 1
  • 6
  • 7
55
votes
6 answers

What's an easy way to detect modified files in a Git workspace?

During make, I create string fields which I embedded in the linked output. Very useful. Other than a complex sed/grep parsing of the git status command, how can I easily determine if files in the workspace have been modified according to git?
Jamie
  • 7,075
  • 12
  • 56
  • 86
55
votes
2 answers

How to get the invoking target of makefile?

How to get the invoking target of the GNU make Makefile? for example, I invoke make with the following command line: make a-target How can I get the invoking target "a-target" in the Makefile and assign it to a variable? Further more, if more than…
Justin
  • 693
  • 1
  • 5
  • 7
55
votes
6 answers

ldconfig error:"is not a symbolic link" when using Linux loader

When running: sudo /sbin/ldconfig the following error appears: /sbin/ldconfig: /usr/local/lib/ is not a symbolic link When I run the file command, the below appears: file /usr/local/lib/ /usr/local/lib/: directory Inside…
Rodrigo Gurgel
  • 1,696
  • 2
  • 15
  • 32
54
votes
2 answers

Are makefiles Turing complete?

Lately at work, I've been doing some translation from Makefiles to an alternative build system. I've seen some pretty hairy Make code in some places using functional map, filter, and foreach constructs. This surprised me since I think build scripts…
Jay Conrod
  • 28,943
  • 19
  • 98
  • 110
54
votes
15 answers

Recommended build system for latex?

I'm trying to figure out the best build system for latex. Currently, I use latex-makefile, editing in vim, and viewing changes in Okular or gv. The major problem is that it sometimes gets hides errors on me, and I have to run latex manually. The…
Paul Biggar
  • 27,579
  • 21
  • 99
  • 152
54
votes
1 answer

How to conditional set up a Makefile variable by testing if a file exists

For example: I want: if file1 exists: CLEAN_SRC = *.h file3 else CLEAN_SRC =
Sam Liao
  • 43,637
  • 15
  • 53
  • 61
53
votes
4 answers

how to include git commit-number into a c++ executable?

i use git as a version tracker for my c++ project. sometimes i need to repeat a calculation and i would like to know which version of the program i used. what would be a good way to put a # of the commit into the main executable? in other words.…
kirill_igum
  • 3,953
  • 5
  • 47
  • 73
53
votes
1 answer

How to use the __attribute__((visibility("default")))?

Reading Visibility in the GNU wiki, it is clear. Taking this example from C++ Tutorials // classes example #include using namespace std; class Rectangle { int width, height; public: void set_values (int,int); int area()…
Tony Tannous
  • 14,154
  • 10
  • 50
  • 86
53
votes
5 answers

why "make" before "make install"

I know the process of installing from source are. ./configure make make install But why "make" before /etc/cups/cupsd.conf, why not just do "make install"? My understanding so far is "make" only compile the source into executable file, and "make…
aggressionexp
  • 690
  • 1
  • 5
  • 10