3 # Debian X Strike Force Build System (XSFBS): Make portion
5 # Copyright 1996 Stephen Early
6 # Copyright 1997 Mark Eichin
7 # Copyright 1998-2005, 2007 Branden Robinson
8 # Copyright 2005 David Nusinow
10 # Licensed under the GNU General Public License, version 2. See the file
11 # /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
13 # Originally by Stephen Early <sde1000@debian.org>
14 # Modified by Mark W. Eichin <eichin@kitten.gen.ma.us>
15 # Modified by Adam Heath <doogie@debian.org>
16 # Modified by Branden Robinson <branden@debian.org>
17 # Modified by Fabio Massimo Di Nitto <fabbione@fabbione.net>
18 # Modified by David Nusinow <dnusinow@debian.org>
19 # Acknowledgements to Manoj Srivastava.
21 # Pass $(DH_OPTIONS) into the environment for debhelper's benefit.
24 # force quilt to not use ~/.quiltrc
25 QUILT = quilt --quiltrc /dev/null
26 # force QUILT_PATCHES to the default in case it is exported in the environment
27 QUILT_PATCHES = patches/
29 # Set up parameters for the upstream build environment.
31 # Determine (source) package name from Debian changelog.
32 SOURCE_NAME:=$(shell dpkg-parsechangelog -ldebian/changelog \
33 | grep '^Source:' | awk '{print $$2}')
35 # Determine package version from Debian changelog.
36 SOURCE_VERSION:=$(shell dpkg-parsechangelog -ldebian/changelog \
37 | grep '^Version:' | awk '{print $$2}')
39 # Determine upstream version number.
40 UPSTREAM_VERSION:=$(shell echo $(SOURCE_VERSION) | sed 's/-.*//')
42 # Determine the source version without the epoch for make-orig-tar-gz
43 NO_EPOCH_VER:=$(shell echo $(UPSTREAM_VERSION) | sed 's/^.://')
45 # Figure out who's building this package.
46 BUILDER:=$(shell echo $${DEBEMAIL:-$${EMAIL:-$$(echo $$LOGNAME@$$(cat /etc/mailname 2>/dev/null))}})
48 # Find out if this is an official build; an official build has nothing but
49 # digits, dots, and/or the strings "woody" or "sarge" in the Debian part of the
50 # version number. Anything else indicates an unofficial build.
51 OFFICIAL_BUILD:=$(shell VERSION=$(SOURCE_VERSION); if ! expr "$$(echo $${VERSION\#\#*-} | sed 's/\(woody\|sarge\)//g')" : ".*[^0-9.].*" >/dev/null 2>&1; then echo yes; fi)
53 # Set up parameters for the Debian build environment.
55 # Determine our architecture.
56 BUILD_ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
57 # Work around some old-time dpkg braindamage.
58 BUILD_ARCH:=$(subst i486,i386,$(BUILD_ARCH))
59 # The DEB_HOST_ARCH variable may be set per the Debian cross-compilation policy.
61 ARCH:=$(DEB_HOST_ARCH)
63 # dpkg-cross sets the ARCH environment variable; if set, use it.
71 # $(STAMP_DIR) houses stamp files for complex targets.
74 # $(SOURCE_DIR) houses one or more source trees.
75 SOURCE_DIR:=build-tree
77 # $(SOURCE_TREE) is the location of the source tree to be compiled. If there
78 # is more than one, others are found using this name plus a suffix to indicate
79 # the purpose of the additional tree (e.g., $(SOURCE_TREE)-custom). The
80 # "setup" target is responsible for creating such trees.
81 #SOURCE_TREE:=$(SOURCE_DIR)/xc
82 #FIXME We need to define this in our debian/rules file
84 # $(DEBTREEDIR) is where all install rules are told (via $(DESTDIR)) to place
86 DEBTREEDIR:=$(CURDIR)/debian/tmp
88 # All "important" targets have four lines:
89 # 1) A target name that is invoked by a package-building tool or the user.
90 # This consists of a dependency on a "$(STAMP_DIR)/"-prefixed counterpart.
91 # 2) A line delcaring 1) as a phony target (".PHONY:").
92 # 3) A "$(STAMP_DIR)/"-prefixed target which does the actual work, and may
93 # depend on other targets.
94 # 4) A line declaring 3) as a member of the $(stampdir_targets) variable; the
95 # "$(STAMP_DIR)/" prefix is omitted.
97 # This indirection is needed so that the "stamp" files that signify when a rule
98 # is done can be located in a separate "stampdir". Recall that make has no way
99 # to know when a goal has been met for a phony target (like "build" or
102 # At the end of each "$(STAMP_DIR)/" target, be sure to run the command ">$@"
103 # so that the target will not be run again. Removing the file will make Make
104 # run the target over.
106 # All phony targets should be declared as dependencies of .PHONY, even if they
107 # do not have "($STAMP_DIR)/"-prefixed counterparts.
109 # Define a harmless default rule to keep things from going nuts by accident.
113 # Set up the $(STAMP_DIR) directory.
115 stampdir_targets+=stampdir
116 stampdir: $(STAMP_DIR)/stampdir
117 $(STAMP_DIR)/stampdir:
121 # Set up the package build directory as quilt expects to find it.
123 stampdir_targets+=prepare
124 prepare: $(STAMP_DIR)/genscripts $(STAMP_DIR)/prepare $(STAMP_DIR)/patches $(STAMP_DIR)/log
125 $(STAMP_DIR)/prepare: $(STAMP_DIR)/stampdir
126 if [ ! -e $(STAMP_DIR)/patches ]; then \
127 mkdir $(STAMP_DIR)/patches; \
128 ln -s $(STAMP_DIR)/patches .pc; \
129 echo 2 >$(STAMP_DIR)/patches/.version; \
131 if [ ! -e $(STAMP_DIR)/log ]; then \
132 mkdir $(STAMP_DIR)/log; \
134 if [ -e debian/patches ] && [ ! -e patches ]; then \
135 ln -s debian/patches patches; \
139 # Apply all patches to the upstream source.
141 stampdir_targets+=patch
142 patch: $(STAMP_DIR)/patch
143 $(STAMP_DIR)/patch: $(STAMP_DIR)/prepare
144 if ! [ `which quilt` ]; then \
145 echo "Couldn't find quilt. Please install it or add it to the build-depends for this package."; \
148 if $(QUILT) next >/dev/null 2>&1; then \
149 echo -n "Applying patches..."; \
150 if $(QUILT) push -a -v >$(STAMP_DIR)/log/patch 2>&1; then \
151 cat $(STAMP_DIR)/log/patch; \
152 echo "successful."; \
154 cat $(STAMP_DIR)/log/patch; \
155 echo "failed! (check $(STAMP_DIR)/log/patch for details)"; \
159 echo "No patches to apply"; \
163 # Revert all patches to the upstream source.
166 rm -f $(STAMP_DIR)/patch
167 @echo -n "Unapplying patches..."; \
168 if [ -e $(STAMP_DIR)/patches/applied-patches ]; then \
169 if $(QUILT) pop -a -v >$(STAMP_DIR)/log/unpatch 2>&1; then \
170 cat $(STAMP_DIR)/log/unpatch; \
171 echo "successful."; \
173 cat $(STAMP_DIR)/log/unpatch; \
174 echo "failed! (check $(STAMP_DIR)/log/unpatch for details)"; \
178 echo "nothing to do."; \
181 # Clean the generated maintainer scripts.
184 rm -f $(STAMP_DIR)/genscripts
185 rm -f debian/*.config \
191 # Clean the package build tree.
193 xsfclean: cleanscripts unpatch
196 rm -rf $(STAMP_DIR) $(SOURCE_DIR)
198 dh_clean debian/shlibs.local \
201 # Generate the debconf templates POT file header.
202 debian/po/pothead: debian/po/pothead.in
203 sed -e 's/SOURCE_VERSION/$(SOURCE_VERSION)/' \
204 -e 's/DATE/$(shell date "+%F %X%z"/)' <$< >$@
206 # Update POT and PO files.
208 updatepo: debian/po/pothead
209 debian/scripts/debconf-updatepo --pot-header=pothead --verbose
211 # Remove files from the upstream source tree that we don't need, or which have
212 # licensing problems. It must be run before creating the .orig.tar.gz.
214 # Note: This rule is for Debian package maintainers' convenience, and is not
215 # needed for conventional build scenarios.
216 .PHONY: prune-upstream-tree
218 # Ensure we're in the correct directory.
220 grep -rvh '^#' debian/prune/ | xargs --no-run-if-empty rm -rf
222 # Verify that there are no offsets or fuzz in the patches we apply.
224 # Note: This rule is for Debian package maintainers' convenience, and is not
225 # needed for conventional build scenarios.
227 patch-audit: prepare unpatch
228 @echo -n "Auditing patches..."; \
229 >$(STAMP_DIR)/log/patch; \
231 while [ -n "$$($(QUILT) next)" ]; do \
232 RESULT=$$($(QUILT) push -v | tee -a $(STAMP_DIR)/log/patch | grep ^Hunk | sed 's/^Hunk.*\(succeeded\|FAILED\).*/\1/');\
235 echo "fuzzy patch: $$($(QUILT) top)" \
236 | tee -a $(STAMP_DIR)/log/$$($(QUILT) top); \
240 echo "broken patch: $$($(QUILT) next)" \
241 | tee -a $(STAMP_DIR)/log/$$($(QUILT) next); \
246 if [ -n "$$FUZZY" ]; then \
247 echo "there were fuzzy patches; please fix."; \
253 # Generate the maintainer scripts.
255 stampdir_targets+=genscripts
256 genscripts: $(STAMP_DIR)/genscripts
257 $(STAMP_DIR)/genscripts: $(STAMP_DIR)/stampdir
258 for FILE in debian/*.config.in \
259 debian/*.postinst.in \
261 debian/*.preinst.in \
262 debian/*.prerm.in; do \
263 if [ -e "$$FILE" ]; then \
264 MAINTSCRIPT=$$(echo $$FILE | sed 's/.in$$//'); \
265 sed -n '1,/^#INCLUDE_SHELL_LIB#$$/p' <$$FILE \
266 | sed -e '/^#INCLUDE_SHELL_LIB#$$/d' >$$MAINTSCRIPT.tmp; \
267 cat debian/xsfbs/xsfbs.sh >>$$MAINTSCRIPT.tmp; \
268 sed -n '/^#INCLUDE_SHELL_LIB#$$/,$$p' <$$FILE \
269 | sed -e '/^#INCLUDE_SHELL_LIB#$$/d' >>$$MAINTSCRIPT.tmp; \
270 sed -e 's/@SOURCE_VERSION@/$(SOURCE_VERSION)/' \
271 -e 's/@OFFICIAL_BUILD@/$(OFFICIAL_BUILD)/' \
272 -e 's/@DEFAULT_DCRESOLUTIONS@/$(DEFAULT_DCRESOLUTIONS)/' \
273 <$$MAINTSCRIPT.tmp >$$MAINTSCRIPT; \
274 rm $$MAINTSCRIPT.tmp; \
277 # Validate syntax of generated shell scripts.
278 #sh debian/scripts/validate-posix-sh debian/*.config \
279 # debian/*.postinst \
285 # Generate the shlibs.local file.
287 cat debian/*.shlibs >$@
289 SERVERMINVERS = $(shell cat /usr/share/xserver-xorg/serverminver 2>/dev/null)
290 VIDEOABI = $(shell cat /usr/share/xserver-xorg/videoabiver 2>/dev/null)
291 INPUTABI = $(shell cat /usr/share/xserver-xorg/inputabiver 2>/dev/null)
292 SERVER_DEPENDS = xserver-xorg-core (>= $(SERVERMINVERS))
293 VIDDRIVER_PROVIDES = xserver-xorg-video-$(VIDEOABI)
294 INPDRIVER_PROVIDES = xserver-xorg-input-$(INPUTABI)
296 PACKAGE=$(shell awk '/^Package:/ { print $$2; exit }' < debian/control)
301 ifeq ($(SERVERMINVERS),)
302 @echo error: xserver-xorg-dev needs to be installed
305 echo "xserver:Depends=$(SERVER_DEPENDS)" >> debian/$(PACKAGE).substvars
306 echo "xviddriver:Provides=$(VIDDRIVER_PROVIDES)" >> debian/$(PACKAGE).substvars
307 echo "xinpdriver:Provides=$(INPDRIVER_PROVIDES)" >> debian/$(PACKAGE).substvars
310 # vim:set noet ai sts=8 sw=8 tw=0: