[hackers] [ubase] Bring in the sbase Makefile updates to ubase || sin

From: <git_AT_suckless.org>
Date: Sun, 30 Nov 2014 13:18:58 +0100

commit 0c008b65ee3dc4992087fb58aa798bc109c63b89
Author: sin <sin_AT_2f30.org>
Date: Sun Nov 30 12:09:34 2014 +0000

    Bring in the sbase Makefile updates to ubase

diff --git a/Makefile b/Makefile
index f86fd8f..6d196da 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -1,11 +1,11 @@
 include config.mk
 
-.POSIX:
-.SUFFIXES: .c .o
+.SUFFIXES:
+.SUFFIXES: .o .c
 
 HDR = \
         arg.h \
- config.def.h \
+ config.h \
         passwd.h \
         proc.h \
         queue.h \
_AT_@ -14,73 +14,76 @@ HDR = \
         text.h \
         util.h
 
-LIB = \
- libutil/agetcwd.o \
- libutil/agetline.o \
- libutil/apathmax.o \
- libutil/concat.o \
- libutil/ealloc.o \
- libutil/eprintf.o \
- libutil/estrtol.o \
- libutil/estrtoul.o \
- libutil/explicit_bzero.o \
- libutil/passwd.o \
- libutil/proc.o \
- libutil/putword.o \
- libutil/recurse.o \
- libutil/strlcat.o \
- libutil/strlcpy.o \
- libutil/tty.o
-
-SRC = \
- last.c \
- lastlog.c \
- chvt.c \
- clear.c \
- ctrlaltdel.c \
- dd.c \
- df.c \
- dmesg.c \
- eject.c \
- fallocate.c \
- free.c \
- freeramdisk.c \
- fsfreeze.c \
- getty.c \
- halt.c \
- hwclock.c \
- id.c \
- insmod.c \
- killall5.c \
- login.c \
- lsmod.c \
- lsusb.c \
- mesg.c \
- mknod.c \
- mkswap.c \
- mount.c \
- mountpoint.c \
- pagesize.c \
- passwd.c \
- pidof.c \
- pivot_root.c \
- ps.c \
- readahead.c \
- respawn.c \
- rmmod.c \
- stat.c \
- su.c \
- swaplabel.c \
- swapoff.c \
- swapon.c \
- switch_root.c \
- sysctl.c \
- truncate.c \
- umount.c \
- unshare.c \
- uptime.c \
- watch.c \
- who.c
+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
 
 MAN1 = \
         chvt.1 \
_AT_@ -133,93 +136,73 @@ MAN8 = \
         sysctl.8 \
         umount.8
 
-OBJ = $(SRC:.c=.o) $(LIB)
-BIN = $(SRC:.c=) lastb
+LIBUTILOBJ = $(LIBUTILSRC:.c=.o)
+OBJ = $(BIN:=.o) $(LIBUTILOBJ)
+SRC = $(BIN:=.c)
 
-all: options binlib
+all: $(BIN)
 
-options:
- _AT_echo ubase build options:
- _AT_echo "CFLAGS = $(CFLAGS)"
- _AT_echo "LDFLAGS = $(LDFLAGS)"
- _AT_echo "CC = $(CC)"
+$(BIN): $(LIB)
 
-binlib: libutil.a
- $(MAKE) bin
-
-bin: $(BIN)
-
-$(OBJ): config.h util.h config.mk
+$(OBJ): $(HDR) config.mk
 
 config.h:
- _AT_echo creating $@ from config.def.h
- _AT_cp config.def.h $@
+ cp config.def.h $_AT_
 
 .o:
- _AT_echo LD $@
- _AT_$(LD) -o $@ $< libutil.a $(LDFLAGS)
+ $(LD) $(LDFLAGS) -o $_AT_ $< $(LIB)
 
 .c.o:
- _AT_echo CC $<
- _AT_$(CC) -c -o $@ $< $(CFLAGS)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -o $_AT_ -c $<
 
-libutil.a: $(LIB)
- _AT_echo AR $@
- _AT_$(AR) -r -c $@ $?
- _AT_ranlib $@
-
-lastb: last
- ln -f last lastb
+$(LIBUTIL): $(LIBUTILOBJ)
+ $(AR) -r -c $_AT_ $?
+ $(RANLIB) $_AT_
 
 install: all
- _AT_echo installing executables to $(DESTDIR)$(PREFIX)/bin
- _AT_mkdir -p $(DESTDIR)$(PREFIX)/bin
- _AT_cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin
- _AT_cd $(DESTDIR)$(PREFIX)/bin && chmod 755 $(BIN)
- _AT_echo installing manual pages to $(DESTDIR)$(MANPREFIX)/man1
- _AT_mkdir -p $(DESTDIR)$(MANPREFIX)/man1
- _AT_for m in $(MAN1); do sed "s/VERSION/$(VERSION)/g" < "$$m" > $(DESTDIR)$(MANPREFIX)/man1/"$$m"; done
- _AT_echo installing manual pages to $(DESTDIR)$(MANPREFIX)/man8
- _AT_mkdir -p $(DESTDIR)$(MANPREFIX)/man8
- _AT_for m in $(MAN8); do sed "s/VERSION/$(VERSION)/g" < "$$m" > $(DESTDIR)$(MANPREFIX)/man8/"$$m"; done
- _AT_chmod 644 $(DESTDIR)$(MANPREFIX)/man1/$(MAN1)
- _AT_chmod 644 $(DESTDIR)$(MANPREFIX)/man8/$(MAN8)
+ 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)
 
 uninstall:
