Makefile (3651B)
1 include config.mk 2 3 .SUFFIXES: 4 .SUFFIXES: .o .c 5 6 HDR =\ 7 arg.h\ 8 compat.h\ 9 crypt.h\ 10 fs.h\ 11 md5.h\ 12 queue.h\ 13 runetypebody.h\ 14 sha1.h\ 15 sha256.h\ 16 sha512.h\ 17 text.h\ 18 utf.h\ 19 util.h 20 21 LIBUTF = libutf.a 22 LIBUTFSRC =\ 23 libutf/chartorunearr.c\ 24 libutf/readrune.c\ 25 libutf/rune.c\ 26 libutf/runetype.c\ 27 libutf/utf.c\ 28 libutf/writerune.c 29 30 LIBUTIL = libutil.a 31 LIBUTILSRC =\ 32 libutil/agetcwd.c\ 33 libutil/apathmax.c\ 34 libutil/concat.c\ 35 libutil/cp.c\ 36 libutil/crypt.c\ 37 libutil/ealloc.c\ 38 libutil/enmasse.c\ 39 libutil/eprintf.c\ 40 libutil/eregcomp.c\ 41 libutil/estrtod.c\ 42 libutil/estrtol.c\ 43 libutil/fnck.c\ 44 libutil/getlines.c\ 45 libutil/human.c\ 46 libutil/md5.c\ 47 libutil/mode.c\ 48 libutil/putword.c\ 49 libutil/recurse.c\ 50 libutil/rm.c\ 51 libutil/sha1.c\ 52 libutil/sha256.c\ 53 libutil/sha512.c\ 54 libutil/strcasestr.c\ 55 libutil/strlcat.c\ 56 libutil/strlcpy.c 57 58 LIB = $(LIBUTF) $(LIBUTIL) 59 60 BIN =\ 61 basename\ 62 cal\ 63 cat\ 64 chgrp\ 65 chmod\ 66 chown\ 67 chroot\ 68 cksum\ 69 cmp\ 70 cols\ 71 comm\ 72 cp\ 73 cron\ 74 cut\ 75 date\ 76 dirname\ 77 du\ 78 echo\ 79 env\ 80 expand\ 81 expr\ 82 false\ 83 fold\ 84 grep\ 85 head\ 86 hostname\ 87 kill\ 88 link\ 89 ln\ 90 logger\ 91 logname\ 92 ls\ 93 md5sum\ 94 mkdir\ 95 mkfifo\ 96 mktemp\ 97 mv\ 98 nice\ 99 nl\ 100 nohup\ 101 paste\ 102 printenv\ 103 printf\ 104 pwd\ 105 readlink\ 106 renice\ 107 rm\ 108 rmdir\ 109 seq\ 110 setsid\ 111 sha1sum\ 112 sha256sum\ 113 sha512sum\ 114 sleep\ 115 sort\ 116 split\ 117 sponge\ 118 strings\ 119 sync\ 120 tail\ 121 tar\ 122 tee\ 123 test\ 124 touch\ 125 tr\ 126 true\ 127 tty\ 128 uname\ 129 unexpand\ 130 uniq\ 131 unlink\ 132 uudecode\ 133 uuencode\ 134 wc\ 135 xargs\ 136 yes 137 138 LIBUTFOBJ = $(LIBUTFSRC:.c=.o) 139 LIBUTILOBJ = $(LIBUTILSRC:.c=.o) 140 OBJ = $(BIN:=.o) $(LIBUTFOBJ) $(LIBUTILOBJ) 141 SRC = $(BIN:=.c) 142 MAN = $(BIN:=.1) 143 144 all: $(BIN) 145 146 $(BIN): $(LIB) $(@:=.o) 147 148 $(OBJ): $(HDR) config.mk 149 150 .o: 151 $(LD) $(LDFLAGS) -o $@ $< $(LIB) 152 153 .c.o: 154 $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< 155 156 $(LIBUTF): $(LIBUTFOBJ) 157 $(AR) -r -c $@ $? 158 $(RANLIB) $@ 159 160 $(LIBUTIL): $(LIBUTILOBJ) 161 $(AR) -r -c $@ $? 162 $(RANLIB) $@ 163 164 install: all 165 mkdir -p $(DESTDIR)$(PREFIX)/bin 166 cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin 167 cd $(DESTDIR)$(PREFIX)/bin && chmod 755 $(BIN) 168 mkdir -p $(DESTDIR)$(MANPREFIX)/man1 169 for m in $(MAN); do sed "s/VERSION/$(VERSION)/g" < "$$m" > $(DESTDIR)$(MANPREFIX)/man1/"$$m"; done 170 cd $(DESTDIR)$(MANPREFIX)/man1 && chmod 644 $(MAN) 171 172 uninstall: 173 cd $(DESTDIR)$(PREFIX)/bin && rm -f $(BIN) 174 cd $(DESTDIR)$(MANPREFIX)/man1 && rm -f $(MAN) 175 176 dist: clean 177 mkdir -p sbase-$(VERSION) 178 cp -r LICENSE Makefile README TODO config.mk $(SRC) $(MAN) libutf libutil $(HDR) sbase-$(VERSION) 179 tar -cf sbase-$(VERSION).tar sbase-$(VERSION) 180 gzip sbase-$(VERSION).tar 181 rm -rf sbase-$(VERSION) 182 183 sbase-box: $(LIB) $(SRC) 184 mkdir -p build 185 cp $(HDR) build 186 for f in $(SRC); do sed "s/^main(/`basename $$f .c`_&/" < $$f > build/$$f; done 187 echo '#include <libgen.h>' > build/$@.c 188 echo '#include <stdio.h>' >> build/$@.c 189 echo '#include <stdlib.h>' >> build/$@.c 190 echo '#include <string.h>' >> build/$@.c 191 echo '#include "util.h"' >> build/$@.c 192 for f in $(SRC); do echo "int `basename $$f .c`_main(int, char **);" >> build/$@.c; done 193 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 194 for f in $(SRC); do echo "else if(!strcmp(s, \"`basename $$f .c`\")) return `basename $$f .c`_main(argc, argv);" >> build/$@.c; done 195 echo 'else {' >> build/$@.c 196 for f in $(SRC); do echo "printf(\"`basename $$f .c`\"); putchar(' ');" >> build/$@.c; done 197 echo "putchar(0xa); }; return 0; }" >> build/$@.c 198 $(LD) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ build/*.c $(LIB) 199 rm -r build 200 201 clean: 202 rm -f $(BIN) $(OBJ) $(LIB) sbase-box sbase-$(VERSION).tar.gz 203 204 .PHONY: 205 all install uninstall dist sbase-box clean