Skip to content

Instantly share code, notes, and snippets.

@CapnKernel
Created October 6, 2012 04:43
Show Gist options
  • Save CapnKernel/3843897 to your computer and use it in GitHub Desktop.
Save CapnKernel/3843897 to your computer and use it in GitHub Desktop.
CONVERT=echo convert
CONVERT_FLAGS=-resize 60% -quality 80
# Get a list of all .jpg and .JPG files, except for ones with '-resize' in the name
IN_FILES:=$(shell find -iname '*.jpg' | grep -v -- "-resize")
$(info IN_FILES=$(IN_FILES))
# From that list, generate a list of output filenames.
# We do this in two lines, one for .jpg, and one for .JPG
OUT_FILES_tmp:=$(patsubst %.jpg,%-resize.jpg,$(IN_FILES))
OUT_FILES:=$(patsubst %.JPG,%-resize.JPG,$(OUT_FILES_tmp))
$(info OUT_FILES=$(OUT_FILES))
all: $(OUT_FILES)
%-resize.jpg: %.jpg
$(CONVERT) $(CONVERT_FLAGS) $< $@
%-resize.JPG: %.JPG
$(CONVERT) $(CONVERT_FLAGS) $< $@
@CapnKernel
Copy link
Author

foo.o: foo.c
gcc -o foo.o -c foo.c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment