]> git.donarmstrong.com Git - debian/debian-policy.git/blob - debian/rules
various optimizations
[debian/debian-policy.git] / debian / rules
1 #!/usr/bin/make -f
2 ############################ -*- Mode: Makefile -*- ###########################
3 ## rules ---
4 ## Author           : Manoj Srivastava ( srivasta@tiamat.datasync.com )
5 ## Created On       : Thu Oct 29 15:35:55 1998
6 ## Created On Node  : tiamat.datasync.com
7 ## Last Modified By : Manoj Srivastava
8 ## Last Modified On : Sat Oct 26 12:29:03 2002
9 ## Last Machine Used: glaurung.green-gryphon.com
10 ## Update Count     : 58
11 ## Status           : Unknown, Use with caution!
12 ## HISTORY          :
13 ## Description      :
14 ## $Id$
15 ###############################################################################
16
17 # ifdef ARCH
18 #   ha:=-a$(ARCH)
19 # endif
20
21 # set the dpkg-architecture vars; but we don't use them, so we'll comment out
22 # export DEB_BUILD_ARCH      := $(shell dpkg-architecture $(ha) -qDEB_BUILD_ARCH)
23 # export DEB_BUILD_GNU_CPU   := $(shell dpkg-architecture $(ha) -qDEB_BUILD_GNU_CPU)
24 # export DEB_BUILD_GNU_SYSTEM:= $(shell dpkg-architecture $(ha) -qDEB_BUILD_GNU_SYSTEM)
25 # export DEB_BUILD_GNU_TYPE  := $(shell dpkg-architecture $(ha) -qDEB_BUILD_GNU_TYPE)
26 # export DEB_HOST_ARCH       := $(shell dpkg-architecture $(ha) -qDEB_HOST_ARCH)
27 # export DEB_HOST_GNU_CPU    := $(shell dpkg-architecture $(ha) -qDEB_HOST_GNU_CPU)
28 # export DEB_HOST_GNU_SYSTEM := $(shell dpkg-architecture $(ha) -qDEB_HOST_GNU_SYSTEM)
29 # export DEB_HOST_GNU_TYPE   := $(shell dpkg-architecture $(ha) -qDEB_HOST_GNU_TYPE)
30
31
32 # The name of the package (for example, `emacs').
33 package := $(shell grep Source debian/control | sed 's/^Source: //')
34 # arch  := $(shell dpkg --print-installation-architecture)
35 date    := $(shell date +"%Y-%m-%d")
36 version := $(shell awk -F '[()]' '/^$(package)/{ print $$2; exit }' debian/changelog)
37
38 # Location of the source dir
39 SRCTOP    := $(CURDIR)
40 TMPTOP    := $(SRCTOP)/debian/tmp
41 DOCDIR    := $(TMPTOP)/usr/share/doc/$(package)
42 LIBDIR    := $(TMPTOP)/usr/share/doc-base
43
44
45 SGML_FILES      = policy menu-policy mime-policy policy-process perl-policy
46 DESC_FILES      = debian-policy debian-menu-policy debian-perl-policy \
47                   debian-mime-policy debian-policy-process debconf-spec \
48                   fhs
49
50 # While we have two versions of the FHS installed in the source package,
51 # we need to modify this to handle it.  This is the easiest way to do it.
52 # FHS_ARCHIVE := $(wildcard fhs*.tar.gz)
53 # And with version 2.1, we have to build the text and dvi versions
54 # ourselves :-(
55 FHS_ARCHIVE  :=  fhs-2.1-source.tar.gz
56 FHS_HTML     := fhs-2.1.html.tar.gz
57 FHS_FILES    := fhs/fhs.ps fhs/fhs.txt fhs/fhs.pdf
58 FHS_BYHAND   := fhs-2.1.html.tar.gz fhs/fhs.txt
59 # FSSTND_FILES := FSSTND-FAQ fsstnd-1.2.dvi.gz fsstnd-1.2.ps.gz fsstnd-1.2.txt.gz
60 POLICY_FILES = $(SGML_FILES:=.sgml) $(SGML_FILES:=.txt.gz) \
61                virtual-package-names-list.txt \
62                upgrading-checklist.txt libc6-migration.txt version.ent \
63                debconf_spec/debconf_specification.html \
64                debconf_spec/debconf_specification.txt.gz
65 BYHAND_FILES = $(SGML_FILES:=.txt.gz) $(SGML_FILES:=.html.tar.gz) \
66                debconf_spec/debconf_specification.txt.gz \
67                debconf_spec/debconf_specification.html \
68                libc6-migration.txt virtual-package-names-list.txt \
69                policy.ps.gz policy.pdf.gz upgrading-checklist.txt \
70                $(FHS_BYHAND)
71
72 FILES_TO_CLEAN  = debian/files debian/buildinfo  debian/substvars \
73                   debian/postinst debian/prerm \
74                   version.ent upgrading-checklist.txt \
75                   $(SGML_FILES:=.txt.gz) $(SGML_FILES:=.html.tar.gz) \
76                   policy.pdf.gz policy.ps.gz \
77                   debconf_specification.xml.tar.gz
78
79 STAMPS_TO_CLEAN = stamp-policy stamp-build
80 DIRS_TO_CLEAN   = debian/tmp fhs $(SGML_FILES:=.html)
81
82
83 install_file   = /usr/bin/install -p    -o root -g root  -m  644
84 install_program= /usr/bin/install -p    -o root -g root  -m  755
85 make_directory = /usr/bin/install -p -d -o root -g root  -m  755
86
87
88 all build: stamp-build
89 stamp-build: version.ent
90         $(checkdir)
91         @set -ex; \
92         for file in $(SGML_FILES); do \
93           nsgmls -gues $$file.sgml; \
94           debiandoc2html $$file.sgml; \
95           debiandoc2text $$file.sgml; \
96           if [ -f $$file.text ]; then mv $$file.text $$file.txt; fi; \
97           gzip -f9 $$file.txt; \
98           tar -cf $$file.html.tar $$file.html; \
99           gzip -f9 $$file.html.tar; \
100         done
101         tar -zxf $(FHS_ARCHIVE)
102         # Need to use a patched tmac.m macro file if we're using a pre-1.16
103         # groff; version 1.16 is apparently fixed
104         if dpkg --compare-versions "$(shell dpkg -s groff | sed -n -e 's/Version: //p')" lt 1.16; then \
105             cp /usr/share/groff/tmac/tmac.m fhs && \
106             cd fhs && patch -p1 < ../mm1.32-patch; \
107         fi
108         # The extra '.' in the tmac path won't harm if unnecessary
109         GROFF_TMAC_PATH=. GROFF_NO_SGR=1 $(MAKE) -C fhs fhs.ps fhs.pdf fhs.txt
110         links -dump fhs-changes-2.1.html | perl -pe 's/[\r\0]//g' > \
111                     fhs/fhs-changes-2.1.txt
112         links -dump upgrading-checklist.html | perl -pe 's/[\r\0]//g' > \
113                     upgrading-checklist.txt
114         $(MAKE) -C debconf_spec all
115         gzip -9f debconf_spec/debconf_specification.txt
116         touch stamp-build
117
118 configure: version.ent
119 version.ent: $(SGML_FILES:=.sgml) $(DESC_FILES:=.desc) \
120   upgrading-checklist.html debian/changelog
121         rm -f $@
122         echo "<!entity version \"$(version)\">" >> $@
123         echo "<!entity date    \"$(date)\">"    >> $@
124         touch $@
125
126 clean:
127 # Undoes the effect of `make -f debian/rules build'.
128         $(checkdir)
129         $(MAKE) -C debconf_spec clean
130         rm -f  $(FILES_TO_CLEAN) $(STAMPS_TO_CLEAN)
131         rm -rf $(DIRS_TO_CLEAN)
132         rm -f core `find . \( -name '*.orig' -o -name '*.rej' -o \
133           -name '*~' -o -name '*.bak' -o -name '#*#' -o \
134           -name '.*.orig' -o -name '.*.rej' -o -name '.SUMS' -o \
135           -size 0 \) -print` TAGS
136
137
138 binary:         binary-indep binary-arch
139 binary-arch:    build
140         $(checkdir)
141 # There are no architecture-dependent files to be uploaded
142 # generated by this package.  If there were any they would be
143 # made here.
144
145 binary-indep:   stamp-policy
146 stamp-policy:  build
147         @test $$(id | sed -e 's/(.*$$//' -e 's/^uid=//') || \
148                 (echo need root priviledges; exit 1)
149         $(checkdir)
150 #       This is unnecessary; commenting out
151 #       test -f stamp-build     || $(MAKE) -f        debian/rules build
152         -rm -rf                 $(TMPTOP)
153         $(make_directory)       $(TMPTOP)/DEBIAN
154 #       $(make_directory)       $(DOCDIR)/fsstnd
155         $(make_directory)       $(DOCDIR)/fhs
156         $(make_directory)       $(LIBDIR)
157         # create a substvar to reference from debian/control so that
158         # we don't hardcode the policy compliance of the policy
159         # package.  I guess some might question this but I take it as
160         # a given that the debian-policy pkg must always comply with
161         # itself...
162         echo "debian-policy:Version=$(version)"      > debian/substvars
163         $(install_file)     $(POLICY_FILES)          $(DOCDIR)/
164 #       $(install_file)     $(FSSTND_FILES)          $(DOCDIR)/fsstnd/
165         $(install_file)     $(FHS_FILES)             $(DOCDIR)/fhs/
166         $(install_file)     debian/changelog         $(DOCDIR)/
167         # Be more specific with file compression
168         gzip -f9            $(DOCDIR)/*.txt $(DOCDIR)/*.sgml \
169                                 $(DOCDIR)/fhs/* $(DOCDIR)/changelog
170         $(install_file)     debian/copyright         $(DOCDIR)/
171         GZIP=-9 cd debconf_spec && \
172           tar -zcf ../debconf_specification.xml.tar.gz *
173         $(install_file)     debconf_specification.xml.tar.gz $(DOCDIR)/
174         @set -ex; \
175         for file in $(DESC_FILES); do \
176           $(install_file) $$file.desc $(LIBDIR)/$$file; \
177         done
178         @set -ex; \
179         for file in $(SGML_FILES); do \
180           tar -C $(DOCDIR) -zxf $$file.html.tar.gz; \
181         done
182         tar -C $(DOCDIR)/fhs -zxf $(FHS_HTML)
183         sed -e 's/#PACKAGE#/$(package)/g' debian/postinst.in > debian/postinst
184         sed -e 's/#PACKAGE#/$(package)/g' debian/prerm.in > debian/prerm
185         $(install_program)  debian/postinst          debian/tmp/DEBIAN/
186         $(install_program)  debian/prerm             debian/tmp/DEBIAN/
187         dpkg-gencontrol     -pdebian-policy -Pdebian/tmp -isp
188         chown               -R root:root debian/tmp
189         chmod               -R go=rX debian/tmp
190         dpkg                --build debian/tmp ..
191         debiandoc2latexps   policy.sgml
192         gzip -9f            policy.ps
193         debiandoc2latexpdf  policy.sgml
194         gzip -9f            policy.pdf
195         set -e; \
196         for i in            $(BYHAND_FILES); do                          \
197           $(install_file)   $$i            ..                          ; \
198           dpkg-distaddfile  -fdebian/files `basename $$i`     byhand - ; \
199         done
200         touch               stamp-policy
201
202
203 define checkdir
204         test -f debian/rules -a -f policy.sgml
205 endef
206
207 source diff:
208         @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
209
210 .PHONY: configure build binary binary-arch binary-indep clean checkroot
211
212 #Local variables:
213 #mode: makefile
214 #End: