62a6be332fcde9d868f7da665ceaf54545e6832c
[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
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
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-athlon) $(pixmap-dir)
100         dh_install -p $(pkg-p4) debian/ctsim.xpm $(pixmap-dir)
101         dh_install -p $(pkg-athlon) debian/ctsim.xpm $(pixmap-dir)
102 endif
103         # Add here commands to install the package into debian/ctsim.
104         dh_installdirs -p $(pkg) $(pixmap-dir)
105         dh_install -p $(pkg) debian/ctsim.xpm $(pixmap-dir)
106         dh_install -p $(pkg-help) docs/ctsim.htb $(ctsim-shared)
107         dh_install -p $(pkg-doc) docs/html $(doc-dir)
108         dh_link -p $(pkg-doc) $(doc-dir)/html/$(pkg)_contents.html $(doc-dir)/html/index.html
109         gzip -9 docs/ctsim.pdf
110         dh_install -p $(pkg-doc) docs/ctsim.pdf.gz $(doc-dir)
111         gunzip docs/ctsim.pdf.gz
112         chmod +x helical/*.sh tools/*.sh
113
114 # Build architecture-independent files here.
115 # Pass -i to all debhelper commands in this target to reduce clutter.
116 binary-indep: build install
117         dh_testdir -i
118         dh_testroot -i
119 #       dh_installdebconf -i
120         dh_installdocs -i
121         dh_installexamples -i
122         dh_installmenu -i
123 #       dh_installlogrotate -i
124 #       dh_installemacsen -i
125 #       dh_installpam -i
126 #       dh_installmime -i
127 #       dh_installinit -i
128         dh_installcron -i
129 #       dh_installman -i
130         dh_installinfo -i
131 #       dh_undocumented -i
132         dh_installchangelogs ChangeLog -i
133         dh_link -i
134         dh_compress -i
135         dh_fixperms -i
136         dh_installdeb -i
137 #       dh_perl -i
138         dh_gencontrol -i
139         dh_md5sums -i
140         dh_builddeb -i
141
142 # Build architecture-dependent files here.
143 binary-arch: build install
144         dh_testdir -a
145         dh_testroot -a
146 #       dh_installdebconf -a
147         dh_installdocs -a
148         dh_installexamples -p $(pkg) tools/sample-ctsim.sh helical/sample-helical.sh
149 ifneq (,$(findstring i386,$(host_arch)))
150         dh_installexamples -p $(pkg-p4) tools/sample-ctsim.sh helical/sample-helical.sh
151         dh_installexamples -p $(pkg-athlon) tools/sample-ctsim.sh helical/sample-helical.sh
152 endif
153 #       dh_installlogrotate -a
154 #       dh_installemacsen -a
155 #       dh_installpam -a
156 #       dh_installmime -a
157 #       dh_installinit -a
158 #       dh_installcron -a
159 #       dh_installman -a
160 #       dh_installinfo -a
161 #       dh_undocumented -a
162 #       dh_makeshlibs -a
163 #       dh_perl -a
164 ifeq (,$(findstring i386,$(host_arch)))
165         dh_installchangelogs -p $(pkg)ChangeLog 
166         dh_strip -p $(pkg)
167         dh_link -p $(pkg)
168         dh_compress -p $(pkg)
169         dh_fixperms -p $(pkg)
170         dh_installmenu -p $(pkg)
171         dh_installdeb -p $(pkg)
172         dh_gencontrol -p $(pkg)
173         dh_shlibdeps -p $(pkg)
174         dh_md5sums -p $(pkg)
175         dh_builddeb -p $(pkg)
176 else
177         dh_installchangelogs ChangeLog -a
178         dh_strip -a
179         dh_link -a
180         dh_compress -a
181         dh_fixperms -a
182         dh_installmenu -a
183         dh_installdeb -a
184         dh_gencontrol -a
185         dh_shlibdeps -a
186         dh_md5sums -a
187         dh_builddeb -a
188 endif
189
190 binary: binary-indep binary-arch
191
192 .PHONY: build clean binary-indep binary-arch binary install configure
193