GNUmakefile 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. .NOTPARALLEL:
  2. MAX_THREADS ?= 16
  3. PROGRAM_NAME ?= bin/vlmcsd
  4. CLIENT_NAME ?= bin/vlmcs
  5. MULTI_NAME ?= bin/vlmcsdmulti
  6. OBJ_NAME ?= build/libkms-static.o
  7. A_NAME ?= lib/libkms.a
  8. BASE_PROGRAM_NAME=$(notdir $(PROGRAM_NAME))
  9. BASE_CLIENT_NAME=$(notdir $(CLIENT_NAME))
  10. BASE_MULTI_NAME=$(notdir $(MULTI_NAME))
  11. BASE_DLL_NAME=$(notdir $(DLL_NAME))
  12. BASE_A_NAME=$(notdir $(A_NAME))
  13. TARGETPLATFORM := $(shell LANG=en_US.UTF-8 $(CC) -v 2>&1 | grep '^Target: ' | cut -f 2 -d ' ')
  14. ifneq (,$(findstring darwin,$(TARGETPLATFORM)))
  15. DARWIN := 1
  16. UNIX := 1
  17. endif
  18. ifneq (,$(findstring android,$(TARGETPLATFORM)))
  19. ANDROID := 1
  20. UNIX := 1
  21. ELF := 1
  22. endif
  23. ifneq (,$(findstring minix,$(TARGETPLATFORM)))
  24. MINIX := 1
  25. UNIX := 1
  26. ELF := 1
  27. endif
  28. ifneq (,$(findstring mingw,$(TARGETPLATFORM)))
  29. MINGW := 1
  30. WIN := 1
  31. PE := 1
  32. endif
  33. ifneq (,$(findstring cygwin,$(TARGETPLATFORM)))
  34. CYGWIN := 1
  35. WIN := 1
  36. PE := 1
  37. endif
  38. ifneq (,$(findstring cygnus,$(TARGETPLATFORM)))
  39. CYGWIN := 1
  40. WIN := 1
  41. PE := 1
  42. endif
  43. ifneq (,$(findstring freebsd,$(TARGETPLATFORM)))
  44. FREEBSD := 1
  45. UNIX := 1
  46. BSD := 1
  47. ELF := 1
  48. endif
  49. ifneq (,$(findstring netbsd,$(TARGETPLATFORM)))
  50. NETBSD := 1
  51. UNIX := 1
  52. BSD := 1
  53. ELF := 1
  54. endif
  55. ifneq (,$(findstring openbsd,$(TARGETPLATFORM)))
  56. OPENBSD := 1
  57. UNIX := 1
  58. BSD := 1
  59. ELF := 1
  60. endif
  61. ifneq (,$(findstring solaris,$(TARGETPLATFORM)))
  62. SOLARIS := 1
  63. UNIX := 1
  64. ELF := 1
  65. endif
  66. ifneq (,$(findstring linux,$(TARGETPLATFORM)))
  67. LINUX := 1
  68. UNIX := 1
  69. ELF := 1
  70. endif
  71. ifneq (,$(findstring gnu,$(TARGETPLATFORM)))
  72. ifeq (,$(findstring linux,$(TARGETPLATFORM)))
  73. UNIX := 1
  74. HURD := 1
  75. ELF := 1
  76. endif
  77. endif
  78. ifeq ($(CYGWIN),1)
  79. DLL_NAME ?= lib/cygkms.dll
  80. else ifeq ($(WIN),1)
  81. DLL_NAME ?= lib/libkms.dll
  82. else ifeq ($(DARWIN),1)
  83. DLL_NAME ?= lib/libkms.dylib
  84. else
  85. DLL_NAME ?= lib/libkms.so
  86. endif
  87. .DEFAULT:
  88. +@(test -d bin || mkdir bin) & (test -d lib || mkdir lib) & (test -d build || mkdir build)
  89. +@$(MAKE) -j$(MAX_THREADS) -C src $@ FROM_PARENT=1 PROGRAM_NAME=$(PROGRAM_NAME) CLIENT_NAME=$(CLIENT_NAME) MULTI_NAME=$(MULTI_NAME) DLL_NAME=$(DLL_NAME) A_NAME=$(A_NAME)
  90. all:
  91. +@(test -d bin || mkdir bin) & (test -d lib || mkdir lib) & (test -d build || mkdir build)
  92. +@$(MAKE) -j$(MAX_THREADS) -C src $@ FROM_PARENT=1 PROGRAM_NAME=$(PROGRAM_NAME) CLIENT_NAME=$(CLIENT_NAME) MULTI_NAME=$(MULTI_NAME) DLL_NAME=$(DLL_NAME) A_NAME=$(A_NAME)
  93. clean:
  94. +@$(MAKE) -j$(MAX_THREADS) -C src $@ FROM_PARENT=1 PROGRAM_NAME=$(PROGRAM_NAME) CLIENT_NAME=$(CLIENT_NAME) MULTI_NAME=$(MULTI_NAME) DLL_NAME=$(DLL_NAME) A_NAME=$(A_NAME)
  95. +@$(MAKE) -j$(MAX_THREADS) -C man $@
  96. alldocs:
  97. +@$(MAKE) -j$(MAX_THREADS) -C man $@
  98. dosdocs:
  99. +@$(MAKE) -j$(MAX_THREADS) -C man $@
  100. unixdocs:
  101. +@$(MAKE) -j$(MAX_THREADS) -C man $@
  102. htmldocs:
  103. +@$(MAKE) -j$(MAX_THREADS) -C man $@
  104. pdfdocs:
  105. +@$(MAKE) -j$(MAX_THREADS) -C man $@
  106. GNUmakefile:
  107. help:
  108. @echo "Type"
  109. @echo " ${MAKE} - to build $(BASE_PROGRAM_NAME) and $(BASE_CLIENT_NAME)"
  110. @echo " ${MAKE} clean - to remove all targets and temporary files"
  111. @echo " ${MAKE} pdfdocs - Create PDF versions of the documentation (Requires groff with PDF support)."
  112. @echo " ${MAKE} htmldocs - Create HTML versions of the documentation."
  113. @echo " ${MAKE} unixdocs - Create Unix TXT versions of the documentation."
  114. @echo " ${MAKE} dosdocs - Create DOS/Windows TXT versions of the documentation."
  115. @echo " ${MAKE} alldocs - Create all versions of the documentation."
  116. @echo " ${MAKE} vlmcsd - to build KMS server $(PROGRAM_NAME)"
  117. @echo " ${MAKE} vlmcs - to build KMS client $(CLIENT_NAME)"
  118. @echo " ${MAKE} vlmcsdmulti - to build $(BASE_PROGRAM_NAME) and $(BASE_CLIENT_NAME) in a single multi-call binary $(MULTI_NAME)"
  119. @echo " ${MAKE} libkms - to build the shared library $(DLL_NAME)"
  120. @echo " ${MAKE} libkms-static - to build the static library $(A_NAME)"
  121. @echo ""
  122. @echo "Options"
  123. @echo " CONFIG=<x> Compile <x> as instead of config.h."
  124. @echo " INI=<x> Compile $(BASE_PROGRAM_NAME) with default ini file <x>"
  125. @echo " PROGRAM_NAME=<x> Use <x> as output file name for the KMS server. Defaults to vlmcsd."
  126. @echo " CLIENT_NAME=<x> Use <x> as output file name for the KMS client. Defaults to vlmcs."
  127. @echo " MULTI_NAME=<x> Use <x> as output file name for the multi-call binary. Defaults to vlmcsdmulti."
  128. @echo " DEPENDENCIES=1 Create dependency files."
  129. @echo " CRYPTO=openssl Use openssl for SHA256/HMAC calculations."
  130. @echo " CRYPTO=openssl_with_aes EXPERIMENTAL: Use openssl for SHA256/HMAC and AES calculations (hardware, e.g. AES-NI on x86)."
  131. @echo " CRYPTO=openssl_with_aes_soft EXPERIMENTAL: Use openssl for SHA256/HMAC and AES calculations (software)."
  132. @echo " CRYPTO=polarssl Use polarssl instead of internal crypto code for SHA256/HMAC calculations."
  133. @echo " CRYPTO=windows Use Windows CryptoAPI instead of internal crypto code for SHA256/HMAC calculations."
  134. @echo " MSRPC=1 Use Microsoft RPC instead of vlmcsd's internal RPC. Only works with Windows and Cygwin targets."
  135. @echo " CC=<x> Use compiler <x>. Supported compilers are gcc, icc, tcc and clang. Others may or may not work."
  136. @echo " AR=<x> Use <x> instead of ar to build $(BASE_A_NAME). Set to gcc-ar if you want to use gcc's LTO feature."
  137. @echo " COMPILER_LANGUAGE=<x> May be c or c++."
  138. @echo " TERMINAL_WIDTH=<x> Assume a fixed terminal width of <x> columns. Use in case of problems only."
  139. @echo " VLMCSD_VERSION=<x> Sets <x> as your version identifier. Defaults to \"private build\"."
  140. @echo " CFLAGS=<x> Pass <x> as additional arguments to the compiler."
  141. @echo " LDFLAGS=<x> Pass <x> as additional arguments to the linker."
  142. @echo " PLATFORMFLAGS=<x> Pass <x> as additional arguments to the compiler and the linker."
  143. @echo " BASECFLAGS=<x> Pass only <x> as arguments to the compiler (advanced users only)."
  144. @echo " BASELDFLAGS=<x> Pass only <x> as arguments to the linker (advanced users only)."
  145. @echo " STRIP=0 Don't strip debug information from $(BASE_PROGRAM_NAME) and $(BASE_CLIENT_NAME) (for developers)."
  146. @echo " VERBOSE=1 Be verbose when making targets."
  147. @echo " VERBOSE=3 Show name of compiler."
  148. @echo " THREADS=1 Use threads instead of fork(). Automatically set for native Windows. Recommended for Cygwin."
  149. @echo " WINDOWS=<x> Use <x> as the default ePID for Windows (when using $(BASE_PROGRAM_NAME) with -r 0)."
  150. @echo " OFFICE2010=<x> Use <x> as the default ePID for Office2010 (when using $(BASE_PROGRAM_NAME) with -r 0)."
  151. @echo " OFFICE2013=<x> Use <x> as the default ePID for Office2013 (when using $(BASE_PROGRAM_NAME) with -r 0)."
  152. @echo " OFFICE2016=<x> Use <x> as the default ePID for Office2016 (when using $(BASE_PROGRAM_NAME) with -r 0)."
  153. @echo " HWID=<x> Use <x> as the default HWID (when it can't be found in an ini file)."
  154. @echo " FEATURES=full Compile $(BASE_PROGRAM_NAME) with all features (default)."
  155. @echo " FEATURES=most Compile $(BASE_PROGRAM_NAME) without rarely used features."
  156. @echo " FEATURES=embedded Compile $(BASE_PROGRAM_NAME) with typical features for embedded systems."
  157. @echo " FEATURES=autostart Removes features typically not needed if you place $(BASE_PROGRAM_NAME) in an autostart script."
  158. @echo " FEATURES=inetd Compile $(BASE_PROGRAM_NAME) for running through an internet superserver only."
  159. @echo " FEATURES=minimum Compiles only basic features of $(BASE_PROGRAM_NAME)."
  160. @echo " FEATURES=fixedepids $(BASE_PROGRAM_NAME) only uses bultin internal ePIDs."
  161. @echo ""
  162. @echo "Useful CFLAGS to save memory when running $(BASE_PROGRAM_NAME) on very small embedded devices (finer control than FEATURES=)"
  163. @echo " -DNO_EXTENDED_PRODUCT_LIST Don't compile the detailed product list."
  164. @echo " -DNO_BASIC_PRODUCT_LIST Don't compile the basic product list."
  165. @echo " -DNO_STRICT_MODES Don't support enhanced emulator detection prevention."
  166. @echo " -DNO_CLIENT_LIST Don't support maintaining a client list (CMIDs)."
  167. @echo " -DNO_VERBOSE_LOG Don't support verbose logging. Removes -v option."
  168. @echo " -DNO_LOG Don't add support for logging. Implies -DNO_VERBOSE_LOG -DNO_EXTENDED_PRODUCT_LIST and -DNO_BASIC_PRODUCT_LIST."
  169. @echo " -DNO_RANDOM_EPID Don't support random ePIDs."
  170. @echo " -DNO_INI_FILE Don't support reading ePIDs/HWIDs from a file."
  171. @echo " -DNO_PID_FILE Don't support writing a PID file. Removes -p option."
  172. @echo " -DNO_USER_SWITCH Don't support changing uid/gid after program start. Removes -u and -g options."
  173. @echo " -DNO_HELP Don't support command line help."
  174. @echo " -DNO_CUSTOM_INTERVALS Don't support custom intervals for retry and refresh activation. Removes -A and -R options."
  175. @echo " -DNO_FREEBIND Don't support binding to foreign IP addresses. Removes -F0 and -F1 options. Only affects FreeBSD and Linux."
  176. @echo " -DNO_SOCKETS Don't support standalone operation. Requires an internet superserver to start $(BASE_PROGRAM_NAME)."
  177. @echo " -DSIMPLE_SOCKETS Don't support listening on explicit IP addresses. Always listens on all IP addresses."
  178. @echo " -DSIMPLE_RPC Don't support RPC with NDR64 and BTFN in $(BASE_PROGRAM_NAME) (but do in $(BASE_CLIENT_NAME)). Makes emulator detection easy."
  179. @echo " -DNO_CL_PIDS Don't support specifying ePIDs and HwId from the command line in $(BASE_PROGRAM_NAME)."
  180. @echo " -DNO_LIMIT Don't support limiting concurrent clients in $(BASE_PROGRAM_NAME)."
  181. @echo " -DNO_SIGHUP Don't support SIGHUP handling in $(BASE_PROGRAM_NAME)."
  182. @echo " -DNO_VERSION_INFORMATION Don't support displaying version information in $(BASE_PROGRAM_NAME) and $(BASE_CLIENT_NAME). Removes -V option."
  183. @echo " -DNO_PRIVATE_IP_DETECT Don't support protection against clients with public IP addresses in $(BASE_PROGRAM_NAME)"
  184. @echo " -DSIMPLE_SOCKETS Compile $(BASE_PROGRAM_NAME) with basic socket support only. Removes -L option."
  185. @echo " -DSMALL_AES Use a smaller (saves about 200 bytes) but slower implementation of AES."
  186. @echo ""
  187. @echo "Troubleshooting options"
  188. @echo " CAT=1 Combine all sources in a single in-memory file and compile directly to target."
  189. @echo " NOPROCFS=1 Don't rely on a properly mounted proc filesystem in /proc."
  190. @echo " AUXV=1 Use /proc/self/auxv (requires Linux with glibc >= 2.16 or musl.)"
  191. @echo " NOLPTHREAD=1 Disable detection if -lpthread is required (for use with Android NDK)."
  192. @echo " NOLRESOLV=1 Disable detection if -lresolv is required (for use with Android NDK)."
  193. @echo " NOLIBS=1 Do not attempt to autodetect any library dependencies."
  194. @echo " OPENSSL_HMAC=0 Compile for openssl versions that don't have HMAC support (required on some embedded devices)."
  195. @echo " NO_TIMEOUT=1 Do not set timeouts for sockets (for systems that don't support it)."
  196. @echo " CHILD_HANDLER=1 Install a handler for SIGCHLD (for systems that don't support SA_NOCLDWAIT)."
  197. @echo " NO_DNS=1 Compile $(BASE_CLIENT_NAME) without support for detecting KMS servers via DNS."
  198. @echo " NO_GETIFADDRS=1 Compile $(BASE_PROGRAM_NAME) without using getifaddrs()."
  199. @echo " GETIFADDRS=musl Compile $(BASE_PROGRAM_NAME) with its own implementation of getifaddrs() based on musl."
  200. @echo " DNS_PARSER=internal Use $(BASE_CLIENT_NAME) internal DNS parsing routines. No effect on MingW (native Windows)."
  201. @echo ""
  202. @echo "Other useful CFLAGS"
  203. @echo " -DSUPPORT_WINE Add code that the Windows version of $(BASE_PROGRAM_NAME) runs on Wine if MSRPC=1"
  204. @echo " -D_PEDANTIC Report rare error/warning conditions instead of silently ignoring them."
  205. @echo " -DINCLUDE_BETAS Include SKU / activation IDs for obsolete beta/preview products."
  206. @echo " -DFD_SETSIZE=<x> Allow <x> -L statements in $(BASE_PROGRAM_NAME) (default: 64 on Windows, 1024 on most Unixes)."