summaryrefslogtreecommitdiff
path: root/cpan.am
blob: 0cf4967adc892fcbcbc4ed9d86c2810ab5141d13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
CPAN_DIST_NAME = $(PACKAGE_CPAN_NAME)
CPAN_DIST_VERSION = $(PACKAGE_VERSION)
CPAN_DIST = $(CPAN_DIST_NAME)-$(CPAN_DIST_VERSION)
CPAN_DIST_ARCHIVE = $(CPAN_DIST).tar.gz

dist-cpan:
	: # Create the CPAN source tree.
	mkdir -p $(CPAN_DIST)
	mkdir -p $(CPAN_DIST)/lib
	mkdir -p $(CPAN_DIST)/t
	cp -fpR $(top_srcdir)/data $(CPAN_DIST)
	cp -fpR $(top_srcdir)/t/* \
	         $(top_srcdir)/scripts/t/Dpkg* \
	         $(top_srcdir)/scripts/t/origins \
	         $(CPAN_DIST)/t
	$(do_perl_subst) <$(top_srcdir)/scripts/Dpkg.pm \
	                 >$(CPAN_DIST)/lib/Dpkg.pm
	cp -fpR $(top_srcdir)/scripts/Dpkg.pm \
	         $(top_srcdir)/scripts/Dpkg \
	         $(CPAN_DIST)/lib/
	cp -fpR $(top_srcdir)/scripts/Test $(CPAN_DIST)/lib/
	cp -fpR $(top_srcdir)/scripts/Build.PL $(CPAN_DIST)

	: # Fix permissions of the distributed files.
	chmod a+x $(CPAN_DIST)/Build.PL
	find $(CPAN_DIST) \
	       -type d ! -perm 755 -exec chmod u+rwx,go+rx {} ';' -o \
	     ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
	     ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
	     ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; || \
	  chmod -R a+r $(CPAN_DIST)

	: # Prepare the CPAN distribution.
	cd $(CPAN_DIST) && ./Build.PL
	cd $(CPAN_DIST) && ./Build manifest
	cd $(CPAN_DIST) && ./Build distsign

	: # Pack the CPAN distribution.
	$(TAR) -caf $(CPAN_DIST_ARCHIVE) -C $(CPAN_DIST) -Hustar \
	  --sort=name --owner=root:0 --group=root:0 $(CPAN_DIST)

	: # Cleanup the CPAN source tree.
	find $(CPAN_DIST) -type d ! -perm -200 -exec chmod u+w {} ';'
	rm -rf $(CPAN_DIST)

# Ignore the CPAN archive for distcleancheck.
distcleancheck_listfiles = \
	find -type f \( -name $(CPAN_DIST_ARCHIVE) -o -print \)