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
8
votes
3 answers

How to make a 'rebuild' rule out of 'build' and 'clean' in Makefile?

I have a Makefile containing rules for building a small project and cleaning it. For example: CC:=gcc LD:=gcc SOURCES:=$(wildcard src/*.c) OBJS:=$(SOURCES:src/%.c=build/%.o) TARGET:=bin/program all: $(TARGET) $(TARGET): $(OBJS) @mkdir -p bin …
CygnusX1
  • 20,968
  • 5
  • 65
  • 109
8
votes
1 answer

Why is toctree not updating with RTD theme?

I have an programmatically generated sphinx-doc source that uses the Read-The-Docs theme. The source tree looks like: source ├── conf.py ├── index.rst ├── models │   ├── 1lin │   │   ├── 1lin_Amplero.rst │   │   ├── 1lin_Blodgett.rst │   │   ├──…
naught101
  • 18,687
  • 19
  • 90
  • 138
8
votes
1 answer

Makefile implicit rules with different directories

I am following the manual in order to learn more about Makefiles, so I decided to code along and apply this example ( https://www.gnu.org/software/make/manual/make.html#Letting-make-Deduce-the-Recipes ) to the Makefile of my project. The problem is…
Leonard Heldt
  • 123
  • 1
  • 6
8
votes
6 answers

free secure distributed make system for linux

Are there any good language-agnostic distributed make systems for linux that are secure and free? Background Information: I run scientific experiments (computer-science ones) that sometimes have large dependency trees, occasionally on the order of…
Mr Fooz
  • 109,094
  • 6
  • 73
  • 101
8
votes
2 answers

Directory as a dependency in make rule

Is it possible to specify a directory as a dependency in a Makefile rule? Actually I have a Makefile in a directory and another directory containing all the source files. . . |_ Makefile |_ src |_a.c |_a.h Now I want that whenever I make…
Ravi Gupta
  • 6,258
  • 17
  • 56
  • 79
8
votes
2 answers

CMake and add test program command

I use usually makefile for project but I want to start learn CMake. I use makefile not only for build my project but also to test my project. It's very useful. How can I do that with CMake? For exemple this…
Fractale
  • 1,503
  • 3
  • 19
  • 34
8
votes
5 answers

Makefile linking: undefined reference to _exit

I have been trying to create a neatly-organized makefile project template utilizing the ARM mbed library. I have already solved a few of the problems (see this post) related to header file paths. However, now I am having problems with the linker. My…
Caleb Reister
  • 263
  • 1
  • 2
  • 9
8
votes
2 answers

make - define multiple variables in the same eval call

I would like to use make's eval function to define several (dynamically-named) variables inside a foreach, but I can't get eval to do this job. I tried something like this: $(eval \ var1 = val1 \ var2 = val2 \ ) It doesn't work: var1 gets…
lephe
  • 302
  • 4
  • 14
8
votes
1 answer

Get CMake to declare a target phony

I want to generate some compile time constants. The first answer to another question gets me quite close. From my CMakeLists.txt: add_library(${PROJECT_NAME} STATIC ${CXX_SRCS} compile_time.hpp) add_custom_command(OUTPUT compile_time.hpp COMMAND…
pythonic metaphor
  • 10,296
  • 18
  • 68
  • 110
8
votes
1 answer

Makefile: why command substitution can't work in $(shell) function?

I have a variable in Makefile: JAVABIN = $(shell dirname $(which java)) And when I echo the JAVA_HOME variable in Makefile, the variable definition complains: dirname: missing operand Try 'dirname --help' for more information. When I quote the…
zhenguoli
  • 2,268
  • 1
  • 14
  • 31
8
votes
1 answer

How to filter out files with multiple criteria in a Makefile?

Lets say you filter for cpp files like so $(wildcard **/*.cpp) But you don't want files that contain the word foo and you don't want the file with the exact name bar.cpp How does one use filter-out with multiple criteria?
Johnny Haddock
  • 415
  • 3
  • 11
8
votes
1 answer

How to switch between debug and release Makefiles in Eclipse CDT?

For example I have 2 Makefiles: Makefile.Debug and Makefile.Release. I can switch between them by setting different commands in: C/C++ Build -> Builder Settings -> build command : make -f Makefile.Debug -j4 or make -f Makefile.Release -j4, but how…
mrgloom
  • 20,061
  • 36
  • 171
  • 301
8
votes
2 answers

Bash snippet doesn't work in makefile

I have one version file verfile which contains below version string V1.1.2 And in Makefile I intend to read this version string, So I wrote Makefile as follows, filepath := $(PWD) versionfile := $(filepath)/verfile all: …
ART
  • 1,509
  • 3
  • 29
  • 47
8
votes
2 answers

Failure installing xgboost on Mac - ar: no archive members specified

I am trying to install xgboost on Mac. I followed the instructions on github, but when I run make -j4 I get an error: c++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC…
user2725109
  • 2,286
  • 4
  • 27
  • 46
8
votes
7 answers

GCC cant find GMP, MPFR and MPC libraries

I am trying to cross-compile GCC on Mac OS 10.5.7. I used this command to configure GCC after installing GMP, MPFR, and MPC: ../gcc-4.5.0/configure --target=$i586-elf --prefix=/usr/local/cross \ --disable-nls \ …
None
  • 3,875
  • 7
  • 43
  • 67