- _AT_echo removing executables from $(DESTDIR)$(PREFIX)/bin
- _AT_cd $(DESTDIR)$(PREFIX)/bin && rm -f $(BIN)
- _AT_echo removing manual pages from $(DESTDIR)$(MANPREFIX)/man1
- _AT_cd $(DESTDIR)$(MANPREFIX)/man1 && rm -f $(MAN)
+ cd $(DESTDIR)$(PREFIX)/bin && rm -f $(BIN)
+ cd $(DESTDIR)$(MANPREFIX)/man1 && rm -f $(MAN1)
+ cd $(DESTDIR)$(MANPREFIX)/man8 && rm -f $(MAN8)
 
 dist: clean
- _AT_echo creating dist tarball
- _AT_mkdir -p ubase-$(VERSION)
- _AT_cp -r LICENSE Makefile config.mk TODO $(SRC) $(MAN) libutil $(HDR) ubase-$(VERSION)
- _AT_tar -cf ubase-$(VERSION).tar ubase-$(VERSION)
- _AT_gzip ubase-$(VERSION).tar
- _AT_rm -rf ubase-$(VERSION)
-
-ubase-box: config.h $(SRC) libutil.a
- _AT_echo creating box binary
- _AT_mkdir -p build
- _AT_cp $(HDR) build
- _AT_cp config.h build
- _AT_for f in $(SRC); do sed "s/^main(/`basename $$f .c`_&/" < $$f > build/$$f; done
- _AT_echo '#include <libgen.h>' > build/$@.c
- _AT_echo '#include <stdio.h>' >> build/$@.c
- _AT_echo '#include <stdlib.h>' >> build/$@.c
- _AT_echo '#include <string.h>' >> build/$@.c
- _AT_echo '#include "util.h"' >> build/$@.c
- _AT_for f in $(SRC); do echo "int `basename $$f .c`_main(int, char **);" >> build/$@.c; done
- _AT_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
- _AT_for f in $(SRC); do echo "else if(!strcmp(s, \"`basename $$f .c`\")) return `basename $$f .c`_main(argc, argv);" >> build/$@.c; done
- _AT_echo 'else {' >> build/$@.c
- _AT_for f in $(SRC); do echo "printf(\"`basename $$f .c`\"); putchar(' ');" >> build/$@.c; done
- _AT_echo "putchar(0xa); }; return 0; }" >> build/$@.c
- _AT_echo LD $@
- _AT_$(LD) -o $@ build/*.c libutil.a $(CFLAGS) $(LDFLAGS)
- _AT_rm -r build
+ 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/$_AT_.c
+ echo '#include <stdio.h>' >> build/$_AT_.c
+ echo '#include <stdlib.h>' >> build/$_AT_.c
+ echo '#include <string.h>' >> build/$_AT_.c
+ echo '#include "util.h"' >> build/$_AT_.c
+ for f in $(SRC); do echo "int `basename $$f .c`_main(int, char **);" >> build/$_AT_.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/$_AT_.c
+ for f in $(SRC); do echo "else if(!strcmp(s, \"`basename $$f .c`\")) return `basename $$f .c`_main(argc, argv);" >> build/$_AT_.c; done
+ echo 'else {' >> build/$_AT_.c
+ for f in $(SRC); do echo "printf(\"`basename $$f .c`\"); putchar(' ');" >> build/$_AT_.c; done
+ echo "putchar(0xa); }; return 0; }" >> build/$_AT_.c
+ $(LD) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $_AT_ build/*.c $(LIB)
+ rm -r build
 
 clean:
- _AT_echo cleaning
- _AT_rm -f $(BIN) $(OBJ) $(LIB) libutil.a ubase-box
+ rm -f $(BIN) $(OBJ) $(LIB) ubase-box ubase-$(VERSION).tar.gz
+
+.PHONY:
+ all install uninstall dist ubase-box clean
diff --git a/config.mk b/config.mk
index 0970abf..899bbf8 100644
--- a/config.mk
+++ b/config.mk
_AT_@ -5,9 +5,11 @@ VERSION = 0.1
 PREFIX = /usr/local
 MANPREFIX = $(PREFIX)/share/man
 
-#CC = gcc
-#CC = musl-gcc
+CC = cc
 LD = $(CC)
+AR = ar
+RANLIB = ranlib
+
 CPPFLAGS = -D_XOPEN_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-CFLAGS = -std=c99 -Wall -Wextra $(CPPFLAGS)
+CFLAGS = -std=c99 -Wall -Wextra
 LDFLAGS = -s -lcrypt # -static
Received on Sun Nov 30 2014 - 13:18:58 CET

This archive was generated by hypermail 2.3.0 : Sun Nov 30 2014 - 13:24:09 CET