forked from siemens/gencmpclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpenSSL_version.mk
73 lines (51 loc) · 1.64 KB
/
OpenSSL_version.mk
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
ifeq ($(LIB),)
ifeq ($(OS),Windows_NT)
EXE=.exe
LIB=bin
else
EXE=
LIB=lib
endif
#CC=gcc
ifneq ($(OPENSSL_DIR),)
ifeq ($(shell echo $(OPENSSL_DIR) | grep "^/"),)
# $(OPENSSL_DIR) is relative path
OPENSSL_LIB=$(OPENSSL_DIR)
else
# $(OPENSSL_DIR) is absolute path
OPENSSL_LIB=$(OPENSSL_DIR)/$(LIB)
endif
CFLAGS+=-isystem $(OPENSSL_DIR)/include
LDFLAGS+=-L$(OPENSSL_DIR) -L$(OPENSSL_LIB) -Wl,-rpath=$(OPENSSL_DIR) -Wl,-rpath=$(OPENSSL_LIB)
endif
LDLIBS=-lcrypto
.phony: default build show clean
default: build show clean
build: OpenSSL_version
show: build
@./OpenSSL_version$(EXE)
clean:
@rm -f OpenSSL_version$(EXE)
else ifeq ($(LIB),header)
OPENSSL_NUMBER_SEL=head -n 1 | sed -r 's/.*?OpenSSL //' | awk '{print ($$0+0)}'
OPENSSLV_H=$(OPENSSL_DIR)/include/openssl/opensslv.h
ifeq ($(shell fgrep OPENSSL_VERSION_MAJOR "$(OPENSSLV_H)"),)
OPENSSL_VERSION=$(shell grep 'OPENSSL_VERSION_TEXT\s* "OpenSSL ' "$(OPENSSLV_H)" | $(OPENSSL_NUMBER_SEL))
else
OPENSSL_VERSION=$(shell fgrep OPENSSL_VERSION_M "$(OPENSSLV_H)" | head -n 2 | awk -v RS="" '{print $$4"."$$8 }')
endif
ifeq ($(OPENSSL_VERSION),1)
OPENSSL_VERSION=1.0
endif
else # $(LIB) is name of library file
OPENSSL_VERSION=$(shell strings "$(LIB)" | grep -E 'OpenSSL [0-9]+\.[0-9]+\.' | head -n 1 | sed -r 's/.*?OpenSSL //' | awk -v FS="." '{print $$1"."$$2}')
ifeq ($(OPENSSL_VERSION),)
OPENSSL_VERSION=$(shell strings "$(LIB)" | grep -E 'libcrypto\.' | head -n 1 | sed -r 's/.*?libcrypto(.[a-z]+)?\.//')
endif
ifeq ($(OPENSSL_VERSION),1.0.0)
OPENSSL_VERSION=1.0
endif
endif # $(LIB)
.phony: detect
detect:
$(info $(OPENSSL_VERSION))