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