Makefile.Linux 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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 -D_GNU_SOURCE -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. RUNBASE = $(DESTDIR)$(prefix)/var/run
  67. RUNDIR = $(RUNBASE)/3proxy
  68. LOGBASE = $(DESTDIR)$(prefix)/var/log
  69. LOGDIR = $(LOGBASE)/3proxy
  70. INSTALL_CFG_DEST = $(ETCDIR)/conf
  71. install-bin:
  72. $(INSTALL_BIN) -d $(BINDIR)
  73. $(INSTALL_BIN) -s $(INSTALL_OBJS) $(BINDIR)
  74. $(INSTALL_BIN) -s bin/*.ld.so $(CHROOTDIR)/libexec
  75. chmod -R a-w $(CHROOTDIR)/libexec
  76. install-etc-dir:
  77. $(INSTALL_BIN) -d $(ETCDIR)
  78. install-chroot-dir:
  79. $(INSTALL_BIN) -d $(CHROOTDIR)
  80. $(INSTALL_BIN) -d $(CHROOTDIR)/conf
  81. $(INSTALL_BIN) -d $(CHROOTDIR)/logs
  82. $(INSTALL_BIN) -d $(CHROOTDIR)/count
  83. $(INSTALL_BIN) -d $(CHROOTDIR)/libexec
  84. chmod -R o-rwx $(CHROOTDIR)
  85. install-etc-default-config:
  86. if [ ! -d $(INSTALL_CFG_DEST) ]; then \
  87. ln -s $(CHROOTDIR)/conf $(INSTALL_CFG_DEST); \
  88. $(INSTALL_BIN) $(INSTALL_CFG) $(ETCDIR)/3proxy.cfg; \
  89. $(INSTALL_BIN) $(INSTALL_CFG_OBJS) $(INSTALL_CFG_DEST); \
  90. fi
  91. install-etc: install-etc-dir install-etc-default-config
  92. for file in $(INSTALL_CFG_OBJS2); \
  93. do \
  94. touch $(INSTALL_CFG_DEST)/$$file; chmod 0600 $(INSTALL_CFG_DEST)/$$file; \
  95. done;
  96. install-man:
  97. $(INSTALL_BIN) -d $(MANDIR3)
  98. $(INSTALL_BIN) -d $(MANDIR8)
  99. $(INSTALL_DATA) man/*.3 $(MANDIR3)
  100. $(INSTALL_DATA) man/*.8 $(MANDIR8)
  101. install-init:
  102. if [ -d $(INITDIR) ]; then \
  103. $(INSTALL_BIN) $(INSTALL_INITD_SCRIPT) $(INITDDIR)/3proxy; \
  104. fi
  105. if [ -f /usr/sbin/update-rc.d ]; then \
  106. /usr/sbin/update-rc.d 3proxy defaults; \
  107. /usr/sbin/update-rc.d 3proxy enable; \
  108. fi
  109. install-run:
  110. $(INSTALL_BIN) -d $(RUNDIR)
  111. install-log:
  112. @if [ -d $(LOGBASE) ] && [ ! -d $(LOGDIR) ]; then \
  113. ln -s $(CHROOTDIR)/logs $(LOGDIR);\
  114. fi
  115. install: install-chroot-dir install-bin install-etc install-log install-man install-run install-init
  116. @getent passwd proxy || useradd -UMr -s /bin/false -c 3proxy proxy
  117. @if [ ! -f $(INSTALL_CFG_DEST)/passwd ]; then \
  118. touch $(INSTALL_CFG_DEST)/passwd;\
  119. fi
  120. @chown -R proxy:proxy $(CHROOTDIR)
  121. @chmod 550 $(CHROOTDIR)/
  122. @chmod 550 $(CHROOTDIR)/conf/
  123. @chmod 440 $(CHROOTDIR)/conf/*
  124. @echo ""
  125. @echo 3proxy installed.
  126. @echo use
  127. @echo " "service 3proxy start
  128. @echo to start proxy
  129. @echo " "service 3proxy stop
  130. @echo to stop proxy
  131. @echo " "$(INSTALL_CFG_DEST)/add3proxyuser.sh
  132. @echo to add users
  133. @echo ""
  134. @echo Default config uses Google\'s DNS.
  135. @echo It\'s recommended to use provider supplied DNS or install local recursor, e.g. pdns-recursor.
  136. @echo Configure preferred DNS in $(INSTALL_CFG_DEST)/3proxy.cfg.
  137. @echo run \'$(INSTALL_CFG_DEST)/add3proxyuser.sh admin password\' to configure \'admin\' user
  138. @if [ -f /usr/sbin/service ]; then \
  139. /usr/sbin/service 3proxy stop ;\
  140. /usr/sbin/service 3proxy start ;\
  141. fi