Makefile.Linux 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #
  2. # 3 proxy Makefile for GCC/Linux/Cygwin
  3. #
  4. # You can try to remove -DWITH_STD_MALLOC to CFLAGS to use optimized malloc
  5. # libraries
  6. #
  7. # remove -DNOODBC from CFLAGS and add -lodbc to LIBS to compile with ODBC
  8. # library support. Add -DSAFESQL for poorely written ODBC library / drivers.
  9. BUILDDIR = ../bin/
  10. CC = gcc
  11. CFLAGS = -g -O2 -fno-strict-aliasing -c -pthread -DWITHSPLICE -DGETHOSTBYNAME_R -D_THREAD_SAFE -D_REENTRANT -DNOODBC -DWITH_STD_MALLOC -DFD_SETSIZE=4096 -DWITH_POLL -DWITH_NETFILTER
  12. COUT = -o
  13. LN = gcc
  14. DCFLAGS = -fpic
  15. LDFLAGS = -O2 -fno-strict-aliasing -pthread
  16. DLFLAGS = -shared
  17. DLSUFFICS = .ld.so
  18. # -lpthreads may be reuqired on some platforms instead of -pthreads
  19. LIBSPREFIX = -l
  20. LIBSSUFFIX =
  21. LNOUT = -o
  22. EXESUFFICS =
  23. OBJSUFFICS = .o
  24. DEFINEOPTION = -D
  25. COMPFILES = *~
  26. REMOVECOMMAND = rm -f
  27. TYPECOMMAND = cat
  28. COMPATLIBS =
  29. MAKEFILE = Makefile.Linux
  30. # PamAuth requires libpam, you may require pam-devel package to be installed
  31. # SSLPlugin requires -lcrypto -lssl
  32. #LIBS = -lcrypto -lssl -ldl
  33. LIBS = -ldl
  34. #PLUGINS = SSLPlugin StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin PamAuth
  35. PLUGINS = StringsPlugin TrafficPlugin PCREPlugin TransparentPlugin
  36. include Makefile.inc
  37. allplugins:
  38. @list='$(PLUGINS)'; for p in $$list; do cp Makefile Makefile.var plugins/$$p; cd plugins/$$p ; make ; cd ../.. ; done
  39. DESTDIR =
  40. prefix =
  41. exec_prefix = $(prefix)
  42. man_prefix = /usr/share
  43. INSTALL = /usr/bin/install
  44. INSTALL_BIN = $(INSTALL) -m 755
  45. INSTALL_DATA = $(INSTALL) -m 644
  46. INSTALL_OBJS = bin/3proxy \
  47. bin/ftppr \
  48. bin/mycrypt \
  49. bin/pop3p \
  50. bin/proxy \
  51. bin/socks \
  52. bin/tcppm \
  53. bin/udppm
  54. INSTALL_CFG = scripts/3proxy.cfg.chroot
  55. INSTALL_CFG_OBJS = scripts/3proxy.cfg \
  56. scripts/add3proxyuser.sh
  57. INSTALL_CFG_OBJS2 = counters bandlimiters
  58. INSTALL_INITD_SCRIPT = scripts/init.d/3proxy.sh
  59. CHROOTDIR = $(DESTDIR)/usr/local/3proxy
  60. MANDIR1 = $(DESTDIR)$(man_prefix)/man/man1
  61. MANDIR3 = $(DESTDIR)$(man_prefix)/man/man3
  62. MANDIR8 = $(DESTDIR)$(man_prefix)/man/man8
  63. BINDIR = $(DESTDIR)$(exec_prefix)/bin
  64. ETCDIR = $(DESTDIR)$(prefix)/etc/3proxy
  65. INITDDIR = $(DESTDIR)$(prefix)/etc/init.d
  66. RUNDIR = $(DESTDIR)$(prefix)/var/run/3proxy
  67. LOGDIR = $(DESTDIR)$(prefix)/var/log/3proxy
  68. INSTALL_CFG_DEST = $(ETCDIR)/conf
  69. install-bin:
  70. $(INSTALL_BIN) -d $(BINDIR)
  71. $(INSTALL_BIN) -s $(INSTALL_OBJS) $(BINDIR)
  72. install-etc-dir:
  73. $(INSTALL_BIN) -d $(ETCDIR)
  74. install-chroot-dir:
  75. $(INSTALL_BIN) -d $(CHROOTDIR)
  76. $(INSTALL_BIN) -d $(CHROOTDIR)/conf
  77. $(INSTALL_BIN) -d $(CHROOTDIR)/logs
  78. $(INSTALL_BIN) -d $(CHROOTDIR)/count
  79. chmod -R o-rwx $(CHROOTDIR)
  80. install-etc-default-config:
  81. if [ ! -d $(INSTALL_CFG_DEST) ]; then \
  82. ln -s $(CHROOTDIR)/conf $(INSTALL_CFG_DEST); \
  83. $(INSTALL_BIN) $(INSTALL_CFG) $(ETCDIR)/3proxy.cfg; \
  84. $(INSTALL_BIN) $(INSTALL_CFG_OBJS) $(INSTALL_CFG_DEST); \
  85. fi
  86. install-etc: install-etc-dir install-etc-default-config
  87. for file in $(INSTALL_CFG_OBJS2); \
  88. do \
  89. touch $(INSTALL_CFG_DEST)/$$file; chmod 0600 $(INSTALL_CFG_DEST)/$$file; \
  90. done;
  91. install-man:
  92. $(INSTALL_BIN) -d $(MANDIR3)
  93. $(INSTALL_BIN) -d $(MANDIR8)
  94. $(INSTALL_DATA) man/*.3 $(MANDIR3)
  95. $(INSTALL_DATA) man/*.8 $(MANDIR8)
  96. install-init:
  97. if [ -f $(INITDIR) ]; then \
  98. $(INSTALL_BIN) $(INSTALL_INITD_SCRIPT) $(INITDDIR)/3proxy; \
  99. fi
  100. if [ -f /usr/sbin/update-rc.d ]; then \
  101. /usr/sbin/update-rc.d 3proxy defaults; \
  102. /usr/sbin/update-rc.d 3proxy enable; \
  103. fi
  104. install-run:
  105. $(INSTALL_BIN) -d $(RUNDIR)
  106. install-log:
  107. @if [ ! -d $(LOGDIR) ]; then \
  108. ln -s $(CHROOTDIR)/logs $(LOGDIR);\
  109. fi
  110. install: install-bin install-chroot-dir install-etc install-log install-man install-run install-init
  111. @getent passwd proxy || useradd -UMr -s /bin/false -c 3proxy proxy
  112. @if [ ! -f $(INSTALL_CFG_DEST)/passwd ]; then \
  113. touch $(INSTALL_CFG_DEST)/passwd;\
  114. stty -echo ;\
  115. echo "" ;\
  116. read -p "Proxy admin password: " password && $(INSTALL_CFG_DEST)/add3proxyuser.sh admin $password ;\
  117. stty echo ;\
  118. fi
  119. @chown -R proxy:proxy $(CHROOTDIR)
  120. @chmod 660 $(CHROOTDIR)/conf/*
  121. @echo ""
  122. @echo 3proxy installed.
  123. @echo use
  124. @echo " "$(INSTALL_CFG_DEST)/add3proxyuser.sh
  125. @echo to add users
  126. @echo ""
  127. @echo Default config uses Google DNS.
  128. @echo It's recommended to ues provider's DNS or install local recursor, e.g. pdns-recursor.
  129. @echo Configure preferred DNS in $(INSTALL_CFG_DEST)/3proxy.cfg.
  130. @if [ -f /usr/sbin/service ]; then \
  131. /usr/sbin/service 3proxy stop ;\
  132. /usr/sbin/service 3proxy start ;\
  133. fi