File: rules

package info (click to toggle)
makefs 20100306-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,712 kB
  • sloc: ansic: 29,055; makefile: 157
file content (112 lines) | stat: -rwxr-xr-x 3,112 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/make -f
# $MirOS: contrib/hosted/tg/deb/makefs/debian/rules,v 1.14 2012/04/30 16:48:39 tg Exp $

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

DEB_HOST_ARCH_OS?=$(shell dpkg-architecture -qDEB_HOST_ARCH_OS)

CC?=			gcc
EXTRA_CFLAGS+=		-Wall -Wformat
EXTRA_CPPFLAGS+=	-include /usr/include/bsd/bsd.h
EXTRA_CPPFLAGS+=	-idirafter /usr/include/bsd
EXTRA_LDFLAGS=		-Wl,--as-needed

# not yet (needs to be checked upstream)
EXTRA_CFLAGS+=		-Wno-unused-but-set-variable
EXTRA_CFLAGS+=		-Wno-unused-result

ifneq (,$(wildcard /usr/share/dpkg/buildflags.mk))
# dpkg-dev (>= 1.16.1~)
DEB_CFLAGS_MAINT_APPEND=${EXTRA_CFLAGS}
DEB_CPPFLAGS_MAINT_APPEND=${EXTRA_CPPFLAGS}
DEB_LDFLAGS_MAINT_APPEND=${EXTRA_LDFLAGS}
DEB_BUILD_MAINT_OPTIONS=hardening=+all
include /usr/share/dpkg/buildflags.mk
else
# old-fashioned way to determine build flags
CFLAGS=			-O$(if $(findstring noopt,${DEB_BUILD_OPTIONS}),0,2) -g
CFLAGS+=		${EXTRA_CFLAGS}
CPPFLAGS+=		${EXTRA_CPPFLAGS}
LDFLAGS+=		${EXTRA_LDFLAGS}
endif

# should be in libbsd
DEFS+=	-D'__IDSTRING(x,y)=static const char x[] __attribute__((used)) = y'
DEFS+=	-D'__KERNEL_RCSID(x,y)=__IDSTRING(kernelrcsid_ \#\# x,y)'
DEFS+=	-D'__dead=__attribute__((noreturn))'
DEFS+=	-D'_DIAGASSERT(x)='

# is in libbsd, but not all versions: Debian #547399
ifeq ($(shell fgrep -ch __RCSID \
    /usr/include/bsd/cdefs.h /usr/include/bsd/sys/cdefs.h \
    2>/dev/null),0)
DEFS+=	-D'__RCSID(x)=__IDSTRING(rcsid,x)'
endif

DEFS+=	-D'bswap16=__bswap_16'
DEFS+=	-D'bswap32=__bswap_32'
DEFS+=	-D'bswap64=__bswap_64'
DEFS+=	-DHAVE_STRUCT_STATVFS_F_IOSIZE=0
DEFS+=	-DHAVE_STRUCT_STAT_ST_MTIMENSEC=0
DEFS+=	-DHAVE_STRUCT_STAT_ST_FLAGS=0
DEFS+=	-DHAVE_STRUCT_STAT_ST_GEN=0

PMAKE_FLAGS:=	BSDSRCDIR="$$_topdir/builddir"
PMAKE_FLAGS+=	DEBIAN=Yes
# disable -Werror for package build (comment this out if developing)
PMAKE_FLAGS+=	NOGCCERROR=Yes

build build-arch: builddir/.build_stamp
build-indep:

builddir/.build_stamp:
	dh_testdir
	-rm -rf builddir
	mkdir builddir
	cp -r src/* builddir/
ifeq (${DEB_HOST_ARCH_OS},hurd)
	mkdir -p builddir/usr.sbin/makefs/sys
	:>builddir/usr.sbin/makefs/sys/mount.h
endif
	# pmake in Debian is pretty buggy
	+_topdir=$$(pwd); cd builddir/usr.sbin/makefs; \
	 for opts in '-flto=jobserver' ''; do \
		set -x; \
		$(foreach i,CC CFLAGS LDFLAGS,$(call shellexport,$i)); \
		CPPFLAGS=$(call shellescape,${CPPFLAGS} ${DEFS}); \
		CFLAGS="$$CFLAGS $$opts"; \
		LDFLAGS="$$CFLAGS $$LDFLAGS"; \
		export LC_ALL=C CC CFLAGS CPPFLAGS LDFLAGS; \
		pmake ${PMAKE_FLAGS} makefs || continue; \
		test -x makefs && exit 0; \
	done; echo >&2 Compiling failed.; exit 1
	@:>$@

clean:
	dh_testdir
	-rm -rf builddir
	dh_clean

binary-indep:

binary-arch: build-arch
	dh_testdir
	dh_testroot
	if test -x "$$(which dh_prep)"; then dh_prep; else dh_clean -k; fi
	dh_installchangelogs
	dh_installdocs
	dh_install
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: binary binary-arch binary-indep build build-arch build-indep clean