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