summaryrefslogtreecommitdiff
path: root/debian/rules
blob: 88e51ddd8665bf5c6bb0bde4437a5c14039faf4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/make -f
#export DH_VERBOSE=1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_MULTIARCH  ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
DEB_HOST_ARCH       ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_ARCH_OS    ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)

VERSION = $(shell head -n1 debian/changelog | sed -e 's/.*(//;s/-.*).*//;s/\+/\-/')

ifeq ($(DEB_HOST_ARCH_OS),)
  DEB_HOST_ARCH_OS := $(subst -gnu,,$(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM))
  ifeq ($(DEB_HOST_ARCH_OS),gnu)
      DEB_HOST_ARCH_OS := hurd
  endif
endif

ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -g
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
	INSTALL_STRIP_FLAG = ""
	STRIP = ""
endif

%:
	dh $@

override_dh_auto_configure:
	autoconf
	dh_auto_configure -- --host=$(DEB_HOST_GNU_TYPE) \
		--build=$(DEB_BUILD_GNU_TYPE) \
		--prefix=/usr \
		--libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--datadir=\$${prefix}/share \
		--mandir=\$${prefix}/share/man \
		--with-docdir=\$${prefix}/share/doc/libsane \
		--disable-locking \
		--enable-static \
		--enable-pthread \
		--with-gphoto2 \
		--enable-translations \
		--enable-avahi \
		--enable-pnm-backend \
		--with-usb \
		--without-v4l

override_dh_auto_build-indep:
	# generate POT file for translators
	(cd po && make sane-backends.pot)
	$(MAKE)

override_dh_auto_clean:
	# Autoconf-generated files
	$(RM) include/byteorder.h include/_stdint.h
	# Add here commands to clean up after the build process.
	[ ! -f Makefile ] || $(MAKE) distclean
	$(RM) debian/libsane-common.install
	$(RM) debian/libsane.udev
	dh_auto_clean

override_dh_auto_install-arch:
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
	# remove /usr/lib/sane/libsane.so.1 (libtool side-effect ?)
	$(RM) debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/sane/libsane.so.1
	# remove libsane-dll, same as regular libsane
	$(RM) debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/sane/libsane-dll.*
	# install only the manpages for the backends which have been built
#	cp debian/libsane-common.install.in debian/libsane-common.install
#	ls debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/sane/*.so | sed -e \
#		"s#.*/lib\([^.]\+\)[.]so#usr/share/man/man5/\1.5#" | { while read mp; do \
#		test -e debian/tmp/$$mp && echo $$mp >> debian/libsane-common.install; done }

override_dh_auto_install-indep:
	cp debian/libsane-common.install.in debian/libsane-common.install
	dh_auto_install
#	ls debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/sane/*.so | sed -e \
#		"s#.*/lib\([^.]\+\)[.]so#usr/share/man/man5/\1.5#" | { while read mp; do \
#		test -e debian/tmp/$$mp && echo $$mp >> debian/libsane-common.install; done }

override_dh_install-arch:
	dh_install
#	# Install HAL fdi file
#	mkdir -p $(CURDIR)/debian/libsane-common/usr/share/hal/fdi/preprobe/10osvendor
#	$(CURDIR)/tools/sane-desc -s $(CURDIR)/doc/descriptions -m hal-new > \
#	$(CURDIR)/debian/libsane-common/usr/share/hal/fdi/preprobe/10osvendor/20-libsane.fdi
	# Install the pkg-config file
	mkdir -p debian/libsane-dev/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/
	cp tools/sane-backends.pc debian/libsane-dev/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/
	#
	mkdir -p $(CURDIR)/debian/sane-utils/usr/share/man/man5/
	cp $(CURDIR)/doc/sane-umax_pp.man $(CURDIR)/debian/sane-utils/usr/share/man/man5/umax_pp.5

override_dh_install-indep:
	dh_install
	# Install HAL fdi file
	mkdir -p $(CURDIR)/debian/libsane-common/usr/share/hal/fdi/preprobe/10osvendor
	$(CURDIR)/tools/sane-desc -s $(CURDIR)/doc/descriptions -m hal-new > \
	$(CURDIR)/debian/libsane-common/usr/share/hal/fdi/preprobe/10osvendor/20-libsane.fdi

override_dh_installdocs-arch:
	dh_installdocs
	# move files that belong to libsane-dev
	mv debian/tmp/usr/share/doc/sane-backends/backend-writing.txt debian/libsane-dev/usr/share/doc/libsane-dev/

override_dh_installdocs-indep:
	dh_installdocs
	# Platform-specific documentation
	$(RM) debian/libsane-common/etc/sane.d/saned.conf
ifeq (kfreebsd,$(DEB_HOST_ARCH_OS))
	cp README.freebsd debian/libsane-common/usr/share/doc/libsane-common/
endif
ifeq (linux,$(DEB_HOST_ARCH_OS))
	cp README.linux debian/libsane-common/usr/share/doc/libsane-common/
endif

override_dh_installudev-arch:
ifeq (linux,$(DEB_HOST_ARCH_OS))
	# udev support
	# Generate the udev rules file
#	$(CURDIR)/tools/sane-desc -s $(CURDIR)/doc/descriptions -m udev+acl > $(CURDIR)/debian/libsane1.udev
	$(CURDIR)/tools/sane-desc -s $(CURDIR)/doc/descriptions -m udev+hwdb > $(CURDIR)/debian/libsane1.udev
	$(CURDIR)/tools/sane-desc -s $(CURDIR)/doc/descriptions -m hwdb > $(CURDIR)/debian/20-sane.hwdb
	cp $(CURDIR)/debian/20-sane.hwdb $(CURDIR)/debian/libsane1/lib/udev/hwdb.d/
	dh_installudev
endif

	# remove rpath from the binaries (wonderful tool !)
	chrpath -d debian/sane-utils/usr/sbin/saned
	chrpath -d debian/sane-utils/usr/bin/scanimage
	chrpath -d debian/sane-utils/usr/bin/sane-find-scanner

override_dh_installinit-arch:
	dh_installinit -psane-utils --name=saned

override_dh_systemd_enable-arch:
	dh_systemd_enable --no-enable saned.socket

override_dh_makeshlibs-arch:
	dh_makeshlibs -- -v$(VERSION) -Pdebian/libsane1 -plibsane1
	# Empty dependency_libs in all .la files
	#find debian -name "*.la" -type f -exec sed -i "/dependency_libs/ s/'.*'/''/" -i {} \;