Devuan fork of gpsd
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

242 lines
6.9 KiB

  1. #!/usr/bin/make -f
  2. include /usr/share/dpkg/pkg-info.mk
  3. #uncomment if debhelper should be verbose
  4. #export DH_VERBOSE=1
  5. LIBGPS_SONAME := $(strip $(shell grep -E '^libgps_version_current' SConstruct | sed 's,.*=[^0-9]*\([0-9]*\).*,\1,'))
  6. export QT_SELECT=qt5
  7. export DEB_BUILD_MAINT_OPTIONS+=hardening=+bindnow
  8. LIBGPS_DEBIAN_FILE_SOURCES := $(strip $(shell ls -1 debian/*LIBGPSSONAME* ))
  9. LIBGPS_DEBIAN_FILE_TARGETS := $(strip $(shell echo $(LIBGPS_DEBIAN_FILE_SOURCES) | sed 's,LIBGPSSONAME,$(LIBGPS_SONAME),g'))
  10. #python versions
  11. PYTHONS := $(shell py3versions -r)
  12. PYTHON3 := $(shell py3versions -d)
  13. #debhelper version and settings needed for udev
  14. DH_VERSION := $(shell dpkg -s debhelper | grep '^Version' | awk '{print $$2}')
  15. LSB_RELEASE := $(shell lsb_release -si)
  16. UDEV_BREAKS =
  17. ifeq (Debian,$(strip $(LSB_RELEASE))) ## debian ##
  18. ifeq (0, $(strip $(shell dpkg --compare-versions $(DH_VERSION) ge 7.3.15; echo $$?)))
  19. UDEV_BREAKS = 125
  20. endif
  21. endif
  22. ifeq (Devuan,$(strip $(LSB_RELEASE))) ## devuan ##
  23. ifeq (0, $(strip $(shell dpkg --compare-versions $(DH_VERSION) ge 7.3.15; echo $$?)))
  24. UDEV_BREAKS = 125
  25. endif
  26. endif
  27. ifeq (Ubuntu,$(strip $(LSB_RELEASE))) ## ubuntu ##
  28. ifeq (0, $(strip $(shell dpkg --compare-versions $(DH_VERSION) ge 7.0.17ubuntu2; echo $$?)))
  29. UDEV_BREAKS = 136-1
  30. endif
  31. endif
  32. DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
  33. SCONSOPTS = \
  34. prefix=/usr \
  35. systemd=no \
  36. nostrip=yes \
  37. dbus_export=yes \
  38. docdir=/usr/share/doc/gpsd \
  39. libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
  40. gpsd_user=gpsd \
  41. gpsd_group=dialout \
  42. qt_versioned=5 \
  43. python_libdir=/usr/lib/python3/dist-packages
  44. ifneq (,$(findstring nodoc,$(DEB_BUILD_OPTIONS)))
  45. SCONSOPTS += manbuild=no
  46. endif
  47. ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
  48. SCONSOPTS += debug=yes
  49. else
  50. SCONSOPTS += debug=no
  51. endif
  52. #package names
  53. PACKAGE_GPSD := gpsd
  54. PACKAGE_CLIENTS := gpsd-clients
  55. PACKAGE_TOOLS := gpsd-tools
  56. PACKAGE_LIB := libgps$(LIB_soname)
  57. PACKAGE_QTLIB := libqgpsmm$(LIB_soname)
  58. PACKAGE_LIB_DEV := libgps-dev
  59. PACKAGE_QTLIB_DEV := libqgpsmm-dev
  60. PACKAGE_PY := python-gps
  61. PACKAGE_PY3 := python3-gps
  62. PACKAGE_GPSDDBG := gpsd-dbg
  63. cflags := $(shell DEB_BUILD_MAINT_OPTIONS=$(DEB_BUILD_MAINT_OPTIONS) dpkg-buildflags --get CFLAGS)
  64. cppflags := $(shell DEB_BUILD_MAINT_OPTIONS=$(DEB_BUILD_MAINT_OPTIONS) dpkg-buildflags --get CPPFLAGS)
  65. cxxflags := $(shell DEB_BUILD_MAINT_OPTIONS=$(DEB_BUILD_MAINT_OPTIONS) dpkg-buildflags --get CXXFLAGS)
  66. ldflags := $(shell DEB_BUILD_MAINT_OPTIONS=$(DEB_BUILD_MAINT_OPTIONS) dpkg-buildflags --get LDFLAGS)
  67. SCONS_ENV := set -e ;\
  68. export LDFLAGS="$(ldflags)" ;\
  69. export CFLAGS="$(cflags)" ;\
  70. export CXXFLAGS="$(cxxflags)" ;\
  71. export CPPFLAGS="$(cppflags)";
  72. $(LIBGPS_DEBIAN_FILE_TARGETS): $(LIBGPS_DEBIAN_FILE_SOURCES)
  73. for source in $(LIBGPS_DEBIAN_FILE_SOURCES); do \
  74. target=$$(echo "$$source" | sed 's,LIBGPSSONAME,$(LIBGPS_SONAME),g') ;\
  75. sed 's,LIBGPSSONAME,$(LIBGPS_SONAME),g' "$$source" > "$$target" ;\
  76. done
  77. debian/control: debian/control.in
  78. rm -f $@
  79. sed 's,LIBGPSSONAME,$(LIBGPS_SONAME),g' $< > $@
  80. if which git 1>/dev/null && [ -d .git ]; then \
  81. git add debian/control ;\
  82. git commit -m 'Updating debian/control from debian/control.in' debian/control ;\
  83. true ;\
  84. fi ;
  85. SConstruct.deb_revision: SConstruct
  86. if [ ! -f $@ ]; then \
  87. cp $< $@ ;\
  88. sed -i '/^revision=/s/%(.*)/%("$(DEB_VERSION)",)/' $< ;\
  89. fi
  90. touch $@
  91. build-indep: build
  92. build-arch: build
  93. build: build-stamp build-static-stamp
  94. build-stamp: SConstruct.deb_revision
  95. set -e; \
  96. for py in $(PYTHONS); do \
  97. $(SCONS_ENV) $${py} /usr/bin/scons $(SCONSOPTS) target_python=$${py} ; \
  98. done
  99. ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
  100. # disable tests on hurd due to weird ipv6 errors
  101. # http://deb.li/4C46AEAC.7040906@bzed.de
  102. ifeq (,$(findstring hurd,$(DEB_HOST_ARCH_OS)))
  103. -$(SCONS_ENV) $(PYTHON3) /usr/bin/scons check
  104. endif
  105. endif
  106. # ensure the test tools are built
  107. $(SCONS_ENV) $(PYTHON3) /usr/bin/scons $(SCONSOPTS) $(shell grep test_ debian/gpsd-dbg.install | grep -v '\.py' | awk '{print $$1}')
  108. touch $@
  109. build-static-stamp: SConstruct.deb_revision
  110. cp libgps_static.a libgps.a
  111. touch $@
  112. clean: debian/control
  113. dh_testdir
  114. dh_testroot
  115. set -e; \
  116. for py in $(PYTHONS); do \
  117. $(SCONS_ENV) $${py} /usr/bin/scons $(SCONSOPTS) target_python=$${py} --clean ; \
  118. done
  119. $(SCONS_ENV) $(PYTHON3) /usr/bin/scons $(SCONSOPTS) sconsclean --clean || true
  120. # revert revision changes in SConstruct
  121. if [ -f SConstruct.deb_revision ]; then \
  122. mv SConstruct.deb_revision SConstruct; \
  123. fi
  124. rm -rf \
  125. .sconf_temp \
  126. .scons-option-cache \
  127. .sconsign.dblite \
  128. .sconsign.*.dblite \
  129. gps/*.pyc \
  130. TROUBLESHOOTING \
  131. TROUBLESHOOTING.adoc \
  132. debian/buildinfo.gz \
  133. config.log \
  134. debian/shlibs.local \
  135. leapsecond.pyc \
  136. libgps.a \
  137. $(LIBGPS_DEBIAN_FILE_TARGETS) \
  138. __pycache__
  139. dh_clean
  140. install: install-stamp
  141. install-stamp: build-stamp build-static-stamp $(LIBGPS_DEBIAN_FILE_TARGETS)
  142. chmod -x contrib/skyview.php
  143. dh_testdir
  144. dh_testroot
  145. dh_prep
  146. set -e ;\
  147. for py in $(PYTHONS); do \
  148. $(SCONS_ENV) DESTDIR=`pwd`/debian/tmp $${py} /usr/bin/scons install $(SCONSOPTS) target_python=$${py} ;\
  149. done
  150. # install static lib
  151. cp libgps.a debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)
  152. cp INSTALL.adoc TROUBLESHOOTING.adoc
  153. # install everything
  154. dh_install
  155. # quirk to avoid issues by broken fakeroot misdetecting links as files and
  156. # then breaking dh_install -> cp -a fatally
  157. ln -s libgps.so.$(LIBGPS_SONAME).0.0 debian/libgps$(LIBGPS_SONAME)/usr/lib/$(DEB_HOST_MULTIARCH)/libgps.so.$(LIBGPS_SONAME)
  158. rm debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libgps.so.$(LIBGPS_SONAME)
  159. dh_missing --fail-missing
  160. # use python3
  161. sed -i 's,/usr/bin/env python,/usr/bin/env python3,' debian/gpsd-clients/usr/bin/*
  162. sed -i 's,/usr/bin/env python,/usr/bin/env python3,' debian/gpsd/usr/bin/*
  163. sed -i 's,^#!/usr/bin/env python,#!/usr/bin/env python3,' debian/*/usr/libexec/gpsd/debug/*.py
  164. touch $@
  165. install-indep: install
  166. install-arch: install
  167. binary: install-stamp
  168. dh_testdir
  169. dh_testroot
  170. dh_installchangelogs NEWS
  171. dh_installdocs
  172. dh_installman
  173. dh_installmenu
  174. dh_installdebconf
  175. dh_apparmor --profile-name=usr.sbin.gpsd -pgpsd
  176. dh_installinit -- start 26 2 3 4 5 . stop 73 0 1 6 .
  177. dh_installexamples
  178. chmod 644 debian/$(PACKAGE_PY3)/usr/lib/python3*/*-packages/gps/gps.py
  179. dh_python3 -Ngpsd-clients -Ngpsd-dbg
  180. dh_python3 -pgpsd-dbg usr/libexec/gpsd/debug
  181. dh_python3 -pgpsd-clients usr/bin
  182. dh_python3 -pgpsd lib/udev/
  183. cp $(CURDIR)/gpsd.rules $(CURDIR)/debian/gpsd.udev
  184. dh_installudev
  185. dh_link
  186. dh_strip
  187. dh_buildinfo -p$(PACKAGE_GPSDDBG)
  188. dh_compress
  189. dh_fixperms -Xgpsd.hotplug
  190. dh_lintian
  191. ifeq (,$(DEB_BUILD_OPTIONS))
  192. dh_makeshlibs -Nlibqgpsmm$(LIBGPS_SONAME) -- -c4
  193. dh_makeshlibs -plibqgpsmm$(LIBGPS_SONAME) -- -c1
  194. else
  195. dh_makeshlibs
  196. endif
  197. dh_shlibdeps
  198. ifneq (,$(UDEV_BREAKS))
  199. echo "gpsd:Breaks=udev (<< $(UDEV_BREAKS))" >> $(CURDIR)/debian/gpsd.substvars
  200. endif
  201. dh_gencontrol
  202. dh_installdeb
  203. dh_md5sums
  204. dh_builddeb
  205. binary-indep: binary
  206. binary-arch: binary
  207. .PHONY: binary binary-indep binary-arch \
  208. install install-arch install-indep \
  209. clean \
  210. build debian/control