Skip to content

Commit fa3eccc

Browse files
committed
0531
0 parents  commit fa3eccc

File tree

1,103 files changed

+182588
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,103 files changed

+182588
-0
lines changed

GNUmakefile

+233
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
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+

Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Let BSD make switch to GNU make
2+
all ${.TARGETS}:
3+
@echo "================================================================"
4+
@echo " PLEASE USE THE GNU VERSION OF MAKE (gmake) INSTEAD OF ${MAKE} "
5+
@echo "================================================================"
6+
@echo ""
7+
@gmake $@

README

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
To view the documentation cd to the directory containing the distribution
2+
files and type
3+
4+
man man/vlmcsd.8
5+
to see documentation for vlmcsd
6+
7+
man man/vlmcs.1
8+
to see documentation for vlmcs
9+
10+
man man/vlmcsd.7
11+
to see general documentation for kms
12+
13+
If you don't have man, you may also use the .txt, .html and .pdf files
14+
in the man directory

README.compile-and-pre-built-binaries

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
Compilation and pre-built binaries FAQ
2+
======================================
3+
4+
What is the best pre-built binary for my system or device?
5+
----------------------------------------------------------
6+
7+
None. The best binary is compiled by yourself using a toolchain that is
8+
optimized for your system or device in every respect.
9+
10+
11+
How do I compile my own binary?
12+
-------------------------------
13+
14+
On a full blown desktop system this is relativly easy. If not already done so,
15+
install a C compiler (e.g. gcc or clang) through your packet manager, e.g.
16+
"sudo apt-get install gcc" (Debian/Ubuntu) or "sudo yum install gcc"
17+
(RedHat/Fedora).
18+
19+
Then cd to your vlmcsd directory and type "make". vlmcs and vlmcsd will
20+
be built right away for your local system.
21+
22+
If you installed gcc and it is not the default compiler for your OS or
23+
distribution, you may need to type "make CC=gcc" to explicitly select a
24+
specific C compiller.
25+
26+
27+
How do I compile a binary for my embedded device?
28+
-------------------------------------------------
29+
30+
What you need is cross-compiling toolchain for your device. It consists of a
31+
C compiler, libraries, header files and some tools (called binutils). The
32+
toolchain must match the device in processor architecture, endianess, ABI,
33+
library and header files version, library configuration, ...
34+
35+
If the endianess or ABI differs or the version of some library between
36+
toolchain and device differs too much, the resulting binary does not run
37+
on your device.
38+
39+
Once you have a proper toolchain (probably found on the Internet for download),
40+
unpack it to any directory and type
41+
42+
"make CC=/path/to/toolchain/bindir/c-compiler-binary"
43+
44+
Building vlmcsd for using a cross-compiling toolchain is as easy as building
45+
vlmcsd for your local machine. The only question is, whether this you have
46+
a toolchain that actually matches your device.
47+
48+
Whenever you change any parameter of the make command line, you must "clean"
49+
the source directory from intermediate files and output from previous runs
50+
of make. You can do so by typeing "make clean" or force make to behave as if
51+
the directory were clean by adding -B to the command line, e.g.
52+
53+
"make -B CC=/path/to/toolchain/bindir/c-compiler-binary"
54+
55+
56+
I have downloaded several promising toolchains for my device but they all
57+
don't work. Can I create my own toolchain?
58+
-------------------------------------------------------------------------
59+
60+
You can use tools like buildroot or OpenWRT. Both are able to create toolchains
61+
for many embedded devices. But this is out of the scope of this document.
62+
If you are unable to walk through thousands of configuration options and make
63+
the right choice, you may probably want to try the pre-built binaries.
64+
65+
66+
How to choose a pre-built binary?
67+
---------------------------------
68+
69+
The directory structure for the binaries is
70+
71+
binaries
72+
+
73+
+--<operating system>
74+
+
75+
+--<cpu arch>
76+
+
77+
+--<endianess> (omitted if CPU or OS does not allow multi-endianess)
78+
+
79+
+--<C-library>
80+
81+
<C-library> can also be "static". That means no special library is required.
82+
Static binaries are much bigger and need more RAM than dynamic binaries but
83+
are more likely to run on your system. Use a static binary only, if none of
84+
the dynmic binaries run.
85+
86+
Don't get confused when a binary is named after an OS or a specific device,
87+
e.g. the name contains "openwrt", "tomato" or "Fritzbox". This does not mean
88+
that the binary will run only on that OS or on that device. It is a hint only
89+
where I got or built the toolchain from.
90+
91+
92+
How to determine the endianess of my system?
93+
--------------------------------------------
94+
95+
- All Intel CPUs (x86, x32, x64) are little-endian only
96+
- Windows is little-endian only even if the CPU support big-endian
97+
- big-endian ARM is extremely uncommon. You can safely assume little-endian
98+
- little-endian PowerPC virtually does not exist since only newer POWER7
99+
and POWER8 CPUs support it. Always assume big-endian.
100+
- For MIPS both little-endian and big-endian are common. Most Broadcomm and
101+
TI chips run little-endian. Most Atheros and Ikanos CPUs run big-endian.
102+
103+
Try typing
104+
echo -n I | od -o | awk 'FNR==1{ print substr($2,6,1)}'
105+
106+
This returns 1 for little-endian systems and 0 for big-endian systems. However
107+
some devices do not have the od command and thus this method won't work.
108+
109+
110+

0 commit comments

Comments
 (0)