[PATCH] Automatically determine GCC_VERSION and dep:devlibs based on g++ package version.

Jon Severinsson jon at severinsson.net
Sat Aug 31 07:34:59 UTC 2013


To build with a specific gcc version instead of the system default, set
GCC_VERSION to X.Y at the top of make/rules and add gcc-X.Y and g++-X.Y
to Build-Depends in debian/control.
(backported from 3.3 branch to 3.2 branch)
---
 debian/changelog |    1 +
 debian/control   |   11 +++++------
 debian/rules     |   18 ++++++++++++++++--
 3 filer ändrade, 22 tillägg(+), 8 borttagningar(-)

diff --git a/debian/changelog b/debian/changelog
index ab723c6b..4381cac9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ llvm-toolchain-3.2 (1:3.2repack-12) UNRELEASED; urgency=low
 
   [ Jon Severinsson ]
   * Drop auto-generated file debian/libllvm3.2.install.
+  * Automatically determine GCC_VERSION and dep:devlibs based on g++ package version.
 
  -- Jon Severinsson <jon at severinsson.net>  Wed, 28 Aug 2013 18:00:00 +0200
 
diff --git a/debian/control b/debian/control
index b41ffbe2..8e2a885e 100644
--- a/debian/control
+++ b/debian/control
@@ -9,7 +9,7 @@ Build-Depends: debhelper (>= 9.0), flex, bison, dejagnu, tcl8.5, expect,
     lsb-release, patchutils, diffstat, xz-utils, chrpath, python-dev,
     libedit-dev, swig, python-sphinx, ocaml-nox, binutils-dev, libcloog-isl-dev,
     libisl-dev (>= 0.11.1), binutils-gold [amd64 armhf i386 x32],
-    gcc-4.7, g++-4.7, libjsoncpp-dev
+    libjsoncpp-dev
 Build-Conflicts: oprofile, ocaml
 Standards-Version: 3.9.4
 Homepage: http://www.llvm.org/
@@ -18,9 +18,8 @@ Vcs-Browser: http://svn.debian.org/viewsvn/pkg-llvm/llvm-toolchain/trunk/
 
 Package: clang-3.2
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, libstdc++-4.8-dev,
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${dep:devlibs},
  libclang-common-dev (= ${binary:Version}),
- libobjc-4.8-dev, libgcc-4.8-dev
 Provides: c-compiler, objc-compiler, c++-compiler
 Recommends: llvm-3.2-dev, python
 Replaces: clang (<< 1:3.1), clang-3.1, compiler-rt
@@ -83,7 +82,7 @@ Description: C, C++ and Objective-C compiler (LLVM based) - Documentation
 
 Package: libclang1
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, libstdc++-4.8-dev,
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${dep:devlibs}
 Description: clang library
  Clang project is a C, C++, Objective C and Objective C++ front-end
  for the LLVM compiler. Some of its goals include the following:
@@ -115,7 +114,7 @@ Package: libclang1-dbg
 Architecture: any
 Section: debug
 Priority: extra
-Depends: ${shlibs:Depends}, ${misc:Depends}, libstdc++-4.8-dev, libclang1
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${dep:devlibs}, libclang1
 Description: clang library
  Clang project is a C, C++, Objective C and Objective C++ front-end
  for the LLVM compiler. Some of its goals include the following:
@@ -146,7 +145,7 @@ Description: clang library
 Package: libclang-dev
 Architecture: any
 Section: libdevel
-Depends: ${shlibs:Depends}, ${misc:Depends}, libstdc++-4.8-dev,
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${dep:devlibs},
  libclang1 (= ${binary:Version}), libclang-common-dev (= ${binary:Version})
 Description: clang library - Development package
  Clang project is a C, C++, Objective C and Objective C++ front-end
diff --git a/debian/rules b/debian/rules
index dac39485..6648d339 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,7 +1,7 @@
 #!/usr/bin/make -f
 
 TARGET_BUILD	:= build-llvm
-GCC_VERSION     := 4.7
+GCC_VERSION     := $(shell dpkg-query -W -f '$${Version}' g++ | sed -rne 's,^([0-9]+:)?([0-9]+\.[0-9]+).*$$,\2,p')
 LLVM_VERSION	:= 3.2
 SONAME_EXT      := 1
 DEBIAN_REVISION := $(shell dpkg-parsechangelog | sed -rne 's,^Version: .*-(.*),\1,p')
@@ -18,6 +18,9 @@ DEB_HOST_ARCH       = $(shell dpkg-architecture -qDEB_HOST_ARCH)
 
 OCAML_STDLIB_DIR    ?= $(shell ocamlc -where)
 
+export CC=gcc-$(GCC_VERSION)
+export CXX=g++-$(GCC_VERSION)
+
 confargs := \
         --with-c-include-dirs=/usr/include/$(DEB_HOST_MULTIARCH):/usr/include/$(DEB_HOST_GNU_TYPE):/usr/include \
 	--with-cxx-include-root=/usr/include/c++/$(GCC_VERSION) \
@@ -35,6 +38,14 @@ ifneq (,$(findstring $(DEB_HOST_ARCH),armel))
   opt_flags += -marm
 endif
 
+ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' g++-$(GCC_VERSION)) ge 4.8-20121128-1~ ; echo $$?),0)
+	control_vars = '-Vdep:devlibs=libstdc++-$(GCC_VERSION)-dev, libgcc-$(GCC_VERSION)-dev, libobjc-$(GCC_VERSION)-dev'
+else ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' g++-$(GCC_VERSION)) ge 4.7.2-10~ ; echo $$?),0)
+	control_vars = '-Vdep:devlibs=libstdc++6-$(GCC_VERSION)-dev, libgcc-$(GCC_VERSION)-dev, libobjc-$(GCC_VERSION)-dev'
+else
+	control_vars = '-Vdep:devlibs=libstdc++6-$(GCC_VERSION)-dev'
+endif
+
 LLDB_ARCHS :=
 LLDB_ENABLE=no
 ifneq (,$(findstring $(DEB_HOST_ARCH),$(LLDB_ARCHS)))
@@ -103,7 +114,7 @@ override_dh_auto_configure: debian/lldb-$(LLVM_VERSION).install debian/lldb-$(LL
 	--with-bug-report-url=http://bugs.debian.org/ \
 	--enable-shared \
     --enable-experimental-targets=R600 \
-	CLANG_VENDOR=$(VENDOR) CC=gcc-$(GCC_VERSION) CXX=g++-$(GCC_VERSION) || { cat config.log tools/polly/config.log; exit 1; }
+	CLANG_VENDOR=$(VENDOR) || { cat config.log tools/polly/config.log; exit 1; }
 #	cd $(TARGET_BUILD) && cmake ../ -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON
 #	mkdir build-compiler-rt && cd build-compiler-rt && cmake ../compiler-rt
 
@@ -182,6 +193,9 @@ override_dh_shlibdeps:
 override_dh_auto_test:
 	$(MAKE) -C $(TARGET_BUILD) check || true
 
+override_dh_gencontrol:
+	dh_gencontrol -- $(control_vars)
+
 override_dh_auto_clean:
 	rm -rf $(TARGET_BUILD) tools/clang/include/clang/Debian/debian_path.h docs/_build/
 	rm -f `ls debian/*.in|sed -e "s|.in$$||g"`
-- 
1.7.10.4




More information about the Pkg-llvm-team mailing list