[hackers] [sbase] simpler make || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Thu, 16 Jun 2011 22:20:39 +0200 (CEST)

changeset: 83:23deb4b8e5a9
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Thu Jun 16 21:20:17 2011 +0100
files: Makefile
description:
simpler make

diff -r ae421ae32f67 -r 23deb4b8e5a9 Makefile
--- a/Makefile Thu Jun 16 01:57:01 2011 +0100
+++ b/Makefile Thu Jun 16 21:20:17 2011 +0100
@@ -54,15 +54,15 @@
 cat.o grep.o tail.o: text.h
 
 .o:
- @echo LD -o $@
+ @echo LD $@
         @$(LD) -o $@ $< util.a $(LDFLAGS)
 
 .c.o:
- @echo CC -c $<
+ @echo CC $<
         @$(CC) -c -o $@ $< $(CFLAGS)
 
 util.a: $(LIB)
- @echo AR -r $@
+ @echo AR $@
         @$(AR) -r -c $@ $(LIB)
 
 install: all
@@ -89,21 +89,21 @@
         @gzip sbase-$(VERSION).tar
         @rm -rf sbase-$(VERSION)
 
-sbase-box: $(SRC)
+sbase-box: $(SRC) util.a
         @echo creating box binary
         @mkdir -p build
- @cp -r $(HDR) util build
- @for f in $(SRC); do sed "s/^main/`basename $$f .c`_&/" < $$f > build/$$f; done
+ @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 <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/sbase-box.c; done
- @echo 'int main(int argc, char *argv[]) { char *s = basename(argv[0]); if(0);' >> build/sbase-box.c
- @for f in $(SRC); do echo "else if(!strcmp(s, \"`basename $$f .c`\")) `basename $$f .c`_main(argc, argv);" >> build/sbase-box.c; done
- @printf 'else eprintf("%%s: unknown program\\n", s); return EXIT_SUCCESS; }\n' >> build/sbase-box.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(0) ;' >> build/$@.c
+ @for f in $(SRC); do echo "else if(!strcmp(s, \"`basename $$f .c`\")) `basename $$f .c`_main(argc, argv);" >> build/$@.c; done
+ @printf 'else eprintf("%%s: unknown program\\n", s); return EXIT_SUCCESS; }\n' >> build/$@.c
         @echo LD $@
- @$(LD) -o $@ build/*.c build/util/*.c $(CFLAGS) $(LDFLAGS)
+ @$(LD) -o $@ build/*.c util.a $(CFLAGS) $(LDFLAGS)
         @rm -r build
 
 clean:
Received on Thu Jun 16 2011 - 22:20:39 CEST

This archive was generated by hypermail 2.2.0 : Thu Jun 16 2011 - 22:24:05 CEST