llvm-toolchain/debian/rules
2013-02-26 16:34:08 +00:00

159 lines
6.2 KiB
Makefile
Executable File

#!/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
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)
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
%:
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 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 \
CLANG_VENDOR=Debian || { 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
# --enable-experimental-targets=R600
override_dh_auto_build:
$(MAKE) $(NJOBS) -C $(TARGET_BUILD) VERBOSE=1 CLANG_VENDOR=Debian CXXFLAGS=-std=c++0x 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
# && make -f Makefile.sphinx man
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/compiler-rt/usr/bin/
cp compiler-rt/lib/asan/scripts/asan_symbolize.py $(CURDIR)/debian/compiler-rt/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
# Remove some license files
rm $(CURDIR)/debian/tmp/usr/lib/llvm-$(LLVM_VERSION)/include/llvm/Support/LICENSE.TXT
.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:
$(MAKE) -C $(TARGET_BUILD) check || true
override_dh_auto_clean:
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"`
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