common.dj 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. #***************************************************************************
  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. ###########################################################################
  24. #
  25. # Common defines for curl (djgpp/Watt-32)
  26. #
  27. # Assumes you've unpacked curl with long-file names
  28. # I.e use "set LFN=y" before untaring on Win9x/XP.
  29. # Requires sed, rm and the usual stuff.
  30. #
  31. # Define TOPDIR before including this file.
  32. MAKEFILE = Makefile.dj
  33. OBJ_DIR = djgpp
  34. #
  35. # Find out if using a Unix-like shell or a DOS command interpreter
  36. #
  37. ifneq ($(findstring COMMAND.COM,$(SHELL)),COMMAND.COM)
  38. ifneq ($(findstring CMD.EXE,$(SHELL)),CMD.EXE)
  39. ifneq ($(findstring 4DOS.COM,$(SHELL)),4DOS.COM)
  40. IS_UNIX_SHELL = 1
  41. endif
  42. endif
  43. endif
  44. #
  45. # Define shell dependent commands and vars
  46. #
  47. ifeq ($(IS_UNIX_SHELL),1)
  48. COPY = cp -f
  49. DELETE = rm -f
  50. MKDIR = mkdir
  51. RMDIR = rm -f -r
  52. DS = /
  53. else
  54. COPY = copy
  55. DELETE = del
  56. MKDIR = mkdir
  57. RMDIR = rmdir
  58. DS = \$(NOTHING)
  59. endif
  60. ifeq ($(OS),Windows_NT)
  61. #
  62. # Windows hosted djgpp cross compiler. Get it from:
  63. # https://github.com/andrewwutw/build-djgpp/releases
  64. #
  65. DJ_PREFIX ?= c:/some-path/djgpp/bin/i586-pc-msdosdjgpp-
  66. CC = $(DJ_PREFIX)gcc
  67. else
  68. #
  69. # The normal djgpp 'gcc' for MSDOS.
  70. #
  71. CC = gcc
  72. endif
  73. #
  74. # OpenSSL is available from www.openssl.org and builds okay
  75. # with djgpp/Watt-32. Set to 0 if you don't need https URLs
  76. # (reduces curl.exe with approx 700 kB)
  77. #
  78. USE_OPENSSL ?= 0
  79. #
  80. # Use zlib for contents encoding. Needed for 'USE_OPENSSL=1' too.
  81. #
  82. USE_ZLIB ?= 0
  83. #
  84. # Use libidn for international domain names
  85. #
  86. USE_IDNA ?= 0
  87. #
  88. # Use Watt-32 IPv6 stack (only IPv6 name resolution working at the moment)
  89. #
  90. USE_IPV6 ?= 0
  91. #
  92. # Use C-Ares resolver library
  93. #
  94. USE_ARES ?= 0
  95. #
  96. # Enable debug code in libcurl/curl
  97. #
  98. USE_DEBUG ?= 0
  99. #
  100. # Enable memory tracking code in libcurl/curl
  101. #
  102. USE_CURLDEBUG ?= 0
  103. #
  104. # Generate a .map file in 'link_EXE' macro
  105. #
  106. MAKE_MAP_FILE ?= 0
  107. default: all
  108. #
  109. # Root directory for Waterloo tcp/ip etc. Change to suite.
  110. # WATT_ROOT should be set during Watt-32 install.
  111. #
  112. WATT32_ROOT = $(realpath $(WATT_ROOT))
  113. OPENSSL_ROOT ?= $(TOPDIR)/../crypto/OpenSSL
  114. ZLIB_ROOT ?= e:/djgpp/contrib/zlib
  115. LIBIDN_ROOT ?= $(TOPDIR)/../IDN/libidn
  116. ARES_ROOT ?= $(TOPDIR)/../DNS/c-ares
  117. CFLAGS = -g -O2 -I. -I$(TOPDIR)/include -I$(TOPDIR)/lib \
  118. -I$(WATT32_ROOT)/inc -Wall -DHAVE_CONFIG_H
  119. ifeq ($(USE_OPENSSL),1)
  120. CFLAGS += -DUSE_OPENSSL -I$(OPENSSL_ROOT)/include
  121. #
  122. # Squelch the warnings on deprecated functions.
  123. #
  124. CFLAGS += -DOPENSSL_SUPPRESS_DEPRECATED
  125. #
  126. # Use some of these too?
  127. #
  128. # CFLAGS += -DUSE_TLS_SRP=1 \
  129. # -DHAVE_ENGINE_LOAD_BUILTIN_ENGINES \
  130. # -DHAVE_SSLV2_CLIENT_METHOD \
  131. # -DOPENSSL_NO_DEPRECATED
  132. #
  133. # 'libcomm.a' is normally 'libcommon.a'. But to keep it 8+3 clean, it's
  134. # shortened to 'libcomm.a'. The official OpenSSL build was recently changed
  135. # and this "Common" library was added for several of the Crypto Providers.
  136. #
  137. OPENSSL_LIBS = $(OPENSSL_ROOT)/lib/libssl.a \
  138. $(OPENSSL_ROOT)/lib/libcrypt.a \
  139. $(OPENSSL_ROOT)/lib/libcomm.a
  140. endif
  141. ifeq ($(USE_ZLIB),1)
  142. CFLAGS += -DUSE_ZLIB -I$(ZLIB_ROOT)
  143. endif
  144. ifeq ($(USE_IPV6),1)
  145. CFLAGS += -DENABLE_IPV6
  146. endif
  147. ifeq ($(USE_ARES),1)
  148. CFLAGS += -DUSE_ARES -I$(ARES_ROOT)/include
  149. endif
  150. ifeq ($(USE_IDNA),1)
  151. CFLAGS += -DHAVE_LIBIDN -I$(LIBIDN_ROOT)/lib
  152. endif
  153. ifeq ($(USE_DEBUG),1)
  154. CFLAGS += -DDEBUG=1 -DDEBUGBUILD
  155. endif
  156. ifeq ($(USE_CURLDEBUG),1)
  157. CFLAGS += -DCURLDEBUG
  158. endif
  159. $(OBJ_DIR):
  160. $(MKDIR) $(OBJ_DIR)
  161. $(OBJ_DIR)/%.o: %.c
  162. $(CC) $(CFLAGS) -o $@ -c $<
  163. @echo
  164. #
  165. # Link-EXE macro:
  166. # $(1): the .exe
  167. # $(2): the .o-files and libraries
  168. #
  169. ifeq ($(MAKE_MAP_FILE),1)
  170. define link_EXE
  171. $(CC) -o $(1) $(LDFLAGS) -Wl,--print-map,--sort-common $(2) > $(1:.exe=.map)
  172. endef
  173. else
  174. define link_EXE
  175. $(CC) $(LDFLAGS) -o $(1) $(2)
  176. endef
  177. endif
  178. $(TOPDIR)/docs/curl.1: $(wildcard $(TOPDIR)/docs/cmdline-opts/*.d)
  179. cd $(TOPDIR)/docs/cmdline-opts; \
  180. perl gen.pl mainpage > ../$(TOPDIR)/docs/curl.1
  181. DEP_REPLACE = sed -e 's@\(.*\)\.o: @\n$$(OBJ_DIR)\/\1.o: @' \
  182. -e 's@$(ARES_ROOT)@$$(ARES_ROOT)@g' \
  183. -e 's@$(OPENSSL_ROOT)@$$(OPENSSL_ROOT)@g' \
  184. -e 's@$(WATT32_ROOT)@$$(WATT32_ROOT)@g' \
  185. -e 's@$(ZLIB_ROOT)@$$(ZLIB_ROOT)@g'
  186. #
  187. # One may have to do 'make -f Makefile.dj clean' first in case
  188. # a foreign 'curl_config.h' is making trouble.
  189. #
  190. depend: $(DEPEND_PREREQ) $(MAKEFILE)
  191. $(CC) -MM $(CFLAGS) $(CSOURCES) | $(DEP_REPLACE) > depend.dj