1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

root/csw/mgar/gar/v2-defaultchange/gar.lib.mk @ 13903

Revision 13903, 41.8 KB (checked in by dmichelsen, 2 years ago)

mGAR v2 defaultchange: Changes as announced

  • Property svn:keywords set to Id Revision URL
Line 
1# vim: ft=make ts=4 sw=4 noet
2#
3# $Id$
4#
5# Copyright (C) 2001 Nick Moffitt
6#
7# Redistribution and/or use, with or without modification, is
8# permitted.  This software is without warranty of any kind.  The
9# author(s) shall not be liable in the event that use of the
10# software causes damage.
11#
12
13# cookies go here, so we have to be able to find them for
14# dependency checking.
15VPATH += $(COOKIEDIR)
16
17# convenience variable to make the cookie.
18MAKECOOKIE = mkdir -p $(COOKIEDIR)/$(@D) && date >> $(COOKIEDIR)/$@
19
20URLSTRIP = $(subst ://,//,$(1))
21
22# if you need to proxy git:// connections, set GIT_USE_PROXY.  There is a
23# default proxy script that works with the (squid?) proxy at the BO buildfarm.
24# override GIT_PROXY_SCRIPT to something else if you need to.
25GIT_MAYBEPROXY = $(if $(GIT_USE_PROXY),GIT_PROXY_COMMAND=$(GIT_PROXY_SCRIPT))
26GIT_TREEISH = $(if $(GIT_TREEISH_$(1)),$(GIT_TREEISH_$(1)),HEAD)
27
28#################### FETCH RULES ####################
29
30# if the caller has defined _postinstall, etc targets for a package,
31# add these 'dynamic script' targets to our fetch list
32DYNURLS := $(foreach DYN,$(DYNSCRIPTS),dynscr://$(DYN))
33
34URLS := $(foreach SITE,$(FILE_SITES) $(MASTER_SITES),$(addprefix $(SITE),$(DISTFILES))) $(foreach SITE,$(FILE_SITES) $(PATCH_SITES) $(MASTER_SITES),$(addprefix $(SITE),$(ALLFILES_PATCHFILES))) $(DYNURLS)
35
36define gitsubst
37$(subst git-git,git,$(if $(findstring $(1)://,$(2)),$(patsubst $(1)%,git-$(1)%,$(call URLSTRIP,$(2)))))
38endef
39
40ifdef GIT_REPOS
41URLS += $(foreach R,$(GIT_REPOS),gitrepo://$(call GITPROJ,$(R)) $(foreach gitproto,git http file ssh,$(call gitsubst,$(gitproto),$(R))))
42endif
43
44# Download the file if and only if it doesn't have a preexisting
45# checksum file.  Loop through available URLs and stop when you
46# get one that doesn't return an error code.
47# Note that GAR targets are used to download the URLs, thus:
48# 1) we have to strip the colon from the URLs
49# 2) the download is very costly with bigger Makefiles as they will be
50#    re-evaluated for every URL (nested gmake invocation, room for improvement)
51$(DOWNLOADDIR)/%: 
52        @if test -f $(COOKIEDIR)/checksum-$*; then : ; else \
53                echo " ==> Grabbing $@"; \
54                ( for i in $(filter %/$*,$(URLS)); do  \
55                        echo "  ==> Trying $$i"; \
56                        $(MAKE) -s `echo $$i | tr -d :` || continue; \
57                        mv $(PARTIALDIR)/$* $@; \
58                        break; \
59                done; ) 2>&1 | grep -v '^$(MAKE)'; \
60                if test -r $@ ; then : ; else \
61                        echo '(!!!) Failed to download $@!' 1>&2; \
62                        false; \
63                fi; \
64        fi
65
66gitrepo//%:
67        @( if [ -d $(GARCHIVEDIR)/$(call GITPROJ,$*) ]; then \
68                ( cd $(GARCHIVEDIR)/$(call GITPROJ,$*); \
69                        $(GIT_MAYBEPROXY) git --bare fetch ) && \
70                gln -s $(GARCHIVEDIR)/$(call GITPROJ,$*)/ $(PARTIALDIR)/$(call GITPROJ,$*); \
71           else \
72                false; \
73          fi )
74
75# the git remote add commands are so that we can later do a fetch
76# to update the code.
77# we possibly proxy the git:// references depending on GIT_USE_PROXY
78git-http//%:
79        @git clone --bare http://$* $(PARTIALDIR)/$(call GITPROJ,$*)
80        @( cd $(PARTIALDIR)/$(call GITPROJ,$*); \
81                git remote add origin http://$*; \
82                git config remote.origin.fetch $(if $(GIT_REFS_$(call GITPROJ,$*)),$(GIT_REFS_$(call GITPROJ,$*)),$(GIT_DEFAULT_TRACK)); )
83
84git//%:
85        @$(GIT_MAYBEPROXY) git clone --bare git://$* $(PARTIALDIR)/$(call GITPROJ,$*)
86        @( cd $(PARTIALDIR)/$(call GITPROJ,$*); \
87                git remote add origin git://$*; \
88                git config remote.origin.fetch $(if $(GIT_REFS_$(call GITPROJ,$*)),$(GIT_REFS_$(call GITPROJ,$*)),$(GIT_DEFAULT_TRACK)); )
89
90git-file//%:
91        @git clone --bare file:///$* $(PARTIALDIR)/$(call GITPROJ,$*)
92        @( cd $(PARTIALDIR)/$(call GITPROJ,$*); \
93                git remote add origin file://$*; \
94                git config remote.origin.fetch $(if $(GIT_REFS_$(call GITPROJ,$*)),$(GIT_REFS_$(call GITPROJ,$*)),$(GIT_DEFAULT_TRACK)); )
95
96git-ssh//%:
97        @git clone --bare ssh://$* $(PARTIALDIR)/$(call GITPROJ,$*)
98        @( cd $(PARTIALDIR)/$(call GITPROJ,$*); \
99                git remote add origin ssh://$*; \
100                git config remote.origin.fetch $(if $(GIT_REFS_$(call GITPROJ,$*)),$(GIT_REFS_$(call GITPROJ,$*)),$(GIT_DEFAULT_TRACK)); )
101
102
103# create ADMSCRIPTS 'on the fly' from variables defined by the caller
104# This version is private and should only be called from the non-private
105# version directly below
106_dynscr//%:
107        $($(subst .,_,$*))
108
109dynscr//%:
110        $(MAKE) --no-print-directory -n _$@ > $(PARTIALDIR)/$*
111
112# download an http URL (colons omitted)
113http//%:
114        @wget $(WGET_OPTS) -T 30 -c -P $(PARTIALDIR) http://$*
115
116https//%:
117        @wget $(WGET_OPTS) -T 30 -c -P $(PARTIALDIR) https://$*
118
119# download an ftp URL (colons omitted)
120#ftp//%:
121#       @wget -T 30 -c --passive-ftp -P $(PARTIALDIR) ftp://$*
122ftp//%:
123        @wget $(WGET_OPTS) -T 30 -c -P $(PARTIALDIR) ftp://$*
124
125# link to a local copy of the file
126# (absolute path)
127file///%:
128        @if test -f /$*; then \
129                gln -sf /$* $(PARTIALDIR)/$(notdir $*); \
130        else \
131                false; \
132        fi
133
134# link to a local copy of the file
135# (relative path)
136file//%:
137        @if test -f $*; then \
138                gln -sf "$(CURDIR)/$*" $(PARTIALDIR)/$(notdir $*); \
139        else \
140                false; \
141        fi
142
143# Using Jeff Waugh's rsync rule.
144# DOES NOT PRESERVE SYMLINKS!
145rsync//%:
146        @rsync -azvLP rsync://$* $(PARTIALDIR)/
147
148# Using Jeff Waugh's scp rule
149scp//%:
150        @scp -C $* $(PARTIALDIR)/
151
152# Fetch a SVN repo via http
153svn-http//%:
154        @svn co $(SVNHTTP_CO_ARGS) http://$* $(PARTIALDIR)/$(notdir $*)
155
156svn-https//%:
157        @svn co $(SVNHTTP_CO_ARGS) https://$* $(PARTIALDIR)/$(notdir $*)
158
159#################### CHECKSUM RULES ####################
160
161# check a given file's checksum against $(CHECKSUM_FILE) and
162# error out if it mentions the file without an "OK".
163# The removal of the download prefix is for legacy checksums. For newstyle
164# checksums without path this is not necessary.
165checksum-%: $(CHECKSUM_FILE) 
166        @echo " ==> Running checksum on $*"
167        @if ggrep -- '[ /]$*$$' $(CHECKSUM_FILE); then \
168                if cat $(CHECKSUM_FILE) | sed -e 's!download/!!' | (cd $(DOWNLOADDIR); LC_ALL="C" LANG="C" gmd5sum -c 2>&1) | \
169                        ggrep -- '$*' | ggrep -v ':[ ]\+OK'; then \
170                        echo '(!!!) $* failed checksum test!' 1>&2; \
171                        false; \
172                else \
173                        echo 'file $* passes checksum test!'; \
174                        $(MAKECOOKIE); \
175                fi \
176        else \
177                echo '(!!!) $* not in $(CHECKSUM_FILE) file!' 1>&2; \
178                false; \
179        fi
180
181#################### CHECKNEW RULES ####################
182
183
184################### UWATCH VARIABLES ###################
185UPSTREAM_MASTER_SITES ?= $(MASTER_SITES)
186ENABLE_UWATCH ?= 1
187
188
189########################################################
190# Display uwatch informations
191#
192get-uwatch-configuration:
193        @if [ '$(ENABLE_UWATCH)' -ne '1' ] ; then \
194                echo "$(NAME) - Upstream Watch is disabled" ; \
195        else \
196                echo "$(NAME) - Upstream Watch is enabled" ; \
197                if [ ! -n '$(CATALOGNAME)' ]; then \
198                        echo "$(NAME) - CATALOGNAME is not set" ; \
199                else \
200                        echo "$(NAME) - CATALOGNAME is : $(CATALOGNAME)" ; \
201                fi ; \
202                if [ ! -n '$(DISTFILES)' ]; then \
203                        echo "$(NAME) - DISTFILES is not set" ; \
204                else \
205                        echo "$(NAME) - DISTFILES are : $(DISTFILES)" ; \
206                fi ; \
207                if [ ! -n '$(UFILES_REGEX)' ]; then \
208                        echo "$(NAME) - UFILES_REGEX is not set" ; \
209                else \
210                        echo "$(NAME) - UFILES_REGEX is : $(UFILES_REGEX)" ; \
211                fi; \
212                if [ ! -n '$(UPSTREAM_MASTER_SITES)' ]; then \
213                        echo "$(NAME) - UPSTREAM_MASTER_SITES is not set" ; \
214                else \
215                        echo "$(NAME) - UPSTREAM_MASTER_SITES is : $(UPSTREAM_MASTER_SITES)" ; \
216                fi; \
217                if [ ! -n '$(VERSION)' ]; then \
218                        echo "$(NAME) - VERSION is not set" ; \
219                else \
220                        echo "$(NAME) - GAR version is : $(VERSION)" ; \
221                fi ; \
222                if [ ! -n '$(http_proxy)' ]; then \
223                        echo "$(NAME) - http_proxy is not set" ; \
224                else \
225                        echo "$(NAME) - http_proxy is : $(http_proxy)" ; \
226                fi ; \
227                if [ ! -n '$(ftp_proxy)' ]; then \
228                        echo "$(NAME) - ftp_proxy is not set" ; \
229                else \
230                        echo "$(NAME) - ftp_proxy is : $(ftp_proxy)" ; \
231                fi ; \
232        fi ;
233
234########################################################
235# Retrieve the list of upstream versions
236#
237
238get-upstream-version-list:
239        @if [ '$(ENABLE_UWATCH)' -ne '1' ] ; then \
240                echo "$(NAME) - Upstream Watch is disabled" ; \
241        else \
242                UWATCHCONFCHECK="Ok" ; \
243                if [ ! -n '$(UFILES_REGEX)' ]; then \
244                        echo "$(NAME) - UFILES_REGEX is not set - trying to guess it" ; \
245                fi; \
246                if [ ! -n '$(UPSTREAM_MASTER_SITES)' ]; then \
247                        echo "$(NAME) - Error UPSTREAM_MASTER_SITES is not set" ; \
248                        UWATCHCONFCHECK="Error" ; \
249                fi; \
250                if [ ! -n '$(VERSION)' ]; then \
251                        echo "$(NAME) - Error VERSION is not set" ; \
252                        UWATCHCONFCHECK="Error" ; \
253                fi; \
254                if [ "$$UWATCHCONFCHECK" -ne "Ok" ] ; then \
255                        exit 1 ; \
256                fi ; \
257                if [ ! -n '$(UFILES_REGEX)' ]; then \
258                        VERSIONLIST=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch get-upstream-version-list --upstream-url="$(UPSTREAM_MASTER_SITES)" --gar-distfiles="$(DISTFILES)" --catalog-name="$(CATALOGNAME)"` ; \
259                else \
260                        VERSIONLIST=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch get-upstream-version-list --upstream-url="$(UPSTREAM_MASTER_SITES)" --regexp="$(UFILES_REGEX)"` ; \
261                fi ; \
262                if [ "$$?" -ne "0" ] ; then \
263                        echo "Error occured while executing uwatch get-upstream-version-list. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
264                        echo "Output : $$VERSIONLIST" ; \
265                        exit 1 ; \
266                fi; \
267                if [ -n "$$VERSIONLIST" ] ; then \
268                        for VERSION in $$VERSIONLIST ; do \
269                                if [ ! "$$VERSION" -eq "" ] ; then \
270                                        echo "$(NAME) - $$VERSION" ; \
271                                fi ; \
272                        done ; \
273                else \
274                        echo "$(NAME) - No version found. Please check UPSTREAM_MASTER_SITES and UFILES_REGEX variables in the Makefile" ; \
275                fi ; \
276        fi ;
277
278########################################################
279# Retrieve the newest upstream version
280#
281get-upstream-latest-version:
282        @if [ '$(ENABLE_UWATCH)' -ne '1' ] ; then \
283                echo "$(NAME) - Upstream Watch is disabled" ; \
284        else \
285                UWATCHCONFCHECK="Ok" ; \
286                if [ ! -n '$(UFILES_REGEX)' ]; then \
287                        echo "$(NAME) - UFILES_REGEX is not set - trying to guess it" ; \
288                fi; \
289                if [ ! -n '$(UPSTREAM_MASTER_SITES)' ]; then \
290                        echo "$(NAME) - Error UPSTREAM_MASTER_SITES is not set" ; \
291                        UWATCHCONFCHECK="Error" ; \
292                fi; \
293                if [ ! -n '$(VERSION)' ]; then \
294                        echo "$(NAME) - Error VERSION is not set" ; \
295                        UWATCHCONFCHECK="Error" ; \
296                fi; \
297                if [ "$$UWATCHCONFCHECK" -ne "Ok" ] ; then \
298                        exit 1 ; \
299                fi ; \
300                if [ ! -n '$(UFILES_REGEX)' ]; then \
301                        LATEST=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch get-upstream-latest-version --upstream-url="$(UPSTREAM_MASTER_SITES)" --gar-distfiles="$(DISTFILES)" --catalog-name="$(CATALOGNAME)"` ; \
302                else \
303                        LATEST=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch get-upstream-latest-version --upstream-url="$(UPSTREAM_MASTER_SITES)" --regexp="$(UFILES_REGEX)"` ; \
304                fi ; \
305                if [ "$$?" -ne "0" ] ; then \
306                        echo "Error occured while executing uwatch get-upstream-latest-version. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
307                        echo "$$LATEST" ; \
308                        exit 1 ; \
309                fi; \
310                if [ -n "$$LATEST" ] ; then \
311                        echo "$(NAME) - Latest upstream version is $$LATEST" ; \
312                else \
313                        echo "$(NAME) - No version found. Please check UPSTREAM_MASTER_SITES and UFILES_REGEX variables in the Makefile" ; \
314                fi ; \
315        fi ;
316
317########################################################
318# Compare local and upstream versions
319#
320check-upstream:
321        @if [ '$(ENABLE_UWATCH)' -ne '1' ] ; then \
322                echo "$(NAME) - Upstream Watch is disabled" ; \
323        else \
324                UWATCHCONFCHECK="Ok" ; \
325                if [ ! -n '$(UFILES_REGEX)' ]; then \
326                        echo "$(NAME) - UFILES_REGEX is not set - trying to guess it" ; \
327                fi; \
328                if [ ! -n '$(UPSTREAM_MASTER_SITES)' ]; then \
329                        echo "$(NAME) - Error UPSTREAM_MASTER_SITES is not set" ; \
330                        UWATCHCONFCHECK="Error" ; \
331                fi; \
332                if [ ! -n '$(VERSION)' ]; then \
333                        echo "$(NAME) - Error VERSION is not set" ; \
334                        UWATCHCONFCHECK="Error" ; \
335                fi; \
336                if [ "$$UWATCHCONFCHECK" -ne "Ok" ] ; then \
337                        exit 1 ; \
338                fi ; \
339                if [ ! -n '$(UFILES_REGEX)' ]; then \
340                        LATEST=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch check-upstream --upstream-url="$(UPSTREAM_MASTER_SITES)" --gar-distfiles="$(DISTFILES)" --catalog-name="$(CATALOGNAME)" --current-version="$(VERSION)"` ; \
341                else \
342                        LATEST=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch check-upstream --upstream-url="$(UPSTREAM_MASTER_SITES)" --regexp="$(UFILES_REGEX)" --current-version="$(VERSION)"` ; \
343                fi ; \
344                if [ "$$?" -ne "0" ] ; then \
345                        echo "Error occured while executing uwatch check-upstream. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
346                        echo "$$LATEST" ; \
347                        exit 1 ; \
348                fi; \
349                if [ -n "$$LATEST" ] ; then \
350                        echo "$(NAME) : A new version of upstream files is available. Package can be upgraded from version $(VERSION) to $$LATEST"; \
351                else \
352                        echo "$(NAME) : Package is up-to-date. Current version is $(VERSION)" ; \
353                fi ; \
354        fi
355
356
357########################################################
358# Create upgrade branch from current to latest upstream
359#
360upgrade-to-latest-upstream:
361        @if [ '$(ENABLE_UWATCH)' -ne '1' ] ; then \
362                echo "$(NAME) - Upstream Watch is disabled" ; \
363        else \
364                UWATCHCONFCHECK="Ok" ; \
365                if [ ! -n '$(UFILES_REGEX)' ]; then \
366                        echo "$(NAME) - UFILES_REGEX is not set - trying to guess it" ; \
367                fi; \
368                if [ ! -n '$(UPSTREAM_MASTER_SITES)' ]; then \
369                        echo "$(NAME) - Error UPSTREAM_MASTER_SITES is not set" ; \
370                        UWATCHCONFCHECK="Error" ; \
371                fi; \
372                if [ ! -n '$(VERSION)' ]; then \
373                        echo "$(NAME) - Error VERSION is not set" ; \
374                        UWATCHCONFCHECK="Error" ; \
375                fi; \
376                if [ "$$UWATCHCONFCHECK" -ne "Ok" ] ; then \
377                        exit 1 ; \
378                fi ; \
379                if [ ! -n '$(UFILES_REGEX)' ]; then \
380                        LATEST=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch check-upstream --upstream-url="$(UPSTREAM_MASTER_SITES)" --gar-distfiles="$(DISTFILES)" --catalog-name="$(CATALOGNAME)" --current-version="$(VERSION)"` ; \
381                else \
382                        LATEST=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch check-upstream --upstream-url="$(UPSTREAM_MASTER_SITES)" --regexp="$(UFILES_REGEX)" --current-version="$(VERSION)"` ; \
383                fi ; \
384                if [ "$$?" -ne "0" ] ; then \
385                        echo "Error occured while executing uwatch check-upstream. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
386                        echo "$$LATEST" ; \
387                        exit 1 ; \
388                fi; \
389                if [ ! -f "$(COOKIEDIR)/upgrade-to-latest-upstream-$$LATEST" ] ; then \
390                        if [ ! -d "../branches/upgrade_from_$(VERSION)_to_$$LATEST" ] ; then \
391                                if [ -n "$$LATEST" ] ; then \
392                                        echo "$(NAME) : a new version of upstream files is available. Creating upgrade branch from version $(VERSION) to $$LATEST"; \
393                                        VERSIONUPGRADE=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch upgrade-to-version --current-version="$(VERSION)" --target-version="$$LATEST"` ; \
394                                        if [ "$$?" -ne "0" ] ; then \
395                                                echo "Error occured while executing uwatch upgrade-to-version. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
396                                                echo "$$VERSIONUPGRADE" ; \
397                                                exit 1 ; \
398                                        fi; \
399                                        if [ -n "$$VERSIONUPGRADE" ] ; then \
400                                                echo "$(NAME) - $$VERSIONUPGRADE" ; \
401                                        fi ; \
402                                else \
403                                        echo "$(NAME) : Package is up-to-date. Upstream site has no version newer than $(VERSION)" ; \
404                                fi ; \
405                        else \
406                                echo "$(NAME) - Upgrade branch from version $(VERSION) to version $$LATEST already exist" ; \
407                        fi ; \
408                        $(MAKE) upgrade-to-latest-upstream-$$LATEST >/dev/null; \
409                else \
410                        echo "$(NAME) - Upgrade branch to version $$LATEST already created by upstream_watch" ; \
411                fi ; \
412        fi
413
414
415########################################################
416# Create upgrade branch from current to latest upstream
417#
418update-package-version-database:PACKAGELIST=$(foreach SPEC,$(SPKG_SPECS),$(call _pkglist_one,$(SPEC))\n)
419update-package-version-database:
420        @EXECUTIONDATE=`date +"%Y-%m-%d %H:%M:%S"` ; \
421        if [ '$(ENABLE_UWATCH)' -ne '1' ] ; then \
422                echo "$(NAME) - Upstream Watch is disabled" ; \
423                printf "$(PACKAGELIST)" | while read line ; do \
424                        GARPATH=`echo $$line | awk '{ print $$1 }'` ; \
425                        CATALOGNAME=`echo $$line | awk '{ print $$2 }'` ; \
426                        PKGNAME=`echo $$line | awk '{ print $$3 }'` ; \
427                        REPORTVERSION=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch update-package-version-database --catalog-name="$$CATALOGNAME" --package-name="$$PKGNAME" --execution-date="$$EXECUTIONDATE" --gar-path="$$GARPATH" --gar-version="$(VERSION)" --upstream-url="$(UPSTREAM_MASTER_SITES)" --regexp="$(UFILES_REGEX)" --gar-distfiles="$(DISTFILES)" --uwatch-output="Upstream Watch is disabled" --uwatch-deactivated` ; \
428                        if [ "$$?" -ne "0" ] ; then \
429                                echo "Error occured while executing uwatch update-package-version-database --uwatch-deactivated. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
430                                echo "$$REPORTVERSION" ; \
431                                exit 1 ; \
432                        fi; \
433                done ; \
434                if [ -n "$$REPORTVERSION" ] ; then \
435                        echo "$(NAME) - $$REPORTVERSION" ; \
436                fi ; \
437        else \
438                UWATCHCONFCHECK="Ok" ; \
439                if [ ! -n '$(UFILES_REGEX)' ]; then \
440                        echo "$(NAME) - UFILES_REGEX is not set - trying to guess it" ; \
441                fi; \
442                if [ ! -n '$(UPSTREAM_MASTER_SITES)' ]; then \
443                        echo "$(NAME) - Error UPSTREAM_MASTER_SITES is not set" ; \
444                        UWATCHCONFCHECK="Error" ; \
445                fi; \
446                if [ ! -n '$(VERSION)' ]; then \
447                        echo "$(NAME) - Error VERSION is not set" ; \
448                        UWATCHCONFCHECK="Error" ; \
449                fi; \
450                if [ "$$UWATCHCONFCHECK" -ne "Ok" ] ; then \
451                        printf "$(PACKAGELIST)" | while read line ; do \
452                                GARPATH=`echo $$line | awk '{ print $$1 }'` ; \
453                                CATALOGNAME=`echo $$line | awk '{ print $$2 }'` ; \
454                                PKGNAME=`echo $$line | awk '{ print $$3 }'` ; \
455                                REPORTVERSION=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch update-package-version-database --catalog-name="$$CATALOGNAME" --package-name="$$PKGNAME" --execution-date="$$EXECUTIONDATE" --gar-path="$$GARPATH" --gar-version="$(VERSION)" --uwatch-error  --upstream-url="$(UPSTREAM_MASTER_SITES)" --regexp="$(UFILES_REGEX)" --gar-distfiles="$(DISTFILES)" --uwatch-output="Upstream Watch configuration error" ` ; \
456                                if [ "$$?" -ne "0" ] ; then \
457                                        echo "Error occured while executing uwatch update-package-version-database --uwatch-error. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
458                                        echo "$$REPORTVERSION" ; \
459                                        exit 1 ; \
460                                fi; \
461                        done ; \
462                        exit 1 ; \
463                fi ; \
464                if [ ! -n '$(UFILES_REGEX)' ]; then \
465                        LATEST=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch get-upstream-latest-version --upstream-url="$(UPSTREAM_MASTER_SITES)" --gar-distfiles="$(DISTFILES)" --catalog-name="$(CATALOGNAME)"` ; \
466                else \
467                        LATEST=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch get-upstream-latest-version --upstream-url="$(UPSTREAM_MASTER_SITES)" --regexp="$(UFILES_REGEX)"` ; \
468                fi ; \
469                if [ "$$?" -ne "0" ] ; then \
470                        echo "Error occured while executing uwatch get-upstream-latest-version. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
471                        echo "$$LATEST" ; \
472                        printf "$(PACKAGELIST)" | while read line ; do \
473                                GARPATH=`echo $$line | awk '{ print $$1 }'` ; \
474                                CATALOGNAME=`echo $$line | awk '{ print $$2 }'` ; \
475                                PKGNAME=`echo $$line | awk '{ print $$3 }'` ; \
476                                REPORTVERSION=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch update-package-version-database --catalog-name="$$CATALOGNAME" --package-name="$$PKGNAME" --execution-date="$$EXECUTIONDATE" --gar-path="$$GARPATH" --gar-version="$(VERSION)" --uwatch-error  --upstream-url="$(UPSTREAM_MASTER_SITES)" --regexp="$(UFILES_REGEX)" --gar-distfiles="$(DISTFILES)" --uwatch-output="$$LATEST" ` ; \
477                                if [ "$$?" -ne "0" ] ; then \
478                                        echo "Error occured while executing uwatch update-package-version-database --uwatch-error. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
479                                        echo "$$REPORTVERSION" ; \
480                                        exit 1 ; \
481                                fi; \
482                        done ; \
483                        exit 1 ; \
484                fi; \
485                printf "$(PACKAGELIST)" | while read line ; do \
486                        GARPATH=`echo $$line | awk '{ print $$1 }'` ; \
487                        CATALOGNAME=`echo $$line | awk '{ print $$2 }'` ; \
488                        PKGNAME=`echo $$line | awk '{ print $$3 }'` ; \
489                        if [ ! -n '$(UFILES_REGEX)' ]; then \
490                                REPORTVERSION=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch update-package-version-database --catalog-name="$$CATALOGNAME" --package-name="$$PKGNAME" --execution-date="$$EXECUTIONDATE" --gar-path="$$GARPATH" --gar-version=$(VERSION) --upstream-version="$$LATEST"  --upstream-url="$(UPSTREAM_MASTER_SITES)"  --gar-distfiles="$(DISTFILES)" --uwatch-output="Successful" ` ; \
491                        else \
492                                REPORTVERSION=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch update-package-version-database --catalog-name="$$CATALOGNAME" --package-name="$$PKGNAME" --execution-date="$$EXECUTIONDATE" --gar-path="$$GARPATH" --gar-version=$(VERSION) --upstream-version="$$LATEST"  --upstream-url="$(UPSTREAM_MASTER_SITES)" --regexp="$(UFILES_REGEX)" --gar-distfiles="$(DISTFILES)" --uwatch-output="Successful" ` ; \
493                        fi ; \
494                        if [ "$$?" -ne "0" ] ; then \
495                                echo "Error occured while executing uwatch update-package-version-database. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
496                                echo "$$REPORTVERSION" ; \
497                                REPORTVERSION=`http_proxy=$(http_proxy) ftp_proxy=$(ftp_proxy) $(GARBIN)/uwatch update-package-version-database --catalog-name="$$CATALOGNAME" --package-name="$$PKGNAME" --execution-date="$$EXECUTIONDATE" --gar-path="$$GARPATH" --gar-version="$(VERSION)" --uwatch-error  --upstream-url="$(UPSTREAM_MASTER_SITES)" --regexp="$(UFILES_REGEX)" --gar-distfiles="$(DISTFILES)" --uwatch-output="$$REPORTVERSION" ` ; \
498                                if [ "$$?" -ne "0" ] ; then \
499                                        echo "Error occured while executing uwatch update-package-version-database --uwatch-error. Please check configuration with target get-uwatch-configuration. Here is the output of uwatch command :" ; \
500                                        echo "$$REPORTVERSION" ; \
501                                        exit 1 ; \
502                                fi; \
503                                exit 1 ; \
504                        fi; \
505                done ; \
506                if [ -n "$$REPORTVERSION" ] ; then \
507                        echo "$(NAME) - $$REPORTVERSION" ; \
508                fi ; \
509        fi
510
511#       
512
513########################################################
514#
515get-gar-version:
516        @if [ ! -n '$(VERSION)' ]; then \
517                echo "$(NAME) - VERSION is not defined" ; \
518                exit 1 ; \
519        else \
520                echo "$(NAME) - GAR version is $(VERSION)" ; \
521        fi ;
522
523upgrade-to-latest-upstream-%:
524        @$(MAKECOOKIE)
525
526
527#################### GARCHIVE RULES ####################
528
529# while we're here, let's just handle how to back up our
530# checksummed files
531
532$(GARCHIVEDIR)/%: $(GARCHIVEDIR)
533        @if [ -h $(DOWNLOADDIR)/$* ]; then :; else \
534                gcp -Lr $(DOWNLOADDIR)/$* $@; \
535        fi
536
537
538#################### EXTRACT RULES ####################
539
540TAR_ARGS = --no-same-owner
541
542# rule to extract uncompressed tarballs
543tar-extract-%:
544        @echo " ==> Extracting $(DOWNLOADDIR)/$*"
545        @gtar $(TAR_ARGS) -xf $(DOWNLOADDIR)/$* -C $(EXTRACTDIR)
546        @$(MAKECOOKIE)
547
548# rule to extract files with tar xzf
549tar-gz-extract-%:
550        @echo " ==> Extracting $(DOWNLOADDIR)/$*"
551        @gzip -dc $(DOWNLOADDIR)/$* | gtar $(TAR_ARGS) -xf - -C $(EXTRACTDIR)
552        @$(MAKECOOKIE)
553
554# rule to extract files with tar and bzip
555tar-bz-extract-%:
556        @echo " ==> Extracting $(DOWNLOADDIR)/$*"
557        @bzip2 -dc $(DOWNLOADDIR)/$* | gtar $(TAR_ARGS) -xf - -C $(EXTRACTDIR)
558        @$(MAKECOOKIE)
559
560# rule to extract files with tar and xz
561tar-xz-extract-%:
562        @echo " ==> Extracting $(DOWNLOADDIR)/$*"
563        @xz -dc $(DOWNLOADDIR)/$* | gtar $(TAR_ARGS) -xf - -C $(EXTRACTDIR)
564        @$(MAKECOOKIE)
565
566# rule to extract files with tar and lz
567tar-lz-extract-%:
568        @echo " ==> Extracting $(DOWNLOADDIR)/$*"
569        @lzip -dc $(DOWNLOADDIR)/$* | gtar $(TAR_ARGS) -xf - -C $(EXTRACTDIR)
570        @$(MAKECOOKIE)
571
572# rule to extract files with tar and lzma
573tar-lzma-extract-%:
574        @echo " ==> Extracting $(DOWNLOADDIR)/$*"
575        @lzma -dc $(DOWNLOADDIR)/$* | gtar $(TAR_ARGS) -xf - -C $(EXTRACTDIR)
576        @$(MAKECOOKIE)
577
578# extract compressed single files
579gz-extract-%:
580        @echo " ==> Decompressing $(DOWNLOADDIR)/$*"
581        @cp $(DOWNLOADDIR)/$* $(WORKDIR)/
582        @gzip -d $(WORKDIR)/$*
583        @$(MAKECOOKIE)
584
585gz-extract-%:
586        @echo " ==> Decompressing $(DOWNLOADDIR)/$*"
587        @cp $(DOWNLOADDIR)/$* $(WORKDIR)/
588        @gzip -d $(WORKDIR)/$*
589        @$(MAKECOOKIE)
590
591xz-extract-%:
592        @echo " ==> Decompressing $(DOWNLOADDIR)/$*"
593        @cp $(DOWNLOADDIR)/$* $(WORKDIR)/
594        @xz -d $(WORKDIR)/$*
595        @$(MAKECOOKIE)
596
597lz-extract-%:
598        @echo " ==> Decompressing $(DOWNLOADDIR)/$*"
599        @cp $(DOWNLOADDIR)/$* $(WORKDIR)/
600        @lzip -d $(WORKDIR)/$*
601        @$(MAKECOOKIE)
602
603lzma-extract-%:
604        @echo " ==> Decompressing $(DOWNLOADDIR)/$*"
605        @cp $(DOWNLOADDIR)/$* $(WORKDIR)/
606        @lzma -d $(WORKDIR)/$*
607        @$(MAKECOOKIE)
608
609# extra dependency rule for git repos, that will allow the user
610# to supply an alternate target at their discretion
611git-extract-%:
612        @echo " ===> Extracting Git Repo $(DOWNLOADDIR)/$* (Treeish: $(call GIT_TREEISH,$*))"
613        git --bare archive --prefix=$(NAME)-$(VERSION)/ --remote=file://$(abspath $(DOWNLOADDIR))/$*/ $(call GIT_TREEISH,$*) | gtar -xf - -C $(EXTRACTDIR)
614        @$(MAKECOOKIE)
615
616# rule to extract files with unzip
617zip-extract-%:
618        @echo " ==> Extracting $(DOWNLOADDIR)/$*"
619        @unzip $(DOWNLOADDIR)/$* -d $(EXTRACTDIR)
620        @$(MAKECOOKIE)
621
622# this is a null extract rule for files which are constant and
623# unchanged (not archives)
624cp-extract-%:
625        @echo " ==> Copying $(DOWNLOADDIR)/$*"
626        @# Make sure to keep symlinks and don't traverse recursive ones
627        @(cd $(DOWNLOADDIR); tar cf - $*) | (cd $(WORKDIR); tar xf -)
628        @$(MAKECOOKIE)
629
630#gets the meat of a .deb into $(WORKSRC)
631deb-bin-extract-%:
632        @echo " ==> Extracting $(DOWNLOADDIR)/$*"
633        @ar x $(DOWNLOADDIR)/$*
634        @rm debian-binary && \
635                mv *.tar.gz $(DOWNLOADDIR) && \
636                        mkdir $(WORKSRC) && \
637                                gtar $(TAR_ARGS) -xvz -C $(WORKSRC) \
638                                        -f $(DOWNLOADDIR)/data.tar.gz
639        @$(MAKECOOKIE)
640
641### EXTRACT FILE TYPE MAPPINGS ###
642# These rules specify which of the above extract action rules to use for a
643# given file extension.  Often support for a given extract type can be handled
644# by simply adding a rule here.
645
646extract-archive-%.tar: tar-extract-%.tar
647        @$(MAKECOOKIE)
648
649extract-archive-%.tar.gz: tar-gz-extract-%.tar.gz
650        @$(MAKECOOKIE)
651
652extract-archive-%.tar.Z: tar-gz-extract-%.tar.Z
653        @$(MAKECOOKIE)
654
655extract-archive-%.tgz: tar-gz-extract-%.tgz
656        @$(MAKECOOKIE)
657
658extract-archive-%.taz: tar-gz-extract-%.taz
659        @$(MAKECOOKIE)
660
661extract-archive-%.tar.bz: tar-bz-extract-%.tar.bz
662        @$(MAKECOOKIE)
663
664extract-archive-%.tar.bz2: tar-bz-extract-%.tar.bz2
665        @$(MAKECOOKIE)
666
667extract-archive-%.tbz: tar-bz-extract-%.tbz
668        @$(MAKECOOKIE)
669
670extract-archive-%.tar.xz: tar-xz-extract-%.tar.xz
671        @$(MAKECOOKIE)
672
673extract-archive-%.tar.lz: tar-lz-extract-%.tar.lz
674        @$(MAKECOOKIE)
675
676extract-archive-%.tar.lzma: tar-lzma-extract-%.tar.lzma
677        @$(MAKECOOKIE)
678
679extract-archive-%.zip: zip-extract-%.zip
680        @$(MAKECOOKIE)
681
682extract-archive-%.ZIP: zip-extract-%.ZIP
683        @$(MAKECOOKIE)
684
685extract-archive-%.deb: deb-bin-extract-%.deb
686        @$(MAKECOOKIE)
687
688extract-archive-%.gz: gz-extract-%.gz
689        @$(MAKECOOKIE)
690
691extract-archive-%.bz2: bz-extract-%.bz2
692        @$(MAKECOOKIE)
693
694extract-archive-%.xz: xz-extract-%.xz
695        @$(MAKECOOKIE)
696
697extract-archive-%.lz: lz-extract-%.lz
698        @$(MAKECOOKIE)
699
700extract-archive-%.lzma: lzma-extract-%.lzma
701        @$(MAKECOOKIE)
702
703extract-archive-%.git: git-extract-%.git
704        @$(MAKECOOKIE)
705
706extract-copy-%: cp-extract-%
707        @$(MAKECOOKIE)
708
709# anything we don't know about, we just assume is already
710# uncompressed and unarchived in plain format
711extract-archive-%: cp-extract-%
712        @$(MAKECOOKIE)
713
714#################### PATCH RULES ####################
715
716PATCHDIR ?= $(WORKSRC)
717PATCHDIRLEVEL ?= 1
718PATCHDIRFUZZ ?= 2
719GARPATCH = gpatch -d$(PATCHDIR) -p$(PATCHDIRLEVEL) -F$(PATCHDIRFUZZ)
720BASEWORKSRC = $(shell basename $(WORKSRC))
721
722# apply xzipped patches
723xz-patch-%:
724        @echo " ==> Applying patch $(DOWNLOADDIR)/$*"
725        @xz -dc $(DOWNLOADDIR)/$* | $(GARPATCH)
726        @( if [ -z "$(NOGITPATCH)" ]; then \
727                cd $(WORKSRC); git add -A; \
728                git commit -am "old xz-style patch: $*"; \
729           fi )
730        @$(MAKECOOKIE)
731
732# apply bzipped patches
733bz-patch-%:
734        @echo " ==> Applying patch $(DOWNLOADDIR)/$*"
735        @bzip2 -dc $(DOWNLOADDIR)/$* | $(GARPATCH)
736        @( if [ -z "$(NOGITPATCH)" ]; then \
737                cd $(WORKSRC); git add -A; \
738                git commit -am "old bz-style patch: $*"; \
739           fi )
740        @$(MAKECOOKIE)
741
742# apply gzipped patches
743gz-patch-%:
744        @echo " ==> Applying patch $(DOWNLOADDIR)/$*"
745        @gzip -dc $(DOWNLOADDIR)/$* | $(GARPATCH)
746        @( if [ -z "$(NOGITPATCH)" ]; then \
747                cd $(WORKSRC); git add -A; \
748                git commit -am "old gz-style patch: $*"; \
749           fi )
750        @$(MAKECOOKIE)
751
752# apply normal patches (git format-patch output or old-style diff -r)
753normal-patch-%:
754        @echo " ==> Applying patch $(DOWNLOADDIR)/$*"
755        @( if ggrep -q 'diff --git' $(abspath $(DOWNLOADDIR)/$*); then \
756                if [ -z "$(NOGITPATCH)" ]; then \
757                        cd $(WORKSRC);\
758                        git am --ignore-space-change --ignore-whitespace $(abspath $(DOWNLOADDIR)/$*); \
759                else \
760                        $(GARPATCH) < $(DOWNLOADDIR)/$*; \
761                fi; \
762          else \
763                echo Adding old-style patch...; \
764                $(GARPATCH) < $(DOWNLOADDIR)/$*; \
765                if [ -z "$(NOGITPATCH)" ]; then \
766                        cd $(WORKSRC); \
767                        git add -A; \
768                        git commit -am "old style patch: $*"; \
769                fi; \
770          fi )
771        @$(MAKECOOKIE)
772
773### PATCH FILE TYPE MAPPINGS ###
774# These rules specify which of the above patch action rules to use for a given
775# file extension.  Often support for a given patch format can be handled by
776# simply adding a rule here.
777
778patch-extract-%.xz: xz-patch-%.xz
779        @$(MAKECOOKIE)
780
781patch-extract-%.bz: bz-patch-%.bz
782        @$(MAKECOOKIE)
783
784patch-extract-%.bz2: bz-patch-%.bz2
785        @$(MAKECOOKIE)
786
787patch-extract-%.gz: gz-patch-%.gz
788        @$(MAKECOOKIE)
789
790patch-extract-%.Z: gz-patch-%.Z
791        @$(MAKECOOKIE)
792
793patch-extract-%.diff: normal-patch-%.diff
794        @$(MAKECOOKIE)
795
796patch-extract-%.patch: normal-patch-%.patch
797        @$(MAKECOOKIE)
798
799patch-extract-%: normal-patch-%
800        @$(MAKECOOKIE)
801
802#################### CONFIGURE RULES ####################
803
804TMP_DIRPATHS = --prefix=$(prefix) --exec_prefix=$(exec_prefix) --bindir=$(bindir) --sbindir=$(sbindir) --libexecdir=$(libexecdir) --datadir=$(datadir) --sysconfdir=$(sysconfdir) --sharedstatedir=$(sharedstatedir) --localstatedir=$(localstatedir) --libdir=$(libdir) --infodir=$(infodir) --lispdir=$(lispdir) --includedir=$(includedir) --mandir=$(mandir)
805
806NODIRPATHS += --lispdir
807
808DIRPATHS = $(filter-out $(addsuffix %,$(NODIRPATHS)), $(TMP_DIRPATHS))
809
810CONFIGURE_ARGS ?= $(DIRPATHS) $(EXTRA_CONFIGURE_ARGS)
811
812# configure a package that has an autoconf-style configure
813# script.
814configure-%/configure:
815        @echo " ==> Running configure in $*"
816        cd $* && $(CONFIGURE_ENV) ./configure $(CONFIGURE_ARGS)
817        @$(MAKECOOKIE)
818
819configure-%/autogen.sh:
820        @echo " ==> Running autogen.sh in $*"
821        @cd $* && $(CONFIGURE_ENV) ./autogen.sh $(CONFIGURE_ARGS)
822        @$(MAKECOOKIE)
823
824# configure a package that uses imake
825# FIXME: untested and likely not the right way to handle the
826# arguments
827configure-%/Imakefile:
828        @echo " ==> Running xmkmf in $*"
829        @cd $* && $(CONFIGURE_ENV) xmkmf $(CONFIGURE_ARGS)
830        @$(MAKECOOKIE)
831
832configure-%/setup.rb:
833        @echo " ==> Running setup.rb config in $*"
834        @( cd $* ; $(CONFIGURE_ENV) ruby ./setup.rb config $(CONFIGURE_ARGS) )
835        @$(MAKECOOKIE)
836
837# WAF build, for details see http://code.google.com/p/waf/
838configure-%/waf:
839        @echo " ==> Running waf configure in $*"
840        cd $* && $(CONFIGURE_ENV) ./waf configure $(CONFIGURE_ARGS)
841        @$(MAKECOOKIE)
842
843#################### BUILD RULES ####################
844
845# build from a standard gnu-style makefile's default rule.
846build-%/Makefile:
847        @echo " ==> Running make in $*"
848        $(BUILD_ENV) $(MAKE) $(PARALLELMFLAGS) $(foreach TTT,$(BUILD_OVERRIDE_VARS),$(TTT)="$(BUILD_OVERRIDE_VAR_$(TTT))") $(foreach TTT,$(BUILD_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(BUILD_ARGS)
849        @$(MAKECOOKIE)
850
851build-%/makefile:
852        @echo " ==> Running make in $*"
853        @$(BUILD_ENV) $(MAKE) $(PARALLELMFLAGS) $(foreach TTT,$(BUILD_OVERRIDE_VARS),$(TTT)="$(BUILD_OVERRIDE_VAR_$(TTT))") $(foreach TTT,$(BUILD_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(BUILD_ARGS)
854        @$(MAKECOOKIE)
855
856build-%/GNUmakefile:
857        @echo " ==> Running make in $*"
858        @$(BUILD_ENV) $(MAKE) $(PARALLELMFLAGS) $(foreach TTT,$(BUILD_OVERRIDE_VARS),$(TTT)="$(BUILD_OVERRIDE_VAR_$(TTT))")  $(foreach TTT,$(BUILD_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(BUILD_ARGS)
859        @$(MAKECOOKIE)
860
861build-%/Jamfile:
862        @echo " ==> Running bjam in $*"
863        @( cd $* ; $(BUILD_ENV) bjam $(JAMFLAGS) $(BUILD_ARGS) )
864        @$(MAKECOOKIE)
865
866# Ruby makefiles
867build-%/Rakefile:
868        @echo " ==> Running rake in $*"
869        @( cd $* ; $(BUILD_ENV) rake $(RAKEFLAGS) $(BUILD_ARGS) )
870        @$(MAKECOOKIE)
871
872build-%/rakefile:
873        @echo " ==> Running rake in $*"
874        @( cd $* ; $(BUILD_ENV) rake $(RAKEFLAGS) $(BUILD_ARGS) )
875        @$(MAKECOOKIE)
876
877build-%/setup.rb:
878        @echo " ==> Running setup.rb setup in $*"
879        @( cd $* ; $(BUILD_ENV) ruby ./setup.rb setup $(BUILD_ARGS) )
880        @$(MAKECOOKIE)
881
882# WAF build, for details see http://code.google.com/p/waf/
883build-%/waf:
884        @echo " ==> Running waf build in $*"
885        @$(cd $* ; (BUILD_ENV) ./waf build $(BUILD_ARGS) )
886        @$(MAKECOOKIE)
887
888# This can be: build, build_py, build_ext, build_clib, build_scripts
889# See setup.py --help-commands for details
890PYBUILD_CMD ?= build
891build-%/setup.py:
892        @echo " ==> Running setup.py $(PYBUILD_TYPE) in $*"
893        @( cd $* ; $(BUILD_ENV) python ./setup.py $(PYBUILD_CMD) $(BUILD_ARGS) )
894        @$(MAKECOOKIE)
895
896#################### CLEAN RULES ####################
897
898CLEAN_ARGS ?= clean
899 
900# build from a standard gnu-style makefile's default rule.
901clean-%/Makefile:
902        @echo " ==> Running clean in $*"
903        @$(BUILD_ENV) $(MAKE) $(foreach TTT,$(BUILD_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(CLEAN_ARGS)
904        @rm -f $(COOKIEDIR)/build-$*
905
906clean-%/makefile:
907        @echo " ==> Running clean in $*"
908        @$(BUILD_ENV) $(MAKE) $(foreach TTT,$(BUILD_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(CLEAN_ARGS)
909        @rm -f $(COOKIEDIR)/build-$*
910
911clean-%/GNUmakefile:
912        @echo " ==> Running clean in $*"
913        @$(BUILD_ENV) $(MAKE) $(foreach TTT,$(BUILD_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(CLEAN_ARGS)
914        @rm -f $(COOKIEDIR)/build-$*
915
916clean-%/Jamfile:
917        $(error *** Don't know how to clean Jamfiles)
918
919clean-%/Rakefile:
920        $(error *** Don't know how to clean Rakefiles)
921
922clean-%/rakefile:
923        $(error *** Don't know how to clean Rakefiles)
924
925clean-%/setup.rb:
926        $(error *** Don't know how to clean Ruby setups)
927
928clean-%/setup.py:
929        $(error *** Don't know how to clean Python builds)
930
931#################### TEST RULES ####################
932
933TEST_TARGET ?= check
934
935# Run tests on pre-built sources
936test-%/Makefile:
937        @echo " ==> Running make $(TEST_TARGET) in $*"
938        $(TEST_ENV) $(MAKE) $(foreach TTT,$(TEST_OVERRIDE_VARS),$(TTT)="$(TEST_OVERRIDE_VAR_$(TTT))") $(foreach TTT,$(TEST_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(TEST_ARGS) $(TEST_TARGET)
939        @$(MAKECOOKIE)
940
941test-%/makefile:
942        @echo " ==> Running make $(TEST_TARGET) in $*"
943        @$(TEST_ENV) $(MAKE) $(foreach TTT,$(TEST_OVERRIDE_VARS),$(TTT)="$(TEST_OVERRIDE_VAR_$(TTT))") $(foreach TTT,$(TEST_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(TEST_ARGS) $(TEST_TARGET)
944        @$(MAKECOOKIE)
945
946test-%/GNUmakefile:
947        @echo " ==> Running make $(TEST_TARGET) in $*"
948        @$(TEST_ENV) $(MAKE) $(foreach TTT,$(TEST_OVERRIDE_VARS),$(TTT)="$(TEST_OVERRIDE_VAR_$(TTT))") $(foreach TTT,$(TEST_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(TEST_ARGS) $(TEST_TARGET)
949        @$(MAKECOOKIE)
950
951# Ruby makefiles
952test-%/Rakefile:
953        @echo " ==> Running rake $(TEST_TARGET) in $*"
954        @( cd $* ; $(TEST_ENV) rake $(RAKEFLAGS) $(TEST_ARGS) $(TEST_TARGET) )
955        @$(MAKECOOKIE)
956
957test-%/rakefile:
958        @echo " ==> Running rake $(TEST_TARGET) in $*"
959        @( cd $* ; $(TEST_ENV) rake $(RAKEFLAGS) $(TEST_ARGS) $(TEST_TARGET) )
960        @$(MAKECOOKIE)
961
962test-%/setup.py:
963        @echo " ==> Running setup.py test in $*"
964        @( cd $* ; $(TEST_ENV) python ./setup.py test $(TEST_ARGS) )
965        @$(MAKECOOKIE)
966
967################# INSTALL RULES ####################
968
969# just run make install and hope for the best.
970install-%/Makefile:
971        @echo " ==> Running make install in $*"
972        @$(INSTALL_ENV) $(MAKE) DESTDIR=$(DESTDIR) $(foreach TTT,$(INSTALL_OVERRIDE_VARS),$(TTT)="$(INSTALL_OVERRIDE_VAR_$(TTT))") $(foreach TTT,$(INSTALL_OVERRIDE_DIRS),$(TTT)="$(DESTDIR)$($(TTT))") -C $* $(INSTALL_ARGS) install
973        @$(MAKECOOKIE)
974
975install-%/makefile:
976        @echo " ==> Running make install in $*"
977        @$(INSTALL_ENV) $(MAKE) DESTDIR=$(DESTDIR) $(foreach TTT,$(INSTALL_OVERRIDE_VARS),$(TTT)="$(INSTALL_OVERRIDE_VAR_$(TTT))") $(foreach TTT,$(INSTALL_OVERRIDE_DIRS),$(TTT)="$(DESTDIR)$($(TTT))") -C $* $(INSTALL_ARGS) install
978        @$(MAKECOOKIE)
979
980install-%/GNUmakefile:
981        @echo " ==> Running make install in $*"
982        @$(INSTALL_ENV) $(MAKE) DESTDIR=$(DESTDIR) $(foreach TTT,$(INSTALL_OVERRIDE_VARS),$(TTT)="$(INSTALL_OVERRIDE_VAR_$(TTT))") $(foreach TTT,$(INSTALL_OVERRIDE_DIRS),$(TTT)="$(DESTDIR)$($(TTT))") -C $* $(INSTALL_ARGS) install
983        @$(MAKECOOKIE)
984
985# Ruby makefiles
986install-%/Rakefile:
987        @echo " ==> Running rake install in $*"
988        @( cd $* ; $(INSTALL_ENV) rake $(RAKEFLAGS) $(INSTALL_ARGS) )
989        @$(MAKECOOKIE)
990
991install-%/rakefile:
992        @echo " ==> Running rake install in $*"
993        @( cd $* ; $(INSTALL_ENV) rake $(RAKEFLAGS) $(INSTALL_ARGS) )
994        @$(MAKECOOKIE)
995
996install-%/setup.rb:
997        @echo " ==> Running setup.rb install in $*"
998        @( cd $* ; $(INSTALL_ENV) ruby ./setup.rb install --prefix=$(DESTDIR) )
999        @$(MAKECOOKIE)
1000
1001# WAF build, for details see http://code.google.com/p/waf/
1002install-%/waf:
1003        @echo " ==> Running waf install in $*"
1004        @$(cd $* ; (INSTALL_ENV) ./waf install $(INSTALL_ARGS) )
1005        @$(MAKECOOKIE)
1006
1007# This can be: install, install_lib, install_headers, install_scripts,
1008# or install_data.  See setup.py --help-commands for details.
1009PYINSTALL_CMD ?= install
1010install-%/setup.py:
1011        @echo " ==> Running setup.py $(PYINSTALL_CMD) in $*"
1012        @( cd $* ; $(INSTALL_ENV) python ./setup.py $(PYINSTALL_CMD) $(INSTALL_ARGS) )
1013        @$(MAKECOOKIE)
1014
1015# pkg-config scripts
1016install-%-config:
1017        mkdir -p $(STAGINGDIR)/$(NAME)
1018        cp -f $(DESTDIR)$(bindir)/$*-config $(STAGINGDIR)/$(NAME)/
1019        $(MAKECOOKIE)
1020
1021######################################
1022# Use a manifest file of the format:
1023# src:dest[:mode[:owner[:group]]]
1024#   as in...
1025# ${WORKSRC}/nwall:${bindir}/nwall:2755:root:tty
1026# ${WORKSRC}/src/foo:${sharedstatedir}/foo
1027# ${WORKSRC}/yoink:${sysconfdir}/yoink:0600
1028
1029# Okay, so for the benefit of future generations, this is how it
1030# works:
1031#
1032# First of all, we have this file with colon-separated lines.
1033# The $(shell cat foo) routine turns it into a space-separated
1034# list of words.  The foreach iterates over this list, putting a
1035# colon-separated record in $(ZORCH) on each pass through.
1036#
1037# Next, we have the macro $(MANIFEST_LINE), which splits a record
1038# into a space-separated list, and $(MANIFEST_SIZE), which
1039# determines how many elements are in such a list.  These are
1040# purely for convenience, and could be inserted inline if need
1041# be.
1042MANIFEST_LINE = $(subst :, ,$(ZORCH))
1043MANIFEST_SIZE = $(words $(MANIFEST_LINE))
1044
1045# So the install command takes a variable number of parameters,
1046# and our records have from two to five elements.  Gmake can't do
1047# any sort of arithmetic, so we can't do any really intelligent
1048# indexing into the list of parameters.
1049#
1050# Since the last three elements of the $(MANIFEST_LINE) are what
1051# we're interested in, we make a parallel list with the parameter
1052# switch text (note the dummy elements at the beginning):
1053MANIFEST_FLAGS = notused notused --mode= --owner= --group=
1054
1055# The following environment variables are set before the
1056# installation boogaloo begins.  This ensures that WORKSRC is
1057# available to the manifest and that all of the location
1058# variables are suitable for *installation* (that is, using
1059# DESTDIR)
1060
1061MANIFEST_ENV += WORKSRC=$(WORKSRC)
1062# This was part of the "implicit DESTDIR" regime.  However:
1063# http://gar.lnx-bbc.org/wiki/ImplicitDestdirConsideredHarmful
1064#MANIFEST_ENV += $(foreach TTT,prefix exec_prefix bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir infodir lispdir includedir mandir,$(TTT)=$(DESTDIR)$($(TTT)))
1065
1066# ...and then we join a slice of it with the corresponding slice
1067# of the $(MANIFEST_LINE), starting at 3 and going to
1068# $(MANIFEST_SIZE).  That's where all the real magic happens,
1069# right there!
1070#
1071# following that, we just splat elements one and two of
1072# $(MANIFEST_LINE) on the end, since they're the ones that are
1073# always there.  Slap a semicolon on the end, and you've got a
1074# completed iteration through the foreach!  Beaujolais!
1075
1076# FIXME: using -D may not be the right thing to do!
1077install-$(MANIFEST_FILE):
1078        @echo " ==> Installing from $(MANIFEST_FILE)"
1079        $(MANIFEST_ENV) ; $(foreach ZORCH,$(shell cat $(MANIFEST_FILE)), ginstall -Dc $(join $(wordlist 3,$(MANIFEST_SIZE),$(MANIFEST_FLAGS)),$(wordlist 3,$(MANIFEST_SIZE),$(MANIFEST_LINE))) $(word 1,$(MANIFEST_LINE)) $(word 2,$(MANIFEST_LINE)) ;)
1080        @$(MAKECOOKIE)
1081
1082#################### DEPENDENCY RULES ####################
1083
1084# These two lines are here to grandfather in all the packages that use
1085# BUILDDEPS
1086IMGDEPS += build
1087build_DEPENDS = $(BUILDDEPS)
1088
1089# Standard deps install into the standard install dir.  For the
1090# BBC, we set the includedir to the build tree and the libdir to
1091# the install tree.  Most dependencies work this way.
1092
1093$(GARDIR)/%/$(COOKIEDIR)/install:
1094        @echo ' ==> Building $* as a dependency'
1095        @$(MAKE) -C $(GARDIR)/$* install DESTIMG=$(DESTIMG)
1096
1097# builddeps need to have everything put in the build DESTIMG
1098#$(GARDIR)/%/$(COOKIEROOTDIR)/build.d/install:
1099#       @echo ' ==> Building $* as a build dependency'
1100#       @$(MAKE) -C $(GARDIR)/$* install        DESTIMG=build
1101
1102# Source Deps grab the source code for another package
1103# XXX: nobody uses this, but it should really be more like
1104# $(GARDIR)/%/cookies/patch:
1105srcdep-$(GARDIR)/%:
1106        @echo ' ==> Grabbing source for $* as a dependency'
1107        @$(MAKE) -C $(GARDIR)/$* patch-p extract-p > /dev/null 2>&1 || \
1108         $(MAKE) -C $(GARDIR)/$* patch
1109
1110# Image deps create dependencies on package installations in
1111# images other than the current package's DESTIMG.
1112IMGDEP_TARGETS = $(foreach TTT,$($*_DEPENDS),$(subst xyzzy,$(TTT),$(GARDIR)/xyzzy/$(COOKIEROOTDIR)/$*.d/install))
1113imgdep-%:
1114        @test -z "$(strip $(IMGDEP_TARGETS))" || $(MAKE) DESTIMG="$*" $(IMGDEP_TARGETS)
1115
1116# Igor's info and man gzipper rule
1117gzip-info-man: gzip-info gzip-man
1118
1119gzip-info:
1120        gfind $(DESTDIR) -type f -iname *.info* -not -iname *.gz | \
1121                gxargs -r gzip --force
1122
1123gzip-man:
1124        gfind $(DESTDIR) -type f -iname *.[1-8] -size +2 -print | \
1125                gxargs -r gzip --force
1126
1127compile-elisp:
1128        @(for d in $(ELISP_DIRS); do \
1129                echo " ===> Compiling .el files in $$d"; \
1130                cd $(PKGROOT)/$$d; \
1131                for f in `find . -name "*el"`; do \
1132                        bf=`basename $$f`; \
1133                        bd=`dirname $$f`; \
1134                        cd $$bd; \
1135                        emacs -L $(PKGROOT)/$$d -L $(PKGROOT)/$$d/$$bd $(EXTRA_EMACS_ARGS) -batch -f batch-byte-compile "$$bf"; \
1136                        cd $(PKGROOT)/$$d; \
1137                done; \
1138        done)
1139
1140include $(addprefix $(GARDIR)/,$(EXTRA_LIBS))
1141
1142# Mmm, yesssss.  cookies my preciousssss!  Mmm, yes downloads it
1143# is!  We mustn't have nasty little gmakeses deleting our
1144# precious cookieses now must we?
1145.PRECIOUS: $(DOWNLOADDIR)/% $(COOKIEDIR)/% $(FILEDIR)/%
Note: See TracBrowser for help on using the browser.