Add to git.
[makeplus.git] / dist.mk
1 # This is make+. Make+ is a set of scripts which enhance GNU make and
2 # let ou build RPMs, and other packages types with just one control
3 # file. Read more at http://www.annexia.org/freeware/makeplus/
4 #
5 # The original author is Richard W.M. Jones <rich@annexia.org>.
6 #
7 # This software has been explicitly placed in the PUBLIC DOMAIN.  You
8 # do not need any sort of license or agreement to use or copy this
9 # software. You may also copyright this software yourself, and/or
10 # relicense it under any terms you want, at any time and at no cost.
11 # This allows you (among other things) to include this software with
12 # other packages so that the user does not need to download and
13 # install make+ separately.
14
15 # The user can add more exclude patterns by adding to or overriding
16 # this variable. Each pattern is a wildcard passed to the -X option
17 # of tar.
18 MP_DIST_EXCLUDE = build-* makeplus-* CVS .\#* *~ *.old core
19
20 # Default name for the source distribution.
21 MP_SRC_DIST     = $(PACKAGE)-$(VERSION).tar.gz
22
23 # Default name for the binary distribution.
24 MP_BIN_DIST     = $(PACKAGE)-$(VERSION).bin.tar.gz
25
26 # Default name for the binary manifest.
27 MP_BIN_MANIFEST = MANIFEST.bin
28
29 # If set then bundle a copy of make+ with source distributions.
30 # (Note: Doesn't work on platforms with losing non-GNU 'tar').
31 MP_BUNDLE       = 1
32
33 # Build a source distribution.
34 dist: mp-dist.ex
35         rm -rf $(PACKAGE)-$(VERSION)
36         rm -f $(MP_SRC_DIST)
37         mkdir $(PACKAGE)-$(VERSION)
38         tar -cf - -X mp-dist.ex $(EXTRA_DIST) -C .. . | \
39           tar -xf - -C $(PACKAGE)-$(VERSION)
40         if [ -n "$(MP_BUNDLE)" -a -r "$(MAKEPLUS_HOME)/makeplus.tar.gz" ]; \
41         then \
42           gzip -d -c $(MAKEPLUS_HOME)/makeplus.tar.gz | \
43           tar -xf - -C $(PACKAGE)-$(VERSION); \
44           cp $(MAKEPLUS_HOME)/README.make+_for_bundles \
45             $(PACKAGE)-$(VERSION)/README.make+; \
46         fi
47         tar -cf - $(PACKAGE)-$(VERSION) | gzip --best > $(MP_SRC_DIST)
48         rm -rf $(PACKAGE)-$(VERSION)
49         rm mp-dist.ex
50
51 mp-dist.ex:
52         @for ex in $(MP_DIST_EXCLUDE); do echo $$ex; done > mp-dist.ex
53
54 # Build a binary distribution.
55 # XXX What's the standard name for this target?
56 bindist:
57         rm -rf mp-bindist
58         rm -f $(MP_BIN_DIST)
59         mkdir mp-bindist
60         $(MAKE) -f $(srcdir)/$(_mp_makefile) DESTDIR=mp-bindist install
61         tar -cf - -C mp-bindist . | gzip --best > $(MP_BIN_DIST)
62         rm -rf mp-bindist
63
64 # Build a manifest for the binary distribution.
65 mp_manifest_bin:
66         rm -rf mp-bindist
67         mkdir mp-bindist
68         $(MAKE) -f $(srcdir)/$(_mp_makefile) DESTDIR=mp-bindist install
69         find mp-bindist \! -type d | sed 's|^mp-bindist||' > $(MP_BIN_MANIFEST)
70         rm -rf mp-bindist
71
72 .PHONY: dist bindist mp_manifest_bin