xref: /curl/src/Makefile.mk (revision ba8752e5)
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
48curl_OBJECTS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(strip $(CURL_CFILES)))
49ifdef MAP
50CURL_MAP := curl.map
51LDFLAGS += -Wl,-Map,$(CURL_MAP)
52TOVCLEAN := $(CURL_MAP)
53endif
54vpath %.c $(PROOT)/lib
55
56TOCLEAN := $(curl_OBJECTS)
57
58### Rules
59
60ifneq ($(wildcard tool_hugehelp.c.cvs),)
61PERL  ?= perl
62NROFF ?= groff
63
64TOCLEAN += tool_hugehelp.c
65
66ifneq ($(shell $(call WHICH, $(NROFF))),)
67$(PROOT)/docs/curl.1: $(wildcard $(PROOT)/docs/cmdline-opts/*.d)
68	cd $(PROOT)/docs/cmdline-opts && \
69	$(PERL) gen.pl mainpage $(notdir $^) > ../curl.1
70
71# Necessary for the generated tools_hugehelp.c
72CPPFLAGS += -DUSE_MANUAL
73
74ifdef ZLIB
75_MKHELPOPT += -c
76endif
77tool_hugehelp.c: $(PROOT)/docs/curl.1 mkhelp.pl
78	$(NROFF) -man -Tascii $(MANOPT) $< | \
79	$(PERL) mkhelp.pl $(_MKHELPOPT) $< > $@
80else
81tool_hugehelp.c:
82	@echo Creating $@
83	@$(call COPY, $@.cvs, $@)
84endif
85endif
86
87$(TARGETS): $(curl_OBJECTS) $(PROOT)/lib/libcurl.a
88	$(CC) $(LDFLAGS) -o $@ $(curl_OBJECTS) $(LIBS)
89
90all: $(OBJ_DIR) $(TARGETS)
91