2011-05-23 01:36:34 +00:00
|
|
|
include config.mk
|
|
|
|
|
2012-05-16 12:14:02 +00:00
|
|
|
.POSIX:
|
|
|
|
.SUFFIXES: .c .o
|
|
|
|
|
2014-11-13 18:20:51 +00:00
|
|
|
HDR = \
|
|
|
|
arg.h \
|
|
|
|
crypt.h \
|
|
|
|
fs.h \
|
|
|
|
md5.h \
|
2014-11-16 12:37:43 +00:00
|
|
|
queue.h \
|
2014-11-13 18:20:51 +00:00
|
|
|
sha1.h \
|
|
|
|
sha256.h \
|
|
|
|
sha512.h \
|
|
|
|
text.h \
|
|
|
|
util.h
|
|
|
|
|
2011-06-03 04:38:40 +00:00
|
|
|
LIB = \
|
2011-06-18 05:41:28 +00:00
|
|
|
util/agetcwd.o \
|
2014-06-01 11:57:22 +00:00
|
|
|
util/agetline.o \
|
2011-06-25 16:26:44 +00:00
|
|
|
util/apathmax.o \
|
2011-06-18 05:41:28 +00:00
|
|
|
util/concat.o \
|
2012-01-30 22:41:33 +00:00
|
|
|
util/cp.o \
|
2013-07-07 14:29:45 +00:00
|
|
|
util/crypt.o \
|
2014-11-14 18:09:48 +00:00
|
|
|
util/ealloc.o \
|
2011-06-18 05:41:28 +00:00
|
|
|
util/enmasse.o \
|
|
|
|
util/eprintf.o \
|
2014-11-16 14:16:14 +00:00
|
|
|
util/eregcomp.o \
|
2014-06-01 11:57:22 +00:00
|
|
|
util/estrtod.o \
|
2011-06-18 05:41:28 +00:00
|
|
|
util/estrtol.o \
|
2012-01-30 22:41:33 +00:00
|
|
|
util/fnck.o \
|
2012-05-21 21:09:38 +00:00
|
|
|
util/getlines.o \
|
2014-10-18 21:25:00 +00:00
|
|
|
util/human.o \
|
2013-06-19 08:54:52 +00:00
|
|
|
util/md5.o \
|
2014-04-09 13:17:20 +00:00
|
|
|
util/mode.o \
|
2011-06-18 05:41:28 +00:00
|
|
|
util/putword.o \
|
|
|
|
util/recurse.o \
|
2013-07-04 11:14:14 +00:00
|
|
|
util/rm.o \
|
2013-07-19 13:29:43 +00:00
|
|
|
util/sha1.o \
|
2013-07-22 08:34:07 +00:00
|
|
|
util/sha256.o \
|
2014-01-30 12:37:35 +00:00
|
|
|
util/sha512.o \
|
|
|
|
util/strlcat.o \
|
|
|
|
util/strlcpy.o
|
2011-06-03 04:38:40 +00:00
|
|
|
|
|
|
|
SRC = \
|
|
|
|
basename.c \
|
2013-06-19 18:13:50 +00:00
|
|
|
cal.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
cat.c \
|
2013-05-30 19:29:56 +00:00
|
|
|
chgrp.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
chmod.c \
|
|
|
|
chown.c \
|
2013-06-14 16:55:25 +00:00
|
|
|
chroot.c \
|
2011-06-10 03:14:05 +00:00
|
|
|
cksum.c \
|
2011-06-10 00:55:12 +00:00
|
|
|
cmp.c \
|
2014-09-29 18:45:42 +00:00
|
|
|
col.c \
|
2014-03-12 14:43:45 +00:00
|
|
|
cols.c \
|
2013-06-18 10:19:47 +00:00
|
|
|
comm.c \
|
2012-01-30 22:41:33 +00:00
|
|
|
cp.c \
|
2014-10-16 10:58:04 +00:00
|
|
|
csplit.c \
|
2013-10-08 19:39:08 +00:00
|
|
|
cut.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
date.c \
|
|
|
|
dirname.c \
|
2013-10-16 15:58:52 +00:00
|
|
|
du.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
echo.c \
|
2013-06-14 16:55:25 +00:00
|
|
|
env.c \
|
2013-06-17 11:00:36 +00:00
|
|
|
expand.c \
|
2014-09-29 12:43:41 +00:00
|
|
|
expr.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
false.c \
|
2011-06-08 20:30:33 +00:00
|
|
|
fold.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
grep.c \
|
|
|
|
head.c \
|
2013-08-19 16:22:46 +00:00
|
|
|
hostname.c \
|
2011-06-10 01:29:10 +00:00
|
|
|
kill.c \
|
2014-10-17 14:32:08 +00:00
|
|
|
link.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
ln.c \
|
2014-10-16 21:15:16 +00:00
|
|
|
logname.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
ls.c \
|
2013-06-19 08:54:52 +00:00
|
|
|
md5sum.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
mkdir.c \
|
|
|
|
mkfifo.c \
|
2013-11-12 11:52:28 +00:00
|
|
|
mktemp.c \
|
2012-01-30 22:41:33 +00:00
|
|
|
mv.c \
|
2013-05-29 18:52:39 +00:00
|
|
|
nice.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
nl.c \
|
2011-06-18 05:41:28 +00:00
|
|
|
nohup.c \
|
2013-04-29 16:54:36 +00:00
|
|
|
paste.c \
|
2013-05-30 19:29:56 +00:00
|
|
|
printenv.c \
|
2014-09-28 14:10:27 +00:00
|
|
|
printf.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
pwd.c \
|
2013-06-15 14:17:57 +00:00
|
|
|
readlink.c \
|
2013-06-11 18:33:52 +00:00
|
|
|
renice.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
rm.c \
|
2013-05-30 19:29:56 +00:00
|
|
|
rmdir.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
sleep.c \
|
2013-08-21 11:56:26 +00:00
|
|
|
setsid.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
sort.c \
|
2013-06-14 16:55:25 +00:00
|
|
|
split.c \
|
2013-07-02 17:21:30 +00:00
|
|
|
sponge.c \
|
2013-08-14 09:41:55 +00:00
|
|
|
strings.c \
|
2013-05-30 19:29:56 +00:00
|
|
|
sync.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
tail.c \
|
2013-07-18 15:15:35 +00:00
|
|
|
tar.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
tee.c \
|
2011-11-08 18:35:38 +00:00
|
|
|
test.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
touch.c \
|
2013-11-15 16:25:10 +00:00
|
|
|
tr.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
true.c \
|
|
|
|
tty.c \
|
2014-02-02 19:08:22 +00:00
|
|
|
uudecode.c \
|
2014-01-31 15:24:38 +00:00
|
|
|
uuencode.c \
|
2011-06-03 04:38:40 +00:00
|
|
|
uname.c \
|
2014-06-09 15:52:20 +00:00
|
|
|
unexpand.c \
|
2012-05-21 23:24:28 +00:00
|
|
|
uniq.c \
|
2013-05-30 19:29:56 +00:00
|
|
|
unlink.c \
|
2012-04-10 15:33:19 +00:00
|
|
|
seq.c \
|
2013-07-04 11:14:14 +00:00
|
|
|
sha1sum.c \
|
2013-07-19 13:29:43 +00:00
|
|
|
sha256sum.c\
|
2013-07-22 08:34:07 +00:00
|
|
|
sha512sum.c\
|
2012-04-23 14:27:40 +00:00
|
|
|
wc.c \
|
2014-01-03 11:52:47 +00:00
|
|
|
xargs.c \
|
2012-04-23 14:27:40 +00:00
|
|
|
yes.c
|
2011-05-27 00:20:03 +00:00
|
|
|
|
2011-05-24 12:00:30 +00:00
|
|
|
OBJ = $(SRC:.c=.o) $(LIB)
|
2011-05-23 01:36:34 +00:00
|
|
|
BIN = $(SRC:.c=)
|
|
|
|
MAN = $(SRC:.c=.1)
|
|
|
|
|
2013-07-18 19:28:08 +00:00
|
|
|
all: binlib
|
|
|
|
|
2014-11-17 10:28:54 +00:00
|
|
|
binlib: libutil.a
|
2013-07-18 19:28:08 +00:00
|
|
|
$(MAKE) bin
|
|
|
|
|
|
|
|
bin: $(BIN)
|
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 10:31:29 +00:00
|
|
|
$(LD) $(LDFLAGS) -o $@ $< libutil.a
|
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-17 10:28:54 +00:00
|
|
|
libutil.a: $(LIB)
|
2014-11-17 10:15:44 +00:00
|
|
|
$(AR) -r -c $@ $?
|
|
|
|
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)
|
|
|
|
cp -r LICENSE Makefile README TODO config.mk $(SRC) $(MAN) util $(HDR) sbase-$(VERSION)
|
|
|
|
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 10:28:54 +00:00
|
|
|
sbase-box: $(SRC) libutil.a
|
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 10:31:29 +00:00
|
|
|
$(LD) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ build/*.c libutil.a
|
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-17 10:28:54 +00:00
|
|
|
@rm -f $(BIN) $(OBJ) $(LIB) libutil.a sbase-box sbase-$(VERSION).tar.gz
|