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
2 answers

make: pattern rule matching multiple extensions

I have duplicated pattern rules for several extensions (eg: cpp and cc): $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp @$(CXX) $(CPPFLAGS) -I. -o $@ -c $? $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cc @$(CXX) $(CPPFLAGS) -I. -o $@ -c $? Is there a way to have one…
Steve Lorimer
  • 27,059
  • 17
  • 118
  • 213
8
votes
1 answer

Is it possible to add a dependency to another Makefile?

I'm not asking if it is possible to call Makefile from another Makefile. Suppose I have a rule for generating an executable which looks like this: my-prog: some.o local.o dependencies.o Note that I'm exploiting built-in rules here. Now suppose I…
cYrus
  • 2,976
  • 6
  • 29
  • 47
8
votes
1 answer

Prevent GNU make from expanding dollar signs in environment variables

Is there any way to make GNU Make interpret dollar signs literally in environment variables? Take this makefile: echoFOO: echo '$(FOO)' Run it like this: $ FOO='a$bc' make echo 'ac' ac I'd like this to echo a$bc literally, but I can't find…
Doradus
  • 938
  • 1
  • 9
  • 15
8
votes
3 answers

CMake does not properly find CUDA library

I'm trying to build a program that requires CUDA. To the CMake script I supply: cmake -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda .. CUDA is found and CMake runs normally: staudt ~/workspace/clutbb/cluster/build $ cmake -D…
clstaudt
  • 21,436
  • 45
  • 156
  • 239
8
votes
3 answers

Broken tab completion on make under linux

I have no idea how tab completion works, but all of a sudden mine is broken. I don't even know what info to provide other than the use case. there is a target clean in the makefile. $ make c results in $ make c23:set: command not…
Ciprian Tomoiagă
  • 3,773
  • 4
  • 41
  • 65
8
votes
4 answers

How to make a struct maker like CGRectMake (iphone)

i have a struct HLRange with two CGFloat's struct HOLRange { CGFloat min; CGFloat max; }; typedef struct HOLRange HOLRange; but how do i make a function like HLRangeMake(1,2); .. like CGRectMake? --EDIT-- my header file #import…
Andy Jacobs
  • 15,187
  • 13
  • 60
  • 91
8
votes
2 answers

Vim: Restart Syntax Highlighting from Arbitrary Line

I have discovered an interesting edge-case in Vim syntax highlighting. Consider the following snippet from a company Makefile: LDSCRIPT := $(subst ",,$(CONFIG_SYS_LDSCRIPT)) The above line simply removes double quotes from a given LDSCRIPT. …
MysteryMoose
  • 2,211
  • 4
  • 23
  • 47
8
votes
2 answers

DistCC and CMake - select between local and distributed build when running make

My project is build using CMake and is compiled with DistCC + GCC. I configure the compiler as follows: SET(CMAKE_C_COMPILER "distcc variation-of-gcc") To build the project, I simply run 'cmake' and then 'make -jXX'. Although distcc really speeds…
oferlivny
  • 300
  • 4
  • 15
8
votes
3 answers

How to print messages after make done with cmake?

I'm trying to print messages after building process done using CMake. I just want to inform the user after make command is done without any error. How can I do it? I tried add_custom_target() but I cannot choose when to run. Also, I tried…
Genie
  • 185
  • 1
  • 8
8
votes
5 answers

How to check existence of the target in a makefile

I want to run certain action in the shell depending on whether a default makefile in the current directory contains a certain target. #!/bin/sh make -q some_target if test $? -le 1 ; then true # do something else false # do something else …
sshilovsky
  • 958
  • 2
  • 9
  • 22
8
votes
2 answers

How to do Makefile dependencies for python code

I have a bunch of C files that are generated by a collection of python programs that have a number of shared python modules and I need to account for this in my make system. It is easy enough to enumerate which python program need to be run to…
Gordon Wrigley
  • 11,015
  • 10
  • 48
  • 62
8
votes
1 answer

error while running make install - include/generated/autoconf.h or include/config/auto.conf are missing

when i try to run make install on my custom built kernel, I get following error- root@localhost [ /home/avi/dd/labs/lab1_compile_and_load ]$ make install V=1 make -C /lib/modules/3.12.17/build SUBDIRS=/home/avi/dd/labs/lab1_compile_and_load …
avee137
  • 421
  • 2
  • 7
  • 15
8
votes
1 answer

Why does bash freeze in windows?

I am running the bash program in windows which was installed along with msys and mingw. I am trying to run ./configure. However whenever I do it the configuration freezes on "checking whether make sets $(MAKE)". Can you think of any reason why and…
Logan Murphy
  • 6,120
  • 3
  • 24
  • 42
8
votes
2 answers

Compiling out-of-tree kernel module against any kernel source tree on the filesystem

I am trying to compile a module against any source tree on the file system but I am having trouble with the Makefile. This was the original Makefile I had against the kernel specified: obj-m += new-mod.o all: make -C /lib/modules/$(shell…
Chris Fritz
  • 281
  • 2
  • 4
  • 14
8
votes
1 answer

Run a command in GNU and BSD Makefile and store the result into a variable

I would like to execute a command in a Makefile, store the result to a variable and reuse the result later. In BSD Makefile, I can use the != operator: PASSWORD != openssl rand -base64 48 In GNU Makefile, I can use the shell function: PASSWORD :=…
Dereckson
  • 1,340
  • 17
  • 30