added sed command in makefile to concat quine
This commit is contained in:
@@ -49,6 +49,7 @@ CFLAGS += -g3
|
||||
# AUTOMATICALLY CREATED :
|
||||
D_OBJS = builds
|
||||
OBJS = $(SRCS:%.$(EXT)=$(D_OBJS)/%.o)
|
||||
EXPLODED = $(SRCS:%.$(EXT)=%_exploded.$(EXT))
|
||||
VPATH = $(D_SRCS)
|
||||
F_INCLUDES = $(HEADERS:%=$(D_HEADERS)/%)
|
||||
INCLUDES = -I$(D_HEADERS)
|
||||
@@ -65,7 +66,18 @@ endif
|
||||
# . recipe . $^ : all prerequisites #
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||
|
||||
all: $(NAME)
|
||||
all: concat $(NAME)
|
||||
|
||||
# sed :
|
||||
# -z : instead of classic "-e", looks for lines that ends with \0 instead of \n, usefull when lines can contain \n
|
||||
# 's/\\\n\t*//g' : subsitutes backslash '\\' followed by newline '\n' followed by any number of tabs '\t*', and replace them by nothing
|
||||
# empty recipe :
|
||||
# - to avoid makefile complaining when $(EXPLODED) does not exist
|
||||
# - https://www.gnu.org/software/make/manual/html_node/Empty-Recipes.html
|
||||
concat: $(EXPLODED)
|
||||
@echo $(CYAN)"create the condensed version of the quine :"$(RESET)
|
||||
- test -f $< && sed -z 's/\\\n\t*//g' $< > $(SRCS)
|
||||
$(EXPLODED): ;
|
||||
|
||||
# %.$(EXT) | $(D_OBJS) -> pipe is for order-only prerequisites :
|
||||
# - for each file "%.$(EXT)" :
|
||||
@@ -74,6 +86,8 @@ all: $(NAME)
|
||||
# - and directory "$(D_OBJS)" is order-only prerequisite :
|
||||
# - it must exist before executing rule
|
||||
# - but last time modification is not checked
|
||||
# - it avoids recompiling each time because the build folder was
|
||||
# modified by creation of other objects files
|
||||
$(D_OBJS)/%.o: %.$(EXT) | $(D_OBJS)
|
||||
@echo $(CYAN)"compilation (objects.o) :"$(RESET)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
@@ -104,6 +118,6 @@ fclean: clean
|
||||
|
||||
re: fclean all
|
||||
|
||||
.PHONY : all clean fclean re
|
||||
.PHONY : all clean fclean re concat diff leaks
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user