GNUmakefile 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  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 androideabi,$(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 ($(NO_DNS),1)
  114. ifneq ($(ANDROID),1)
  115. ifneq ($(NOLRESOLV),1)
  116. ifeq ($(MINGW),1)
  117. CLIENTLDFLAGS += -ldnsapi
  118. endif
  119. ifeq ($(LINUX),1)
  120. CLIENTLDFLAGS += -lresolv
  121. endif
  122. ifeq ($(HURD),1)
  123. CLIENTLDFLAGS += -lresolv
  124. endif
  125. ifeq ($(DARWIN),1)
  126. CLIENTLDFLAGS += -lresolv
  127. endif
  128. ifeq ($(CYGWIN),1)
  129. DNS_PARSER := internal
  130. CLIENTLDFLAGS += -lresolv
  131. endif
  132. ifeq ($(OPENBSD),1)
  133. DNS_PARSER := internal
  134. endif
  135. ifeq ($(SOLARIS),1)
  136. CLIENTLDFLAGS += -lresolv
  137. endif
  138. endif
  139. endif
  140. else
  141. BASECFLAGS += -DNO_DNS
  142. endif
  143. ifneq ($(CAT),2)
  144. BASECFLAGS += "-Wall"
  145. endif
  146. ifeq ($(DARWIN), 1)
  147. STRIPFLAGS += -Wl,-S -Wl,-x
  148. BASECFLAGS += -Wno-deprecated-declarations
  149. else ifeq ($(shell uname), SunOS)
  150. STRIPFLAGS += -s
  151. ifeq ($(notdir $(LD_ALTEXEC)),gld)
  152. BASELDFLAGS += -Wl,--gc-sections
  153. endif
  154. BASELDFLAGS += -lsocket
  155. else
  156. ifneq ($(CC),tcc)
  157. BASELDFLAGS += -Wl,--gc-sections
  158. endif
  159. STRIPFLAGS += -s
  160. endif
  161. 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
  162. ifeq ($(FEATURES), embedded)
  163. BASECFLAGS += -DNO_HELP -DNO_USER_SWITCH -DNO_BASIC_PRODUCT_LIST -DNO_CUSTOM_INTERVALS -DNO_PID_FILE -DNO_VERBOSE_LOG -DNO_VERSION_INFORMATION
  164. else ifeq ($(FEATURES), autostart)
  165. BASECFLAGS += -DNO_HELP -DNO_VERSION_INFORMATION
  166. else ifeq ($(FEATURES), minimum)
  167. BASECFLAGS += $(LIBRARY_CFLAGS)
  168. else ifeq ($(FEATURES), most)
  169. BASECFLAGS += -DNO_SIGHUP -DNO_PID_FILE -DNO_LIMIT
  170. else ifeq ($(FEATURES), inetd)
  171. BASECFLAGS += -DNO_SIGHUP -DNO_SOCKETS -DNO_PID_FILE -DNO_LIMIT -DNO_VERSION_INFORMATION
  172. else ifeq ($(FEATURES), fixedepids)
  173. BASECFLAGS += -DNO_SIGHUP -DNO_CL_PIDS -DNO_RANDOM_EPID -DNO_INI_FILE
  174. endif
  175. ifdef INI
  176. BASECFLAGS += -DINI_FILE=\"$(INI)\"
  177. endif
  178. ifeq ($(THREADS), 1)
  179. BASECFLAGS += -DUSE_THREADS
  180. endif
  181. ifeq ($(CHILD_HANDLER), 1)
  182. BASECFLAGS += -DCHILD_HANDLER
  183. endif
  184. ifeq ($(NO_TIMEOUT), 1)
  185. BASECFLAGS += -DNO_TIMEOUT
  186. endif
  187. ifdef WINDOWS
  188. BASECFLAGS += -DEPID_WINDOWS=\"$(WINDOWS)\"
  189. endif
  190. ifdef OFFICE2010
  191. BASECFLAGS += -DEPID_OFFICE2010=\"$(OFFICE2010)\"
  192. endif
  193. ifdef OFFICE2013
  194. BASECFLAGS += -DEPID_OFFICE2013=\"$(OFFICE2013)\"
  195. endif
  196. ifdef HWID
  197. BASECFLAGS += -DHWID=$(HWID)
  198. endif
  199. ifdef TERMINAL_WIDTH
  200. BASECFLAGS += -DTERMINAL_FIXED_WIDTH=$(TERMINAL_WIDTH) -DDISPLAY_WIDTH=\"$(TERMINAL_WIDTH)\"
  201. endif
  202. ifeq ($(NOPROCFS), 1)
  203. BASECFLAGS += -DNO_PROCFS
  204. endif
  205. ifeq ($(AUXV), 1)
  206. BASECFLAGS += -DUSE_AUXV
  207. endif
  208. ifneq ($(ANDROID), 1)
  209. ifneq ($(MINIX), 1)
  210. ifneq ($(NOLPTHREAD), 1)
  211. ifeq ($(THREADS), 1)
  212. SERVERLDFLAGS += -lpthread
  213. endif
  214. ifeq (,$(findstring NO_LIMIT,$(CFLAGS) $(BASECFLAGS)))
  215. SERVERLDFLAGS += -lpthread
  216. endif
  217. endif
  218. endif
  219. endif
  220. $(MULTI_NAME): BASECFLAGS += -DMULTI_CALL_BINARY=1
  221. all: $(CLIENT_NAME) $(PROGRAM_NAME)
  222. #ifdef CAT
  223. allmulti: $(CLIENT_NAME) $(PROGRAM_NAME) $(MULTI_NAME)
  224. #endif
  225. ifneq ($(strip $(VLMCSD_VERSION)),)
  226. BASECFLAGS += -DVERSION=\"$(VLMCSD_VERSION),\ built\ $(shell date -u '+%Y-%m-%d %H:%M:%S' | sed -e 's/ /\\ /g')\ UTC\"
  227. endif
  228. ifdef CAT
  229. BASECFLAGS += -DONE_FILE
  230. endif
  231. SRCS = crypto.c kms.c endian.c output.c shared_globals.c helpers.c
  232. 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
  233. DEPS = $(MULTI_SRCS:.c=.d)
  234. VLMCSD_SRCS = vlmcsd.c $(SRCS)
  235. VLMCSD_OBJS = $(VLMCSD_SRCS:.c=.o)
  236. VLMCS_SRCS = vlmcs.c $(SRCS)
  237. VLMCS_OBJS = $(VLMCS_SRCS:.c=.o)
  238. MULTI_SRCS = vlmcsd.c vlmcs.c vlmcsdmulti.c $(SRCS)
  239. MULTI_OBJS = $(SRCS:.c=.o) vlmcsd-m.o vlmcs-m.o vlmcsdmulti-m.o
  240. DLL_SRCS = libkms.c $(SRCS)
  241. DLL_OBJS = $(DLL_SRCS:.c=.o)
  242. PDFDOCS = vlmcs.1.pdf vlmcsd.7.pdf vlmcsd.8.pdf vlmcsdmulti.1.pdf vlmcsd.ini.5.pdf vlmcsd-floppy.7.pdf
  243. HTMLDOCS = $(PDFDOCS:.pdf=.html)
  244. UNIXDOCS = $(PDFDOCS:.pdf=.unix.txt)
  245. DOSDOCS = $(PDFDOCS:.pdf=.dos.txt)
  246. ifneq ($(NO_DNS),1)
  247. VLMCS_SRCS += dns_srv.c
  248. MULTI_SRCS += dns_srv.c
  249. MULTI_OBJS += dns_srv.o
  250. ifeq ($(DNS_PARSER),internal)
  251. ifneq ($(MINGW),1)
  252. VLMCS_SRCS += ns_parse.c ns_name.c
  253. MULTI_SRCS += ns_parse.c ns_name.c
  254. MULTI_OBJS += ns_parse.o ns_name.o
  255. BASECFLAGS += "-DDNS_PARSER_INTERNAL"
  256. endif
  257. endif
  258. endif
  259. ifeq ($(MSRPC),1)
  260. VLMCSD_SRCS += msrpc-server.c
  261. VLMCS_SRCS += msrpc-client.c
  262. MULTI_SRCS += msrpc-server.c msrpc-client.c
  263. MULTI_OBJS += msrpc-server-m.o msrpc-client-m.o
  264. DLL_SRCS += msrpc-server.c
  265. BASECFLAGS += -DUSE_MSRPC -Wno-unknown-pragmas
  266. BASELDFLAGS += -lrpcrt4
  267. else
  268. SRCS += network.c rpc.c
  269. endif
  270. ifeq "$(WIN)" "1"
  271. VLMCSD_SRCS += ntservice.c
  272. MULTI_SRCS += ntservice.c
  273. MULTI_OBJS += ntservice.o
  274. endif
  275. ifeq ($(CRYPTO), openssl_with_aes)
  276. BASECFLAGS += -D_CRYPTO_OPENSSL -D_USE_AES_FROM_OPENSSL
  277. BASELDFLAGS += -lcrypto
  278. SRCS += crypto_openssl.c
  279. else ifeq ($(CRYPTO), openssl_with_aes_soft)
  280. BASECFLAGS += -D_CRYPTO_OPENSSL -D_USE_AES_FROM_OPENSSL -D_OPENSSL_SOFTWARE
  281. BASELDFLAGS += -lcrypto
  282. SRCS += crypto_openssl.c
  283. else ifeq ($(CRYPTO), openssl)
  284. BASECFLAGS += -D_CRYPTO_OPENSSL
  285. BASELDFLAGS += -lcrypto
  286. SRCS += crypto_openssl.c
  287. else ifeq ($(CRYPTO), polarssl)
  288. BASECFLAGS += -D_CRYPTO_POLARSSL
  289. BASELDFLAGS += -lpolarssl
  290. else ifeq ($(CRYPTO), windows)
  291. BASECFLAGS += -D_CRYPTO_WINDOWS
  292. SRCS += crypto_windows.c
  293. else
  294. BASECFLAGS += -D_CRYPTO_INTERNAL
  295. SRCS += crypto_internal.c
  296. endif
  297. ifneq ($(STRIP),0)
  298. BASELDFLAGS += $(STRIPFLAGS)
  299. endif
  300. ifeq ($(OPENSSL_HMAC),0)
  301. BASECFLAGS += -D_OPENSSL_NO_HMAC
  302. endif
  303. ifeq ($(DEPENDENCIES),2)
  304. BASECFLAGS += -MMD
  305. endif
  306. ifeq ($(VERBOSE),3)
  307. COMPILER := $(shell printf "%-40s" $(notdir $(CC)))
  308. ARCHIVER := $(shell printf "%-40s" $(notdir $(AR)))
  309. endif
  310. ARCMD := AR
  311. ifdef CAT
  312. LDCMD := CC/LD
  313. else
  314. LDCMD := LD
  315. endif
  316. -include $(MULTI_SRCS:.c=.d)
  317. %.o: %.c
  318. ifeq ($(VERBOSE),1)
  319. $(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -c $<
  320. ifeq ($(DEPENDENCIES),1)
  321. $(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -MM -MF $*.d $<
  322. endif
  323. else
  324. @echo "$(COMPILER) CC $@ <- $<"
  325. @$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -c $<
  326. ifeq ($(DEPENDENCIES),1)
  327. @echo "$(COMPILER) DEP $*.d <- $<"
  328. @$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -MM -MF $*.d $<
  329. endif
  330. endif
  331. %-m.o: %.c
  332. ifeq ($(VERBOSE),1)
  333. $(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -o $@ -c $<
  334. ifeq ($(DEPENDENCIES),1)
  335. $(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -MM -MF $*.d $<
  336. endif
  337. else
  338. @echo "$(COMPILER) CC $@ <- $<"
  339. @$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -o $@ -c $<
  340. ifeq ($(DEPENDENCIES),1)
  341. @echo "$(COMPILER) DEP $*.d <- $<"
  342. @$(CC) -x$(COMPILER_LANGUAGE) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(PLATFORMFLAGS) -MM -MF $*.d $<
  343. endif
  344. endif
  345. ifdef CAT
  346. BUILDCOMMAND = cat $^ | $(CC) -x$(COMPILER_LANGUAGE) -o $@ -
  347. VLMCSD_PREREQUISITES = $(VLMCSD_SRCS)
  348. VLMCS_PREREQUISITES = $(VLMCS_SRCS)
  349. MULTI_PREREQUISITES = $(MULTI_SRCS)
  350. DLL_PREREQUISITES = $(DLL_SRCS)
  351. OBJ_PREREQUISITES = $(DLL_SRCS)
  352. else
  353. BUILDCOMMAND = $(CC) -o $@ $^
  354. VLMCSD_PREREQUISITES = $(VLMCSD_OBJS)
  355. VLMCS_PREREQUISITES = $(VLMCS_OBJS)
  356. MULTI_PREREQUISITES = $(MULTI_OBJS)
  357. DLL_PREREQUISITES = $(DLL_OBJS)
  358. OBJ_PREREQUISITES = $(DLL_OBJS)
  359. endif
  360. ifeq ($(VERBOSE),1)
  361. BUILDCOMMANDPREFIX = +
  362. else
  363. BUILDCOMMANDPREFIX = +@
  364. endif
  365. INFOCOMMAND = +@echo "$(COMPILER) $(LDCMD) $@ <- $^"
  366. ARINFOCOMMAND = +@echo "$(ARCHIVER) $(ARCMD) $@ <. $^"
  367. VLMCSD_COMMAND = $(BUILDCOMMANDPREFIX)$(BUILDCOMMAND) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(BASELDFLAGS) $(LDFLAGS) $(SERVERLDFLAGS)
  368. VLMCS_COMMAND = $(BUILDCOMMANDPREFIX)$(BUILDCOMMAND) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(BASELDFLAGS) $(LDFLAGS) $(CLIENTLDFLAGS)
  369. MULTI_COMMAND = $(BUILDCOMMANDPREFIX)$(BUILDCOMMAND) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(BASELDFLAGS) $(LDFLAGS) $(CLIENTLDFLAGS) $(SERVERLDFLAGS)
  370. DLL_COMMAND = $(BUILDCOMMANDPREFIX)$(BUILDCOMMAND) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(BASELDFLAGS) $(LDFLAGS) $(SERVERLDFLAGS) -fvisibility=hidden -shared -DIS_LIBRARY=1 $(LIBRARY_CFLAGS) -UNO_SOCKETS -UUSE_MSRPC
  371. OBJ_COMMAND = $(BUILDCOMMANDPREFIX)$(BUILDCOMMAND) $(PLATFORMFLAGS) $(BASECFLAGS) $(CFLAGS) $(BASELDFLAGS) $(LDFLAGS) $(SERVERLDFLAGS) -fvisibility=hidden -c -DIS_LIBRARY=1 $(LIBRARY_CFLAGS) -UNO_SOCKETS -UUSE_MSRPC
  372. $(PROGRAM_NAME): $(VLMCSD_PREREQUISITES)
  373. ifneq ($(VERBOSE),1)
  374. $(INFOCOMMAND)
  375. endif
  376. $(VLMCSD_COMMAND)
  377. $(CLIENT_NAME): $(VLMCS_PREREQUISITES)
  378. ifneq ($(VERBOSE),1)
  379. $(INFOCOMMAND)
  380. endif
  381. $(VLMCS_COMMAND)
  382. $(MULTI_NAME): $(MULTI_PREREQUISITES)
  383. ifneq ($(VERBOSE),1)
  384. $(INFOCOMMAND)
  385. endif
  386. $(MULTI_COMMAND)
  387. $(DLL_NAME): $(DLL_PREREQUISITES)
  388. ifneq ($(VERBOSE),1)
  389. $(INFOCOMMAND)
  390. endif
  391. $(DLL_COMMAND)
  392. ifndef CAT
  393. $(OBJ_NAME):
  394. +@echo Cannot make $@ without CAT defined. Please create $(A_NAME)
  395. else
  396. $(OBJ_NAME): $(OBJ_PREREQUISITES)
  397. ifneq ($(VERBOSE),1)
  398. $(INFOCOMMAND)
  399. endif
  400. $(OBJ_COMMAND)
  401. endif
  402. ifdef CAT
  403. $(A_NAME): $(OBJ_NAME)
  404. else
  405. $(A_NAME): BASECFLAGS += -fvisibility=hidden -DIS_LIBRARY=1 $(LIBRARY_CFLAGS) -UNO_SOCKETS -UUSE_MSRPC
  406. $(A_NAME): $(DLL_OBJS)
  407. endif
  408. ifneq ($(VERBOSE),1)
  409. $(ARINFOCOMMAND)
  410. endif
  411. +@rm -f $@
  412. $(BUILDCOMMANDPREFIX)$(AR) rcs $@ $^
  413. %.pdf : %
  414. ifeq ($(shell uname), Darwin)
  415. groff -Tps -mandoc -c $< | pstopdf -i -o $@
  416. else
  417. groff -Tpdf -mandoc -c $< > $@
  418. endif
  419. %.html : %
  420. groff -Thtml -mandoc -c $< > $@
  421. %.unix.txt : %
  422. groff -P -c -Tutf8 -mandoc -c $< | col -bx > $@
  423. %.dos.txt : %.unix.txt
  424. # unix2dos -n $< $@
  425. # sed -e 's/$$/\r/' $< > $@
  426. awk 'sub("$$", "\r")' $< > $@
  427. pdfdocs : $(PDFDOCS)
  428. dosdocs : $(DOSDOCS)
  429. unixdocs : $(UNIXDOCS)
  430. htmldocs : $(HTMLDOCS)
  431. alldocs : $(UNIXDOCS) $(HTMLDOCS) $(PDFDOCS) $(DOSDOCS)
  432. clean:
  433. 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
  434. dnsclean:
  435. rm -f dns_srv.o
  436. help:
  437. @echo "Type"
  438. @echo " ${MAKE} - to build $(PROGRAM_NAME) and $(CLIENT_NAME)"
  439. @echo " ${MAKE} clean - to remove $(PROGRAM_NAME) and $(CLIENT_NAME)"
  440. @echo " ${MAKE} help - to see this help"
  441. @echo " ${MAKE} pdfdocs - Create PDF versions of the documentation (Requires groff with PDF support)."
  442. @echo " ${MAKE} htmldocs - Create HTML versions of the documentation."
  443. @echo " ${MAKE} unixdocs - Create Unix TXT versions of the documentation."
  444. @echo " ${MAKE} dosdocs - Create DOS/Windows TXT versions of the documentation."
  445. @echo " ${MAKE} alldocs - Create all versions of the documentation."
  446. @echo " ${MAKE} -j <x> - Use <x> parallel tasks (SMP support) when compiling $(PROGRAM_NAME) and $(CLIENT_NAME)"
  447. @echo ""
  448. @echo " ${MAKE} $(PROGRAM_NAME) - to build the server only."
  449. @echo " ${MAKE} $(CLIENT_NAME) - to build the client only."
  450. @echo " ${MAKE} $(MULTI_NAME) - to build $(PROGRAM_NAME) and $(CLIENT_NAME) in a single multi-call binary"
  451. @echo " ${MAKE} $(DLL_NAME) - to build the shared library $(DLL_NAME)"
  452. @echo " ${MAKE} $(A_NAME) - to build the static library $(A_NAME)"
  453. @echo ""
  454. @echo "Options"
  455. @echo " CONFIG=<x> Compile <x> as instead of config.h."
  456. @echo " INI=<x> Compile $(PROGRAM_NAME) with default ini file <x>"
  457. @echo " PROGRAM_NAME=<x> Use <x> as output file name for the KMS server. Defaults to vlmcsd."
  458. @echo " CLIENT_NAME=<x> Use <x> as output file name for the KMS client. Defaults to vlmcs."
  459. @echo " MULTI_NAME=<x> Use <x> as output file name for the multi-call binary. Defaults to vlmcsdmulti."
  460. @echo " DEPENDENCIES=1 Create dependency files."
  461. @echo " CRYPTO=openssl Use openssl for SHA256/HMAC calculations."
  462. @echo " CRYPTO=openssl_with_aes EXPERIMENTAL: Use openssl for SHA256/HMAC and AES calculations (hardware, e.g. AES-NI on x86)."
  463. @echo " CRYPTO=openssl_with_aes_soft EXPERIMENTAL: Use openssl for SHA256/HMAC and AES calculations (software)."
  464. @echo " CRYPTO=polarssl Use polarssl instead of internal crypto code for SHA256/HMAC calculations."
  465. @echo " CRYPTO=windows Use Windows CryptoAPI instead of internal crypto code for SHA256/HMAC calculations."
  466. @echo " MSRPC=1 Use Microsoft RPC instead of vlmcsd's internal RPC. Only works with Windows and Cygwin targets."
  467. @echo " CC=<x> Use compiler <x>. Supported compilers are gcc, icc, tcc and clang. Others may or may not work."
  468. @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."
  469. @echo " COMPILER_LANGUAGE=<x> May be c or c++."
  470. @echo " TERMINAL_WIDTH=<x> Assume a fixed terminal width of <x> columns. Use in case of problems only."
  471. @echo " VLMCSD_VERSION=<x> Sets <x> as your version identifier. Defaults to \"private build\"."
  472. @echo " CFLAGS=<x> Pass <x> as additional arguments to the compiler."
  473. @echo " LDFLAGS=<x> Pass <x> as additional arguments to the linker."
  474. @echo " PLATFORMFLAGS=<x> Pass <x> as additional arguments to the compiler and the linker."
  475. @echo " BASECFLAGS=<x> Pass only <x> as arguments to the compiler (advanced users only)."
  476. @echo " BASELDFLAGS=<x> Pass only <x> as arguments to the linker (advanced users only)."
  477. @echo " STRIP=0 Don't strip debug information from $(PROGRAM_NAME) and $(CLIENT_NAME) (for developers)."
  478. @echo " VERBOSE=1 Be verbose when making targets."
  479. @echo " VERBOSE=3 Show name of compiler."
  480. @echo " THREADS=1 Use threads instead of fork(). Automatically set for native Windows. Recommended for Cygwin."
  481. @echo " WINDOWS=<x> Use <x> as the default ePID for Windows (when using $(PROGRAM_NAME) with -r 0)."
  482. @echo " OFFICE2010=<x> Use <x> as the default ePID for Office2010 (when using $(PROGRAM_NAME) with -r 0)."
  483. @echo " OFFICE2013=<x> Use <x> as the default ePID for Office2013 (when using $(PROGRAM_NAME) with -r 0)."
  484. @echo " HWID=<x> Use <x> as the default HWID (when it can't be found in an ini file)."
  485. @echo " FEATURES=full Compile $(PROGRAM_NAME) with all features (default)."
  486. @echo " FEATURES=most Compile $(PROGRAM_NAME) without rarely used features."
  487. @echo " FEATURES=embedded Compile $(PROGRAM_NAME) with typical features for embedded systems."
  488. @echo " FEATURES=autostart Removes features typically not needed if you place $(PROGRAM_NAME) in an autostart script."
  489. @echo " FEATURES=inetd Compile $(PROGRAM_NAME) for running through an internet superserver only."
  490. @echo " FEATURES=minimum Compiles only basic features of $(PROGRAM_NAME)."
  491. @echo " FEATURES=fixedepids $(PROGRAM_NAME) only uses bultin internal ePIDs."
  492. @echo ""
  493. @echo "Useful CFLAGS to save memory when running $(PROGRAM_NAME) on very small embedded devices (finer control than FEATURES=)"
  494. @echo " -DNO_EXTENDED_PRODUCT_LIST Don't compile the detailed product list."
  495. @echo " -DNO_BASIC_PRODUCT_LIST Don't compile the basic product list."
  496. @echo " -DNO_VERBOSE_LOG Don't support verbose logging. Removes -v option."
  497. @echo " -DNO_LOG Don't add support for logging. Implies -DNO_VERBOSE_LOG -DNO_EXTENDED_PRODUCT_LIST and -DNO_BASIC_PRODUCT_LIST."
  498. @echo " -DNO_RANDOM_EPID Don't support random ePIDs."
  499. @echo " -DNO_INI_FILE Don't support reading ePIDs/HWIDs from a file."
  500. @echo " -DNO_PID_FILE Don't support writing a PID file. Removes -p option."
  501. @echo " -DNO_USER_SWITCH Don't support changing uid/gid after program start. Removes -u and -g options."
  502. @echo " -DNO_HELP Don't support command line help."
  503. @echo " -DNO_CUSTOM_INTERVALS Don't support custom intervals for retry and refresh activation. Removes -A and -R options."
  504. @echo " -DNO_FREEBIND Don't support binding to foreign IP addresses. Removes -F0 and -F1 options. Only affects FreeBSD and Linux."
  505. @echo " -DSIMPLE_SOCKETS Compile $(PROGRAM_NAME) with basic socket support only. Removes -L option."
  506. @echo " -DNO_SOCKETS Don't support standalone operation. Requires an internet superserver to start $(PROGRAM_NAME)."
  507. @echo " -DNO_CL_PIDS Don't support specifying ePIDs and HwId from the command line in $(PROGRAM_NAME)."
  508. @echo " -DNO_LIMIT Don't support limiting concurrent clients in $(PROGRAM_NAME)."
  509. @echo " -DNO_SIGHUP Don't support SIGHUP handling in $(PROGRAM_NAME)."
  510. @echo " -DNO_VERSION_INFORMATION Don't support displaying version information in $(PROGRAM_NAME) and $(CLIENT_NAME). Removes -V option."
  511. @echo " -DENABLE_DEPRECATED_OPTIONS Enable command line options that provide compatibility with previous versions of $(PROGRAM_NAME)."
  512. @echo ""
  513. @echo "Troubleshooting options"
  514. @echo " CAT=1 Combine all sources in a single in-memory file and compile directly to target."
  515. @echo " NOPROCFS=1 Don't rely on a properly mounted proc filesystem in /proc."
  516. @echo " AUXV=1 Use /proc/self/auxv (requires Linux with glibc >= 2.16 or musl.)"
  517. @echo " NOLPTHREAD=1 Disable detection if -lpthread is required (for use with Android NDK)."
  518. @echo " NOLRESOLV=1 Disable detection if -lresolv is required (for use with Android NDK)."
  519. @echo " NOLIBS=1 Do not attempt to autodetect any library dependencies."
  520. @echo " OPENSSL_HMAC=0 Compile for openssl versions that don't have HMAC support (required on some embedded devices)."
  521. @echo " NO_TIMEOUT=1 Do not set timeouts for sockets (for systems that don't support it)."
  522. @echo " CHILD_HANDLER=1 Install a handler for SIGCHLD (for systems that don't support SA_NOCLDWAIT)."
  523. @echo " NO_DNS=1 Compile $(CLIENT_NAME) without support for detecting KMS servers via DNS."
  524. @echo " DNS_PARSER=internal Use $(CLIENT_NAME) internal DNS parsing routines. No effect on MingW (native Windows)."
  525. @echo ""
  526. @echo "Other useful CFLAGS"
  527. @echo " -DSUPPORT_WINE Add code that the Windows version of $(PROGRAM_NAME) runs on Wine if MSRPC=1"
  528. @echo " -D_PEDANTIC Report rare error/warning conditions instead of silently ignoring them."
  529. @echo " -DINCLUDE_BETAS Include SKU / activation IDs for obsolete beta/preview products."
  530. @echo " -DFD_SETSIZE=<x> Allow <x> -L statements in $(PROGRAM_NAME) (default: 64 on Windows, 1024 on most Unixes)."
  531. @echo " -flto Use link time optimization. Not supported by old compilers (gcc < 4.7). Use whenever supported."
  532. @echo " -flto=jobserver Utilize all CPUs during link time optimization. Requires ${MAKE} -j <cpus>"
  533. @echo " -fno-stack-protector No stack checking. Smaller binaries."
  534. @echo " -pipe Use pipes instead of temporary files (faster compilation, extends the life of your SSD)."