Release to experimental.
[collab-maint/mingw-w64.git] / debian / rules
1 #!/usr/bin/make -f
2 # -*- makefile -*-
3 # Build mingw-w64.
4 # Copyright © 2010 Stephen Kitt <steve@sk2.org>
5
6 SHELL=/bin/bash
7
8 # Uncomment this to turn on verbose mode.
9 #export DH_VERBOSE=1
10
11 top_dir := $(shell pwd)
12 build_dir := $(top_dir)/build
13 stampdir := $(top_dir)/stamp
14 deb_version := $(shell dpkg-parsechangelog | sed -ne "s/^Version: \(.*\)/\1/p")
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
18 # Build the full MinGW-w64 development package.
19 package := mingw-w64-dev
20 subprojects := headers crt
21
22 targets := i686-w64-mingw32 x86_64-w64-mingw32
23
24 CFLAGS = -Wall -g
25 # TODO Handle install with nostrip?
26
27 ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
28     CFLAGS += -O0
29 else
30     CFLAGS += -O2
31 endif
32
33 #number of jobs to run for build
34 ifeq ($(USE_NJOBS),no)
35   NJOBS :=
36   USE_CPUS := 1
37 else
38   MEM_PER_CPU = 128
39   NUM_CPUS := $(shell if echo $(USE_NJOBS) | grep -q -E '^[0-9]+$$'; \
40                         then echo $(USE_NJOBS); \
41                         else getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1; fi)
42   USE_CPUS := $(shell mt=`awk '/^MemTotal/ { print $$2 }' /proc/meminfo`; \
43                         awk -vn=$(NUM_CPUS) -vmt=$$mt -vm=$(MEM_PER_CPU) \
44                                 'END { mt/=1024; n2 = int(mt/m); print n==1 ? 1 : n2<n+1 ? n2 : n+1}' < /dev/null)
45   ifneq (,$(strip $(USE_CPUS)))
46     NJOBS := -j $(USE_CPUS)
47   endif
48 endif
49
50 # Support parallel=<n> in DEB_BUILD_OPTIONS (see #209008)
51 ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
52   NJOBS := -j $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
53 endif
54
55 clean:
56         dh_testdir
57         dh_testroot
58         dh_clean
59         rm -rf $(stampdir) $(build_dir) $(upstream_dir) autotools_files series
60
61 CONFFLAGS = --prefix=/usr
62 CFLAGS += -I$(top_dir)/mingw-w64-headers/include
63
64 configure-stamp: $(patsubst %,configure-stamp-%,$(subprojects))
65         touch $@
66
67 configure-stamp-headers:
68         dh_testdir
69         for target in $(targets); do \
70                 mkdir -p $(build_dir)/$$target/headers && \
71                 cd $(build_dir)/$$target/headers && \
72                 $(top_dir)/mingw-w64-headers/configure $(CONFFLAGS) --host=$$target --with-sdk=all; \
73         done
74         touch $@
75
76 configure-stamp-crt:
77         dh_testdir
78         for target in $(targets); do \
79                 mkdir -p $(build_dir)/$$target/crt && \
80                 cd $(build_dir)/$$target/crt && \
81                 $(top_dir)/mingw-w64-crt/configure $(CONFFLAGS) --host=$$target $$(if [ "$${target/-w64-mingw32/}" == "i686" ]; then echo --enable-lib32 --disable-lib64; else echo --disable-lib32 --enable-lib64; fi); \
82         done
83         touch $@
84
85 build: build-indep
86 build-indep: build-stamp
87 build-stamp: configure-stamp
88         dh_testdir
89         for target in $(targets); do \
90                 for subproject in $(subprojects); do \
91                         cd $(build_dir)/$$target/$$subproject && \
92                         $(MAKE) $(NJOBS); \
93                 done; \
94         done
95         touch $@
96
97 install: install-stamp
98 install-stamp: build-stamp
99         dh_testdir
100         dh_testroot
101         dh_prep
102         for target in $(targets); do \
103                 for subproject in $(subprojects); do \
104                         mkdir -p $(build_dir)/$$target/$$subproject && \
105                         cd $(build_dir)/$$target/$$subproject && \
106                         $(MAKE) install DESTDIR=$(top_dir)/debian/$(package); \
107                 done; \
108         done
109         rmdir $(top_dir)/debian/$(package)/usr/include
110         touch $@
111
112 binary-indep: build-indep install
113         dh_testdir
114         dh_testroot
115         dh_installdocs
116         dh_installman
117         dh_installchangelogs
118         dh_lintian
119         dh_strip -Xw64-mingw32/lib
120         dh_compress
121         dh_fixperms
122         dh_installdeb
123         dh_shlibdeps
124         dh_gencontrol
125         dh_md5sums
126         dh_builddeb
127
128 binary-arch:
129
130 binary: binary-indep
131
132 .PHONY: binary-indep binary-arch binary clean build-indep build install