2023-03-24 17:48:25 +08:00
|
|
|
CROSS_COMPILE ?=
|
|
|
|
CC := $(CROSS_COMPILE)gcc
|
|
|
|
STRIP := $(CROSS_COMPILE)strip
|
|
|
|
CFLAGS = -Wall -g -O3
|
2024-01-02 18:28:44 +08:00
|
|
|
LIB = -lssh2 -pthread
|
|
|
|
forward-tunnel = forward-tunnel
|
|
|
|
reverse-tunnel = reverse-tunnel
|
2023-03-24 17:48:25 +08:00
|
|
|
|
2024-08-07 16:48:01 +08:00
|
|
|
|
|
|
|
ip2region_SRC := ip2region/ip2region.c ip2region/xdb_searcher.c
|
|
|
|
ip2region_OBJS := $(ip2region_SRC:.c=.o)
|
|
|
|
ip2region_CFLAGS := -Os -g -Wall -I/ip2region
|
|
|
|
|
2024-01-02 18:28:44 +08:00
|
|
|
ifeq ($(shell uname -o), GNU/Linux)
|
|
|
|
ifeq ($(shell lsb_release -si), Debian)
|
|
|
|
LIB += -static
|
|
|
|
SSH2_LIB := $(shell pkg-config --static --libs --cflags libssh2)
|
|
|
|
else
|
|
|
|
SSH2_LIB := $(shell pkg-config --libs --cflags libssh2)
|
|
|
|
endif
|
|
|
|
endif
|
2023-03-24 17:48:25 +08:00
|
|
|
|
|
|
|
all:forward-tunnel reverse-tunnel
|
|
|
|
|
2024-08-07 16:48:01 +08:00
|
|
|
forward-tunnel: forward-tunnel.o thpool.o $(ip2region_OBJS)
|
2024-01-02 18:28:44 +08:00
|
|
|
$(CC) $(CFLAGS) -o $(forward-tunnel) $^ $(SSH2_LIB) $(LIB)
|
2023-06-05 11:47:35 +08:00
|
|
|
$(STRIP) forward-tunnel
|
2023-03-24 17:48:25 +08:00
|
|
|
|
|
|
|
reverse-tunnel: reverse-tunnel.o
|
2024-01-02 18:28:44 +08:00
|
|
|
$(CC) $(CFLAGS) -o $(reverse-tunnel) $^ $(SSH2_LIB) $(LIB)
|
2024-05-13 15:20:25 +08:00
|
|
|
: $(STRIP) reverse-tunnel
|
2023-03-24 17:48:25 +08:00
|
|
|
|
|
|
|
.c.o:
|
|
|
|
$(CC) $(CFLAGS) -c $<
|
|
|
|
|
2024-08-07 16:48:01 +08:00
|
|
|
ip2region/%.o: ip2region/%.c
|
|
|
|
$(CC) $(ip2region_CFLAGS) -c $< -o $@
|
|
|
|
|
2023-03-24 17:48:25 +08:00
|
|
|
clean:
|
2024-08-07 16:48:01 +08:00
|
|
|
rm -rf *.o $(ip2region_SRC:.c=.o)
|
|
|
|
rm -rf reverse-tunnel forward-tunnel
|