File: rules.modules

package info (click to toggle)
eagle-usb 2.1.1-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 5,108 kB
  • ctags: 2,612
  • sloc: ansic: 27,560; sh: 5,440; perl: 3,269; xml: 1,079; tcl: 915; makefile: 878
file content (246 lines) | stat: -rw-r--r-- 7,277 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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
#
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets  by Bill Allombert 2001


# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS


# Names of package
package	= eagle-usb
pmodules= $(package)-modules-$(non_epoch_version)


# FLAGS
CFLAGS = -Wall
ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
        CFLAGS += -g
endif
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif


# FOR AUTOCONF 2.52 AND NEWER ONLY
export DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
  confflags += --build $(DEB_HOST_GNU_TYPE)
else
  confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
endif


### KERNEL SETUP
### Setup the stuff needed for making kernel module packages
### taken from /usr/share/kernel-package/sample.module.rules

# KSRC is the location of the kernel source. This is the default value,
# when make-kpkg is used it will supply to real value
KSRC           ?= /usr/src/linux

## Now to determine the kernel version, normally supplied by make-kpkg
ifeq ($(strip $(KVERS)),)
# Now we need to get the kernel-version somehow (we are not running
# under make-kpkg?)
ifeq ($(strip $(KSRC)),)
$(error Error. I do not know how to determine the kernel version)
else
kversion :=$(shell egrep '^VERSION +=' $(KSRC)/Makefile 2>/dev/null | \
                 sed -e 's/[^0-9]*\([0-9]*\)/\1/')
kplevel  :=$(shell egrep '^PATCHLEVEL +=' $(KSRC)/Makefile 2>/dev/null | \
                    sed -e 's/[^0-9]*\([0-9]*\)/\1/')
ksublevel:=$(shell egrep '^SUBLEVEL +=' $(KSRC)/Makefile 2>/dev/null | \
                  sed -e 's/[^0-9]*\([0-9]*\)/\1/')
EXTRA_VERSION:=$(shell egrep '^EXTRAVERSION +=' $(KSRC)/Makefile 2>/dev/null |\
                 sed -e 's/EXTRAVERSION[\t ]*=[\t ]*\(.*\)/\1/')
kextra:=$(strip $(EXTRA_VERSION))
HAVE_NEW_MODLIB:=$(shell egrep '\(INSTALL_MOD_PATH\)' \
                            $(KSRC)/Makefile 2>/dev/null )

# version, set FLAVOUR in the top level kernel Makefile *before*
# invoking make-kpkg -- it will be appended to UTS_RELEASE in
# version.h (separated by a hyphen). This affects everything -- the
# names and versions of the image, source, headers, and doc packages,
# and where the modules are searched for in /lib/modules.

ifdef FLAVOUR
# uhm - should check if we really have a Makefile capable of Flavours?
endif

FLAVOUR:=$(shell grep ^FLAVOUR $(KSRC)/Makefile 2>/dev/null | \
                  perl -ple 's/FLAVOUR[\s:=]+//g')

ifneq ($(strip $(FLAVOUR)),)
INT_FLAV := -$(FLAVOUR)
FLAV_ARG := FLAVOUR=$(FLAVOUR)
else
INT_FLAV :=
FLAV_ARG :=
endif

## This is the replacement for FLAVOUR
ifneq ($(strip $(APPEND_TO_VERSION)),)
iatv := $(strip $(APPEND_TO_VERSION))
EXTRAV_ARG := EXTRAVERSION=${EXTRA_VERSION}${iatv}
else
iatv :=
EXTRAV_ARG :=
endif

KVERS = $(kversion).$(kplevel).$(ksublevel)$(kextra)$(iatv)$(INT_FLAV)

endif #ifeq ($(strip $(KSRC)),)
endif #ifeq ($(strip $(KVERS)),)

non_epoch_version=$(shell echo $(KVERS) | perl -pe 's/^\d+://')
epoch=$(shell echo $(KVERS) | perl -ne 'm/^(\d+:)/ && print $$1')

# We also need the package version
pversion	:= $(shell sed -ne '1s/.*(\(.*\)).*/\1/p' debian/changelog)

