debian/rules: add option to build sb1 tarball
[qemu] / debian / rules
1 #!/usr/bin/make -f
2 #
3 # $Id: rules 366 2008-12-23 16:19:26Z aurel32 $
4 #
5
6 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
7         CFLAGS = -O0
8 endif
9
10 # Support multiple makes at once
11 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
12 NJOBS := -j $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
13 endif
14
15 # Architecture/system specific configuration
16 DEB_HOST_ARCH_OS = $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
17 DEB_HOST_ARCH_CPU = $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
18
19
20 TARGET_SYSTEM_TCG    = arm-softmmu i386-softmmu
21 TARGET_LINUX_TCG     = arm-linux-user i386-linux-user
22 package_list         = obj-sb2/config-host.mak obj-system/config-host.mak
23 install_list         = sb2-qemu-install sb-system-qemu-install
24 sb1_prefix           = /scratchbox/devkits/qemu
25
26 target_system_list = $(TARGET_SYSTEM_TCG)
27
28 source_version = $(shell dpkg-parsechangelog | grep ^Version | head -n1 | cut -d ' ' -f 2)
29
30 ifeq ($(DEB_HOST_ARCH_OS),linux)
31        conf_arch += --audio-drv-list=sdl
32        target_linux_list += $(TARGET_LINUX_TCG)
33 endif
34 ifeq ($(DEB_HOST_ARCH_OS),kfreebsd)
35        conf_arch += --audio-drv-list=oss,sdl,esd,pa
36 endif
37
38 BUILD_SB1_QEMU=$(shell test -r /scratchbox/tools/lib/libsb.a && echo YES || echo NO)
39
40 ifeq ($(DEB_HOST_ARCH_CPU),i386)
41        conf_arch += --cpu=i386
42 ifeq ($(BUILD_SB1_QEMU),YES)
43        package_list += obj-sb1/config-host.mak
44        install_list += sb1-qemu-install
45        sb1_target_list += arm-linux-user ppc-linux-user sparc-linux-user i386-linux-user armeb-linux-user mips-linux-user mipsel-linux-user
46 endif
47 endif
48 ifeq ($(DEB_HOST_ARCH_CPU),sparc)
49        conf_arch += --cpu=sparc
50 endif
51
52 qemu_docs = \
53         qemu-doc.html \
54         qemu-tech.html \
55         qemu.1 \
56         qemu-img.1
57
58 obj-sb2/config-host.mak: configure
59         dh_testdir
60         mkdir obj-sb2
61         ( cd obj-sb2; CFLAGS="$(CFLAGS)" ../configure \
62                 --prefix=/usr \
63                 --interp-prefix=/ \
64                 --disable-blobs \
65                 --enable-guest-base \
66                 --target-list="$(target_linux_list)" \
67                 $(conf_arch) )
68         ( cd obj-sb2; $(MAKE) $(NJOBS) )
69
70 obj-sb1/config-host.mak: configure
71         dh_testdir
72         mkdir obj-sb1
73         ( cd obj-sb1; CFLAGS="$(CFLAGS) $(SB1_CFLAGS)"  ../configure \
74                 --prefix=$(sb1_prefix) \
75                 --interp-prefix=/ \
76                 --static \
77                 --enable-guest-base \
78                 --target-list="$(sb1_target_list)"\
79                 --disable-kqemu --disable-sdl )
80         ( cd obj-sb1; $(MAKE) $(NJOBS) )
81
82 obj-system/config-host.mak: configure
83         dh_testdir
84         mkdir obj-system
85         ( cd obj-system; CFLAGS="$(CFLAGS)" ../configure \
86                 --prefix=/usr \
87                 --interp-prefix=/ \
88                 --disable-blobs \
89                 --enable-guest-base \
90                 --target-list="$(target_system_list)" \
91                 $(conf_arch) )
92         ( cd obj-system; $(MAKE) $(NJOBS) )
93
94 build: $(package_list)
95
96 clean:
97         dh_testdir
98         dh_testroot
99         [ ! -f config-host.mak ] || $(MAKE) distclean
100         rm -rf obj-sb1 obj-sb2 obj-system
101         rm -f $(qemu_docs)
102         dh_clean
103
104 # cputransp-methods should be generated at postinst
105 sb1-qemu-install:
106         mkdir -p debian/scratchbox-devkit-qemu/$(sb1_prefix)/{bin,etc}
107         cp debian/cputransp-methods \
108                 debian/scratchbox-devkit-qemu/$(sb1_prefix)/etc
109         for i in obj-sb1/*-linux-user/qemu-* ; do \
110                 install -m 755 $$i debian/scratchbox-devkit-qemu/$(sb1_prefix)/bin/`basename $$i`-sb ; \
111         done
112
113 sb2-qemu-install:
114         mkdir -p debian/sb2-qemu-arm/usr/bin
115         cp obj-sb2/arm-linux-user/qemu-arm debian/sb2-qemu-arm/usr/bin/sb2-qemu-arm
116         cp obj-sb2/i386-linux-user/qemu-i386  debian/sb2-qemu-arm/usr/bin/sb2-qemu-i386
117
118 sb-system-qemu-install:
119         mkdir -p debian/sb-system-qemu/usr/bin
120         cp obj-system/arm-softmmu/qemu-system-arm  debian/sb-system-qemu/usr/bin/sb-qemu-system-arm
121         cp obj-system/i386-softmmu/qemu  debian/sb-system-qemu/usr/bin/sb-qemu-system-i386
122
123 install: build $(install_list)
124         dh_testdir
125         dh_testroot
126 #       dh_clean -k
127         dh_installdirs -a
128
129 binary-indep:
130 # Nothing to do.
131
132 binary-arch: install
133         dh_testdir
134         dh_testroot
135 #       dh_install -a
136 #       dh_installdebconf -a
137         dh_installdocs -s
138         dh_installexamples -s
139 #       dh_installlogrotate -a
140         dh_installman -s
141         dh_installinfo -s
142         dh_installchangelogs -s Changelog
143         dh_link -s
144         dh_strip -s
145         dh_compress -s
146         dh_fixperms -s
147         dh_installdeb -s
148         dh_shlibdeps -s
149         dh_gencontrol -s
150         dh_md5sums -s
151         dh_builddeb -s
152
153 binary: binary-indep binary-arch
154
155 sb1-qemu-tarball: build sb1-qemu-install
156         tar czf ../scratchbox-devkit-qemu-$(source_version).tar.gz \
157                 -C debian/scratchbox-devkit-qemu \
158                 $(shell ls -1 debian/scratchbox-devkit-qemu)
159
160 .PHONY: build clean binary-indep binary-arch binary install
161