-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMakefile
More file actions
120 lines (91 loc) · 2.39 KB
/
Makefile
File metadata and controls
120 lines (91 loc) · 2.39 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
MAJOR = 0
MINOR = 2
PATCH = 1
NAME = socksd
ifdef O
ifeq ("$(origin O)", "command line")
BUILD_DIR := $(O)
endif
endif
ifneq ($(BUILD_DIR),)
saved-output := $(BUILD_DIR)
# Attempt to create a output directory.
$(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR})
# Verify if it was successful.
BUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd)
$(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist))
endif # ifneq ($(BUILD_DIR),)
OBJTREE := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))
SRCTREE := $(CURDIR)
TOPDIR := $(SRCTREE)
export TOPDIR SRCTREE OBJTREE
#########################################################################
ifdef HOST
CROSS_COMPILE = $(HOST)-
endif
# for OpenWrt
ifdef CROSS
CROSS_COMPILE = $(CROSS)
HOST = $(patsubst %-,%,$(CROSS_COMPILE))
ifneq (,$(findstring openwrt,$(CROSS_COMPILE)))
OPENWRT = 1
endif
endif
ifdef CROSS_COMPILE
CPPFLAGS = -DCROSS_COMPILE
endif
CFLAGS = \
-Os \
-g \
-std=gnu99 \
-Wall \
$(PLATFORM_CFLAGS)
CFLAGS += -fomit-frame-pointer -fdata-sections -ffunction-sections
EXTRA_CFLAGS =
#########################################################################
CPPFLAGS += -Isrc
CPPFLAGS += -I3rd/libuv/include -I3rd/udns
LDFLAGS = -Wl,--gc-sections
LIBS += -pthread -ldl -lrt
LIBS += 3rd/libuv/.libs/libuv.a 3rd/udns/libudns.a
LDFLAGS += $(LIBS)
#########################################################################
include $(TOPDIR)/config.mk
#########################################################################
all: libuv udns socksd
3rd/libuv/autogen.sh:
$(Q)git submodule update --init
3rd/libuv/Makefile: | 3rd/libuv/autogen.sh
$(Q)cd 3rd/libuv && ./autogen.sh && ./configure --host=$(HOST) LDFLAGS= && $(MAKE)
libuv: 3rd/libuv/Makefile
3rd/udns/configure:
$(Q)git submodule update --init
3rd/udns/Makefile: | 3rd/udns/configure
$(Q)cd 3rd/udns && ./configure && $(MAKE)
udns: 3rd/udns/Makefile
socksd: \
src/util.o \
src/logger.o \
src/resolver.o \
src/consumer.o \
src/dispatcher.o \
src/daemon.o \
src/signal.o \
src/cache.o \
src/md5.o \
src/udprelay.o \
src/client.o \
src/remote.o \
src/main.o
$(LINK) $^ -o $(OBJTREE)/$@ $(LDFLAGS)
clean:
@find $(OBJTREE) -type f \
\( -name '*.bak' -o -name '*~' \
-o -name '*.o' -o -name '*.tmp' \) -print \
| xargs rm -f
@rm -f socksd
distclean: clean
$(Q)cd 3rd/libuv && make distclean
$(Q)cd 3rd/udns && make distclean
install:
$(Q)cp socksd /usr/local/bin