From 721770691c964dbd630716add95a362a0cecba4d Mon Sep 17 00:00:00 2001 From: Nick White Date: Sat, 16 Jul 2011 23:48:08 +0100 Subject: Improve build system --- Makefile | 23 +++++++++++++++++------ config.mk | 13 +++++++++++++ getgbook.c | 2 -- util.c | 4 ++-- 4 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 config.mk diff --git a/Makefile b/Makefile index d9ca4fb..ff728e6 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/getgbook.c b/getgbook.c index cf16aae..a698694 100644 --- a/getgbook.c +++ b/getgbook.c @@ -6,8 +6,6 @@ * https://www.googleapis.com/books/v1/volumes/jglfL_eVG4cC */ -#define VERSION "prealpha" - #include #include #include diff --git a/util.c b/util.c index 47facef..46dcf16 100644 --- a/util.c +++ b/util.c @@ -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; } -- cgit v1.2.3