Skip to content

Commit 5e1ca7c

Browse files
committed
finalized Makefile, worded COMPILING diff
1 parent 0e8b70f commit 5e1ca7c

File tree

2 files changed

+49
-50
lines changed

2 files changed

+49
-50
lines changed

COMPILING.md

+25-12
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,46 @@
1-
# Yet Another Traffic Bouncer
1+
# Yet Another Traffic Bouncer COMPILING
22

3-
## COMPILING
3+
## Make
44

5-
If you've installed OpenSSL as package just runnning `make linux` should work
5+
Always `make clean` first.
66

7-
If you compiled OpenSSL from source into '/usr/local', use the oneliners for your OS below
7+
If you've installed OpenSSL as package just runnning `make linux` should work.
88

9-
In case you used some other method to install OpenSSL, set environment variables accordingly
9+
If you compiled OpenSSL from source into '/usr/local', use the oneliners for your OS below.
10+
11+
In case you're on a different OS and/or used some other method to install OpenSSL you have set environment variables accordingly.
1012

1113
* `PREFIX` base directory used in variables
1214
* `OPENSSL_BIN` path to 'openssl' binary
1315
* `LDFLAGS` linker libraries
1416
* `LD_LIBRARY_PATH` needed to run openssl binary
1517
* `CPPFLAGS` C preprocessor includes
1618

17-
### Debian
19+
Make will first run `openssl dhparam -noout -C 2048 >>include/tls_dh.h`
20+
21+
We want to be sure 'make' can find the openssl binary and dependent shared libraries. This is why OPENSSL_BIN and LD_LIBRARY_PATH need to be set.
22+
23+
To run yatb LD_LIBRARY_PATH also needs to be set. You can print the libs required by runing `ldd yatb`.
24+
25+
### Debian
26+
27+
First compile:
1828

19-
* Make: `PREFIX="/usr/local" LDFLAGS="-L${PREFIX}/lib" LD_LIBRARY_PATH="${PREFIX}/lib" OPENSSL_BIN="${PREFIX}/bin/openssl" make linux`
20-
* Run: `LD_LIBRARY_PATH=/usr/local/lib ./yatb yatb.conf`
29+
`PREFIX="/usr/local" LDFLAGS="-L${PREFIX}/lib" LD_LIBRARY_PATH="${PREFIX}/lib" OPENSSL_BIN="${PREFIX}/bin/openssl" make linux`
30+
31+
Then start yatb:
32+
33+
`LD_LIBRARY_PATH=/usr/local/lib ./yatb yatb.conf`
2134

2235
### CentOS
2336

24-
* Make: `PREFIX="/usr/local" LDFLAGS="-L${PREFIX}/lib64" LD_LIBRARY_PATH="${PREFIX}/lib64" OPENSSL_BIN="${PREFIX}/bin/openssl" make linux`
25-
* Run: `LD_LIBRARY_PATH=/usr/local/lib64 ./yatb yatb.conf`
37+
`PREFIX="/usr/local" LDFLAGS="-L${PREFIX}/lib64" LD_LIBRARY_PATH="${PREFIX}/lib64" OPENSSL_BIN="${PREFIX}/bin/openssl" make linux`
38+
39+
`LD_LIBRARY_PATH=/usr/local/lib64 ./yatb yatb.conf`
2640

2741
### Wrapper
2842

29-
Or, create a little 'yatb.sh' wrapper script:
43+
For starting you could also create a small 'yatb.sh' wrapper script:
3044

3145
``` bash
3246
#!/bin/sh
@@ -39,4 +53,3 @@ if [ -x "yatb" ]; then
3953
LD_LIBRARY_PATH="/usr/local/lib" ./yatb "$@"
4054
fi
4155
```
42-

Makefile

+24-38
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,36 @@
33
CXX = g++
44
CXXFLAGS += -W -Wall
55
CPPFLAGS += -Iinclude
6-
6+
LDFLAGS += -lssl -lcrypto
77
OBJ = src/fpwhitelist.o src/whitelist.o src/iplist.o src/yatb.o src/forward.o src/controlthread.o src/datathread.o src/tls.o src/stringlist.o
88
OBJ_TOOLS = src/config.o src/lock.o src/counter.o src/tools.o
9-
LIBS = -lssl -lcrypto
9+
10+
TARGETS = linux linux-debug linux-static linux-debug-static \
11+
bsd bsd-debug bsd-static bsd-debug-static \
12+
cygwin cygwin-debug cygwin-static cygwin-debug-static \
13+
solaris solaris-debug solaris-static solaris-debug-static
1014

