Makefile.mk 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. # See usage in lib/Makefile.mk
  25. PROOT := ..
  26. ### Common
  27. include $(PROOT)/lib/Makefile.mk
  28. ### Local
  29. RCFLAGS += -DCURL_EMBED_MANIFEST
  30. CPPFLAGS += -I$(PROOT)/lib
  31. LDFLAGS += -L$(PROOT)/lib
  32. LIBS := -lcurl $(LIBS)
  33. ifdef WIN32
  34. ifneq ($(findstring -dyn,$(CFG)),)
  35. DYN := 1
  36. endif
  37. endif
  38. ifdef DYN
  39. curl_DEPENDENCIES := $(PROOT)/lib/libcurl$(CURL_DLL_SUFFIX).dll
  40. curl_DEPENDENCIES += $(PROOT)/lib/libcurl.dll.a
  41. else
  42. curl_DEPENDENCIES := $(PROOT)/lib/libcurl.a
  43. ifdef WIN32
  44. CPPFLAGS += -DCURL_STATICLIB
  45. LDFLAGS += -static
  46. endif
  47. endif
  48. ### Sources and targets
  49. # Provides CURL_CFILES, CURLX_CFILES, CURL_RCFILES
  50. include Makefile.inc
  51. TARGETS := curl$(BIN_EXT)
  52. CURL_CFILES += $(notdir $(CURLX_CFILES))
  53. curl_OBJECTS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(strip $(CURL_CFILES)))
  54. ifdef WIN32
  55. curl_OBJECTS += $(patsubst %.rc,$(OBJ_DIR)/%.res,$(strip $(CURL_RCFILES)))
  56. endif
  57. ifdef MAP
  58. CURL_MAP := curl.map
  59. CURL_LDFLAGS_BIN += -Wl,-Map,$(CURL_MAP)
  60. TOVCLEAN := $(CURL_MAP)
  61. endif
  62. vpath %.c $(PROOT)/lib
  63. TOCLEAN := $(curl_OBJECTS)
  64. ### Rules
  65. ifneq ($(wildcard tool_hugehelp.c.cvs),)
  66. PERL ?= perl
  67. NROFF ?= groff
  68. TOCLEAN += tool_hugehelp.c
  69. ifneq ($(shell $(call WHICH, $(NROFF))),)
  70. $(PROOT)/docs/curl.1: $(wildcard $(PROOT)/docs/cmdline-opts/*.d)
  71. cd $(PROOT)/docs/cmdline-opts && \
  72. $(PERL) gen.pl mainpage $(notdir $^) > ../curl.1
  73. # Necessary for the generated tools_hugehelp.c
  74. CPPFLAGS += -DUSE_MANUAL
  75. ifdef ZLIB
  76. _MKHELPOPT += -c
  77. endif
  78. tool_hugehelp.c: $(PROOT)/docs/curl.1 mkhelp.pl
  79. $(NROFF) -man -Tascii $(MANOPT) $< | \
  80. $(PERL) mkhelp.pl $(_MKHELPOPT) $< > $@
  81. else
  82. tool_hugehelp.c:
  83. @echo Creating $@
  84. @$(call COPY, $@.cvs, $@)
  85. endif
  86. endif
  87. $(TARGETS): $(curl_OBJECTS) $(curl_DEPENDENCIES)
  88. $(CC) $(LDFLAGS) $(CURL_LDFLAGS_BIN) -o $@ $(curl_OBJECTS) $(LIBS)
  89. all: $(OBJ_DIR) $(TARGETS)