mirror of
https://git.proxmox.com/git/llvm-toolchain
synced 2025-06-13 07:48:46 +00:00
297 lines
12 KiB
Makefile
Executable File
297 lines
12 KiB
Makefile
Executable File
#!/usr/bin/make -f
|
|
|
|
TARGET_BUILD := build-llvm
|
|
GCC_VERSION := $(shell dpkg-query -W -f '$${Version}' g++ | sed -rne 's,^([0-9]+:)?([0-9]+\.[0-9]+).*$$,\2,p')
|
|
LLVM_VERSION := 3.4
|
|
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)
|
|
|
|
export CC=gcc-$(GCC_VERSION)
|
|
export CXX=g++-$(GCC_VERSION)
|
|
|
|
LDFLAGS_EXTRA=
|
|
CXXFLAGS_EXTRA=
|
|
|
|
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 ($(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
|
|
|
|
BINUTILS_GOLD_ARCHS := amd64 armhf i386 powerpc powerpcspe ppc64 sparc sparc64 x32
|
|
ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' binutils) ge 2.23.1-1~exp3 ; echo $$?),0)
|
|
ifneq (,$(findstring $(DEB_HOST_ARCH),$(BINUTILS_GOLD_ARCHS)))
|
|
# -fused-ld=gold enables the gold linker (but is not supported by all archs / distro)
|
|
LDFLAGS_EXTRA += -fuse-ld=gold
|
|
endif
|
|
endif
|
|
|
|
ifneq (,$(filter codecoverage,$(DEB_BUILD_OPTIONS)))
|
|
# enable the code coverage
|
|
CODECOVERAGE=yes
|
|
# for -fvisibility-inlines-hidden see http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130729/183016.html
|
|
CXXFLAGS_EXTRA += -fprofile-arcs -ftest-coverage
|
|
LDFLAGS_EXTRA += -coverage -lgcov
|
|
confargs += llvm_cv_cxx_visibility_inlines_hidden=no
|
|
endif
|
|
|
|
ifneq (,$(filter scan-build,$(DEB_BUILD_OPTIONS)))
|
|
# enable the build using scan-build
|
|
# The package are installed through the variable declarations:
|
|
# OTHERMIRROR="deb http://llvm.org/apt/unstable/ llvm-toolchain main"
|
|
# EXTRAPACKAGES="clang-3.4"
|
|
PRE_PROCESS=scan-build
|
|
# no need to run tests in this case
|
|
DEB_BUILD_OPTIONS+=" nocheck"
|
|
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 debian/pollycc
|
|
echo "Using gcc: "
|
|
$(CC) -v
|
|
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 projects/ && \
|
|
if test -h compiler-rt; then \
|
|
rm compiler-rt; \
|
|
fi; \
|
|
ln -s ../compiler-rt .; \
|
|
readlink compiler-rt
|
|
|
|
# Due to bug upstream, no symlink here
|
|
cp -R -H clang-tools-extra tools/clang/tools/extra
|
|
|
|
# Start the actual configure
|
|
cd $(TARGET_BUILD) && $(PRE_PROCESS) \
|
|
../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:
|
|
$(PRE_PROCESS) $(MAKE) $(NJOBS) -C $(TARGET_BUILD) VERBOSE=1 CLANG_VENDOR=$(VENDOR) CXXFLAGS="$(CXXFLAGS_EXTRA) -std=c++0x" LDFLAGS="$(LDFLAGS_EXTRA)" REQUIRES_RTTI=1 DEBUGMAKE=1
|
|
|
|
override_dh_prep: build_doc
|
|
dh_prep
|
|
|
|
build_doc:
|
|
cd $(CURDIR)/docs && make -f Makefile.sphinx && make -f Makefile.sphinx man
|
|
cd $(CURDIR)/tools/clang/docs && make -f Makefile.sphinx
|
|
|
|
# Rename manpages
|
|
d=$(CURDIR)/docs/_build/man/; \
|
|
cd $$d; \
|
|
for f in *.1; do \
|
|
echo "$$f"|grep $(LLVM_VERSION) || mv $$f `echo $$f|sed "s|\.1|-$(LLVM_VERSION).1|"`; \
|
|
done
|
|
|
|
# Remove the copy of jquery. See bug #701087
|
|
for d in $(CURDIR)/clang/docs/_build/html/_static/ $(CURDIR)/docs/_build/html/_static/; do \
|
|
cd $$d && rm -f jquery.js && ln -s /usr/share/javascript/jquery/jquery.js; \
|
|
cd $$d && rm -f underscore.js && ln -s /usr/share/javascript/underscore/underscore.js; \
|
|
done
|
|
|
|
help2man --version-string=$(LLVM_VERSION) clang/tools/scan-view/scan-view > debian/man/scan-view.1
|
|
help2man --version-string=$(LLVM_VERSION) clang/tools/clang-format/clang-format-diff.py > debian/man/clang-format-diff-$(LLVM_VERSION).1
|
|
|
|
for f in clang clang-tblgen clang-check; do \
|
|
help2man --version-string=$(LLVM_VERSION) $(TARGET_BUILD)/Release/bin/$$f > debian/man/$$f.1; \
|
|
done
|
|
|
|
for f in llvm-dwarfdump llvm-mc llvm-mcmarkup llvm-objdump llvm-rtdyld llvm-size llvm-tblgen macho-dump lldb clang-format clang-modernize; do \
|
|
help2man --version-string=$(LLVM_VERSION) $(TARGET_BUILD)/Release/bin/$$f > debian/man/$$f-$(LLVM_VERSION).1; \
|
|
done
|
|
|
|
override_dh_auto_install:
|
|
$(MAKE) -C $(TARGET_BUILD) VERBOSE=1 install DESTDIR=$(CURDIR)/debian/tmp/
|
|
chrpath -d $(TARGET_BUILD)/Release/bin/clang
|
|
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
|
|
mkdir -p $(CURDIR)/debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/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 some stuff with the version name
|
|
# WILL DO when we can install several clang versions together
|
|
#mv $(CURDIR)/$(TARGET_BUILD)/tools/clang/docs/tools/clang.1 $(CURDIR)/$(TARGET_BUILD)/tools/clang/docs/tools/clang-$(LLVM_VERSION).1
|
|
|
|
if test -f $(CURDIR)/utils/vim/llvm.vim; then \
|
|
mv $(CURDIR)/utils/vim/llvm.vim $(CURDIR)/utils/vim/llvm-$(LLVM_VERSION).vim; \
|
|
fi
|
|
|
|
if test -f $(CURDIR)/utils/vim/tablegen.vim; then \
|
|
mv $(CURDIR)/utils/vim/tablegen.vim $(CURDIR)/utils/vim/tablegen-$(LLVM_VERSION).vim; \
|
|
fi
|
|
|
|
if test -f $(CURDIR)/clang/tools/clang-format/clang-format-diff.py; then \
|
|
mv $(CURDIR)/clang/tools/clang-format/clang-format-diff.py $(CURDIR)/clang/tools/clang-format/clang-format-diff-$(LLVM_VERSION); \
|
|
fi
|
|
|
|
if test -f $(CURDIR)/clang/tools/clang-format/clang-format.py; then \
|
|
mv $(CURDIR)/clang/tools/clang-format/clang-format.py clang/tools/clang-format/clang-format-$(LLVM_VERSION).py; \
|
|
fi
|
|
|
|
# Remove some license files
|
|
rm -f $(CURDIR)/debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/include/llvm/Support/LICENSE.TXT \
|
|
$(CURDIR)/debian/llvm-$(LLVM_VERSION)-dev/usr/lib/llvm-$(LLVM_VERSION)/build/autoconf/LICENSE.TXT
|
|
|
|
# Managed in lldb-X.Y.links.in
|
|
rm -f $(CURDIR)/$(TARGET_BUILD)/Release/lib/python*/site-packages/lldb/_lldb.so
|
|
|
|
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)-$(LLVM_VERSION) --dbg-package=libclang$(SONAME_EXT)-$(LLVM_VERSION)-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_installdeb:
|
|
# Managed by the package
|
|
dh_installdeb -a
|
|
|
|
rm -f $(CURDIR)/debian/lldb-$(LLVM_VERSION)/usr/lib/python*/dist-packages/lldb/__init__.pyc
|
|
|
|
|
|
override_dh_auto_test:
|
|
# LLVM tests
|
|
$(MAKE) -C $(TARGET_BUILD) check || true
|
|
# clang tests
|
|
cd $(TARGET_BUILD)/ && $(MAKE) -C tools/clang/ test || true
|
|
# lldb tests
|
|
cd $(TARGET_BUILD)/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 $(TARGET_BUILD)/Release/lib/python2.7/site-packages/lldb && if test ! -h libLLVM-$(LLVM_VERSION).so.$(SONAME_EXT) -o ! -f _lldb.so; then ln -s ../../../libLLVM-$(LLVM_VERSION).so libLLVM-$(LLVM_VERSION).so.$(SONAME_EXT); fi
|
|
cd $(TARGET_BUILD)/ && $(MAKE) -C tools/lldb/test || true
|
|
if test -d $(TARGET_BUILD)/tools/lldb/test/lldb-test-traces/; then \
|
|
cat $(TARGET_BUILD)/tools/lldb/test/lldb-test-traces/*; \
|
|
fi
|
|
|
|
# Managed by debian build system
|
|
rm -f $(CURDIR)/$(TARGET_BUILD)/Release/lib/python*/site-packages/lldb/_lldb.so
|
|
# polly tests
|
|
cd $(TARGET_BUILD)/ && $(MAKE) -C tools/polly/test/ check-polly || true
|
|
|
|
# The compression of the code coverage report is done in the
|
|
# hook B21GetCoverageResults on the server
|
|
if test "$(CODECOVERAGE)" = "yes"; then \
|
|
REPORT=reports/llvm-toolchain.info; \
|
|
mkdir -p reports/; \
|
|
lcov --directory $(TARGET_BUILD)/ --capture --ignore-errors source --output-file $$REPORT; \
|
|
lcov --remove $$REPORT "/usr*" -o $$REPORT; \
|
|
genhtml -o reports/coverage --show-details --highlight --legend $$REPORT; \
|
|
fi
|
|
|
|
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/ 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 '*.cm[ix]' | xargs -r rm -f
|
|
find test/Bindings -name '*.o' | xargs -r rm -f
|
|
rm -f tools/clang tools/polly tools/lldb projects/compiler-rt
|
|
rm -rf tools/clang/tools/extra
|
|
|