libssh2-tunnel/Makefile
2024-08-07 16:48:01 +08:00

42 lines
1.1 KiB
Makefile

CROSS_COMPILE ?=
CC := $(CROSS_COMPILE)gcc
STRIP := $(CROSS_COMPILE)strip
CFLAGS = -Wall -g -O3
LIB = -lssh2 -pthread
forward-tunnel = forward-tunnel
reverse-tunnel = reverse-tunnel
ip2region_SRC := ip2region/ip2region.c ip2region/xdb_searcher.c
ip2region_OBJS := $(ip2region_SRC:.c=.o)
ip2region_CFLAGS := -Os -g -Wall -I/ip2region
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
all:forward-tunnel reverse-tunnel
forward-tunnel: forward-tunnel.o thpool.o $(ip2region_OBJS)
$(CC) $(CFLAGS) -o $(forward-tunnel) $^ $(SSH2_LIB) $(LIB)
$(STRIP) forward-tunnel
reverse-tunnel: reverse-tunnel.o
$(CC) $(CFLAGS) -o $(reverse-tunnel) $^ $(SSH2_LIB) $(LIB)
: $(STRIP) reverse-tunnel
.c.o:
$(CC) $(CFLAGS) -c $<
ip2region/%.o: ip2region/%.c
$(CC) $(ip2region_CFLAGS) -c $< -o $@
clean:
rm -rf *.o $(ip2region_SRC:.c=.o)
rm -rf reverse-tunnel forward-tunnel