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