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
69
votes
7 answers

How to generate a Makefile with source in sub-directories using just one makefile

I have source in a bunch of subdirectories like: src/widgets/apple.cpp src/widgets/knob.cpp src/tests/blend.cpp src/ui/flash.cpp In the root of the project I want to generate a single Makefile using a rule like: %.o: %.cpp $(CC) -c…
Jeroen Dirks
  • 7,705
  • 12
  • 50
  • 70
69
votes
4 answers

Using make with -j4 or -j8

I have 4 processors and am compiling a processor-hungry application. I read that using make with the -j4 switch was recommended for OpenCV; should I instead use -j8? What is the advantage of making for multiple processors?
user784435
68
votes
2 answers

how to "execute" make file

I tried to use a make file in code::blocks but I am doing it wrong. I have the version installed with the compilers included. http://sourceforge.net/projects/codeblocks/files/Binaries/10.05/Windows/codeblocks-10.05mingw-setup.exe/download. What do I…
user366121
  • 3,203
  • 9
  • 48
  • 69
68
votes
3 answers

What is the meaning of a double dollar sign in bash/Makefile?

When inserting a shell script inside a Makefile we have (?) to use a double dollar sign ($$) to make reference to variables. Why is that so? for number in 1 2 3 4 ; do \ echo $$number ; \ done
JohnTortugo
  • 6,356
  • 7
  • 36
  • 69
68
votes
5 answers

How to run a bash script from a Makefile?

I have a Makefile from which I want to call another external bash script to do another part of the building. How would I best go about doing this?
Matthew FL
  • 1,612
  • 3
  • 18
  • 22
68
votes
11 answers

How do I capture all of my compiler's output to a file?

I'm building an opensource project from source (CPP) in Linux. This is the order: $CFLAGS="-g Wall" CXXFLAGS="-g Wall" ../trunk/configure --prefix=/somepath/ --host=i386-pc --target=i386-pc $make While compiling I'm getting lot of compiler…
pecker
  • 1,997
  • 3
  • 21
  • 23
68
votes
11 answers

NDK can't find the application directory

When running the ndk-build command I get the following error: Android NDK: Could not find application project directory ! Android NDK: Please define the NDK_PROJECT_PATH variable to point to it. The contents of my Android.mk file: LOCAL_PATH :=…
Wessel van der Linden
  • 2,592
  • 2
  • 21
  • 42
67
votes
8 answers

How to use makefiles in Visual Studio?

I heard a lot about makefiles and how they simplify the compilation process. I'm using VS2008. Can somebody please suggest some online references or books where I can find out more about how to deal with them?
chester89
  • 8,328
  • 17
  • 68
  • 113
67
votes
3 answers

makefiles - compile all c files at once

I want to experiment with GCC whole program optimizations. To do so I have to pass all C-files at once to the compiler frontend. However, I use makefiles to automate my build process, and I'm not an expert when it comes to makefile magic. How should…
Nils Pipenbrinck
  • 83,631
  • 31
  • 151
  • 221
67
votes
20 answers

make *** no targets specified and no makefile found. stop

I have a problem installing package dionaea. After I type this: ./configure --with-lcfg-include=/opt/dionaea/include/ \ --with-lcfg-lib=/opt/dionaea/lib/ \ --with-python=/opt/dionaea/bin/python3.1 \ --with-cython-dir=/usr/bin…
Nani
  • 671
  • 1
  • 5
  • 3
67
votes
7 answers

Finding version of Microsoft C++ compiler from command-line (for makefiles)

I must be missing something really obvious, but for some reason, the command-line version of the Microsoft C++ compiler (cl.exe) does not seem to support reporting just its version when run. We need this to write makefiles that check the compiler…
jakobengblom2
  • 5,531
  • 2
  • 25
  • 33
66
votes
7 answers

"commence before first target. Stop." error

In *.mak file I receive commands "commence before first target. Stop." I didn't change it before. How to solve this problem?
EK.
  • 2,890
  • 9
  • 36
  • 49
65
votes
10 answers

How to write build time stamp into apk

Making some changes in Android Contacts package Using mm (make) command to build this application Because I have to change and build this app again and again, so I want to add a build time stamp in the Contacts.apk to check the build time when…
FallingRain
  • 671
  • 1
  • 5
  • 7
65
votes
4 answers

GNU make yields "commands commence before first target" error

In my makefile, I would like to check for the existence of a library and give an informative error message. I created a conditional that should exit the make process when the file is not found: 9: ifeq ($(${JSONLIBPATH}),) 10: JSONLIBPATH =…
Alex Reynolds
  • 95,983
  • 54
  • 240
  • 345
65
votes
4 answers

Cmake cannot find library using "link_directories"

I Ubuntu, I am learning about cmake and make, and just trying a simple example. I have two directories: src and build. In src, I have two files: main.cpp, and CMakeLists.txt, which has (only) the following text: add_executable(test…
Karnivaurus
  • 22,823
  • 57
  • 147
  • 247