Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » How do you force a target to be always ran? (GNU Make)
- StackMasher
- Scratcher
100+ posts
How do you force a target to be always ran? (GNU Make)
I've written this makefile:
And I want %/ to be always ran. .PHONY doesn't seem to work, what else could I try?
PATHS := ${shell echo */ | grep -v "*/"}
OBJ := ${subst cpp,o,${shell echo *.cpp | grep -v "*.cpp"}}
.PHONY: build
build : $(PATHS)
@echo ═════════════════════════════════════════
@echo [*] Linking
@echo ═════════════════════════════════════════
mkdir -p build
-mv ${shell find src -type f -name "*.o"} build
$(CXX) $(CXXFLAGS) ${shell echo build/*.o} -lSDL2 -lSDL2_image -o NewSuperTux
.PHONY: subdirectory
subdirectory : $(PATHS) $(OBJ)
rm makefile
@echo ------- Finished $*/ -------
.PHONY: clean
clean :
@echo ═════════════════════════════════════════
@echo [*] Cleaning up
@echo ═════════════════════════════════════════
rm -rf build
%/ :
@echo ═════════════════════════════════════════
@echo [!] Entering subdirectory $*/
@echo ═════════════════════════════════════════
cp makefile $*/
cd $* && make subdirectory
%.o : %.cpp
@echo ═════════════════════════════════════════
@echo [*] Compiling $^
@echo ═════════════════════════════════════════
$(CXX) $(CXXFLAGS) -c $^
- Jonathan50
- Scratcher
1000+ posts
How do you force a target to be always ran? (GNU Make)
You could put it as a dependency of the targets that you're going to use from the command line, couldn't you?
(The .PHONY means that the target isn't meant to output the file that has the name of the target)
(The .PHONY means that the target isn't meant to output the file that has the name of the target)
Last edited by Jonathan50 (March 27, 2017 04:03:45)
Not yet a Knight of the Mu Calculus.
- StackMasher
- Scratcher
100+ posts
How do you force a target to be always ran? (GNU Make)
I did this
https://github.com/RealPipeline/NewSuperTux/blob/master/makefile
.PHONY: FORCE
%/ : FORCE
boom
- Discussion Forums
- » Advanced Topics
- » How do you force a target to be always ran? (GNU Make)