ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ozone/mgar/gar/gar.mk
Revision: 1
Committed: Sat Jun 20 14:58:51 2026 UTC (4 weeks, 3 days ago) by operz
File size: 44716 byte(s)
Log Message:
Initial import of OZSW mgar build tree

File Contents

# Content
1 #
2 # $Id: gar.mk 25997 2016-10-22 07:45:48Z cgrzemba $
3 #
4 # Copyright (C) 2001 Nick Moffitt
5 #
6 # Redistribution and/or use, with or without modification, is
7 # permitted. This software is without warranty of any kind. The
8 # author(s) shall not be liable in the event that use of the
9 # software causes damage.
10
11 # Comment this out to make much verbosity
12 #.SILENT:
13
14 md5sum ?= $(if $(filter no%,$(shell which md5sum)),gmd5sum,$(shell which md5sum))
15
16 ifneq ($(abspath /),/)
17 $(error Your version of 'make' is too old: $(MAKE_VERSION). Please make sure you are using at least 3.81)
18 endif
19
20 $(if $(GARNAME),$(error The deprecated variable 'GARNAME' is defined, please replace it with 'NAME'))
21 $(if $(GARVERSION),$(error The deprecated variable 'GARVERSION' is defined, please replace it with 'VERSION'))
22
23 # $(GARDIR) is pre-set by the top-level category.mk
24 GARBIN = $(GARDIR)/bin
25
26 DIRSTODOTS = $(subst . /,./,$(patsubst %,/..,$(subst /, ,/$(1))))
27 ROOTFROMDEST = $(call DIRSTODOTS,$(DESTDIR))
28 MAKEPATH = $(shell echo $(1) | perl -lne 'print join(":", split)')
29 TOLOWER = $(shell echo $(1) | tr '[A-Z]' '[a-z]')
30
31 # If you call this the value is only evaluated the first time
32 # Usage: $(call SETONCE,A,MyComplexVariableEvaluatedOnlyOnce)
33 SETONCE = $(eval $(1) ?= $(2))
34
35 #meant to take a git url and return just the $proj.git part
36 GITPROJ = $(lastword $(subst /, ,$(1)))
37
38 # GAR uses PARALLELMFLAGS to propagate make options (judging by the name, mainly
39 # intended for -j). Options are determined via MFLAGS which also contains other
40 # options, thus we need to filter harmful ones. e.g. -I breaks upstream builds
41 # that use non-gnu make (Fatal error: Unknown option `-I'). Info on M*FLAGS:
42 # http://www.gnu.org/s/hello/manual/make/Options_002fRecursion.html
43 # Strip -I paths and jobserver references (--jobserver-fds=R,W) from MFLAGS.
44 # The jobserver fds are only valid in the parent make process; passing them to
45 # a child make that has MAKEFLAGS= (cleared) causes GNU Make 3.81 to see bare
46 # -j (unlimited) when the fds are unreadable, spawning runaway parallel jobs.
47 PARALLELMFLAGS ?= $(shell echo $(MFLAGS) | gsed 's/--jobserver-fds=[^ ]*//g; s,-I [^ ]*,,g; s/ -j\b//g' | tr -s ' ' | gsed 's/^[[:space:]]*-[[:space:]]*$$//')
48 export PARALLELMFLAGS
49
50 DISTNAME ?= $(NAME)-$(VERSION)
51
52 DYNSCRIPTS := $(foreach PKG,$(SPKG_SPECS),$(foreach SCR,$(ADMSCRIPTS),$(if $(value $(PKG)_$(SCR)), $(PKG).$(SCR))))
53 _LOCALFILES = $(notdir $(wildcard files/*))
54 _NOCHECKSUM += $(DYNSCRIPTS) $(_LOCALFILES) $(foreach R,$(GIT_REPOS),$(call GITPROJ,$(R))) $(foreach R,$(HG_REPOS),$(call GITPROJ,$(R).hg)) $(_EXTRA_GAR_NOCHECKSUM)
55
56 DISTFILES += $(_EXTRA_GAR_DISTFILES)
57
58 # Allow overriding of only specific components of ALLFILES by clearing e. g. 'ALLFILES_DYNSCRIPTS = '
59 ALLFILES_DISTFILES ?= $(DISTFILES)
60 ALLFILES_PATCHFILES ?= $(PATCHFILES) $(foreach M,$(MODULATIONS),$(PATCHFILES_$M))
61 ALLFILES_DYNSCRIPTS ?= $(DYNSCRIPTS)
62 ALLFILES_GIT_REPOS ?= $(foreach R,$(GIT_REPOS),$(call GITPROJ,$(R)))
63 ALLFILES_HG_REPOS ?= $(foreach R,$(HG_REPOS),$(call GITPROJ,$(R).hg))
64 ALLFILES ?= $(sort $(ALLFILES_DISTFILES) $(ALLFILES_PATCHFILES) $(ALLFILES_DYNSCRIPTS) $(ALLFILES_GIT_REPOS) $(ALLFILES_HG_REPOS) $(EXTRA_ALLFILES) $(_EXTRA_GAR_ALLFILES))
65
66 ifeq ($(MAKE_INSTALL_DIRS),1)
67 INSTALL_DIRS = $(addprefix $(DESTDIR),$(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libexecdir) $(datadir) $(sysconfdir) $(sharedstatedir) $(localstatedir) $(libdir) $(infodir) $(lispdir) $(includedir) $(mandir) $(foreach NUM,1 2 3 4 5 6 7 8, $(mandir)/man$(NUM)) $(sourcedir))
68 else
69 INSTALL_DIRS =
70 endif
71
72 # For rules that do nothing, display what dependencies they
73 # successfully completed
74 #DONADA = @echo " [$@] complete. Finished rules: $+"
75 #DONADA = @touch $(COOKIEDIR)/$@; echo " [$@] complete for $(NAME)."
76 COOKIEFILE = $(COOKIEDIR)/$(patsubst $(COOKIEDIR)/%,%,$1)
77 DONADA = @touch $(call COOKIEFILE,$@); echo " [$@] complete for $(NAME)."
78
79
80 # TODO: write a stub rule to print out the name of a rule when it
81 # *does* do something, and handle indentation intelligently.
82
83 # Default sequence for "all" is: fetch checksum extract patch configure build
84 all: build
85
86 # include the configuration file to override any of these variables
87 include $(GARDIR)/gar.conf.mk
88
89 # ========================= MODULATIONS ========================
90
91 # The default is to modulate over ISAs
92 MODULATORS ?= ISA $(_CATEGORY_MODULATORS) $(EXTRA_MODULATORS) $(EXTRA_MODULATORS_$(GARCH))
93 MODULATIONS_ISA = $(NEEDED_ISAS)
94
95 tolower = $(shell echo $(1) | tr '[A-Z]' '[a-z]')
96 expand_modulator_1 = $(addprefix $(call tolower,$(1))-,$(MODULATIONS_$(1)))
97 # This expands to the list of all modulators with their respective modulations
98 modulations = $(if $(word 2,$(1)),\
99 $(foreach P,$(call expand_modulator_1,$(firstword $(1))),\
100 $(addprefix $(P)-,$(call modulations,$(wordlist 2,$(words $(1)),$(1))))\
101 ),\
102 $(call expand_modulator_1,$(1)))
103
104 MODULATIONS ?= $(filter-out $(SKIP_MODULATIONS),$(strip $(call modulations,$(strip $(MODULATORS)))))
105
106 include $(GARDIR)/gar.lib.mk
107 include $(GARDIR)/gar.pkg.mk
108
109 # _modulate(ISA STATIC,,,)
110 # -> _modulate2(STATIC,isa-i386,ISA,ISA=i386)
111 # -> _modulate2(,,isa-i386-static-yes,ISA STATIC,ISA=i386 STATIC=yes)
112 # -> xxx-isa-i386-static-yes: @gmake xxx ISA=i386 STATIC=yes
113 # -> _modulate2(,,isa-i386-static-no,ISA STATIC,ISA=i386 STATIC=no)
114 # -> xxx-isa-i386-static-no: @gmake xxx ISA=i386 STATIC=no
115 # -> _modulate2(STATIC,isa-amd64,ISA,ISA=amd64)
116 # -> _modulate2(,,isa-amd64-static-yes,ISA STATIC,ISA=amd64 STATIC=yes)
117 # -> xxx-isa-amd64-static-yes: @gmake xxx ISA=amd64 STATIC=yes
118 # -> _modulate2(,,isa-amd64-static-no,ISA STATIC,ISA=amd64 STATIC=no)
119 # -> xxx-isa-amd64-static-no: @gmake xxx ISA=amd64 STATIC=no
120
121 define _modulate_target
122 $(1)-$(2):
123 @$(MAKE) MODULATION=$(2) $(3) $(1)-modulated
124 @# This is MAKECOOKIE expanded to use the name of the rule explicily as the rule has
125 @# not been evaluated yet. XXX: Use function _MAKECOOKIE for both
126 @mkdir -p $(COOKIEDIR)/$(dir $(1)-$(2)) && date >> $(COOKIEDIR)/$(1)-$(2)
127 @# The next line has intentionally been left blank to explicitly terminate this make rule
128
129 endef
130
131 define _modulate_target_nocookie
132 $(1)-$(2):
133 @$(MAKE) -s MODULATION=$(2) $(3) $(1)-modulated
134 @# The next line has intentionally been left blank to explicitly terminate this make rule
135
136 endef
137
138 # Heads up: Don't use MAKEFLAGS to propagate -I to remote GAR invocations as
139 # this will also make it visible to the build environment. Some software builds
140 # use hard-coded non-GNU make which then errs out on -I (unknown option).
141 define _modulate_merge
142 $(foreach ASSIGNMENT,$(3),
143 merge-$(2): $(ASSIGNMENT)
144 )
145 merge-$(2): BUILDHOST=$$(call modulation2host)
146 merge-$(2):
147 @echo "[===== Building modulation '$(2)' on host '$$(BUILDHOST)' =====]"
148 $$(if $$(and $$(BUILDHOST),$$(filter-out $$(THISHOST),$$(BUILDHOST))),\
149 $(SSH) $$(BUILDHOST) "PATH=$$(PATH) $(MAKE) -I $$(GARDIR) -C $$(CURDIR) $(if $(GAR_PLATFORM),GAR_PLATFORM=$(GAR_PLATFORM)) MODULATION=$(2) $(3) merge-modulated",\
150 $(MAKE) $(if $(GAR_PLATFORM),GAR_PLATFORM=$(GAR_PLATFORM)) MODULATION=$(2) $(3) merge-modulated\
151 )
152 @# The next line has intentionally been left blank to explicitly terminate this make rule
153
154 endef
155
156 define _modulate_do
157 $(call _modulate_target,extract,$(2),$(4))
158 $(call _modulate_target,patch,$(2),$(4))
159 $(call _modulate_target_nocookie,makepatch,$(2),$(4))
160 $(call _modulate_target,configure,$(2),$(4))
161 $(call _modulate_target_nocookie,reset-configure,$(2),$(4))
162 $(call _modulate_target,build,$(2),$(4))
163 $(call _modulate_target_nocookie,reset-build,$(2),$(4))
164 $(call _modulate_target,test,$(2),$(4))
165 $(call _modulate_target_nocookie,reset-test,$(2),$(4))
166 $(call _modulate_target,install,$(2),$(4))
167 $(call _modulate_target_nocookie,reset-install,$(2),$(4))
168 $(call _modulate_merge,,$(2),$(4))
169 $(call _modulate_target_nocookie,reset-merge,$(2),$(4))
170 $(call _modulate_target_nocookie,clean,$(2),$(4))
171 $(call _modulate_target_nocookie,_modenv,$(2),$(4))
172 endef
173
174 # This evaluates to the make rules for all modulations passed as first argument
175 # Usage: _modulate( <MODULATORS> )
176 define _modulate
177 $(foreach M,$(MODULATIONS_$(firstword $(1))),\
178 $(call _modulate2,\
179 $(wordlist 2,$(words $(1)),$(1)),\
180 $(call tolower,$(firstword $(1)))-$(M),\
181 $(firstword $(1)),\
182 $(firstword $(1))=$(M)\
183 )\
184 )
185 endef
186
187 # This is a helper for the recursive _modulate
188 define _modulate2
189 $(if $(strip $(1)),\
190 $(foreach M,$(MODULATIONS_$(firstword $(1))),\
191 $(call _modulate2,\
192 $(wordlist 2,$(words $(1)),$(1)),\
193 $(addprefix $(2)-,$(call tolower,$(firstword $(1)))-$(M)),\
194 $(3) $(firstword $(1)),\
195 $(4) $(firstword $(1))=$(M)\
196 )\
197 ),\
198 $(call _modulate_do,,$(strip $(2)),$(3),$(4))\
199 )
200 endef
201
202 define _pmod
203 @echo "[ $1 for modulation $(MODULATION): $(foreach M,$(MODULATORS),$M=$($M)) ]"
204 endef
205
206 $(eval $(call _modulate,$(MODULATORS)))
207
208 # --- This next block allows you to use collapsed ISAs in modulations
209 # isa-default-... instead of isa-sparcv8-... and isa-i386-...
210 # isa-default64-... instead of isa-sparcv9-... and isa-amd64-...
211 # isa-extra-... instead of any other ISA (if default64 is undefined it falls back to 'extra')
212
213 __collapsedisa = $(strip $(or $(and $(filter $(ISA_DEFAULT_sparc) $(ISA_DEFAULT_i386),$(1)),default),\
214 $(and $(filter $(ISA_DEFAULT64_sparc) $(ISA_DEFAULT64_i386),$(1)),default64),\
215 extra))
216
217 __collapsedisa64 = default64
218 __collapsedisaextra = extra
219
220 __isacollapsedmodulation_1 = $(call tolower,$(1))-$(if $(filter ISA,$(1)),$(call $(2),$(ISA)),$($(1)))
221 __isacollapsedmodulation = $(if $(word 2,$(1)),\
222 $(foreach P,$(call __isacollapsedmodulation_1,$(firstword $(1)),$(2)),\
223 $(addprefix $(P)-,$(call __isacollapsedmodulation,$(wordlist 2,$(words $(1)),$(1))))\
224 ),\
225 $(call __isacollapsedmodulation_1,$(1),$(2)))
226
227 # This is the name of the current modulation but with the ISA i386, sparcv8 and amd64, sparcv9 replaced
228 # with the collapsed name 'default', 'default64' and everything else as 'extra'.
229 MODULATION_ISACOLLAPSED = $(strip $(call __isacollapsedmodulation,$(strip $(MODULATORS)),__collapsedisa))
230
231 # This is the name of the current modulation but with the ISA replaced with 'default64'
232 MODULATION_ISACOLLAPSED64 = $(strip $(call __isacollapsedmodulation,$(strip $(MODULATORS)),__collapsedisa64))
233
234 # This is the name of the current modulation but with the ISA replaced with 'extra'
235 MODULATION_ISACOLLAPSEDEXTRA = $(strip $(call __isacollapsedmodulation,$(strip $(MODULATORS)),__collapsedisaextra))
236
237 # $(warning Mod: $(MODULATION) ISA: $(ISA) coll: $(MODULATION_ISACOLLAPSED) 64: $(MODULATION_ISACOLLAPSED64) extra: $(MODULATION_ISACOLLAPSEDEXTRA))
238
239 # Call this function to get either the modulation-specific value or the default.
240 # Instead of $(myvar_$(MODULATION)) $(call modulationvalue,myvar)
241 define modulationvalue
242 $(strip $(or $($(1)_$(MODULATION)),\
243 $($(1)_$(MODULATION_ISACOLLAPSED)),\
244 $($(1)_$(MODULATION_ISACOLLAPSEDEXTRA)),\
245 ))
246 endef
247
248 # --- end of collapsed ISA modulations
249
250 #################### DIRECTORY MAKERS ####################
251
252 # This is to make dirs as needed by the base rules
253 $(sort $(DOWNLOADDIR) $(PARTIALDIR) $(COOKIEDIR) $(WORKSRC) $(addprefix $(WORKROOTDIR)/build-,global $(MODULATIONS)) $(EXTRACTDIR) $(FILEDIR) $(SCRATCHDIR) $(PKGROOT) $(INSTALL_DIRS) $(INSTALLISADIR) $(GARCHIVEDIR) $(GARPKGDIR) $(STAGINGDIR)):
254 @if test -d $@; then : ; else \
255 ginstall -d $@; \
256 echo "ginstall -d $@"; \
257 fi
258
259 $(COOKIEDIR)/%:
260 @if test -d $@; then : ; else \
261 ginstall -d $@; \
262 echo "ginstall -d $@"; \
263 fi
264
265 # These stubs are wildcarded, so that the port maintainer can
266 # define something like "pre-configure" and it won't conflict,
267 # while the configure target can call "pre-configure" safely even
268 # if the port maintainer hasn't defined it.
269 #
270 # in addition to the pre-<target> rules, the maintainer may wish
271 # to set a "pre-everything" rule, which runs before the first
272 # actual target.
273 pre-%:
274 @true
275
276 post-%:
277 @true
278
279 # Call any arbitrary rule recursively for all dependencies
280 deep-%: %
281 @for target in "" $(DEPEND_LIST) ; do \
282 test -z "$$target" && continue ; \
283 $(MAKE) -C ../../$$target DESTIMG=$(DESTIMG) $@ ; \
284 done
285 @$(foreach IMG,$(filter-out $(DESTIMG),$(IMGDEPS)),for dep in "" $($(IMG)_DEPENDS); do test -z "$$dep" && continue ; $(MAKE) -C ../../$$dep DESTIMG=$(IMG) $@; done; )
286
287
288 # ========================= MAIN RULES =========================
289 # The main rules are the ones that the user can specify as a
290 # target on the "make" command-line. Currently, they are:
291 # prereq fetch-list fetch checksum makesum extract checkpatch patch
292 # build install reinstall uninstall package
293 # (some may not be complete yet).
294 #
295 # Each of these rules has dependencies that run in the following
296 # order:
297 # - run the previous main rule in the chain (e.g., install
298 # depends on build)
299 # - run the pre- rule for the target (e.g., configure would
300 # then run pre-configure)
301 # - generate a set of files to depend on. These are typically
302 # cookie files in $(COOKIEDIR), but in the case of fetch are
303 # actual downloaded files in $(DOWNLOADDIR)
304 # - run the post- rule for the target
305 #
306 # The main rules also run the $(DONADA) code, which prints out
307 # what just happened when all the dependencies are finished.
308
309 announce:
310 @echo "[===== NOW BUILDING: $(DISTNAME) =====]"
311
312 announce-modulation:
313 @echo "[===== NOW BUILDING: $(DISTNAME) MODULATION $(MODULATION): $(foreach M,$(MODULATORS),$M=$($M)) =====]"
314
315 # prerequisite - Make sure that the system is in a sane state for building the package
316 ALL_PREREQ_PKGS = $(PREREQUISITE_BASE_PKGS) $(BUILD_DEP_PKGS) $(DEP_PKGS) $(foreach S,$(_PKG_SPECS),$(DEP_PKGS_$S))
317 PREREQUISITE_TARGETS = $(addprefix prerequisite-,$(PREREQUISITE_SCRIPTS))
318
319 # Force to be called in global modulation
320 prerequisite: $(if $(filter global,$(MODULATION)),announce pre-everything $(COOKIEDIR) $(DOWNLOADDIR) $(PARTIALDIR) $(addprefix dep-$(GARDIR)/,$(FETCHDEPS)) pre-prerequisite check-prereqs $(PREREQUISITE_TARGETS) post-prerequisite)
321 $(if $(filter-out global,$(MODULATION)),$(MAKE) -s MODULATION=global prerequisite)
322 $(DONADA)
323
324 build-dep-pkgs:
325 @echo $(BUILD_DEP_PKGS)
326
327 check-prereqs:
328 @$(abspath $(GARBIN)/check_for_deps) $(ALL_PREREQ_PKGS)
329 @$(MAKECOOKIE)
330
331 prerequisitepkg-%:
332 @echo " ==> Verifying for installed package $*: \c"
333 @(pkginfo -q $*; if [ $$? -eq 0 ]; then echo "installed"; else echo "MISSING"; exit 1; fi)
334 @$(MAKECOOKIE)
335
336 # fetch-list - Show list of files that would be retrieved by fetch.
337 # NOTE: DOES NOT RUN pre-everything!
338 fetch-list:
339 @echo "Distribution files: "
340 @$(foreach F,$(DISTFILES),echo " $F";)
341 @echo "Patch files: "
342 @$(foreach P,$(PATCHFILES),echo " $P";)
343 @$(foreach M,$(MODULATIONS),$(if $(PATCHFILES_$M),echo " Modulation $M only: $(PATCHFILES_$M)";))
344 @echo "Dynamically generated scripts: "
345 @$(foreach D,$(DYNSCRIPTS),echo " $D";)
346 @echo "Git Repos tracked: "
347 @$(foreach R,$(GIT_REPOS),echo " $R";)
348 @echo "Mercurial Repos tracked: "
349 @$(foreach R,$(HG_REPOS),echo " $R";)
350 @echo "All potential URLS: "
351 @$(foreach U,$(URLS),echo " $U";)
352
353 # fetch - Retrieves $(DISTFILES) (and $(PATCHFILES) if defined)
354 # into $(DOWNLOADDIR) as necessary.
355 FETCH_TARGETS = $(addprefix $(DOWNLOADDIR)/,$(ALLFILES))
356
357 fetch: prerequisite pre-fetch $(FETCH_TARGETS) post-fetch
358 @$(DONADA)
359
360 # returns true if fetch has completed successfully, false
361 # otherwise
362 fetch-p:
363 @$(foreach COOKIEFILE,$(FETCH_TARGETS), test -e $(COOKIEDIR)/$(COOKIEFILE) ;)
364
365 # checksum - Use $(CHECKSUMFILE) to ensure that your
366 # distfiles are valid.
367 CHECKSUM_TARGETS = $(addprefix checksum-,$(filter-out $(_NOCHECKSUM) $(NOCHECKSUM),$(ALLFILES)))
368
369 checksum: fetch $(COOKIEDIR) pre-checksum $(CHECKSUM_TARGETS) post-checksum
370 @$(DONADA)
371
372 checksum-global: $(if $(filter global,$(MODULATION)),checksum)
373 $(if $(filter-out global,$(MODULATION)),$(MAKE) -s MODULATION=global checksum)
374 @$(DONADA)
375
376 # The next rule handles the dependency from the modulated context to
377 # the contextless checksumming. The rule is called when the cookie
378 # to the global checksum is requested. If the global checksum has not run,
379 # then run it. Otherwise it is silently accepted.
380 checksum-modulated: checksum-global
381 @$(DONADA)
382
383 # returns true if checksum has completed successfully, false
384 # otherwise
385 checksum-p:
386 @$(foreach COOKIEFILE,$(CHECKSUM_TARGETS), test -e $(COOKIEDIR)/$(COOKIEFILE) ;)
387
388 # makesum - Generate distinfo (only do this for your own ports!).
389 GARCHIVE_TARGETS = $(addprefix $(GARCHIVEDIR)/,$(filter-out $(ALLFILES_DYNSCRIPTS), $(ALLFILES)))
390
391 MAKESUM_TARGETS = $(filter-out $(_NOCHECKSUM) $(NOCHECKSUM),$(ALLFILES))
392
393 makesum: fetch $(GARCHIVE_TARGETS) $(addprefix $(DOWNLOADDIR)/,$(MAKESUM_TARGETS))
394 @if test "x$(MAKESUM_TARGETS)" != "x"; then \
395 (cd $(DOWNLOADDIR) && $(md5sum) $(MAKESUM_TARGETS)) > $(CHECKSUM_FILE) ; \
396 echo "Checksums made for $(MAKESUM_TARGETS)" ; \
397 cat $(CHECKSUM_FILE) ; \
398 else \
399 cp /dev/null $(CHECKSUM_FILE) ; \
400 fi
401
402 # I am always typing this by mistake
403 makesums: makesum
404
405 garchive: checksum $(GARCHIVE_TARGETS) ;
406
407 # extract - Unpacks $(DISTFILES) into $(EXTRACTDIR) (patches are "zcatted" into the patch program)
408 EXTRACT_TARGETS-global ?= $(addprefix extract-copy-,$(filter-out $(NOEXTRACT),$(DISTFILES) $(DYNSCRIPTS) $(foreach R,$(GIT_REPOS),$(call GITPROJ,$(R))) $(foreach R,$(HG_REPOS),$(call GITPROJ,$(R).hg))))
409 EXTRACT_TARGETS-default = $(addprefix extract-archive-,$(filter-out $(NOEXTRACT),$(DISTFILES) $(DYNSCRIPTS) $(foreach R,$(GIT_REPOS),$(call GITPROJ,$(R))) $(foreach R,$(HG_REPOS),$(call GITPROJ,$(R).hg))))
410 EXTRACT_TARGETS = $(or $(EXTRACT_TARGETS-$(MODULATION)),$(EXTRACT_TARGETS-default))
411
412 ifdef REINPLACE_FILES
413 REINPLACEMENTS ?= default
414 REINPLACE_MATCH_default ?= $(REINPLACE_MATCH)
415 REINPLACE_WITH_default ?= $(REINPLACE_WITH)
416 REINPLACE_FILES_default ?= $(REINPLACE_FILES)
417 REINPLACE_WHEN_default ?= $(REINPLACE_WHEN)
418 endif
419
420 REINPLACE_MATCH_USRLOCAL = /usr/local
421 REINPLACE_WITH_USRLOCAL = $(prefix)
422 REINPLACE_FILES_USRLOCAL = $(REINPLACE_USRLOCAL)
423
424 REINPLACE_MATCH_USRSHARE = /usr/share
425 REINPLACE_WITH_USRSHARE = $(sharedstatedir)
426 REINPLACE_FILES_USRSHARE = $(REINPLACE_USRSHARE)
427
428 _ALL_REINPLACEMENTS = $(REINPLACEMENTS) $(if $(REINPLACE_FILES_USRLOCAL),USRLOCAL) $(if $(REINPLACE_FILES_USRSHARE),USRSHARE)
429
430 POSTINSTALL_REINPLACEMENTS = $(foreach R,$(_ALL_REINPLACEMENTS),$(if $(filter postinstall,$(REINPLACE_WHEN_$R)),$R))
431 POSTEXTRACT_REINPLACEMENTS = $(filter-out $(POSTINSTALL_REINPLACEMENTS),$(_ALL_REINPLACEMENTS))
432
433 $(foreach REINPLACEMENT,$(_ALL_REINPLACEMENTS),\
434 $(if $(REINPLACE_FILES_$(REINPLACEMENT)),,$(error Reinplacement '$(REINPLACEMENT)' has been set but REINPLACE_FILES_$(REINPLACEMENT) is empty))\
435 $(if $(REINPLACE_MATCH_$(REINPLACEMENT)),,$(error Reinplacement '$(REINPLACEMENT)' has been set but REINPLACE_MATCH_$(REINPLACEMENT) is empty))\
436 )
437
438 # We call an additional extract-modulated without resetting any variables so
439 # a complete unpacked set goes to the global dir for packaging (like gspec)
440 extract: checksum $(COOKIEDIR) $(if $(NOGITPATCH),,pre-extract-git-check) extract-modulated $(addprefix extract-,$(MODULATIONS))
441 @$(DONADA)
442
443 extract-global: $(if $(filter global,$(MODULATION)),extract-modulated)
444 $(if $(filter-out global,$(MODULATION)),$(MAKE) -s MODULATION=global extract)
445 @$(MAKECOOKIE)
446
447 extract-modulated: checksum-modulated $(EXTRACTDIR) $(COOKIEDIR) \
448 $(addprefix dep-$(GARDIR)/,$(EXTRACTDEPS)) \
449 announce-modulation \
450 $(if $(filter-out global,$(MODULATION)),pre-extract) pre-extract-modulated pre-extract-$(MODULATION) $(EXTRACT_TARGETS) post-extract-$(MODULATION) post-extract-modulated $(if $(filter-out global,$(MODULATION)),post-extract) \
451 $(if $(filter global,$(MODULATION)),,$(if $(NOGITPATCH),,post-extract-gitsnap)) \
452 $(foreach FILE,$(EXPANDVARS),expandvars-$(FILE)) \
453 $(foreach REINPLACEMENT,$(POSTEXTRACT_REINPLACEMENTS),\
454 post-extract-reinplace-$(REINPLACEMENT) \
455 )
456 @$(DONADA)
457
458 # This target ensures that the values used by git when making a commit
459 # are more sane than they _could_ otherwise be by taking the hostname
460 # to build the email address used. If you want to submit patches with
461 # an alternate email address, use git config yourself to override the
462 # values.
463 pre-extract-git-check:
464 @( g_email=`git config --global user.email`; \
465 g_name=`git config --global user.name`; \
466 email=$$USER@opencsw.org; \
467 name=`getent passwd $$USER | awk -F: '{print $$5}'`; \
468 if [ -z "$$g_email" ]; then \
469 echo "Setting User Email value to: $$email"; \
470 git config --global user.email "$$email"; \
471 fi; \
472 if [ -z "$$g_name" ]; then \
473 echo "Setting User Name value to: $$name"; \
474 git config --global user.name "$$name"; \
475 fi )
476 @$(MAKECOOKIE)
477
478 post-extract-gitsnap: $(EXTRACT_TARGETS)
479 @( if [ -d "$(PATCHDIR)" ]; then \
480 echo ' ==> Snapshotting extracted source tree with git'; \
481 cd $(PATCHDIR); git init; git add .; \
482 git commit -m "Upstream $(VERSION)"; \
483 git tag -am "Upstream $(VERSION)" upstream-$(VERSION); \
484 git checkout -b csw; \
485 fi )
486 @$(MAKECOOKIE)
487
488 # returns true if extract has completed successfully, false
489 # otherwise
490 extract-p:
491 @$(foreach COOKIEFILE,$(EXTRACT_TARGETS), test -e $(COOKIEDIR)/$(COOKIEFILE) ;)
492
493 # The rule takes all files from EXPANDVARS and replaces all occurrences of @<var>@ (but not @@<var>@@ as this is used by patch) in the file
494 # with the values of <var> from the Makefile.
495 _var_definitions = $(foreach VAR,$(shell perl -ne 'print "$$1 " while( /(?<!@)@([^@]+)@(?!@)/g );' <$1),$(VAR)="$($(VAR))")
496
497 expandvars-%:
498 $(call _var_definitions,$(WORKDIR)/$*) perl -i-unexpanded -npe 's/(?<!@)@([^@]+)@(?!@)/$$ENV{$$1}/eg' $(WORKDIR)/$*
499 @$(MAKECOOKIE)
500
501 post-extract-reinplace-%:
502 -perl -p -i$(REINPLACE_BACKUP_$*) -e 's{$(REINPLACE_MATCH_$*)}{$(REINPLACE_WITH_$*)}g' \
503 $(addprefix $(WORKSRC)/,$(REINPLACE_FILES_$*))
504 @( if [ -d "$(PATCHDIR)/.git" ]; then \
505 echo "Committing reinplacements..."; \
506 cd $(PATCHDIR); \
507 git commit -am "Reinplacement $*"; \
508 git tag -am "Reinplacement $*" reinplacement-$*; \
509 fi )
510 @$(MAKECOOKIE)
511
512 # checkpatch - Do a "patch -C" instead of a "patch". Note
513 # that it may give incorrect results if multiple
514 # patches deal with the same file.
515 # TODO: actually write it!
516 checkpatch: extract
517 @echo "$@ NOT IMPLEMENTED YET"
518
519 # patch - Apply any provided patches to the source.
520 PATCH_TARGETS = $(addprefix patch-extract-,$(PATCHFILES) $(PATCHFILES_$(MODULATION)))
521
522 patch: $(addprefix patch-,$(MODULATIONS))
523 @$(DONADA)
524
525 patch-modulated: extract-modulated $(WORKSRC) pre-patch pre-patch-modulated pre-patch-$(MODULATION) $(PATCH_TARGETS) $(if $(filter global,$(MODULATION)),,$(if $(NOGITPATCH),,post-patch-gitsnap)) post-patch-$(MODULATION) post-patch-modulated post-patch
526 @$(DONADA)
527
528 # returns true if patch has completed successfully, false
529 # otherwise
530 patch-p:
531 @$(foreach COOKIEFILE,$(PATCH_TARGETS), test -e $(COOKIEDIR)/$(COOKIEFILE) ;)
532
533 post-patch-gitsnap: $(PATCH_TARGETS)
534
535 @( if [ -d "$(PATCHDIR)/.git" ]; then \
536 echo "Tagging top of current csw patch stack..."; \
537 cd $(PATCHDIR); \
538 git tag -am "CSW $(VERSION)" csw-$(VERSION); \
539 fi )
540 @$(MAKECOOKIE)
541
542 makepatch: $(if $(NOGITPATCH),makepatch-nogit,$(addprefix patch-,$(MODULATIONS)) $(addprefix makepatch-,$(MODULATIONS)))
543 @$(DONADA)
544
545 makepatch-nogit:
546 @echo You set NOGITPATCH in your build recipe. I can't create a patch.
547 @$(DONADA)
548
549 # Allow generation of patches from modified work source.
550 makepatch-modulated: $(FILEDIR)
551 @( if [ -d "$(PATCHDIR)/.git" ]; then \
552 echo " ==> Makepatch: Looking for changes in modulation $(MODULATION)"; \
553 cd $(PATCHDIR); \
554 git add -u; \
555 git diff --cached --quiet; \
556 if test $$? -eq 0; then \
557 echo "No changes."; \
558 else \
559 echo "Capturing changes..."; \
560 git commit $(GIT_COMMIT_OPTS) && \
561 ( NEXTPATCH=`git log --pretty=oneline master..HEAD | wc -l | tr -d '[[:space:]]'`; \
562 git format-patch --start-number=$$NEXTPATCH csw-$(VERSION); \
563 echo Add the following to your recipe and then; \
564 NEWPATCHES=`echo 00*-*patch`; \
565 FILES_PATCHES=`for p in $$NEWPATCHES; do echo files/$$p; done`; \
566 echo rerun: gmake makesums; \
567 echo PATCHFILES += $$NEWPATCHES; \
568 echo "(or maybe PATCHFILES_$(MODULATION) ??)"; \
569 echo "Don't forget:"; \
570 echo; \
571 echo " svn add" $$FILES_PATCHES; \
572 echo; \
573 mv $$NEWPATCHES $(abspath $(FILEDIR)); \
574 for p in $$NEWPATCHES; do \
575 touch $(abspath $(COOKIEDIR))/normal-patch-$$p; \
576 touch $(abspath $(COOKIEDIR))/patch-extract-$$p; \
577 done; \
578 touch $(abspath $(COOKIEDIR))/extract-modulated; \
579 touch $(abspath $(COOKIEDIR))/patch-modulated; \
580 touch $(abspath $(COOKIEDIR))/post-patch-gitsnap; ) \
581 fi; \
582 else \
583 echo "No extracted sources so we can't create patches..."; \
584 fi )
585
586 # XXX: Allow patching of pristine sources separate from ISA directories
587 # XXX: Use makepatch on global/
588
589 # this takes the changes you've made to a working directory,
590 # distills them to a patch, updates the checksum file, and tries
591 # out the build (assuming you've listed the gar-base.diff in your
592 # PATCHFILES). This is way undocumented. -NickM
593 beaujolais: makepatch makesum clean build
594 $(DONADA)
595
596 update: makesum garchive clean
597
598 # configure - Runs either GNU configure, one or more local
599 # configure scripts or nothing, depending on
600 # what's available.
601 CONFIGURE_TARGETS = $(addprefix configure-,$(CONFIGURE_SCRIPTS))
602
603 # Limit dependencies to all but one category or to exclude one category
604 ALL_CATEGORIES = apps cpan devel gnome lang lib net server utils extra
605 ifneq ($(BUILD_CATEGORY),)
606 NOBUILD_CATEGORY = $(filter-out $(BUILD_CATEGORY),$(ALL_CATEGORIES))
607 endif
608
609 DEPEND_LIST = $(filter-out $(addsuffix /%,$(NOBUILD_CATEGORY)),$(DEPENDS) $(LIBDEPS) $(BUILDDEPS))
610
611 ifneq ($(SKIPDEPEND),1)
612 CONFIGURE_DEPS = $(addprefix $(GARDIR)/,$(addsuffix /$(COOKIEDIR)/install,$(DEPEND_LIST)))
613 CONFIGURE_IMGDEPS = $(addprefix imgdep-,$(filter-out $(DESTIMG),$(IMGDEPS)))
614 #CONFIGURE_BUILDDEPS = $(addprefix $(GARDIR)/,$(addsuffix /$(COOKIEROOTDIR)/build.d/install,$(BUILDDEPS)))
615 endif
616
617 configure: $(addprefix configure-,$(MODULATIONS))
618 @$(DONADA)
619
620 configure-modulated: verify-isa patch-modulated $(CONFIGURE_IMGDEPS) $(CONFIGURE_BUILDDEPS) $(CONFIGURE_DEPS) \
621 $(addprefix srcdep-$(GARDIR)/,$(SOURCEDEPS)) \
622 pre-configure pre-configure-modulated pre-configure-$(MODULATION) $(CONFIGURE_TARGETS) post-configure-$(MODULATION) post-configure-modulated post-configure $(if $(STRIP_LIBTOOL),strip-libtool)
623 @$(DONADA)
624
625 strip-libtool:
626 @echo '[===== Stripping Libtool =====]'
627 fixlibtool $(WORKSRC)
628 @$(MAKECOOKIE)
629
630 .PHONY: reset-configure reset-configure-modulated
631 reconfigure: reset-configure configure
632
633 reset-configure: $(addprefix reset-configure-,$(MODULATIONS))
634 @rm -f $(addprefix $(COOKIEDIR)/configure-,$(MODULATIONS))
635 @rm -f $(COOKIEDIR)/configure
636
637 reset-configure-modulated:
638 @rm -f $(foreach C,pre-configure pre-configure-modulated configure-modulated post-configure-modulated post-configure,$(COOKIEDIR)/$C)
639 @rm -f $(COOKIEDIR)/pre-configure-$(MODULATION) $(COOKIEDIR)/post-configure-$(MODULATION)
640 @rm -f $(addprefix $(COOKIEDIR)/,$(CONFIGURE_TARGETS))
641
642 # returns true if configure has completed successfully, false
643 # otherwise
644 configure-p:
645 @$(foreach COOKIEFILE,$(CONFIGURE_TARGETS), test -e $(COOKIEDIR)/$(COOKIEFILE) ;)
646
647 # build - Actually compile the sources.
648 BUILD_TARGETS = $(addprefix build-,$(BUILD_CHECK_SCRIPTS)) $(addprefix build-,$(BUILD_SCRIPTS))
649
650 build: $(addprefix build-,$(MODULATIONS))
651 $(DONADA)
652
653 # Build for a specific architecture
654 build-modulated-check:
655 $(if $(filter ERROR,$(ARCHFLAGS_$(GARCOMPILER)_$*)), \
656 $(error Code for the architecture $* can not be produced with the compiler $(GARCOMPILER)) \
657 )
658
659 build-modulated: verify-isa configure-modulated pre-build pre-build-modulated pre-build-$(MODULATION) $(BUILD_TARGETS) post-build-$(MODULATION) post-build-modulated post-build
660 @$(MAKECOOKIE)
661
662 .PHONY: reset-build reset-build-modulated
663 rebuild: reset-build build
664
665 reset-build: $(addprefix reset-build-,$(MODULATIONS))
666 rm -f $(COOKIEDIR)/build
667
668 reset-build-modulated: $(patsubst build-%,clean-%,$(BUILD_TARGETS))
669 rm -f $(addprefix $(COOKIEDIR)/,pre-build pre-build-modulated $(BUILD_TAGRETS) post-build-modulated post-build))
670
671 # returns true if build has completed successfully, false
672 # otherwise
673 build-p:
674 @$(foreach COOKIEFILE,$(BUILD_TARGETS), test -e $(COOKIEDIR)/$(COOKIEFILE) ;)
675
676 TEST_TARGETS = $(addprefix test-,$(TEST_SCRIPTS))
677
678 test: $(addprefix test-,$(MODULATIONS))
679 $(DONADA)
680
681 test-modulated: build-modulated pre-test pre-test-modulated pre-test-$(MODULATION) $(TEST_TARGETS) post-test-$(MODULATION) post-test-modulated post-test
682 $(DONADA)
683
684 # XXX: retest
685
686 # strip - Strip executables
687 ifneq ($(GARFLAVOR),DBG)
688 POST_INSTALL_TARGETS := $(if $(NOSTRIP),,strip) $(POST_INSTALL_TARGETS)
689 endif
690
691 strip:
692 @for target in $(STRIP_DIRS) $(DESTDIR)$(bindir) $(DESTDIR)$(sbindir) ; \
693 do \
694 $(GARBIN)/stripbin $$target ; \
695 done
696 $(DONADA)
697
698 # fixconfig - Remove build-time paths config files
699 POST_INSTALL_TARGETS := fixconfig $(POST_INSTALL_TARGETS)
700 FIXCONFIG_DIRS ?= $(DESTDIR)$(libdir) $(DESTDIR)$(bindir)
701 FIXCONFIG_RMPATHS ?= $(DESTDIR) $(CURDIR)/$(WORKSRC)
702 fixconfig:
703 @if test "x$(FIXCONFIG_DIRS)" != "x" ; then \
704 for path in $(FIXCONFIG_DIRS) ; do \
705 if test -d $$path ; then \
706 echo " ==> fixconfig: $$path" ; \
707 replacer $$path $(FIXCONFIG_RMPATHS) ; \
708 fi ; \
709 done ; \
710 fi
711
712 # install - Test and install the results of a build.
713 INSTALL_TARGETS = $(addprefix install-,$(INSTALL_SCRIPTS))
714
715 install: $(addprefix install-,$(MODULATIONS))
716 $(DONADA)
717
718 install-modulated: build-modulated $(addprefix dep-$(GARDIR)/,$(INSTALLDEPS)) test-modulated $(INSTALL_DIRS) $(PRE_INSTALL_TARGETS) \
719 pre-install pre-install-modulated pre-install-$(MODULATION) \
720 $(INSTALL_TARGETS) \
721 post-install-$(MODULATION) post-install-modulated post-install \
722 $(POST_INSTALL_TARGETS) \
723 $(foreach REINPLACEMENT,$(POSTINSTALL_REINPLACEMENTS),\
724 post-install-reinplace-$(REINPLACEMENT) \
725 )
726 @$(MAKECOOKIE)
727
728 post-install-reinplace-%:
729 -perl -p -i$(REINPLACE_BACKUP_$*) -e "s($(REINPLACE_MATCH_$*))($(REINPLACE_WITH_$*))g" \
730 $(addprefix $(DESTDIR)/,$(REINPLACE_FILES_$*))
731 @$(MAKECOOKIE)
732
733 # returns true if install has completed successfully, false
734 # otherwise
735 install-p:
736 @$(foreach COOKIEFILE,$(INSTALL_TARGETS), test -e $(COOKIEDIR)/$(COOKIEFILE) ;)
737
738
739
740 # reinstall - Install the results of a build, ignoring
741 # "already installed" flag.
742 .PHONY: reinstall reset-install reset-install-modulated
743 reinstall: reset-install install
744
745 reset-install: reset-merge $(addprefix reset-install-,$(MODULATIONS))
746 @rm -f $(foreach M,$(MODULATIONS),$(COOKIEDIR)/install-$M) $(COOKIEDIR)/install $(COOKIEDIR)/post-install
747 @rm -f $(COOKIEDIR)/strip
748
749 reset-install-modulated:
750 @$(call _pmod,Reset install state)
751 @rm -rf $(INSTALLISADIR) $(COOKIEDIR)/install-work
752 @rm -f $(foreach C,pre-install pre-install-modulated install-modulated post-install-modulated post-install,$(COOKIEDIR)/$C)
753 @rm -f $(COOKIEDIR)/pre-install-$(MODULATION) $(COOKIEDIR)/post-install-$(MODULATION)
754 @rm -f $(COOKIEDIR)/strip
755 @rm -f $(foreach S,$(INSTALL_TARGETS),$(COOKIEDIR)/$S)
756 @rm -f $(COOKIEROOTDIR)/global/install-$(MODULATION)
757 @rm -f $(addprefix $(COOKIEDIR)/post-install-reinplace-,$(POSTINSTALL_REINPLACEMENTS))
758
759 # merge in all isas to the package directory after installation
760
761 # Merging in general allows the selection of parts from different ISA builds into the package
762 # Per default merging is done differently depending on
763 # (a) if the sources are build for more than one ISA
764 # (b) if the executables should be replaced by isaexec or not
765 #
766 # - If there is only one ISA to build for everything is copied verbatim to PKGROOT.
767 # - If there are builds for more than one ISA the destination differs depending on if
768 # the binaries should be executed by isaexec. This is usually bin, sbin and libexec.
769 #
770 # default: ISA_DEFAULT gets installed in bin/..., all others in bin/$ISA/
771 # ISAEXEC = 1: relocate to ISA subdirs if more than one ISA, use isaexec-wrapper for bin/, etc.
772 #
773 # Automatic merging is only possible if you have the default modulation "ISA"
774 # Otherwise you *must* specify merge scripts for all modulations.
775
776 ifeq ($(DEBUG_MERGING),)
777 _DBG_MERGE=@
778 else
779 _DBG_MERGE=
780 endif
781
782 ifeq ($(NEEDED_ISAS),$(ISA_DEFAULT))
783 MERGE_SCRIPTS_isa-default ?= copy-all $(EXTRA_MERGE_SCRIPTS_$(ISA_DEFAULT)) $(EXTRA_MERGE_SCRIPTS)
784 MERGE_SCRIPTS_isa-$(ISA_DEFAULT) ?= $(MERGE_SCRIPTS_isa-default)
785 MERGE_SCRIPTS_$(MODULATION) ?= $(MERGE_SCRIPTS_$(MODULATION_ISACOLLAPSED))
786 else
787 ISAEXEC_DIRS ?= $(if $(ISAEXEC),$(bindir) $(sbindir) $(libexecdir))
788 MERGE_DIRS_isa-default ?= $(EXTRA_MERGE_DIRS) $(EXTRA_MERGE_DIRS_isa-$(ISA_DEFAULT))
789 MERGE_DIRS_isa-extra ?= $(if $(or $(BUILD64),$(ISAEXEC)),$(bindir) $(sbindir) $(libexecdir)) $(libdir) $(EXTRA_MERGE_DIRS) $(EXTRA_MERGE_DIRS_isa-extra) $(EXTRA_MERGE_DIRS_isa-$(ISA))
790 MERGE_DIRS_$(MODULATION_ISACOLLAPSED64) ?= $(MERGE_DIRS_$(MODULATION_ISACOLLAPSEDEXTRA))
791 MERGE_DIRS_$(MODULATION) ?= $(MERGE_DIRS_$(MODULATION_ISACOLLAPSED))
792
793 MERGE_SCRIPTS_isa-default ?= copy-relocate $(EXTRA_MERGE_SCRIPTS_isa-$(ISA_DEFAULT)) $(EXTRA_MERGE_SCRIPTS)
794 MERGE_SCRIPTS_isa-default64 ?= $(if $(BUILD64_ONLY),copy-relocate,copy-relocated-only copy-config-only) $(EXTRA_MERGE_SCRIPTS_isa-$(ISA)) $(EXTRA_MERGE_SCRIPTS_isa-default64) $(EXTRA_MERGE_SCRIPTS)
795 MERGE_SCRIPTS_isa-extra ?= copy-relocated-only copy-config-only $(EXTRA_MERGE_SCRIPTS_isa-$(ISA)) $(EXTRA_MERGE_SCRIPTS_isa-extra) $(EXTRA_MERGE_SCRIPTS)
796 MERGE_SCRIPTS_$(MODULATION_ISACOLLAPSED64) ?= $(MERGE_SCRIPTS_$(MODULATION_ISACOLLAPSEDEXTRA))
797 MERGE_SCRIPTS_$(MODULATION) ?= $(MERGE_SCRIPTS_$(MODULATION_ISACOLLAPSED))
798 endif
799
800 # These directories get relocated into their ISA subdirectories
801 MERGE_DIRS ?= $(call modulationvalue,MERGE_DIRS)
802
803 ifneq ($(COMMON_PKG_DEPENDS),)
804 _EXTRA_GAR_PKGS += $(COMMON_PKG_DEPENDS)
805 endif
806
807 # These merge-rules are actually processed for the current modulation
808 MERGE_TARGETS ?= $(addprefix merge-,$(MERGE_SCRIPTS_$(MODULATION))) $(EXTRA_MERGE_TARGETS)
809
810 # Include only these files
811 ifeq ($(origin MERGE_INCLUDE_FILES_$(MODULATION)), undefined)
812 _MERGE_INCLUDE_FILES = $(MERGE_INCLUDE_FILES)
813 else
814 _MERGE_INCLUDE_FILES = $(MERGE_INCLUDE_FILES_$(MODULATION))
815 endif
816
817 # This can be defined in category.mk
818 MERGE_EXCLUDE_CATEGORY ?= $(_MERGE_EXCLUDE_CATEGORY)
819
820 # Support for cswpycompile, skip pre-compiled python files (.pyc, .pyo)
821 # during the merge phase.
822 _PYCOMPILE_FILES = /opt/csw/lib/python.*/site-packages/.*\.py
823 MERGE_EXCLUDE_PYCOMPILE ?= $(if $(PYCOMPILE), $(addsuffix c,$(_PYCOMPILE_FILES)) $(addsuffix o,$(_PYCOMPILE_FILES)))
824
825 MERGE_EXCLUDE_INFODIR ?= $(sharedstatedir)/info/dir
826 MERGE_EXCLUDE_LIBTOOL ?= $(libdir)/.*\.la
827 MERGE_EXCLUDE_BACKUPFILES ?= .*\~
828 MERGE_EXCLUDE_STATICLIBS ?= $(libdir)/.*\.a
829 # Exclude all other .pc-files apart from the default 32- and 64 bit versions
830 MERGE_EXCLUDE_EXTRA_ISA_PKGCONFIG ?= $(if $(filter-out $(ISA_DEFAULT) $(ISA_DEFAULT64),$(ISA)),$(libdir)/.*\.pc)
831 MERGE_EXCLUDE_DEFAULT ?= $(MERGE_EXCLUDE_CATEGORY) $(MERGE_EXCLUDE_INFODIR) $(MERGE_EXCLUDE_LIBTOOL) $(MERGE_EXCLUDE_BACKUPFILES) $(MERGE_EXCLUDE_STATICLIBS) $(MERGE_EXCLUDE_EXTRA_ISA_PKGCONFIG) $(MERGE_EXCLUDE_PYCOMPILE)
832
833 # Exclude these files
834 ifeq ($(origin MERGE_EXCLUDE_FILES_$(MODULATION)), undefined)
835 _MERGE_EXCLUDE_FILES = $(MERGE_EXCLUDE_FILES)
836 else
837 _MERGE_EXCLUDE_FILES = $(MERGE_EXCLUDE_FILES_$(MODULATION))
838 endif
839 _MERGE_EXCLUDE_FILES += $(EXTRA_MERGE_EXCLUDE_FILES) $(EXTRA_MERGE_EXCLUDE_FILES_$(MODULATION)) $(MERGE_EXCLUDE_DEFAULT)
840
841 # This variable contains parameter for pax to honor global file inclusion/exclusion
842 # Make sure include overrides are processed first
843 _INC_EXT_RULE = $(foreach F,$(EXTRA_MERGE_INCLUDE_FILES) $(EXTRA_MERGE_INCLUDE_FILES_$(MODULATION)),-i "^\.$F$$")
844 # Exclude by replacing files with the empty string
845 _INC_EXT_RULE += $(foreach F,$(_MERGE_EXCLUDE_FILES),-s ',^\.$F$$,,')
846 # Replace files by itself terminating on first match
847 _INC_EXT_RULE += $(foreach F,$(_MERGE_INCLUDE_FILES),-s ",^\(\.$F\)$$,\1,")
848
849 # These are used during merge phase to determine the base installation directory
850 MERGEBASE_$(bindir) ?= $(bindir_install)
851 MERGEBASE_$(sbindir) ?= $(sbindir_install)
852 MERGEBASE_$(libexecdir) ?= $(libexecdir_install)
853 MERGEBASE_$(libdir) ?= $(libdir_install)
854
855 define mergebase
856 $(if $(MERGEBASE_$(1)),$(MERGEBASE_$(1)),$(1))
857 endef
858
859 # A package is compiled for the pathes defined in $(bindir), $(libdir), etc.
860 # These may not be the standard pathes, because specific ISA compilation
861 # could have appended e. g. /64 for .pc-pathes to be correct. Anyway these
862 # pathes may need to be rewritten e. g. from lib/64 to lib/amd64. Here,
863 # $(libdir) has the memorymodel-directory appended, whereas $(libdir_install)
864 # has not, so we use this one for appending.
865
866 # Make sure the configuration files always have a .CSW suffix and rename the
867 # configuration files to this if necessary during merge.
868 _PAX_ARGS = $(_INC_EXT_RULE) $(_EXTRA_PAX_ARGS) $(call modulationvalue,EXTRA_PAX_ARGS) $(EXTRA_PAX_ARGS)
869
870 define killprocandparent
871 cpids() { \
872 P=$1 \
873 PPIDS=$P \
874 PP=`ps -eo pid,ppid | awk "BEGIN { ORS=\" \" } \\$2 == $P { print \\$1 }\"` \
875 while [ -n "$PP" ]; do \
876 PQ=$PP \
877 PP= \
878 for q in $PQ; do \
879 PPIDS="$PPIDS $q" \
880 PP=$PP\ `ps -eo pid,ppid | awk "BEGIN { ORS=\" \" } \\$2 == $q { print \\$1 }\"` \
881 done \
882 done \
883 \
884 echo $PPIDS \
885 }
886 endef
887
888
889 # The basic merge merges the compiles for all ISAs on the current architecture
890 merge: checksum merge-do merge-license merge-classutils merge-checkpkgoverrides merge-alternatives $(if $(COMPILE_ELISP),compile-elisp) $(if $(NOSOURCEPACKAGE),,merge-src) merge-distfile-README.CSW merge-distfile-changelog.CSW merge-obsolete $(if $(AP2_MODS),post-merge-ap2mod) $(if $(PHP5_EXT),post-merge-php5ext) post-merge-all
891 @banner merge
892 @$(MAKECOOKIE)
893
894 .PHONY: merge-do
895 merge-do: $(if $(PARALLELMODULATIONS),merge-parallel,merge-sequential)
896
897 .PHONY: merge-sequential
898 merge-sequential: $(addprefix merge-,$(MODULATIONS))
899
900 .PHONY: merge-parallel
901 merge-parallel: _PIDFILE=$(WORKROOTDIR)/build-global/multitail.pid
902 merge-parallel: merge-watch
903 $(_DBG_MERGE)trap "kill -9 `cat $(_PIDFILE) $(foreach M,$(MODULATIONS),$(WORKROOTDIR)/build-$M/build.pid) 2>/dev/null`;stty sane" INT;\
904 $(foreach M,$(MODULATIONS),($(MAKE) merge-$M >$(WORKROOTDIR)/build-$M/build.log 2>&1; echo $$? >$(WORKROOTDIR)/build-$M/build.ret) & echo $$! >$(WORKROOTDIR)/build-$M/build.pid; ) wait
905 $(_DBG_MERGE)if [ -f $(_PIDFILE) ]; then kill `cat $(_PIDFILE)`; stty sane; fi
906 $(_DBG_MERGE)$(foreach M,$(MODULATIONS),if [ "`cat $(WORKROOTDIR)/build-$M/build.ret`" -ne 0 ]; then \
907 echo "Build error in modulation $M. Please see"; \
908 echo " $(WORKROOTDIR)/build-$M/build.log"; \
909 echo "for details:"; \
910 echo; \
911 tail -100 $(WORKROOTDIR)/build-$M/build.log; \
912 exit "Return code: `cat $(WORKROOTDIR)/build-$M/build.ret`"; \
913 fi;)
914
915 .PHONY: merge-watch
916 merge-watch: _USEMULTITAIL=$(shell test -x $(MULTITAIL) && test -x $(TTY) && $(TTY) >/dev/null 2>&1; if [ $$? -eq 0 ]; then echo yes; fi)
917 merge-watch: $(addprefix $(WORKROOTDIR)/build-,global $(MODULATIONS))
918 $(_DBG_MERGE)$(if $(_USEMULTITAIL),\
919 $(MULTITAIL) --retry-all $(foreach M,$(MODULATIONS),$(WORKROOTDIR)/build-$M/build.log) -t "build(s) in progress" -wh 1 -j & echo $$! > $(WORKROOTDIR)/build-global/multitail.pid,\
920 echo "Building all ISAs in parallel. Please see the individual logfiles for details:";$(foreach M,$(MODULATIONS),echo "- $(WORKROOTDIR)/build-$M/build.log";)\
921 )
922
923 post-merge-ap2mod:
924 $(GARBIN)/ap2mod_build_scripts $(PKGROOT) $(AP2_MODFILES)
925 @$(MAKECOOKIE)
926
927 post-merge-php5ext:
928 $(GARBIN)/php5ext_build_scripts $(PKGROOT) $(PHP5_EXTFILES)
929 @$(MAKECOOKIE)
930
931 # This merges the
932 merge-modulated: install-modulated pre-merge pre-merge-modulated pre-merge-$(MODULATION) $(MERGE_TARGETS) post-merge-$(MODULATION) post-merge-modulated post-merge
933 @$(MAKECOOKIE)
934
935 # Copy the whole tree verbatim
936 merge-copy-all: $(PKGROOT) $(INSTALLISADIR)
937 $(_DBG_MERGE)(cd $(INSTALLISADIR)$(if $(ALLOW_RELOCATE),$(RELOCATE_PREFIX)); umask 022 && $(GARBIN)/pcopy $(_PAX_ARGS) \
938 $(foreach DIR,$(MERGE_DIRS),-s ",^\(\.$(DIR)/\),.$(call mergebase,$(DIR))/,p") \
939 . $(PKGROOT))
940 @$(MAKECOOKIE)
941
942 # Copy only the merge directories
943 merge-copy-only: $(PKGROOT)
944 $(_DBG_MERGE)(cd $(INSTALLISADIR)$(if $(ALLOW_RELOCATE),$(RELOCATE_PREFIX)); umask 022 && $(GARBIN)/pcopy $(_PAX_ARGS) \
945 $(foreach DIR,$(MERGE_DIRS),-s ",^\(\.$(DIR)/\),.$(call mergebase,$(DIR))/,p") -m \
946 . $(PKGROOT) \
947 )
948 @$(MAKECOOKIE)
949
950 # Copy the whole tree and relocate the directories in $(MERGE_DIRS)
951 merge-copy-relocate: $(PKGROOT) $(INSTALLISADIR)
952 $(_DBG_MERGE)(cd $(INSTALLISADIR)$(if $(ALLOW_RELOCATE),$(RELOCATE_PREFIX)); umask 022 && $(GARBIN)/pcopy $(_PAX_ARGS) \
953 $(foreach DIR,$(MERGE_DIRS),-s ",^\(\.$(DIR)/\),.$(call mergebase,$(DIR))/$(ISA)/,p") \
954 . $(PKGROOT) \
955 )
956 @$(MAKECOOKIE)
957
958 # Copy only the relocated directories
959 merge-copy-relocated-only: $(PKGROOT) $(INSTALLISADIR)
960 $(_DBG_MERGE)(cd $(INSTALLISADIR)$(if $(ALLOW_RELOCATE),$(RELOCATE_PREFIX)); umask 022 && $(GARBIN)/pcopy $(_PAX_ARGS) \
961 $(foreach DIR,$(MERGE_DIRS),-s ",^\(\.$(DIR)/\),.$(call mergebase,$(DIR))/$(ISA)/,p") -m \
962 . $(PKGROOT) \
963 )
964 @$(MAKECOOKIE)
965
966 DEVEL_EXECUTABLES ?= $(bindir)/.*_config $(bindir)/.*-config
967
968 # Copy
969 merge-copy-config-only:
970 $(_DBG_MERGE)(cd $(INSTALLISADIR)$(if $(ALLOW_RELOCATE),$(RELOCATE_PREFIX)); umask 022 && $(GARBIN)/pcopy \
971 -m $(foreach C,$(DEVEL_EXECUTABLES),-s ",^\(\.$C\)\$$,\1,p" ) \
972 . $(PKGROOT) \
973 )
974 @$(MAKECOOKIE)
975
976 .PHONY: remerge reset-merge reset-merge-modulated
977 remerge: reset-merge merge
978
979 reset-merge: reset-package $(addprefix reset-merge-,$(MODULATIONS)) reset-merge-license reset-merge-classutils reset-merge-checkpkgoverrides reset-merge-alternatives reset-merge-distfile-README.CSW reset-merge-distfile-changelog.CSW reset-merge-obsolete reset-merge-ap2mod reset-merge-php5ext reset-merge-src
980 rm -f $(foreach M,$(MODULATIONS),$(COOKIEDIR)/merge-$M) $(COOKIEDIR)/merge $(COOKIEDIR)/post-merge-all
981 rm -rf $(PKGROOT)
982
983 reset-merge-modulated:
984 @$(call _pmod,Reset merge state)
985 rm -f $(COOKIEDIR)/pre-merge $(COOKIEDIR)/pre-merge-* $(COOKIEDIR)/merge-* $(COOKIEDIR)/post-merge $(COOKIEDIR)/post-merge-*
986
987 # The clean rule. It must be run if you want to re-download a
988 # file after a successful checksum (or just remove the checksum
989 # cookie, but that would be lame and unportable).
990
991 clean: $(addprefix clean-,$(MODULATIONS))
992 @rm -rf $(WORKROOTDIR) $(COOKIEROOTDIR) $(DOWNLOADDIR)
993
994 clean-modulated:
995 $(call _pmod,Cleaning )
996 @rm -rf $(WORKSRC) $(EXTRACTDIR) \
997 $(SCRATCHDIR) $(SCRATCHDIR)-$(COOKIEDIR) \
998 $(SCRATCHDIR)-build $(SCRATCHDIR)-$(COOKIEROOTDIR) \
999 $(LOGDIR) *~
1000 @rm -rf $(COOKIEDIR)
1001
1002
1003 SRC_CLEAN_TARGET ?= clean
1004 clean-source:
1005 @if test -d $(WORKSRC) ; then \
1006 ( $(MAKE) -C $(WORKSRC) $(SRC_CLEAN_TARGET) || true ) ; \
1007 fi
1008
1009 # Remove specified files/directories
1010 clean-dirs:
1011 @for target in "" $(REMOVE_DIRS) ; do \
1012 test -z "$$target" && continue ; \
1013 rm -rf $$target ; \
1014 done ; \
1015
1016 # Clean an image
1017 imageclean:
1018 @echo " ==> Removing $(COOKIEDIR)"
1019 @-rm -rf $(COOKIEDIR)
1020 @echo " ==> Removing $(WORKDIR)"
1021 @-rm -rf tmp-deleteme-workdir
1022 @-mv $(WORKDIR) tmp-deleteme-workdir
1023 @-rm -rf tmp-deleteme-workdir &
1024
1025 spotless: imageclean
1026 @echo " ==> Removing $(DESTDIR)"
1027 @-rm -rf work-old
1028 @-mv work work-old
1029 @-rm -rf work-old &
1030
1031 # Print package dependencies
1032 PKGDEP_LIST = $(filter-out $(BUILDDEPS),$(DEPEND_LIST))
1033 printdepends:
1034 @for depend in "" $(PKGDEP_LIST) ; do \
1035 test -z "$$depend" && continue ; \
1036 echo " $$depend" ; \
1037 if test -n "$(DEPFILE)" ; then \
1038 check_pkgdb -o $(DEPFILE) $$depend ; \
1039 else \
1040 check_pkgdb $$depend ; \
1041 fi ; \
1042 done
1043
1044 # Update inter-package depends
1045 makedepend:
1046 $(_DBG)for gspec in `gfind $(CURDIR) -type f -name '*.gspec' | ggrep files`; do \
1047 pkgname=`basename $$gspec .gspec` ; \
1048 pkgfiles=`dirname $$gspec` ; \
1049 pkgdir=`dirname $$pkgfiles` ; \
1050 pkgbuild=`basename $$pkgdir` ; \
1051 pkgdep="$$pkgname.depend" ; \
1052 echo " ==> $$pkgbuild ($$pkgname)" ; \
1053 ( cd $$pkgdir ; \
1054 rm -f /tmp/$$pkgdep ; \
1055 if test -f $$pkgfiles/$$pkgdep ; then \
1056 cat $$pkgfiles/$$pkgdep > /tmp/$$pkgdep ; \
1057 fi ; \
1058 DEPFILE=/tmp/$$pkgdep $(MAKE) printdepends ; \
1059 if test -f /tmp/$$pkgdep ; then \
1060 sort /tmp/$$pkgdep | uniq > $$pkgfiles/$$pkgname.depend ; \
1061 fi ) ; \
1062 done
1063
1064 buildstatus:
1065
1066 love:
1067 @echo "not war!"
1068
1069 # these targets do not have actual corresponding files
1070 .PHONY: all fetch-list beaujolais fetch-p checksum-p extract-p patch-p configure-p build-p install-p package-p love
1071
1072 # apparently this makes all previous rules non-parallelizable,
1073 # but the actual builds of the packages will be, according to
1074 # jdub.
1075 .NOTPARALLEL: