2013-08-06 11:16:27 +00:00
|
|
|
include config.mk
|
|
|
|
|
|
|
|
.POSIX:
|
|
|
|
.SUFFIXES: .c .o
|
|
|
|
|
2014-06-30 11:58:24 +00:00
|
|
|
HDR = \
|
|
|
|
arg.h \
|
|
|
|
config.def.h \
|
|
|
|
passwd.h \
|
|
|
|
proc.h \
|
|
|
|
queue.h \
|
|
|
|
reboot.h \
|
|
|
|
rtc.h \
|
|
|
|
text.h \
|
|
|
|
util.h
|
|
|
|
|
2013-08-06 11:16:27 +00:00
|
|
|
LIB = \
|
2014-04-30 11:25:29 +00:00
|
|
|
util/agetcwd.o \
|
2014-06-05 11:48:45 +00:00
|
|
|
util/agetline.o \
|
2014-04-30 11:25:29 +00:00
|
|
|
util/apathmax.o \
|
2014-07-10 17:51:51 +00:00
|
|
|
util/concat.o \
|
2014-04-30 12:01:56 +00:00
|
|
|
util/ealloc.o \
|
2014-04-30 11:25:29 +00:00
|
|
|
util/eprintf.o \
|
|
|
|
util/estrtol.o \
|
2014-06-04 12:07:34 +00:00
|
|
|
util/estrtoul.o \
|
2014-04-30 11:25:29 +00:00
|
|
|
util/explicit_bzero.o \
|
2014-06-05 11:48:45 +00:00
|
|
|
util/passwd.o \
|
2014-04-30 11:25:29 +00:00
|
|
|
util/proc.o \
|
|
|
|
util/putword.o \
|
|
|
|
util/recurse.o \
|
|
|
|
util/strlcat.o \
|
|
|
|
util/strlcpy.o \
|
2013-08-14 14:38:43 +00:00
|
|
|
util/tty.o
|
2013-08-06 11:16:27 +00:00
|
|
|
|
|
|
|
SRC = \
|
2014-08-18 17:24:29 +00:00
|
|
|
lastlog.c \
|
2013-08-15 11:54:40 +00:00
|
|
|
chvt.c \
|
2013-08-16 10:08:26 +00:00
|
|
|
clear.c \
|
2014-02-07 16:35:51 +00:00
|
|
|
ctrlaltdel.c \
|
2014-06-04 10:39:00 +00:00
|
|
|
dd.c \
|
2013-08-06 19:08:41 +00:00
|
|
|
df.c \
|
2013-08-07 08:52:10 +00:00
|
|
|
dmesg.c \
|
2013-09-04 12:31:06 +00:00
|
|
|
eject.c \
|
2013-08-16 10:14:55 +00:00
|
|
|
fallocate.c \
|
2013-08-15 15:02:53 +00:00
|
|
|
free.c \
|
2014-06-26 15:16:15 +00:00
|
|
|
freeramdisk.c \
|
2014-06-14 15:48:10 +00:00
|
|
|
fsfreeze.c \
|
2014-02-10 12:12:50 +00:00
|
|
|
getty.c \
|
2013-08-09 14:04:02 +00:00
|
|
|
halt.c \
|
2014-06-03 13:46:27 +00:00
|
|
|
hwclock.c \
|
2014-02-27 14:27:28 +00:00
|
|
|
id.c \
|
2013-08-09 08:42:34 +00:00
|
|
|
insmod.c \
|
2014-03-06 11:13:47 +00:00
|
|
|
killall5.c \
|
2014-06-02 13:00:55 +00:00
|
|
|
login.c \
|
2013-08-09 09:23:40 +00:00
|
|
|
lsmod.c \
|
2013-09-03 12:52:47 +00:00
|
|
|
lsusb.c \
|
2014-07-26 14:31:44 +00:00
|
|
|
mesg.c \
|
2014-01-28 16:49:25 +00:00
|
|
|
mknod.c \
|
2013-08-09 12:45:20 +00:00
|
|
|
mkswap.c \
|
2013-08-12 11:32:34 +00:00
|
|
|
mount.c \
|
2013-08-16 10:00:43 +00:00
|
|
|
mountpoint.c \
|
2013-10-29 15:36:18 +00:00
|
|
|
pagesize.c \
|
2014-06-05 11:48:45 +00:00
|
|
|
passwd.c \
|
2013-08-29 10:11:26 +00:00
|
|
|
pidof.c \
|
2013-08-14 13:38:56 +00:00
|
|
|
pivot_root.c \
|
2013-08-14 14:38:43 +00:00
|
|
|
ps.c \
|
2014-06-27 16:02:42 +00:00
|
|
|
readahead.c \
|
2014-04-17 13:00:36 +00:00
|
|
|
respawn.c \
|
2013-08-09 14:42:49 +00:00
|
|
|
rmmod.c \
|
2014-01-30 16:20:27 +00:00
|
|
|
stat.c \
|
2014-02-10 15:16:53 +00:00
|
|
|
su.c \
|
2013-08-09 14:48:29 +00:00
|
|
|
swapoff.c \
|
2013-08-12 10:14:56 +00:00
|
|
|
swapon.c \
|
2014-04-13 22:07:06 +00:00
|
|
|
switch_root.c \
|
2014-04-17 14:18:38 +00:00
|
|
|
sysctl.c \
|
2013-08-16 10:34:52 +00:00
|
|
|
truncate.c \
|
2013-08-14 13:19:05 +00:00
|
|
|
umount.c \
|
2013-08-16 10:55:55 +00:00
|
|
|
unshare.c \
|
2013-09-04 10:27:29 +00:00
|
|
|
uptime.c \
|
2014-02-14 15:03:48 +00:00
|
|
|
watch.c \
|
|
|
|
who.c
|
2013-08-07 10:43:55 +00:00
|
|
|
|
2013-10-17 10:41:48 +00:00
|
|
|
MAN1 = \
|
|
|
|
chvt.1 \
|
|
|
|
clear.1 \
|
2014-06-11 10:49:44 +00:00
|
|
|
dd.1 \
|
2013-10-17 10:41:48 +00:00
|
|
|
df.1 \
|
2014-04-14 14:19:52 +00:00
|
|
|
dmesg.1 \
|
|
|
|
eject.1 \
|
|
|
|
fallocate.1 \
|
|
|
|
free.1 \
|
|
|
|
id.1 \
|
2014-06-02 15:41:07 +00:00
|
|
|
login.1 \
|
2014-08-04 19:59:47 +00:00
|
|
|
mesg.1 \
|
2014-04-14 14:19:52 +00:00
|
|
|
mknod.1 \
|
|
|
|
mountpoint.1 \
|
|
|
|
pagesize.1 \
|
2014-06-09 15:42:27 +00:00
|
|
|
passwd.1 \
|
2014-04-14 14:19:52 +00:00
|
|
|
pidof.1 \
|
|
|
|
ps.1 \
|
2014-04-17 13:00:36 +00:00
|
|
|
respawn.1 \
|
2014-04-14 14:19:52 +00:00
|
|
|
stat.1 \
|
|
|
|
su.1 \
|
|
|
|
truncate.1 \
|
|
|
|
unshare.1 \
|
|
|
|
uptime.1 \
|
|
|
|
watch.1 \
|
|
|
|
who.1
|
2013-10-17 10:41:48 +00:00
|
|
|
|
|
|
|
MAN8 = \
|
2014-04-14 14:19:52 +00:00
|
|
|
ctrlaltdel.8 \
|
2014-06-26 15:16:15 +00:00
|
|
|
freeramdisk.8 \
|
2014-06-26 15:02:04 +00:00
|
|
|
fsfreeze.8 \
|
2014-04-14 14:19:52 +00:00
|
|
|
getty.8 \
|
2013-10-17 10:41:48 +00:00
|
|
|
halt.8 \
|
2014-06-03 15:20:57 +00:00
|
|
|
hwclock.8 \
|
2014-04-14 14:19:52 +00:00
|
|
|
insmod.8 \
|
|
|
|
killall5.8 \
|
2014-08-18 17:24:29 +00:00
|
|
|
lastlog.8 \
|
2013-10-17 10:41:48 +00:00
|
|
|
lsmod.8 \
|
2014-04-14 14:19:52 +00:00
|
|
|
lsusb.8 \
|
|
|
|
mkswap.8 \
|
|
|
|
mount.8 \
|
|
|
|
pivot_root.8 \
|
2014-06-30 13:14:46 +00:00
|
|
|
readahead.8 \
|
2014-04-14 14:19:52 +00:00
|
|
|
rmmod.8 \
|
|
|
|
swapoff.8 \
|
|
|
|
swapon.8 \
|
|
|
|
switch_root.8 \
|
2014-04-17 14:18:38 +00:00
|
|
|
sysctl.8 \
|
2014-04-14 14:19:52 +00:00
|
|
|
umount.8
|
2013-10-17 10:41:48 +00:00
|
|
|
|
2013-08-06 11:16:27 +00:00
|
|
|
OBJ = $(SRC:.c=.o) $(LIB)
|
|
|
|
BIN = $(SRC:.c=)
|
|
|
|
|
2013-08-07 10:56:03 +00:00
|
|
|
all: options binlib
|
|
|
|
|
|
|
|
options:
|
|
|
|
@echo ubase build options:
|
|
|
|
@echo "CFLAGS = $(CFLAGS)"
|
|
|
|
@echo "LDFLAGS = $(LDFLAGS)"
|
|
|
|
@echo "CC = $(CC)"
|
2013-08-06 11:16:27 +00:00
|
|
|
|
|
|
|
binlib: util.a
|
|
|
|
$(MAKE) bin
|
|
|
|
|
|
|
|
bin: $(BIN)
|
|
|
|
|
2014-02-09 12:25:36 +00:00
|
|
|
$(OBJ): config.h util.h config.mk
|
|
|
|
|
|
|
|
config.h:
|
|
|
|
@echo creating $@ from config.def.h
|
|
|
|
@cp config.def.h $@
|
2013-08-06 11:16:27 +00:00
|
|
|
|
|
|
|
.o:
|
|
|
|
@echo LD $@
|
|
|
|
@$(LD) -o $@ $< util.a $(LDFLAGS)
|
|
|
|
|
|
|
|
.c.o:
|
|
|
|
@echo CC $<
|
|
|
|
@$(CC) -c -o $@ $< $(CFLAGS)
|
|
|
|
|
|
|
|
util.a: $(LIB)
|
|
|
|
@echo AR $@
|
|
|
|
@$(AR) -r -c $@ $(LIB)
|
|
|
|
@ranlib $@
|
|
|
|
|
|
|
|
install: all
|
|
|
|
@echo installing executables to $(DESTDIR)$(PREFIX)/bin
|
|
|
|
@mkdir -p $(DESTDIR)$(PREFIX)/bin
|
|
|
|
@cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin
|
|
|
|
@cd $(DESTDIR)$(PREFIX)/bin && chmod 755 $(BIN)
|
|
|
|
@echo installing manual pages to $(DESTDIR)$(MANPREFIX)/man1
|
|
|
|
@mkdir -p $(DESTDIR)$(MANPREFIX)/man1
|
2013-10-17 10:41:48 +00:00
|
|
|
@for m in $(MAN1); do sed "s/VERSION/$(VERSION)/g" < "$$m" > $(DESTDIR)$(MANPREFIX)/man1/"$$m"; done
|
|
|
|
@echo installing manual pages to $(DESTDIR)$(MANPREFIX)/man8
|
|
|
|
@mkdir -p $(DESTDIR)$(MANPREFIX)/man8
|
|
|
|
@for m in $(MAN8); do sed "s/VERSION/$(VERSION)/g" < "$$m" > $(DESTDIR)$(MANPREFIX)/man8/"$$m"; done
|
|
|
|
@chmod 644 $(DESTDIR)$(MANPREFIX)/man1/$(MAN1)
|
|
|
|
@chmod 644 $(DESTDIR)$(MANPREFIX)/man8/$(MAN8)
|
2013-08-06 11:16:27 +00:00
|
|
|
|
|
|
|
uninstall:
|
|
|
|
@echo removing executables from $(DESTDIR)$(PREFIX)/bin
|
|
|
|
@cd $(DESTDIR)$(PREFIX)/bin && rm -f $(BIN)
|
|
|
|
@echo removing manual pages from $(DESTDIR)$(MANPREFIX)/man1
|
|
|
|
@cd $(DESTDIR)$(MANPREFIX)/man1 && rm -f $(MAN)
|
|
|
|
|
|
|
|
dist: clean
|
|
|
|
@echo creating dist tarball
|
|
|
|
@mkdir -p ubase-$(VERSION)
|
2013-08-16 09:35:09 +00:00
|
|
|
@cp -r LICENSE Makefile config.mk TODO $(SRC) $(MAN) util $(HDR) ubase-$(VERSION)
|
2013-08-06 11:16:27 +00:00
|
|
|
@tar -cf ubase-$(VERSION).tar ubase-$(VERSION)
|
|
|
|
@gzip ubase-$(VERSION).tar
|
|
|
|
@rm -rf ubase-$(VERSION)
|
|
|
|
|
2014-02-09 12:25:36 +00:00
|
|
|
ubase-box: config.h $(SRC) util.a
|
2013-08-06 11:16:27 +00:00
|
|
|
@echo creating box binary
|
|
|
|
@mkdir -p build
|
|
|
|
@cp $(HDR) build
|
2014-02-09 12:25:36 +00:00
|
|
|
@cp config.h build
|
2013-08-06 11:16:27 +00:00
|
|
|
@for f in $(SRC); do sed "s/^main(/`basename $$f .c`_&/" < $$f > build/$$f; done
|
|
|
|
@echo '#include <libgen.h>' > build/$@.c
|
2013-08-15 15:46:46 +00:00
|
|
|
@echo '#include <stdio.h>' >> build/$@.c
|
2013-08-06 11:16:27 +00:00
|
|
|
@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
|
2013-10-08 22:32:29 +00:00
|
|
|
@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
|
2013-08-06 11:16:27 +00:00
|
|
|
@for f in $(SRC); do echo "else if(!strcmp(s, \"`basename $$f .c`\")) `basename $$f .c`_main(argc, argv);" >> build/$@.c; done
|
2013-08-15 15:46:46 +00:00
|
|
|
@echo 'else {' >> build/$@.c
|
|
|
|
@for f in $(SRC); do echo "printf(\"`basename $$f .c`\"); putchar(' ');" >> build/$@.c; done
|
2014-10-02 22:50:19 +00:00
|
|
|
@echo "putchar(0xa); }; return 0; }" >> build/$@.c
|
2013-08-06 11:16:27 +00:00
|
|
|
@echo LD $@
|
|
|
|
@$(LD) -o $@ build/*.c util.a $(CFLAGS) $(LDFLAGS)
|
|
|
|
@rm -r build
|
|
|
|
|
|
|
|
clean:
|
|
|
|
@echo cleaning
|
|
|
|
@rm -f $(BIN) $(OBJ) $(LIB) util.a ubase-box
|