1#***************************************************************************
2#                                  _   _ ____  _
3#  Project                     ___| | | |  _ \| |
4#                             / __| | | | |_) | |
5#                            | (__| |_| |  _ <| |___
6#                             \___|\___/|_| \_\_____|
7#
8# Copyright (C) 1998 - 2021, 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###########################################################################
22AUTOMAKE_OPTIONS = foreign nostdinc
23
24# remove targets if the command fails
25.DELETE_ON_ERROR:
26
27# Specify our include paths here, and do it relative to $(top_srcdir) and
28# $(top_builddir), to ensure that these paths which belong to the library
29# being currently built and tested are searched before the library which
30# might possibly already be installed in the system.
31#
32# $(top_srcdir)/include is for libcurl's external include files
33# $(top_builddir)/lib is for libcurl's generated lib/curl_config.h file
34# $(top_builddir)/src is for curl's generated src/curl_config.h file
35# $(top_srcdir)/lib for libcurl's lib/curl_setup.h and other "borrowed" files
36# $(top_srcdir)/src is for curl's src/tool_setup.h and "curl-private" files
37
38AM_CPPFLAGS = -I$(top_srcdir)/include        \
39              -I$(top_builddir)/lib          \
40              -I$(top_builddir)/src          \
41              -I$(top_srcdir)/lib            \
42              -I$(top_srcdir)/src
43
44bin_PROGRAMS = curl
45
46SUBDIRS = ../docs
47
48if USE_CPPFLAG_CURL_STATICLIB
49AM_CPPFLAGS += -DCURL_STATICLIB
50endif
51
52include Makefile.inc
53
54# CURL_FILES comes from Makefile.inc
55curl_SOURCES = $(CURL_FILES)
56
57# This might hold -Werror
58CFLAGS += @CURL_CFLAG_EXTRAS@
59
60# Prevent LIBS from being used for all link targets
61LIBS = $(BLANK_AT_MAKETIME)
62
63if USE_EXPLICIT_LIB_DEPS
64curl_LDADD = $(top_builddir)/lib/libcurl.la @LIBCURL_LIBS@
65else
66curl_LDADD = $(top_builddir)/lib/libcurl.la @NSS_LIBS@ @SSL_LIBS@ @ZLIB_LIBS@ @CURL_NETWORK_AND_TIME_LIBS@
67endif
68
69# if unit tests are enabled, build a static library to link them with
70if BUILD_UNITTESTS
71noinst_LTLIBRARIES = libcurltool.la
72libcurltool_la_CPPFLAGS = $(AM_CPPFLAGS) \
73                          -DCURL_STATICLIB -DUNITTESTS
74libcurltool_la_CFLAGS =
75libcurltool_la_LDFLAGS = -static $(LINKFLAGS)
76libcurltool_la_SOURCES = $(curl_SOURCES)
77endif
78
79CLEANFILES = tool_hugehelp.c
80# Use the C locale to ensure that only ASCII characters appear in the
81# embedded text.
82NROFF=env LC_ALL=C @NROFF@ @MANOPT@ # figured out by the configure script
83
84EXTRA_DIST = mkhelp.pl makefile.dj                                     \
85 Makefile.m32 macos/curl.mcp.xml.sit.hqx macos/MACINSTALL.TXT          \
86 macos/src/curl_GUSIConfig.cpp macos/src/macos_main.cpp makefile.amiga \
87 curl.rc Makefile.netware Makefile.inc CMakeLists.txt
88
89# Use absolute directory to disable VPATH
90MANPAGE=$(abs_top_builddir)/docs/curl.1
91MKHELP=$(top_srcdir)/src/mkhelp.pl
92HUGE=tool_hugehelp.c
93
94HUGECMD = $(HUGEIT_$(V))
95HUGEIT_0 = @echo "  HUGE    " $@;
96HUGEIT_1 =
97HUGEIT_ = $(HUGEIT_0)
98
99CHECKSRC = $(CS_$(V))
100CS_0 = @echo "  RUN     " $@;
101CS_1 =
102CS_ = $(CS_0)
103
104if USE_MANUAL
105# Here are the stuff to create a built-in manual
106
107$(MANPAGE):
108	cd $(top_builddir)/docs && $(MAKE)
109
110if HAVE_LIBZ
111# This generates the tool_hugehelp.c file in both uncompressed and
112# compressed formats.
113$(HUGE): $(MANPAGE) $(MKHELP)
114	$(HUGECMD) (echo '#include "tool_setup.h"' > $(HUGE);   \
115	echo '#ifndef HAVE_LIBZ' >> $(HUGE);                    \
116	$(NROFF) $(MANPAGE) | $(PERL) $(MKHELP) >> $(HUGE);     \
117	echo '#else' >> $(HUGE);                                \
118	$(NROFF) $(MANPAGE) | $(PERL) $(MKHELP) -c >> $(HUGE);  \
119	echo '#endif /* HAVE_LIBZ */' >> $(HUGE) )
120else # HAVE_LIBZ
121# This generates the tool_hugehelp.c file uncompressed only
122$(HUGE): $(MANPAGE) $(MKHELP)
123	$(HUGECMD)(echo '#include "tool_setup.h"' > $(HUGE);    \
124	$(NROFF) $(MANPAGE) | $(PERL) $(MKHELP) >> $(HUGE) )
125endif
126
127else # USE_MANUAL
128# built-in manual has been disabled, make a blank file
129$(HUGE):
130	$(HUGECMD)(echo "/* built-in manual is disabled, blank function */" > $(HUGE); \
131	echo '#include "tool_hugehelp.h"' >> $(HUGE); \
132	echo "void hugehelp(void) {}" >>$(HUGE) )
133endif
134
135# ignore tool_hugehelp.c since it is generated source code and it plays
136# by slightly different rules!
137checksrc:
138	$(CHECKSRC)(@PERL@ $(top_srcdir)/lib/checksrc.pl -D$(srcdir)        \
139	-W$(srcdir)/tool_hugehelp.c $(srcdir)/*.[ch])
140
141if CURLDEBUG
142# for debug builds, we scan the sources on all regular make invokes
143all-local: checksrc
144endif
145
146# disable the tests that are mostly causing false positives
147TIDYFLAGS=-checks=-clang-analyzer-security.insecureAPI.strcpy,-clang-analyzer-optin.performance.Padding,-clang-analyzer-valist.Uninitialized,-clang-analyzer-core.NonNullParamChecker,-clang-analyzer-core.NullDereference
148
149TIDY:=clang-tidy
150
151tidy:
152	$(TIDY) $(CURL_CFILES) $(TIDYFLAGS) -- $(curl_CPPFLAGS) $(CPPFLAGS) -DHAVE_CONFIG_H
153
154listhelp:
155	(cd $(top_srcdir)/docs/cmdline-opts && ./gen.pl listhelp *.d) > tool_listhelp.c
156