2011-05-22 21:36:34 -04:00
|
|
|
include config.mk
|
|
|
|
|
2014-11-18 15:12:14 -05:00
|
|
|
.SUFFIXES:
|
|
|
|
.SUFFIXES: .o .c
|
2012-05-16 08:14:02 -04:00
|
|
|
|
2014-11-17 08:22:10 -05:00
|
|
|
HDR =\
|
|
|
|
arg.h\
|
2014-11-17 10:45:09 -05:00
|
|
|
compat.h\
|
2014-11-17 08:22:10 -05:00
|
|
|
crypt.h\
|
|
|
|
fs.h\
|
|
|
|
md5.h\
|
|
|
|
queue.h\
|
2014-11-17 10:41:44 -05:00
|
|
|
runetypebody.h\
|
2014-11-17 08:22:10 -05:00
|
|
|
sha1.h\
|
|
|
|
sha256.h\
|
|
|
|
sha512.h\
|
|
|
|
text.h\
|
2014-11-17 10:41:44 -05:00
|
|
|
utf.h\
|
2014-11-13 13:20:51 -05:00
|
|
|
util.h
|
|
|
|
|
2014-11-17 10:41:44 -05:00
|
|
|
LIBUTF = libutf.a
|
|
|
|
LIBUTFSRC =\
|
|
|
|
libutf/rune.c\
|
|
|
|
libutf/runetype.c\
|
|
|
|
libutf/utf.c
|
|
|
|
|
|
|
|
LIBUTIL = libutil.a
|
|
|
|
LIBUTILSRC =\
|
2014-11-17 11:48:01 -05: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\
|
|
|
|
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\
|
|
|
|
libutil/strlcat.c\
|
|
|
|
libutil/strlcpy.c
|
2014-11-17 07:12:10 -05:00
|
|
|
|
2014-11-17 10:41:44 -05:00
|
|
|
LIB = $(LIBUTF) $(LIBUTIL)
|
|
|
|
|
2014-11-17 08:22:10 -05:00
|
|
|
BIN =\
|
|
|
|
basename\
|
|
|
|
cal\
|
|
|
|
cat\
|
|
|
|
chgrp\
|
|
|
|
chmod\
|
|
|
|
chown\
|
|
|
|
chroot\
|
|
|
|
cksum\
|
|
|
|
cmp\
|
|
|
|
cols\
|
|
|
|
comm\
|
|
|
|
cp\
|
|
|
|
cut\
|
|
|
|
date\
|
|
|
|
dirname\
|
|
|
|
du\
|
|
|
|
echo\
|
|
|
|
env\
|
|
|
|
expand\
|
|
|
|
expr\
|
|
|
|
false\
|
|
|
|
fold\
|
|
|
|
grep\
|
|
|
|
head\
|
|
|
|
hostname\
|
|
|
|
kill\
|
|
|
|
link\
|
|
|
|
ln\
|
|
|
|
logname\
|
|
|
|
ls\
|
|
|
|
md5sum\
|
|
|
|
mkdir\
|
|
|
|
mkfifo\
|
|
|
|
mktemp\
|
|
|
|
mv\
|
|
|
|
nice\
|
|
|
|
nl\
|
|
|
|
nohup\
|
|
|
|
paste\
|
|
|
|
printenv\
|
|
|
|
printf\
|
|
|
|
pwd\
|
|
|
|
readlink\
|
|
|
|
renice\
|
|
|
|
rm\
|
|
|
|
rmdir\
|
|
|
|
sleep\
|
|
|
|
setsid\
|
|
|
|
sort\
|
|
|
|
split\
|
|
|
|
sponge\
|
|
|
|
strings\
|
|
|
|
sync\
|
|
|
|
tail\
|
|
|
|
tar\
|
|
|
|
tee\
|
|
|
|
test\
|
|
|
|
touch\
|
|
|
|
tr\
|
|
|
|
true\
|
|
|
|
tty\
|
|
|
|
uudecode\
|
|
|
|
uuencode\
|
|
|
|
uname\
|
|
|
|
unexpand\
|
|
|
|
uniq\
|
|
|
|
unlink\
|
|
|
|
seq\
|
|
|
|
sha1sum\
|
2014-11-17 07:12:10 -05:00
|
|
|
sha256sum\
|
|
|
|
sha512sum\
|
2014-11-17 08:22:10 -05:00
|
|
|
wc\
|
|
|
|
xargs\
|
2014-11-17 07:12:10 -05:00
|
|
|
yes
|
|
|
|
|
2014-11-17 10:41:44 -05:00
|
|
|
LIBUTFOBJ = $(LIBUTFSRC:.c=.o)
|
|
|
|
LIBUTILOBJ = $(LIBUTILSRC:.c=.o)
|
|
|
|
OBJ = $(BIN:=.o) $(LIBUTFOBJ) $(LIBUTILOBJ)
|
2014-11-17 07:12:10 -05:00
|
|
|
SRC = $(BIN:=.c)
|
|
|
|
MAN = $(BIN:=.1)
|
2011-05-22 21:36:34 -04:00
|
|
|
|
2014-11-17 08:50:19 -05:00
|
|
|
all: $(BIN)
|
2013-07-18 15:28:08 -04:00
|
|
|
|
2014-11-17 08:50:19 -05:00
|
|
|
$(BIN): $(LIB)
|
2011-05-22 21:36:34 -04:00
|
|
|
|
2014-11-13 13:26:38 -05:00
|
|
|
$(OBJ): $(HDR) config.mk
|
2011-05-22 21:36:34 -04:00
|
|
|
|
|
|
|
.o:
|
2014-11-17 07:12:10 -05:00
|
|
|
$(LD) $(LDFLAGS) -o $@ $< $(LIB)
|
2011-05-22 21:36:34 -04:00
|
|
|
|
|
|
|
.c.o:
|
2014-11-17 05:31:29 -05:00
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
|
2011-05-24 08:00:30 -04:00
|
|
|
|
2014-11-19 05:50:54 -05:00
|
|
|
$(LIBUTF): $(LIBUTFOBJ)
|
|
|
|
$(AR) -r -c $@ $?
|
|
|
|
$(RANLIB) $@
|
|
|
|
|
|
|
|
$(LIBUTIL): $(LIBUTILOBJ)
|
2014-11-17 05:15:44 -05:00
|
|
|
$(AR) -r -c $@ $?
|
2014-11-17 07:22:53 -05:00
|
|
|
$(RANLIB) $@
|
2011-05-22 21:36:34 -04:00
|
|
|
|
2011-06-08 11:26:05 -04:00
|
|
|
install: all
|
2014-11-17 05:15:44 -05: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 06:37:00 -04:00
|
|
|
|
|
|
|
uninstall:
|
2014-11-17 05:15:44 -05:00
|
|
|
cd $(DESTDIR)$(PREFIX)/bin && rm -f $(BIN)
|
|
|
|
cd $(DESTDIR)$(MANPREFIX)/man1 && rm -f $(MAN)
|
2011-06-08 06:37:00 -04:00
|
|
|
|
2011-05-22 21:36:34 -04:00
|
|
|
dist: clean
|
2014-11-17 05:15:44 -05:00
|
|
|
mkdir -p sbase-$(VERSION)
|
2014-11-17 11:48:01 -05:00
|
|
|
cp -r LICENSE Makefile README TODO config.mk $(SRC) $(MAN) libutf libutil $(HDR) sbase-$(VERSION)
|
2014-11-17 05:15:44 -05:00
|
|
|
tar -cf sbase-$(VERSION).tar sbase-$(VERSION)
|
|
|
|
gzip sbase-$(VERSION).tar
|
|
|
|
rm -rf sbase-$(VERSION)
|
2011-05-22 21:36:34 -04:00
|
|
|
|
2014-11-17 07:12:10 -05:00
|
|
|
sbase-box: $(LIB) $(SRC)
|
2014-11-17 05:15:44 -05: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 07:12:10 -05:00
|
|
|
$(LD) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ build/*.c $(LIB)
|
2014-11-17 05:15:44 -05:00
|
|
|
rm -r build
|
2011-06-15 20:53:33 -04:00
|
|
|
|
2011-05-22 21:36:34 -04:00
|
|
|
clean:
|
2014-11-17 10:41:44 -05:00
|
|
|
rm -f $(BIN) $(OBJ) $(LIBUTFOBJ) $(LIBUTIL) $(LIB) sbase-box sbase-$(VERSION).tar.gz
|
2014-11-17 08:02:17 -05:00
|
|
|
|
|
|
|
.PHONY:
|
2014-11-17 09:46:34 -05:00
|
|
|
all install uninstall dist sbase-box clean
|