-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
90 lines (63 loc) · 2.25 KB
/
Copy pathmakefile
File metadata and controls
90 lines (63 loc) · 2.25 KB
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
############################################################################
# Copyright Nash!Com, Daniel Nashed 2024-2026 - APACHE 2.0 see LICENSE
############################################################################
CC=g++
CFLAGS=-g -Wall -c -fPIC -pedantic
# If OpenSSL statically linked is available compile and link statically with it
ifneq (,$(wildcard ../openssl/libssl.a))
LIBS=../openssl/libssl.a ../openssl/libcrypto.a -lresolv
SSL_INCLUDE_PATH=-I../openssl/include
$(info )
$(info Build with OpenSSL statically linked)
$(info )
# On MacOS if LibreSSL is available, statically with it
else ifneq (,$(wildcard /opt/local/lib/libssl.a))
LIBS=/opt/local/lib/libssl.a /opt/local/lib/libcrypto.a -lresolv -static
SSL_INCLUDE_PATH=-I/opt/local/include
$(info )
$(info Build with LibreSSL statically linked)
$(info )
$(info Some TLS/SSL logging functionality is not available on LibreSSL.)
$(info Consider using statically linked OpenSSL instead.)
$(info )
# Else just link dynamically with OpenSSL
else
LIBS = -lssl -lcrypto -lresolv
$(info )
$(info Build with OpenSSL dynamically linked)
$(info )
endif
ifeq ($(WITH_SFTP_SUPPORT),1)
$(info )
$(info Build with with SFTP support)
$(info )
CFLAGS += -DWITH_SFTP_SUPPORT
LIBS += -lssh2
endif
PROGRAM=nshmailx
TARGET?=$(PROGRAM)
all: $(TARGET)
$(TARGET): $(PROGRAM).o lib.o sftp.o testing.o
$(CC) -o $(PROGRAM) $(PROGRAM).o lib.o sftp.o testing.o $(LIBS) $(SPECIAL_LINK_OPTIONS)
$(PROGRAM).o: $(PROGRAM).cpp nshmailx.hpp testing.hpp
$(CC) $(CFLAGS) $(PROGRAM).cpp $(SSL_INCLUDE_PATH) -O2
lib.o: lib.cpp lib.hpp
$(CC) $(CFLAGS) lib.cpp $(SSL_INCLUDE_PATH) -O2
sftp.o: sftp.cpp sftp.hpp
$(CC) $(CFLAGS) sftp.cpp $(SSL_INCLUDE_PATH) -O2
testing.o: testing.cpp testing.hpp
$(CC) $(CFLAGS) testing.cpp $(SSL_INCLUDE_PATH) -O2
install: all
sudo cp -f $(PROGRAM) /usr/bin/nshmailx
mailx: install
sudo ln -s -f /usr/bin/nshmailx /usr/bin/mailx
sudo ln -s -f /usr/bin/nshmailx /usr/bin/mail
clean:
rm -f $(TARGET) *.o
test: all
./$(TARGET) --version
publish: all
mkdir -p /local/software/nashcom.de/linux-bin
cp -f ./$(TARGET) /local/software/nashcom.de/linux-bin
container_build:
docker run --rm -v .:/src -w /src -u 0 nashcom/alpine_build_env:latest sh -c 'SPECIAL_LINK_OPTIONS=-static make'