From 1def5bd819633ec847c6399985063d1d3f4fca95 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 23 Jan 2013 13:01:51 -0500 Subject: [PATCH] Makefile: Quote all $@ and $< expansion To protect against spaces and special characters in their values. --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 44af03e..97390cb 100644 --- a/Makefile +++ b/Makefile @@ -120,11 +120,11 @@ dist: # certainly allowed to go that route if you wish. .SECONDEXPANSION: $(C_PROGRAMS): % : $$($$(@)_OBJECTS) - $(CC) $(LDFLAGS) -o $@ $^ $($(@)_LIBS) + $(CC) $(LDFLAGS) -o "$@" $^ $($(@)_LIBS) .SECONDEXPANSION: $(CXX_PROGRAMS): % : $$($$(*)_OBJECTS) - $(CXX) $(LDFLAGS) -o $@ $^ $($(@)_LIBS) + $(CXX) $(LDFLAGS) -o "$@" $^ $($(@)_LIBS) # target: run - use the program for its intended purpose # Here we just execute RUN_PROGRAM, but you could also use something @@ -152,12 +152,12 @@ run: $(PROGRAMS) # for example, try # $ make CXX=/usr/local/bin/g++ CXXFLAGS=-Wall %.o: %.cpp - $(CXX) $(CXXFLAGS) -c $< + $(CXX) $(CXXFLAGS) -c "$<" # Pattern rule for compiling object files from C source # The comments from the C++ rule above also apply here %.o: %.c - $(CC) $(CFLAGS) -c $< + $(CC) $(CFLAGS) -c "$<" # target: print-% - display a variable value (e.g. print-PROGRAMS) # Take some of the mystery out of variable manipulation. For example, -- 2.26.2