-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
86 lines (71 loc) · 2.03 KB
/
Makefile
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
# This file was taken from sslscan (https://github.com/rbsec/sslscan)
# All Credits goes to them for the OpenSSL static build stuff :)
#
#
#
# set gcc as default if CC is not set
ifndef CC
CC=gcc
endif
GIT_VERSION = $(shell git describe --tags --always --dirty=-wip)
# Ugly hack to get version if git isn't installed
ifeq ($(GIT_VERSION),)
GIT_VERSION = $(shell grep -E -o -m 1 "[0-9]+\.[0-9]+\.[0-9]+" Changelog)
endif
# Detect OS
OS := $(shell uname)
SRCS = bin/scan.cr
PREFIX = /usr
BINDIR = $(PREFIX)/bin
WARNINGS = -Wall -Wformat=2
DEFINES = -DVERSION=\"$(GIT_VERSION)\"
# for dynamic linking
LIBS = -lssl -lcrypto
ifneq ($(OS), FreeBSD)
LIBS += -ldl
endif
# for static linking
ifeq ($(STATIC_BUILD), TRUE)
PWD = $(shell pwd)/static_libs
LDFLAGS += -L${PWD}/
CFLAGS += -I${PWD}/include/ -I${PWD}/ -I${PWD}/pcre/
LIBS = -lssl -lcrypto -lz -lpcre -levent
endif
ifneq ($(OS), FreeBSD)
LIBS += -ldl
endif
GIT_VERSION := $(GIT_VERSION)-static
.PHONY: all sslscanner clean install uninstall static
all: sslscanner
@echo
@echo "==========="
@echo "| WARNING |"
@echo "==========="
@echo
@echo "Building against system OpenSSL. Legacy protocol checks may not be possible."
@echo "It is recommended that you statically build sslscanner with \`make static\`."
@echo
sslscanner: $(SRCS)
ifeq ($(STATIC_BUILD), TRUE)
crystal build ${SRCS} --release --link-flags "-static ${LDFLAGS} ${CFLAGS} ${CPPFLAGS} ${DEFINES} ${LIBS} -I/usr/lib/" -o sslscanner
else
crystal build ${SRCS} --release -o sslscanner
endif
install:
@if [ ! -f sslscanner ] ; then \
echo "\n=========\n| ERROR |\n========="; \
echo "Before installing you need to build sslscanner with either \`make\` or \`make static\`\n"; \
exit 1; \
fi
ifeq ($(OS), Darwin)
install -d $(DESTDIR)$(BINDIR)/;
install sslscanner $(DESTDIR)$(BINDIR)/sslscanner;
else
install -D sslscanner $(DESTDIR)$(BINDIR)/sslscanner;
endif
uninstall:
rm -f $(DESTDIR)$(BINDIR)/sslscanner
static:
$(MAKE) sslscanner STATIC_BUILD=TRUE
clean:
rm -f scan