Advertisement
OstermanA

Python3 Makefile

Feb 5th, 2019 (edited)
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 22.62 KB | None | 0 0
  1. # Initialize env vars
  2. ifndef PREFIX
  3. PREFIX=$(shell dirname $(shell dirname $(PWD)))/python3
  4. endif
  5.  
  6. PATH := $(PREFIX)/bin:$(PREFIX)/sbin:$(PATH)
  7. LDFLAGS = -Wl,-rpath,$(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib64 -L$(PREFIX)/lib -L$(PREFIX)/lib64
  8. CFLAGS = -Wl,-rpath,$(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib64 -I$(PREFIX)/include
  9. CPPFLAGS = $(CFLAGS)
  10. PKG_CONFIG_PATH = $(PREFIX)/lib/pkgconfig
  11.  
  12. export PATH LDFLAGS CFLAGS CPPFLAGS PKG_CONFIG_PATH PREFIX
  13.  
  14. ifndef NOCOLORS
  15. RED=\033[0;31m
  16. YEL=\033[0;33m
  17. GRE=\033[0;32m
  18. # No Color
  19. NC=\033[0m
  20. endif
  21.  
  22. # Software Package Versions
  23. bzip2=1.0.8
  24. cyrussasl=2.1.27
  25. expat=2.2.10
  26. gdbm=1.19
  27. libffi=3.3
  28. ncurses=6.2
  29. openldap=2.4.57
  30. openssl=1.1.1h
  31. readline=8.1
  32. sqlite3=3.34.1
  33. sqlite3_year=2021
  34. python3=3.9.1
  35. xz=5.2.5
  36. zlib=1.2.11
  37.  
  38. # Software filenames
  39. bzip2file=bzip2-$(bzip2).tar.gz
  40. cyrussaslfile=cyrus-sasl-$(cyrussasl).tar.gz
  41. expatfile=expat-$(expat).tar.bz2
  42. gdbmfile=gdbm-$(gdbm).tar.gz
  43. libffifile=libffi-$(libffi).tar.gz
  44. ncursesfile=ncurses-$(ncurses).tar.gz
  45. openldapfile=openldap-$(openldap).tgz
  46. opensslfile=openssl-$(openssl).tar.gz
  47. python3file=Python-$(python3).tgz
  48. readlinefile=readline-$(readline).tar.gz
  49. sqlite3file=sqlite-autoconf-$(shell printf '%d%02d%02d%02d' $(subst ., ,$(sqlite3))).tar.gz
  50. xzfile=xz-$(xz).tar.bz2
  51. zlibfile=zlib-$(zlib).tar.gz
  52.  
  53. # Software sources
  54. bzip2source=https://sourceware.org/pub/bzip2/$(bzip2file)
  55. cyrussaslsource=https://github.com/cyrusimap/cyrus-sasl/releases/download/cyrus-sasl-$(cyrussasl)/$(cyrussaslfile)
  56. expatsource=https://github.com/libexpat/libexpat/releases/download/R_$(subst .,_,$(expat))/$(expatfile)
  57. gdbmsource=https://ftp.gnu.org/gnu/gdbm/$(gdbmfile)
  58. libffisource=ftp://sourceware.org/pub/libffi/$(libffifile)
  59. ncursessource=ftp://ftp.gnu.org/gnu/ncurses/$(ncursesfile)
  60. openldapsource=ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/$(openldapfile)
  61. opensslsource=https://www.openssl.org/source/$(opensslfile)
  62. readlinesource=ftp://ftp.gnu.org/gnu/readline/$(readlinefile)
  63. sqlite3source=https://www.sqlite.org/$(sqlite3_year)/$(sqlite3file)
  64. python3source=https://www.python.org/ftp/python/$(python3)/$(python3file)
  65. xzsource=https://tukaani.org/xz/$(xzfile)
  66. zlibsource=https://zlib.net/$(zlibfile)
  67.  
  68. # Software dir names
  69. bzip2dir=$(basename $(basename $(bzip2file)))
  70. cyrussasldir=$(basename $(basename $(cyrussaslfile)))
  71. expatdir=$(basename $(basename $(expatfile)))
  72. gdbmdir=$(basename $(basename $(gdbmfile)))
  73. libffidir=$(basename $(basename $(libffifile)))
  74. ncursesdir=$(basename $(basename $(ncursesfile)))
  75. openldapdir=$(basename $(openldapfile))
  76. openssldir=$(basename $(basename $(opensslfile)))
  77. readlinedir=$(basename $(basename $(readlinefile)))
  78. sqlite3dir=$(basename $(basename $(sqlite3file)))
  79. python3dir=$(basename $(python3file))
  80. xzdir=$(basename $(basename $(xzfile)))
  81. zlibdir=$(basename $(basename $(zlibfile)))
  82.  
  83. $(VERBOSE).SILENT:
  84.  
  85. .PHONY: \
  86.     help \
  87.     clean \
  88.     bzip2 \
  89.     cyrussasl \
  90.     expat \
  91.     gdbm \
  92.     libffi \
  93.     ncurses \
  94.     openldap \
  95.     openssl \
  96.     readline \
  97.     sqlite3 \
  98.     python3 \
  99.     xz \
  100.     zlib \
  101.     python-update \
  102.     ansible \
  103.     python-ldap
  104.  
  105. help:
  106.     echo "Makefile for Python $(python3) and dependencies."
  107.     echo "Will build artifacts and install them to PREFIX=$(PREFIX)"
  108.     echo "If PREFIX is set as an environment variable this Makefile will use it."
  109.     echo
  110.     echo "Any source code needed will be retrieved."
  111.     echo "Any targets will automatically build and install dependencies."
  112.     echo "Note: OpenSSL is compiled without compression support for additional security."
  113.     echo
  114.     printf "%-12s %-8s %s\n" "TARGET" "VERSION" "DEPENDENCIES"
  115.     printf "%-12s %-8s %s\n" "bzip2" "$(bzip2)" "None"
  116.     printf "%-12s %-8s %s\n" "cyrussasl" "$(cyrussasl)" "gdbm openssl sqlite3"
  117.     printf "%-12s %-8s %s\n" "expat" "$(expat)" "None"
  118.     printf "%-12s %-8s %s\n" "gdbm" "$(gdbm)" "ncurses openssl readline"
  119.     printf "%-12s %-8s %s\n" "libffi" "$(libffi)" "None"
  120.     printf "%-12s %-8s %s\n" "ncurses" "$(ncurses)" "None"
  121.     printf "%-12s %-8s %s\n" "openldap" "$(openldap)" "cyrussasl openssl"
  122.     printf "%-12s %-8s %s\n" "openssl" "$(openssl)" "None"
  123.     printf "%-12s %-8s %s\n" "readline" "$(readline)" "ncurses"
  124.     printf "%-12s %-8s %s\n" "sqlite3" "$(sqlite3)" "readline"
  125.     printf "%-12s %-8s %s\n" "python3" "$(python3)" "bzip2 expat gdbm libffi ncurses openssl readline sqlite3 xz zlib"
  126.     printf "%-12s %-8s %s\n" "xz" "$(xz)" "None"
  127.     printf "%-12s %-8s %s\n" "zlib" "$(zlib)" "None"
  128.     echo
  129.     echo "Python module targets:"
  130.     printf "%-12s %-8s %s\n" "ansible" "auto" "None"
  131.     printf "%-12s %-8s %s\n" "python-ldap" "auto" "openldap python-update"
  132.     echo
  133.     echo "Special build targets:"
  134.     echo "all            Synonym for \`python3 ansible python-ldap\`"
  135.     echo "help           Displays this message"
  136.     echo "clean          Removes temp source directories"
  137.     echo "python-update  Updates pip, setuptools and wheel to latest verions"
  138.     echo
  139.     echo "Set these environment vars to any non-null value to turn them on:"
  140.     echo -e "NOCOLORS   Disable logging $(GRE)co$(NC)$(YEL)lo$(NC)$(RED)rs$(NC)"
  141.     echo "NOTESTS    Skip 'make check' and 'make test'"
  142.     echo "NOPREREQS  Skip building prerequisites."
  143.     echo "VERBOSE    Show debug messages."
  144.  
  145. all: python3 ansible python-ldap
  146.  
  147. prebuild:
  148.     echo -e "$(GRE)INFO$(NC): Build parameters:"
  149.     echo -e "$(GRE)INFO$(NC): PREFIX=$(PREFIX)"
  150.     echo -e "$(GRE)INFO$(NC): PATH=$(PATH)"
  151.     echo -e "$(GRE)INFO$(NC): LDFLAGS=$(LDFLAGS)"
  152.     echo -e "$(GRE)INFO$(NC): CFLAGS=$(CFLAGS)"
  153.     echo -e "$(GRE)INFO$(NC): CPPFLAGS=$(CPPFLAGS)"
  154.     echo -e "$(GRE)INFO$(NC): PKG_CONFIG_PATH=$(PKG_CONFIG_PATH)"
  155.     if [[ ! -d "$(PREFIX)" ]]; then echo -e "$(GRE)INFO$(NC): Creating directory $(PREFIX)"; mkdir -p "$(PREFIX)"; fi
  156.  
  157. bzip2: prebuild
  158.     echo "#########################################"
  159.     echo -e "$(GRE)INFO$(NC): Building bzip2 $(bzip2)"
  160.     echo -e "$(GRE)INFO$(NC): bzip2file=$(bzip2file)"
  161.     echo -e "$(GRE)INFO$(NC): bzip2source=$(bzip2source)"
  162.    
  163.     test -f "$(bzip2file)" \
  164.     && echo -e "$(GRE)INFO$(NC): Found $(bzip2file)" \
  165.     || (echo -e "$(GRE)INFO$(NC): Retrieving $(bzip2source)"; curl -Lso "$(bzip2file)" "$(bzip2source)")
  166.     tar -xf "$(bzip2file)"
  167.    
  168.     #   If bin/bz{egrep,fgrep,less,cmp} already exists, then the bzip2 install process fails and aborts the entire build.
  169.     #
  170.     # Makefile-libbz2_so builds a Linux ELF shared library, used to link to other apps dynamically.
  171.     cd "$(bzip2dir)" \
  172.     && make -f Makefile-libbz2_so \
  173.     && rm -f "$(PREFIX)"/bin/bz{egrep,fgrep,less,cmp} \
  174.     && make install PREFIX="$(PREFIX)"
  175.  
  176. ifndef NOPREREQS
  177. cyrussasl: prebuild gdbm openssl sqlite3
  178. else
  179. cyrussasl: prebuild
  180. endif
  181.     # This is the bootstrap version of cyrus-sasl, built without openldap.
  182.     #   With this, openldap can build with SASL support, allowing us to rebuild
  183.     #       with cyrussasl_ldap to have both linked to the other.
  184.     echo "#########################################"
  185.     echo -e "$(GRE)INFO$(NC): Building cyrussasl $(cyrussasl) without OpenLDAP support"
  186.     echo -e "$(GRE)INFO$(NC): cyrussaslfile=$(cyrussaslfile)"
  187.     echo -e "$(GRE)INFO$(NC): cyrussaslsource=$(cyrussaslsource)"I mean, ncurses-6.2
  188.    
  189.     test -f "$(cyrussaslfile)" \
  190.     && echo -e "$(GRE)INFO$(NC): Found $(cyrussaslfile)" \
  191.     || (echo -e "$(GRE)INFO$(NC): Retrieving $(cyrussaslsource)"; curl -Lso "$(cyrussaslfile)" "$(cyrussaslsource)")
  192.     tar -xf "$(cyrussaslfile)"
  193.    
  194.     # The build didn't seem to be honoring my CFLAGS to set the rpath, so I forced the issue with CC
  195.     #
  196.     #   Setting both --with-plugindir and SASL_PATH hoping at least one of them will bake into the libs.
  197.     #       I'm not holding my breath, though. SASL_PATH may need to be exported at runtime.
  198.     cd "$(cyrussasldir)" \
  199.     && ./configure \
  200.         --prefix="$(PREFIX)" \
  201.         --enable-shared \
  202.         --enable-static \
  203.         --with-dblib=gdbm \
  204.         --with-gdbm="$(PREFIX)" \
  205.         --with-openssl="$(PREFIX)" \
  206.         --with-sqlite3="$(PREFIX)" \
  207.         --with-plugindir="$(PREFIX)/lib/sasl2" \
  208.         CC="gcc -Wl,-rpath,$(PREFIX)/lib" \
  209.         SASL_PATH="$(PREFIX)/lib/sasl2" \
  210.     && make \
  211.     && ( \
  212.         [[ -n "$$NOTEST" ]] \
  213.         && echo -e "$(YEL)WARN$(NC): Skipping make check" \
  214.         || make check \
  215.         || echo -e "$(RED)ERROR$(NC): make check failed, please check log." \
  216.     ) \
  217.     && make install
  218.  
  219. ifndef NOPREREQS
  220. cyrussasl_ldap: prebuild gdbm openssl sqlite3
  221. else
  222. cyrussasl_ldap: prebuild
  223. endif
  224.     echo "#########################################"
  225.     echo -e "$(GRE)INFO$(NC): Building cyrussasl $(cyrussasl) with OpenLDAP support"
  226.     echo -e "$(GRE)INFO$(NC): cyrussaslfile=$(cyrussaslfile)"
  227.     echo -e "$(GRE)INFO$(NC): cyrussaslsource=$(cyrussaslsource)"I mean, ncurses-6.2
  228.    
  229.     test -f "$(cyrussaslfile)" \
  230.     && echo -e "$(GRE)INFO$(NC): Found $(cyrussaslfile)" \
  231.     || (echo -e "$(GRE)INFO$(NC): Retrieving $(cyrussaslsource)"; curl -Lso "$(cyrussaslfile)" "$(cyrussaslsource)")
  232.     mkdir "$(cyrussasldir)_ldap"
  233.     tar -xf "$(cyrussaslfile)" -C "$(cyrussasldir)_ldap" --strip-components 1
  234.    
  235.     # The build didn't seem to be honoring my CFLAGS to set the rpath, so I forced the issue with CC
  236.     #
  237.     #   Setting both --with-plugindir and SASL_PATH hoping at least one of them will bake into the libs.
  238.     #       I'm not holding my breath, though. SASL_PATH may need to be exported at runtime.
  239.     cd "$(cyrussasldir)_ldap" \
  240.     && ./configure \
  241.         --prefix="$(PREFIX)" \
  242.         --enable-shared \
  243.         --enable-static \
  244.         --with-dblib=gdbm \
  245.         --with-gdbm="$(PREFIX)" \
  246.         --with-ldap="$(PREFIX)" \
  247.         --with-openssl="$(PREFIX)" \
  248.         --with-sqlite3="$(PREFIX)" \
  249.         --with-plugindir="$(PREFIX)/lib/sasl2" \
  250.         CC="gcc -Wl,-rpath,$(PREFIX)/lib" \
  251.         SASL_PATH="$(PREFIX)/lib/sasl2" \
  252.     && make \
  253.     && ( \
  254.         [[ -n "$$NOTEST" ]] \
  255.         && echo -e "$(YEL)WARN$(NC): Skipping make check" \
  256.         || make check \
  257.         || echo -e "$(RED)ERROR$(NC): make check failed, please check log." \
  258.     ) \
  259.     && make install
  260.  
  261. expat: prebuild
  262.     echo "#########################################"
  263.     echo -e "$(GRE)INFO$(NC): Building expat $(expat)"
  264.     echo -e "$(GRE)INFO$(NC): expatfile=$(expatfile)"
  265.     echo -e "$(GRE)INFO$(NC): expatsource=$(expatsource)"
  266.    
  267.     test -f "$(expatfile)" \
  268.     && echo -e "$(GRE)INFO$(NC): Found $(expatfile)" \
  269.     || (echo -e "$(GRE)INFO$(NC): Retrieving $(expatsource)"; curl -Lso "$(expatfile)" "$(expatsource)")
  270.     tar -xf "$(expatfile)"
  271.    
  272.     cd "$(expatdir)" \
  273.     && ./configure \
  274.         --prefix="$(PREFIX)" \
  275.         --enable-shared \
  276.         --enable-static \
  277.     && make \
  278.     && ( \
  279.         [[ -n "$$NOTEST" ]] \
  280.         && echo -e "$(YEL)WARN$(NC): Skipping make check" \
  281.         || make check \
  282.         || echo -e "$(RED)ERROR$(NC): make check failed, please check log." \
  283.     ) \
  284.     && make install
  285.  
  286. ifndef NOPREREQS
  287. gdbm: prebuild ncurses openssl readline
  288. else
  289. gdbm: prebuild
  290. endif
  291.     echo "#########################################"
  292.     echo -e "$(GRE)INFO$(NC): Building gdbm $(gdbm)"
  293.     echo -e "$(GRE)INFO$(NC): gdbmfile=$(gdbmfile)"
  294.     echo -e "$(GRE)INFO$(NC): gdbmsource=$(gdbmsource)"
  295.    
  296.     test -f "$(gdbmfile)" \
  297.     && echo -e "$(GRE)INFO$(NC): Found $(gdbmfile)" \
  298.     || (echo -e "$(GRE)INFO$(NC): Retrieving $(gdbmsource)"; curl -Lso "$(gdbmfile)" "$(gdbmsource)")
  299.     tar -xf "$(gdbmfile)"
  300.    
  301.     #   Python's _gdm looks for $(PREFIX)/include/gdbm/ndbm.h
  302.     #   so --enable-libgdbm-compat and COMPATINCLUDEDIR are necessary.
  303.     #
  304.     #   LIBS is used to massage it into successfully finding
  305.     #       libtinfow and libncursesw for readline and ncurses
  306.     cd "$(gdbmdir)" \
  307.     && LIBS="-ltinfow -lncursesw" \
  308.         COMPATINCLUDEDIR="$(PREFIX)/include/gdbm" \
  309.         ./configure \
  310.         --prefix="$(PREFIX)" \
  311.         --enable-libgdbm-compat \
  312.         --with-readline \
  313.     && make \
  314.     && ( \
  315.         [[ -n "$$NOTEST" ]] \
  316.         && echo -e "$(YEL)WARN$(NC): Skipping make check" \
  317.         || make check \
  318.         || echo -e "$(RED)ERROR$(NC): make check failed, please check log." \
  319.     ) \
  320.     && make install
  321.  
  322. libffi: prebuild
  323.     echo "#########################################"
  324.     echo -e "$(GRE)INFO$(NC): Building libffi $(libffi)"
  325.     echo -e "$(GRE)INFO$(NC): libffifile=$(libffifile)"
  326.     echo -e "$(GRE)INFO$(NC): libffisource=$(libffisource)"
  327.    
  328.     test -f "$(libffifile)" \
  329.     && echo -e "$(GRE)INFO$(NC): Found $(libffifile)" \
  330.     || (echo -e "$(GRE)INFO$(NC): Retrieving $(libffisource)"; curl -Lso "$(libffifile)" "$(libffisource)")
  331.     tar -xf "$(libffifile)"
  332.    
  333.     cd "$(libffidir)" \
  334.     && ./configure \
  335.         --prefix="$(PREFIX)" \
  336.         --enable-shared \
  337.         --enable-static \
  338.     && make \
  339.     && ( \
  340.         [[ -n "$$NOTEST" ]] \
  341.         && echo -e "$(YEL)WARN$(NC): Skipping make check" \
  342.         || make check \
  343.         || echo -e "$(RED)ERROR$(NC): make check failed, please check log." \
  344.     ) \
  345.     && make install
  346.  
  347. ncurses: prebuild
  348.     echo "#########################################"
  349.     echo -e "$(GRE)INFO$(NC): Building ncurses $(ncurses)"
  350.     echo -e "$(GRE)INFO$(NC): ncursesfile=$(ncursesfile)"
  351.     echo -e "$(GRE)INFO$(NC): ncursessource=$(ncursessource)"
  352.    
  353.     test -f "$(ncursesfile)" \
  354.     && echo -e "$(GRE)INFO$(NC): Found $(ncursesfile)" \
  355.     || (echo -e "$(GRE)INFO$(NC): Retrieving $(ncursessource)"; curl -Lso "$(ncursesfile)" "$(ncursessource)")
  356.     tar -xf "$(ncursesfile)"
  357.    
  358.     cd "$(ncursesdir)" \
  359.     && ./configure \
  360.         --prefix="$(PREFIX)" \
  361.         --with-shared \
  362.         --with-profile \
  363.         --with-cxx-shared \
  364.         --with-termlib \
  365.         --enable-rpath \
  366.         --enable-termcap \
  367.         --enable-symlinks \
  368.         --enable-broken_linker \
  369.         --enable-widec \
  370.         --enable-ext-colors \
  371.         --enable-ext-mouse \
  372.         --enable-ext-putwin \
  373.         --enable-no-padding \
  374.         --enable-signed-char \
  375.         --enable-sigwinch \
  376.         --enable-tcap-names \
  377.         --with-pthread \
  378.         --enable-pthreads-eintr \
  379.         --enable-weak-symbols \
  380.         --enable-reentrant \
  381.         --enable-opaque-curses \
  382.         --enable-opaque-form \
  383.         --enable-opaque-menu \
  384.         --enable-opaque-panel \
  385.         --enable-hard-tabs \
  386.         --enable-xmc-glitch \
  387.     && make \
  388.     && make install
  389.  
  390. #   This bit of ridiculousness is to deal with the circular dependency between cyrussasl and openldap.
  391. #
  392. #   If we're not building pre-reqs then it can just build, using the "openldap" target.
  393. #
  394. #   If we are building pre-reqs then we need to build cyrussasl without ldap first, build _openldap,
  395. #       then build cyrussasl again but with ldap support.
  396. ifndef NOPREREQS
  397. openldap: prebuild cyrussasl _openldap cyrussasl_ldap openssl
  398.  
  399. _openldap: prebuild
  400. else
  401. openldap: prebuild
  402. endif
  403.     echo "#########################################"
  404.     echo -e "$(GRE)INFO$(NC): Building openldap $(openldap)"
  405.     echo -e "$(GRE)INFO$(NC): openldapfile=$(openldapfile)"
  406.     echo -e "$(GRE)INFO$(NC): openldapsource=$(openldapsource)"
  407.    
  408.     test -f "$(openldapfile)" \
  409.     && echo -e "$(GRE)INFO$(NC): Found $(openldapfile)" \
  410.     || (echo -e "$(GRE)INFO$(NC): Retrieving $(openldapsource)"; curl -Lso "$(openldapfile)" "$(openldapsource)")
  411.     tar -xf "$(openldapfile)"
  412.    
  413.     #   BerkeleyDB appears to be a mess of license hell. OpenLDAP refuses to use any modern version.
  414.     #       So, disablinig bdb and hdb to avoid the dependency.
  415.     cd "$(openldapdir)" \
  416.     && ./configure \
  417.         --prefix="$(PREFIX)" \
  418.         --enable-spasswd \
  419.         --disable-bdb \
  420.         --disable-hdb \
  421.         --with-cyrus-sasl \
  422.         --with-tls \
  423.     && make \
  424.     && ( \
  425.         [[ -n "$$NOTEST" ]] \
  426.         && echo -e "$(YEL)WARN$(NC): Skipping make test" \
  427.         || make test \
  428.         || echo -e "$(RED)ERROR$(NC): make test failed, please check log." \
  429.     ) \
  430.     && make install
  431.  
  432. openssl: prebuild
  433.     echo "#########################################"
  434.     echo -e "$(GRE)INFO$(NC): Building openssl $(openssl)"
  435.     echo -e "$(GRE)INFO$(NC): opensslfile=$(opensslfile)"
  436.     echo -e "$(GRE)INFO$(NC): opensslsource=$(opensslsource)"
  437.    
  438.     test -f "$(opensslfile)" \
  439.     && echo -e "$(GRE)INFO$(NC): Found $(opensslfile)" \
  440.     || (echo -e "$(GRE)INFO$(NC): Retrieving $(opensslsource)"; curl -Lso "$(opensslfile)" "$(opensslsource)")
  441.     tar -xf "$(opensslfile)"
  442.    
  443.     #   Adding no-comp, as I have seen hints that compression may have unforseen consequences on security.
  444.     #
  445.     #   Using "install_sw install_ssldirs" instead of just "install" to avoid installing the documentation.
  446.     cd "$(openssldir)" \
  447.     && ./config \
  448.         --prefix="$(PREFIX)" \
  449.         --openssldir="$(PREFIX)" \
  450.         threads \
  451.         shared \
  452.         no-comp \
  453.         "$(CFLAGS)" \
  454.     && make depend \
  455.     && make \
  456.     && echo -e "$(YEL)WARN$(NC): Skipping make test" \
  457.     && make install_sw install_ssldirs
  458.  
  459. ifndef NOPREREQS
  460. python3: prebuild bzip2 expat gdbm libffi ncurses openssl readline sqlite3 zlib
  461. else
  462. python3: prebuild
  463. endif
  464.     echo "#########################################"
  465.     echo -e "$(GRE)INFO$(NC): Building python3 $(python3)"
  466.     echo -e "$(GRE)INFO$(NC): python3file=$(python3file)"
  467.     echo -e "$(GRE)INFO$(NC): python3source=$(python3source)"
  468.    
  469.     test -f "$(python3file)" \
  470.     && echo -e "$(GRE)INFO$(NC): Found $(python3file)" \
  471.     || (echo -e "$(GRE)INFO$(NC): Retrieving $(python3source)"; curl -Lso "$(python3file)" "$(python3source)")
  472.     tar -xf "$(python3file)"
  473.    
  474.     cd "$(python3dir)" \
  475.     && ./configure \
  476.         --prefix="$(PREFIX)" \
  477.         --enable-big-digits \
  478.         --enable-ipv6 \
  479.         --enable-optimizations \
  480.         --enable-profiling \
  481.         --enable-shared \
  482.         --with-doc-strings \
  483.         --with-ensurepip=install \
  484.         --with-system-expat="$(PREFIX)" \
  485.         --with-dbmliborder=gdbm \
  486.         --with-openssl="$(PREFIX)" \
  487.         --oldincludedir="$(PREFIX)/include" \
  488.         "CFLAGS=$(CFLAGS) -I$(PREFIX)/include/ncursesw" \
  489.         "CPPFLAGS=$(CFLAGS) -I$(PREFIX)/include/ncursesw" \
  490.         "LDFLAGS=$(LDFLAGS)" \
  491.     && make \
  492.         "CFLAGS=$(CFLAGS) -I$(PREFIX)/include/ncursesw" \
  493.         "CPPFLAGS=$(CFLAGS) -I$(PREFIX)/include/ncursesw" \
  494.         "LDFLAGS=$(LDFLAGS)" \
  495.     && ( \
  496.         [[ -n "$$NOTEST" ]] \
  497.         && echo -e "$(YEL)WARN$(NC): Skipping make check" \
  498.         || make test \
  499.         || echo -e "$(RED)ERROR$(NC): make test failed, please check log." \
  500.     ) \
  501.     && make install
  502.    
  503.     echo -n -e "$(GRE)INFO$(NC): Testing if Python runs with --version: "
  504.     "$(PREFIX)/bin/python3" --version
  505.  
  506. ifndef NOPREREQS
  507. readline: prebuild ncurses
  508. else
  509. readline: prebuild
  510. endif
  511.     echo "#########################################"
  512.     echo -e "$(GRE)INFO$(NC): Building readline $(readline)"
  513.     echo -e "$(GRE)INFO$(NC): readlinefile=$(readlinefile)"
  514.     echo -e "$(GRE)INFO$(NC): readlinesource=$(readlinesource)"
  515.    
  516.     test -f "$(readlinefile)" \
  517.     && echo -e "$(GRE)INFO$(NC): Found $(readlinefile)" \
  518.     || (echo -e "$(GRE)INFO$(NC): Retrieving $(readlinesource)"; curl -Lso "$(readlinefile)" "$(readlinesource)")
  519.     tar -xf "$(readlinefile)"
  520.    
  521.     cd "$(readlinedir)" \
  522.     && ./configure \
  523.         --prefix="$(PREFIX)" \
  524.         --with-curses="$(PREFIX)" \
  525.         --enable-shared \
  526.         --enable-static \
  527.     && make \
  528.     && make install
  529.  
  530. ifndef NOPREREQS
  531. sqlite3: prebuild readline
  532. else
  533. sqlite3: prebuild
  534. endif
  535.     echo "#########################################"
  536.     echo -e "$(GRE)INFO$(NC): Building sqlite3 $(sqlite3)"
  537.     echo -e "$(GRE)INFO$(NC): sqlite3file=$(sqlite3file)"
  538.     echo -e "$(GRE)INFO$(NC): sqlite3source=$(sqlite3source)"
  539.    
  540.     test -f "$(sqlite3file)" \
  541.     && echo -e "$(GRE)INFO$(NC): Found $(sqlite3file)" \
  542.     || (echo -e "$(GRE)INFO$(NC): Retrieving $(sqlite3source)"; curl -Lso "$(sqlite3file)" "$(sqlite3source)")
  543.     tar -xf "$(sqlite3file)"
  544.    
  545.     cd "$(sqlite3dir)" \
  546.     && ./configure \
  547.         --prefix="$(PREFIX)" \
  548.         --enable-shared \
  549.         --enable-static \
  550.         --enable-readline \
  551.         --enable-threadsafe \
  552.         --enable-dynamic-extensions \
  553.     && make \
  554.     && make install
  555.  
  556. xz: prebuild
  557.     echo "#########################################"
  558.     echo -e "$(GRE)INFO$(NC): Building xz $(xz)"
  559.     echo -e "$(GRE)INFO$(NC): xzfile=$(xzfile)"
  560.     echo -e "$(GRE)INFO$(NC): xzsource=$(xzsource)"
  561.    
  562.     test -f "$(xzfile)" \
  563.     && echo -e "$(GRE)INFO$(NC): Found $(xzfile)" \
  564.     || (echo -e "$(GRE)INFO$(NC): Retrieving $(xzsource)"; curl -Lso "$(xzfile)" "$(xzsource)")
  565.     tar -xf "$(xzfile)"
  566.    
  567.     cd "$(xzdir)" \
  568.     && ./configure \
  569.         --prefix="$(PREFIX)" \
  570.     && make \
  571.     && ( \
  572.         [[ -n "$$NOTEST" ]] \
  573.         && echo -e "$(YEL)WARN$(NC): Skipping make check" \
  574.         || make check \
  575.         || echo -e "$(RED)ERROR$(NC): make check failed, please check log." \
  576.     ) \
  577.     && make install
  578.  
  579. zlib: prebuild
  580.     echo "#########################################"
  581.     echo -e "$(GRE)INFO$(NC): Building zlib $(zlib)"
  582.     echo -e "$(GRE)INFO$(NC): zlibfile=$(zlibfile)"
  583.     echo -e "$(GRE)INFO$(NC): zlibsource=$(zlibsource)"
  584.    
  585.     test -f "$(zlibfile)" \
  586.     && echo -e "$(GRE)INFO$(NC): Found $(zlibfile)" \
  587.     || (echo -e "$(GRE)INFO$(NC): Retrieving $(zlibsource)"; curl -Lso "$(zlibfile)" "$(zlibsource)")
  588.     tar -xf "$(zlibfile)"
  589.    
  590.     cd "$(zlibdir)" \
  591.     && ./configure \
  592.         --prefix="$(PREFIX)" \
  593.         --64 \
  594.         --shared \
  595.         --libdir="$(PREFIX)/lib" \
  596.         --sharedlibdir="$(PREFIX)/lib" \
  597.     && make \
  598.     && ( \
  599.         [[ -n "$$NOTEST" ]] \
  600.         && echo -e "$(YEL)WARN$(NC): Skipping make check" \
  601.         || make check \
  602.         || echo -e "$(RED)ERROR$(NC): make check failed, please check log." \
  603.     ) \
  604.     && make install
  605.  
  606. python-update:
  607.     echo -e "$(GRE)INFO$(NC): Executing $(PREFIX)/bin/python3 -m pip install --upgrade pip setuptools wheel"
  608.     "$(PREFIX)/bin/python3" -m pip install --upgrade pip setuptools wheel
  609.  
  610. ifndef NOPREREQS
  611. ansible: python-update
  612. else
  613. ansible:
  614. endif
  615.     echo "#########################################"
  616.     echo -e "$(GRE)INFO$(NC): Executing $(PREFIX)/bin/pip install --upgrade ansible"
  617.     "$(PREFIX)/bin/pip" install --upgrade ansible
  618.  
  619. ifndef NOPREREQS
  620. python-ldap: openldap python-update
  621. else
  622. python-ldap:
  623. endif
  624.     echo "#########################################"
  625.     echo -e "$(GRE)INFO$(NC): Executing $(PREFIX)/bin/pip install --upgrade python-ldap"
  626.     "$(PREFIX)/bin/pip" install --upgrade python-ldap
  627.  
  628. clean:
  629.     echo -e "$(GRE)INFO$(NC): Clean starting"
  630. ifneq ($(wildcard $(bzip2dir)/.),)
  631.     echo -e "$(GRE)INFO$(NC): Removing $(bzip2dir)"
  632.     rm -rf "$(bzip2dir)"
  633. endif
  634. ifneq ($(wildcard $(cyrussasldir)/.),)
  635.     echo -e "$(GRE)INFO$(NC): Removing $(cyrussasldir)"
  636.     rm -rf "$(cyrussasldir)"
  637. endif
  638. ifneq ($(wildcard $(cyrussasldir)_ldap/.),)
  639.     echo -e "$(GRE)INFO$(NC): Removing $(cyrussasldir)_ldap"
  640.     rm -rf "$(cyrussasldir)_ldap"
  641. endif
  642. ifneq ($(wildcard $(expatdir)/.),)
  643.     echo -e "$(GRE)INFO$(NC): Removing $(expatdir)"
  644.     rm -rf "$(expatdir)"
  645. endif
  646. ifneq ($(wildcard $(gdbmdir)/.),)
  647.     echo -e "$(GRE)INFO$(NC): Removing $(gdbmdir)"
  648.     rm -rf "$(gdbmdir)"
  649. endif
  650. ifneq ($(wildcard $(libffidir)/.),)
  651.     echo -e "$(GRE)INFO$(NC): Removing $(libffidir)"
  652.     rm -rf "$(libffidir)"
  653. endif
  654. ifneq ($(wildcard $(ncursesdir)/.),)
  655.     echo -e "$(GRE)INFO$(NC): Removing $(ncursesdir)"
  656.     rm -rf "$(ncursesdir)"
  657. endif
  658. ifneq ($(wildcard $(openldapdir)/.),)
  659.     echo -e "$(GRE)INFO$(NC): Removing $(openldapdir)"
  660.     rm -rf "$(openldapdir)"
  661. endif
  662. ifneq ($(wildcard $(openssldir)/.),)
  663.     echo -e "$(GRE)INFO$(NC): Removing $(openssldir)"
  664.     rm -rf "$(openssldir)"
  665. endif
  666. ifneq ($(wildcard $(python3dir)/.),)
  667.     echo -e "$(GRE)INFO$(NC): Removing $(python3dir)"
  668.     rm -rf "$(python3dir)"
  669. endif
  670. ifneq ($(wildcard $(readlinedir)/.),)
  671.     echo -e "$(GRE)INFO$(NC): Removing $(readlinedir)"
  672.     rm -rf "$(readlinedir)"
  673. endif
  674. ifneq ($(wildcard $(sqlite3dir)/.),)
  675.     echo -e "$(GRE)INFO$(NC): Removing $(sqlite3dir)"
  676.     rm -rf "$(sqlite3dir)"
  677. endif
  678. ifneq ($(wildcard $(xzdir)/.),)
  679.     echo -e "$(GRE)INFO$(NC): Removing $(xzdir)"
  680.     rm -rf "$(xzdir)"
  681. endif
  682. ifneq ($(wildcard $(zlibdir)/.),)
  683.     echo -e "$(GRE)INFO$(NC): Removing $(zlibdir)"
  684.     rm -rf "$(zlibdir)"
  685. endif
  686.     echo -e "$(GRE)INFO$(NC): Clean complete"
  687.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement