#!/usr/bin/make -f TARGET_BUILD := build-llvm GCC_VERSION := 4.7 LLVM_VERSION := 3.3 SONAME_EXT := 1 DEBIAN_REVISION := $(shell dpkg-parsechangelog | sed -rne 's,^Version: .*-(.*),\1,p') ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) NJOBS := -j $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) endif VENDOR=$(shell lsb_release -is) DEB_HOST_MULTIARCH = $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) DEB_HOST_GNU_TYPE = $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) DEB_HOST_ARCH_BITS = $(shell dpkg-architecture -qDEB_HOST_ARCH_BITS) DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH) OCAML_STDLIB_DIR ?= $(shell ocamlc -where) distribution := $(shell lsb_release --id --short) distrel := $(shell lsb_release --codename --short) ifeq ($(distrel),n/a) distrel := sid endif 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) \ --with-cxx-include-arch=$(DEB_HOST_GNU_TYPE) \ --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) ifeq ($(shell dpkg-architecture -qDEB_HOST_ARCH_BITS),64) confargs += --with-cxx-include-32bit-dir=32 else confargs += --with-cxx-include-64bit-dir=64 endif opt_flags = -g -O2 ifneq (,$(findstring $(DEB_HOST_ARCH),armel)) opt_flags += -marm endif ifeq ($(distribution),Ubuntu) ifeq ($(distrel),precise) control_vars = '-Vdep:devlibs=libstdc++6-4.6-dev' endif ifeq ($(distrel),quantal) control_vars = '-Vdep:devlibs=libstdc++6-4.7-dev' endif ifeq ($(distrel),raring) control_vars = '-Vdep:devlibs=libstdc++6-4.7-dev, libgcc-4.7-dev, libobjc-4.7-dev' endif else ifeq ($(distrel),wheezy) control_vars = '-Vdep:devlibs=libstdc++6-4.7-dev' else # Debian experimental control_vars = '-Vdep:devlibs=libstdc++6-4.7-dev, libgcc-4.7-dev, libobjc-4.7-dev' endif endif ifneq (,$(filter codecoverage,$(DEB_BUILD_OPTIONS))) # enable the code coverage CODECOVERAGE=yes CXXFLAGS_EXTRA=-fprofile-arcs -ftest-coverage LDFLAGS_EXTRA=-coverage -lgcov endif %: dh $@ # --buildsystem=cmake --builddirectory=$(TARGET_BUILD) debian/%: debian/%.in sed -e 's|@DEB_HOST_MULTIARCH@|$(DEB_HOST_MULTIARCH)|g' -e "s|@OCAML_STDLIB_DIR@|$(OCAML_STDLIB_DIR)|g" -e "s|@LLVM_VERSION@|$(LLVM_VERSION)|g" $< > $@ override_dh_auto_configure: debian/lldb-$(LLVM_VERSION).install debian/lldb-$(LLVM_VERSION).links debian/libllvm$(LLVM_VERSION).install debian/llvm-$(LLVM_VERSION)-dev.links debian/libllvm-$(LLVM_VERSION)-ocaml-dev.install debian/libllvm-$(LLVM_VERSION)-ocaml-dev.dirs debian/llvm-$(LLVM_VERSION)-runtime.binfmt debian/llvm-$(LLVM_VERSION)-runtime.prerm mkdir -p $(TARGET_BUILD) mkdir -p clang/include/clang/Debian sed -e "s|@DEB_HOST_MULTIARCH@|$(DEB_HOST_MULTIARCH)|" \ -e "s|@DEB_HOST_GNU_TYPE@|$(DEB_HOST_GNU_TYPE)|" \ -e "s|@DEB_PATCHSETVERSION@|$(DEBIAN_REVISION)|" \ debian/debian_path.h > clang/include/clang/Debian/debian_path.h # Remove some old symlinks cd tools/ && \ if test -h clang; then \ rm clang; \ fi; \ ln -s ../clang .; \ readlink clang; \ if test -h lldb; then \ rm lldb; \ fi; \ ln -s ../lldb .; \ if test -h polly; then \ rm polly; \ fi; \ ln -s ../polly .; \ # cd clang/tools/ && \ # if test -h extra; then \ # rm extra; \ # fi; \ # ln -s ../../clang-extra extra; \ # readlink extra cd projects/ && \ if test -h compiler-rt; then \ rm compiler-rt; \ fi; \ ln -s ../compiler-rt .; \ readlink compiler-rt # Start the actual configure cd $(TARGET_BUILD) && \ ../configure $(confargs) \ --prefix=/usr/lib/llvm-$(LLVM_VERSION) \ --bindir=\$${prefix}/bin/ \ --disable-assertions \ --enable-shared \ --enable-optimized \ --with-optimize-option=' $(opt_flags)' \ --enable-pic \ --enable-libffi \ --with-ocaml-libdir=/usr/lib/ocaml/llvm-$(LLVM_VERSION) \ --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \ --with-binutils-include=/usr/include \ --with-cloog --with-isl \ --with-bug-report-url=http://bugs.debian.org/ \ --enable-shared --enable-experimental-targets=R600 \ 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 override_dh_auto_build: $(MAKE) $(NJOBS) -C $(TARGET_BUILD) VERBOSE=1 CLANG_VENDOR=$(VENDOR) CXXFLAGS="$(CXXFLAGS_EXTRA) -std=c++0x" LDFLAGS="$(LDFLAGS_EXTRA)" REQUIRES_RTTI=1 cd $(CURDIR)/docs && make -f Makefile.sphinx && make -f Makefile.sphinx man # $(MAKE) $(NJOBS) -C build-compiler-rt VERBOSE=1 # Only available in clang 3.3 cd $(CURDIR)/tools/clang/docs && make -f Makefile.sphinx override_dh_auto_install: chrpath -d `find $(CURDIR)/debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/bin/ -type f -executable` chrpath -d $(TARGET_BUILD)/Release/bin/clang $(MAKE) -C $(TARGET_BUILD) VERBOSE=1 install DESTDIR=$(CURDIR)/debian/tmp/ chrpath -d `find $(CURDIR)/debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/bin/ -type f -executable` mv $(CURDIR)/debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/libLLVM-$(LLVM_VERSION)*.so $(CURDIR)/debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/libLLVM-$(LLVM_VERSION).so.$(SONAME_EXT) mv $(CURDIR)/debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/liblldb.so $(CURDIR)/debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/liblldb.so.$(SONAME_EXT) cd debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/ && mv libclang.so libclang.so.$(SONAME_EXT) && ln -s libclang.so.$(SONAME_EXT) libclang.so # cd $(TARGET_BUILD)/tools/clang/runtime/compiler-rt/ && rm -rf $$(find . -iname "SubDir.lib*" -o -iname .dir) && rm -rf $$(find -empty) mkdir -p $(CURDIR)/debian/clang-$(LLVM_VERSION)/usr/bin/ cp compiler-rt/lib/asan/scripts/asan_symbolize.py $(CURDIR)/debian/clang-$(LLVM_VERSION)/usr/bin/asan_symbolize # Create this fake directory to make the install libclang-common-dev happy # under the unsupported archs of compiler-rt mkdir -p $(CURDIR)/debian/tmp/usr/lib/clang/$(LLVM_VERSION)/lib # Rename binaries mkdir -p $(CURDIR)/debian/tmp/usr/bin/ cd $(CURDIR)/debian/tmp/usr/bin/; rm -f *; \ for f in ../lib/llvm-$(LLVM_VERSION)/bin/*; do \ ln -s $$f `basename $$f`-$(LLVM_VERSION); \ echo "Link $$f to `basename $$f`-$(LLVM_VERSION)"; \ done # Rename manpages d=$(CURDIR)/docs/_build/man/; \ cd $$d; \ for f in *.1; do \ echo "$$f"|grep "3\.2" || mv $$f `echo $$f|sed "s|\.1|-$(LLVM_VERSION).1|"`; \ done mv $(CURDIR)/build-llvm/tools/clang/docs/tools/clang.1 $(CURDIR)/build-llvm/tools/clang/docs/tools/clang-$(LLVM_VERSION).1 # Remove some license files rm $(CURDIR)/debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/include/llvm/Support/LICENSE.TXT # Managed in lldb-X.Y.links.in rm -f $(CURDIR)/build-llvm/Release/lib/python*/site-packages/lldb/_lldb.so # Remove the copy of jquery. See bug #701087 cd $(CURDIR)/docs/_build/html/_static/ && rm -f jquery.js && ln -s /usr/share/javascript/jquery/jquery.js override_dh_installman: dh_installman # Make sure that lli manpage is only in llvm-3.2-runtime (See #697117) rm -f $(CURDIR)/debian/llvm-$(LLVM_VERSION)/usr/share/man/man1/lli* .PHONY: override_dh_strip override_dh_strip: dh_strip -p libclang$(SONAME_EXT) --dbg-package=libclang$(SONAME_EXT)-dbg dh_strip -p libllvm$(LLVM_VERSION) --dbg-package=libllvm$(LLVM_VERSION)-dbg dh_strip -a override_dh_shlibdeps: LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(CURDIR)/debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/lib/ dh_shlibdeps override_dh_auto_test: # LLVM tests $(MAKE) -C $(TARGET_BUILD) check || true # clang tests cd build-llvm/ && $(MAKE) -C tools/clang/ test || true # lldb tests cd build-llvm/Release/lib/python2.7/site-packages/lldb && if test ! -h _lldb.so -o -f _lldb.so; then ln -s ../../../liblldb.so _lldb.so; fi cd build-llvm/ && $(MAKE) -C tools/lldb/test # polly tests cd build-llvm/ && $(MAKE) polly-test -C tools/polly/test/ if test "$(CODECOVERAGE)" = "yes"; then \ mkdir -p reports/; \ lcov --directory build-llvm/ --capture --ignore-errors source --output-file reports/scilab-code-coverage.info; \ genhtml -o reports/coverage --show-details --highlight --legend reports/scilab-code-coverage.info; \ fi override_dh_gencontrol: dh_gencontrol -- $(control_vars) override_dh_auto_clean: dh_auto_clean rm -rf $(TARGET_BUILD) tools/clang/include/clang/Debian/debian_path.h docs/_build/ tools/clang/docs/_html/ rm -f `ls debian/*.in|sed -e "s|.in$$||g"` find utils -name '*.pyc' | xargs -r rm -f find test -name '*.pyc' -o -name '*.o' -o -name '*.cm[ix]' | xargs -r rm -f rm -f tools/clang tools/polly tools/lldb projects/compiler-rt