2011-05-23 01:36:34 +00:00
|
|
|
include config.mk
|
|
|
|
|
2014-11-18 20:12:14 +00:00
|
|
|
.SUFFIXES:
|
|
|
|
.SUFFIXES: .o .c
|
2012-05-16 12:14:02 +00:00
|
|
|
|
2014-11-17 13:22:10 +00:00
|
|
|
HDR =\
|
|
|
|
arg.h\
|
2014-11-17 15:45:09 +00:00
|
|
|
compat.h\
|
2014-11-17 13:22:10 +00:00
|
|
|
crypt.h\
|
|
|
|
fs.h\
|
|
|
|
md5.h\
|
|
|
|
queue.h\
|
2014-11-17 15:41:44 +00:00
|
|
|
runetypebody.h\
|
2014-11-17 13:22:10 +00:00
|
|
|
sha1.h\
|
|
|
|
sha256.h\
|
|
|
|
sha512.h\
|
|
|
|
text.h\
|
2014-11-17 15:41:44 +00:00
|
|
|
utf.h\
|
2014-11-13 18:20:51 +00:00
|
|
|
util.h
|
|
|
|
|
2014-11-17 15:41:44 +00:00
|
|
|
LIBUTF = libutf.a
|
|
|
|
LIBUTFSRC =\
|
Rewrite tr(1) in a sane way
tr(1) always used to be a saddening part of sbase, which was
inherently broken and crufted.
But to be fair, the POSIX-standard doesn't make it very simple.
Given the current version was unfixable and broken by design, I
sat down and rewrote tr(1) very close to the concept of set theory
and the POSIX-standard with a few exceptions:
- UTF-8: not allowed in POSIX, but in my opinion a must. This
finally allows you to work with UTF-8 streams without
problems or unexpected behaviour.
- Equivalence classes: Left out, even GNU coreutils ignore them
and depending on LC_COLLATE, which sucks.
- Character classes: No experiments or environment-variable-trickery.
Just plain definitions derived from the POSIX-
standard, working as expected.
I tested this thoroughly, but expect problems to show up in some
way given the wide range of input this program has to handle.
The only thing left on the TODO is to add support for literal
expressions ('\n', '\t', '\001', ...) and probably rethinking
the way [_*n] is unnecessarily restricted to string2.
2015-01-09 19:36:27 +00:00
|
|
|
libutf/chartorunearr.c\
|
2014-11-21 16:20:15 +00:00
|
|
|
libutf/readrune.c\
|
2014-11-17 15:41:44 +00:00
|
|
|
libutf/rune.c\
|
|
|
|
libutf/runetype.c\
|
2014-11-21 16:20:15 +00:00
|
|
|
libutf/utf.c\
|
|
|
|
libutf/writerune.c
|
2014-11-17 15:41:44 +00:00
|
|
|
|
|
|
|
LIBUTIL = libutil.a
|
|
|
|
LIBUTILSRC =\
|
2014-11-17 16:48:01 +00:00
|
|
|
libutil/agetcwd.c\
|
|
|
|
libutil/apathmax.c\
|
|
|
|
libutil/concat.c\
|
|
|
|
libutil/cp.c\
|
|
|
|
libutil/crypt.c\
|
|
|
|
libutil/ealloc.c\
|
|
|
|
libutil/enmasse.c\
|
|
|
|
libutil/eprintf.c\
|
|
|
|
libutil/eregcomp.c\
|
|
|
|
libutil/estrtod.c\
|
|
|
|
libutil/estrtol.c\
|
2015-01-30 13:24:41 +00:00
|
|
|
libutil/estrtoul.c\
|
2014-11-17 16:48:01 +00:00
|
|
|
libutil/fnck.c\
|
|
|
|
libutil/getlines.c\
|
|
|
|
libutil/human.c\
|
|
|
|
libutil/md5.c\
|
|
|
|
libutil/mode.c\
|
|
|
|
libutil/putword.c\
|
|
|
|
libutil/recurse.c\
|
|
|
|
libutil/rm.c\
|
|
|
|
libutil/sha1.c\
|
|
|
|
libutil/sha256.c\
|
|
|
|
libutil/sha512.c\
|
2014-11-20 23:43:08 +00:00
|
|
|
libutil/strcasestr.c\
|
2014-11-17 16:48:01 +00:00
|
|
|
libutil/strlcat.c\
|
2015-01-25 17:48:11 +00:00
|
|
|
libutil/strlcpy.c\
|
2015-01-29 20:52:44 +00:00
|
|
|
libutil/strsep.c\
|
2015-01-30 13:48:33 +00:00
|
|
|
libutil/strtonum.c\
|
2015-01-29 20:52:44 +00:00
|
|
|
libutil/unescape.c
|
2014-11-17 12:12:10 +00:00
|
|
|
|
2014-11-17 15:41:44 +00:00
|
|
|
LIB = $(LIBUTF) $(LIBUTIL)
|
|
|
|
|
2014-11-17 13:22:10 +00:00
|
|
|
BIN =\
|
|
|
|
basename\
|
|
|
|
cal\
|
|
|
|
cat\
|
|
|
|
chgrp\
|
|
|
|
chmod\
|
|
|
|
chown\
|
|
|
|
chroot\
|
|
|
|
cksum\
|
|
|
|
cmp\
|
|
|
|
cols\
|
|
|
|
comm\
|
|
|
|
cp\
|
2014-12-16 10:59:08 +00:00
|
|
|
cron\
|
2014-11-17 13:22:10 +00:00
|
|
|
cut\
|
|
|
|
date\
|
|
|
|
dirname\
|
|
|
|
du\
|
|
|
|
echo\
|
|
|
|
env\
|
|
|
|
expand\
|
|
|
|
expr\
|
|
|
|
false\
|
|
|
|
fold\
|
|
|
|
grep\
|
|
|
|
head\
|
|
|
|
hostname\
|
|
|
|
kill\
|
|
|
|
link\
|
|
|
|
ln\
|
2014-12-04 11:34:39 +00:00
|
|
|
logger\
|
2014-11-17 13:22:10 +00:00
|
|
|
logname\
|
|
|
|
ls\
|
|
|
|
md5sum\
|
|
|
|
mkdir\
|
|
|
|
mkfifo\
|
|
|
|
mktemp\
|
|
|
|
mv\
|
|
|
|
nice\
|
|
|
|
nl\
|
|
|
|
nohup\
|
|
|
|
paste\
|
|
|
|
printenv\
|
|
|
|
printf\
|
|
|
|
pwd\
|
|
|
|
readlink\
|
|
|
|
renice\
|
|
|
|
rm\
|
|
|
|
rmdir\
|
2014-12-01 17:12:07 +00:00
|
|
|
seq\
|
2014-11-17 13:22:10 +00:00
|
|
|
setsid\
|
2014-12-01 17:12:07 +00:00
|
|
|
sha1sum\
|
|
|
|
sha256sum\
|
|
|
|
sha512sum\
|
|
|
|
sleep\
|
2014-11-17 13:22:10 +00:00
|
|
|
sort\
|
|
|
|
split\
|
|
|
|
sponge\
|
|
|
|
strings\
|
|
|
|
sync\
|
|
|
|
tail\
|
|
|
|
tar\
|
|
|
|
tee\
|
|
|
|
test\
|
|
|
|
touch\
|
|
|
|
tr\
|
|
|
|
true\
|
|
|
|
tty\
|
|
|
|
uname\
|
|
|
|
unexpand\
|
|
|
|
uniq\
|
|
|
|
unlink\
|
2014-12-01 17:12:07 +00:00
|
|
|
uudecode\
|
|
|
|
uuencode\
|
2014-11-17 13:22:10 +00:00
|
|
|
wc\
|
|
|
|
xargs\
|
2014-11-17 12:12:10 +00:00
|
|
|
yes
|
|
|
|
|
2014-11-17 15:41:44 +00:00
|
|
|
LIBUTFOBJ = $(LIBUTFSRC:.c=.o)
|
|
|
|
LIBUTILOBJ = $(LIBUTILSRC:.c=.o)
|
|
|
|
OBJ = $(BIN:=.o) $(LIBUTFOBJ) $(LIBUTILOBJ)
|
2014-11-17 12:12:10 +00:00
|
|
|
SRC = $(BIN:=.c)
|
|
|
|
MAN = $(BIN:=.1)
|
2011-05-23 01:36:34 +00:00
|
|
|
|
2014-11-17 13:50:19 +00:00
|
|
|
all: $(BIN)
|
2013-07-18 19:28:08 +00:00
|
|
|
|
2014-12-01 17:37:21 +00:00
|
|
|
$(BIN): $(LIB) $(@:=.o)
|
2011-05-23 01:36:34 +00:00
|
|
|
|
2014-11-13 18:26:38 +00:00
|
|
|
$(OBJ): $(HDR) config.mk
|
2011-05-23 01:36:34 +00:00
|
|
|
|
|
|
|
.o:
|
2014-11-17 12:12:10 +00:00
|
|
|
$(LD) $(LDFLAGS) -o $@ $< $(LIB)
|
2011-05-23 01:36:34 +00:00
|
|
|
|
|
|
|
.c.o:
|
2014-11-17 10:31:29 +00:00
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
|
2011-05-24 12:00:30 +00:00
|
|
|
|
2014-11-19 10:50:54 +00:00
|
|
|
$(LIBUTF): $(LIBUTFOBJ)
|
|
|
|
$(AR) -r -c $@ $?
|
|
|
|
$(RANLIB) $@
|
|
|
|
|
|
|
|
$(LIBUTIL): $(LIBUTILOBJ)
|
2014-11-17 10:15:44 +00:00
|
|
|
$(AR) -r -c $@ $?
|
2014-11-17 12:22:53 +00:00
|
|
|
$(RANLIB) $@
|
2011-05-23 01:36:34 +00:00
|
|
|
|
2011-06-08 15:26:05 +00:00
|
|
|
install: all
|
2014-11-17 10:15:44 +00:00
|
|
|
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
|
|
|
cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin
|
|
|
|
cd $(DESTDIR)$(PREFIX)/bin && chmod 755 $(BIN)
|
|
|
|
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
|
|
|
|
for m in $(MAN); do sed "s/VERSION/$(VERSION)/g" < "$$m" > $(DESTDIR)$(MANPREFIX)/man1/"$$m"; done
|
|
|
|
cd $(DESTDIR)$(MANPREFIX)/man1 && chmod 644 $(MAN)
|
2011-06-08 10:37:00 +00:00
|
|
|
|
|
|
|
uninstall:
|
2014-11-17 10:15:44 +00:00
|
|
|
cd $(DESTDIR)$(PREFIX)/bin && rm -f $(BIN)
|
|
|
|
cd $(DESTDIR)$(MANPREFIX)/man1 && rm -f $(MAN)
|
2011-06-08 10:37:00 +00:00
|
|
|
|
2011-05-23 01:36:34 +00:00
|
|
|
dist: clean
|
2014-11-17 10:15:44 +00:00
|
|
|
mkdir -p sbase-$(VERSION)
|
2014-11-17 16:48:01 +00:00
|
|
|
cp -r LICENSE Makefile README TODO config.mk $(SRC) $(MAN) libutf libutil $(HDR) sbase-$(VERSION)
|
2014-11-17 10:15:44 +00:00
|
|
|
tar -cf sbase-$(VERSION).tar sbase-$(VERSION)
|
|
|
|
gzip sbase-$(VERSION).tar
|
|
|
|
rm -rf sbase-$(VERSION)
|
2011-05-23 01:36:34 +00:00
|
|
|
|
2014-11-17 12:12:10 +00:00
|
|
|
sbase-box: $(LIB) $(SRC)
|
2014-11-17 10:15:44 +00:00
|
|
|
mkdir -p build
|
|
|
|
cp $(HDR) build
|
|
|
|
for f in $(SRC); do sed "s/^main(/`basename $$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
|
|
|
|
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
|
|
|
|
for f in $(SRC); do echo "else if(!strcmp(s, \"`basename $$f .c`\")) return `basename $$f .c`_main(argc, argv);" >> build/$@.c; done
|
|
|
|
echo 'else {' >> build/$@.c
|
|
|
|
for f in $(SRC); do echo "printf(\"`basename $$f .c`\"); putchar(' ');" >> build/$@.c; done
|
|
|
|
echo "putchar(0xa); }; return 0; }" >> build/$@.c
|
2014-11-17 12:12:10 +00:00
|
|
|
$(LD) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ build/*.c $(LIB)
|
2014-11-17 10:15:44 +00:00
|
|
|
rm -r build
|
2011-06-16 00:53:33 +00:00
|
|
|
|
2011-05-23 01:36:34 +00:00
|
|
|
clean:
|
2014-11-30 11:57:04 +00:00
|
|
|
rm -f $(BIN) $(OBJ) $(LIB) sbase-box sbase-$(VERSION).tar.gz
|
2014-11-17 13:02:17 +00:00
|
|
|
|
|
|
|
.PHONY:
|
2014-11-17 14:46:34 +00:00
|
|
|
all install uninstall dist sbase-box clean
|