simpler make
This commit is contained in:
parent
a85348c33b
commit
e54eb9f4bc
22
Makefile
22
Makefile
@ -54,15 +54,15 @@ $(BIN): util.a
|
|||||||
cat.o grep.o tail.o: text.h
|
cat.o grep.o tail.o: text.h
|
||||||
|
|
||||||
.o:
|
.o:
|
||||||
@echo LD -o $@
|
@echo LD $@
|
||||||
@$(LD) -o $@ $< util.a $(LDFLAGS)
|
@$(LD) -o $@ $< util.a $(LDFLAGS)
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
@echo CC -c $<
|
@echo CC $<
|
||||||
@$(CC) -c -o $@ $< $(CFLAGS)
|
@$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
util.a: $(LIB)
|
util.a: $(LIB)
|
||||||
@echo AR -r $@
|
@echo AR $@
|
||||||
@$(AR) -r -c $@ $(LIB)
|
@$(AR) -r -c $@ $(LIB)
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
@ -89,21 +89,21 @@ dist: clean
|
|||||||
@gzip sbase-$(VERSION).tar
|
@gzip sbase-$(VERSION).tar
|
||||||
@rm -rf sbase-$(VERSION)
|
@rm -rf sbase-$(VERSION)
|
||||||
|
|
||||||
sbase-box: $(SRC)
|
sbase-box: $(SRC) util.a
|
||||||
@echo creating box binary
|
@echo creating box binary
|
||||||
@mkdir -p build
|
@mkdir -p build
|
||||||
@cp -r $(HDR) util 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 <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/sbase-box.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(0);' >> build/sbase-box.c
|
@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/sbase-box.c; done
|
@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/sbase-box.c
|
@printf 'else eprintf("%%s: unknown program\\n", s); return EXIT_SUCCESS; }\n' >> build/$@.c
|
||||||
@echo LD $@
|
@echo LD $@
|
||||||
@$(LD) -o $@ build/*.c build/util/*.c $(CFLAGS) $(LDFLAGS)
|
@$(LD) -o $@ build/*.c util.a $(CFLAGS) $(LDFLAGS)
|
||||||
@rm -r build
|
@rm -r build
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
Loading…
Reference in New Issue
Block a user