Skip to content

Instantly share code, notes, and snippets.

@mgerdts
Last active July 18, 2019 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgerdts/00a00311307f396e18b37e4721356377 to your computer and use it in GitHub Desktop.
Save mgerdts/00a00311307f396e18b37e4721356377 to your computer and use it in GitHub Desktop.
can make handle % in file names?
THINGS = foo%bar foo.bar
SRCS = $(THINGS:%=src/%)
OBJS = $(THINGS:%=obj/%)
install: $(OBJS)
obj/%: src/%
@echo Making $@ from $<
rm -f $@
cp -f $< $@
chmod 444 $@
setup: src obj $(SRCS)
touch src/food_at_the_bar
touch src/foolbar
src obj:
mkdir -p $@
src/%: src
touch $@
clean:
rm -rf src obj
$ make clean
rm -rf src obj

$ make setup
mkdir -p src
mkdir -p obj
touch src/foo%bar
touch src/foo.bar
touch src/food_at_the_bar
touch src/foolbar

$ make install
Making obj/foo%bar from src/foo%bar
rm -f obj/foo%bar
cp -f src/foo%bar obj/foo%bar
chmod 444 obj/foo%bar
Making obj/foo.bar from src/foo.bar
rm -f obj/foo.bar
cp -f src/foo.bar obj/foo.bar
chmod 444 obj/foo.bar

$ find obj
obj
obj/foo.bar
obj/foo%bar

$ type make
make is hashed (/home/mgerdts/buglets/projects/illumos/usr/src/tools/proto/root_i386-nd/opt/onbld/bin/i386/make)

$ make -v
make: illumos make
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment