summaryrefslogtreecommitdiff
path: root/Makefile.Windows
blob: 455aa11a6e4b26158cd6bc02afe9caa13b51970c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#
# A GNU Makefile that creates:
#   target/release/rustls_ffi.lib  -- using 'cargo build'
#   target/client.exe
#   target/server.exe
#
# for Windows using 'cl' or 'clang-cl'.
#
export CL=

VPATH = tests

RUSTLS_LIB = target/release/rustls_ffi.lib

USE_CLANG_CL ?= 0

green_msg = @echo -e "\e[1;32m$(strip $(1))\e[0m"

CFLAGS = -nologo -MD -Zi -W3 -O2   \
         -I./src                   \
         -D_WIN32_WINNT=0x601      \
         -Dssize_t=int             \
         -D_CRT_SECURE_NO_WARNINGS \
         -D_CRT_NONSTDC_NO_WARNINGS

LDFLAGS = -nologo -incremental:no -debug

ifeq ($(USE_CLANG_CL),1)
  CC = clang-cl
  CFLAGS += -ferror-limit=5 -Wno-pointer-sign
else
  CC = cl
endif

all: $(RUSTLS_LIB) target/client.exe target/server.exe

test: all
	$(call green_msg, getting 'https://httpbin.org/headers' ...)
	target/client.exe httpbin.org 443 /headers
	$(call green_msg, Running 'cargo test')
	cargo test

$(RUSTLS_LIB): src/lib.rs Cargo.toml
	$(call green_msg, Building '$@')
	RUSTFLAGS="--print native-static-libs" cargo build --release
	@echo

%.obj: tests/%.c
	$(CC) -Fo$@ -c $< $(CFLAGS)
	@echo

target/%.exe: common.obj %.obj $(RUSTLS_LIB)
	$(call link_EXE, $@, $^ advapi32.lib credui.lib kernel32.lib secur32.lib legacy_stdio_definitions.lib kernel32.lib advapi32.lib userenv.lib kernel32.lib kernel32.lib ws2_32.lib bcrypt.lib msvcrt.lib legacy_stdio_definitions.lib userenv.lib kernel32.lib msvcrt.lib)

clean:
	rm -f *.obj target/.rustc_info.json $(RUSTLS_LIB) vc1*.pdb
	rm -fR target/*
	rmdir target

define link_EXE
  $(call green_msg, Linking $(1))
  link $(LDFLAGS) -out:$(strip $(1)) $(2)
  @echo
endef