summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.me.uk>2010-06-25 18:58:44 +0100
committerNick White <git@njw.me.uk>2010-06-25 18:58:44 +0100
commitb3fd93d1d59d22489de2a88c3e0a9373fb3a1569 (patch)
tree5ef03eb201d6791d2924f65966a7bef93daf6dfb
parent7d4ad5e47d8cdc8b9ef10f9a994d8682e14d3cdd (diff)
Fix initialisation bug, clean Makefile
-rw-r--r--Makefile70
-rw-r--r--config.mk2
-rw-r--r--tocxml.c3
3 files changed, 46 insertions, 29 deletions
diff --git a/Makefile b/Makefile
index edf3acf..06a4275 100644
--- a/Makefile
+++ b/Makefile
@@ -1,40 +1,58 @@
# See COPYING file for copyright, license and warranty details.
+NAME = getht
+SRC = cli.c download.c getht.c issuemem.c parseconfig.c tocxml.c xml.c
+TARGETS = ${NAME}
+
+OBJ = ${SRC:.c=.o}
+MAN = ${TARGETS:=.1}
+
include config.mk
-TARGET = getht
-SRC = $(shell find . -name '*.c')
-OBJ = $(SRC:.c=.o)
-MAN = $(TARGET:=.1)
-DOC = README COPYING
+all: ${TARGETS}
-all: $(TARGET)
+${OBJ}: config.mk
-$(TARGET:=.o): $(SRC)
- cc -c $(SRC) $(CFLAGS)
+.c.o:
+ @echo CC $<
+ @cc -c ${CFLAGS} $<
-$(TARGET): $(OBJ)
- cc -o $@ $(OBJ) $(LDFLAGS)
+$(TARGETS): $(OBJ)
+ @echo LD $@
+ @cc -o $@ $(OBJ) $(LDFLAGS)
clean:
- rm -f -- $(TARGET) $(OBJ) getht-*.tar.bz2*
+ rm -f -- ${TARGETS} ${OBJ} ${NAME}-${VERSION}.tar.gz ${NAME}-${VERSION}.tar.gz.sig
+
+dist: clean
+ @mkdir -p ${NAME}-${VERSION}
+ @cp -R ${SRC} Makefile config.mk COPYING README ${NAME}-${VERSION}
+ @for i in ${MAN}; do \
+ sed "s/VERSION/${VERSION}/g" < $$i > ${NAME}-${VERSION}/$$i; done
+ @tar -c ${NAME}-${VERSION} | gzip -c > ${NAME}-${VERSION}.tar.gz
+ @gpg -b < ${NAME}-${VERSION}.tar.gz > ${NAME}-${VERSION}.tar.gz.sig
+ @rm -rf ${NAME}-${VERSION}
+ @echo ${NAME}-${VERSION}.tar.gz ${NAME}-${VERSION}.tar.gz.sig
install: all
- mkdir -p $(DESTDIR)$(PREFIX)/bin
- cp -f $(TARGET) $(DESTDIR)$(PREFIX)/bin
- mkdir -p $(DESTDIR)$(MANPREFIX)/man1
- cp -f $(MAN) $(DESTDIR)$(MANPREFIX)/man1
+ @echo installing executables to ${DESTDIR}${PREFIX}/bin
+ @mkdir -p ${DESTDIR}${PREFIX}/bin
+ @for i in ${TARGETS}; do \
+ cp -f $$i ${DESTDIR}${PREFIX}/bin/$$i; \
+ chmod 755 ${DESTDIR}${PREFIX}/bin/$$i; done
+ @echo installing manual pages to ${DESTDIR}${MANPREFIX}/man1
+ @mkdir -p ${DESTDIR}${MANPREFIX}/man1
+ @for i in ${MAN}; do \
+ sed "s/VERSION/${VERSION}/g" < $$i > ${DESTDIR}${MANPREFIX}/man1/$$i; \
+ chmod 644 ${DESTDIR}${MANPREFIX}/man1/$$i; done
uninstall:
- rm -f $(DESTDIR)$(PREFIX)/bin/$(TARGET)
- rm -f $(DESTDIR)$(MANPREFIX)/man1/$(MAN)
+ @echo uninstalling executables from ${DESTDIR}${PREFIX}/bin
+ @for i in ${TARGETS}; do rm -f ${DESTDIR}${PREFIX}/bin/$$i; done
+ @echo uninstalling manual pages from ${DESTDIR}${MANPREFIX}/man1
+ @for i in ${MAN}; do rm -f ${DESTDIR}${MANPREFIX}/man1/$$i; done
-dist: clean
- mkdir -p getht-$(VERSION)
- cp -R $(SRC) $(DOC) Makefile config.mk getht-$(VERSION)
- sed "s/VERSION/$(VERSION)/g" < $(MAN) > getht-$(VERSION)/$(MAN)
- tar -c getht-$(VERSION) > getht-$(VERSION).tar
- bzip2 < getht-$(VERSION).tar > getht-$(VERSION).tar.bz2
- rm -rf getht-$(VERSION).tar getht-$(VERSION)
- gpg -b < getht-$(VERSION).tar.bz2 > getht-$(VERSION).tar.bz2.sig
- sha1sum < getht-$(VERSION).tar.bz2 > getht-$(VERSION).tar.bz2.sha1
+test: all
+ @echo no tests yet!
+
+.PHONY: all clean dist install uninstall test
diff --git a/config.mk b/config.mk
index 3251293..72fe97f 100644
--- a/config.mk
+++ b/config.mk
@@ -3,6 +3,7 @@
VERSION = 0.2
# paths
+#PREFIX = /usr/local
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
@@ -16,7 +17,6 @@ XMLINC = $(shell pkg-config --cflags libxml-2.0)
XMLLIB = $(shell pkg-config --libs libxml-2.0)
# flags
-#CFLAGS = -pedantic -Wall -Werror ${INCS} ${CURLINC} ${XMLINC} -DVERSION=\"${VERSION}\"
CFLAGS = -std=c99 -Wall -Werror ${INCS} ${CURLINC} ${XMLINC} -DVERSION=\"${VERSION}\"
LDFLAGS = ${LIBS} ${CURLLIB} ${XMLLIB}
diff --git a/tocxml.c b/tocxml.c
index ac75ec7..1e2a0b7 100644
--- a/tocxml.c
+++ b/tocxml.c
@@ -109,6 +109,7 @@ void parsesection(xmlDocPtr file, xmlNodePtr node, sec * cur_section)
/* parses section xml, filling cur_section structure */
{
it * cur_item = NULL;
+ char * pagenums = "";
strncpy(cur_section->uri, (char *) xmlGetProp(node, (unsigned char *) "pdflink"), STR_MAX);
strncpy(cur_section->title, (char *) xmlGetProp(node, (unsigned char *) "title"), STR_MAX);
@@ -120,8 +121,6 @@ void parsesection(xmlDocPtr file, xmlNodePtr node, sec * cur_section)
node = node->xmlChildrenNode;
- char * pagenums;
-
while(node != NULL)
{
if(!xmlStrcmp(node->name, (const xmlChar *) "item"))