Recursive wildcards in GNU make?

I would try something along these lines FLAC_FILES = $(shell find flac/ -type f -name ‘*.flac’) MP3_FILES = $(patsubst flac/%.flac, mp3/%.mp3, $(FLAC_FILES)) .PHONY: all all: $(MP3_FILES) mp3/%.mp3: flac/%.flac @mkdir -p “$(@D)” @echo convert “$<” to “$@” A couple of quick notes for make beginners: The @ in front of the commands prevents make from printing … Read more

OS detecting makefile

There are many good answers here already, but I wanted to share a more complete example that both: doesn’t assume uname exists on Windows also detects the processor The CCFLAGS defined here aren’t necessarily recommended or ideal; they’re just what the project to which I was adding OS/CPU auto-detection happened to be using. ifeq ($(OS),Windows_NT) … Read more

Passing additional variables from command line to make

You have several options to set up variables from outside your makefile: From environment – each environment variable is transformed into a makefile variable with the same name and value. You may also want to set -e option (aka –environments-override) on, and your environment variables will override assignments made into makefile (unless these assignments themselves … Read more

Creating Makefile with libraries

Maybe something like # your Makefile #### variables RM= rm -vf CXX= g++ CXXFLAGS= -Wall -g CPPFLAGS= -I/usr/include/opencv -I/usr/include/opencv2 LDLIBS= -lopencv_core -lopencv_imgproc -lopencv_highgui \ -lopencv_ml -lopencv_video -lopencv_features2d \ -lopencv_calib3d -lopencv_objdetect -lopencv_contrib \ -lopencv_legacy -lv4l1 -lv4l2 -lv4lconvert SOURCEFILES= sourc1.cpp sourc2.cpp sourc3.cpp OBJECTFILES= $(patsubst %.cpp,%.o,$(SOURCEFILES)) PROGNAME= yourexe ### rules .PHONY: all clean all: $(PROGNAME) $(PROGNAME): $(OBJECTFILES) $(LINK.cpp) … Read more

Make error: missing separator

As indicated in the online manual, the most common cause for that error is that lines are indented with spaces when make expects tab characters. Correct target: \tcmd where \t is TAB (U+0009) Wrong target: ….cmd where each . represents a SPACE (U+0020).