actions.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Licensed under the GNU General Public License, version 3.
  5. # See the file http://www.gnu.org/licenses/gpl.txt
  6. from pisi.actionsapi import autotools
  7. from pisi.actionsapi import pisitools
  8. from pisi.actionsapi import shelltools
  9. from pisi.actionsapi import get
  10. import os
  11. snapshot = False
  12. if snapshot:
  13. verMajor, verMinor = get.srcVERSION().replace("pre", "").split("_", 1)
  14. WorkDir = "gcc-4.7-%s" % verMinor
  15. else:
  16. verMajor = get.srcVERSION()
  17. arch = get.ARCH().replace("x86_64", "x86-64")
  18. #opt_unwind = "--with-system-libunwind" if get.ARCH() == "x86_64" else "--without-system-libunwind"
  19. opt_arch = "--with-arch_32=i686" if get.ARCH() == "x86_64" else "--with-arch=i686"
  20. opt_multilib = "--enable-multilib" if get.ARCH() == "x86_64" else ""
  21. # WARNING: even -fomit-frame-pointer may break the build, stack protector, fortify source etc. are off limits
  22. cflags = "-O2 -g"
  23. def removePisiLinuxSection(_dir):
  24. for root, dirs, files in os.walk(_dir):
  25. for name in files:
  26. # FIXME: should we do this only on nonshared or all ?
  27. # if ("crt" in name and name.endswith(".o")) or name.endswith("nonshared.a"):
  28. if ("crt" in name and name.endswith(".o")) or name.endswith(".a"):
  29. i = os.path.join(root, name)
  30. shelltools.system('objcopy -R ".comment.PISILINUX.OPTs" -R ".note.gnu.build-id" %s' % i)
  31. def exportFlags():
  32. # we set real flags with new configure settings, these are just safe optimizations
  33. shelltools.export("CFLAGS", cflags)
  34. shelltools.export("CXXFLAGS", cflags)
  35. # shelltools.export("LDFLAGS", "")
  36. # FIXME: this may not be necessary for biarch
  37. shelltools.export("CC", "gcc")
  38. shelltools.export("CXX", "g++")
  39. shelltools.export("LC_ALL", "en_US.UTF-8")
  40. def setup():
  41. exportFlags()
  42. # Maintainer mode off, do not force recreation of generated files
  43. #shelltools.system("contrib/gcc_update --touch")
  44. pisitools.dosed("gcc/Makefile.in", "\.\/fixinc\.sh", "-c true")
  45. pisitools.dosed("gcc/configure", "^(ac_cpp='\$CPP\s\$CPPFLAGS)", r"\1 -O2")
  46. pisitools.dosed("libiberty/configure", "^(ac_cpp='\$CPP\s\$CPPFLAGS)", r"\1 -O2")
  47. shelltools.cd("../")
  48. shelltools.makedirs("build")
  49. shelltools.cd("build")
  50. shelltools.system('.././gcc-%s/configure \
  51. --prefix=/usr \
  52. --bindir=/usr/bin \
  53. --libdir=/usr/lib \
  54. --libexecdir=/usr/lib \
  55. --includedir=/usr/include \
  56. --mandir=/usr/share/man \
  57. --infodir=/usr/share/info \
  58. --with-bugurl=http://bugs.pisilinux.org \
  59. --enable-languages=c,c++,fortran,lto,objc,obj-c++ \
  60. --disable-libgcj \
  61. --enable-shared \
  62. --enable-threads=posix \
  63. --with-system-zlib \
  64. --enable-__cxa_atexit \
  65. --disable-libunwind-exceptions \
  66. --enable-clocale=gnu \
  67. --disable-libstdcxx-pch \
  68. --disable-libssp \
  69. --enable-gnu-unique-object \
  70. --enable-linker-build-id \
  71. --enable-cloog-backend=isl \
  72. --disable-cloog-version-check \
  73. --enable-lto \
  74. --enable-plugin \
  75. --with-linker-hash-style=gnu \
  76. --with-pkgversion="Pisi Linux" \
  77. --disable-werror \
  78. --enable-checking=release \
  79. --build=%s \
  80. %s \
  81. %s ' % ( verMajor , get.HOST(), opt_arch, opt_multilib))
  82. def build():
  83. exportFlags()
  84. shelltools.cd("../build")
  85. autotools.make('BOOT_CFLAGS="%s" profiledbootstrap' % cflags)
  86. def install():
  87. shelltools.cd("../build")
  88. autotools.rawInstall("DESTDIR=%s" % get.installDIR())
  89. #autotools.install()
  90. for header in ["limits.h","syslimits.h"]:
  91. pisitools.insinto("/usr/lib/gcc/%s/%s/include" % (get.HOST(), verMajor) , "gcc/include-fixed/%s" % header)
  92. # Not needed
  93. pisitools.removeDir("/usr/lib/gcc/*/*/include-fixed")
  94. pisitools.removeDir("/usr/lib/gcc/*/*/install-tools")
  95. # This one comes with binutils
  96. #pisitools.remove("/usr/lib*/libiberty.a")
  97. # cc symlink
  98. pisitools.dosym("/usr/bin/gcc" , "/usr/bin/cc")
  99. # /lib/cpp symlink for legacy X11 stuff
  100. pisitools.dosym("/usr/bin/cpp", "/lib/cpp")
  101. pisitools.dosym("/usr/bin/x86_64-pc-linux-gnu-gcc-ar", "/usr/bin/x86_64-pc-linux-gnu-ar")
  102. # Remove our options section from crt stuff
  103. removePisiLinuxSection("%s/usr/lib/" % get.installDIR())
  104. if get.ARCH() == "x86_64":
  105. removePisiLinuxSection("%s/usr/lib32/" % get.installDIR())
  106. # autoload gdb pretty printers
  107. gdbpy_dir = "/usr/share/gdb/auto-load/usr/lib/"
  108. pisitools.dodir(gdbpy_dir)
  109. gdbpy_files = shelltools.ls("%s/usr/lib/libstdc++*gdb.py*" % get.installDIR())
  110. for i in gdbpy_files:
  111. pisitools.domove("/usr/lib/%s" % shelltools.baseName(i), gdbpy_dir)
  112. if arch == "x86-64":
  113. pisitools.remove("/usr/lib32/libstdc++*gdb.py*")