sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit a2e704c8c9d1a8bda9747d021bebc0ee8c67be7a
parent 654997c32087d25133139accd6c1957651bc398e
Author: Evan Gates <evan.gates@gmail.com>
Date:   Fri, 20 Feb 2015 12:12:12 -0800

use parameter expansion instead of basename in Makefile

Diffstat:
MMakefile | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile @@ -199,19 +199,19 @@ dist: clean sbase-box: $(LIB) $(SRC) mkdir -p build cp $(HDR) build - for f in $(SRC); do sed "s/^main(/`basename $$f .c`_&/" < $$f > build/$$f; done + for f in $(SRC); do sed "s/^main(/$${f%.c}_&/" < $$f > build/$$f; done echo '#include <libgen.h>' > build/$@.c echo '#include <stdio.h>' >> build/$@.c echo '#include <stdlib.h>' >> build/$@.c echo '#include <string.h>' >> build/$@.c echo '#include "util.h"' >> build/$@.c - for f in $(SRC); do echo "int `basename $$f .c`_main(int, char **);" >> build/$@.c; done + for f in $(SRC); do echo "int $${f%.c}_main(int, char **);" >> build/$@.c; done echo 'int main(int argc, char *argv[]) { char *s = basename(argv[0]); if(!strcmp(s,"sbase-box")) { argc--; argv++; s = basename(argv[0]); } if(0) ;' >> build/$@.c echo "else if (!strcmp(s, \"[\")) return test_main(argc, argv);" >> build/$@.c - for f in $(SRC); do echo "else if(!strcmp(s, \"`basename $$f .c`\")) return `basename $$f .c`_main(argc, argv);" >> build/$@.c; done + for f in $(SRC); do echo "else if(!strcmp(s, \"$${f%.c}\")) return $${f%.c}_main(argc, argv);" >> build/$@.c; done echo 'else {' >> build/$@.c echo "printf(\"[\"); putchar(' ');" >> build/$@.c - for f in $(SRC); do echo "printf(\"`basename $$f .c`\"); putchar(' ');" >> build/$@.c; done + for f in $(SRC); do echo "printf(\"$${f%.c}\"); putchar(' ');" >> build/$@.c; done echo "putchar(0xa); }; return 0; }" >> build/$@.c $(LD) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ build/*.c $(LIB) rm -r build