summaryrefslogtreecommitdiff
path: root/crypto/CMakeLists.txt
blob: f98c7c86ee4d838a3447e4472df93f9c027c3065 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
include_directories(. ../include)

if(APPLE)
	set(PERLASM_STYLE macosx)
	set(ASM_EXT S)
	enable_language(ASM)
elseif(UNIX)
	set(PERLASM_STYLE elf)
	set(ASM_EXT S)
	enable_language(ASM)
else()
	if (CMAKE_CL_64)
		message("Using masm")
		set(PERLASM_STYLE masm)
		enable_language(ASM_MASM)
	else()
		message("Using win32n")
		set(PERLASM_STYLE win32n)

		# On 32-bit, upstream supports only NASM, not MASM. We'll use Yasm, specifically.
		set(CMAKE_ASM_NASM_COMPILER "yasm")
		enable_language(ASM_NASM)
	endif()
	set(ASM_EXT asm)
endif()

function(perlasm dest src)
	add_custom_command(
		OUTPUT ${dest}
		COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${PERLASM_STYLE} ${ARGN} > ${dest}
		DEPENDS
		${src}
		${PROJECT_SOURCE_DIR}/crypto/perlasm/x86_64-xlate.pl
		${PROJECT_SOURCE_DIR}/crypto/perlasm/x86asm.pl
		${PROJECT_SOURCE_DIR}/crypto/perlasm/x86gas.pl
		${PROJECT_SOURCE_DIR}/crypto/perlasm/x86masm.pl
		${PROJECT_SOURCE_DIR}/crypto/perlasm/x86nasm.pl
		WORKING_DIRECTORY .
	)
endfunction()

if (${ARCH} STREQUAL "x86_64")
	set(
		CRYPTO_ARCH_SOURCES

		cpu-x86_64-asm.${ASM_EXT}
		cpu-intel.c
	)
endif()

if (${ARCH} STREQUAL "x86")
	set(
		CRYPTO_ARCH_SOURCES

		cpu-x86-asm.${ASM_EXT}
		cpu-intel.c
	)
endif()

if (${ARCH} STREQUAL "arm")
	set(
		CRYPTO_ARCH_SOURCES

		cpu-x86-asm.${ASM_EXT}
		cpu-arm.c
	)
endif()

# Level 0.1 - depends on nothing outside this set.
add_subdirectory(stack)
add_subdirectory(lhash)
add_subdirectory(err)
add_subdirectory(buf)
add_subdirectory(base64)
add_subdirectory(bytestring)

# Level 0.2 - depends on nothing but itself
add_subdirectory(sha)
add_subdirectory(md4)
add_subdirectory(md5)
add_subdirectory(modes)
add_subdirectory(aes)
add_subdirectory(des)
add_subdirectory(rc4)
add_subdirectory(conf)
add_subdirectory(chacha)
add_subdirectory(poly1305)

# Level 1, depends only on 0.*
add_subdirectory(digest)
add_subdirectory(cipher)
add_subdirectory(rand)
add_subdirectory(bio)
add_subdirectory(bn)
add_subdirectory(obj)
add_subdirectory(asn1)

# Level 2
add_subdirectory(engine)
add_subdirectory(dh)
add_subdirectory(dsa)
add_subdirectory(rsa)
add_subdirectory(ec)
add_subdirectory(ecdh)
add_subdirectory(ecdsa)
add_subdirectory(hmac)

# Level 3
add_subdirectory(evp)
add_subdirectory(pem)
add_subdirectory(x509)
add_subdirectory(x509v3)

# Level 4
add_subdirectory(pkcs8)

add_library(
	crypto
	STATIC

	crypto.c
	crypto_error.c
	mem.c
	thread.c
	ex_data.c
	ex_data_impl.c
	time_support.c
	directory_posix.c
	directory_win.c

	${CRYPTO_ARCH_SOURCES}

	$<TARGET_OBJECTS:stack>
	$<TARGET_OBJECTS:lhash>
	$<TARGET_OBJECTS:err>
	$<TARGET_OBJECTS:base64>
	$<TARGET_OBJECTS:bytestring>
	$<TARGET_OBJECTS:sha>
	$<TARGET_OBJECTS:md4>
	$<TARGET_OBJECTS:md5>
	$<TARGET_OBJECTS:digest>
	$<TARGET_OBJECTS:cipher>
	$<TARGET_OBJECTS:modes>
	$<TARGET_OBJECTS:aes>
	$<TARGET_OBJECTS:des>
	$<TARGET_OBJECTS:rc4>
	$<TARGET_OBJECTS:conf>
	$<TARGET_OBJECTS:chacha>
	$<TARGET_OBJECTS:poly1305>
	$<TARGET_OBJECTS:buf>
	$<TARGET_OBJECTS:bn>
	$<TARGET_OBJECTS:bio>
	$<TARGET_OBJECTS:rand>
	$<TARGET_OBJECTS:obj>
	$<TARGET_OBJECTS:asn1>
	$<TARGET_OBJECTS:engine>
	$<TARGET_OBJECTS:dh>
	$<TARGET_OBJECTS:dsa>
	$<TARGET_OBJECTS:rsa>
	$<TARGET_OBJECTS:ec>
	$<TARGET_OBJECTS:ecdh>
	$<TARGET_OBJECTS:ecdsa>
	$<TARGET_OBJECTS:hmac>
	$<TARGET_OBJECTS:evp>
	$<TARGET_OBJECTS:pem>
	$<TARGET_OBJECTS:x509>
	$<TARGET_OBJECTS:x509v3>
	$<TARGET_OBJECTS:pkcs8>
)

perlasm(cpu-x86_64-asm.${ASM_EXT} cpu-x86_64-asm.pl)
perlasm(cpu-x86-asm.${ASM_EXT} cpu-x86-asm.pl)