~ubuntu-branches/ubuntu/oneiric/gcc-mingw-w64/oneiric

« back to all changes in this revision

Viewing changes to debian/rules

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Kitt
  • Date: 2010-11-16 12:52:08 UTC
  • Revision ID: james.westby@ubuntu.com-20101116125208-swoehxdi6s2kfm0p
Tags: 0.1
Initial release (Closes: #602997).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/make -f
 
2
# -*- makefile -*-
 
3
# Build gcc-mingw-w64 using gcc-4.5-source.
 
4
# Copyright © 2010 Stephen Kitt <steve@sk2.org>
 
5
 
 
6
# Uncomment this to turn on verbose mode.
 
7
#export DH_VERBOSE=1
 
8
 
 
9
top_dir := $(shell pwd)
 
10
gcc_dir := /usr/src/gcc-4.5
 
11
upstream_dir := $(top_dir)/src
 
12
build_dir := $(top_dir)/build
 
13
stampdir := $(top_dir)/stamp
 
14
deb_version := $(shell dpkg-query -W -f="\$${Version}\n" gcc-4.5-source)
 
15
deb_upstream_version := $(shell echo $(deb_version) | cut -d- -f1)
 
16
gnu_upstream_version := $(shell echo $(deb_upstream_version) | cut -d. -f1-3)
 
17
base_version := $(shell echo $(deb_version) | sed -e 's/\([1-9]\.[0-9]\).*-.*/\1/')
 
18
 
 
19
# Include the rules variant - symlink rules.bootstrap to produce the
 
20
# minimal gcc required to build mingw-w64, or rules.full to produce
 
21
# the full gcc.
 
22
include debian/rules.variant
 
23
 
 
24
targets := i686-w64-mingw32 x86_64-w64-mingw32
 
25
 
 
26
CFLAGS = $(shell dpkg-buildflags --get CFLAGS)
 
27
CFLAGS += -Wall
 
28
 
 
29
# Number of jobs to run for build
 
30
ifeq ($(USE_NJOBS),no)
 
31
  NJOBS :=
 
32
  USE_CPUS := 1
 
33
else
 
34
  # Increase to 192 if building Java
 
35
  MEM_PER_CPU = 128
 
36
  NUM_CPUS := $(shell if echo $(USE_NJOBS) | grep -q -E '^[0-9]+$$'; \
 
37
                        then echo $(USE_NJOBS); \
 
38
                        else getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1; fi)
 
39
  USE_CPUS := $(shell mt=`awk '/^MemTotal/ { print $$2 }' /proc/meminfo`; \
 
40
                        awk -vn=$(NUM_CPUS) -vmt=$$mt -vm=$(MEM_PER_CPU) \
 
41
                                'END { mt/=1024; n2 = int(mt/m); print n==1 ? 1 : n2<n+1 ? n2 : n+1}' < /dev/null)
 
42
  ifneq (,$(strip $(USE_CPUS)))
 
43
    NJOBS := -j $(USE_CPUS)
 
44
  endif
 
45
endif
 
46
 
 
47
# Support parallel=<n> in DEB_BUILD_OPTIONS (see #209008)
 
48
ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
 
49
  NJOBS := -j $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
 
50
endif
 
51
 
 
52
# Patch targets
 
53
patchdir = $(gcc_dir)/debian/patches
 
54
series_file = series
 
55
unpack_stamp = $(stampdir)/unpack
 
56
patch_stamp = $(stampdir)/patch
 
57
GFDL_INVARIANT_FREE=yes
 
58
srcdir=$(upstream_dir)
 
59
include $(gcc_dir)/debian/rules.patch
 
60
 
 
61
unpack: $(unpack_stamp)
 
62
$(unpack_stamp):
 
63
        tar xf $(gcc_dir)/gcc-$(gnu_upstream_version)-dfsg.tar.*
 
64
        rm -rf $(upstream_dir)
 
65
        mv gcc-$(deb_upstream_version) $(upstream_dir)
 
66
        mkdir -p $(stampdir)
 
67
        touch $@
 
68
        # Apply our extra patch here...
 
69
        patch -p0 < debian/patches/mingw-include.patch
 
70
        patch -p0 < debian/patches/disable-multilib.patch
 
71
 
 
72
clean:
 
73
        dh_testdir
 
74
        dh_testroot
 
75
        rm -rf $(stampdir) $(build_dir) $(upstream_dir) .pc autotools_files series
 
76
        dh_clean
 
77
 
 
78
# Configuration constructed as in the gcc package
 
79
PF=usr
 
80
libdir=lib
 
81
libexecdir=$(PF)/$(libdir)
 
82
 
 
83
# Standard Debian configuration flags
 
84
# TODO Re-enable shared, multilib and linker-build-id
 
85
CONFFLAGS = \
 
86
        --prefix=/$(PF) \
 
87
        --disable-shared \
 
88
        --disable-multilib \
 
89
        --enable-linker-build-id \
 
90
        --with-system-zlib \
 
91
        --libexecdir=/$(libexecdir) \
 
92
        --without-included-gettext
 
93
CONFFLAGS += \
 
94
        --libdir=/$(PF)/$(libdir) \
 
95
        --enable-libstdcxx-time=yes \
 
96
        --with-tune=generic
 
97
# MinGW-w64 flags
 
98
CONFFLAGS += \
 
99
        --enable-version-specific-runtime-libs
 
100
# version-specific-runtime-libs puts target-specific libraries in
 
101
# /usr/lib/gcc rather than /usr/$(target)
 
102
# Languages
 
103
CONFFLAGS += \
 
104
        --enable-languages=$(languages)
 
105
#CONFFLAGS = --disable-shared --disable-multilib --prefix=/usr --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-languages=c,c++,fortran --with-gnu-ld --with-gnu-as --enable-leading-mingw64-underscores
 
106
 
 
107
configure-stamp: $(patch_stamp)
 
108
        dh_testdir
 
109
        set -e; \
 
110
        for target in $(targets); do \
 
111
                dh_auto_configure -B$(build_dir)/$$target -D$(upstream_dir) -- \
 
112
                        $(CONFFLAGS) \
 
113
                        --target=$$target \
 
114
                        --with-gxx-include-dir=/$(PF)/include/c++/$(base_version) \
 
115
                        --with-as=/usr/bin/$$target-as \
 
116
                        --with-ld=/usr/bin/$$target-ld; \
 
117
        done
 
118
        touch $@
 
119
 
 
120
build: build-stamp
 
121
build-stamp: configure-stamp
 
122
        dh_testdir
 
123
        set -e; \
 
124
        for target in $(targets); do \
 
125
                cd $(build_dir)/$$target && $(MAKE) $(NJOBS) $(BUILD_TARGET); \
 
126
        done
 
127
        touch $@
 
128
 
 
129
install: install-stamp
 
130
install-stamp: build-stamp
 
131
        dh_testdir
 
132
        dh_testroot
 
133
        dh_prep
 
134
        set -e; \
 
135
        for target in $(targets); do \
 
136
                cd $(build_dir)/$$target && $(MAKE) DESTDIR=$(top_dir)/debian/$(package) $(INSTALL_TARGET); \
 
137
        done
 
138
 
 
139
        # Remove files which conflict with other packages
 
140
        # gcc-4.5-locales
 
141
        rm -rf $(top_dir)/debian/$(package)/usr/share/locale
 
142
        # binutils-dev
 
143
        rm -f $(top_dir)/debian/$(package)/usr/lib/libiberty.a
 
144
        # libstdc++6-4.5-dbg (potentially)
 
145
        rm -rf $(top_dir)/debian/$(package)/usr/share/gcc-$(gnu_upstream_version)/python
 
146
        # libstdc++6-4.6-dev
 
147
        ls -1 $(top_dir)/debian/$(package)/usr/include/c++/$(base_version)/|grep -v w64-mingw32|xargs -I{} rm -rf $(top_dir)/debian/$(package)/usr/include/c++/$(base_version)/{}
 
148
        # -doc packages
 
149
        rm -rf $(top_dir)/debian/$(package)/usr/share/info
 
150
        rm -rf $(top_dir)/debian/$(package)/usr/share/man/man7
 
151
 
 
152
        # No need to ship empty manpages
 
153
        rm -rf $(top_dir)/debian/$(package)/usr/share/man/man1
 
154
 
 
155
        # We don't need libiberty
 
156
        rm -f $(patsubst %,$(top_dir)/debian/$(package)/$(PF)/%/lib/libiberty.a,$(targets))
 
157
 
 
158
        # Drop .la files
 
159
        rm -f $(patsubst %,$(top_dir)/debian/$(package)/$(PF)/lib/gcc/%/$(gnu_upstream_version)/*.la,$(targets))
 
160
 
 
161
        # Move libraries to base directories and add version-specific links
 
162
ifneq ($(base_version),$(gnu_upstream_version))
 
163
        [ -d $(top_dir)/debian/$(package)/usr/include/c++ ] && cd $(top_dir)/debian/$(package)/usr/include/c++ && ln -s $(base_version) $(gnu_upstream_version) || true
 
164
        for target in $(targets); do \
 
165
                cd $(top_dir)/debian/$(package)/$(PF)/lib/gcc/$$target && \
 
166
                mv $(gnu_upstream_version) $(base_version) && \
 
167
                ln -s $(base_version) $(gnu_upstream_version); \
 
168
        done
 
169
endif
 
170
 
 
171
        for i in 1 2; do \
 
172
                find $(top_dir)/debian/$(package)/ -type d -empty | while read i; do rmdir $$i; done; \
 
173
        done
 
174
 
 
175
        touch $@
 
176
 
 
177
binary-indep:
 
178
binary-arch: build install
 
179
        dh_testdir
 
180
        dh_testroot
 
181
        dh_installdocs
 
182
        dh_installman
 
183
        dh_installchangelogs $(upstream_dir)/ChangeLog
 
184
        dh_strip -Xw64-mingw32/lib -Xw64-mingw32/$(base_version)/lib
 
185
        dh_lintian
 
186
        dh_compress
 
187
        dh_fixperms
 
188
        dh_installdeb
 
189
        dh_shlibdeps
 
190
        dh_gencontrol -- -v$(deb_version) -Vlocal:Version=$(deb_upstream_version)
 
191
        dh_md5sums
 
192
        dh_builddeb
 
193
 
 
194
binary: binary-indep binary-arch
 
195
 
 
196
.PHONY: binary-indep binary-arch binary clean build install