1115
ifneq ("$(findstring static,"$(MAKECMDGOALS)")","")
12-
LDFLAGS += -static
13-
SUFFIX := $(SUFFIX)-static
16+
LDFLAGS := -static $(LDFLAGS) -ldl -lz
17+
POSTFIX := $(POSTFIX)-static
1418
endif
15-
ifneq ("$(findstring debug, "$(MAKECMDGOALS)")","")
16-
LIBS += -ldl -lz
19+
ifneq ("$(findstring debug,"$(MAKECMDGOALS)")","")
1720
CXXFLAGS += -g
18-
SUFFIX := $(SUFFIX)-debug
21+
POSTFIX := $(POSTFIX)-debug
1922
else
2023
CXXLAGS += -O2
2124
endif
22-
23-
ifneq ("$(findstring cygwin, "$(MAKECMDGOALS)")","")
24-
SUFFIX := $(SUFFIX).exe
25+
ifneq ("$(findstring cygwin,"$(MAKECMDGOALS)")","")
26+
POSTFIX := $(POSTFIX).exe
2527
else
26-
LIBS += -lpthread
28+
LDFLAGS += -lpthread
2729
endif
28-
2930
OPENSSL_BIN ?= openssl
3031

32+
.PHONY: all yatb clean
33+
3134
.cc.o :
32-
g++ -c $(CPPFLAGS) $< -o $@
35+
$(CXX) -c $(CPPFLAGS) $< -o $@
3336

3437
all:
3538
@echo "To compile yatb type"
@@ -42,34 +45,17 @@ all:
4245
include/tls_dh.h :
4346
$(OPENSSL_BIN) dhparam -noout -C 2048 >>include/tls_dh.h
4447

45-
default: include/tls_dh.h $(OBJ) $(OBJ_TOOLS) src/blowcrypt.o src/bnccheck.o src/getfp.o
46-
$(CXX) $(LDFLAGS) $(OBJ) $(OBJ_TOOLS) $(LIBS) -o bin/yatb$(SUFFIX)
47-
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) src/blowcrypt.o $(OBJ_TOOLS) -o bin/blowcrypt$(SUFFIX) $(LIBS)
48-
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) src/bnccheck.o $(OBJ_TOOLS) -o bin/bnccheck$(SUFFIX) $(LIBS)
49-
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) src/getfp.o $(OBJ_TOOLS) -o bin/getfp$(SUFFIX) $(LIBS)
48+
yatb: include/tls_dh.h $(OBJ) $(OBJ_TOOLS) src/blowcrypt.o src/bnccheck.o src/getfp.o
49+
$(CXX) $(OBJ) $(OBJ_TOOLS) -o bin/yatb$(POSTFIX) $(LDFLAGS)
50+
$(CXX) $(CXXFLAGS) $(CPPFLAGS) src/blowcrypt.o $(OBJ_TOOLS) -o bin/blowcrypt$(POSTFIX) $(LDFLAGS)
51+
$(CXX) $(CXXFLAGS) $(CPPFLAGS) src/bnccheck.o $(OBJ_TOOLS) -o bin/bnccheck$(POSTFIX) $(LDFLAGS)
52+
$(CXX) $(CXXFLAGS) $(CPPFLAGS) src/getfp.o $(OBJ_TOOLS) -o bin/getfp$(POSTFIX) $(LDFLAGS)
5053
ifneq ($(findstring debug, "$@"),"")
51-
strip bin/yatb$(SUFFIX) bin/blowcrypt$(SUFFIX) bin/bnccheck$(SUFFIX) bin/getfp$(SUFFIX)
54+
strip bin/yatb$(POSTFIX) bin/blowcrypt$(POSTFIX) bin/bnccheck$(POSTFIX) bin/getfp$(POSTFIX)
5255
endif
5356

54-
linux: default
55-
linux-debug: default
56-
linux-static: default
57-
linux-debug-static: default
58-
59-
bsd: default
60-
bsd-debug: default
61-
bsd-static: default
62-
bsd-debug-static: default
63-
64-
cygwin: default
65-
cygwin-debug: default
66-
cygwin-static: default
67-
cygwin-debug-static: default
68-
69-
solaris: default
70-
solaris-debug: default
71-
solaris-static: default
72-
solaris-debug-static: default
57+
.PHONY: $(TARGETS)
58+
$(TARGETS): yatb
7359

7460
clean:
7561
@(rm -f bin/yatb bin/blowcrypt bin/yatb-static bin/blowcrypt-static bin/yatb-debug bin/blowcrypt-debug bin/yatb-static-debug bin/blowcrypt-static-debug bin/bnccheck bin/bnccheck-static bin/bnccheck-debug bin/bnccheck-static-debug bin/*.exe src/*.o bin/getfp* include/tls_dh.h)

0 commit comments

Comments
 (0)