convert=/usr/bin/convert identify=/usr/bin/identify imgs_nb=$(patsubst %_nb.png,%,$(wildcard *_nb.png)) .PHONY: all_wrapped all_wrapped: remove_spaces @$(MAKE) all .PHONY: remove_spaces remove_spaces: @find . -name "* *" -exec rename -v 's/ /_/g' '{}' ';' #IMG = $(shell ls --quoting-style="escape" */*.jpeg */*.JPEG */*.jpg */*.JPG */*.png */*.PNG */*.gif */*.GIF 2>/dev/null) #IMG = $(wildcard */*.jpeg */*.JPEG */*.jpg */*.JPG */*.png */*.PNG */*.gif */*.GIF) #IMG = $(shell find . -iregex ".*\.\(jpeg\|jpg\|gif\|png\)"|grep -v "\.img/") # ignore directories where there is a .img/ignore file IGNORE = $(shell find . -path '*/.img/ignore'|sed -r 's@^(.*)/.img/ignore$$@-path '\''\1'\''@;2,$$s/^/-o /') FORCE = $(shell find . -path '*/.img/force'|sed -r 's@^(.*)/.img/force$$@'\''\1'\''@') # find picture files not in $(IGNORE) directories nor in */.img IMG = $(shell find . $(FORCE) \( -path '*/.img' $(if $(IGNORE),-o $(IGNORE)) \) -prune -o \( -iregex '.*\.\(jpeg\|jpg\|gif\|png\)' -print \)) #TOREMOVE = $(filter-out $(THUMBS) $(SIZES) $(TITLES) $(DESCRIPTIONS),$(shell find . -type f \( $(IGNORE) -name 'sdfsdfsdfsdf' \) -prune -o \( -iregex '.*/\.img/.*' -print \)|grep -v .exists)) .PHONY: all clean all: $(imgs:%=%_col.png) # @rm -f $(TOREMOVE) 2>/dev/null || true define IMG_template THUMBS += $(dir $(i)).img/thumb/$(notdir $(i)) SIZES += $(dir $(i)).img/size/$(notdir $(i)) TITLES += $(dir $(i)).img/title/$(notdir $(i)) DESCRIPTIONS += $(dir $(i)).img/description/$(notdir $(i)) $(dir $(i)).img/thumb/$(notdir $(i)): $(i) $(dir $(i)).img/thumb/.exists $(dir $(i)).img/size/.exists @echo -n "generating thumbnail for $$<..." @$(convert) -size "512x512>" -thumbnail "128x128>" "$$<" "$$@" \ && echo "done." $(dir $(i)).img/size/$(notdir $(i)): $(i) @echo -n "computing size of $$<..." @$(identify) -format '%wx%h\n' '$$<' | head -1 > '$$@' \ && echo "done." endef %/.exists: @mkdir -p $(dir $@) && touch $@ $(foreach i,$(IMG),$(eval $(call IMG_template,$(i)))) all: $(THUMBS) $(SIZES) clean: @echo -n "cleaning thumbnails..." @rm -f $(THUMBS) $(SIZES) \ && echo "done." $(imgs_nb:%=%_col.png): %_col.png: %_nb.png Makefile $(convert) $< -channel green -fx 'g*g' -channel blue -fx 'b*b' -background 'rgb(255,255,255)' $@ .PHONY: list list2 list2: @echo IGNORE=$(IGNORE) @echo FORCE=$(FORCE) list: @echo $(IMG)