aboutsummaryrefslogtreecommitdiff
path: root/debian/rules
blob: 3ca425f769f7b011d667bbabd07d2f67140acfe8 (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
#!/usr/bin/make -f

NULL =

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

include /usr/share/dpkg/architecture.mk

export LIBDIR = "/usr/lib/$(DEB_HOST_MULTIARCH)"
export LIBEXECDIR = "$(LIBDIR)/nx/bin"
export INCLUDEDIR = "/usr/include/$(DEB_HOST_MULTIARCH)"

VENDOR_DEBIAN := 0
RELEASE_VER := 0

# detect VENDOR_* variables and RELEASE_VER{,_MAJOR,_MINOR}
VENDOR_DEBIAN := $(shell { dpkg-vendor --is 'Debian' && echo 'yes'; } || { dpkg-vendor --is 'Raspbian' && echo 'yes'; })

ifeq ($(VENDOR_DEBIAN),yes)
  RELEASE_VER := $(shell /usr/bin/lsb_release -r |  cut -d ':' -f'2' |  sed -e 's/\s*//g' | cut -d '.' -f'1')
  # Let's fake testing's and unstable's "release version"...
  ifeq ($(RELEASE_VER),testing)
    RELEASE_VER := 999
  endif
  ifeq ($(RELEASE_VER),unstable)
    RELEASE_VER := 9999
  endif
else
  VENDOR_UBUNTU := $(shell dpkg-vendor --is 'Ubuntu' && echo 'yes')

  ifeq ($(VENDOR_UBUNTU),yes)
    RELEASE_VER_MAJOR := $(shell lsb_release -r | cut -d ':' -f '2' | sed -e 's/\s*//g' | cut -d '.' -f '1')
    RELEASE_VER_MINOR := $(shell lsb_release -r | cut -d ':' -f '2' | sed -e 's/\s*//g' | cut -d '.' -f '2')
  endif
endif

# detect when to use libtirpc and when glibc still provides rpc/rpc.h
IMAKE_EXTRA_DEFINES := ""
ifeq ($(VENDOR_DEBIAN),yes)
  ifeq ($(shell /bin/bash -c '(( $(RELEASE_VER) >= 10 )) && echo '"'"'yes'"'"),yes)
    IMAKE_EXTRA_DEFINES+="-DUseTIRPC=1"
  endif
else
  ifeq ($(VENDOR_UBUNTU),yes)
    ifeq ($(shell /bin/bash -c '(( $(RELEASE_VER_MAJOR) >= 18 )) && echo '"'"'yes'"'"),yes)
      IMAKE_EXTRA_DEFINES+="-DUseTIRPC=1"
    endif
  endif
endif

%:
	CONFIGURE="./configure --disable-silent-rules \
	                       --prefix=/usr \
	                       --libdir=$(LIBDIR) \
	                       --includedir=$(INCLUDEDIR) \
	                       --libexecdir=$(LIBEXECDIR) \
	                       --build=$(DEB_BUILD_GNU_TYPE) \
	                       --host=$(DEB_HOST_GNU_TYPE)"  dh $@ --no-parallel --with quilt

override_dh_auto_clean:
	rm -Rf nx-X11/.build-exports
	dh_auto_clean --no-parallel || dh_auto_clean

override_dh_clean:
	dh_clean
	rm -f nx-X11/config/cf/date.def

override_dh_install:

	# strip static libs and remove .la files
	rm debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libXcomp.la
	strip --strip-debug --remove-section=.comment --remove-section=.note debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libXcomp.a
	rm debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libXcompshad.la
	strip --strip-debug --remove-section=.comment --remove-section=.note debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libXcompshad.a
	rm debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libNX_X11.la
	strip --strip-debug --remove-section=.comment --remove-section=.note debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libNX_X11.a

	# remove extras, GL, and other unneeded headers
	rm -R debian/tmp/usr/include/$(DEB_HOST_MULTIARCH)/GL/
	rm -R debian/tmp/usr/include/$(DEB_HOST_MULTIARCH)/nx-X11/extensions/XK*.h
	rm -R debian/tmp/usr/include/$(DEB_HOST_MULTIARCH)/nx-X11/extensions/*Xv*.h
	rm -R debian/tmp/usr/include/$(DEB_HOST_MULTIARCH)/nx-X11/extensions/XRes*.h
	rm -R debian/tmp/usr/include/$(DEB_HOST_MULTIARCH)/nx-X11/extensions/XIproto.h
	rm -R debian/tmp/usr/include/$(DEB_HOST_MULTIARCH)/nx-X11/extensions/XI.h
	rm -R debian/tmp/usr/include/$(DEB_HOST_MULTIARCH)/nx-X11/Xtrans/

	dh_install

override_dh_missing:
	dh_missing --fail-missing

override_dh_auto_install:
	PREFIX='/usr' dh_auto_install --no-parallel -Smakefile || \
	PREFIX='/usr' dh_auto_install -Smakefile

override_dh_auto_build:
	debian/compat.sh
	PREFIX='/usr' dh_auto_build --no-parallel -- CDEBUGFLAGS="$(CPPFLAGS) $(CFLAGS)" LOCAL_LDFLAGS="$(LDFLAGS)" SHLIBGLOBALSFLAGS='$(filter-out -pie,$(LDFLAGS))' IMAKE_DEFINES="$(IMAKE_EXTRA_DEFINES)" || \
	PREFIX='/usr' dh_auto_build -- CDEBUGFLAGS="$(CPPFLAGS) $(CFLAGS)" LOCAL_LDFLAGS="$(LDFLAGS)" SHLIBGLOBALSFLAGS='$(filter-out -pie,$(LDFLAGS))' IMAKE_DEFINES="$(IMAKE_EXTRA_DEFINES)"

override_dh_strip:
	dh_strip -plibnx-x11-6 --dbg-package=libnx-x11-6-dbg
	dh_strip -plibxcomp3 --dbg-package=libxcomp3-dbg
	dh_strip -plibxcompshad3 --dbg-package=libxcompshad3-dbg
	dh_strip -pnxagent --dbg-package=nxagent-dbg
	dh_strip -pnxproxy --dbg-package=nxproxy-dbg

override_dh_makeshlibs:
	dh_makeshlibs -n

# Needed for the libX11 RUNPATH/RPATH link-time hack.
# dh_shlibdeps will follow dependencies within binaries and choke
# on the libX11 dependency, since the SONAME (libX11.*) used while linking
# does not match the later detected SONAME (libNX_X11.*) obtained through
# the libX11 -> libNX_X11 compat symlink.
override_dh_shlibdeps:
	dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info

get-orig-source:
	uscan --noconf --force-download --rename --download-current-version --destdir=..