# Copyright (c) 2008, 2009, 2011 - 2013, 2016, 2017 Peter Pentchev # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. LOCALBASE?= /usr/local PREFIX?= ${LOCALBASE} BINDIR?= ${PREFIX}/bin MANDIR?= ${PREFIX}/man/man EXAMPLESDIR?= ${PREFIX}/share/examples/${PROG} STD_CPPFLAGS?= -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 LFS_CPPFLAGS?= -D_FILE_OFFSET_BITS=64 LFS_LDFLAGS?= PCRE_CPPFLAGS?= -DHAVE_PCRE -I${LOCALBASE}/include PCRE_LIBS?= -L${LOCALBASE}/lib -lpcre STD_CFLAGS?= -std=c99 WARN_CFLAGS?= -Wall -W CC?= gcc CPPFLAGS?= CPPFLAGS+= ${STD_CPPFLAGS} ${LFS_CPPFLAGS} ${PCRE_CPPFLAGS} CFLAGS?= -g -pipe CFLAGS+= ${STD_CFLAGS} ${WARN_CFLAGS} LDFLAGS?= LDFLAGS+= ${LFS_LDFLAGS} LIBS?= RM= rm -f MKDIR?= mkdir -p SETENV?= env PROG= confget OBJS= confget.o confget_common.o confget_http_get.o confget_ini.o SRCS= confget.c confget_common.c confget_http_get.c confget_ini.c DEPENDFILE= .depend MAN1= confget.1 MAN1GZ= ${MAN1}.gz BINOWN?= root BINGRP?= wheel BINMODE?= 555 SHAREOWN?= ${BINOWN} SHAREGRP?= ${BINGRP} SHAREMODE?= 644 INSTALL?= install COPY?= -c STRIP?= -s INSTALL_PROGRAM?= ${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} INSTALL_SCRIPT?= ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} INSTALL_DATA?= ${INSTALL} ${COPY} -o ${SHAREOWN} -g ${SHAREGRP} -m ${SHAREMODE} # development/debugging flags, you may safely ignore them BDECFLAGS= -W -Wall -std=c99 -pedantic -Wbad-function-cast -Wcast-align \ -Wcast-qual -Wchar-subscripts -Winline \ -Wmissing-prototypes -Wnested-externs -Wpointer-arith \ -Wredundant-decls -Wshadow -Wstrict-prototypes -Wwrite-strings #CFLAGS+= ${BDECFLAGS} #CFLAGS+= -ggdb -g3 TESTEXEC= test-getline test-fgetln all: ${PROG} ${MAN1GZ} clean: ${RM} ${PROG} ${OBJS} ${MAN1GZ} ${RM} ${TESTEXEC} readaline.h ${PROG}: ${OBJS} ${CC} ${LDFLAGS} -o ${PROG} ${OBJS} ${PCRE_LIBS} .c.o: ${CC} ${CPPFLAGS} ${CFLAGS} -c $< ${MAN1GZ}: ${MAN1} gzip -c9 ${MAN1} > ${MAN1GZ}.tmp mv ${MAN1GZ}.tmp ${MAN1GZ} install: all install-bin install-man install-examples install-bin: -${MKDIR} ${DESTDIR}${BINDIR} ${INSTALL_PROGRAM} ${PROG} ${DESTDIR}${BINDIR}/ install-man: -${MKDIR} ${DESTDIR}${MANDIR}1 ${INSTALL_DATA} ${MAN1GZ} ${DESTDIR}${MANDIR}1/ install-examples: -${MKDIR} ${DESTDIR}${EXAMPLESDIR}/tests ${INSTALL_SCRIPT} t/*.t ${DESTDIR}${EXAMPLESDIR}/tests/ ${INSTALL_DATA} t/*.ini ${DESTDIR}${EXAMPLESDIR}/tests/ depend: touch readaline.h ${SETENV} CPPFLAGS="-DCONFGET_MAKEDEP ${CPPFLAGS}" \ DEPENDFILE="${DEPENDFILE}" sh makedep.sh ${SRCS} rm -f readaline.h test: all prove t readaline.h: test-getline.c Makefile rm -f readaline.h if ${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -o test-getline test-getline.c ${LIBS}; then \ echo '#define HAVE_GETLINE' > readaline.h; \ else if ${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -o test-fgetln test-fgetln.c ${LIBS}; then \ echo '#define HAVE_FGETLN' > readaline.h; \ else \ echo 'Neither getline() nor fgetln() found!' 1>&2; \ false; \ fi; fi .PHONY: all clean depend install test ifeq ($(wildcard ${DEPENDFILE}),${DEPENDFILE}) include ${DEPENDFILE} endif