GNUmakefile 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. ################################################################################
  2. .PHONY: clean
  3. PROGRAM_NAME ?= vlmcsd
  4. CLIENT_NAME ?= vlmcs
  5. MULTI_NAME ?= vlmcsdmulti
  6. OBJ_NAME ?= libkms-static.o
  7. A_NAME ?= libkms.a
  8. CONFIG ?= config.h
  9. COMPILER_LANGUAGE ?= c
  10. # crypto library to use for standard algos, could save ~1-2kb ;)
  11. # can be either 'openssl', 'polarssl' or anything other for internal impl
  12. CRYPTO ?= internal
  13. # use DNS_PARSER=internal if your OS doesn't supply the DNS parser routines
  14. DNS_PARSER ?= OS
  15. # You should supply your own version string here
  16. VLMCSD_VERSION ?= $(shell test -d .svn && echo svn`svnversion`)
  17. FEATURES ?= full
  18. VERBOSE ?= NO
  19. ################################################################################
  20. CC ?= gcc
  21. TARGETPLATFORM := $(shell LANG=en_US.UTF-8 $(CC) -v 2>&1 | grep '^Target: ' | cut -f 2 -d ' ')
  22. ifneq (,$(findstring darwin,$(TARGETPLATFORM)))
  23. DARWIN := 1
  24. UNIX := 1
  25. endif
  26. ifneq (,$(findstring android,$(TARGETPLATFORM)))
  27. ANDROID := 1
  28. UNIX := 1
  29. ELF := 1
  30. endif
  31. ifneq (,$(findstring minix,$(TARGETPLATFORM)))
  32. MINIX := 1
  33. UNIX := 1
  34. ELF := 1
  35. endif
  36. ifneq (,$(findstring mingw,$(TARGETPLATFORM)))
  37. MINGW := 1
  38. WIN := 1
  39. PE := 1
  40. endif
  41. ifneq (,$(findstring cygwin,$(TARGETPLATFORM)))
  42. CYGWIN := 1
  43. WIN := 1
  44. PE := 1
  45. endif
  46. ifneq (,$(findstring cygnus,$(TARGETPLATFORM)))
  47. CYGWIN := 1
  48. WIN := 1
  49. PE := 1
  50. endif
  51. ifneq (,$(findstring freebsd,$(TARGETPLATFORM)))
  52. FREEBSD := 1
  53. UNIX := 1
  54. BSD := 1
  55. ELF := 1
  56. endif
  57. ifneq (,$(findstring netbsd,$(TARGETPLATFORM)))
  58. NETBSD := 1
  59. UNIX := 1
  60. BSD := 1
  61. ELF := 1
  62. endif
  63. ifneq (,$(findstring openbsd,$(TARGETPLATFORM)))
  64. OPENBSD := 1
  65. UNIX := 1
  66. BSD := 1
  67. ELF := 1
  68. endif
  69. ifneq (,$(findstring solaris,$(TARGETPLATFORM)))
  70. SOLARIS := 1
  71. UNIX := 1
  72. ELF := 1
  73. endif
  74. ifneq (,$(findstring linux,$(TARGETPLATFORM)))
  75. LINUX := 1
  76. UNIX := 1
  77. ELF := 1
  78. endif
  79. ifneq (,$(findstring gnu,$(TARGETPLATFORM)))
  80. ifeq (,$(findstring linux,$(TARGETPLATFORM)))
  81. UNIX := 1
  82. HURD := 1
  83. ELF := 1
  84. endif
  85. endif
  86. ifeq ($(CYGWIN),1)
  87. DLL_NAME ?= cygkms.dll
  88. else ifeq ($(WIN),1)
  89. DLL_NAME ?= libkms.dll
  90. else ifeq ($(DARWIN),1)
  91. DLL_NAME ?= libkms.dylib
  92. else
  93. DLL_NAME ?= libkms.so
  94. endif
  95. BASECFLAGS = -DVLMCSD_COMPILER=\"$(notdir $(CC))\" -DVLMCSD_PLATFORM=\"$(TARGETPLATFORM)\" -DCONFIG=\"$(CONFIG)\" -DBUILD_TIME=$(shell date '+%s') -g -Os -fno-strict-aliasing -fomit-frame-pointer -ffunction-sections -fdata-sections
  96. BASELDFLAGS =
  97. STRIPFLAGS =
  98. CLIENTLDFLAGS =
  99. SERVERLDFLAGS =
  100. ifndef SAFE_MODE
  101. BASECFLAGS += -fvisibility=hidden -pipe -fno-common -fno-exceptions -fno-stack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fmerge-all-constants
  102. ifeq ($(ELF),1)
  103. BASELDFLAGS += -Wl,-z,norelro
  104. endif
  105. ifneq (,$(findstring gcc,$(notdir $(CC))))
  106. BASECFLAGS += -flto
  107. endif
  108. endif
  109. ifeq ($(NOLIBS),1)
  110. NOLRESOLV=1
  111. NOLPTHREAD=1
  112. endif
  113. ifneq ($(NOLIBS),1)
  114. ifeq ($(MINGW),1)
  115. BASELDFLAGS += -lws2_32 -liphlpapi
  116. endif
  117. endif
  118. ifneq ($(NO_DNS),1)
  119. ifneq ($(ANDROID),1)
  120. ifneq ($(NOLRESOLV),1)
  121. ifeq ($(MINGW),1)
  122. CLIENTLDFLAGS += -ldnsapi
  123. endif
  124. ifeq ($(LINUX),1)
  125. CLIENTLDFLAGS += -lresolv
  126. endif
  127. ifeq ($(HURD),1)
  128. CLIENTLDFLAGS += -lresolv
  129. endif
  130. ifeq ($(DARWIN),1)
  131. CLIENTLDFLAGS += -lresolv
  132. endif
  133. ifeq ($(CYGWIN),1)
  134. DNS_PARSER := internal
  135. CLIENTLDFLAGS += -lresolv
  136. endif
  137. ifeq ($(OPENBSD),1)
  138. DNS_PARSER := internal
  139. endif
  140. ifeq ($(SOLARIS),1)
  141. CLIENTLDFLAGS += -lresolv
  142. endif
  143. endif
  144. endif
  145. else
  146. BASECFLAGS += -DNO_DNS
  147. endif
  148. ifneq ($(CAT),2)
  149. BASECFLAGS += "-Wall"
  150. endif
  151. ifeq ($(DARWIN), 1)
  152. STRIPFLAGS += -Wl,-S -Wl,-x
  153. BASECFLAGS += -Wno-deprecated-declarations
  154. else ifeq ($(shell uname), SunOS)
  155. STRIPFLAGS += -s
  156. ifeq ($(notdir $(LD_ALTEXEC)),gld)
  157. BASELDFLAGS += -Wl,--gc-sections
  158. endif
  159. BASELDFLAGS += -lsocket
  160. else
  161. ifneq ($(CC),tcc)
  162. BASELDFLAGS += -Wl,--gc-sections
  163. endif
  164. STRIPFLAGS += -s
  165. endif
  166. LIBRARY_CFLAGS = -DSIMPLE_SOCKETS -DNO_TIMEOUT -DNO_SIGHUP -DNO_CL_PIDS -DNO_EXTENDED_PRODUCT_LIST -DNO_BASIC_PRODUCT_LIST -DNO_LOG -DNO_RANDOM_EPID -DNO_INI_FILE -DNO_INI_FILE -DNO_HELP -DNO_CUSTOM_INTERVALS -DNO_PID_FILE -DNO_USER_SWITCH -DNO_VERBOSE_LOG -DNO_LIMIT -DNO_VERSION_INFORMATION -DNO_PRIVATE_IP_DETECT
  167. ifeq ($(FEATURES), embedded)
  168. BASECFLAGS += -DNO_HELP -DNO_USER_SWITCH -DNO_BASIC_PRODUCT_LIST -DNO_CUSTOM_INTERVALS -DNO_PID_FILE -DNO_VERBOSE_LOG -DNO_VERSION_INFORMATION
  169. else ifeq ($(FEATURES), autostart)
  170. BASECFLAGS += -DNO_HELP -DNO_VERSION_INFORMATION
  171. else ifeq ($(FEATURES), minimum)
  172. BASECFLAGS += $(LIBRARY_CFLAGS)
  173. else ifeq ($(FEATURES), most)
  174. BASECFLAGS += -DNO_SIGHUP -DNO_PID_FILE -DNO_LIMIT
  175. else ifeq ($(FEATURES), inetd)
  176. BASECFLAGS += -DNO_SIGHUP -DNO_SOCKETS -DNO_PID_FILE -DNO_LIMIT -DNO_VERSION_INFORMATION
  177. else ifeq ($(FEATURES), fixedepids)
  178. BASECFLAGS += -DNO_SIGHUP -DNO_CL_PIDS -DNO_RANDOM_EPID -DNO_INI_FILE
  179. endif
  180. ifdef INI
  181. BASECFLAGS += -DINI_FILE=\"$(INI)\"
  182. endif
  183. ifeq ($(NO_GETIFADDRS), 1)
  184. BASECFLAGS += -DNO_GETIFADDRS
  185. endif
  186. ifeq ($(THREADS), 1)
  187. BASECFLAGS += -DUSE_THREADS
  188. endif
  189. ifeq ($(CHILD_HANDLER), 1)
  190. BASECFLAGS += -DCHILD_HANDLER
  191. endif
  192. ifeq ($(NO_TIMEOUT), 1)
  193. BASECFLAGS += -DNO_TIMEOUT
  194. endif
  195. ifdef WINDOWS
  196. BASECFLAGS += -DEPID_WINDOWS=\"$(WINDOWS)\"
  197. endif
  198. ifdef OFFICE2010
  199. BASECFLAGS += -DEPID_OFFICE2010=\"$(OFFICE2010)\"
  200. endif
  201. ifdef OFFICE2013
  202. BASECFLAGS += -DEPID_OFFICE2013=\"$(OFFICE2013)\"
  203. endif
  204. ifdef HWID
  205. BASECFLAGS += -DHWID=$(HWID)
  206. endif
  207. ifdef TERMINAL_WIDTH
  208. BASECFLAGS += -DTERMINAL_FIXED_WIDTH=$(TERMINAL_WIDTH) -DDISPLAY_WIDTH=\"$(TERMINAL_WIDTH)\"
  209. endif
  210. ifeq ($(NOPROCFS), 1)
  211. BASECFLAGS += -DNO_PROCFS
  212. endif
  213. ifeq ($(AUXV), 1)
  214. BASECFLAGS += -DUSE_AUXV
  215. endif
  216. ifneq ($(ANDROID), 1)
  217. ifneq ($(MINIX), 1)
  218. ifneq ($(NOLPTHREAD), 1)
  219. ifeq ($(THREADS), 1)
  220. SERVERLDFLAGS += -lpthread
  221. endif
  222. ifeq (,$(findstring NO_LIMIT,$(CFLAGS) $(BASECFLAGS)))
  223. SERVERLDFLAGS += -lpthread
  224. endif
  225. endif
  226. endif
  227. endif
  228. $(MULTI_NAME): BASECFLAGS += -DMULTI_CALL_BINARY=1
  229. all: $(CLIENT_NAME) $(PROGRAM_NAME)
  230. #ifdef CAT
  231. allmulti: $(CLIENT_NAME) $(PROGRAM_NAME) $(MULTI_NAME)
  232. #endif
  233. ifneq ($(strip $(VLMCSD_VERSION)),)
  234. BASECFLAGS += -DVERSION=\"$(VLMCSD_VERSION),\ built\ $(shell date -u '+%Y-%m-%d %H:%M:%S' | sed -e 's/ /\\ /g')\ UTC\"
  235. endif
  236. ifdef CAT
  237. BASECFLAGS += -DONE_FILE
  238. endif
  239. SRCS = crypto.c kms.c endian.c output.c shared_globals.c helpers.c
  240. HEADERS = $(CONFIG) types.h rpc.h vlmcsd.h endian.h crypto.h kms.h network.h output.h shared_globals.h vlmcs.h helpers.h
  241. DEPS = $(MULTI_SRCS:.c=.d)
  242. VLMCSD_SRCS = vlmcsd.c $(SRCS)
  243. VLMCSD_OBJS = $(VLMCSD_SRCS:.c=.o)
  244. VLMCS_SRCS = vlmcs.c $(SRCS)
  245. VLMCS_OBJS = $(VLMCS_SRCS:.c=.o)
  246. MULTI_SRCS = vlmcsd.c vlmcs.c vlmcsdmulti.c $(SRCS)
  247. MULTI_OBJS = $(SRCS:.c=.o) vlmcsd-m.o vlmcs-m.o vlmcsdmulti-m.o
  248. DLL_SRCS = libkms.c vlmcs.c $(SRCS)
  249. DLL_OBJS = $(DLL_SRCS:.c=-l.o)
  250. PDFDOCS = vlmcs.1.pdf vlmcsd.7.pdf vlmcsd.8.pdf vlmcsdmulti.1.pdf vlmcsd.ini.5.pdf vlmcsd-floppy.7.pdf
  251. HTMLDOCS = $(PDFDOCS:.pdf=.html)
  252. UNIXDOCS = $(PDFDOCS:.pdf=.unix.txt)
  253. DOSDOCS = $(PDFDOCS:.pdf=.dos.txt)
  254. ifneq ($(NO_DNS),1)
  255. VLMCS_SRCS += dns_srv.c
  256. MULTI_SRCS += dns_srv.c
  257. MULTI_OBJS += dns_srv.o
  258. ifeq ($(DNS_PARSER),internal)
  259. ifneq ($(MINGW),1)
  260. VLMCS_SRCS += ns_parse.c ns_name.c
  261. MULTI_SRCS += ns_parse.c ns_name.c
  262. MULTI_OBJS += ns_parse.o ns_name.o
  263. BASECFLAGS += "-DDNS_PARSER_INTERNAL"
  264. endif
  265. endif
  266. endif
  267. ifeq ($(MSRPC),1)
  268. VLMCSD_SRCS += msrpc-server.c
  269. VLMCS_SRCS += msrpc-client.c
  270. MULTI_SRCS += msrpc-server.c msrpc-client.c
  271. MULTI_OBJS += msrpc-server-m.o msrpc-client-m.o
  272. DLL_SRCS += msrpc-server.c
  273. BASECFLAGS += -DUSE_MSRPC -Wno-unknown-pragmas
  274. BASELDFLAGS += -lrpcrt4
  275. else
  276. SRCS += network.c rpc.c
  277. endif
  278. ifeq ($(GETIFADDRS),musl)
  279. ifneq ($(NO_GETIFADDRS),1)
  280. BASECFLAGS += -DGETIFADDRS_MUSL
  281. VLMCSD_SRCS += getifaddrs-musl.c
  282. MULTI_SRCS += getifaddrs-musl.c
  283. VLMCS_SRCS += getifaddrs-musl.c
  284. DLL_SRCS += getifaddrs-musl.c
  285. MULTI_OBJS += getifaddrs-musl.o
  286. endif
  287. endif
  288. ifeq ($(ANDROID),1)
  289. ifneq ($(NO_GETIFADDRS),1)
  290. VLMCSD_SRCS += ifaddrs-android.c
  291. MULTI_SRCS += ifaddrs-android.c
  292. DLL_SRCS += ifaddrs-android.c
  293. MULTI_OBJS += ifaddrs-android.o
  294. endif
  295. endif
  296. ifeq "$(WIN)" "1"
  297. VLMCSD_SRCS += ntservice.c
  298. MULTI_SRCS += ntservice.c
  299. MULTI_OBJS += ntservice.o
  300. endif
  301. ifeq ($(CRYPTO), openssl_with_aes)
  302. BASECFLAGS += -D_CRYPTO_OPENSSL -D_USE_AES_FROM_OPENSSL
  303. BASELDFLAGS += -lcrypto
  304. SRCS += crypto_openssl.c
  305. else ifeq ($(CRYPTO), openssl_with_aes_soft)
  306. BASECFLAGS += -D_CRYPTO_OPENSSL -D_USE_AES_FROM_OPENSSL -D_OPENSSL_SOFTWARE
  307. BASELDFLAGS += -lcrypto
  308. SRCS += crypto_openssl.c
  309. else ifeq ($(CRYPTO), openssl)
  310. BASECFLAGS += -D_CRYPTO_OPENSSL
  311. BASELDFLAGS += -lcrypto
  312. SRCS += crypto_openssl.c
  313. else ifeq ($(CRYPTO), polarssl)
  314. BASECFLAGS += -D_CRYPTO_POLARSSL
  315. BASELDFLAGS += -lpolarssl
  316. else ifeq ($(CRYPTO), windows)
  317. BASECFLAGS += -D_CRYPTO_WINDOWS
  318. SRCS += crypto_windows.c
  319. else
  320. BASECFLAGS += -D_CRYPTO_INTERNAL
  321. SRCS += crypto_internal.c
  322. endif
  323. ifneq ($(STRIP),0)
  324. BASELDFLAGS += $(STRIPFLAGS)
  325. endif
  326. ifeq ($(OPENSSL_HMAC),0)
  327. BASECFLAGS += -D_OPENSSL_NO_HMAC
  328. endif
  329. ifeq ($(DEPENDENCIES),2)
  330. BASECFLAGS += -MMD
  331. endif
  332. ifeq ($(VERBOSE),3)
  333. COMPILER := $(shell printf "%-40s" $(notdir $(CC)))
  334. ARCHIVER := $(shell printf "%-40s" $(notdir $(AR)))
  335. endif
  336. ARCMD := AR
  337. ifdef CAT
  338. LDCMD := CC/LD
  339. else
  340. LDCMD := LD
  341. endif
  342. -include $(MULTI_SRCS:.c=.d)
  343. %.o: %.c
  344. ifeq ($(VERBOSE),1)
  345. $(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -c $<
  346. ifeq ($(DEPENDENCIES),1)
  347. $(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -MM -MF $*.d $<
  348. endif
  349. else
  350. @echo "$(COMPILER) CC $@ <- $<"
  351. @$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -c $<
  352. ifeq ($(DEPENDENCIES),1)
  353. @echo "$(COMPILER) DEP $*.d <- $<"
  354. @$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -MM -MF $*.d $<
  355. endif
  356. endif
  357. %-m.o: %.c
  358. ifeq ($(VERBOSE),1)
  359. $(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -o $@ -c $<
  360. ifeq ($(DEPENDENCIES),1)
  361. $(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -MM -MF $*.d $<
  362. endif
  363. else
  364. @echo "$(COMPILER) CC $@ <- $<"
  365. @$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -o $@ -c $<
  366. ifeq ($(DEPENDENCIES),1)
  367. @echo "$(COMPILER) DEP $*.d <- $<"
  368. @$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -MM -MF $*.d $<
  369. endif
  370. endif
  371. %-l.o: %.c
  372. ifeq ($(VERBOSE),1)
  373. $(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -fvisibility=hidden -c -DIS_LIBRARY=1 $(LIBRARY_CFLAGS) -UNO_SOCKETS -UUSE_MSRPC -o $@ -c $<
  374. ifeq ($(DEPENDENCIES),1)
  375. $(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) $(SERVERLDFLAGS) -fvisibility=hidden -c -DIS_LIBRARY=1 $(LIBRARY_CFLAGS) -UNO_SOCKETS -UUSE_MSRPC -MM -MF $*.d $<
  376. endif
  377. else
  378. @echo "$(COMPILER) CC $@ <- $<"
  379. @$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) $(SERVERLDFLAGS) -fvisibility=hidden -c -DIS_LIBRARY=1 $(LIBRARY_CFLAGS) -UNO_SOCKETS -UUSE_MSRPC -o $@ -c $<
  380. ifeq ($(DEPENDENCIES),1)
  381. @echo "$(COMPILER) DEP $*.d <- $<"
  382. @$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) $(SERVERLDFLAGS) -fvisibility=hidden -c -DIS_LIBRARY=1 $(LIBRARY_CFLAGS) -UNO_SOCKETS -UUSE_MSRPC -MM -MF $*.d $<
  383. endif
  384. endif
  385. ifdef CAT
  386. BUILDCOMMAND = cat $^ | $(CC) -x$(COMPILER_LANGUAGE) -o $@ -
  387. VLMCSD_PREREQUISITES = $(VLMCSD_SRCS)
  388. VLMCS_PREREQUISITES = $(VLMCS_SRCS)
  389. MULTI_PREREQUISITES = $(MULTI_SRCS)
  390. DLL_PREREQUISITES = $(DLL_SRCS)
  391. OBJ_PREREQUISITES = $(DLL_SRCS)
  392. else
  393. BUILDCOMMAND = $(CC) -o $@ $^
  394. VLMCSD_PREREQUISITES = $(VLMCSD_OBJS)
  395. VLMCS_PREREQUISITES = $(VLMCS_OBJS)
  396. MULTI_PREREQUISITES = $(MULTI_OBJS)
  397. DLL_PREREQUISITES = $(DLL_OBJS)
  398. OBJ_PREREQUISITES = $(DLL_OBJS)
  399. endif
  400. ifeq ($(VERBOSE),1)
  401. BUILDCOMMANDPREFIX = +
  402. else
  403. BUILDCOMMANDPREFIX = +@
  404. endif
  405. INFOCOMMAND = +@echo "$(COMPILER) $(LDCMD) $@ <- $^"
  406. ARINFOCOMMAND = +@echo "$(ARCHIVER) $(ARCMD) $@ <. $^"
  407. VLMCSD_COMMAND = $(BUILDCOMMANDPREFIX)$(BUILDCOMMAND) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(BASELDFLAGS) $(LDFLAGS) $(SERVERLDFLAGS)
  408. VLMCS_COMMAND = $(BUILDCOMMANDPREFIX)$(BUILDCOMMAND) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(BASELDFLAGS) $(LDFLAGS) $(CLIENTLDFLAGS)
  409. MULTI_COMMAND = $(BUILDCOMMANDPREFIX)$(BUILDCOMMAND) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(BASELDFLAGS) $(LDFLAGS) $(CLIENTLDFLAGS) $(SERVERLDFLAGS)
  410. DLL_COMMAND = $(BUILDCOMMANDPREFIX)$(BUILDCOMMAND) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(BASELDFLAGS) $(LDFLAGS) $(SERVERLDFLAGS) -fvisibility=hidden -shared -DIS_LIBRARY=1 $(LIBRARY_CFLAGS) -UNO_SOCKETS -UUSE_MSRPC
  411. OBJ_COMMAND = $(BUILDCOMMANDPREFIX)$(BUILDCOMMAND) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(BASELDFLAGS) $(LDFLAGS) $(SERVERLDFLAGS) -fvisibility=hidden -c -DIS_LIBRARY=1 $(LIBRARY_CFLAGS) -UNO_SOCKETS -UUSE_MSRPC
  412. $(PROGRAM_NAME): $(VLMCSD_PREREQUISITES)
  413. ifneq ($(VERBOSE),1)
  414. $(INFOCOMMAND)
  415. endif
  416. $(VLMCSD_COMMAND)
  417. $(CLIENT_NAME): $(VLMCS_PREREQUISITES)
  418. ifneq ($(VERBOSE),1)
  419. $(INFOCOMMAND)
  420. endif
  421. $(VLMCS_COMMAND)
  422. $(MULTI_NAME): $(MULTI_PREREQUISITES)
  423. ifneq ($(VERBOSE),1)
  424. $(INFOCOMMAND)
  425. endif
  426. $(MULTI_COMMAND)
  427. $(DLL_NAME): $(DLL_PREREQUISITES)
  428. ifneq ($(VERBOSE),1)
  429. $(INFOCOMMAND)
  430. endif
  431. $(DLL_COMMAND)
  432. ifndef CAT
  433. $(OBJ_NAME):
  434. +@echo Cannot make $@ without CAT defined. Please create $(A_NAME)
  435. else
  436. $(OBJ_NAME): $(OBJ_PREREQUISITES)
  437. ifneq ($(VERBOSE),1)
  438. $(INFOCOMMAND)
  439. endif
  440. $(OBJ_COMMAND)
  441. endif
  442. ifdef CAT
  443. $(A_NAME): $(OBJ_NAME)
  444. else
  445. $(A_NAME): BASECFLAGS += -fvisibility=hidden -DIS_LIBRARY=1 $(LIBRARY_CFLAGS) -UNO_SOCKETS -UUSE_MSRPC
  446. $(A_NAME): $(DLL_OBJS)
  447. endif
  448. ifneq ($(VERBOSE),1)
  449. $(ARINFOCOMMAND)
  450. endif
  451. +@rm -f $@
  452. $(BUILDCOMMANDPREFIX)$(AR) rcs $@ $^
  453. %.pdf : %
  454. ifeq ($(shell uname), Darwin)
  455. groff -Tps -mandoc -c $< | pstopdf -i -o $@
  456. else
  457. groff -Tpdf -mandoc -c $< > $@
  458. endif
  459. %.html : %
  460. groff -Thtml -mandoc -c $< > $@
  461. %.unix.txt : %
  462. groff -P -c -Tutf8 -mandoc -c $< | col -bx > $@
  463. %.dos.txt : %.unix.txt
  464. # unix2dos -n $< $@
  465. # sed -e 's/$$/\r/' $< > $@
  466. awk 'sub("$$", "\r")' $< > $@
  467. pdfdocs : $(PDFDOCS)
  468. dosdocs : $(DOSDOCS)
  469. unixdocs : $(UNIXDOCS)
  470. htmldocs : $(HTMLDOCS)
  471. alldocs : $(UNIXDOCS) $(HTMLDOCS) $(PDFDOCS) $(DOSDOCS)
  472. clean:
  473. rm -f *.o *.d *_all.c libkms_all_*.c $(PROGRAM_NAME) $(MULTI_NAME) $(DLL_NAME) $(CLIENT_NAME) $(PDFDOCS) $(DOSDOCS) $(UNIXDOCS) $(HTMLDOCS) $(OBJ_NAME) $(A_NAME) *.a
  474. dnsclean:
  475. rm -f dns_srv.o
  476. help:
  477. @echo "Type"
  478. @echo " ${MAKE} - to build $(PROGRAM_NAME) and $(CLIENT_NAME)"
  479. @echo " ${MAKE} clean - to remove $(PROGRAM_NAME) and $(CLIENT_NAME)"
  480. @echo " ${MAKE} help - to see this help"
  481. @echo " ${MAKE} pdfdocs - Create PDF versions of the documentation (Requires groff with PDF support)."
  482. @echo " ${MAKE} htmldocs - Create HTML versions of the documentation."
  483. @echo " ${MAKE} unixdocs - Create Unix TXT versions of the documentation."
  484. @echo " ${MAKE} dosdocs - Create DOS/Windows TXT versions of the documentation."
  485. @echo " ${MAKE} alldocs - Create all versions of the documentation."
  486. @echo " ${MAKE} -j <x> - Use <x> parallel tasks (SMP support) when compiling $(PROGRAM_NAME) and $(CLIENT_NAME)"
  487. @echo ""
  488. @echo " ${MAKE} $(PROGRAM_NAME) - to build the server only."
  489. @echo " ${MAKE} $(CLIENT_NAME) - to build the client only."
  490. @echo " ${MAKE} $(MULTI_NAME) - to build $(PROGRAM_NAME) and $(CLIENT_NAME) in a single multi-call binary"
  491. @echo " ${MAKE} $(DLL_NAME) - to build the shared library $(DLL_NAME)"
  492. @echo " ${MAKE} $(A_NAME) - to build the static library $(A_NAME)"
  493. @echo ""
  494. @echo "Options"
  495. @echo " CONFIG=<x> Compile <x> as instead of config.h."
  496. @echo " INI=<x> Compile $(PROGRAM_NAME) with default ini file <x>"
  497. @echo " PROGRAM_NAME=<x> Use <x> as output file name for the KMS server. Defaults to vlmcsd."
  498. @echo " CLIENT_NAME=<x> Use <x> as output file name for the KMS client. Defaults to vlmcs."
  499. @echo " MULTI_NAME=<x> Use <x> as output file name for the multi-call binary. Defaults to vlmcsdmulti."
  500. @echo " DEPENDENCIES=1 Create dependency files."
  501. @echo " CRYPTO=openssl Use openssl for SHA256/HMAC calculations."
  502. @echo " CRYPTO=openssl_with_aes EXPERIMENTAL: Use openssl for SHA256/HMAC and AES calculations (hardware, e.g. AES-NI on x86)."
  503. @echo " CRYPTO=openssl_with_aes_soft EXPERIMENTAL: Use openssl for SHA256/HMAC and AES calculations (software)."
  504. @echo " CRYPTO=polarssl Use polarssl instead of internal crypto code for SHA256/HMAC calculations."
  505. @echo " CRYPTO=windows Use Windows CryptoAPI instead of internal crypto code for SHA256/HMAC calculations."
  506. @echo " MSRPC=1 Use Microsoft RPC instead of vlmcsd's internal RPC. Only works with Windows and Cygwin targets."
  507. @echo " CC=<x> Use compiler <x>. Supported compilers are gcc, icc, tcc and clang. Others may or may not work."
  508. @echo " AR=<x> Use <x> instead of ar to build $(A_NAME). Set to gcc-ar if you want to use gcc's LTO feature."
  509. @echo " COMPILER_LANGUAGE=<x> May be c or c++."
  510. @echo " TERMINAL_WIDTH=<x> Assume a fixed terminal width of <x> columns. Use in case of problems only."
  511. @echo " VLMCSD_VERSION=<x> Sets <x> as your version identifier. Defaults to \"private build\"."
  512. @echo " CFLAGS=<x> Pass <x> as additional arguments to the compiler."
  513. @echo " LDFLAGS=<x> Pass <x> as additional arguments to the linker."
  514. @echo " PLATFORMFLAGS=<x> Pass <x> as additional arguments to the compiler and the linker."
  515. @echo " BASECFLAGS=<x> Pass only <x> as arguments to the compiler (advanced users only)."
  516. @echo " BASELDFLAGS=<x> Pass only <x> as arguments to the linker (advanced users only)."
  517. @echo " STRIP=0 Don't strip debug information from $(PROGRAM_NAME) and $(CLIENT_NAME) (for developers)."
  518. @echo " VERBOSE=1 Be verbose when making targets."
  519. @echo " VERBOSE=3 Show name of compiler."
  520. @echo " THREADS=1 Use threads instead of fork(). Automatically set for native Windows. Recommended for Cygwin."
  521. @echo " WINDOWS=<x> Use <x> as the default ePID for Windows (when using $(PROGRAM_NAME) with -r 0)."
  522. @echo " OFFICE2010=<x> Use <x> as the default ePID for Office2010 (when using $(PROGRAM_NAME) with -r 0)."
  523. @echo " OFFICE2013=<x> Use <x> as the default ePID for Office2013 (when using $(PROGRAM_NAME) with -r 0)."
  524. @echo " HWID=<x> Use <x> as the default HWID (when it can't be found in an ini file)."
  525. @echo " FEATURES=full Compile $(PROGRAM_NAME) with all features (default)."
  526. @echo " FEATURES=most Compile $(PROGRAM_NAME) without rarely used features."
  527. @echo " FEATURES=embedded Compile $(PROGRAM_NAME) with typical features for embedded systems."
  528. @echo " FEATURES=autostart Removes features typically not needed if you place $(PROGRAM_NAME) in an autostart script."
  529. @echo " FEATURES=inetd Compile $(PROGRAM_NAME) for running through an internet superserver only."
  530. @echo " FEATURES=minimum Compiles only basic features of $(PROGRAM_NAME)."
  531. @echo " FEATURES=fixedepids $(PROGRAM_NAME) only uses bultin internal ePIDs."
  532. @echo ""
  533. @echo "Useful CFLAGS to save memory when running $(PROGRAM_NAME) on very small embedded devices (finer control than FEATURES=)"
  534. @echo " -DNO_EXTENDED_PRODUCT_LIST Don't compile the detailed product list."
  535. @echo " -DNO_BASIC_PRODUCT_LIST Don't compile the basic product list."
  536. @echo " -DNO_VERBOSE_LOG Don't support verbose logging. Removes -v option."
  537. @echo " -DNO_LOG Don't add support for logging. Implies -DNO_VERBOSE_LOG -DNO_EXTENDED_PRODUCT_LIST and -DNO_BASIC_PRODUCT_LIST."
  538. @echo " -DNO_RANDOM_EPID Don't support random ePIDs."
  539. @echo " -DNO_INI_FILE Don't support reading ePIDs/HWIDs from a file."
  540. @echo " -DNO_PID_FILE Don't support writing a PID file. Removes -p option."
  541. @echo " -DNO_USER_SWITCH Don't support changing uid/gid after program start. Removes -u and -g options."
  542. @echo " -DNO_HELP Don't support command line help."
  543. @echo " -DNO_CUSTOM_INTERVALS Don't support custom intervals for retry and refresh activation. Removes -A and -R options."
  544. @echo " -DNO_FREEBIND Don't support binding to foreign IP addresses. Removes -F0 and -F1 options. Only affects FreeBSD and Linux."
  545. @echo " -DSIMPLE_SOCKETS Compile $(PROGRAM_NAME) with basic socket support only. Removes -L option."
  546. @echo " -DNO_SOCKETS Don't support standalone operation. Requires an internet superserver to start $(PROGRAM_NAME)."
  547. @echo " -DNO_CL_PIDS Don't support specifying ePIDs and HwId from the command line in $(PROGRAM_NAME)."
  548. @echo " -DNO_LIMIT Don't support limiting concurrent clients in $(PROGRAM_NAME)."
  549. @echo " -DNO_SIGHUP Don't support SIGHUP handling in $(PROGRAM_NAME)."
  550. @echo " -DNO_VERSION_INFORMATION Don't support displaying version information in $(PROGRAM_NAME) and $(CLIENT_NAME). Removes -V option."
  551. @echo " -DNO_PRIVATE_IP_DETECT Don't support protection against clients with public IP addresses in $(PROGRAM_NAME)"
  552. @echo ""
  553. @echo "Troubleshooting options"
  554. @echo " CAT=1 Combine all sources in a single in-memory file and compile directly to target."
  555. @echo " NOPROCFS=1 Don't rely on a properly mounted proc filesystem in /proc."
  556. @echo " AUXV=1 Use /proc/self/auxv (requires Linux with glibc >= 2.16 or musl.)"
  557. @echo " NOLPTHREAD=1 Disable detection if -lpthread is required (for use with Android NDK)."
  558. @echo " NOLRESOLV=1 Disable detection if -lresolv is required (for use with Android NDK)."
  559. @echo " NOLIBS=1 Do not attempt to autodetect any library dependencies."
  560. @echo " OPENSSL_HMAC=0 Compile for openssl versions that don't have HMAC support (required on some embedded devices)."
  561. @echo " NO_TIMEOUT=1 Do not set timeouts for sockets (for systems that don't support it)."
  562. @echo " CHILD_HANDLER=1 Install a handler for SIGCHLD (for systems that don't support SA_NOCLDWAIT)."
  563. @echo " NO_DNS=1 Compile $(CLIENT_NAME) without support for detecting KMS servers via DNS."
  564. @echo " NO_GETIFADDRS=1 Compile $(PROGRAM_NAME) without using getifaddrs()."
  565. @echo " GETIFADDRS=musl Compile $(PROGRAM_NAME) with its own implementation of getifaddrs() based on musl."
  566. @echo " DNS_PARSER=internal Use $(CLIENT_NAME) internal DNS parsing routines. No effect on MingW (native Windows)."
  567. @echo ""
  568. @echo "Other useful CFLAGS"
  569. @echo " -DSUPPORT_WINE Add code that the Windows version of $(PROGRAM_NAME) runs on Wine if MSRPC=1"
  570. @echo " -D_PEDANTIC Report rare error/warning conditions instead of silently ignoring them."
  571. @echo " -DINCLUDE_BETAS Include SKU / activation IDs for obsolete beta/preview products."
  572. @echo " -DFD_SETSIZE=<x> Allow <x> -L statements in $(PROGRAM_NAME) (default: 64 on Windows, 1024 on most Unixes)."
  573. @echo " -flto Use link time optimization. Not supported by old compilers (gcc < 4.7). Use whenever supported."
  574. @echo " -flto=jobserver Utilize all CPUs during link time optimization. Requires ${MAKE} -j <cpus>"
  575. @echo " -fno-stack-protector No stack checking. Smaller binaries."
  576. @echo " -pipe Use pipes instead of temporary files (faster compilation, extends the life of your SSD)."