# KPKG_DEST_DIR is the place where the final .deb package should be made
# when make-kpkg is used.
ifeq "$(origin KPKG_DEST_DIR)" "undefined"
ifeq "$(origin KMAINT)" "undefined"
DEB_DESTDIR = $(CURDIR)/..
else
DEB_DESTDIR = $(KSRC)/..
endif
else
DEB_DESTDIR = $(KPKG_DEST_DIR)
endif

# KDREV is the package-revision, as given to make-kpkg by the user.
# Just put a simply default value in here which we use when we test
# the packagebuilding without make-kpkg
ifeq ($(strip $(KDREV)),)
VERSION = $(epoch)$(pversion)
else
VERSION = $(epoch)$(pversion)+$(KDREV)
endif


# Prepares the package for distribution.  Intended for the kernel
# maintainer.
.PHONY: kdist
kdist: kdist_clean kdist_config kdist_image

# The kdist_configure target is called by make-kpkg modules_config. It
# should configure the module so it is ready for compilation (mostly
# useful for calling configure)
.PHONY: kdist_config
kdist_config:
	@echo Nothing to configure

# the kdist_image target is called by make-kpkg modules_image. It is
# responsible for compiling the module and creating the package. It
# should also clean up after making the module. Please note we use a
# seperate binary-modules target to make testing the package building
# easier
.PHONY: kdist_image
kdist_image:
	$(MAKE) $(MFLAGS) -f debian/rules binary-modules
	$(MAKE) $(MFLAGS) -f debian/rules clean

# the kdist_clean target is called by make-kpkg modules_clean. It is
# responsible for cleaning up any changes that have been made by the
# other kdist_commands (except for the .deb files created).
.PHONY: kdist_clean
kdist_clean:
	$(MAKE) $(MFLAGS) -f debian/rules clean

### end  KERNEL SETUP

# The substvars mechanism can't be use with the name of the packet
debian/control debian/postinst: %: %.in
	sed -e 's/_KVERS_/$(KVERS)/g' $< >$@


.PHONY: configure
configure: configure-stamp
configure-stamp: debian/control debian/postinst
	dh_testdir

	# Add here commands to configure the package.
	CONFIG_FILES=Makefile.common ./configure $(confflags) \
		--prefix=/ \
		--exec-prefix=/usr \
		--sysconfdir=/etc \
		--libdir=/usr/lib \
		--datadir=/usr/share \
		--includedir=/usr/include \
		--infodir=/usr/share/info \
		--mandir=/usr/share/man \
		--with-dsp-dir=/usr/share/$(package)/dsp \
		--with-kernel-src=$(KSRC)

	touch configure-stamp

.PHONY: clean
clean: debian/control
	dh_testdir
	dh_testroot

	# Add here commands to clean up after the build process.
	$(MAKE) -C driver clean >/dev/null 2>&1 || true
	rm -f Makefile.common
	rm -rf config.{status,log,cache}
	rm -f configure-stamp
	dh_clean 
	rm -f debian/control debian/postinst

# the binary-modules target prepares the $(pmodules) package.
# It is called by make-kpkg and *not* during a normal build
.PHONY: binary_modules binary-modules
binary_modules binary-modules: configure
	export DH_OPTIONS='-p$(pmodules)'

	dh_testdir
	dh_testroot
	dh_clean -k

	# Build the module
	$(MAKE) KERNELSRC=$(KSRC) KERNELVER=$(KVERS) -C driver driver

	# Install the module
#	$(MAKE) DESTDIR=$(CURDIR)/debian/$(pmodules) \
#		KERNELSRC=$(KSRC) KERNELVER=$(KVERS) \
#		-C driver installdriver 
	dh_installdirs -p$(pmodules) lib/modules/$(KVERS)/misc
ifneq (,$(findstring 2.6,$(KVERS)))
	install -o root -g root -m 644 driver/$(package).ko \
		debian/$(pmodules)/lib/modules/$(KVERS)/misc
else
	install -o root -g root -m 644 driver/$(package).o \
		debian/$(pmodules)/lib/modules/$(KVERS)/misc
endif

	# Build the package
	dh_installdebconf
	dh_installdocs
	dh_installchangelogs

	dh_fixperms
	dh_compress

	# We're not using this yet
	#dh_installmodules

	dh_installdeb
	dh_gencontrol -- -v$(VERSION)
	dh_md5sums
	dh_builddeb --destdir=$(DEB_DESTDIR)