--- Makefile.orig 2024-01-21 13:41:31 UTC +++ Makefile @@ -1,12 +1,7 @@ # set gcc as default if CC is not set -GIT_VERSION = $(shell git describe --tags --always --dirty=-wip) +VERSION = $(shell grep -E -o -m 1 "[0-9]+\.[0-9]+\.[0-9]+" Changelog) -# 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) ARCH := $(shell uname -m) @@ -30,7 +25,7 @@ WARNINGS = -Wall -Wformat=2 -Wformat-security -Wno-de MAN1DIR = $(MANDIR)/man1 WARNINGS = -Wall -Wformat=2 -Wformat-security -Wno-deprecated-declarations -DEFINES = -DVERSION=\"$(GIT_VERSION)\" +DEFINES = -DVERSION=\"$(VERSION)\" # for dynamic linking LIBS = -lssl -lcrypto @@ -58,38 +53,12 @@ CFLAGS += -std=gnu11 CFLAGS += -std=gnu11 # for static linking -ifeq ($(STATIC_BUILD), TRUE) PWD = $(shell pwd)/openssl LDFLAGS += -L${PWD}/ CFLAGS += -I${PWD}/include/ -I${PWD}/ -ifeq ($(OS), Darwin) -LIBS = ./openssl/libssl.a ./openssl/libcrypto.a -lz -lpthread -else LIBS = -lssl -lcrypto -lz -lpthread -endif -ifneq ($(OS), FreeBSD) - LIBS += -ldl -endif -ifeq ($(OS), SunOS) - LIBS += -lsocket -lnsl -endif -GIT_VERSION := $(GIT_VERSION)-static -else -# for dynamic linking -LDFLAGS += -L/usr/local/lib -L/usr/local/ssl/lib -L/usr/local/opt/openssl/lib -L/opt/local/lib -CFLAGS += -I/usr/local/include -I/usr/local/ssl/include -I/usr/local/ssl/include/openssl -I/usr/local/opt/openssl/include -I/opt/local/include -I/opt/local/include/openssl -endif +VERSION := $(VERSION)-static -# Find the number of processors on the system (used in -j option in building OpenSSL). -# Uses /usr/bin/nproc if available, otherwise defaults to 1. -NUM_PROCS = 1 -ifneq (,$(wildcard /usr/bin/nproc)) - NUM_PROCS = `/usr/bin/nproc --all` -endif -ifeq ($(OS), Darwin) - NUM_PROCS = `sysctl -n hw.ncpu` -endif - .PHONY: all sslscan clean install uninstall static opensslpull all: sslscan @@ -116,6 +85,9 @@ ifeq ($(OS), Darwin) install sslscan $(DESTDIR)$(BINDIR)/sslscan; install -d $(DESTDIR)$(MAN1DIR)/; install sslscan.1 $(DESTDIR)$(MAN1DIR)/sslscan.1; +else ifeq ($(OS), FreeBSD) + install -s -m 755 sslscan $(DESTDIR)$(BINDIR) + install -m 644 sslscan.1 $(DESTDIR)$(MAN1DIR) else install -D sslscan $(DESTDIR)$(BINDIR)/sslscan; install -D sslscan.1 $(DESTDIR)$(MAN1DIR)/sslscan.1; @@ -128,11 +100,7 @@ opensslpull: .openssl.is.fresh: opensslpull true opensslpull: - if [ -d openssl -a -d openssl/.git ]; then \ - cd ./openssl && git checkout `git ls-remote https://github.com/openssl/openssl | grep -Eo '(openssl-3\.0\.[0-9]+)' | sort --version-sort | tail -n 1` && git pull | grep -q "Already up-to-date." && [ -e ../.openssl.is.fresh ] || touch ../.openssl.is.fresh ; \ - else \ - git clone --depth 1 -b `git ls-remote https://github.com/openssl/openssl | grep -Eo '(openssl-3\.0\.[0-9]+)' | sort -V | tail -n 1` https://github.com/openssl/openssl ./openssl && cd ./openssl && touch ../.openssl.is.fresh ; \ - fi + true # Need to build OpenSSL differently on OSX ifeq ($(OS), Darwin) @@ -146,16 +114,15 @@ openssl/Makefile: .openssl.is.fresh # Any other *NIX platform else openssl/Makefile: .openssl.is.fresh - cd ./openssl; ./config -v -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIC no-shared enable-weak-ssl-ciphers zlib + cd ./openssl; ./config -v -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIC no-shared enable-weak-ssl-ciphers zlib $(OSSL_TARGET) endif openssl/libcrypto.a: openssl/Makefile - $(MAKE) -j $(NUM_PROCS) -C openssl depend - $(MAKE) -j $(NUM_PROCS) -C openssl build_libs -# $(MAKE) -j $(NUM_PROCS) -C openssl test # Disabled because this takes 45+ minutes for OpenSSL v1.1.1. + $(MAKE) -C openssl depend + $(MAKE) -C openssl build_libs static: openssl/libcrypto.a - $(MAKE) -j $(NUM_PROCS) sslscan STATIC_BUILD=TRUE + $(MAKE) sslscan STATIC_BUILD=TRUE docker: docker build -t sslscan:sslscan .