Makefile (4380B) - raw


      1 .POSIX:
      2 
      3 NAME = sfeed
      4 VERSION = 1.2
      5 
      6 # curses theme, see themes/ directory.
      7 SFEED_THEME = mono
      8 
      9 # paths
     10 PREFIX = /usr/local
     11 MANPREFIX = ${PREFIX}/man
     12 DOCPREFIX = ${PREFIX}/share/doc/${NAME}
     13 
     14 RANLIB = ranlib
     15 
     16 # use system flags.
     17 SFEED_CFLAGS = ${CFLAGS}
     18 SFEED_LDFLAGS = ${LDFLAGS}
     19 SFEED_CPPFLAGS = -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -D_BSD_SOURCE
     20 
     21 # uncomment for conservative locked I/O.
     22 #SFEED_CPPFLAGS = -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -D_BSD_SOURCE \
     23 #	-DGETNEXT=getchar
     24 
     25 # set $SFEED_CURSES to empty to not build sfeed_curses.
     26 SFEED_CURSES = sfeed_curses
     27 SFEED_CURSES_CFLAGS = ${CFLAGS}
     28 SFEED_CURSES_CPPFLAGS = -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -D_BSD_SOURCE \
     29 	 -DSFEED_THEME=\"themes/${SFEED_THEME}.h\" ${SFEED_CPPFLAGS}
     30 SFEED_CURSES_LDFLAGS = ${LDFLAGS} -lcurses
     31 
     32 # Linux: some distros use ncurses and require -lncurses.
     33 #SFEED_CURSES_LDFLAGS = ${LDFLAGS} -lncurses
     34 
     35 # Gentoo Linux: some distros might also require -ltinfo and -D_DEFAULT_SOURCE
     36 # to prevent warnings about feature test macros.
     37 #SFEED_CURSES_LDFLAGS = ${LDFLAGS} -lcurses -ltinfo
     38 
     39 # FreeBSD: unset feature test macros for SIGWINCH etc.
     40 #SFEED_CURSES_CPPFLAGS =
     41 
     42 # use minicurses with hardcoded escape sequences (not the system curses).
     43 #SFEED_CURSES_CPPFLAGS = -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -D_BSD_SOURCE \
     44 #	-DSFEED_THEME=\"themes/${SFEED_THEME}.h\" -DSFEED_MINICURSES
     45 #SFEED_CURSES_LDFLAGS = ${LDFLAGS}
     46 
     47 BIN = \
     48 	sfeed\
     49 	sfeed_atom\
     50 	${SFEED_CURSES}\
     51 	sfeed_frames\
     52 	sfeed_gopher\
     53 	sfeed_html\
     54 	sfeed_mbox\
     55 	sfeed_opml_import\
     56 	sfeed_plain\
     57 	sfeed_twtxt\
     58 	sfeed_web\
     59 	sfeed_xmlenc
     60 SCRIPTS = \
     61 	sfeed_content\
     62 	sfeed_markread\
     63 	sfeed_opml_export\
     64 	sfeed_update
     65 
     66 SRC = ${BIN:=.c}
     67 HDR = \
     68 	minicurses.h\
     69 	util.h\
     70 	xml.h
     71 
     72 LIBUTIL = libutil.a
     73 LIBUTILSRC = \
     74 	util.c
     75 LIBUTILOBJ = ${LIBUTILSRC:.c=.o}
     76 
     77 LIBXML = libxml.a
     78 LIBXMLSRC = \
     79 	xml.c
     80 LIBXMLOBJ = ${LIBXMLSRC:.c=.o}
     81 
     82 COMPATSRC = \
     83 	strlcat.c\
     84 	strlcpy.c
     85 COMPATOBJ =\
     86 	strlcat.o\
     87 	strlcpy.o
     88 
     89 LIB = ${LIBUTIL} ${LIBXML} ${COMPATOBJ}
     90 
     91 MAN1 = ${BIN:=.1}\
     92 	${SCRIPTS:=.1}
     93 MAN5 = \
     94 	sfeed.5\
     95 	sfeedrc.5
     96 DOC = \
     97 	LICENSE\
     98 	README\
     99 	README.xml
    100 
    101 all: ${BIN}
    102 
    103 ${BIN}: ${LIB} ${@:=.o}
    104 
    105 OBJ = ${SRC:.c=.o} ${LIBXMLOBJ} ${LIBUTILOBJ} ${COMPATOBJ}
    106 
    107 ${OBJ}: ${HDR}
    108 
    109 .o:
    110 	${CC} -o $@ $< ${LIB} ${SFEED_LDFLAGS}
    111 
    112 .c.o:
    113 	${CC} -o $@ -c $< ${SFEED_CFLAGS} ${SFEED_CPPFLAGS}
    114 
    115 sfeed_curses.o: sfeed_curses.c
    116 	${CC} -o $@ -c sfeed_curses.c ${SFEED_CURSES_CFLAGS} ${SFEED_CURSES_CPPFLAGS}
    117 
    118 sfeed_curses: ${LIB} sfeed_curses.o
    119 	${CC} -o $@ sfeed_curses.o ${LIB} ${SFEED_CURSES_LDFLAGS}
    120 
    121 ${LIBUTIL}: ${LIBUTILOBJ}
    122 	${AR} -rc $@ $?
    123 	${RANLIB} $@
    124 
    125 ${LIBXML}: ${LIBXMLOBJ}
    126 	${AR} -rc $@ $?
    127 	${RANLIB} $@
    128 
    129 dist:
    130 	rm -rf "${NAME}-${VERSION}"
    131 	mkdir -p "${NAME}-${VERSION}"
    132 	cp -fR ${MAN1} ${MAN5} ${DOC} ${HDR} \
    133 		${SRC} ${LIBXMLSRC} ${LIBUTILSRC} ${COMPATSRC} ${SCRIPTS} \
    134 		themes Makefile \
    135 		sfeedrc.example style.css \
    136 		"${NAME}-${VERSION}"
    137 	# make tarball
    138 	tar cf - "${NAME}-${VERSION}" | \
    139 		gzip -c > "${NAME}-${VERSION}.tar.gz"
    140 	rm -rf "${NAME}-${VERSION}"
    141 
    142 clean:
    143 	rm -f ${BIN} ${OBJ} ${LIB}
    144 
    145 install: all
    146 	# installing executable files and scripts.
    147 	mkdir -p "${DESTDIR}${PREFIX}/bin"
    148 	cp -f ${BIN} ${SCRIPTS} "${DESTDIR}${PREFIX}/bin"
    149 	for f in ${BIN} ${SCRIPTS}; do chmod 755 "${DESTDIR}${PREFIX}/bin/$$f"; done
    150 	# installing example files.
    151 	mkdir -p "${DESTDIR}${DOCPREFIX}"
    152 	cp -f sfeedrc.example\
    153 		style.css\
    154 		README\
    155 		README.xml\
    156 		"${DESTDIR}${DOCPREFIX}"
    157 	# installing manual pages for general commands: section 1.
    158 	mkdir -p "${DESTDIR}${MANPREFIX}/man1"
    159 	cp -f ${MAN1} "${DESTDIR}${MANPREFIX}/man1"
    160 	for m in ${MAN1}; do chmod 644 "${DESTDIR}${MANPREFIX}/man1/$$m"; done
    161 	# installing manual pages for file formats: section 5.
    162 	mkdir -p "${DESTDIR}${MANPREFIX}/man5"
    163 	cp -f ${MAN5} "${DESTDIR}${MANPREFIX}/man5"
    164 	for m in ${MAN5}; do chmod 644 "${DESTDIR}${MANPREFIX}/man5/$$m"; done
    165 
    166 uninstall:
    167 	# removing executable files and scripts.
    168 	for f in ${BIN} ${SCRIPTS}; do rm -f "${DESTDIR}${PREFIX}/bin/$$f"; done
    169 	# removing example files.
    170 	rm -f \
    171 		"${DESTDIR}${DOCPREFIX}/sfeedrc.example"\
    172 		"${DESTDIR}${DOCPREFIX}/style.css"\
    173 		"${DESTDIR}${DOCPREFIX}/README"\
    174 		"${DESTDIR}${DOCPREFIX}/README.xml"
    175 	-rmdir "${DESTDIR}${DOCPREFIX}"
    176 	# removing manual pages.
    177 	for m in ${MAN1}; do rm -f "${DESTDIR}${MANPREFIX}/man1/$$m"; done
    178 	for m in ${MAN5}; do rm -f "${DESTDIR}${MANPREFIX}/man5/$$m"; done
    179 
    180 .PHONY: all clean dist install uninstall