xref: /curl/src/Makefile.am (revision 0aece8f6)
1#***************************************************************************
2#                                  _   _ ____  _
3#  Project                     ___| | | |  _ \| |
4#                             / __| | | | |_) | |
5#                            | (__| |_| |  _ <| |___
6#                             \___|\___/|_| \_\_____|
7#
8# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9#
10# This software is licensed as described in the file COPYING, which
11# you should have received as part of this distribution. The terms
12# are also available at https://curl.se/docs/copyright.html.
13#
14# You may opt to use, copy, modify, merge, publish, distribute and/or sell
15# copies of the Software, and permit persons to whom the Software is
16# furnished to do so, under the terms of the COPYING file.
17#
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
20#
21# SPDX-License-Identifier: curl
22#
23###########################################################################
24AUTOMAKE_OPTIONS = foreign nostdinc
25
26# remove targets if the command fails
27.DELETE_ON_ERROR:
28
29EXTRA_DIST = mk-file-embed.pl mkhelp.pl \
30 Makefile.mk curl.rc Makefile.inc CMakeLists.txt .checksrc
31
32# Specify our include paths here, and do it relative to $(top_srcdir) and
33# $(top_builddir), to ensure that these paths which belong to the library
34# being currently built and tested are searched before the library which
35# might possibly already be installed in the system.
36#
37# $(top_srcdir)/include is for libcurl's external include files
38# $(top_builddir)/lib is for libcurl's generated lib/curl_config.h file
39# $(top_builddir)/src is for curl's generated src/curl_config.h file
40# $(top_srcdir)/lib for libcurl's lib/curl_setup.h and other "borrowed" files
41# $(top_srcdir)/src is for curl's src/tool_setup.h and "curl-private" files
42
43AM_CPPFLAGS = -I$(top_srcdir)/include        \
44              -I$(top_builddir)/lib          \
45              -I$(top_builddir)/src          \
46              -I$(top_srcdir)/lib            \
47              -I$(top_srcdir)/src
48
49bin_PROGRAMS = curl
50
51if USE_CPPFLAG_CURL_STATICLIB
52AM_CPPFLAGS += -DCURL_STATICLIB
53endif
54AM_CPPFLAGS += -DBUILDING_CURL
55
56AM_LDFLAGS =
57if USE_UNICODE
58AM_LDFLAGS += -municode
59endif
60
61include Makefile.inc
62
63CLEANFILES =
64
65if USE_UNITY
66curl_EXCLUDE =
67if DEBUGBUILD
68# We must compile this source separately to avoid memdebug.h redefinitions
69# applying to them.
70curl_EXCLUDE += ../lib/curl_multibyte.c
71endif
72if USE_CPPFLAG_CURL_STATICLIB
73curl_CURLX = $(CURLTOOL_LIBCURL_CFILES)
74else
75curl_CURLX = $(CURLX_CFILES)
76endif
77curltool_unity.c: $(top_srcdir)/scripts/mk-unity.pl $(CURL_CFILES) $(curl_CURLX)
78	@PERL@  $(top_srcdir)/scripts/mk-unity.pl $(srcdir) $(CURL_CFILES) $(curl_CURLX) --exclude $(curl_EXCLUDE) > curltool_unity.c
79
80nodist_curl_SOURCES = curltool_unity.c
81curl_SOURCES = $(curl_EXCLUDE)
82CLEANFILES += curltool_unity.c
83else
84# CURL_FILES comes from Makefile.inc
85curl_SOURCES = $(CURL_FILES)
86endif
87if HAVE_WINDRES
88curl_SOURCES += $(CURL_RCFILES)
89$(CURL_RCFILES): tool_version.h
90endif
91
92curl_LDFLAGS = $(AM_LDFLAGS) $(CURL_LDFLAGS_BIN)
93
94# This might hold -Werror
95CFLAGS += @CURL_CFLAG_EXTRAS@
96
97# Prevent LIBS from being used for all link targets
98LIBS = $(BLANK_AT_MAKETIME)
99
100curl_LDADD = $(top_builddir)/lib/libcurl.la @LIBCURL_PC_LIBS_PRIVATE@
101
102# if unit tests are enabled, build a static library to link them with
103if BUILD_UNITTESTS
104noinst_LTLIBRARIES = libcurltool.la
105libcurltool_la_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_STATICLIB -DUNITTESTS
106libcurltool_la_CFLAGS =
107libcurltool_la_LDFLAGS = -static $(LINKFLAGS)
108if USE_UNITY
109libcurltool_unity.c: $(top_srcdir)/scripts/mk-unity.pl $(CURL_CFILES) $(CURLTOOL_LIBCURL_CFILES)
110	@PERL@ $(top_srcdir)/scripts/mk-unity.pl $(srcdir) $(CURL_CFILES) $(CURLTOOL_LIBCURL_CFILES) --exclude $(curl_EXCLUDE) > libcurltool_unity.c
111
112nodist_libcurltool_la_SOURCES = libcurltool_unity.c
113libcurltool_la_SOURCES = $(curl_EXCLUDE)
114CLEANFILES += libcurltool_unity.c
115else
116libcurltool_la_SOURCES = $(CURL_FILES)
117endif
118endif
119
120# Use absolute directory to disable VPATH
121ASCIIPAGE=$(top_builddir)/docs/cmdline-opts/curl.txt
122MKHELP=$(top_srcdir)/src/mkhelp.pl
123HUGE=tool_hugehelp.c
124
125HUGECMD = $(HUGEIT_$(V))
126HUGEIT_0 = @echo "  HUGE    " $@;
127HUGEIT_1 =
128HUGEIT_ = $(HUGEIT_0)
129
130if USE_MANUAL
131# Here are the stuff to create a built-in manual
132AM_CPPFLAGS += -DUSE_MANUAL
133
134$(ASCIIPAGE):
135	cd $(top_builddir)/docs && $(MAKE)
136
137if HAVE_LIBZ
138# This generates the tool_hugehelp.c file in both uncompressed and
139# compressed formats.
140$(HUGE): $(ASCIIPAGE) $(MKHELP)
141	$(HUGECMD) (echo '#include "tool_setup.h"' > $(HUGE);   \
142	echo '#ifndef HAVE_LIBZ' >> $(HUGE);                    \
143	$(PERL) $(MKHELP) < $(ASCIIPAGE) >> $(HUGE);     \
144	echo '#else' >> $(HUGE);                                \
145	$(PERL) $(MKHELP) -c < $(ASCIIPAGE) >> $(HUGE);  \
146	echo '#endif /* HAVE_LIBZ */' >> $(HUGE) )
147else # HAVE_LIBZ
148# This generates the tool_hugehelp.c file uncompressed only
149$(HUGE): $(ASCIIPAGE) $(MKHELP)
150	$(HUGECMD)(echo '#include "tool_setup.h"' > $(HUGE);    \
151	$(PERL) $(MKHELP) < $(ASCIIPAGE) >> $(HUGE) )
152endif
153
154else # USE_MANUAL
155# built-in manual has been disabled, make a blank file
156$(HUGE):
157	echo '#include "tool_hugehelp.h"' >> $(HUGE)
158endif
159
160CLEANFILES += $(HUGE)
161
162CA_EMBED_CSOURCE = tool_ca_embed.c
163CURL_CFILES += $(CA_EMBED_CSOURCE)
164CLEANFILES += $(CA_EMBED_CSOURCE)
165if CURL_CA_EMBED_SET
166AM_CPPFLAGS += -DCURL_CA_EMBED
167MK_FILE_EMBED = $(top_srcdir)/src/mk-file-embed.pl
168$(CA_EMBED_CSOURCE): $(MK_FILE_EMBED) $(CURL_CA_EMBED)
169	$(PERL) $(MK_FILE_EMBED) --var curl_ca_embed < $(CURL_CA_EMBED) > $(CA_EMBED_CSOURCE)
170else
171$(CA_EMBED_CSOURCE):
172	echo 'extern const void *curl_ca_embed; const void *curl_ca_embed;' > $(CA_EMBED_CSOURCE)
173endif
174
175CHECKSRC = $(CS_$(V))
176CS_0 = @echo "  RUN     " $@;
177CS_1 =
178CS_ = $(CS_0)
179
180# ignore generated C files since they play by slightly different rules!
181checksrc:
182	$(CHECKSRC)(@PERL@ $(top_srcdir)/scripts/checksrc.pl -D$(srcdir) \
183	  -W$(srcdir)/$(HUGE) \
184	  -W$(srcdir)/$(CA_EMBED_CSOURCE) \
185	  $(srcdir)/*.[ch])
186
187if DEBUGBUILD
188# for debug builds, we scan the sources on all regular make invokes
189all-local: checksrc
190endif
191
192# disable the tests that are mostly causing false positives
193TIDYFLAGS=-checks=-clang-analyzer-security.insecureAPI.strcpy,-clang-analyzer-optin.performance.Padding,-clang-analyzer-valist.Uninitialized,-clang-analyzer-core.NonNullParamChecker,-clang-analyzer-core.NullDereference
194
195TIDY:=clang-tidy
196
197tidy:
198	$(TIDY) $(CURL_CFILES) $(TIDYFLAGS) -- $(curl_CPPFLAGS) $(CPPFLAGS) -DHAVE_CONFIG_H
199
200listhelp:
201	(cd $(top_srcdir)/docs/cmdline-opts && make listhelp)
202
203if HAVE_WINDRES
204.rc.o:
205	$(RC) -I$(top_srcdir)/include -DCURL_EMBED_MANIFEST $(RCFLAGS) -i $< -o $@
206endif
207
208dist-hook:
209	rm -f $(distdir)/$(CA_EMBED_CSOURCE)
210