summaryrefslogtreecommitdiff
path: root/Makefile.am
blob: 156d690c8e5e316bf083211b5d065bb198aad59e (plain)
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# Makefile for popt library.

ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = -I. -I$(top_srcdir)
AM_CFLAGS = $(POPT_CFLAGS)
AM_LDFLAGS = $(POPT_LDFLAGS) $(INTLLIBS)

## begin configmake

# Retrieve values of the variables through 'configure' followed by
# 'make', not directly through 'configure', so that a user who
# sets some of these variables consistently on the 'make' command
# line gets correct results.
#
# One advantage of this approach, compared to the classical
# approach of adding -DLIBDIR=\"$(libdir)\" etc. to AM_CPPFLAGS,
# is that it protects against the use of undefined variables.
# If, say, $(libdir) is not set in the Makefile, LIBDIR is not
# defined by this module, and code using LIBDIR gives a
# compilation error.
#
# Another advantage is that 'make' output is shorter.
#
# Listed in the same order as the GNU makefile conventions.
# The Automake-defined pkg* macros are appended, in the order
# listed in the Automake 1.10a+ documentation.
configmake.h: Makefile
	$(AM_V_GEN)rm -f $@-t && \
	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
	  echo '#define PREFIX "$(prefix)"'; \
	  echo '#define EXEC_PREFIX "$(exec_prefix)"'; \
	  echo '#define BINDIR "$(bindir)"'; \
	  echo '#define SBINDIR "$(sbindir)"'; \
	  echo '#define LIBEXECDIR "$(libexecdir)"'; \
	  echo '#define DATAROOTDIR "$(datarootdir)"'; \
	  echo '#define DATADIR "$(datadir)"'; \
	  echo '#define SYSCONFDIR "$(sysconfdir)"'; \
	  echo '#define SHAREDSTATEDIR "$(sharedstatedir)"'; \
	  echo '#define LOCALSTATEDIR "$(localstatedir)"'; \
	  echo '#define INCLUDEDIR "$(includedir)"'; \
	  echo '#define OLDINCLUDEDIR "$(oldincludedir)"'; \
	  echo '#define DOCDIR "$(docdir)"'; \
	  echo '#define INFODIR "$(infodir)"'; \
	  echo '#define HTMLDIR "$(htmldir)"'; \
	  echo '#define DVIDIR "$(dvidir)"'; \
	  echo '#define PDFDIR "$(pdfdir)"'; \
	  echo '#define PSDIR "$(psdir)"'; \
	  echo '#define LIBDIR "$(libdir)"'; \
	  echo '#define LISPDIR "$(lispdir)"'; \
	  echo '#define LOCALEDIR "$(localedir)"'; \
	  echo '#define MANDIR "$(mandir)"'; \
	  echo '#define MANEXT "$(manext)"'; \
	  echo '#define PKGDATADIR "$(pkgdatadir)"'; \
	  echo '#define PKGINCLUDEDIR "$(pkgincludedir)"'; \
	  echo '#define PKGLIBDIR "$(pkglibdir)"'; \
	  echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \
	  echo '#define POPT_ALIAS "$(sysconfdir)/popt"'; \
	} | sed '/""/d' > $@-t && \
	if test -f $@ && cmp $@-t $@ > /dev/null; then \
	  rm -f $@-t; \
	  touch $@; \
	else \
	  rm -f $@; mv $@-t $@; \
	fi

BUILT_SOURCES = configmake.h
CLEANFILES = configmake.h configmake.h-t


## end configmake

EXTRA_DIST = lookup3.c autogen.sh CHANGES  \
	footer_no_timestamp.html libpopt.vers README-prereq \
	popt.xcodeproj/project.pbxproj \
	popt.ps Doxyfile \
	Makefile.mingw config.h.mingw

dist_noinst_SCRIPTS = \
	autogen.sh \
	testit.sh
dist_noinst_DATA = \
	test-poptrc \
	test3-data/01.answer \
	test3-data/01.input \
	test3-data/02.answer \
	test3-data/02.input \
	test3-data/03.answer \
	test3-data/03.input

SUBDIRS = po . auto

noinst_HEADERS = poptint.h system.h

check_PROGRAMS  = test1 test2 tdict test3
check_SCRIPTS	= $(TESTS)


test1_CPPFLAGS  = -I $(top_builddir) 
test2_CPPFLAGS  = -I $(top_builddir) 
tdict_CPPFLAGS  = -I $(top_builddir) 
test3_CPPFLAGS  = -I $(top_builddir) 
test1_CFLAGS  = $(AM_CFLAGS) 
test2_CFLAGS  = $(AM_CFLAGS) 
tdict_CFLAGS  = $(AM_CFLAGS) 
test3_CFLAGS  = $(AM_CFLAGS) 
test1_LDFLAGS  = $(AM_LDFLAGS) 
test2_LDFLAGS  = $(AM_LDFLAGS) 
tdict_LDFLAGS  = $(AM_LDFLAGS) 
test3_LDFLAGS  = $(AM_LDFLAGS) 
test1_LDADD  = $(top_builddir)/$(usrlib_LTLIBRARIES)
test2_LDADD  = $(top_builddir)/$(usrlib_LTLIBRARIES)
tdict_LDADD  = $(top_builddir)/$(usrlib_LTLIBRARIES)
test3_LDADD  = $(top_builddir)/$(usrlib_LTLIBRARIES)

TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) MUDFLAP_OPTIONS="$(MUDFLAP_OPTIONS)" testpoptrc="test-poptrc" PATH=.:../src:$$PATH \
                        valgrind_environment="$(VALGRIND_ENVIRONMENT)"


TESTS = testit.sh

include_HEADERS = popt.h

usrlibdir = $(libdir)
usrlib_LTLIBRARIES = libpopt.la

libpopt_la_SOURCES = popt.c poptparse.c poptconfig.c popthelp.c poptint.c
libpopt_la_LDFLAGS = -no-undefined $(AM_LDFLAGS)
libpopt_la_LIBADD = $(LTLIBICONV)

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = popt.pc

poptaliasdir = $(sysconfdir)/popt.d
poptalias_DATA =

if HAVE_LD_VERSION_SCRIPT
libpopt_la_LDFLAGS += -Wl,@LD_VERSION_SCRIPT_FLAG@,@top_srcdir@/libpopt.vers
endif

dist_man_MANS = popt.3

BUILT_SOURCES += popt.pc .syntastic_c_config

.syntastic_c_config: Makefile
	@echo $(COMPILE) | tr ' ' '\n' | sed -e '1d' > $@

distclean-local:
	rm -rf .ccache .syntastic_c_config
	rm -f cscope.files cscope.out cscope.in.out cscope.po.out

clean-local:
	rm -rf doxygen *.gcda *.gcno lcov-result popt-valgrind-result 

if HAVE_SPLINT
lint:
	$(SPLINT) ${DEFS} ${INCLUDES} test1.c ${libpopt_la_SOURCES}

popt.lcd: Makefile.am ${libpopt_la_SOURCES} ${include_HEADERS} ${noinst_HEADERS}
	$(SPLINT) -dump $@ ${libpopt_la_SOURCES}
endif 

if HAVE_MCCABE
mccabe:
	$(MCCABE) $(libpopt_la_SOURCES) | sort -n -r | head -n 10
endif

if HAVE_CPPCHECK
cppcheck:
	$(CPPCHECK) -q --force --inline-suppr \
	  --template="{file},{line},{severity},{id},{message}" \
	  -UNOTYET -UNOTNOW -UNOTNEEDED -UDYING -UDEAD -UREFERENCE \
	  -U__cplusplus -U__LCLINT__ -USWIG \
	  -U_JLU3_SELFTEST \
	  -U _WIN64 \
	  -U __NeXT \
	  -DHAVE_CONFIG_H \
	  -DPOPT_fprintf=fprintf \
	  --enable=warning,style,performance,portability,information,unusedFunction,missingInclude \
	  $(AM_CPPFLAGS) -I$(includedir) \
	  $(libpopt_la_SOURCES) test1.c test2.c test3.c tdict.c

endif

if DOXYGEN_ENABLE
doxygen: Doxyfile
	rm -rf doxygen
	mkdir -p doxygen
	$(DOXYGEN)
endif 

# --- scan.coverity.com manual submission in $(PACKAGE).tgz
COVDIR =	cov-int
COVBUILD =	cov-build --dir $(COVDIR)
COVFILE =	$(PACKAGE)-scan.tgz
COVSITE =	https://scan.coverity.com/builds?project=$(PACKAGE_NAME)
covscan:
	rm -rf $(COVDIR) $(PACKAGE).tgz
	make clean
	$(COVBUILD) make -j4
	tar czf $(COVFILE) $(COVDIR)
	curl --form project=$(PACKAGE) \
	     --form token=HEYLAdeYklp2QrsRMaHVAw  \
	     --form email=n3npq@mac.com \
	     --form file=@$(COVFILE) \
	     --form version=$(PACKAGE_VERSION) \
	     --form description=$$(date -u "+%Y%m%d.%H%M%S") \
	     $(COVSITE)

if HAVE_LCOV
# run lcov from scratch, always
lcov-reset:
	make lcov-run
	make lcov-report

# run lcov from scratch if the dir is not there
lcov:
	make lcov-reset

# reset run coverage tests
lcov-run:
	@-rm -rf lcov
	find . -name "*.gcda" -exec rm {} \;
	make check

# generate report based on current coverage data
lcov-report:
	rm -rf lcov-result
	mkdir lcov-result
	$(LCOV) --directory . --capture --output-file lcov-result/lcov.info
	$(LCOV) -l lcov-result/lcov.info | grep -v "`cd $(top_srcdir) && pwd`" | cut -d: -f1 > lcov-result/remove
	$(LCOV) -r lcov-result/lcov.info `cat lcov-result/remove` > lcov-result/lcov.cleaned.info
	rm lcov-result/remove
	mv lcov-result/lcov.cleaned.info lcov-result/lcov.info
	genhtml -t "$(PACKAGE_STRING)" -o lcov lcov-result/lcov.info
endif

po_dir=./po
.PHONY:	updatepo
updatepo:
	rsync -Lrtvz  translationproject.org::tp/latest/popt/  po
	ls "$(po_dir)"/*.po 2>/dev/null | LANG=C sed 's|.*/||; s|\.po$$||' > "$(po_dir)/LINGUAS"

.PHONY:	sources
sources:
	@echo $(libpopt_la_SOURCES:%=popt/%)