summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <hg@njw.me.uk>2011-07-16 23:48:08 +0100
committerNick White <hg@njw.me.uk>2011-07-16 23:48:08 +0100
commit721770691c964dbd630716add95a362a0cecba4d (patch)
treec5008e66211b617b9c77e82a4af005ca8e5501b8
parentc2892e23ef3aa063812714323b5e8f9ebe0fc318 (diff)
Improve build system
-rw-r--r--Makefile23
-rw-r--r--config.mk13
-rw-r--r--getgbook.c2
-rw-r--r--util.c4
4 files changed, 32 insertions, 10 deletions
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 <stdio.h>
#include <stdlib.h>
#include <string.h>
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;
}