diff options
-rw-r--r-- | Makefile | 23 | ||||
-rw-r--r-- | config.mk | 13 | ||||
-rw-r--r-- | getgbook.c | 2 | ||||
-rw-r--r-- | util.c | 4 |
4 files changed, 32 insertions, 10 deletions
@@ -1,19 +1,30 @@ +# See COPYING file for copyright, license and warranty details. + +include config.mk + SRC = getgbook.c OBJ = $(SRC:.c=.o) +BIN = $(SRC:.c=) -all: getgbook +all: $(BIN) + +$(OBJ): util.c .c.o: @echo CC $< - @$(CC) -c -g -Wall -Werror $(CFLAGS) $< - -$(OBJ): util.c + @$(CC) -c $(CFLAGS) $< getgbook: $(OBJ) @echo LD $@ @$(CC) -o $@ $(OBJ) $(LDFLAGS) +install: all + cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin + +uninstall: + cd $(DESTDIR)$(PREFIX)/bin && rm -f $(BIN) + clean: - rm -f -- getgbook $(OBJ) + rm -f -- $(BIN) $(OBJ) -.PHONY: all clean +.PHONY: all clean install uninstall diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..42c5654 --- /dev/null +++ b/config.mk @@ -0,0 +1,13 @@ +# See COPYING file for copyright, license and warranty details. +VERSION = prealpha + +# paths +PREFIX = /usr/local + +# flags +CFLAGS = -ansi -pedantic -Wall -Wextra -Werror -g -D_POSIX_C_SOURCE=200112L -DVERSION=\"$(VERSION)\" +LDFLAGS = + +# compiler and linker +CC = cc +LD = ld @@ -6,8 +6,6 @@ * https://www.googleapis.com/books/v1/volumes/jglfL_eVG4cC */ -#define VERSION "prealpha" - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -36,7 +36,7 @@ static int dial(char *host, char *port) { int get(char *host, char *path, char **buf) { size_t l, res; - int fd, i; + int fd, i, p; char h[1024] = "\0"; FILE *srv; @@ -49,7 +49,7 @@ int get(char *host, char *path, char **buf) { while(h[0] != '\r') { fgets(h, 1024, srv); - if(sscanf(h, "HTTP/%d.%d %d", &i, &i, &l) == 3 && l != 200) + if(sscanf(h, "HTTP/%d.%d %d", &i, &i, &p) == 3 && p != 200) return 1; } |