Advertisement
marmistrz

build.mk

May 26th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 7.98 KB | None | 0 0
  1. # Because variables can be masked at anypoint by declaring
  2. # PASS_VAR, we need to call all variables as $(call xx,VAR)
  3. # This little bit of magic makes it possible:
  4. xx=$(if $($(curpass)_$(1)),$($(curpass)_$(1)),$($(1)))
  5.  
  6. # We want to log output to a logfile but we also need to preserve the
  7. # return code of the command being run.
  8. # This little bit of magic makes it possible:
  9. # $(call logme, [-a] <log file>, <cmd>)
  10. define logme
  11. (exec 3>&1; exit `( ( ( $(2) ) 2>&1 3>&-; echo $$? >&4) | tee $(1) >&3) 4>&1`)
  12. endef
  13.  
  14.  
  15. $(patsubst %,mkbuilddir_%,$(EGLIBC_PASSES)) :: mkbuilddir_% : $(stamp)mkbuilddir_%
  16. $(stamp)mkbuilddir_%: $(stamp)patch $(KERNEL_HEADER_DIR)
  17.     @echo Making builddir for $(curpass)
  18.     test -d $(DEB_BUILDDIR) || mkdir -p $(DEB_BUILDDIR)
  19.     touch $@
  20.  
  21. $(patsubst %,configure_%,$(EGLIBC_PASSES)) :: configure_% : $(stamp)configure_%
  22. $(stamp)configure_%: $(stamp)mkbuilddir_%
  23.     @echo Configuring $(curpass)
  24.     rm -f $(DEB_BUILDDIR)/configparms
  25.     echo "CC = $(call xx,CC)"       >> $(DEB_BUILDDIR)/configparms
  26.     echo "CXX = $(call xx,CXX)"     >> $(DEB_BUILDDIR)/configparms
  27.     echo "BUILD_CC = $(BUILD_CC)"       >> $(DEB_BUILDDIR)/configparms
  28.     echo "BUILD_CXX = $(BUILD_CXX)"     >> $(DEB_BUILDDIR)/configparms
  29.     echo "CFLAGS = $(HOST_CFLAGS)"      >> $(DEB_BUILDDIR)/configparms
  30.     echo "ASFLAGS = $(HOST_CFLAGS)"     >> $(DEB_BUILDDIR)/configparms
  31.     echo "BUILD_CFLAGS = $(BUILD_CFLAGS)"   >> $(DEB_BUILDDIR)/configparms
  32.     echo "LDFLAGS = "           >> $(DEB_BUILDDIR)/configparms
  33.     echo "BASH := /bin/bash"        >> $(DEB_BUILDDIR)/configparms
  34.     echo "KSH := /bin/bash"         >> $(DEB_BUILDDIR)/configparms
  35.     echo "SHELL := /bin/bash"       >> $(DEB_BUILDDIR)/configparms
  36.     echo "LIBGD = no"           >> $(DEB_BUILDDIR)/configparms
  37.     echo "have-fpie = $(fpie)"              >> $(DEB_BUILDDIR)/configparms
  38.     echo "bindir = $(bindir)"       >> $(DEB_BUILDDIR)/configparms
  39.     echo "datadir = $(datadir)"     >> $(DEB_BUILDDIR)/configparms
  40.     echo "localedir = $(localedir)"     >> $(DEB_BUILDDIR)/configparms
  41.     echo "sysconfdir = $(sysconfdir)"   >> $(DEB_BUILDDIR)/configparms
  42.     echo "libexecdir = $(libexecdir)"   >> $(DEB_BUILDDIR)/configparms
  43.     echo "rootsbindir = $(rootsbindir)"     >> $(DEB_BUILDDIR)/configparms
  44.     echo "includedir = $(call xx,includedir)" >> $(DEB_BUILDDIR)/configparms
  45.     echo "docdir = $(docdir)"       >> $(DEB_BUILDDIR)/configparms
  46.     echo "mandir = $(mandir)"       >> $(DEB_BUILDDIR)/configparms
  47.     echo "sbindir = $(sbindir)"     >> $(DEB_BUILDDIR)/configparms
  48.     echo "libdir = $(call xx,libdir)"   >> $(DEB_BUILDDIR)/configparms
  49.     echo "slibdir = $(call xx,slibdir)" >> $(DEB_BUILDDIR)/configparms
  50.     rtlddir="$(call xx,rtlddir)" ; if test -n "$$rtlddir" ; then \
  51.         echo "rtlddir = $$rtlddir" >> $(DEB_BUILDDIR)/configparms ; \
  52.     fi
  53.  
  54.     # Prevent autoconf from running unexpectedly by setting it to false.
  55.     # Also explicitly pass CC down - this is needed to get -m64 on
  56.     # Sparc, et cetera.
  57.  
  58.     configure_build=$(call xx,configure_build); \
  59.     if [ $(call xx,configure_target) = $$configure_build ]; then \
  60.       echo "Checking that we're running at least kernel version: $(call xx,MIN_KERNEL_SUPPORTED)"; \
  61.       if ! $(call kernel_check,$(call xx,MIN_KERNEL_SUPPORTED)); then \
  62.         configure_build=`echo $$configure_build | sed 's/^\([^-]*\)-\([^-]*\)$$/\1-dummy-\2/'`; \
  63.         echo "No.  Forcing cross-compile by setting build to $$configure_build."; \
  64.       fi; \
  65.     fi; \
  66.     $(call logme, -a $(log_build), echo -n "Build started: " ; date --rfc-2822 ; echo "---------------") ; \
  67.     $(call logme, -a $(log_build), \
  68.         cd $(DEB_BUILDDIR) && \
  69.         CC="$(call xx,CC)" \
  70.         CXX="$(call xx,CXX)" \
  71.         AUTOCONF=false \
  72.         MAKEINFO=: \
  73.         $(CURDIR)/configure \
  74.         --host=arm-unknown-linux-gnueabi --build=arm-unknown-linux-gnueabi \
  75.         --build=$$configure_build --prefix=/usr --without-cvs \
  76.         --enable-add-ons=$(standard-add-ons)"$(call xx,add-ons)" \
  77.         --enable-profile \
  78.         --without-selinux \
  79.         --enable-stackguard-randomization \
  80.         --with-pkgversion="maemo eglibc $(DEB_VERSION)" \
  81.         --with-bugurl="http://bugs.maemo.org/" \
  82.         --disable-force-install \
  83.         $(call xx,with_headers) $(call xx,extra_config_options))
  84.     touch $@
  85.  
  86. $(patsubst %,build_%,$(EGLIBC_PASSES)) :: build_% : $(stamp)build_%
  87. $(stamp)build_%: $(stamp)configure_%
  88.     @echo Building $(curpass)
  89.     $(call logme, -a $(log_build), $(MAKE) -C $(DEB_BUILDDIR) $(NJOBS))
  90.     $(call logme, -a $(log_build), echo "---------------" ; echo -n "Build ended: " ; date --rfc-2822)
  91. #   if [ $(curpass) = libc ]; then \
  92. #     $(MAKE) -C $(DEB_BUILDDIR) $(NJOBS) \
  93. #       objdir=$(DEB_BUILDDIR) install_root=$(CURDIR)/build-tree/locales-all \
  94. #       localedata/install-locales; \
  95. #     tar --use-compress-program /usr/bin/lzma --owner root --group root -cf $(CURDIR)/build-tree/locales-all/supported.tar.lzma -C $(CURDIR)/build-tree/locales-all/usr/lib/locale .; \
  96. #   fi
  97.     touch $@
  98.  
  99. $(patsubst %,check_%,$(EGLIBC_PASSES)) :: check_% : $(stamp)check_%
  100. $(stamp)check_%: $(stamp)build_%
  101.     @set -e ; \
  102.     if [ -n "$(findstring nocheck,$(DEB_BUILD_OPTIONS))" ]; then \
  103.       echo "Tests have been disabled via DEB_BUILD_OPTIONS." | tee $(log_results) ; \
  104.     elif [ $(call xx,configure_build) != $(call xx,configure_target) ] && \
  105.          ! $(DEB_BUILDDIR)/elf/ld.so $(DEB_BUILDDIR)/libc.so >/dev/null 2>&1 ; then \
  106.       echo "Flavour cross-compiled, tests have been skipped." | tee $(log_results) ; \
  107.     elif ! $(call kernel_check,$(call xx,MIN_KERNEL_SUPPORTED)); then \
  108.       echo "Kernel too old, tests have been skipped." | tee $(log_results) ; \
  109.     elif [ $(call xx,RUN_TESTSUITE) != "yes" ]; then \
  110.       echo "Testsuite disabled for $(curpass), skipping tests."; \
  111.       echo "Tests have been disabled." > $(log_results) ; \
  112.     else \
  113.       echo Testing $(curpass); \
  114.       find $(DEB_BUILDDIR) -name '*.out' -exec rm {} ';' ; \
  115.       LANG="" TIMEOUTFACTOR="50" $(MAKE) -C $(DEB_BUILDDIR) -k check 2>&1 | tee $(log_test); \
  116.       chmod +x debian/testsuite-checking/convertlog.sh ; \
  117.       debian/testsuite-checking/convertlog.sh $(log_test) | tee $(log_results) ; \
  118.       if test -f $(log_expected) ; then \
  119.         echo "***************" ; \
  120.         chmod +x debian/testsuite-checking/compare.sh ; \
  121.         debian/testsuite-checking/compare.sh $(log_expected) $(log_results) ; \
  122.         echo "***************" ; \
  123.       else \
  124.         echo "*** WARNING ***" ; \
  125.         echo "Please generate expected testsuite results for this arch!" ; \
  126.         echo "*** WARNING ***" ; \
  127.       fi ; \
  128.     fi
  129.     touch $@
  130.  
  131. $(patsubst %,install_%,$(EGLIBC_PASSES)) :: install_% : $(stamp)install_%
  132. $(stamp)install_%: $(stamp)check_%
  133.     @echo Installing $(curpass)
  134.     rm -rf $(CURDIR)/debian/tmp-$(curpass)
  135.     $(MAKE) -C $(DEB_BUILDDIR) \
  136.       install_root=$(CURDIR)/debian/tmp-$(curpass) install
  137.  
  138. ifneq (,$(findstring $(call xx,slibdir), /lib /lib32 /lib64))
  139.     # Generate gconv-modules.cache
  140.     /usr/sbin/iconvconfig --nostdlib --prefix=$(CURDIR)/debian/tmp-$(curpass) \
  141.                   -o $(CURDIR)/debian/tmp-$(curpass)/$(call xx,libdir)/gconv/gconv-modules.cache \
  142.                   $(call xx,libdir)/gconv
  143. endif
  144.  
  145.     # Generate the list of SUPPORTED locales
  146.     if [ $(curpass) = libc ]; then \
  147.       $(MAKE) -f debian/generate-supported.mk IN=localedata/SUPPORTED \
  148.         OUT=debian/tmp-$(curpass)/usr/share/i18n/SUPPORTED; \
  149.     fi
  150.  
  151.     # Create the multiarch directories, and the configuration file in /etc/ld.so.conf.d
  152.     if [ $(curpass) = libc ]; then \
  153.       mkdir -p debian/tmp-$(curpass)/etc/ld.so.conf.d; \
  154.       machine=`sed '/^ *config-machine *=/!d;s/.*= *//g' $(DEB_BUILDDIR)/config.make`; \
  155.       os=`sed '/^ *config-os *=/!d;s/.*= *//g;s/gnu-gnu/gnu/' $(DEB_BUILDDIR)/config.make`; \
  156.       triplet="$$machine-$$os"; \
  157.       mkdir -p debian/tmp-$(curpass)/lib/$$triplet debian/tmp-$(curpass)/usr/lib/$$triplet; \
  158.       conffile="debian/tmp-$(curpass)/etc/ld.so.conf.d/$$triplet.conf"; \
  159.       echo "# Multiarch support" > $$conffile; \
  160.       echo /lib/$$triplet >> $$conffile; \
  161.       echo /usr/lib/$$triplet >> $$conffile; \
  162.     fi
  163.  
  164.     $(call xx,extra_install)
  165.     touch $@
  166.  
  167. $(stamp)doc: $(stamp)patch
  168.     touch $@
  169.  
  170. $(stamp)source: $(stamp)patch
  171.     mkdir -p $(build-tree)
  172.     tar -c -j -C .. \
  173.         -f $(build-tree)/eglibc-$(EGLIBC_VERSION).tar.bz2 \
  174.         $(EGLIBC_SOURCES)
  175.     touch $@
  176.  
  177. .NOTPARALLEL: $(patsubst %,check_%,$(EGLIBC_PASSES))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement