Make build process more verbose

This commit is contained in:
sin 2014-11-17 10:15:44 +00:00
parent abdd0671f7
commit 9a9d6bb0dc
2 changed files with 35 additions and 52 deletions

View File

@ -134,62 +134,51 @@ bin: $(BIN)
$(OBJ): $(HDR) config.mk $(OBJ): $(HDR) config.mk
.o: .o:
@echo LD $@ $(LD) -o $@ $< util.a $(LDFLAGS)
@$(LD) -o $@ $< util.a $(LDFLAGS)
.c.o: .c.o:
@echo CC $< $(CC) $(CFLAGS) -o $@ -c $<
@$(CC) -c -o $@ $< $(CFLAGS)
util.a: $(LIB) util.a: $(LIB)
@echo AR $@ $(AR) -r -c $@ $?
@$(AR) -r -c $@ $? ranlib $@
@ranlib $@
install: all install: all
@echo installing executables to $(DESTDIR)$(PREFIX)/bin mkdir -p $(DESTDIR)$(PREFIX)/bin
@mkdir -p $(DESTDIR)$(PREFIX)/bin cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin
@cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin cd $(DESTDIR)$(PREFIX)/bin && chmod 755 $(BIN)
@cd $(DESTDIR)$(PREFIX)/bin && chmod 755 $(BIN) mkdir -p $(DESTDIR)$(MANPREFIX)/man1
@echo installing manual pages to $(DESTDIR)$(MANPREFIX)/man1 for m in $(MAN); do sed "s/VERSION/$(VERSION)/g" < "$$m" > $(DESTDIR)$(MANPREFIX)/man1/"$$m"; done
@mkdir -p $(DESTDIR)$(MANPREFIX)/man1 cd $(DESTDIR)$(MANPREFIX)/man1 && chmod 644 $(MAN)
@for m in $(MAN); do sed "s/VERSION/$(VERSION)/g" < "$$m" > $(DESTDIR)$(MANPREFIX)/man1/"$$m"; done
@cd $(DESTDIR)$(MANPREFIX)/man1 && chmod 644 $(MAN)
uninstall: uninstall:
@echo removing executables from $(DESTDIR)$(PREFIX)/bin cd $(DESTDIR)$(PREFIX)/bin && rm -f $(BIN)
@cd $(DESTDIR)$(PREFIX)/bin && rm -f $(BIN) cd $(DESTDIR)$(MANPREFIX)/man1 && rm -f $(MAN)
@echo removing manual pages from $(DESTDIR)$(MANPREFIX)/man1
@cd $(DESTDIR)$(MANPREFIX)/man1 && rm -f $(MAN)
dist: clean dist: clean
@echo creating dist tarball mkdir -p sbase-$(VERSION)
@mkdir -p sbase-$(VERSION) cp -r LICENSE Makefile README TODO config.mk $(SRC) $(MAN) util $(HDR) sbase-$(VERSION)
@cp -r LICENSE Makefile README TODO config.mk $(SRC) $(MAN) util $(HDR) sbase-$(VERSION) tar -cf sbase-$(VERSION).tar sbase-$(VERSION)
@tar -cf sbase-$(VERSION).tar sbase-$(VERSION) gzip sbase-$(VERSION).tar
@gzip sbase-$(VERSION).tar rm -rf sbase-$(VERSION)
@rm -rf sbase-$(VERSION)
sbase-box: $(SRC) util.a sbase-box: $(SRC) util.a
@echo creating box binary mkdir -p build
@mkdir -p build cp $(HDR) build
@cp $(HDR) build for f in $(SRC); do sed "s/^main(/`basename $$f .c`_&/" < $$f > build/$$f; done
@for f in $(SRC); do sed "s/^main(/`basename $$f .c`_&/" < $$f > build/$$f; done echo '#include <libgen.h>' > build/$@.c
@echo '#include <libgen.h>' > build/$@.c echo '#include <stdio.h>' >> build/$@.c
@echo '#include <stdio.h>' >> build/$@.c echo '#include <stdlib.h>' >> build/$@.c
@echo '#include <stdlib.h>' >> build/$@.c echo '#include <string.h>' >> build/$@.c
@echo '#include <string.h>' >> build/$@.c echo '#include "util.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
@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
@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
@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
@echo 'else {' >> build/$@.c for f in $(SRC); do echo "printf(\"`basename $$f .c`\"); putchar(' ');" >> build/$@.c; done
@for f in $(SRC); do echo "printf(\"`basename $$f .c`\"); putchar(' ');" >> build/$@.c; done echo "putchar(0xa); }; return 0; }" >> build/$@.c
@echo "putchar(0xa); }; return 0; }" >> build/$@.c $(LD) -o $@ build/*.c util.a $(CFLAGS) $(LDFLAGS)
@echo LD $@ rm -r build
@$(LD) -o $@ build/*.c util.a $(CFLAGS) $(LDFLAGS)
@rm -r build
clean: clean:
@echo cleaning
@rm -f $(BIN) $(OBJ) $(LIB) util.a sbase-box sbase-$(VERSION).tar.gz @rm -f $(BIN) $(OBJ) $(LIB) util.a sbase-box sbase-$(VERSION).tar.gz

View File

@ -9,11 +9,5 @@ MANPREFIX = $(PREFIX)/share/man
#CC = musl-gcc #CC = musl-gcc
LD = $(CC) LD = $(CC)
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE
CFLAGS = -g -std=c99 -Wall -pedantic $(CPPFLAGS) CFLAGS = -std=c99 -Wall -pedantic $(CPPFLAGS)
LDFLAGS = -g LDFLAGS = -s
#CC = tcc
#LD = $(CC)
#CPPFLAGS = -D_POSIX_C_SOURCE=200112L
#CFLAGS = -Os -Wall $(CPPFLAGS) -D_GNU_SOURCE
#LDFLAGS =