Upload Tizen:Base source
[external/binutils.git] / debian / rules
1 #!/usr/bin/make -f
2 # debian/rules file - for binutils (2.20)
3 # Based on sample debian/rules file - for GNU Hello (1.3).
4 # Copyright 1994,1995 by Ian Jackson.
5 # Copyright 1998-2007 James Troup.
6 # Portions Copyright 2008-2009 Canonical Ltd.
7 # Portions Copyright 2008-2009 Matthias Klose.
8 # I hereby give you perpetual unlimited permission to copy,
9 # modify and relicense this file, provided that you do not remove
10 # my name from the file itself.  (I assert my moral right of
11 # paternity under the Copyright, Designs and Patents Act 1988.)
12 # This file may have to be extensively modified
13
14 ################################################################################
15
16 p_bin = binutils
17 p_dev = $(p_bin)-dev
18 p_mul = $(p_bin)-multiarch
19 p_gold = $(p_bin)-gold
20 p_doc = $(p_bin)-doc
21 p_hppa64 = $(p_bin)-hppa64
22 p_spu = $(p_bin)-spu
23 p_src = $(p_bin)-source
24
25 # BACKPORT is used for cross builds for a -source package not conflicting
26 # with the source package of the native package.
27 ifeq ($(BACKPORT),true)
28   p_src = $(p_bin)-$(VERSION)-source
29 else
30   p_src = $(p_bin)-source
31 endif
32
33 pwd   := $(shell pwd)
34 d     = debian/tmp
35 d_bin = $(d)
36 d_dev = debian/$(p_dev)
37 d_mul = debian/$(p_mul)
38 d_gold = debian/$(p_gold)
39 d_doc = debian/$(p_doc)
40 d_hppa64 = debian/$(p_hppa64)
41 d_spu = debian/$(p_spu)
42 d_src = debian/$(p_src)
43
44 install_dir    = install -d -m 755
45 install_file   = install -m 644
46 install_script = install -m 755
47 install_binary = install -m 755 -s
48
49 vafilt = $(subst $(2)=,,$(filter $(2)=%,$(1)))
50 DPKG_VARS := $(shell dpkg-architecture)
51 DEB_BUILD_GNU_TYPE      ?= $(call vafilt,$(DPKG_VARS),DEB_BUILD_GNU_TYPE)
52 DEB_HOST_ARCH           ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_ARCH)
53 DEB_HOST_GNU_TYPE       ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_GNU_TYPE)
54 DEB_HOST_MULTIARCH      ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_MULTIARCH)
55
56 ifeq (,$(DEB_HOST_MULTIARCH))
57   ifeq ($(DEB_HOST_ARCH),i386)
58     DEB_HOST_MULTIARCH = i386-linux-gnu
59   else
60     DEB_HOST_MULTIARCH = $(DEB_HOST_GNU_TYPE)
61   endif
62 endif
63
64 SHELL  = /bin/bash
65
66 ifneq (,$(filter $(DEB_HOST_ARCH), amd64 armel armhf i386 powerpc powerpcspe ppc64 sparc sparc64))
67   with_gold = yes
68 endif
69
70 with_multiarch := yes
71
72 CC     = gcc
73 CXX    = g++
74 CFLAGS = -g -O2
75 STRIP  = strip --remove-section=.comment --remove-section=.note
76 CROSS :=
77 ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
78   CROSS := $(DEB_HOST_GNU_TYPE)-
79   CC   = $(CROSS)gcc
80   CXX  = $(CROSS)g++
81   STRIP= $(CROSS)strip --remove-section=.comment --remove-section=.note
82   install_binary = install -m 755 -s --strip-program="$(STRIP)"
83 endif
84
85 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
86   CFLAGS = -g -O0
87 endif
88
89 # this outputs 0 or 1 depending on whether a macro appears in the *default* cpp
90 # -dM -P output; this is used to test the toolchain *default* configuration
91 check_cpp = $(shell $(CROSS)cpp -dM -P /dev/null | grep -q '^\#define $(1)' && echo 1 || echo 0)
92
93 # testsuite doesn't expect to be built with -mthumb
94 # TODO if the testsuite is only broken with Thumb-2 (and not with "Thumb-1"),
95 # we should test for __thumb2__ instead
96 ifneq (,$(filter $(DEB_HOST_ARCH), armel armhf))
97   ifeq ($(call check_cpp,__thumb__),1)
98     CFLAGS += -marm
99   endif
100 endif
101
102 # see LP: #446478, would only fix the testcases
103 #ifneq (,$(filter $(DEB_HOST_ARCH), armel armhf))
104 #  CFLAGS += -fno-section-anchors
105 #endif
106
107 SPACE = $(EMPTY) $(EMPTY)
108 COMMA = ,
109 CHANGELOG_VARS := $(shell dpkg-parsechangelog | \
110         sed -n 's/ /_/g;/^[^_]/s/^\([^:]*\):_\(.*\)/\1=\2/p')
111
112 DEB_VERSION     := $(call vafilt,$(CHANGELOG_VARS),Version)
113 DEB_SVERSION    := $(shell echo $(DEB_VERSION) | sed 's/+b[0-9][0-9]*$$//')
114 DEB_UPSTREAM    := $(firstword $(subst -,$(SPACE),$(DEB_VERSION)))
115
116 VERSION         := $(shell sed -n 's/^ *VERSION=\(.*\)/\1/p' bfd/configure | head -1)
117 DATE            := $(shell sed -n 's/.* \([0-9]*\)$$/\1/p' bfd/version.h)
118 ifneq (,$(DATE))
119   DATE_EXT      := .$(DATE)
120 endif
121
122 ifneq ($(DEB_UPSTREAM),$(VERSION)$(DATE_EXT))
123   $(error upstream ($(DEB_UPSTREAM)) and debian ($(VERSION)$(DATE_EXT)) version mismatch)
124 endif
125
126 SINGLE_VERSION= $(VERSION)-system
127 MULTI_VERSION = $(VERSION)-multiarch
128 HPPA64_VERSION= $(VERSION)-hppa64
129 SPU_VERSION   = $(VERSION)-spu
130
131 DISTRIBUTION := SLP
132 NJOBS =
133 # Support parallel=<n> in DEB_BUILD_OPTIONS (see #209008)
134 ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
135   NJOBS := -j $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
136 endif
137 ifneq (,$(findstring nogold,$(DEB_BUILD_OPTIONS)))
138   with_gold = disabled in DEB_BUILD_OPTIONS
139 endif
140 ifneq (,$(findstring nomult,$(DEB_BUILD_OPTIONS)))
141   with_multiarch = disabled in DEB_BUILD_OPTIONS
142 endif
143
144 # If $(TARGET) is not set, try reading debian/target
145 ifeq (,$(TARGET))
146   ifneq (,$(wildcard debian/target))
147     TARGET := $(shell cat debian/target 2>/dev/null)
148   endif
149 endif
150
151 # PF is the installation prefix for the package without the leading slash.
152 # It's "usr" for gcc releases, so use this if not explicitly set
153 ifeq ($(PF),)
154   PF = usr
155 endif
156
157 ########################################
158
159 CONFARGS = \
160         --enable-shared \
161         --enable-plugins \
162         --prefix=/$(PF) \
163         --build=$(DEB_BUILD_GNU_TYPE) \
164         --host=$(DEB_HOST_GNU_TYPE) \
165         --with-pkgversion="GNU Binutils for $(DISTRIBUTION)"
166
167 ifeq ($(DEB_HOST_MULTIARCH),x86_64-linux-gnu)
168   DEB_HOST_MULTIARCH32 = i386-linux-gnu
169 else ifeq ($(DEB_HOST_MULTIARCH),powerpc64-linux-gnu)
170   DEB_HOST_MULTIARCH32 = powerpc-linux-gnu
171 else ifeq ($(DEB_HOST_MULTIARCH),s390x-linux-gnu)
172   DEB_HOST_MULTIARCH32 = s390-linux-gnu
173 else ifeq ($(DEB_HOST_MULTIARCH),sparc64-linux-gnu)
174   DEB_HOST_MULTIARCH32 = sparc-linux-gnu
175 else ifeq ($(DEB_HOST_MULTIARCH),x86_64-kfreebsd-gnu)
176   DEB_HOST_MULTIARCH32 = i386-kfreebsd-gnu
177 else ifeq ($(DEB_HOST_MULTIARCH),i386-linux-gnu)
178   DEB_HOST_MULTIARCH64 = x86_64-linux-gnu
179 else ifeq ($(DEB_HOST_MULTIARCH),powerpc-linux-gnu)
180   DEB_HOST_MULTIARCH64 = powerpc64-linux-gnu
181 else ifeq ($(DEB_HOST_MULTIARCH),sparc-linux-gnu)
182   DEB_HOST_MULTIARCH64 = sparc64-linux-gnu
183 else ifeq ($(DEB_HOST_MULTIARCH),s390-linux-gnu)
184   DEB_HOST_MULTIARCH64 = s390x-linux-gnu
185 else ifeq ($(DEB_HOST_MULTIARCH),i386-kfreebsd-gnu)
186   DEB_HOST_MULTIARCH64 = x86_64-linux-gnu
187 else ifeq ($(DEB_HOST_MULTIARCH),mips-linux-gnu)
188   DEB_HOST_MULTIARCH64 = mips64-linux-gnu
189 else ifeq ($(DEB_HOST_MULTIARCH),mipsel-linux-gnu)
190   DEB_HOST_MULTIARCH64 = mips64el-linux-gnu
191 endif
192 export DEB_HOST_MULTIARCH DEB_HOST_MULTIARCH32 DEB_HOST_MULTIARCH64
193
194 ifeq ($(DEB_HOST_ARCH),sparc)
195         CONFARGS += --enable-targets=sparc64-linux-gnu
196         CONFLICTS = -VextraConflicts="libc6-dev-sparc64 (<< 2.2.5-7)"
197 endif
198 ifeq ($(DEB_HOST_ARCH),sparc64)
199         CONFARGS += --enable-targets=sparc-linux-gnu
200         CONFLICTS = -VextraConflicts="libc6-dev-sparc64 (<< 2.2.5-7)"
201 endif
202 ifeq ($(DEB_HOST_ARCH),powerpc)
203         CONFARGS += --enable-targets=powerpc64-linux-gnu,spu
204 endif
205 ifeq ($(DEB_HOST_ARCH),ppc64)
206         CONFARGS += --enable-targets=powerpc-linux-gnu,spu
207 endif
208 ifeq ($(DEB_HOST_ARCH),s390)
209         CONFARGS += --enable-targets=s390x-linux-gnu
210 endif
211 ifeq ($(DEB_HOST_ARCH),i386)
212         CONFARGS += --enable-targets=x86_64-linux-gnu
213 endif
214 ifeq ($(DEB_HOST_ARCH),kfreebsd-i386)
215         CONFARGS += --enable-targets=x86_64-kfreebsd-gnu
216 endif
217 ifeq ($(DEB_HOST_ARCH),mips)
218        CONFARGS += --enable-targets=mips64-linux-gnu
219 endif
220 ifeq ($(DEB_HOST_ARCH),mipsel)
221        CONFARGS += --enable-targets=mips64el-linux-gnu
222 endif
223 ifneq (,$(filter $(DEB_HOST_ARCH),armhf ia64 sparc sparc64))
224         CONFARGS += --disable-werror
225 endif
226
227 ifneq ($(DISTRIBUTION),SLP)
228 with_check := yes
229 else
230 with_check := disabled for SLP
231 endif
232
233 ifneq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
234         with_check := disabled through DEB_BUILD_OPTIONS
235 endif
236 ifneq (,$(filter $(DEB_HOST_ARCH), armel armhf mips mipsel sparc))
237         ignore_regressions := regressions ignored on architecture $(DEB_HOST_ARCH)
238 endif
239 ignore_regressions := regressions ignored on architecture $(DEB_HOST_ARCH)
240 #ifneq (,$(filter $(DEB_HOST_ARCH),mips mipsel))
241 #       with_check := disabled for architecture $(DEB_HOST_ARCH)
242 #endif
243
244 with_strip := yes
245 ifneq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
246         with_strip := disabled through DEB_BUILD_OPTIONS
247 endif
248
249 source_files = $(addprefix $(shell basename $(pwd))/, \
250                  $(filter-out %-stamp .pc CVS debian builddir-% test-summary, $(wildcard *)))
251
252 ################################################################################
253
254 #################
255 # patch targets #
256 #################
257
258 patch: patch-stamp
259 patch-stamp:
260 ifneq ($(PATCHED_SOURCES),yes)
261         QUILT_PATCHES=$(CURDIR)/debian/patches \
262           quilt --quiltrc /dev/null push -a || test $$? = 2
263 endif
264         touch $@
265
266 patch-cross: patch-cross-stamp
267 patch-cross-stamp:
268         patch -p1 <debian/patches/xx_force_non-native.patch
269         touch $@
270
271 unpatch-cross:
272         if [ -f patch-cross-stamp ]; \
273         then \
274                 patch -R -p1 <debian/patches/xx_force_non-native.patch; \
275         fi
276         rm -f patch-cross-stamp
277
278 unpatch: unpatch-cross
279         QUILT_PATCHES=$(CURDIR)/debian/patches \
280           quilt --quiltrc /dev/null pop -a -R || test $$? = 2
281         rm -rf .pc
282
283 update-patches:
284         export QUILT_PATCHES=$(CURDIR)/debian/patches; \
285         export QUILT_REFRESH_ARGS="--no-timestamps --no-index -pab"; \
286         export QUILT_DIFF_ARGS="--no-timestamps --no-index -pab"; \
287         while quilt push; do quilt refresh; done
288
289 ################################################################################
290
291 ################
292 # clean target #
293 ################
294
295 clean: unpatch
296         $(checkdir)
297         -rm -fr builddir-multi builddir-single builddir-hppa64 builddir-spu builddir-gold
298         -find . -name \*.gmo -o -name \*~ -o -name \*.info ! -name sysroff.info | xargs rm -f
299         -rm -f $(pwd)/test-summary*
300         -rm -fr $(d_bin) $(d_dev) $(d_mul) $(d_doc) $(d_hppa64) $(d_src) $(d_spu) $(d_gold)
301         -rm -rf debian/patched debian/tmp debian/files* debian/substvars
302         -rm -f debian/*.orig debian/*.rej
303         -rm -rf $(d_cross) debian/files debian/substvars 
304         -rm -rf builddir-$(TARGET) {configure,build,install}-cross-stamp
305         for i in debian/*.in; do \
306             case "$$i" in debian/control*.in) continue; esac; \
307             rm -f $${i%*.in}; \
308         done
309
310         -rm -f *-stamp
311
312 ################################################################################
313
314 #######################
315 # single-arch targets #
316 #######################
317
318 SINGLE_CONFARGS = $(CONFARGS)
319 ifeq ($(with_gold),yes)
320         SINGLE_CONFARGS += --enable-ld=default --enable-gold
321 endif
322
323 configure-single-stamp: patch-stamp
324         $(checkdir)
325
326 ifeq ($(with_check),yes)
327         @if echo "spawn true" | /usr/bin/expect -f - >/dev/null; then \
328           : ; \
329         else \
330           echo "expect is failing on your system with the above error, which means the"; \
331           echo "testsuite will fail.  Please resolve the above issues and retry the build."; \
332           echo "-----------------------------------------------------------------------------"; \
333           exit 1; \
334         fi
335 endif
336
337         rm -rf configure-single-stamp \
338                 builddir-single
339         mkdir builddir-single
340         cd builddir-single && env CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" \
341                 ../configure --with-sysroot=/ $(SINGLE_CONFARGS)
342         $(MAKE) -C builddir-single configure-host
343         touch configure-single-stamp
344
345 build-single-stamp: configure-single-stamp
346         $(checkdir)
347         env MAKE="$(MAKE) VERSION=$(SINGLE_VERSION)" \
348             $(MAKE) -C builddir-single/bfd headers
349         env MAKE="$(MAKE) VERSION=$(SINGLE_VERSION)" \
350             $(MAKE) $(NJOBS) -C builddir-single
351 ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
352 ifeq ($(with_check),yes)
353         -env MAKE="$(MAKE) VERSION=$(SINGLE_VERSION)" \
354             $(MAKE) -C builddir-single -k check
355         cat builddir-single/binutils/binutils.sum \
356             builddir-single/gas/testsuite/gas.sum \
357             builddir-single/ld/ld.sum >> $(pwd)/test-summary
358         set -e; \
359         if [ ! -f /usr/share/doc/binutils/test-summary.gz ]; then \
360           echo "No test results available for the installed binutils version"; \
361         elif [ -x /usr/bin/python ]; then \
362           echo "Test results, compared with installed binutils:"; \
363           zcat /usr/share/doc/binutils/test-summary.gz > test-summary-installed; \
364           if python debian/test-suite-compare.py test-summary-installed test-summary; then \
365             : ; \
366           elif [ -n "$(ignore_regressions)" ]; then \
367             echo "$(ignore_regressions)"; \
368           else \
369             false; \
370           fi; \
371         else \
372           echo "python not installed, not comparing test results."; \
373         fi
374 endif
375 endif
376         touch build-single-stamp
377
378
379 ################################################################################
380
381 #####################
382 # multiarch targets #
383 #####################
384
385 multiarch_targets = \
386         alpha-linux-gnu \
387         arm-linux-gnueabi \
388         hppa-linux-gnu \
389         i486-linux-gnu \
390         ia64-linux-gnu \
391         m68k-linux-gnu \
392         m68k-rtems \
393         mips-linux-gnu \
394         mipsel-linux-gnu \
395         mips64-linux-gnu \
396         mips64el-linux-gnu \
397         powerpc-linux-gnu \
398         powerpc64-linux-gnu \
399         s390-linux-gnu \
400         s390x-linux-gnu \
401         sh-linux-gnu \
402         sh64-linux-gnu \
403         sparc-linux-gnu \
404         sparc64-linux-gnu \
405         x86_64-linux-gnu \
406         m32r-linux-gnu \
407         spu
408
409 configure-multi-stamp: patch-stamp
410         $(checkdir)
411         rm -rf configure-multi-stamp \
412                 builddir-multi
413         mkdir builddir-multi
414         cd builddir-multi \
415             && env CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" ../configure $(CONFARGS) \
416                 --with-sysroot=/ \
417                 --disable-werror \
418                 --enable-targets=$(subst $(SPACE),$(COMMA),$(multiarch_targets))
419         $(MAKE) -C builddir-multi configure-host
420         touch configure-multi-stamp
421
422 build-multi-stamp: configure-multi-stamp
423         $(checkdir)
424         $(MAKE) -C builddir-multi/bfd headers
425         env MAKE="$(MAKE) VERSION=$(MULTI_VERSION)" \
426           $(MAKE) $(NJOBS) -C builddir-multi
427         touch build-multi-stamp
428
429 ################################################################################
430
431 #################
432 # static target #
433 #################
434
435 configure-static-stamp: patch-stamp
436         $(checkdir)
437         rm -rf configure-static-stamp \
438                 builddir-static
439         mkdir builddir-static
440         cd builddir-static \
441             && env CC="$(CC)" CXX="$(CXX)" CFLAGS="-g0 -Os" ../configure \
442                 --prefix=/$(PF) \
443                 --build=$(DEB_BUILD_GNU_TYPE) \
444                 --host=$(DEB_HOST_GNU_TYPE) \
445                 --with-pkgversion="GNU Binutils for $(DISTRIBUTION)"
446         $(MAKE) -C builddir-static configure-bfd
447         $(MAKE) -C builddir-static configure-ld
448         touch configure-static-stamp
449
450 build-static-stamp: configure-static-stamp
451         $(checkdir)
452         $(MAKE) $(NJOBS) -C builddir-static/libiberty CCLD='$(CC) -all-static'
453         $(MAKE) $(NJOBS) -C builddir-static/bfd CCLD='$(CC) -all-static'
454         $(MAKE) $(NJOBS) -C builddir-static/ld CCLD='$(CC) -all-static'
455         touch build-static-stamp
456
457 ################################################################################
458
459 #################
460 # hppa64 target #
461 #################
462
463 configure-hppa64-stamp: patch-stamp
464         $(checkdir)
465         rm -rf configure-hppa64-stamp \
466                 builddir-hppa64
467         mkdir builddir-hppa64
468         cd builddir-hppa64 \
469             && env CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" ../configure \
470                 --enable-shared \
471                 --prefix=/$(PF) \
472                 --build=$(DEB_BUILD_GNU_TYPE) \
473                 --host=$(DEB_HOST_GNU_TYPE) \
474                 --target=hppa64-linux-gnu
475         $(MAKE) -C builddir-hppa64 configure-host
476         touch configure-hppa64-stamp
477
478 build-hppa64-stamp: configure-hppa64-stamp
479         $(checkdir)
480         $(MAKE) -C builddir-hppa64/bfd headers
481         env MAKE="$(MAKE) VERSION=$(HPPA64_VERSION)" \
482           $(MAKE) $(NJOBS) -C builddir-hppa64
483         touch build-hppa64-stamp
484
485 ################################################################################
486
487 ##############
488 # spu target #
489 ##############
490
491 configure-spu-stamp: patch-stamp
492         $(checkdir)
493         rm -rf configure-spu-stamp \
494                 builddir-spu
495         mkdir builddir-spu
496         cd builddir-spu \
497             && env CC="$(CC)" CFLAGS="$(CFLAGS)" ../configure \
498                 --enable-shared \
499                 --prefix=/$(PF) \
500                 --program-prefix=spu- \
501                 --build=$(DEB_BUILD_GNU_TYPE) \
502                 --host=$(DEB_BUILD_GNU_TYPE) \
503                 --target=spu-elf
504         $(MAKE) -C builddir-spu configure-host
505         touch configure-spu-stamp
506
507 build-spu-stamp: configure-spu-stamp
508         $(checkdir)
509         $(MAKE) -C builddir-spu/bfd headers
510         env MAKE="$(MAKE) VERSION=$(SPU_VERSION)" \
511           $(MAKE) $(NJOBS) -C builddir-spu
512         touch build-spu-stamp
513
514 ################################################################################
515
516 pre-build:
517 #ifneq (,$(filter $(DEB_HOST_ARCH), armel powerpc))
518 #       @echo Build it ...
519 #else
520 #       @echo Explicitely fail the build for architecture $(DEB_HOST_ARCH)
521 #       false
522 #endif
523
524 build_stamps = build-single-stamp
525 ifeq ($(with_multiarch),yes)
526        build_stamps += build-multi-stamp
527 endif
528 ifeq ($(DEB_HOST_ARCH),hppa)
529        build_stamps += build-hppa64-stamp
530 endif
531 ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64))
532        build_stamps += build-spu-stamp
533 endif
534 ifneq (,$(TARGET))
535   ifneq (,$(findstring static-cross,$(DEB_BUILD_OPTIONS)))
536        build_stamps = build-static-cross-stamp
537   else
538        build_stamps = build-cross-stamp
539   endif
540 endif
541
542 ifeq ($(BACKPORT),true)
543     build_stamps :=
544     with_check := no
545 endif
546
547 build: pre-build build-stamp
548 build-stamp: $(build_stamps)
549         touch build-stamp
550
551 ################################################################################
552
553 ##################
554 # install target #
555 ##################
556
557 install_stamps = install-stamp
558 ifeq ($(DEB_HOST_ARCH),hppa)
559        install_stamps += install-hppa64-stamp
560 endif
561 ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64))
562        install_stamps += install-spu-stamp
563 endif
564 ifneq (,$(TARGET))
565   ifneq (,$(findstring static-cross,$(DEB_BUILD_OPTIONS)))
566         install_stamps = install-static-cross-stamp
567   else
568         install_stamps = install-cross-stamp
569   endif
570 endif
571 ifeq ($(BACKPORT),true)
572     install_stamps :=
573 endif
574 install: $(install_stamps)
575 install-stamp: checkroot build-stamp
576         $(checkdir)
577
578         rm -fr $(d_bin) $(d_dev) $(d_mul) $(d_doc) $(d_src)
579         $(install_dir) $(d_bin) $(d_dev) $(d_mul) $(d_doc) $(d_src)
580
581         : # install binutils and -dev stuff
582         env MAKE="$(MAKE) VERSION=$(SINGLE_VERSION)" \
583           $(MAKE) -C builddir-single \
584                 CFLAGS="$(CFLAGS)" prefix=$(pwd)/$(d_bin)/$(PF) \
585                 mandir=$(pwd)/$(d_bin)/$(PF)/share/man \
586                 infodir=$(pwd)/$(d_doc)/$(PF)/share/info install
587
588 ifeq ($(with_multiarch),yes)
589         : # now install binutils-multiarch stuff
590         env MAKE="$(MAKE) VERSION=$(MULTI_VERSION)" \
591           $(MAKE) -C builddir-multi \
592                 CFLAGS="$(CFLAGS)" \
593                 prefix=$(pwd)/$(d_mul)/$(PF) \
594                 mandir=$(pwd)/$(d_mul)/$(PF)/share/man \
595                 infodir=$(pwd)/$(d_doc)/$(PF)/share/info install
596 endif
597
598         : # copy libiberty.h ... not too keen on this, but it was requested
599         cp -f include/libiberty.h $(d_bin)/$(PF)/include
600
601         : # copy demangle.h ... not too keen on this, but it was requested
602         cp -f include/demangle.h $(d_bin)/$(PF)/include
603
604         : # copy plugin-api.h ...
605         cp -f include/plugin-api.h $(d_bin)/$(PF)/include
606
607         : # We don't need to distribute everything in binutils and -dev
608         rm -rf $(d_bin)/$(PF)/include/obstack.h
609         rm -f $(d_bin)/$(PF)/man/man1/configure.1
610         rm -f $(d_doc)/$(PF)/share/info/configure.* $(d_doc)/$(PF)/share/info/standards.*
611         : # *sigh*, bugs.debian.org/213524
612         rm -f $(d_doc)/$(PF)/share/info/dir*
613
614 ifeq ($(with_multiarch),yes)
615         : # Now get rid of just about everything in binutils-multiarch
616         rm -rf $(d_mul)/$(PF)/man $(d_mul)/$(PF)/info $(d_mul)/$(PF)/include
617         rm -rf $(d_mul)/$(PF)/share/man $(d_mul)/$(PF)/share/info $(d_mul)/$(PF)/share/locale
618
619         : # elfedit (even with its --input-mach option)
620         : # is the same for all targets.
621         rm -f $(d_mul)/$(PF)/bin/elfedit
622
623         : # c++filt does not link to libbfd for anything more than
624         : # the help message, and its behavior does not vary
625         : # between arches aside from the --version message.
626         rm -f $(d_mul)/$(PF)/bin/c++filt
627
628         : # As gas/README points out (search for --enable-targets),
629         : # multi-arch gas is not ready yet.
630         rm -f $(d_mul)/$(PF)/bin/as
631         rm -f $(d_mul)/$(PF)/bin/ld
632         rm -f $(d_mul)/$(PF)/bin/ld.bfd
633         rm -f $(d_mul)/$(PF)/bin/ld.gold
634         rm -fr $(d_mul)/$(PF)/lib/ldscripts
635
636   ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64))
637         rm -f $(d_mul)/$(PF)/bin/embedspu
638   endif
639 endif
640
641         $(install_dir) $(d_dev)/$(PF)/include/ $(d_dev)/$(PF)/lib/
642         mv $(d_bin)/$(PF)/include/* $(d_dev)/$(PF)/include/
643         mv $(d_bin)/$(PF)/lib/*.a $(d_bin)/$(PF)/lib/libbfd.so $(d_bin)/$(PF)/lib/libopcodes.so \
644            $(d_dev)/$(PF)/lib/
645
646 ifeq ($(with_multiarch),yes)
647         rm -f $(d_mul)/$(PF)/lib/libbfd.so $(d_mul)/$(PF)/lib/libopcodes.so
648         rm -f $(d_mul)/$(PF)/lib/*.la $(d_mul)/$(PF)/lib/*.a
649         rm -f $(d_mul)/$(PF)/lib*/libiberty*
650 endif
651
652         : # Get rid of .la files since libtool obviously has no idea about transient paths
653         rm -f $(d_bin)/$(PF)/lib/*.la
654
655 ifeq ($(with_strip),yes)
656         : # Strip shared libraries
657         $(STRIP) --strip-unneeded $(d_bin)/$(PF)/lib/libbfd-*so
658         $(STRIP) --strip-unneeded $(d_bin)/$(PF)/lib/libopcodes-*so
659
660         chmod ugo-x $(d_bin)/$(PF)/lib/*.so
661
662         $(STRIP) $$(file $(d_bin)/$(PF)/bin/* |awk -F: '$$0 !~ /script/ {print $$1}')
663
664   ifeq ($(with_multiarch),yes)
665         $(STRIP) --strip-unneeded $(d_mul)/$(PF)/lib/libbfd-*so
666         $(STRIP) --strip-unneeded $(d_mul)/$(PF)/lib/libopcodes-*so
667
668         chmod ugo-x $(d_mul)/$(PF)/lib/*.so
669
670         $(STRIP) $$(file $(d_mul)/$(PF)/bin/* |awk -F: '$$0 !~ /script/ {print $$1}')
671   endif
672 endif
673
674         : # Don't want /usr/<arch>-linux to exist in any package
675         rm -rf $(d_bin)/$(PF)/$(DEB_HOST_GNU_TYPE)
676
677         : # Remove windres manpages
678         rm -f $(d_bin)/$(PF)/share/man/man1/windres.1
679
680 ifeq ($(with_multiarch),yes)
681         rm -rf $(d_mul)/$(PF)/$(DEB_HOST_GNU_TYPE)
682         rm -f $(d_mul)/$(PF)/share/man/man1/windres.1
683 endif
684
685         rm -f $(d_bin)/$(PF)/bin/ld
686         ln -s ld.bfd $(d_bin)/$(PF)/bin/ld
687 ifeq ($(with_gold),yes)
688         ln -s ld.gold $(d_bin)/$(PF)/bin/gold
689         mv $(d_bin)/$(PF)/share/man/man1/ld.1 \
690                 $(d_bin)/$(PF)/share/man/man1/ld.bfd.1
691         ln -s ld.bfd.1.gz $(d_bin)/$(PF)/share/man/man1/ld.1.gz
692   ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
693         if which help2man >/dev/null 2>&1; then \
694           help2man $(d_bin)/$(PF)/bin/ld.gold > debian/ld.gold.1; \
695         fi
696   endif
697         cp debian/ld.gold.1 $(d_bin)/$(PF)/share/man/man1/
698         ln -s ld.gold.1.gz $(d_bin)/$(PF)/share/man/man1/gold.1.gz
699
700         : # install a symlink for the gold linker
701         $(install_dir) $(d_bin)/$(PF)/lib/gold-ld
702         ln -s ../../bin/ld.gold $(d_bin)/$(PF)/lib/gold-ld/ld
703
704         : # only keep the gold linker diversion to it's own package.
705         rm -fr $(d_gold)
706         $(install_dir) $(d_gold)
707         $(install_dir) $(d_gold)/$(PF)/bin
708         $(install_dir) $(d_gold)/$(PF)/share/man/man1
709         ln -s ld.gold $(d_gold)/$(PF)/bin/ld
710         ln -s ld.gold.1.gz $(d_gold)/$(PF)/share/man/man1/ld.1.gz
711 endif
712         : # install a symlink for the old linker
713         $(install_dir) $(d_bin)/$(PF)/lib/compat-ld
714         ln -s ../../bin/ld.bfd $(d_bin)/$(PF)/lib/compat-ld/ld
715
716         : # Remove empty directory
717         rmdir $(d_bin)/$(PF)/include/
718
719         : # install libiberty PIC library
720         $(install_file) builddir-single/libiberty/pic/libiberty.a \
721                 $(d_dev)/$(PF)/lib/libiberty_pic.a
722
723         touch install-stamp
724
725 install-hppa64-stamp: checkroot build-hppa64-stamp
726         $(checkdir)
727
728         rm -fr $(d_hppa64)
729         $(install_dir) $(d_hppa64)
730         $(install_dir) $(d_hppa64)/$(PF)/lib
731
732         : # install binutils-hppa64 stuff
733         env MAKE="$(MAKE) VERSION=$(HPPA64_VERSION)" \
734           $(MAKE) -C builddir-hppa64 \
735                 CFLAGS="$(CFLAGS)" \
736                 prefix=$(pwd)/$(d_hppa64)/$(PF)/ \
737                 mandir=$(pwd)/$(d_hppa64)/$(PF)/share/man \
738                 infodir=$(pwd)/$(d_hppa64)/$(PF)/share/info install
739
740         : # move shared libs to the standard path
741         mv $(d_hppa64)/$(PF)/$(DEB_HOST_GNU_TYPE)/hppa64-linux-gnu/lib/lib*-*.so \
742                 $(d_hppa64)/$(PF)/lib/.
743
744         : # Now get rid of just about everything in binutils-hppa64
745         rm -rf $(d_hppa64)/$(PF)/man
746         rm -rf $(d_hppa64)/$(PF)/info
747         rm -rf $(d_hppa64)/$(PF)/include
748         rm -rf $(d_hppa64)/$(PF)/share
749         rm -rf $(d_hppa64)/$(PF)/hppa-linux-gnu
750         rm -rf $(d_hppa64)/$(PF)/lib/libiberty.a
751
752 ifeq ($(with_strip),yes)
753         : # Strip shared libraries
754         $(STRIP) --strip-unneeded $(d_hppa64)/$(PF)/lib/libbfd-*so
755         $(STRIP) --strip-unneeded $(d_hppa64)/$(PF)/lib/libopcodes-*so
756         $(STRIP) $$(file $(d_hppa64)/$(PF)/bin/* | awk -F: '$$0 !~ /script/ {print $$1}')
757 endif
758
759         chmod ugo-x $(d_hppa64)/$(PF)/lib/*.so
760
761         : # Don't want /usr/<arch>-linux to exist in any package
762         rm -rf $(d_hppa64)/$(PF)/hppa64-linux-gnu
763
764         touch install-hppa64-stamp
765
766 install-static-stamp: checkroot build-static-stamp
767         $(checkdir)
768
769         rm -fr $(d_static) $(d_udeb)
770         $(install_dir) $(d_static) $(d_udeb)
771
772         : # Copy static ld-new into /bin for both -static and -static-udeb
773         $(install_dir) $(d_static)/bin
774         $(install_binary) builddir-static/ld/ld-new $(d_static)/bin/ld_static
775         $(install_dir) $(d_udeb)/bin
776         $(install_binary) builddir-static/ld/ld-new $(d_udeb)/bin/ld_static
777 ifeq ($(with_strip),yes)
778         pkg_create_dbgsym $(p_static) $(d_static) || true
779         $(STRIP) --strip-unneeded $(d_static)/bin/ld_static $(d_udeb)/bin/ld_static
780 endif
781
782         touch install-static-stamp
783
784 install-spu-stamp: checkroot build-spu-stamp
785         $(checkdir)
786
787         rm -fr $(d_spu)
788         $(install_dir) $(d_spu)
789         $(install_dir) $(d_spu)/$(PF)/lib
790
791         : # install binutils-spu stuff
792         env MAKE="$(MAKE) VERSION=$(SPU_VERSION)" \
793           $(MAKE) -C builddir-spu \
794                 CFLAGS="$(CFLAGS)" \
795                 prefix=$(pwd)/$(d_spu)/$(PF)/ \
796                 mandir=$(pwd)/$(d_spu)/$(PF)/share/man \
797                 infodir=$(pwd)/$(d_spu)/$(PF)/share/info install
798
799         : # move shared libs to the standard path
800         mv $(d_spu)/$(PF)/$(DEB_HOST_GNU_TYPE)/spu-elf/lib/lib*-*.so \
801                 $(d_spu)/$(PF)/lib/.
802
803         : # Now get rid of just about everything in binutils-spu
804         rm -rf $(d_spu)/$(PF)/man
805         rm -rf $(d_spu)/$(PF)/info
806         rm -rf $(d_spu)/$(PF)/include
807         rm -rf $(d_spu)/$(PF)/share
808         rm -rf $(d_spu)/$(PF)/$(DEB_HOST_GNU_TYPE)
809         rm -rf $(d_spu)/$(PF)/lib/libiberty.a
810         rm -rf $(d_spu)/$(PF)/lib/ldscripts
811
812 ifeq ($(with_strip),yes)
813         : # Strip shared libraries
814         $(STRIP) --strip-unneeded $(d_spu)/$(PF)/lib/libbfd-*so
815         $(STRIP) --strip-unneeded $(d_spu)/$(PF)/lib/libopcodes-*so
816         $(STRIP) $$(file $(d_spu)/$(PF)/bin/* | awk -F: '$$0 !~ /script/ {print $$1}')
817 endif
818
819         chmod ugo-x $(d_spu)/$(PF)/lib/*.so
820
821         : # Don't want /usr/<arch>-linux to exist in any package
822         rm -rf $(d_spu)/$(PF)/spu-elf
823
824         touch install-spu-stamp
825
826 ################################################################################
827
828 #######################
829 # binary-indep target #
830 #######################
831
832 binary-indep: checkroot build install
833         $(checkdir)
834
835         rm -f debian/files debian/substvars
836
837 ifneq ($(DISTRIBUTION),SLP)
838
839 # Cross builds do not have documentation packages
840 ifeq (,$(TARGET))
841
842         $(install_dir) $(d_doc)/DEBIAN
843
844 ifneq ($(BACKPORT),true)
845         $(install_dir) $(d_doc)/$(PF)/share/doc/$(p_doc)/
846         $(install_file) debian/changelog $(d_doc)/$(PF)/share/doc/$(p_doc)/changelog.Debian
847         $(install_file) debian/copyright $(d_doc)/$(PF)/share/doc/$(p_doc)/
848         for i in bfd gas gprof ld; do \
849           ln -sf ../$(p_bin)/$$i $(d_doc)/$(PF)/share/doc/$(p_doc)/$$i; \
850         done
851         find $(d_doc)/$(PF)/share/doc/$(p_doc) -maxdepth 1 -type f ! -name copyright | xargs gzip -9
852         gzip -9 $(d_doc)/$(PF)/share/info/*
853
854         dpkg-gencontrol -isp -P$(d_doc) -p$(p_doc)
855         chown -R root:root $(d_doc)
856         chmod -R go=rX  $(d_doc)
857         dpkg --build $(d_doc) ..
858
859         $(install_dir) $(d_src)/$(PF)/share/doc/$(p_src)/
860         $(install_file) debian/changelog $(d_src)/$(PF)/share/doc/$(p_src)/changelog.Debian
861         $(install_file) debian/copyright $(d_src)/$(PF)/share/doc/$(p_src)/
862         find $(d_src)/$(PF)/share/doc/$(p_src) -maxdepth 1 -type f ! -name copyright | xargs gzip -9
863 endif # ifndef BACKPORT
864
865         $(install_dir) $(d_src)/DEBIAN
866         $(install_dir) $(d_src)/$(PF)/src/binutils/patches
867         $(install_file) debian/patches/* $(d_src)/$(PF)/src/binutils/patches/
868         tar -c --xz -C .. --exclude=CVS \
869                 -f $(pwd)/$(d_src)/$(PF)/src/binutils/binutils-$(VERSION).tar.xz \
870                 $(source_files)
871
872         tar cf - $$(find './debian' -mindepth 1 \( \
873                 -path './debian/binutils*' -type d -prune -o \
874                 -path './debian/patches' -prune -o \
875                 -path './debian/tmp*' -prune -o \
876                 -path './debian/.bzr*' -prune -o \
877                 -path './debian/files' -prune -o \
878                 -print \) ) \
879           | tar -x -C $(d_src)/$(PF)/src/binutils -f -
880         -chmod 755 $(d_src)/$(PF)/src/binutils/debian/*.{pre,post}{inst,rm}
881         chmod 755 $(d_src)/$(PF)/src/binutils/debian/test-suite-compare.py
882
883         dpkg-gencontrol -isp -P$(d_src) -p$(p_src)
884         chown -R root:root $(d_src)
885         chmod -R go=rX  $(d_src)
886         dpkg --build $(d_src) ..
887 endif
888
889 endif
890
891 ################################################################################
892
893 #######################
894 # binary-arch target  #
895 #######################
896
897 binary-arch: checkroot build install
898         $(checkdir)
899
900 ifneq ($(BACKPORT),true)
901 # Process the following only if $(TARGET) is set
902 ifneq (,$(TARGET))
903         test "" != "$(TARGET)"
904
905         rm -rf $(d_cross)/$(PF)/share/info $(d_cross)/$(PF)/share/man
906
907         sed "/^$$/ q" < debian/control.in > debian/control
908         sed -e "s/__TARGET__/$$(echo -n $(TARGET) | sed s/_/-/g)/" \
909                  < debian/control.cross.in >> debian/control
910
911         $(install_dir) $(d_cross)/DEBIAN
912
913         $(install_dir) $(d_cross)/$(PF)/share/doc/$(p_cross)/
914         $(install_file) debian/changelog $(d_cross)/$(PF)/share/doc/$(p_cross)/changelog.Debian
915         $(install_file) debian/copyright debian/README.cross $(d_cross)/$(PF)/share/doc/$(p_cross)/
916         gzip -9f $(d_cross)/$(PF)/share/doc/$(p_cross)/changelog.Debian
917
918         for pkg in bfd gas gprof ld; do \
919           ln -sf ../binutils/$$pkg $(d_cross)/$(PF)/share/doc/$(p_cross)/$$pkg; \
920         done
921
922         rm -f debian/substvars
923         dpkg-shlibdeps $(d_cross)/$(PF)/bin/*
924         dpkg-gencontrol -isp -P$(d_cross) -p$(p_cross)
925         dpkg --build $(d_cross) ..
926
927 else
928         cp debian/control.in debian/control
929         : # generate some control & helper files
930         nver=$$(echo $(DEB_UPSTREAM) | awk -F. '{ OFS="."; $$NF=$$NF+1; print }'); \
931         for i in debian/*.in; do \
932             case "$$i" in debian/control.cross.in) continue; esac; \
933             sed -e 's/@VER@/$(VERSION)/g' \
934                 -e 's/@DEB_VER@/$(DEB_VERSION)/g' \
935                 -e 's/@DEB_SVER@/$(DEB_SVERSION)/g' \
936                 -e 's/@DEB_UVER@/$(DEB_UPSTREAM)/g' \
937                 -e "s/@DEB_NVER@/$$nver/g" \
938                 -e 's/@DATE_EXT@/$(DATE_EXT)/g' \
939                 $$i > $${i%*.in}; \
940         done
941
942         : # make lintian happy
943         $(install_file) -D debian/$(p_bin).overrides \
944                 $(d_bin)/$(PF)/share/lintian/overrides/$(p_bin)
945 ifeq ($(with_multiarch),yes)
946         $(install_file) -D debian/$(p_mul).overrides \
947                 $(d_mul)/$(PF)/share/lintian/overrides/$(p_mul)
948 endif
949 ifeq ($(with_gold),yes)
950         $(install_file) -D debian/$(p_gold).overrides \
951                 $(d_gold)/$(PF)/share/lintian/overrides/$(p_gold)
952 endif
953 ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64))
954         $(install_file) -D debian/$(p_spu).overrides \
955                 $(d_spu)/$(PF)/share/lintian/overrides/$(p_spu)
956 endif
957 ifeq ($(DEB_HOST_ARCH),hppa)
958         $(install_file) -D debian/$(p_hppa64).overrides \
959                 $(d_hppa64)/$(PF)/share/lintian/overrides/$(p_hppa64)
960 endif
961
962         : # install maintainer scrtips
963         $(install_dir) $(d_bin)/DEBIAN
964         $(install_script) debian/binutils.postinst $(d_bin)/DEBIAN/postinst
965         $(install_script) debian/binutils.postrm $(d_bin)/DEBIAN/postrm
966         $(install_file) debian/binutils.shlibs $(d_bin)/DEBIAN/shlibs
967
968         $(install_dir) $(d_dev)/DEBIAN
969
970 ifeq ($(with_multiarch),yes)
971         $(install_dir) $(d_mul)/DEBIAN
972         $(install_script) debian/binutils-multiarch.preinst $(d_mul)/DEBIAN/preinst
973         $(install_script) debian/binutils-multiarch.postinst $(d_mul)/DEBIAN/postinst
974         $(install_script) debian/binutils-multiarch.prerm $(d_mul)/DEBIAN/prerm
975         $(install_script) debian/binutils-multiarch.postrm $(d_mul)/DEBIAN/postrm
976         $(install_file) debian/binutils-multiarch.shlibs $(d_mul)/DEBIAN/shlibs
977 endif
978
979 ifeq ($(with_gold),yes)
980         $(install_dir) $(d_gold)/DEBIAN
981         $(install_script) debian/binutils-gold.postrm $(d_gold)/DEBIAN/postrm
982         $(install_script) debian/binutils-gold.preinst $(d_gold)/DEBIAN/preinst
983 endif
984
985 ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64))
986         $(install_dir) $(d_spu)/DEBIAN
987         $(install_script) debian/binutils-spu.postinst $(d_spu)/DEBIAN/postinst
988         $(install_script) debian/binutils-spu.postrm $(d_spu)/DEBIAN/postrm
989         $(install_file) debian/binutils-spu.shlibs $(d_spu)/DEBIAN/shlibs
990 endif
991
992 ifeq ($(DEB_HOST_ARCH),hppa)
993         $(install_dir) $(d_hppa64)/DEBIAN
994         $(install_script) debian/binutils-hppa64.postinst $(d_hppa64)/DEBIAN/postinst
995         $(install_script) debian/binutils-hppa64.postrm $(d_hppa64)/DEBIAN/postrm
996         $(install_file) debian/binutils-hppa64.shlibs $(d_hppa64)/DEBIAN/shlibs
997 endif
998
999         : # install docs
1000         $(install_dir) $(d_bin)/$(PF)/share/doc/$(p_bin)/
1001         $(install_file) debian/changelog $(d_bin)/$(PF)/share/doc/$(p_bin)/changelog.Debian
1002         $(install_file) debian/copyright $(d_bin)/$(PF)/share/doc/$(p_bin)/
1003
1004         $(install_dir) $(d_dev)/$(PF)/share/doc/
1005         ln -sf $(p_bin) $(d_dev)/$(PF)/share/doc/$(p_dev)
1006 ifeq ($(with_multiarch),yes)
1007         $(install_dir) $(d_mul)/$(PF)/share/doc/
1008         ln -sf $(p_bin) $(d_mul)/$(PF)/share/doc/$(p_mul)
1009 endif
1010 ifeq ($(with_gold),yes)
1011         $(install_dir) $(d_gold)/$(PF)/share/doc/
1012         ln -sf $(p_bin) $(d_gold)/$(PF)/share/doc/$(p_gold)
1013 endif
1014 ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64))
1015         $(install_dir) $(d_spu)/$(PF)/share/doc/
1016         ln -sf $(p_bin) $(d_spu)/$(PF)/share/doc/$(p_spu)
1017 endif
1018 ifeq ($(DEB_HOST_ARCH),hppa)
1019         $(install_dir) $(d_hppa64)/$(PF)/share/doc/
1020         ln -sf $(p_bin) $(d_hppa64)/$(PF)/share/doc/$(p_hppa64)
1021 endif
1022
1023 ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
1024 ifeq ($(with_check),yes)
1025         $(install_file) $(pwd)/test-summary $(d_bin)/$(PF)/share/doc/$(p_bin)/
1026 endif
1027 endif
1028         $(install_file) binutils/NEWS debian/README.cross \
1029                         $(d_bin)/$(PF)/share/doc/$(p_bin)/
1030
1031         $(install_file) binutils/ChangeLog $(d_bin)/$(PF)/share/doc/$(p_bin)/changelog
1032
1033         for pkg in bfd gas gprof ld; do \
1034           $(install_dir) $(d_bin)/$(PF)/share/doc/$(p_bin)/$$pkg; \
1035         done
1036         $(install_file) bfd/ChangeLog bfd/PORTING bfd/TODO \
1037                         $(d_bin)/$(PF)/share/doc/$(p_bin)/bfd/
1038         $(install_file) gas/ChangeLog gas/NEWS $(d_bin)/$(PF)/share/doc/$(p_bin)/gas/
1039         $(install_file) gprof/ChangeLog gprof/TODO gprof/TEST \
1040                         $(d_bin)/$(PF)/share/doc/$(p_bin)/gprof/
1041         $(install_file) ld/ChangeLog ld/TODO ld/NEWS \
1042                         $(d_bin)/$(PF)/share/doc/$(p_bin)/ld/
1043
1044         : # These only exist in H. J. Lu releases not GNU ones.
1045         for dir in binutils bfd gas gprof ld; do \
1046           if [ -f $$dir/ChangeLog.linux ]; then \
1047             $(install_file) $$dir/ChangeLog.linux $(d_bin)/$(PF)/share/doc/$(p_bin)/$$dir/; \
1048           fi; \
1049         done
1050
1051         : # Copy bbconv.pl to the doc dir for use by interested people
1052         $(install_file) gprof/bbconv.pl $(d_bin)/$(PF)/share/doc/$(p_bin)/gprof/.
1053
1054         : # Compress stuff that needs it
1055         gzip -9 $(d_bin)/$(PF)/share/man/man1/*.1
1056         find $(d_bin)/$(PF)/share/doc/$(p_bin)/ -type f ! -name copyright -a ! -name bbconv.pl | xargs gzip -9
1057
1058         : # Finish it all up
1059         find $(d_bin) -type f | xargs file | grep ELF | cut -d: -f 1 | xargs dpkg-shlibdeps
1060         dpkg-gencontrol -isp -P$(d_bin) -p$(p_bin) $(CONFLICTS)
1061
1062         rm -f debian/substvars
1063         dpkg-gencontrol -isp -P$(d_dev) -p$(p_dev)
1064
1065 ifeq ($(with_multiarch),yes)
1066         rm -f debian/substvars
1067         find $(d_mul) -type f | xargs file | grep ELF | cut -d: -f 1 | xargs dpkg-shlibdeps
1068         dpkg-gencontrol -isp -P$(d_mul) -p$(p_mul)
1069 endif
1070
1071 ifeq ($(with_gold),yes)
1072         rm -f debian/substvars
1073 # no binary
1074 #       find $(d_gold) -type f | xargs file | grep ELF | cut -d: -f 1 | xargs dpkg-shlibdeps
1075         dpkg-gencontrol -isp -P$(d_gold) -p$(p_gold)
1076 endif
1077 ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64))
1078         rm -f debian/substvars
1079         find $(d_spu) -type f | xargs file | grep ELF | cut -d: -f 1 | xargs dpkg-shlibdeps
1080         dpkg-gencontrol -isp -P$(d_spu) -p$(p_spu)
1081 endif
1082 ifeq ($(DEB_HOST_ARCH),hppa)
1083         rm -f debian/substvars
1084         find $(d_hppa64) -type f | xargs file | grep ELF | cut -d: -f 1 | xargs dpkg-shlibdeps
1085         dpkg-gencontrol -isp -P$(d_hppa64) -p$(p_hppa64)
1086 endif
1087
1088         chown -R root:root $(d_bin) $(d_dev)
1089         chmod -R go=rX  $(d_bin) $(d_dev)
1090         dpkg --build $(d_bin) ..
1091         dpkg --build $(d_dev) ..
1092 ifeq ($(with_multiarch),yes)
1093         chown -R root:root $(d_mul)
1094         chmod -R go=rX  $(d_mul)
1095         dpkg --build $(d_mul) ..
1096 endif
1097 ifeq ($(with_gold),yes)
1098         chown -R root:root $(d_gold)
1099         chmod -R go=rX  $(d_gold)
1100         dpkg --build $(d_gold) ..
1101 endif
1102 ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64))
1103         chown -R root:root $(d_spu)
1104         chmod -R go=rX  $(d_spu)
1105         dpkg --build $(d_spu) ..
1106 endif
1107 ifeq ($(DEB_HOST_ARCH),hppa)
1108         chown -R root:root $(d_hppa64)
1109         chmod -R go=rX  $(d_hppa64)
1110         dpkg --build $(d_hppa64) ..
1111 endif
1112
1113 endif # Process the following only if $(TARGET) is set
1114 endif # ifndef BACKPORT
1115 ################################################################################
1116
1117 #################
1118 # cross targets #
1119 #################
1120
1121
1122 # Support TARGET both as Debian architecture specification (e.g. arm),
1123 # and as the target name (e.g. arm-linux-gnu).
1124 try_convert := $(shell dpkg-architecture -f -a$(TARGET) -qDEB_HOST_GNU_TYPE 2>/dev/null)
1125 ifneq ($(try_convert),)
1126 override TARGET := $(try_convert)
1127 endif
1128
1129 # Process the following only if $(TARGET) is set
1130 ifneq (,$(TARGET))
1131
1132 p_cross = $(subst _,-,binutils-$(TARGET))
1133 d_cross = debian/$(p_cross)
1134
1135 ifneq ($(filter sparc-linux-gnu powerpc-linux-gnu mips-linux-gnu, $(TARGET)),)
1136 ADDITIONAL_TARGETS = --enable-targets=$(TARGET:%-linux-gnu=%64-linux-gnu)
1137 endif
1138 ifneq ($(filter i386-linux-gnu i486-linux-gnu i586-linux-gnu i686-linux-gnu x86-linux-gnu, $(TARGET)),)
1139 ADDITIONAL_TARGETS = --enable-targets=x86_64-linux-gnu
1140 endif
1141 ifneq ($(filter i386-kfreebsd-gnu i486-kfreebsd-gnu i586-kfreebsd-gnu x86-kfreebsd-gnu, $(TARGET)),)
1142 ADDITIONAL_TARGETS = --enable-targets=x86_64-linux-gnu
1143 endif
1144 ifeq ($(TARGET), x86_64-linux-gnu)
1145 ADDITIONAL_TARGETS = --enable-targets=i486-linux-gnu
1146 endif
1147 ifeq ($(TARGET), x86_64-kfreebsd-gnu)
1148 ADDITIONAL_TARGETS = --enable-targets=i486-kfreebsd-gnu
1149 endif
1150 ifeq ($(TARGET), mipsel-linux-gnu)
1151 ADDITIONAL_TARGETS = --enable-targets=mips64el-linux-gnu
1152 endif
1153 ifeq ($(TARGET), sparc64-linux-gnu)
1154 ADDITIONAL_TARGETS = --enable-targets=sparc-linux-gnu
1155 endif
1156 ifeq ($(TARGET), s390-linux-gnu)
1157 ADDITIONAL_TARGETS = --enable-targets=s390x-linux-gnu
1158 endif
1159 ifeq ($(TARGET), s390x-linux-gnu)
1160 ADDITIONAL_TARGETS = --enable-targets=s390-linux-gnu
1161 endif
1162
1163 #-----------------------------------------------------------------
1164 # sysroot options
1165 ifdef WITH_SYSROOT
1166   with_sysroot = $(WITH_SYSROOT)
1167 endif
1168 ifdef WITH_BUILD_SYSROOT
1169   with_build_sysroot = $(WITH_BUILD_SYSROOT)
1170 endif
1171
1172 CROSS_CONFARGS := $(ADDITIONAL_TARGETS) $(CONFARGS) 
1173 ifneq ($(with_sysroot),)
1174   CROSS_CONFARGS += --with-sysroot=$(with_sysroot)
1175 endif
1176 ifneq ($(with_build_sysroot),)
1177   CROSS_CONFARGS += --with-build-sysroot=$(with_build_sysroot)
1178 endif
1179 ifeq ($(with_gold),yes)
1180   CROSS_CONFARGS += --enable-ld=default --enable-gold
1181 endif
1182
1183 configure-cross-stamp: patch-stamp patch-cross-stamp
1184         $(checkdir)
1185         test "" != "$(TARGET)"
1186         rm -rf configure-cross-stamp builddir-$(TARGET)
1187         mkdir builddir-$(TARGET)
1188         cd builddir-$(TARGET) \
1189             && env CC="$(CC)" CXX="$(CXX)" ../configure --host=$(DEB_HOST_GNU_TYPE) \
1190                 --build=$(DEB_BUILD_GNU_TYPE) --target=$(TARGET) --prefix=/$(PF) \
1191                 $(CROSS_CONFARGS)
1192         touch $@
1193
1194 build-cross-stamp: configure-cross-stamp
1195         $(checkdir)
1196         test "" != "$(TARGET)"
1197         $(MAKE) -C builddir-$(TARGET) $(NJOBS) CFLAGS="$(CFLAGS)"
1198         touch $@
1199
1200 install-cross-stamp: build-cross-stamp
1201         $(checkdir)
1202         test "" != "$(TARGET)"
1203         rm -rf $(d_cross)
1204         $(MAKE) -C builddir-$(TARGET) prefix=$(pwd)/$(d_cross)/$(PF) \
1205                 mandir=$(pwd)/$(d_cross)/$(PF)/share/man install
1206         rm -rf $(d_cross)/$(PF)/lib* $(d_cross)/$(PF)/info $(d_cross)/$(PF)/share/locale
1207 ifeq ($(with_strip),yes)
1208         $(STRIP) $$(file $(d_cross)/$(PF)/bin/* | awk -F: '$$0 !~ /script/ {print $$1}')
1209
1210         chmod ugo-x $(d_cross)/$(PF)/$(DEB_HOST_GNU_TYPE)/$(TARGET)/lib/*.so
1211 endif
1212         gzip -9 $(d_cross)/$(PF)/share/man/man1/*
1213         touch $@
1214
1215 configure-host-cross-stamp: configure-cross-stamp
1216         $(checkdir)
1217         test "" != "$(TARGET)"
1218         $(MAKE) configure-host -C builddir-$(TARGET) $(NJOBS) CFLAGS="$(CFLAGS)"
1219         touch $@
1220
1221 build-static-cross-stamp: configure-host-cross-stamp
1222         $(checkdir)
1223         test "" != "$(TARGET)"
1224         $(MAKE) -C builddir-$(TARGET) $(NJOBS) CFLAGS="$(CFLAGS)" LDFLAGS="-all-static"
1225         touch $@
1226
1227 install-static-cross-stamp: build-static-cross-stamp install-cross-stamp
1228
1229 binary-cross: 
1230         @echo "Please use dpkg-buildpackage instead of calling binary-cross directly; see README.cross"
1231         @false
1232
1233 endif
1234
1235 ################################################################################
1236
1237 define checkdir
1238         test -f bfd/elf32.c -a -f debian/rules
1239 endef
1240
1241 # Below here is fairly generic really
1242
1243 binary:         binary-indep binary-arch
1244
1245 checkroot:
1246         $(checkdir)
1247         test root = "`whoami`"
1248
1249 .PHONY: binary binary-arch binary-indep clean checkroot