Add debianisation code and automatic build script
[wmaker-crm.git] / debian / rules
blobdd09c2cf3fb23e5b850c3c7ba61b5a71c30d9773
1 #!/usr/bin/make -f
2 # GNU Copyright 1997-2005 Marcelo Magallon <mmagallo@debian.org>
4 package := wmaker
5 version := $(shell dpkg-parsechangelog | grep-dctrl -ne -sVersion -FVersion .)
7 # use '(>= some_version)' whenever version dependencies are needed
8 # libwraster_deps := (>= 0.90.0-1)
10 SHELL=/bin/sh
12 CFLAGS = -g -Wall -DGLOBAL_DEFAULTS_SUBDIR="\\\"GNUstep/Defaults\\\""
14 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
15 CFLAGS += -O0
16 else
17 CFLAGS += -O2
18 endif
20 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
21 CFLAGS += -DDEBUG
22 endif
24 LINGUAS := $(patsubst po/%.po, %, $(wildcard po/*.po))
25 #LINGUAS := $(filter-out zh_TW.Big5, $(LINGUAS))
27 # Options, options and more options!!!
29 XLOCALE := --disable-locale
30 MODELOCK := --enable-modelock
32 VDESKTOP := --enable-vdesktop
33 XINERAMA := --enable-xinerama
35 # USERMENU := --enable-usermenu
37 # SHAPE_EXT := --disable-shape
38 # USE_SHM := --disable-shm
40 # USE_XPM := --disable-xpm
41 # USE_PNG := --disable-png
42 # USE_JPEG := --disable-jpeg
43 # USE_GIF := --disable-gif
44 # USE_TIFF := --disable-tiff
46 WMAKER_OPTIONS := $(XLOCALE) $(MODELOCK) $(VDESKTOP) $(XINERAMA) \
47 $(USERMENU) $(SHAPE_EXT) $(USE_SHM) \
48 $(USE_XPM) $(USE_PNG) $(USE_JPEG) $(USE_GIF) $(USE_TIFF)
50 TOPSRCDIR := $(shell pwd)
51 DEBTMPDIR := $(TOPSRCDIR)/debian/wmaker
53 WMAKER := wmaker
54 WMAKER_BD := $(TOPSRCDIR)/$(WMAKER)
55 WMAKER_TMP := $(DEBTMPDIR)
57 # Be careful with the leading / because some of these values are going
58 # to be hardcoded into the executables
60 BASEDIR := /usr
61 CONFDIR := /etc
62 BINDIR := $(BASEDIR)/bin
63 INCLUDEDIR := $(BASEDIR)/include
64 SHAREDIR := $(BASEDIR)/share
65 DOCDIR := $(SHAREDIR)/doc
66 MANDIR := $(SHAREDIR)/man
67 MAN1DIR := $(MANDIR)/man1
68 MAN8DIR := $(MANDIR)/man8
69 LIBDIR := $(BASEDIR)/lib
70 PKGLIBDIR := $(BASEDIR)/lib/WindowMaker
71 NLSDIR := $(SHAREDIR)/locale
72 WMCONFDIR := $(CONFDIR)/X11/WindowMaker
73 WMSHAREDIR := $(SHAREDIR)/WindowMaker
74 WMDOCDIR := $(DOCDIR)/wmaker
75 GNUSTEPDIR := $(LIBDIR)/GNUstep/System
76 GNUSTEPCONFDIR := $(CONFDIR)/GNUstep
77 DEFAULTSDIR := $(GNUSTEPCONFDIR)/Defaults
78 PIXMAPDIR := $(INCLUDEDIR)/X11/pixmaps
79 GNUSTEPAPPS := $(GNUSTEPDIR)/Applications
80 WPREFSAPPDIR := $(GNUSTEPAPPS)/WPrefs.app
82 WPREFSSRCDIR := $(TOPSRCDIR)/WPrefs.app
83 WRASTERSRCDIR := $(TOPSRCDIR)/wrlib
84 WINGSSRCDIR := $(TOPSRCDIR)/WINGs
86 LIBWRASTER := libwraster3
87 LIBWRASTER_TMP := $(DEBTMPDIR)/../$(LIBWRASTER)
88 LIBWMAKER := libwmaker0
89 LIBWINGS := libwings-dev
90 LIBWINGS_TMP := $(DEBTMPDIR)/../$(LIBWINGS)
92 LTMAIN := $(shell: find /usr/share/libtool/ -name ltmain.sh | head -1)
94 RM := rm -f
95 RMDIR := rmdir --ignore-fail-on-non-empty
97 COMMON_OPTIONS := --prefix=$(BASEDIR) \
98 --mandir=$(MANDIR) \
99 --includedir=$(INCLUDEDIR) \
100 --sysconfdir=$(CONFDIR) \
101 --datadir=$(SHAREDIR) \
102 --with-nlsdir=$(NLSDIR) \
103 --with-pixmapdir=$(PIXMAPDIR) \
104 --with-gnustepdir=$(GNUSTEPDIR) \
105 --with-xft
107 AUTOMAKE_FILES := $(shell find -name Makefile.am)
108 IN_MAKEFILES := $(patsubst %.am,%.in,$(AUTOMAKE_FILES))
109 IN_FILES := $(filter-out $(IN_MAKEFILES),$(shell find -name \*.in))
110 GEN_FILES := $(patsubst %.in,%,$(IN_FILES))
112 LIST_PATCHES := find debian/patches -mindepth 1 -maxdepth 1 -name \*.diff -type f | sort
113 RLIST_PATCHES := find debian/patches -mindepth 1 -maxdepth 1 -name \*.diff -type f | sort -r
115 install_file := install -p -o root -g root -m 0644
116 install_prog := install -p -o root -g root -m 0755
117 install_dir := install -p -d -o root -g root -m 0755
119 build: build-stamp
120 build-stamp: build-wmaker-stamp
121 touch $@
123 build-wmaker-stamp: config-wmaker-stamp
124 $(RM) $(patsubst %.in,%,$(shell find WindowMaker -name \*.in ! -name Makefile.in))
125 test -x libtool || ln -sf $(WMAKER_BD)/libtool .
126 $(MAKE) -C $(WMAKER_BD)
127 touch $@
129 config-wmaker-stamp: patch-wmaker-stamp configure
130 dh_testdir
131 test -x config.guess || chmod +x config.guess
132 test -x config.sub || chmod +x config.sub
133 find -name \*.h.in | sed -e 's/\.in$$//' | xargs -r rm -f
134 mkdir -p $(WMAKER_BD)
135 cd $(WMAKER_BD) && \
136 LINGUAS="$(LINGUAS)" $(TOPSRCDIR)/configure $(COMMON_OPTIONS) \
137 $(WMAKER_OPTIONS) CFLAGS="$(CFLAGS)"
138 touch $@
140 patch-wmaker-stamp:
141 @$(LIST_PATCHES) | \
142 while read patch ; do \
143 echo $$patch ; \
144 if head -1 $$patch | grep -q ^Index: ; then \
145 patch -p0 < $$patch ; \
146 else \
147 patch -p1 < $$patch ; \
148 fi ; \
149 echo ; \
150 done
151 touch $@
153 test-patch-wmaker:
154 @$(LIST_PATCHES) | \
155 while read patch ; do \
156 echo $$patch ; \
157 if head -1 $$patch | grep -q ^Index: ; then \
158 patch --dry-run -p0 < $$patch ; \
159 else \
160 patch --dry-run -p1 < $$patch ; \
161 fi ; \
162 echo ; \
163 done
165 unpatch-wmaker:
166 @if [ -e patch-wmaker-stamp ] ; then \
167 $(RLIST_PATCHES) | \
168 while read patch ; do \
169 echo $$patch ; \
170 if head -1 $$patch | grep -q ^Index: ; then \
171 patch -p0 -R < $$patch ; \
172 else \
173 patch -p1 -R < $$patch ; \
174 fi ; \
175 echo ; \
176 done ; \
177 rm patch-wmaker-stamp ; \
178 fi
180 clean:
181 dh_testdir
182 dh_testroot
183 -$(MAKE) distclean
184 debian/rules unpatch-wmaker
185 $(RM) \
186 config.log
187 $(RM) *-stamp \
188 debian/*.files \
189 libtool \
190 src/config.h.in \
191 debian/shlibs.local
192 # debian/conffiles
193 $(RM) -r $(WMAKER_BD)
194 ifeq (skip,)
195 $(RM) \
196 configure \
197 config.guess \
198 config.sub \
199 aclocal.m4 \
200 ltmain.sh
201 $(RM) $(IN_MAKEFILES) $(GEN_FILES)
202 endif
203 dh_clean
205 binary-indep: build
206 # dh_testdir -i
207 # dh_testroot
208 # dh_clean -i -k
210 binary-arch: build
211 dh_testdir -a
212 dh_testroot
213 dh_clean -a -k
214 dh_installdirs -a
215 debian/rules install-wmaker-stamp
216 debian/rules debian/$(LIBWRASTER)-dev.files
217 debian/rules debian/$(LIBWRASTER).files
218 debian/rules debian/$(LIBWMAKER)-dev.files
219 debian/rules debian/$(LIBWINGS).files
220 dh_movefiles -a --sourcedir=debian/wmaker
221 # Remove cruft
222 $(RM) $(DEBTMPDIR)/usr/bin/wkdemenu.pl
223 # deal with menus
224 dh_installmenu -a --noscripts
225 $(install_prog) debian/appearance.menu-method \
226 $(DEBTMPDIR)/etc/menu-methods/wmappearance
227 $(install_file) WindowMaker/appearance.menu \
228 $(DEBTMPDIR)/$(WMCONFDIR)/
229 $(install_file) WindowMaker/background.menu \
230 $(DEBTMPDIR)/$(WMCONFDIR)/
231 $(install_file) WindowMaker/wmmacros \
232 $(DEBTMPDIR)/$(WMCONFDIR)/
233 touch $(DEBTMPDIR)/$(WMCONFDIR)/menu.prehook
234 touch $(DEBTMPDIR)/$(WMCONFDIR)/menu.posthook
235 $(install_file) debian/wmaker.desktop $(DEBTMPDIR)/usr/share/xsessions
236 # build a conffiles list AFTER installing the menus
237 # the sed part is there because of policy
238 # -cd $(DEBTMPDIR) && \
239 # find etc ! -type d \
240 # | sed -e "s:^etc/:/etc/:" > ../conffiles
241 dh_installdocs -a
242 $(install_file) $(WINGSSRCDIR)/README \
243 $(LIBWINGS_TMP)/$(DOCDIR)/$(LIBWINGS)/README.WINGs
244 $(install_file) $(WRASTERSRCDIR)/README \
245 $(LIBWRASTER_TMP)/$(DOCDIR)/$(LIBWRASTER)/README.wrlib
246 $(install_dir) $(DEBTMPDIR)/$(MAN1DIR)
247 $(RM) $(DEBTMPDIR)/$(MAN1DIR)/convertstyle*
248 dh_installman -pwmaker debian/manpages/*.1x
249 dh_installman -pwmaker debian/manpages/*.8
250 dh_installman -plibwraster3-dev debian/manpages/get-wraster-flags.1
251 dh_installman -plibwings-dev debian/manpages/get-wings-flags.1
252 dh_installman -plibwings-dev debian/manpages/get-wutil-flags.1
253 dh_installchangelogs -a ChangeLog
254 # dh_strip -a
255 dh_compress -a
256 dh_fixperms -a
257 cd debian && find -name \*.la -exec chmod a-X {} \;
258 dh_installdeb -a
259 dh_makeshlibs -p$(LIBWRASTER) -V '$(LIBWRASTER) $(libwraster_deps)'
260 dh_shlibdeps -u-L$(LIBWRASTER_TMP)/DEBIAN/shlibs
261 dh_gencontrol -a -u-isp
262 dh_md5sums -a
263 find debian -type d -empty -print0 | xargs -0r rm -rf
264 $(RMDIR) $(DEBTMPDIR)/$(INCLUDEDIR)
265 dh_builddeb -a
267 binary: binary-indep binary-arch
269 install-wmaker-stamp: DH_OPTIONS=-pwmaker
270 install-wmaker-stamp: build-wmaker-stamp
271 dh_testdir
272 dh_installdirs
273 $(MAKE) -C $(WMAKER_BD) install DESTDIR=$(DEBTMPDIR)/
274 # Ugly hack, FIXME
275 mv $(DEBTMPDIR)/etc/WindowMaker/* $(DEBTMPDIR)/$(DEFAULTSDIR)/
277 # Now begin fixing stuff
279 # First, provide a wrapper to compensate for Window Maker's funny first
280 # start up requierements
281 mv $(DEBTMPDIR)/$(BINDIR)/wmaker $(DEBTMPDIR)/$(PKGLIBDIR)/WindowMaker
282 dh_link $(PKGLIBDIR)/WindowMaker $(BINDIR)/WindowMaker
283 $(install_prog) debian/wmaker.sh $(DEBTMPDIR)/$(BINDIR)/wmaker
285 -mv $(DEBTMPDIR)/$(BINDIR)/convertfonts $(DEBTMPDIR)/$(PKGLIBDIR)/
287 # place wm-oldmenu2new under a more appropiate directory
288 -mv $(DEBTMPDIR)/$(BINDIR)/wm-oldmenu2new $(DEBTMPDIR)/$(WMDOCDIR)
290 # put a symlink in place because there's some hardcoded value that says
291 # Defaults is under /usr/share/WindowMaker.
292 ln -s $(DEFAULTSDIR) $(DEBTMPDIR)/$(WMSHAREDIR)/Defaults
293 # the next is stricly not necessary, because there's a symlink in place,
294 # but I don't want to abuse it. Some dumb program uses that path and is a
295 # PITA to modify it)
296 perl -pi -e 's:/$(WPREFSAPPDIR)/WPrefs:/$(BINDIR)/WPrefs:' \
297 $(DEBTMPDIR)/$(DEFAULTSDIR)/WMState
299 # Ditch this!
300 $(RM) $(DEBTMPDIR)/$(BINDIR)/wmaker.inst
301 $(RM) $(DEBTMPDIR)/$(BINDIR)/wmsetup
302 # this copyright is located in /$(DOCDIR)/wmaker
303 $(RM) $(DEBTMPDIR)/$(WMCONFDIR)/Copyright
305 # Fix permissions
306 chmod +x $(DEBTMPDIR)/usr/share/WindowMaker/autostart.sh
307 chmod +x $(DEBTMPDIR)/usr/share/WindowMaker/exitscript.sh
309 # Install our transition script
310 $(install_prog) debian/upgrade-windowmaker-defaults \
311 $(DEBTMPDIR)/usr/sbin/upgrade-windowmaker-defaults
313 # This file qualifies as "unpatchable"
314 cp debian/WMWindowAttributes $(DEBTMPDIR)/$(DEFAULTSDIR)/
315 # Need this file for start up
316 echo '"menu.hook"' > $(DEBTMPDIR)/$(DEFAULTSDIR)/WMRootMenu
318 # the plethora of readmes
319 -cp $(TOPSRCDIR)/po/README \
320 $(DEBTMPDIR)/$(WMDOCDIR)/README.po
321 -cp $(TOPSRCDIR)/README.definable-cursor \
322 $(DEBTMPDIR)/$(WMDOCDIR)/README.definable-cursor
323 -cp $(WPREFSSRCDIR)/README \
324 $(DEBTMPDIR)/$(WMDOCDIR)/README.WPrefs
325 -cp $(WPREFSSRCDIR)/po/README \
326 $(DEBTMPDIR)/$(WMDOCDIR)/README.WPrefs.po
328 # Copy in the Debian theme
329 cp debian/Debian.theme $(DEBTMPDIR)/$(WMSHAREDIR)/Themes/Debian
330 uudecode -o $(DEBTMPDIR)/$(WMSHAREDIR)/Backgrounds/debian.tiff \
331 debian/debian.tiff.uu
332 # This has the new default Debian theme settings.
333 cp debian/WindowMaker.default $(DEBTMPDIR)/$(DEFAULTSDIR)/WindowMaker
335 # Merry Christmas
336 # -mv $(DEBTMPDIR)/$(WMCONFDIR)/xtree.dat $(DEBTMPDIR)/$(WMSHAREDIR)
338 # Overrides lintian warnings
339 dh_installdirs usr/share/lintian/overrides
340 cp debian/wmaker.overrides debian/wmaker/usr/share/lintian/overrides/wmaker
342 # WPrefs
343 # fix the location of WPrefs
344 # mv $(DEBTMPDIR)/$(WPREFSAPPDIR)/WPrefs $(DEBTMPDIR)/$(BINDIR)
345 # dh_link $(BINDIR)/WPrefs $(WPREFSAPPDIR)/WPrefs
346 dh_link $(WPREFSAPPDIR)/WPrefs $(BINDIR)/WPrefs
347 # libwraster is compiled with tiff support, we don't need the xpm version
348 $(RM) -r $(DEBTMPDIR)/$(WPREFSAPPDIR)/xpm
349 $(RM) $(patsubst %.tiff,%.xpm,$(wildcard $(DEBTMPDIR)/$(WMSHAREDIR)/Icons/*.tiff))
351 # Fix the get-*-flags scripts
352 perl -pi -e '/^WCFLAGS/ && s:=.*:="-I/usr/X11R6/include":; /^WLFLAGS/ && s:=.*:="-L/usr/X11R6/lib":;' `find $(DEBTMPDIR) -name get-*-flags`
353 perl -pi -e '/^WLIBS/ && s:=.*:="-lwraster":' `find $(DEBTMPDIR) -name get-wraster-flags`
354 perl -pi -e '/^WLIBS/ && s:=.*:="-lWINGs -lwraster -lXft":' `find $(DEBTMPDIR) -name get-wings-flags`
355 perl -pi -e '/^WLIBS/ && s:=.*:="-lWUtil -lX11":' `find $(DEBTMPDIR) -name get-wutil-flags`
357 ifeq (skip,)
358 if [ -d $(DEBTMPDIR)/usr/include/WINGs ] ; then \
359 mv $(DEBTMPDIR)/usr/include/WINGs/* \
360 $(DEBTMPDIR)/usr/include ; \
361 rmdir $(DEBTMPDIR)/usr/include/WINGs ; \
362 fi
363 endif
365 debian/$(LIBWRASTER)-dev.files: build
366 ( find $(DEBTMPDIR)/$(INCLUDEDIR) $(DEBTMPDIR)/$(LIBDIR) \
367 -name '*wraster*.h' \
368 -o -name '*wraster*.a' \
369 -o -name '*wraster*.la' \
370 -o -name '*wraster*.so' ; \
371 cd $(DEBTMPDIR) && \
372 find usr -name get-wraster-flags \
373 ) | sed -e 's:$(DEBTMPDIR)/*::'> $@
375 debian/$(LIBWRASTER).files: build
376 ( find $(DEBTMPDIR)/$(INCLUDEDIR) $(DEBTMPDIR)/$(LIBDIR) \
377 -name '*wraster*.so.*' \
378 ) | sed -e 's:$(DEBTMPDIR)/*::'> $@
380 debian/$(LIBWMAKER)-dev.files: build
381 ( find $(DEBTMPDIR)/$(INCLUDEDIR) $(DEBTMPDIR)/$(LIBDIR) \
382 -name '*WM*.h' \
383 -o -name '*WM*.a' \
384 -o -name '*WM*.la' \
385 -o -name '*WM*.so' \
386 ) | sed -e 's:$(DEBTMPDIR)/*::'> $@
388 debian/libwings-dev.files: build
389 ( find $(DEBTMPDIR)/$(INCLUDEDIR) $(DEBTMPDIR)/$(LIBDIR) \
390 -name '*WINGs*' \
391 -o -name '*WUtil*' ; \
392 cd $(DEBTMPDIR) && \
393 find usr -name get-wutil-flags -o -name get-wings-flags \
394 ) | sed -e 's:$(DEBTMPDIR)/*::'> $@
396 debian/shlibs.local:
397 echo 'libwraster $(patsubst libwraster%,%, $(LIBWRASTER)) $(LIBWRASTER) $(libwraster_deps)' > $@
399 aclocal.m4: acinclude.m4 configure.ac
400 aclocal
402 src/config.h.in: configure.ac
403 autoheader
405 ltmain.sh: aclocal.m4 $(LTMAIN)
406 libtoolize --force --copy --automake
408 $(IN_MAKEFILES): %.in: ltmain.sh %.am src/config.h.in
409 automake --add-missing --gnu --include-deps
411 configure: $(IN_MAKEFILES) configure.ac
412 autoconf
414 .PHONY: binary binary-arch binary-indep binary-custom clean build unpatch-wmaker