r11003: ctsim (4.4.5-1) unstable; urgency=low
[ctsim.git] / debian / rules
1 #!/usr/bin/make -f
2
3 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
4         CFLAGS += -g
5 endif
6 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
7         INSTALL_PROGRAM += -s
8 endif
9
10 host_arch       := $(shell dpkg-architecture -qDEB_HOST_ARCH)
11
12 pkg             := ctsim
13 pkg-p4          := ctsim-pentium4
14 pkg-athlon      := ctsim-athlon
15 pkg-help        := ctsim-help
16 pkg-doc         := ctsim-doc
17
18 ctsim-shared    := usr/share/ctsim
19
20 prefix          := debian/$(pkg)
21 prefix-p4       := debian/$(pkg-p4)
22 prefix-athlon   := debian/$(pkg-athlon)
23 prefix-help     := debian/$(pkg-help)
24 prefix-doc      := debian/$(pkg-doc)
25
26 DESTDIR         := `pwd`/$(prefix)
27 DESTDIR-P4      := `pwd`/$(prefix-p4)
28 DESTDIR-ATHLON  := `pwd`/$(prefix-athlon)
29 HELPDIR         := `pwd`/$(prefix-help)/$(ctsim-shared)
30 doc-dir         := usr/share/doc/$(pkg-doc)
31 pixmap-dir      := usr/share/pixmaps
32 desktop-dir     := usr/share/applications
33
34 configure: configure-stamp
35 configure-stamp:
36         dh_testdir
37         touch configure.in && touch aclocal.m4 && touch configure
38
39         ./configure --prefix=$(DESTDIR)/usr --mandir=$(DESTDIR)/usr/share/man --datadir=$(HELPDIR) --with-ctn -with-x
40         touch configure-stamp
41
42
43 build-arch: configure-stamp build-arch-stamp
44 build-arch-stamp:
45         dh_testdir
46         # Add here commands to compile the package.
47         $(MAKE) all
48         touch build-arch-stamp
49
50 build-indep: configure-stamp  build-indep-stamp
51 build-indep-stamp:
52         dh_testdir
53         # Add here command to compile/build the arch indep package.
54         # It's ok not to do anything here, if you don't need to build
55         #  anything for this package.
56         #/usr/bin/docbook-to-man debian/#PACKAGE#.sgml > #PACKAGE#.1
57         (cd docs; tar xzf html.tar.gz)
58         touch build-indep-stamp
59
60 build: build-arch build-indep
61
62 clean:
63         dh_testdir
64         dh_testroot
65         rm -f build-arch-stamp build-indep-stamp configure-stamp
66         # Add here commands to clean up after the build process.
67         -$(MAKE) distclean
68         find . -type f -and -name \*~ -or -name .\*~ -exec rm -f {} \;
69         rm -f debian/ctsim.postinst.* debian/ctsim.prerm.*
70         # Ensure up-to-date versions of config.sub and config.guess
71         -test -r /usr/share/misc/config.sub && cp -f /usr/share/misc/config.sub config.sub
72         -test -r /usr/share/misc/config.guess && cp -f /usr/share/misc/config.guess config.guess
73         dh_clean
74
75 install: DH_OPTIONS=
76 install: build
77         dh_testdir
78         dh_testroot
79         dh_clean -k
80         dh_installdirs
81         #
82         dh_installdirs -p $(pkg-help) $(ctsim-shared)
83         ${MAKE} install
84         # Testing for i386 optimized builds
85         echo Host architecture is $(host_arch)
86 ifneq (,$(findstring i386,$(host_arch)))
87         # Building CPU-specific i386 flavors
88         # Pentium 4
89         ${MAKE} clean
90         ./configure --prefix=$(DESTDIR-P4)/usr --mandir=$(DESTDIR-P4)/usr/share/man --datadir=$(HELPDIR) --with-ctn --with-mcpu=pentium4
91         $(MAKE) all
92         ${MAKE} install
93         # Athlon
94         ${MAKE} clean
95         ./configure --prefix=$(DESTDIR-ATHLON)/usr --mandir=$(DESTDIR-ATHLON)/usr/share/man --datadir=$(HELPDIR) --with-ctn --with-mcpu=athlon
96         $(MAKE) all
97         ${MAKE} install
98         dh_installdirs -p $(pkg-p4) $(pixmap-dir)
99         dh_installdirs -p $(pkg-p4) $(desktop-dir)
100         dh_installdirs -p $(pkg-athlon) $(pixmap-dir)
101         dh_installdirs -p $(pkg-athlon) $(desktop-dir)
102         dh_install -p $(pkg-p4) debian/ctsim.xpm $(pixmap-dir)
103         dh_install -p $(pkg-p4) debian/ctsim.desktop $(desktop-dir)
104         dh_install -p $(pkg-athlon) debian/ctsim.xpm $(pixmap-dir)
105         dh_install -p $(pkg-athlon) debian/ctsim.desktop $(desktop-dir)
106
107 endif
108         # Add here commands to install the package into debian/ctsim.
109         dh_installdirs -p $(pkg) $(pixmap-dir)
110         dh_installdirs -p $(pkg) $(desktop-dir)
111         dh_install -p $(pkg) debian/ctsim.xpm $(pixmap-dir)
112         dh_install -p $(pkg) debian/ctsim.desktop $(desktop-dir)
113         dh_install -p $(pkg-help) docs/ctsim.htb $(ctsim-shared)
114         dh_install -p $(pkg-doc) docs/html $(doc-dir)
115         dh_link -p $(pkg-doc) $(doc-dir)/html/$(pkg)_contents.html $(doc-dir)/html/index.html
116         gzip -9 docs/ctsim.pdf
117         dh_install -p $(pkg-doc) docs/ctsim.pdf.gz $(doc-dir)
118         gunzip docs/ctsim.pdf.gz
119         chmod +x helical/*.sh tools/*.sh
120
121 # Build architecture-independent files here.
122 # Pass -i to all debhelper commands in this target to reduce clutter.
123 binary-indep: build install
124         dh_testdir -i
125         dh_testroot -i
126         dh_installdocs -i
127         dh_installexamples -i
128         dh_installmenu -i
129         dh_installcron -i
130         dh_installinfo -i
131         dh_installchangelogs ChangeLog -i
132         dh_link -i
133         dh_compress -i
134         dh_fixperms -i
135         dh_installdeb -i
136         dh_gencontrol -i
137         dh_md5sums -i
138         dh_builddeb -i
139
140 # Build architecture-dependent files here.
141 binary-arch: build install
142         dh_testdir -a
143         dh_testroot -a
144         dh_installdocs -a
145         dh_installexamples -p $(pkg) tools/sample-ctsim.sh helical/sample-helical.sh
146 ifneq (,$(findstring i386,$(host_arch)))
147         dh_installexamples -p $(pkg-p4) tools/sample-ctsim.sh helical/sample-helical.sh
148         dh_installexamples -p $(pkg-athlon) tools/sample-ctsim.sh helical/sample-helical.sh
149 endif
150
151 ifeq (,$(findstring i386,$(host_arch)))
152         dh_installchangelogs -p $(pkg)ChangeLog 
153         dh_strip -p $(pkg)
154         dh_link -p $(pkg)
155         dh_compress -p $(pkg)
156         dh_fixperms -p $(pkg)
157         dh_installmenu -p $(pkg)
158         dh_installdeb -p $(pkg)
159         dh_gencontrol -p $(pkg)
160         dh_shlibdeps -p $(pkg)
161         dh_md5sums -p $(pkg)
162         dh_builddeb -p $(pkg)
163 else
164         dh_installchangelogs ChangeLog -a
165         dh_strip -a
166         dh_link -a
167         dh_compress -a
168         dh_fixperms -a
169         dh_installmenu -a
170         dh_installdeb -a
171         dh_gencontrol -a
172         dh_shlibdeps -a
173         dh_md5sums -a
174         dh_builddeb -a
175 endif
176
177 binary: binary-indep binary-arch
178
179 .PHONY: build clean binary-indep binary-arch binary install configure
180