make,gnu-make , Match-Anything Pattern Rules

Match-Anything Pattern Rules


Tag: make,gnu-make

I am using GNU Make 3.81 version.

From the following example, I expect match anything pattern(%:) has to be print. Instead of that te%: has executed.

Can some one explain, why target '%:' did not run?

Is this not match all file name?


all: test
    echo [email protected]
    echo 1: [email protected]
    echo 2: [email protected]


echo 2: test
2: test
echo all


There are special rules for how make treats match-anything pattern rules; see the documentation. You are creating a "non-terminal match-anything rule" here, and the rule for that is this:

A non-terminal match-anything rule cannot apply to a file name that indicates a specific type of data. A file name indicates a specific type of data if some non-match-anything implicit rule target matches it.

In your case you have a non-match-anything implicit rule target (te%) which matches the file name (test) and so a non-terminal match-anything rule (%:) cannot match it.


force a script to run at the beginning of a makefile, and display its output

I have a script which generates a version.h file with various details about the particular build The script runs various commands, such as: readonly VERSION=$(git describe --always --dirty --long --tags) readonly NUM_COMMITS=$(git rev-list HEAD | wc -l | bc) readonly BRANCH=$(git rev-parse --abbrev-ref HEAD) readonly AHEAD_BY=$(git log --oneline origin/${BRANCH}..${BRANCH} |...

makefile library dependencies - resolve circular dependency

I am trying to build a feature into my makefile which allows me to specify a list of libraries a particular library depends on This will allow dependants of a library to automatically be rebuilt if that library's dependencies are rebuilt, and also have the dependencies added to the link...

How to put this command in a Makefile?

I have the following command I want to execute in a Makefile but I'm not sure how. The command is docker rmi -f $(docker images | grep "<none>" | awk "{print \$3}") The command executed between $(..) should produce output which is fed to docker rmi but this is not...

LFS 7.2: Hundreds of errors in glibc make check

I am on Section 6.9 of the LFS book. Everything before this section seemed fine. When I ran make check I got a huge number of errors. A longer transcript of my make check run can be found here on Pastebin. Summary of test results: 865 FAIL 1308 PASS 202...

Autodependency generation in makefiles

I am trying to understand how autodependency is generated in makefiles in the given link, i cannot understand the following piece of code: DEPDIR = .deps df = $(DEPDIR)/$(*F) SRCS = foo.c bar.c ... %.o : %.c @$(MAKEDEPEND); \ cp $(df).d $(df).P; \ sed -e 's/#.*//' -e 's/^[^:]*: *//' -e...

makefile read reused variable inside recipe

In trying to implement nonrecursive make, I have a which looks like: ############ # Enter Stack ############ sp := $(sp).x dirstack_$(sp) := $(d) d := $(dir) .. setup things like OBJECTS_$(d), DEPS_$(d), TARGET_$(d), etc ... ############ # Exit Stack ############ -include $(DEPS_$(d)) d := $(dirstack_$(sp)) sp := $(basename $(sp))...

Why does gcc search header files from non-exist folders?

I am trying to build an open source project shark on CentOS 7, and get very weird build errors: make: *** No rule to make target `/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdarg.h', needed by `core/luv/luv.o'. make: *** No rule to make target `/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h', needed by `core/luv/luv.o'. make: *** No rule to make target `/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed/limits.h', needed...

How does MAKE remember the file timestamps

I've found this question which is basically asking the same, but got no real answer. Where is the make's config file / database file where it remembers the file timestamps, so it can tell what changed? I checked and there's no .make or similar in my project, nor in the...

Dot in front of variables in make files

I am not able to figure out what does a dot . in front of a variable in makefile does. For e.g.: SOURCEDIRS = . $(PROJECTDIRS) $(TARGET_DIRS_CONCAT) vpath %.c $(SOURCEDIRS) It would be great if someone could tell me. Thanks!...

make error during building webkitgtk

I use UBuntu 14.04 LTS. I need to build webkitgtk 2.8.3 Here is an example instruction which I have used: linuxfromscratch When I run sudo make -j8 I get following log: Scanning dependencies of target JavaScriptCore-4-gir Scanning dependencies of target fake-generated-webkitdom-headers [ 0%] Scanning dependencies of target WebKit2-fake-api-headers Scanning dependencies...

Open Pegasus 2.14.1 client connection issue

I would like to build new version of Open Pegasus Client (2.14.1). Unfortunately I'm facing with some build issues. Does anybody know some workaround for these issues? My environment is: OS: Windows 8.1 Enterprise Make version: GNU Make 3.81 Pegasus sources version: 2.14.1 OpenSSL version: 1.0.2a My scenario is quite...

basic makefile ifeq how to

I am just learning about Makefiles and am having trouble with ifeq. Version = GNU Make 3.82 Here is my simple Makefile: CHECK := 0 CHECK2 := 0 check : @echo "Check=${CHECK}" @echo "Check2=${CHECK2}" ifeq (${CHECK2},${CHECK}) @echo "EQUAL" else @echo "NOT EQUAL" endif Here is the output: Check=0 Check2=0 NOT...

Makefile : fclean gives error if program is not yet built

I have 2 makefiles that crash when I use the command make re if the program (or library) is not yet previously built, because make re calls fclean, which should remove the file and crashes if the file is not found. Here is one of the makefiles for a library...

Ocamlfind command not found

I'm running into an issue installing a package that's reliant on ocamlfind but I'm getting an ocamlfind: command not found error when making. I have installed ocamlfind with the ocaml package manager and have tried reinstalling using "opam reinstall ocamlfind". I have also tried the 'eval opam config env' command...

GNU make equivalent to BSD make's $(var:Q)?

BSD make has a :Q variable expansion modifier, documented in the FreeBSD make man page as follows: :Q Quotes every shell meta-character in the variable, so that it can be passed safely through recursive invocations of make. If variable var has value a b\c"d'e$f, then $(var:Q) expands to a\ b\\c\"d\'e\$f...

make target with multiple extension

How to do the following in gnu make (on mac). I have files with extendion .js and .jsx which needs to go through the build. SRC = $(shell find src -name '*.js' -o -name '*.jsx') LIB = $(SRC:src/%=lib/%) lib/%.js: src/%.js @echo "building [email protected]" above only define the target for *.js...

Makefile overriding default implicit rule

Why this rule cannot override the default implicit rule ? When make is invoked like: make myapp (suppose myapp.c is there). The make runs the default command to build and link the program instead the commands defined in this implicit rule: #... omitted code LCUS=$(LIBS)/libcus.a #... omitted code % :...

Eclipse Makefile: Make Variables are skipped

I have a project with a Makefile in it, on Unix console it works fine, compiles, builds and I can run the binary at the end. I imported the project into Eclipse workspace and somehow Makefile module of Eclipse cannot build the project now. It gives the following error: g++:...

Make: How to process many input files in one invocation of a tool?

I have a data conversion process that is driven by GNU make. It takes human-generated input files and creates output files using a conversion progam. Obviously this is about as simple as a makefile can get: inputs=$(wildcard *.input) outputs=$(subst .input,.output, $(inputs)) .PHONY: all all: $(outputs) %.output: %.input converter $< -o...

Reuse jquery plugin without conflict

I have a little plugin working as a progressbar. the problem is: I can't update progressbar's value because every change I made, affect just the last object created =( also.. if I call it as: $(node-selector).progBar().setValue() it works calling the correct node but it loss the config object follow the...

what does -wl, --start-group mean in make file?

I have this in my Make file.. # Create list of object files # LIB_OBJS = -Wl,--start-group \ $(T_OBJ_DIR)/Source1.o \ $(T_OBJ_DIR)/Source2.o \ $(T_OBJ_DIR)/Source3.o \ $(T_OBJ_DIR)/Source4.o \ $(T_OBJ_DIR)/Source5.o \ -Wl,--end-group \ Could anyone please explain What "-Wl,--start-group" and "-Wl,--end-group" mean?...

What does $(@:.h=.h.d) mean in GNU make?

I'm maintaining a (horrendously complicated) Makefile, and in some recipes I saw the following: $(@:.h=.h.d) I have absolutely no clue as to how to interpret this, or whether there's any documentation on those characters. Obviously, Google won't work because it thinks I'm typing gibberish. I saw a related question about...

Haskell make recipe fails for Paradox theorem prover using GHC

I am trying to install the paradox theorem prover sourced from here. When I run the makefile this is the command that runs: ghc -optl -static -lstdc++ -I../instantiate -I../minisat/current-base ../minisat/current-base/Solver.or ../minisat/current-base/Prop.or ../instantiate/MiniSatWrapper.or ../instantiate/MiniSatInstantiateClause.or -fglasgow-exts -O2 -static -threaded -main-is Paradox.Main.main --make Paradox.Main -o paradox And it results in several errors like...

Do you only need to build the googletest library once?

So firstly I'm new to testing frameworks and relatively new to C++ but am trying to wrap my head around GoogleTest. I'm working on a Windows machine, running "Git for Windows" (MSYS) and MinGW whilst using Sublime Text as my code editor. I am using make as my build tool,...

make: *** No rule to make target 'rm', needed by 'clean.Stop

I am working with cygwin on windows 8.1. I have used the following make file .SUFFIXES : .o .C CFLAGS = -g2 CC =g++ ${CFLAGS} LIBRARIES = -lm .C.o : ${CC} -c $< SOURCE-FILES = sparsegraph.C myvarious.C pairlist.C graphlist.C peo.graph.C choldc.C copy.C metropolis_fns.C likelihood.C metropolis.C OBJECT-FILES = sparsegraph.o myvarious.o pairlist.o...

What does the following makefile command do? /no-symbols-control-file

I cam across the following command in a makefile: %-nosyms.$(TARGET).elf: $(PROJECT_OBJECTFILES) $(INTERRUPT_OBJECTFILES) contiki-$(TARGET).a $(CC) $(CFLAGS) -o [email protected] $(filter-out %.a,$^) $(filter %.a,$^) $(filter %.a,$^) $(LDFLAGS) Source: Contiki/cpu/arm/stm32f103/Makefile.stm32f103 . Does this command generate no-symbols-control-file? What is the use of a no symbol image file?...

Can Make be made to understand that a/../z and b/../z are the same location?

I have a somewhat large and complex Makefile setup that postprocesses some data files. Overall it work quite well, but I have run into an annoying issue where Make builds the same target many times over under different directory names. As a simple example, consider the Makefile foo : 1/foo...

GNU make - depend only on file existence and not modification time

I want to have a makefile in which I have a task a that can only run if a file b exists, but does not need to be re-run if b is updated. How do I do this?

xcode 6.3.2 external build

I'm trying to compile an existing c++ project, originally developed on linux with gcc. The only external library is GSL (GNU Scientific Library). I have created an external build tool project to use xcode's debugger, but I currently have two issues. 1) When I try to build in xcode it...

Nested For loop in makefile

I am trying to loop through the .c files in a specific directory through the makefile. i used the following code, but it seems not working: DIR= Sources \ Sources_2 @for entry in ${DIR} ; \ do \ @for i in $${entry}/*.c ; \ do \ echo "Processing $${i}"; \...

Pattern rule with partial dependency

I have a makefile with a bunch of .R scripts that create .csv files as output. These files are then used in a python simulation. all: $(FILES) python $(FILES): %.csv: %.R Rscript $< This is straightforward. My wrinkle is that one (and only one) of the .R scripts has...

Would GNU Make automatically add extra prerequisite?

The following example snippet is from "Managing Projects with GNU Make(3rd edition)" p.21. count_words: counter.o lexer.o -lfl The author says that make will automatically add count_words.o to prerequisite list by implicit rule. Quoted: ..., make identifies four prerequisites: count_words.o (this prerequisite is missing from the makefile, but is provided by...

add dependencies to a library, and add them to a binary which depends on that library

What I have: I have a non-recursive makefile which searches for files, and includes them modules := $(shell find . -name include $(modules) If I want to create a static library, the looks like this: $(eval $(call make-lib, test_lib)) Which will find a list of all .cpp...

A make rule for verbosity

Typically we have this in a Makefile %.o:%.c $(cc) $(flags) -o [email protected] -c $< When the amount of flags is huge, I feel better to write this instead %.o:%.c $(info $(cc): $< --> [email protected]) @$(cc) $(flags) -o [email protected] -c $< However it can be useful to sometime see everything. So...

How to build a './configure && make && make install' software against a custom library which I also build?

I am building tmux-2.0 from sources on a pretty regular Linux host. First attempt failed as it turned out that the version of libevent installed is older than required, so I proceeded to download and build libevent-2.0.22 from sources (current at the time of writing) first. Building of libevent succeeded...

mono make install fails with “Error 1”

I've finally managed to get mono to build from sources, but make install invoked from the top build directory fails at the following point: make[6]: Entering directory `/bld/mono/mono-4.0.0/mcs/class/System' make install-local WARNING: generic atexit() called from legacy shared library make[7]: Entering directory `/bld/mono/mono-4.0.0/mcs/class/System' MONO_PATH="./../../class/lib/build:$MONO_PATH" /bld/mono/mono-4.0.0/runtime/mono-wrapper ./../../class/lib/build/gacutil.exe /i ./../../class/lib/net_4_5/System.dll /f /root /usr/mono/lib...

How “make” command locates makefile

I am trying to understand the working of "make" command (just started on this command). I have an ".sh" file which has a script to execute "make" command as shown below: source /somepath/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi make arch=arm toolchainPrefix=arm-poky-linux-gnueabi- xeno=off mode=Debug all The directory where the script file is located has a file...

Avr-g++ compilation failed with Make Error 1

I'm trying to compile arduino code in Eclipse. Below is build log. make all Building file: ../test.cpp Starting C++ compile "/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=163 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I"/opt/arduino-1.6.3/hardware/arduino/avr/cores/arduino" -I"/opt/arduino-1.6.3/hardware/arduino/avr/variants/standard" -I/usr/lib/avr/include -MMD -MP -MF"test.cpp.d" -MT"test.cpp.d" -D__IN_ECLIPSE__=1 -x c++ "../test.cpp" -o...

How to correctly make install of binaries and data after compile in linux?

After make of sources I have compiled executable file and data directory with images for it. What should I do at "make install" phase to correctly install these files to the linux system? And how then application can find installed data (in case when binary and data are placed in...

Visual Studio Make instead of GNU Make with Cygwin

I'm still trying to build VTK on windows. I have installed Cygwin and I'm done configuring with CMake I think. However I'm facing the error that you can see on the screenshot below: the make command somehow tries to make through MS Visual Studio while I want to use the...

Is setting environment variable through a makefile - possible?

I'd like to take advantage of MALLOC_PERTURB_ environment variables that can change memory allocation parameters (man 3 mallopt). However, I'd like to control allocation parameters on application level, not entire system level. Ideally, if I could control them through project's makefile. I've tried to change mentioned variables through makefile, yet,...

What's the difference between [email protected] and $1 when there is only one parameter?

There are some C code: apple.c #include<stdio.h> int main(void) { printf("apple\n"); return 0; } Makefile apple: gcc -c [email protected] gcc [email protected] -o [email protected] $ make apple and it works perfectly. But if I modify Makefile as: apple: gcc -c $1.c gcc $1.o -o $1 $ make apple It does not...