1
0

Makefile 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. override ARCH ?= $(shell uname -m)
  2. ifeq ($(ARCH),arm64)
  3. override ARCH := aarch64
  4. endif
  5. TARGET := $(ARCH)-apple-macos10.12
  6. JOBS := $(shell getconf _NPROCESSORS_ONLN)
  7. GOROOT := $${PWD}/../dist/go
  8. GO := $(GOROOT)/bin/go
  9. ifeq ($(ARCH),x86_64)
  10. GOARCH := amd64
  11. else
  12. GOARCH := arm64
  13. endif
  14. .PHONY: all
  15. all:
  16. $(MAKE) ARCH=x86_64 shadowsocks-libev privoxy simple-obfs v2ray-plugin kcptun
  17. $(MAKE) ARCH=aarch64 shadowsocks-libev privoxy simple-obfs v2ray-plugin kcptun
  18. $(MAKE) universal
  19. .PHONY: universal
  20. universal:
  21. # shadowsocks-libev
  22. mkdir -p $${PWD}/dist/universal/shadowsocks-libev/bin
  23. lipo \
  24. $${PWD}/dist/x86_64/shadowsocks-libev/bin/ss-local \
  25. $${PWD}/dist/aarch64/shadowsocks-libev/bin/ss-local \
  26. -create \
  27. -output $${PWD}/dist/universal/shadowsocks-libev/bin/ss-local
  28. cp $${PWD}/dist/universal/shadowsocks-libev/bin/ss-local $${PWD}/../ShadowsocksX-NG/ss-local/
  29. # privoxy
  30. mkdir -p $${PWD}/dist/universal/privoxy/sbin
  31. lipo \
  32. $${PWD}/dist/x86_64/privoxy/sbin/privoxy \
  33. $${PWD}/dist/aarch64/privoxy/sbin/privoxy \
  34. -create \
  35. -output $${PWD}/dist/universal/privoxy/sbin/privoxy
  36. cp $${PWD}/dist/universal/privoxy/sbin/privoxy $${PWD}/../ShadowsocksX-NG/privoxy/
  37. # simple-obfs
  38. mkdir -p $${PWD}/dist/universal/simple-obfs/bin
  39. lipo \
  40. $${PWD}/dist/x86_64/simple-obfs/bin/obfs-local \
  41. $${PWD}/dist/aarch64/simple-obfs/bin/obfs-local \
  42. -create \
  43. -output $${PWD}/dist/universal/simple-obfs/bin/obfs-local
  44. cp $${PWD}/dist/universal/simple-obfs/bin/obfs-local $${PWD}/../ShadowsocksX-NG/simple-obfs/
  45. # v2ray-plugin
  46. mkdir -p $${PWD}/dist/universal/v2ray-plugin/bin
  47. lipo \
  48. $${PWD}/dist/x86_64/v2ray-plugin/bin/v2ray-plugin \
  49. $${PWD}/dist/aarch64/v2ray-plugin/bin/v2ray-plugin \
  50. -create \
  51. -output $${PWD}/dist/universal/v2ray-plugin/bin/v2ray-plugin
  52. cp $${PWD}/dist/universal/v2ray-plugin/bin/v2ray-plugin $${PWD}/../ShadowsocksX-NG/v2ray-plugin/
  53. # kcptun
  54. mkdir -p $${PWD}/dist/universal/kcptun/bin
  55. lipo \
  56. $${PWD}/dist/x86_64/kcptun/bin/client \
  57. $${PWD}/dist/aarch64/kcptun/bin/client \
  58. -create \
  59. -output $${PWD}/dist/universal/kcptun/bin/client
  60. cp $${PWD}/dist/universal/kcptun/bin/client $${PWD}/../ShadowsocksX-NG/kcptun/
  61. .PHONY: pcre
  62. pcre:
  63. [ -f pcre.tar.gz ] || curl -L -o pcre.tar.gz 'https://downloads.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz'
  64. tar -xf pcre.tar.gz
  65. cd pcre-8.45 \
  66. && CXXFLAGS="-target $(TARGET)" CFLAGS="-target $(TARGET)" ./configure --prefix $${PWD}/../dist/$(ARCH)/pcre \
  67. --host=$(TARGET) \
  68. --disable-dependency-tracking \
  69. --enable-utf8 \
  70. --enable-pcre8 \
  71. --enable-pcre16 \
  72. --enable-pcre32 \
  73. --enable-unicode-properties \
  74. --enable-pcregrep-libz \
  75. --enable-pcregrep-libbz2 \
  76. --enable-static \
  77. --disable-shared \
  78. && make -j$(JOBS) \
  79. && make install \
  80. && make clean
  81. .PHONY: libev
  82. libev:
  83. [ -f libev.tar.gz ] || curl -L -o libev.tar.gz 'http://dist.schmorp.de/libev/libev-4.33.tar.gz'
  84. tar -xf libev.tar.gz
  85. cd libev-4.33 \
  86. && CFLAGS="-target $(TARGET)" ./configure --prefix $${PWD}/../dist/$(ARCH)/libev \
  87. --host=$(TARGET) \
  88. --disable-dependency-tracking \
  89. --enable-static \
  90. --disable-shared \
  91. && make -j$(JOBS) \
  92. && make install \
  93. && make clean
  94. .PHONY: privoxy
  95. privoxy:
  96. [ -f privoxy.tar.gz ] || curl -L -o privoxy.tar.gz 'https://www.privoxy.org/sf-download-mirror/Sources/3.0.33%20%28stable%29/privoxy-3.0.33-stable-src.tar.gz'
  97. tar -xf privoxy.tar.gz
  98. cd privoxy-3.0.33-stable \
  99. && patch -Ru configure.in < $${PWD}/../patch/privoxy/configure.in.patch \
  100. && autoreconf -fi \
  101. && LDFLAGS="-target $(TARGET) -L$${PWD}/../dist/$(ARCH)/pcre/lib" \
  102. CPPFLAGS="-target $(TARGET) -Dunix -I$${PWD}/../dist/$(ARCH)/pcre/include" \
  103. CFLAGS="-target $(TARGET) -Dunix -I$${PWD}/../dist/$(ARCH)/pcre/include" \
  104. ./configure --prefix $${PWD}/../dist/$(ARCH)/privoxy \
  105. --host=$(TARGET) \
  106. --disable-debug \
  107. && make -j$(JOBS) \
  108. && make install \
  109. && make clean
  110. .PHONY: c-ares
  111. c-ares:
  112. cd c-ares \
  113. && autoreconf -fi \
  114. && CXXFLAGS="-target $(TARGET)" CFLAGS="-target $(TARGET)" ./configure --prefix=$${PWD}/../dist/$(ARCH)/c-ares \
  115. --host=$(TARGET) \
  116. --disable-dependency-tracking \
  117. --enable-static \
  118. --disable-shared \
  119. && make -j$(JOBS) \
  120. && make install \
  121. && make clean
  122. .PHONY: libsodium
  123. libsodium:
  124. cd libsodium \
  125. && ./autogen.sh \
  126. && CFLAGS="-target $(TARGET)" ./configure --prefix $${PWD}/../dist/$(ARCH)/libsodium \
  127. --host=$(TARGET) \
  128. --enable-static \
  129. --disable-shared \
  130. && make -j$(JOBS) \
  131. && make install \
  132. && make clean
  133. .PHONY: mbedtls
  134. mbedtls:
  135. cd mbedtls \
  136. && make CFLAGS="-target $(TARGET) -O2" LDFLAGS="-target $(TARGET) -O2" -j$(JOBS)\
  137. && make DESTDIR=$${PWD}/../dist/$(ARCH)/mbedtls install \
  138. && make clean
  139. .PHONY: shadowsocks-libev
  140. shadowsocks-libev: pcre libev c-ares libsodium mbedtls
  141. cd shadowsocks-libev \
  142. && ./autogen.sh \
  143. && CFLAGS="-target $(TARGET)" LDFLAGS="-lresolv" ./configure --prefix $${PWD}/../dist/$(ARCH)/shadowsocks-libev \
  144. --host=$(TARGET) \
  145. --disable-dependency-tracking \
  146. --enable-static \
  147. --disable-shared \
  148. --disable-documentation \
  149. --with-mbedtls=$${PWD}/../dist/$(ARCH)/mbedtls \
  150. --with-pcre=$${PWD}/../dist/$(ARCH)/pcre \
  151. --with-sodium=$${PWD}/../dist/$(ARCH)/libsodium \
  152. --with-cares=$${PWD}/../dist/$(ARCH)/c-ares \
  153. --with-ev=$${PWD}/../dist/$(ARCH)/libev \
  154. && make -j$(JOBS) \
  155. && make install \
  156. && make clean
  157. .PHONY: simple-obfs
  158. simple-obfs:
  159. cd simple-obfs \
  160. && ./autogen.sh \
  161. && CFLAGS="-target $(TARGET)" ./configure --prefix=$${PWD}/../dist/$(ARCH)/simple-obfs \
  162. --host=$(TARGET) \
  163. --disable-dependency-tracking \
  164. --disable-documentation \
  165. --enable-static \
  166. --disable-shared \
  167. --with-ev=$${PWD}/../dist/$(ARCH)/libev \
  168. && make -j$(JOBS) \
  169. && make install \
  170. && make clean
  171. .PHONY: v2ray-plugin
  172. v2ray-plugin: go
  173. cd v2ray-plugin \
  174. && GOROOT=$(GOROOT) GOOS=darwin GOARCH=$(GOARCH) \
  175. $(GO) build -trimpath -ldflags "-s -w" -o $${PWD}/../dist/$(ARCH)/v2ray-plugin/bin/v2ray-plugin
  176. .PHONY: kcptun
  177. kcptun: go
  178. cd kcptun \
  179. && GOROOT=$(GOROOT) GOOS=darwin GOARCH=$(GOARCH) \
  180. $(GO) build -trimpath -ldflags "-s -w" -o $${PWD}/../dist/$(ARCH)/kcptun/bin/client github.com/xtaci/kcptun/client
  181. .PHONY: go
  182. go:
  183. [ -d dist ] || mkdir dist
  184. ifeq ($(shell uname -m),arm64)
  185. [ -f dist/go.tar.gz ] || curl "https://dl.google.com/go/go1.18.darwin-arm64.tar.gz" --output dist/go.tar.gz
  186. else
  187. [ -f dist/go.tar.gz ] || curl "https://dl.google.com/go/go1.18.darwin-amd64.tar.gz" --output dist/go.tar.gz
  188. endif
  189. cd dist \
  190. && tar -zxf go.tar.gz
  191. clean:
  192. rm -rf dist
  193. rm -rf pcre*
  194. rm -rf libev*
  195. rm -rf privoxy*