File: rules

package info (click to toggle)
xlax 2.4-3
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 1,204 kB
  • sloc: ansic: 3,787; perl: 127; makefile: 72
file content (92 lines) | stat: -rwxr-xr-x 2,426 bytes parent folder | download
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
#!/usr/bin/make -f

ifeq (,$(filter terse,${DEB_BUILD_OPTIONS}))
export DH_VERBOSE=1
export V=1
export VERBOSE=1
endif

LC_ALL:=C
export LC_ALL
TZ:=UTC
export TZ

shellescape='$(subst ','\'',$(1))'
shellexport=$(1)=$(call shellescape,${$(1)})

ifneq (,$(wildcard /usr/share/dpkg/architecture.mk))
include /usr/share/dpkg/architecture.mk
endif

ifneq (,$(wildcard /usr/share/dpkg/buildtools.mk))
DPKG_EXPORT_BUILDTOOLS:=1
include /usr/share/dpkg/buildtools.mk
else
# is ${CC} defined anywhere (other than implicit rules?)
ifneq (,$(findstring $(origin CC),default undefined))
# no - then default to gcc (or cross-gcc)
DEB_BUILD_ARCH?=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
DEB_HOST_ARCH?=$(shell dpkg-architecture -qDEB_HOST_ARCH)
ifneq (${DEB_BUILD_ARCH},${DEB_HOST_ARCH})
DEB_HOST_GNU_TYPE?=$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
CC=		${DEB_HOST_GNU_TYPE}-gcc
else
CC=		gcc
endif
endif
endif

OUR_CPPFLAGS:=
OUR_CFLAGS:=
OUR_LDFLAGS:=

ifneq (,$(filter debug,${DEB_BUILD_OPTIONS}))
OUR_CFLAGS+=	-Og -g3
endif

OUR_CFLAGS+=	-Wall -Wextra -Wformat
# for now
OUR_CFLAGS+=	-Wno-unused-variable
OUR_CFLAGS+=	-Wno-unused-parameter
OUR_CFLAGS+=	-Wno-unused-but-set-variable
# not fully protoised
OUR_CFLAGS+=	-std=gnu99
# but go towards
OUR_CFLAGS+=	-Wstrict-prototypes

ifneq (,$(wildcard /usr/share/dpkg/buildflags.mk))
# dpkg-dev (>= 1.16.1~)
dpkgbuildflagsmkescape=$(subst \,\\\,$(1))
export DEB_BUILD_MAINT_OPTIONS:=hardening=+all optimize=-lto
export DEB_CPPFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${OUR_CPPFLAGS})
export DEB_CFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${OUR_CFLAGS})
export DEB_LDFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${OUR_LDFLAGS})
ifneq (,$(wildcard /usr/share/dpkg/default.mk))
include /usr/share/dpkg/default.mk
else
include /usr/share/dpkg/buildflags.mk
endif
else
# old-fashioned way to determine build flags
CFLAGS=		-O$(if $(findstring noopt,${DEB_BUILD_OPTIONS}),0,2) -g
CPPFLAGS+=	${OUR_CPPFLAGS}
CFLAGS+=	${OUR_CFLAGS}
LDFLAGS+=	${OUR_LDFLAGS}
endif

%:
	dh $@ -Snone

execute_before_dh_auto_clean:
	dh_testdir
	-rm -rf builddir

override_dh_auto_build:
	dh_testdir
	-rm -rf builddir
	mkdir builddir
	cd builddir && ln -s ../* . && xmkmf && exec make \
	    DEFINES=$(call shellescape,${CPPFLAGS}) \
	    CDEBUGFLAGS=$(call shellescape,${CFLAGS}) \
	    CXXDEBUGFLAGS=$(call shellescape,${CXXFLAGS}) \
	    EXTRA_LDOPTIONS=$(call shellescape,${LDFLAGS})