summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2015-01-02 16:49:04 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2015-01-02 16:49:04 +0100
commit9d19f7f844be74359b054d3bf395d6fdff5c20f8 (patch)
tree914bdb310b9d0db2a42a17809911a0bc93e39f26
parent99d1766681b543dc0e2e50138c473fbcabd1c809 (diff)
improve compat
-rw-r--r--Makefile43
-rw-r--r--config.mk21
-rw-r--r--util.h14
3 files changed, 37 insertions, 41 deletions
diff --git a/Makefile b/Makefile
index db6351e..47ee223 100644
--- a/Makefile
+++ b/Makefile
@@ -10,6 +10,7 @@ SRC = \
sfeed_plain.c\
sfeed_web.c\
sfeed_xmlenc.c\
+ strlcpy.c\
util.c\
xml.c
BIN = \
@@ -45,13 +46,7 @@ HDR = \
util.h\
xml.h
-LIBCOMPAT = libcompat.a
-LIBCOMPATSRC = \
- compat/strlcpy.c
-LIBCOMPATOBJ = $(LIBCOMPATSRC:.c=.o)
-
-OBJ = ${SRC:.c=.o} \
- $(LIBCOMPATOBJ)
+OBJ = ${SRC:.c=.o}
all: $(BIN)
@@ -88,33 +83,29 @@ doc-oldman: $(MAN1)
${OBJ}: config.mk
-$(LIBCOMPAT): $(LIBCOMPATDOBJ)
- $(AR) -r -c $@ $?
- $(RANLIB) $@
-
-sfeed: sfeed.o xml.o util.o
- ${CC} -o $@ sfeed.o xml.o util.o ${LDFLAGS}
+sfeed: sfeed.o xml.o util.o ${EXTRAOBJ}
+ ${CC} -o $@ $? ${LDFLAGS}
-sfeed_opml_import: sfeed_opml_import.o xml.o util.o
- ${CC} -o $@ sfeed_opml_import.o xml.o util.o ${LDFLAGS}
+sfeed_opml_import: sfeed_opml_import.o xml.o util.o ${EXTRAOBJ}
+ ${CC} -o $@ $? ${LDFLAGS}
-sfeed_plain: sfeed_plain.o util.o
- ${CC} -o $@ sfeed_plain.o util.o ${LDFLAGS}
+sfeed_plain: sfeed_plain.o util.o ${EXTRAOBJ}
+ ${CC} -o $@ $? ${LDFLAGS}
-sfeed_html: sfeed_html.o util.o
- ${CC} -o $@ sfeed_html.o util.o ${LDFLAGS}
+sfeed_html: sfeed_html.o util.o ${EXTRAOBJ}
+ ${CC} -o $@ $? ${LDFLAGS}
-sfeed_frames: sfeed_frames.o util.o
- ${CC} -o $@ sfeed_frames.o util.o ${LDFLAGS}
+sfeed_frames: sfeed_frames.o util.o ${EXTRAOBJ}
+ ${CC} -o $@ $? ${LDFLAGS}
-sfeed_xmlenc: sfeed_xmlenc.o xml.o
- ${CC} -o $@ sfeed_xmlenc.o xml.o ${LDFLAGS}
+sfeed_xmlenc: sfeed_xmlenc.o xml.o ${EXTRAOBJ}
+ ${CC} -o $@ $? ${LDFLAGS}
-sfeed_web: sfeed_web.o xml.o util.o
- ${CC} -o $@ sfeed_web.o xml.o util.o ${LDFLAGS}
+sfeed_web: sfeed_web.o xml.o util.o ${EXTRAOBJ}
+ ${CC} -o $@ $? ${LDFLAGS}
clean:
- rm -f ${BIN} ${OBJ} ${LIBCOMPAT}
+ rm -f ${BIN} ${OBJ}
install: all
# installing executable files and scripts.
diff --git a/config.mk b/config.mk
index 7c831ae..33bc780 100644
--- a/config.mk
+++ b/config.mk
@@ -5,26 +5,31 @@ PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
# includes and libs
-INCS =
+INCS = -I.
LIBS = -lc
# debug
CFLAGS = -fstack-protector-all -O0 -g -std=c99 -Wall -Wextra -pedantic \
- -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700
+ ${INCS} \
+ -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE
LDFLAGS = ${LIBS}
# optimized
-#CFLAGS = -O2 -std=c99 -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700
+#CFLAGS = -O2 -std=c99 \
+# ${INCS} \
+# -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE
#LDFLAGS = -s ${LIBS}
-# tcc
-#CC = tcc
-#CFLAGS = -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700
-#LDFLAGS = -s ${LIBS}
+# optimized static
+#CFLAGS = -static -O2 -std=c99 \
+# ${INCS} \
+# -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE
+#LDFLAGS = -static -s ${LIBS}
# uncomment for compat
CFLAGS += -DCOMPAT
-LDFLAGS += -L. -lcompat
+# if your libc doesn't support strlcpy.c
+EXTRAOBJ = strlcpy.o
# compiler and linker
#CC = cc
diff --git a/util.h b/util.h
index 67b2f2a..5b876f0 100644
--- a/util.h
+++ b/util.h
@@ -2,6 +2,7 @@
#include "compat.h"
#endif
+#include <stdio.h>
#include <time.h>
#define ISUTF8(c) (((c) & 0xc0) != 0x80)
@@ -20,10 +21,9 @@ enum { FieldUnixTimestamp = 0, FieldTimeFormatted, FieldTitle, FieldLink,
FieldContent, FieldContentType, FieldId, FieldAuthor, FieldFeedType,
FieldFeedName, FieldFeedUrl, FieldBaseSiteUrl, FieldLast };
-void feedsfree(struct feed *f);
-unsigned int parseline(char **line, size_t *size, char **fields,
- unsigned int maxfields, int separator, FILE *fp);
-void printfeednameid(const char *s, FILE *fp);
-void printhtmlencoded(const char *s, FILE *fp);
-void printlink(const char *link, const char *baseurl, FILE *fp);
-void printutf8pad(FILE *fp, const char *s, size_t len, int pad);
+void feedsfree(struct feed *);
+unsigned int parseline(char **, size_t *, char **, unsigned int, int, FILE *);
+void printfeednameid(const char *, FILE *);
+void printhtmlencoded(const char *, FILE *);
+void printlink(const char *, const char *, FILE *);
+void printutf8pad(FILE *, const char *, size_t, int);