File: Makefile

package info (click to toggle)
confget 2.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 552 kB
  • sloc: python: 1,303; ansic: 907; sh: 569; makefile: 142
file content (146 lines) | stat: -rw-r--r-- 4,465 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# 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}
		[ -n '${NO_DOC_BUILD}' ] || ${MAKE} ${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
		[ -n '${NO_DOC_BUILD}' ] || ${MAKE} 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