sbase/Makefile

185 lines
3.7 KiB
Makefile
Raw Normal View History

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