xref: /curl/lib/Makefile.am (revision 60c3d044)
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
26CMAKE_DIST = CMakeLists.txt curl_config.h.cmake
27
28CHECKSRC_DIST = .checksrc vauth/.checksrc vquic/.checksrc vssh/.checksrc \
29 vtls/.checksrc
30
31EXTRA_DIST = Makefile.mk config-win32.h config-win32ce.h config-plan9.h \
32 config-riscos.h config-mac.h curl_config.h.in config-dos.h libcurl.rc  \
33 config-amigaos.h config-win32ce.h config-os400.h setup-os400.h         \
34 $(CMAKE_DIST) setup-win32.h Makefile.soname optiontable.pl libcurl.def \
35 $(CHECKSRC_DIST)
36
37lib_LTLIBRARIES = libcurl.la
38
39if BUILD_UNITTESTS
40noinst_LTLIBRARIES = libcurlu.la
41else
42noinst_LTLIBRARIES =
43endif
44
45# This might hold -Werror
46CFLAGS += @CURL_CFLAG_EXTRAS@
47
48# Specify our include paths here, and do it relative to $(top_srcdir) and
49# $(top_builddir), to ensure that these paths which belong to the library
50# being currently built and tested are searched before the library which
51# might possibly already be installed in the system.
52#
53# $(top_srcdir)/include is for libcurl's external include files
54# $(top_builddir)/lib is for libcurl's generated lib/curl_config.h file
55# $(top_srcdir)/lib for libcurl's lib/curl_setup.h and other "private" files
56
57AM_CPPFLAGS = -I$(top_srcdir)/include        \
58              -I$(top_builddir)/lib          \
59              -I$(top_srcdir)/lib
60
61# Prevent LIBS from being used for all link targets
62LIBS = $(BLANK_AT_MAKETIME)
63
64include Makefile.soname
65
66AM_CPPFLAGS += -DBUILDING_LIBCURL
67AM_LDFLAGS =
68AM_CFLAGS =
69
70# Makefile.inc provides the CSOURCES and HHEADERS defines
71include Makefile.inc
72
73if USE_UNITY
74# Keep these separate to avoid duplicate definitions when linking libtests
75# in static mode.
76curl_EXCLUDE = curl_threads.c timediff.c warnless.c
77if DEBUGBUILD
78# We must compile these sources separately to avoid memdebug.h redefinitions
79# applying to them.
80curl_EXCLUDE += memdebug.c curl_multibyte.c
81endif
82libcurl_unity.c: $(top_srcdir)/scripts/mk-unity.pl $(CSOURCES)
83	@PERL@ $(top_srcdir)/scripts/mk-unity.pl $(srcdir) $(CSOURCES) --exclude $(curl_EXCLUDE) > libcurl_unity.c
84
85nodist_libcurl_la_SOURCES = libcurl_unity.c
86libcurl_la_SOURCES = $(curl_EXCLUDE)
87nodist_libcurlu_la_SOURCES = libcurl_unity.c
88libcurlu_la_SOURCES = $(curl_EXCLUDE)
89CLEANFILES = libcurl_unity.c
90else
91libcurl_la_SOURCES = $(CSOURCES) $(HHEADERS)
92libcurlu_la_SOURCES = $(CSOURCES) $(HHEADERS)
93endif
94
95libcurl_la_CPPFLAGS_EXTRA =
96libcurl_la_LDFLAGS_EXTRA =
97libcurl_la_CFLAGS_EXTRA =
98
99if CURL_LT_SHLIB_USE_VERSION_INFO
100libcurl_la_LDFLAGS_EXTRA += $(VERSIONINFO)
101endif
102
103if CURL_LT_SHLIB_USE_NO_UNDEFINED
104libcurl_la_LDFLAGS_EXTRA += -no-undefined
105endif
106
107if CURL_LT_SHLIB_USE_MIMPURE_TEXT
108libcurl_la_LDFLAGS_EXTRA += -mimpure-text
109endif
110
111if CURL_LT_SHLIB_USE_VERSIONED_SYMBOLS
112libcurl_la_LDFLAGS_EXTRA += -Wl,--version-script=libcurl.vers
113else
114# if symbol-hiding is enabled, hide them!
115if DOING_CURL_SYMBOL_HIDING
116libcurl_la_LDFLAGS_EXTRA += -export-symbols-regex '^curl_.*'
117endif
118endif
119
120if USE_CPPFLAG_CURL_STATICLIB
121libcurl_la_CPPFLAGS_EXTRA += -DCURL_STATICLIB
122else
123if HAVE_WINDRES
124libcurl_la_SOURCES += $(LIB_RCFILES)
125$(LIB_RCFILES): $(top_srcdir)/include/curl/curlver.h
126endif
127endif
128
129if DOING_CURL_SYMBOL_HIDING
130libcurl_la_CPPFLAGS_EXTRA += -DCURL_HIDDEN_SYMBOLS
131libcurl_la_CFLAGS_EXTRA += $(CFLAG_CURL_SYMBOL_HIDING)
132endif
133
134libcurl_la_CPPFLAGS = $(AM_CPPFLAGS) $(libcurl_la_CPPFLAGS_EXTRA)
135libcurl_la_LDFLAGS = $(AM_LDFLAGS) $(libcurl_la_LDFLAGS_EXTRA) $(CURL_LDFLAGS_LIB) $(LIBCURL_PC_LIBS_PRIVATE)
136libcurl_la_CFLAGS = $(AM_CFLAGS) $(libcurl_la_CFLAGS_EXTRA)
137
138libcurlu_la_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_STATICLIB -DUNITTESTS
139libcurlu_la_LDFLAGS = $(AM_LDFLAGS) -static $(LIBCURL_PC_LIBS_PRIVATE)
140libcurlu_la_CFLAGS = $(AM_CFLAGS)
141
142CHECKSRC = $(CS_$(V))
143CS_0 = @echo "  RUN     " $@;
144CS_1 =
145CS_ = $(CS_0)
146
147checksrc:
148	$(CHECKSRC)(@PERL@ $(top_srcdir)/scripts/checksrc.pl -D$(srcdir)    \
149	-W$(srcdir)/curl_config.h $(srcdir)/*.[ch] $(srcdir)/vauth/*.[ch]   \
150	$(srcdir)/vtls/*.[ch] $(srcdir)/vquic/*.[ch] $(srcdir)/vssh/*.[ch])
151
152if DEBUGBUILD
153# for debug builds, we scan the sources on all regular make invokes
154all-local: checksrc
155endif
156
157# disable the tests that are mostly causing false positives
158TIDYFLAGS=-checks=-clang-analyzer-security.insecureAPI.strcpy,-clang-analyzer-optin.performance.Padding,-clang-analyzer-valist.Uninitialized,-clang-analyzer-core.NonNullParamChecker,-clang-analyzer-core.NullDereference -quiet
159
160TIDY:=clang-tidy
161
162tidy:
163	$(TIDY) $(CSOURCES) $(TIDYFLAGS) -- $(AM_CPPFLAGS) $(CPPFLAGS) -DHAVE_CONFIG_H
164
165optiontable:
166	perl optiontable.pl < $(top_srcdir)/include/curl/curl.h > easyoptions.c
167
168if HAVE_WINDRES
169.rc.lo:
170	$(LIBTOOL) --tag=RC --mode=compile $(RC) -I$(top_srcdir)/include $(RCFLAGS) -i $< -o $@
171endif
172