xref: /curl/src/Makefile.mk (revision f6955e42)
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#***************************************************************************
24
25# See usage in lib/Makefile.mk
26
27PROOT := ..
28
29### Common
30
31include $(PROOT)/lib/Makefile.mk
32
33### Local
34
35CPPFLAGS += -I$(PROOT)/lib
36LDFLAGS  += -L$(PROOT)/lib
37LIBS     := -lcurl $(LIBS)
38
39### Sources and targets
40
41# Provides CURL_CFILES, CURLX_CFILES
42include Makefile.inc
43
44TARGETS := curl$(BIN_EXT)
45
46CURL_CFILES += $(notdir $(CURLX_CFILES))
47
48ifneq ($(CURL_CA_EMBED),)
49CPPFLAGS += -DCURL_CA_EMBED
50CURL_CFILES += tool_ca_embed.c
51endif
52
53curl_OBJECTS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(strip $(CURL_CFILES)))
54ifdef MAP
55CURL_MAP := curl.map
56LDFLAGS += -Wl,-Map,$(CURL_MAP)
57TOVCLEAN := $(CURL_MAP)
58endif
59vpath %.c $(PROOT)/lib
60
61TOCLEAN := $(curl_OBJECTS)
62
63### Rules
64
65PERL ?= perl
66
67ifneq ($(wildcard tool_hugehelp.c.cvs),)
68TOCLEAN += tool_hugehelp.c
69# Load DPAGES
70include $(PROOT)/docs/cmdline-opts/Makefile.inc
71$(PROOT)/docs/cmdline-opts/curl.txt: $(addprefix $(PROOT)/docs/cmdline-opts/,$(DPAGES)) $(PROOT)/scripts/managen
72	cd $(PROOT)/docs/cmdline-opts && $(PERL) ../../scripts/managen ascii $(DPAGES) > curl.txt
73# Necessary for the generated tools_hugehelp.c
74CPPFLAGS += -DUSE_MANUAL
75ifdef ZLIB
76_MKHELPOPT += -c
77endif
78tool_hugehelp.c: $(PROOT)/docs/cmdline-opts/curl.txt mkhelp.pl
79	$(PERL) mkhelp.pl $(_MKHELPOPT) < $< > $@
80else
81tool_hugehelp.c:
82	@echo Creating $@
83	@$(call COPY, $@.cvs, $@)
84endif
85
86ifneq ($(CURL_CA_EMBED),)
87TOCLEAN += tool_ca_embed.c
88tool_ca_embed.c: mk-file-embed.pl
89	$(PERL) mk-file-embed.pl --var curl_ca_embed < $(CURL_CA_EMBED) > $@
90endif
91
92$(TARGETS): $(curl_OBJECTS) $(PROOT)/lib/libcurl.a
93	$(CC) $(LDFLAGS) -o $@ $(curl_OBJECTS) $(LIBS)
94
95all: $(OBJ_DIR) $(TARGETS)
96