2013-08-06 07:16:27 -04:00
|
|
|
include config.mk
|
|
|
|
|
2014-11-30 07:09:34 -05:00
|
|
|
.SUFFIXES:
|
|
|
|
.SUFFIXES: .o .c
|
2013-08-06 07:16:27 -04:00
|
|
|
|
2014-06-30 07:58:24 -04:00
|
|
|
HDR = \
|
|
|
|
arg.h \
|
2014-11-30 07:09:34 -05:00
|
|
|
config.h \
|
2014-06-30 07:58:24 -04:00
|
|
|
passwd.h \
|
|
|
|
proc.h \
|
|
|
|
queue.h \
|
|
|
|
reboot.h \
|
|
|
|
rtc.h \
|
|
|
|
text.h \
|
|
|
|
util.h
|
|
|
|
|
2014-11-30 07:09:34 -05:00
|
|
|
LIBUTIL = libutil.a
|
|
|
|
LIBUTILSRC = \
|
|
|
|
libutil/agetcwd.c \
|
|
|
|
libutil/agetline.c \
|
|
|
|
libutil/apathmax.c \
|
|
|
|
libutil/concat.c \
|
|
|
|
libutil/ealloc.c \
|
|
|
|
libutil/eprintf.c \
|
|
|
|
libutil/estrtol.c \
|
|
|
|
libutil/estrtoul.c \
|
|
|
|
libutil/explicit_bzero.c \
|
|
|
|
libutil/passwd.c \
|
|
|
|
libutil/proc.c \
|
|
|
|
libutil/putword.c \
|
|
|
|
libutil/recurse.c \
|
|
|
|
libutil/strlcat.c \
|
|
|
|
libutil/strlcpy.c \
|
|
|
|
libutil/tty.c
|
|
|
|
|
|
|
|
LIB = $(LIBUTIL)
|
|
|
|
|
|
|
|
BIN = \
|
|
|
|
chvt \
|
|
|
|
clear \
|
|
|
|
ctrlaltdel \
|
|
|
|
dd \
|
|
|
|
df \
|
|
|
|
dmesg \
|
|
|
|
eject \
|
|
|
|
fallocate \
|
|
|
|
free \
|
|
|
|
freeramdisk \
|
|
|
|
fsfreeze \
|
|
|
|
getty \
|
|
|
|
halt \
|
|
|
|
hwclock \
|
|
|
|
id \
|
|
|
|
insmod \
|
|
|
|
killall5 \
|
|
|
|
last \
|
|
|
|
lastlog \
|
|
|
|
login \
|
|
|
|
lsmod \
|
|
|
|
lsusb \
|
|
|
|
mesg \
|
|
|
|
mknod \
|
|
|
|
mkswap \
|
|
|
|
mount \
|
|
|
|
mountpoint \
|
|
|
|
pagesize \
|
|
|
|
passwd \
|
|
|
|
pidof \
|
|
|
|
pivot_root \
|
|
|
|
ps \
|
|
|
|
readahead \
|
|
|
|
respawn \
|
|
|
|
rmmod \
|
|
|
|
stat \
|
|
|
|
su \
|
|
|
|
swaplabel \
|
|
|
|
swapoff \
|
|
|
|
swapon \
|
|
|
|
switch_root \
|
|
|
|
sysctl \
|
|
|
|
truncate \
|
|
|
|
umount \
|
|
|
|
unshare \
|
|
|
|
uptime \
|
|
|
|
watch \
|
|
|
|
who
|
2013-08-07 06:43:55 -04:00
|
|
|
|
2013-10-17 06:41:48 -04:00
|
|
|
MAN1 = \
|
|
|
|
chvt.1 \
|
|
|
|
clear.1 \
|
2014-06-11 06:49:44 -04:00
|
|
|
dd.1 \
|
2013-10-17 06:41:48 -04:00
|
|
|
df.1 \
|
2014-04-14 10:19:52 -04:00
|
|
|
dmesg.1 \
|
|
|
|
eject.1 \
|
|
|
|
fallocate.1 \
|
|
|
|
free.1 \
|
|
|
|
id.1 \
|
2014-06-02 11:41:07 -04:00
|
|
|
login.1 \
|
2014-08-04 15:59:47 -04:00
|
|
|
mesg.1 \
|
2014-04-14 10:19:52 -04:00
|
|
|
mknod.1 \
|
|
|
|
mountpoint.1 \
|
|
|
|
pagesize.1 \
|
2014-06-09 11:42:27 -04:00
|
|
|
passwd.1 \
|
2014-04-14 10:19:52 -04:00
|
|
|
pidof.1 \
|
|
|
|
ps.1 \
|
2014-04-17 09:00:36 -04:00
|
|
|
respawn.1 \
|
2014-04-14 10:19:52 -04:00
|
|
|
stat.1 \
|
|
|
|
su.1 \
|
|
|
|
truncate.1 \
|
|
|
|
unshare.1 \
|
|
|
|
uptime.1 \
|
|
|
|
watch.1 \
|
|
|
|
who.1
|
2013-10-17 06:41:48 -04:00
|
|
|
|
|
|
|
MAN8 = \
|
2014-04-14 10:19:52 -04:00
|
|
|
ctrlaltdel.8 \
|
2014-06-26 11:16:15 -04:00
|
|
|
freeramdisk.8 \
|
2014-06-26 11:02:04 -04:00
|
|
|
fsfreeze.8 \
|
2014-04-14 10:19:52 -04:00
|
|
|
getty.8 \
|
2013-10-17 06:41:48 -04:00
|
|
|
halt.8 \
|
2014-06-03 11:20:57 -04:00
|
|
|
hwclock.8 \
|
2014-04-14 10:19:52 -04:00
|
|
|
insmod.8 \
|
|
|
|
killall5.8 \
|
2014-08-18 13:24:29 -04:00
|
|
|
lastlog.8 \
|
2013-10-17 06:41:48 -04:00
|
|
|
lsmod.8 \
|
2014-04-14 10:19:52 -04:00
|
|
|
lsusb.8 \
|
|
|
|
mkswap.8 \
|
|
|
|
mount.8 \
|
|
|
|
pivot_root.8 \
|
2014-06-30 09:14:46 -04:00
|
|
|
readahead.8 \
|
2014-04-14 10:19:52 -04:00
|
|
|
rmmod.8 \
|
2014-11-29 16:09:39 -05:00
|
|
|
swaplabel.8 \
|
2014-04-14 10:19:52 -04:00
|
|
|
swapoff.8 \
|
|
|
|
swapon.8 \
|
|
|
|
switch_root.8 \
|
2014-04-17 10:18:38 -04:00
|
|
|
sysctl.8 \
|
2014-04-14 10:19:52 -04:00
|
|
|
umount.8
|
2013-10-17 06:41:48 -04:00
|
|
|
|
2014-11-30 07:09:34 -05:00
|
|
|
LIBUTILOBJ = $(LIBUTILSRC:.c=.o)
|
|
|
|
OBJ = $(BIN:=.o) $(LIBUTILOBJ)
|
|
|
|
SRC = $(BIN:=.c)
|
2013-08-06 07:16:27 -04:00
|
|
|
|
2014-11-30 07:09:34 -05:00
|
|
|
all: $(BIN)
|
2013-08-07 06:56:03 -04:00
|
|
|
|
2014-11-30 07:09:34 -05:00
|
|
|
$(BIN): $(LIB)
|
2013-08-06 07:16:27 -04:00
|
|
|
|
2014-11-30 07:09:34 -05:00
|
|
|
$(OBJ): $(HDR) config.mk
|
2014-02-09 07:25:36 -05:00
|
|
|
|
|
|
|
config.h:
|
2014-11-30 07:09:34 -05:00
|
|
|
cp config.def.h $@
|
2013-08-06 07:16:27 -04:00
|
|
|
|
|
|
|
.o:
|
2014-11-30 07:30:52 -05:00
|
|
|
$(LD) $(LDFLAGS) -o $@ $< $(LIB) $(LDLIBS)
|
2013-08-06 07:16:27 -04:00
|
|
|
|
|
|
|
.c.o:
|
2014-11-30 07:09:34 -05:00
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
|
2013-08-06 07:16:27 -04:00
|
|
|
|
2014-11-30 07:09:34 -05:00
|
|
|
$(LIBUTIL): $(LIBUTILOBJ)
|
|
|
|
$(AR) -r -c $@ $?
|
|
|
|
$(RANLIB) $@
|
2014-10-16 06:27:39 -04:00
|
|
|
|
2013-08-06 07:16:27 -04:00
|
|
|
install: all
|
2014-11-30 07:09:34 -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 $(MAN1); do sed "s/VERSION/$(VERSION)/g" < "$$m" > $(DESTDIR)$(MANPREFIX)/man1/"$$m"; done
|
|
|
|
mkdir -p $(DESTDIR)$(MANPREFIX)/man8
|
|
|
|
for m in $(MAN8); do sed "s/VERSION/$(VERSION)/g" < "$$m" > $(DESTDIR)$(MANPREFIX)/man8/"$$m"; done
|
|
|
|
cd $(DESTDIR)$(MANPREFIX)/man1 && chmod 644 $(MAN1)
|
|
|
|
cd $(DESTDIR)$(MANPREFIX)/man8 && chmod 644 $(MAN8)
|
2013-08-06 07:16:27 -04:00
|
|
|
|
|
|
|
uninstall:
|
2014-11-30 07:09:34 -05:00
|
|
|
cd $(DESTDIR)$(PREFIX)/bin && rm -f $(BIN)
|
|
|
|
cd $(DESTDIR)$(MANPREFIX)/man1 && rm -f $(MAN1)
|
|
|
|
cd $(DESTDIR)$(MANPREFIX)/man8 && rm -f $(MAN8)
|
2013-08-06 07:16:27 -04:00
|
|
|
|
|
|
|
dist: clean
|
2014-11-30 07:09:34 -05:00
|
|
|
mkdir -p ubase-$(VERSION)
|
|
|
|
cp -r LICENSE Makefile README TODO config.mk $(SRC) $(MAN1) $(MAN8) libutil $(HDR) config.def.h ubase-$(VERSION)
|
|
|
|
tar -cf ubase-$(VERSION).tar ubase-$(VERSION)
|
|
|
|
gzip ubase-$(VERSION).tar
|
|
|
|
rm -rf ubase-$(VERSION)
|
|
|
|
|
|
|
|
ubase-box: $(LIB) $(SRC)
|
|
|
|
mkdir -p build
|
|
|
|
cp $(HDR) build
|
|
|
|
cp config.h 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,"ubase-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-30 07:30:52 -05:00
|
|
|
$(LD) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ build/*.c $(LIB) $(LDLIBS)
|
2014-11-30 07:09:34 -05:00
|
|
|
rm -r build
|
2013-08-06 07:16:27 -04:00
|
|
|
|
|
|
|
clean:
|
2014-11-30 07:09:34 -05:00
|
|
|
rm -f $(BIN) $(OBJ) $(LIB) ubase-box ubase-$(VERSION).tar.gz
|
|
|
|
|
|
|
|
.PHONY:
|
|
|
|
all install uninstall dist ubase-box clean
|