mirror of
https://gitlab.com/mattia.basaglia/ASCII-Pony.git
synced 2024-11-22 04:07:59 +01:00
89 lines
2.6 KiB
Makefile
89 lines
2.6 KiB
Makefile
PONIES= applejack-nohat \
|
|
fluttershy \
|
|
pinkie-pie \
|
|
rainbow-dash \
|
|
rarity \
|
|
twilight-alicorn \
|
|
twilight-unicorn \
|
|
derpy \
|
|
trixie-hat \
|
|
rose \
|
|
lyra \
|
|
vinyl-scratch-noglasses \
|
|
vinyl-scratch-glasses \
|
|
celestia \
|
|
|
|
MAKEFILE=$(lastword $(MAKEFILE_LIST))
|
|
MAKEFILE_DIR=$(dir $(MAKEFILE))
|
|
PONY_DIR=$(MAKEFILE_DIR)Ponies
|
|
SCRIPT=$(MAKEFILE_DIR)render_parts.php
|
|
OUT_DIR=$(MAKEFILE_DIR)rendered
|
|
OUT_PLAIN=$(addprefix $(PONY_DIR)/,$(addsuffix .txt,$(PONIES)))
|
|
OUT_COLOR=$(addprefix $(OUT_DIR)/,$(addsuffix .colored.txt,$(PONIES)))
|
|
OUT_COLOR_IRC=$(addprefix $(OUT_DIR)/,$(addsuffix .irc.txt,$(PONIES)))
|
|
OUT_SVG=$(addprefix $(OUT_DIR)/,$(addsuffix .svg,$(PONIES)))
|
|
OUT_PNG=$(addprefix $(OUT_DIR)/,$(addsuffix .png,$(PONIES)))
|
|
OUT_BASH=$(addprefix $(OUT_DIR)/,$(addsuffix .sh,$(PONIES)))
|
|
OUT_ALL= $(OUT_COLOR) $(OUT_PLAIN) $(OUT_SVG) $(OUT_PNG) $(OUT_BASH) $(OUT_COLOR_IRC)
|
|
OUT_DIRS=$(sort $(dir $(OUT_ALL)))
|
|
find_deps=$(addprefix $(PONY_DIR)/,$(subst ;,\\\;,$(wildcard $(1)/*)))
|
|
|
|
.PHONY: show show_deps cleans list random
|
|
|
|
all: $(OUT_ALL)
|
|
|
|
define rule_template
|
|
$(OUT_DIR)/$(1).colored.txt: | $(dir $(OUT_DIR)/$(1))
|
|
$(OUT_DIR)/$(1).colored.txt: $(call find_deps, $(1))
|
|
$(OUT_DIR)/$(1).colored.txt: $(PONY_DIR)/$(1)
|
|
$(SCRIPT) $(PONY_DIR)/$(1) >$(OUT_DIR)/$(1).colored.txt
|
|
|
|
$(PONY_DIR)/$(1).txt: $(call find_deps, $(1))
|
|
$(PONY_DIR)/$(1).txt: $(PONY_DIR)/$(1)
|
|
$(SCRIPT) $(PONY_DIR)/$(1) >$(PONY_DIR)/$(1).txt nocolor
|
|
|
|
$(OUT_DIR)/$(1).svg: | $(dir $(OUT_DIR)/$(1))
|
|
$(OUT_DIR)/$(1).svg: $(call find_deps, $(1))
|
|
$(OUT_DIR)/$(1).svg: $(PONY_DIR)/$(1)
|
|
$(SCRIPT) $(PONY_DIR)/$(1) >$(OUT_DIR)/$(1).svg svg
|
|
|
|
$(OUT_DIR)/$(1).sh: | $(dir $(OUT_DIR)/$(1))
|
|
$(OUT_DIR)/$(1).sh: $(call find_deps, $(1))
|
|
$(OUT_DIR)/$(1).sh: $(PONY_DIR)/$(1)
|
|
$(SCRIPT) $(PONY_DIR)/$(1) >$(OUT_DIR)/$(1).sh bash
|
|
chmod a+x $(OUT_DIR)/$(1).sh
|
|
|
|
|
|
$(OUT_DIR)/$(1).irc.txt: | $(dir $(OUT_DIR)/$(1))
|
|
$(OUT_DIR)/$(1).irc.txt: $(call find_deps, $(1))
|
|
$(OUT_DIR)/$(1).irc.txt: $(PONY_DIR)/$(1)
|
|
$(SCRIPT) $(PONY_DIR)/$(1) >$(OUT_DIR)/$(1).irc.txt irc
|
|
endef
|
|
define dir_rule_template
|
|
$(1) :
|
|
mkdir -p $(1)
|
|
endef
|
|
|
|
%.png : %.svg
|
|
inkscape $*.svg -e $*.png
|
|
|
|
$(foreach pony,$(PONIES),$(eval $(call rule_template,$(pony))))
|
|
$(foreach directory,$(OUT_DIRS),$(eval $(call dir_rule_template,$(directory))))
|
|
|
|
show: $(OUT_DIR)/$(PONY).colored.txt
|
|
@cat $(OUT_DIR)/$(PONY).colored.txt
|
|
|
|
show_deps:
|
|
@$(foreach d,$(call find_deps,$(PONY)), echo $(d);)
|
|
|
|
clean:
|
|
rm -f $(OUT_ALL)
|
|
rmdir --ignore-fail-on-non-empty $(OUT_DIRS) $(OUT_DIR)
|
|
|
|
list:
|
|
@$(foreach pony,$(PONIES), echo $(pony);)
|
|
|
|
random: PONY=$(shell make -f $(MAKEFILE) list | shuf | head -n 1)
|
|
random:
|
|
@make -f $(MAKEFILE) show PONY=$(PONY)
|
|
|