common.dj 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2021, 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. ###########################################################################
  22. #
  23. # Common defines for curl (djgpp/Watt-32)
  24. #
  25. # Assumes you've unpacked curl with long-file names
  26. # I.e use "set LFN=y" before untaring on Win9x/XP.
  27. # Requires sed, rm and the usual stuff.
  28. #
  29. # Define TOPDIR before including this file.
  30. MAKEFILE = Makefile.dj
  31. OBJ_DIR = djgpp
  32. #
  33. # Find out if using a Unix-like shell or a DOS command interpreter
  34. #
  35. ifneq ($(findstring COMMAND.COM,$(SHELL)),COMMAND.COM)
  36. ifneq ($(findstring CMD.EXE,$(SHELL)),CMD.EXE)
  37. ifneq ($(findstring 4DOS.COM,$(SHELL)),4DOS.COM)
  38. IS_UNIX_SHELL = 1
  39. endif
  40. endif
  41. endif
  42. #
  43. # Define shell dependent commands and vars
  44. #
  45. ifeq ($(IS_UNIX_SHELL),1)
  46. COPY = cp -f
  47. DELETE = rm -f
  48. MKDIR = mkdir
  49. RMDIR = rm -f -r
  50. DS = /
  51. else
  52. COPY = copy
  53. DELETE = del
  54. MKDIR = mkdir
  55. RMDIR = rmdir
  56. DS = \$(NOTHING)
  57. endif
  58. ifeq ($(OS),Windows_NT)
  59. #
  60. # Windows hosted djgpp cross compiler. Get it from:
  61. # https://github.com/andrewwutw/build-djgpp/releases
  62. #
  63. DJ_PREFIX ?= c:/some-path/djgpp/bin/i586-pc-msdosdjgpp-
  64. CC = $(DJ_PREFIX)gcc
  65. else
  66. #
  67. # The normal djgpp 'gcc' for MSDOS.
  68. #
  69. CC = gcc
  70. endif
  71. #
  72. # OpenSSL is available from www.openssl.org and builds okay
  73. # with djgpp/Watt-32. Set to 0 if you don't need https URLs
  74. # (reduces curl.exe with approx 700 kB)
  75. #
  76. USE_OPENSSL ?= 0
  77. #
  78. # Use zlib for contents encoding. Needed for 'USE_OPENSSL=1' too.
  79. #
  80. USE_ZLIB ?= 0
  81. #
  82. # Use libidn for international domain names
  83. #
  84. USE_IDNA ?= 0
  85. #
  86. # Use Watt-32 IPv6 stack (only IPv6 name resolution working at the moment)
  87. #
  88. USE_IPV6 ?= 0
  89. #
  90. # Use C-Ares resolver library
  91. #
  92. USE_ARES ?= 0
  93. #
  94. # Enable debug code in libcurl/curl
  95. #
  96. USE_DEBUG ?= 0
  97. #
  98. # Enable memory tracking code in libcurl/curl
  99. #
  100. USE_CURLDEBUG ?= 0
  101. #
  102. # Generate a .map file in 'link_EXE' macro
  103. #
  104. MAKE_MAP_FILE ?= 0
  105. default: all
  106. #
  107. # Root directory for Waterloo tcp/ip etc. Change to suite.
  108. # WATT_ROOT should be set during Watt-32 install.
  109. #
  110. WATT32_ROOT = $(realpath $(WATT_ROOT))
  111. OPENSSL_ROOT ?= $(TOPDIR)/../crypto/OpenSSL
  112. ZLIB_ROOT ?= e:/djgpp/contrib/zlib
  113. LIBIDN_ROOT ?= $(TOPDIR)/../IDN/libidn
  114. ARES_ROOT ?= $(TOPDIR)/../DNS/c-ares
  115. CFLAGS = -g -O2 -I. -I$(TOPDIR)/include -I$(TOPDIR)/lib \
  116. -I$(WATT32_ROOT)/inc -Wall -DHAVE_CONFIG_H
  117. ifeq ($(USE_OPENSSL),1)
  118. CFLAGS += -DUSE_OPENSSL -I$(OPENSSL_ROOT)/include
  119. #
  120. # Squelch the warnings on deprecated functions.
  121. #
  122. CFLAGS += -DOPENSSL_SUPPRESS_DEPRECATED
  123. #
  124. # Use some of these too?
  125. #
  126. # CFLAGS += -DUSE_TLS_SRP=1 \
  127. # -DHAVE_ENGINE_LOAD_BUILTIN_ENGINES \
  128. # -DHAVE_OPENSSL_PKCS12_H \
  129. # -DHAVE_SSLV2_CLIENT_METHOD \
  130. # -DOPENSSL_NO_DEPRECATED
  131. #
  132. # 'libcomm.a' is normally 'libcommon.a'. But to keep it 8+3 clean, it's
  133. # shortened to 'libcomm.a'. The official OpenSSL build was recently changed
  134. # and this "Common" library was added for several of the Crypto Providers.
  135. #
  136. OPENSSL_LIBS = $(OPENSSL_ROOT)/lib/libssl.a \
  137. $(OPENSSL_ROOT)/lib/libcrypt.a \
  138. $(OPENSSL_ROOT)/lib/libcomm.a
  139. endif
  140. ifeq ($(USE_ZLIB),1)
  141. CFLAGS += -DUSE_ZLIB -I$(ZLIB_ROOT)
  142. endif
  143. ifeq ($(USE_IPV6),1)
  144. CFLAGS += -DENABLE_IPV6
  145. endif
  146. ifeq ($(USE_ARES),1)
  147. CFLAGS += -DUSE_ARES -I$(ARES_ROOT)/include
  148. endif
  149. ifeq ($(USE_IDNA),1)
  150. CFLAGS += -DHAVE_LIBIDN -DHAVE_IDN_FREE_H -DHAVE_IDN_FREE -DHAVE_TLD_H \
  151. -DHAVE_TLD_STRERROR -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