sfeed

simple feed reader - forked from git.codemadness.org/sfeed
git clone git://src.gearsix.net/sfeed
Log | Files | Refs | Atom | README | LICENSE

commit d646f34126dc541914fc6609150a0219c470961f
parent b5282c0c2cb976753c2faf9a438ef04d2daace6d
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sat, 27 Feb 2016 17:19:45 +0100

simplify build and fix linking for strlcat.o and strlcpy.o

separate util source (util.c, strlcat.c, strlcpy.c) to libutil.a
separate xml source (xml.c) to libxml.a

Diffstat:
MMakefile | 98++++++++++++++++++++++++++++++++-----------------------------------------------
Mconfig.mk | 25++++++++++++-------------
2 files changed, 51 insertions(+), 72 deletions(-)

diff --git a/Makefile b/Makefile @@ -2,20 +2,6 @@ include config.mk NAME = sfeed VERSION = 0.9 -SRC = \ - sfeed.c\ - sfeed_frames.c\ - sfeed_html.c\ - sfeed_mbox.c\ - sfeed_opml_import.c\ - sfeed_plain.c\ - sfeed_tail.c\ - sfeed_web.c\ - sfeed_xmlenc.c\ - util.c\ - xml.c\ - strlcat.c\ - strlcpy.c BIN = \ sfeed\ sfeed_frames\ @@ -29,18 +15,25 @@ BIN = \ SCRIPTS = \ sfeed_opml_export\ sfeed_update -MAN1 = \ - sfeed.1\ - sfeed_frames.1\ - sfeed_html.1\ - sfeed_mbox.1\ - sfeed_opml_export.1\ - sfeed_opml_import.1\ - sfeed_plain.1\ - sfeed_tail.1\ - sfeed_update.1\ - sfeed_web.1\ - sfeed_xmlenc.1 + +SRC = ${BIN:=.c} + +LIBUTIL = libutil.a +LIBUTILSRC = \ + strlcat.c\ + strlcpy.c\ + util.c +LIBUTILOBJ = ${LIBUTILSRC:.c=.o} + +LIBXML = libxml.a +LIBXMLSRC = \ + xml.c +LIBXMLOBJ = ${LIBXMLSRC:.c=.o} + +LIB = ${LIBUTIL} ${LIBXML} + +MAN1 = ${BIN:=.1}\ + ${SCRIPTS:=.1} MAN5 = \ sfeedrc.5 DOC = \ @@ -53,17 +46,33 @@ HDR = \ util.h\ xml.h +all: $(BIN) + +${BIN}: ${LIB} ${@:=.o} + OBJ = ${SRC:.c=.o} -all: $(BIN) +${OBJ}: config.mk ${HDR} + +.o: + ${CC} ${LDFLAGS} -o $@ $< ${LIB} .c.o: - ${CC} -c ${CFLAGS} $< + ${CC} -c ${CFLAGS} ${CPPFLAGS} -o $@ -c $< + +${LIBUTIL}: ${LIBUTILOBJ} + ${AR} rc $@ $? + ${RANLIB} $@ + +${LIBXML}: ${LIBXMLOBJ} + ${AR} rc $@ $? + ${RANLIB} $@ dist: $(BIN) rm -rf release/${VERSION} mkdir -p release/${VERSION} - cp -f ${MAN1} ${MAN5} ${HDR} ${SCRIPTS} ${SRC} ${DOC} \ + cp -f ${MAN1} ${MAN5} ${DOC} ${HDR} \ + ${SRC} ${LIBXMLSRC} ${LIBUTILSRC} ${SCRIPTS} \ Makefile config.mk \ sfeedrc.example style.css \ release/${VERSION}/ @@ -72,37 +81,8 @@ dist: $(BIN) (cd release/${VERSION}; \ tar -czf ../../sfeed-${VERSION}.tar.gz .) -${OBJ}: config.mk ${HDR} - -sfeed: sfeed.o xml.o util.o - ${CC} -o $@ sfeed.o xml.o util.o ${LDFLAGS} - -sfeed_frames: sfeed_frames.o util.o - ${CC} -o $@ sfeed_frames.o util.o ${LDFLAGS} - -sfeed_html: sfeed_html.o util.o - ${CC} -o $@ sfeed_html.o util.o ${LDFLAGS} - -sfeed_mbox: sfeed_mbox.o util.o - ${CC} -o $@ sfeed_mbox.o util.o ${LDFLAGS} - -sfeed_opml_import: sfeed_opml_import.o util.o xml.o - ${CC} -o $@ sfeed_opml_import.o util.o xml.o ${LDFLAGS} - -sfeed_plain: sfeed_plain.o util.o - ${CC} -o $@ sfeed_plain.o util.o ${LDFLAGS} - -sfeed_tail: sfeed_tail.o util.o - ${CC} -o $@ sfeed_tail.o util.o ${LDFLAGS} - -sfeed_web: sfeed_web.o xml.o util.o - ${CC} -o $@ sfeed_web.o xml.o util.o ${LDFLAGS} - -sfeed_xmlenc: sfeed_xmlenc.o util.o xml.o - ${CC} -o $@ sfeed_xmlenc.o util.o xml.o ${LDFLAGS} - clean: - rm -f ${BIN} ${OBJ} + rm -f ${BIN} ${OBJ} ${LIB} install: all # installing executable files and scripts. diff --git a/config.mk b/config.mk @@ -4,26 +4,25 @@ PREFIX = /usr/local MANPREFIX = ${PREFIX}/man -# includes and libs -LIBS = -lc +# compiler and linker +CC = cc +AR = ar +RANLIB = ranlib # debug #CFLAGS = -fstack-protector-all -O0 -g -std=c99 -Wall -Wextra -pedantic \ # -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -#LDFLAGS = ${LIBS} +#LDFLAGS = # optimized -CFLAGS = -O2 -std=c99 \ - -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -LDFLAGS = -s ${LIBS} +CFLAGS = -O2 -std=c99 +CPPFLAGS = -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE +LDFLAGS = -s # optimized static -#CFLAGS = -static -O2 -std=c99 \ -# -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -#LDFLAGS = -static -s ${LIBS} +#CFLAGS = -static -O2 -std=c99 +CPPFLAGS = -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE +#LDFLAGS = -static -s # OpenBSD 5.9+: use pledge(2) -#CFLAGS += -DUSE_PLEDGE - -# compiler and linker -#CC = cc +CPPFLAGS += -DUSE_PLEDGE