Run make in each subdirectory

There are various problems with doing the sub-make inside a for loop in a single recipe. The best way to do multiple subdirectories is like this: SUBDIRS := $(wildcard */.) all: $(SUBDIRS) $(SUBDIRS): $(MAKE) -C $@ .PHONY: all $(SUBDIRS) (Just to point out this is GNU make specific; you didn’t mention any restrictions on the … Read more

How to use GNU Make on Windows?

Explanation Inside directory C:\MinGW\bin there is an executable file mingw32-make.exe which is the program make you are trying to run. You can use the keyword mingw32-make and run the program make since you have added the needed directory to the system path, but it is not an easy to remember keyword. Solution Renaming the file … Read more

How to change the extension of each file in a list with multiple extensions in GNU make?

Substituting extensions in a list of whitespace-separated file names is a common requirement, and there are built-in features for this. If you want to add an x at the end of every name in the list: FILES_OUT = $(FILES_IN:=x) The general form is $(VARIABLE:OLD_SUFFIX=NEW_SUFFIX). This takes the value of VARIABLE and replaces OLD_SUFFIX at the … Read more

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