portage.repository.config.RepoConfigLoader.config_string(): Rename a variable.
[portage.git] / Makefile
1 SHELL = /bin/sh
2 PN ?= portage
3 PF ?= portage
4 HOMEPAGE ?= http://www.gentoo.org/proj/en/portage/index.xml
5 PWD ?= $(shell pwd)
6 S ?= $(PWD)
7 WORKDIR ?= $(PWD)
8 DESTDIR = $(PWD)/image/
9 srcdir = $(S)
10 prefix = /usr
11 sysconfdir = /etc
12 exec_prefix = $(prefix)
13 bindir = $(exec_prefix)/bin
14 sbindir = $(exec_prefix)/sbin
15 libdir = $(exec_prefix)/lib
16 datarootdir = $(prefix)/share
17 datadir = $(datarootdir)
18 mandir = $(datarootdir)/man
19 docdir = $(datarootdir)/doc/$(PF)
20 htmldir = $(docdir)/html
21 portage_datadir = $(datarootdir)/$(PN)
22 portage_confdir = $(portage_datadir)/config
23 portage_setsdir = $(portage_confdir)/sets
24 portage_base = $(libdir)/$(PN)
25 EPYDOC_OPTS = -qqqqq --no-frames --show-imports
26 INSMODE = 0644
27 EXEMODE = 0755
28 DIRMODE = 0755
29 SYSCONFDIR_FILES = etc-update.conf dispatch-conf.conf
30 PORTAGE_CONFDIR_FILES = make.globals repos.conf
31 LOGROTATE_FILES = elog-save-summary
32 BINDIR_FILES = ebuild egencache emerge emerge-webrsync \
33         emirrordist portageq quickpkg repoman
34 SBINDIR_FILES = archive-conf dispatch-conf emaint \
35         env-update etc-update fixpackages regenworld
36 DOCS = ChangeLog NEWS RELEASE-NOTES
37 LINGUAS ?= $(shell cd "$(srcdir)/man" && find -mindepth 1 -type d)
38
39 ifdef PYTHONPATH
40         PYTHONPATH := $(srcdir)/pym:$(PYTHONPATH)
41 else
42         PYTHONPATH := $(srcdir)/pym
43 endif
44
45 all: docbook epydoc
46
47 docbook:
48         set -e; \
49         touch "$(srcdir)/doc/fragment/date"; \
50         $(MAKE) -C "$(srcdir)/doc" xhtml xhtml-nochunks
51
52 epydoc:
53         set -e; \
54         # workaround for bug 282760 \
55         touch "$(srcdir)/pym/pysqlite2.py"; \
56         env PYTHONPATH="$(PYTHONPATH)" epydoc \
57                 -o "$(WORKDIR)/epydoc" \
58                 --name $(PN) \
59                 --url "$(HOMEPAGE)" \
60                 $(EPYDOC_OPTS) \
61                 $$(cd "$(srcdir)" && find pym -name '*.py' | sed \
62                 -e s:/__init__.py$$:: \
63                 -e s:\.py$$:: \
64                 -e s:^pym/:: \
65                 -e s:/:.:g \
66                 | sort); \
67         rm -f "$(srcdir)/pym/pysqlite2.py"* \
68                 "$(WORKDIR)/epydoc/pysqlite2-"* \
69                 "$(WORKDIR)/epydoc/api-objects.txt"; \
70
71 test:
72         set -e; \
73         "$(srcdir)/pym/portage/tests/runTests"; \
74
75 install:
76         set -e; \
77         cd "$(srcdir)/cnf"; \
78         install -d -m$(DIRMODE) "$(DESTDIR)$(sysconfdir)"; \
79         install -m$(INSMODE) $(SYSCONFDIR_FILES) "$(DESTDIR)$(sysconfdir)"; \
80         \
81         install -d -m$(DIRMODE) "$(DESTDIR)$(portage_confdir)"; \
82         cd "$(srcdir)/cnf"; \
83         install -m$(INSMODE) $(PORTAGE_CONFDIR_FILES) \
84                 "$(DESTDIR)$(portage_confdir)"; \
85         install -m$(INSMODE) "$(srcdir)/cnf/make.conf" \
86                 "$(DESTDIR)$(portage_confdir)/make.conf.example"; \
87         \
88         install -d -m$(DIRMODE) "$(DESTDIR)$(portage_setsdir)"; \
89         cd "$(S)/cnf/sets"; \
90         install -m$(INSMODE) *.conf "$(DESTDIR)$(portage_setsdir)"; \
91         \
92         install -d -m$(DIRMODE) "$(DESTDIR)$(sysconfdir)/logrotate.d"; \
93         cd "$(srcdir)/cnf/logrotate.d"; \
94         install -m$(INSMODE) $(LOGROTATE_FILES) \
95                 "$(DESTDIR)$(sysconfdir)/logrotate.d"; \
96         \
97         for x in $$(cd "$(srcdir)" && find bin -type d) ; do \
98                 cd "$(srcdir)/$$x"; \
99                 install -d -m$(DIRMODE) "$(DESTDIR)$(portage_base)/$$x"; \
100                 files=$$(find . -mindepth 1 -maxdepth 1 -type f ! -type l); \
101                 if [ -n "$$files" ] ; then \
102                         install -m$(EXEMODE) $$files \
103                                 "$(DESTDIR)$(portage_base)/$$x"; \
104                 fi; \
105                 symlinks=$$(find . -mindepth 1 -maxdepth 1 -type l); \
106                 if [ -n "$$symlinks" ] ; then \
107                         cp -P $$symlinks "$(DESTDIR)$(portage_base)/$$x"; \
108                 fi; \
109         done; \
110         \
111         for x in $$(cd "$(srcdir)" && find pym/* -type d \
112                 ! -path "pym/portage/tests*") ; do \
113                 cd "$(srcdir)/$$x"; \
114                 files=$$(echo *.py); \
115                 if [ -z "$$files" ] || [ "$$files" = "*.py" ]; then \
116                         # __pycache__ directories contain no py files \
117                         continue; \
118                 fi; \
119                 install -d -m$(DIRMODE) "$(DESTDIR)$(portage_base)/$$x"; \
120                 install -m$(INSMODE) $$files "$(DESTDIR)$(portage_base)/$$x"; \
121         done; \
122         \
123         install -d -m$(DIRMODE) "$(DESTDIR)$(bindir)"; \
124         relative_path=".."; \
125         x=$(bindir) ; \
126         y="$(portage_base)"; \
127         if [ "$${x#$(prefix)}" != "$$x" ] && \
128                 [ "$${y#$(prefix)}" != "$$y" ]; then \
129                 x=$${x#$(prefix)}; \
130                 y=$${y#$(prefix)}; \
131         fi; \
132         x=$${x%/*}; \
133         while [ -n "$$x" ] ; do \
134                 relative_path=$${relative_path}/..; \
135                 x=$${x%/*}; \
136         done; \
137         relative_path=$$relative_path$$y; \
138         for x in $(BINDIR_FILES) ; do \
139                 ln -sf "$$relative_path/bin/$$x" \
140                         "$(DESTDIR)$(bindir)/$$x"; \
141         done; \
142         \
143         install -d -m$(DIRMODE) "$(DESTDIR)$(sbindir)"; \
144         relative_path=".."; \
145         x=$(sbindir) ; \
146         y="$(portage_base)"; \
147         if [ "$${x#$(prefix)}" != "$$x" ] && \
148                 [ "$${y#$(prefix)}" != "$$y" ]; then \
149                 x=$${x#$(prefix)}; \
150                 y=$${y#$(prefix)}; \
151         fi; \
152         x=$${x%/*}; \
153         while [ -n "$$x" ] ; do \
154                 relative_path=$${relative_path}/..; \
155                 x=$${x%/*}; \
156         done; \
157         relative_path=$$relative_path$$y; \
158         for x in $(SBINDIR_FILES) ; do \
159                 ln -sf "$$relative_path/bin/$$x" \
160                         "$(DESTDIR)$(sbindir)/$$x"; \
161         done; \
162         \
163         ln -sf "$$relative_path/bin/env-update" \
164                 "$(DESTDIR)$(sbindir)/update-env"; \
165         ln -sf "$$relative_path/bin/etc-update" \
166                 "$(DESTDIR)$(sbindir)/update-etc"; \
167         \
168         # We install some minimal tests for use as a preinst sanity check. \
169         # These tests must be able to run without a full source tree and \
170         # without relying on a previous portage instance being installed. \
171         install -d -m$(DIRMODE) \
172                 "$(DESTDIR)$(portage_base)/pym/portage/tests"; \
173         install -m$(EXEMODE) "$(srcdir)/pym/portage/tests/runTests" \
174                 "$(DESTDIR)$(portage_base)/pym/portage/tests"; \
175         cd "$(srcdir)/pym/portage/tests"; \
176         install -m$(INSMODE) *.py \
177                 "$(DESTDIR)$(portage_base)/pym/portage/tests"; \
178         install -d -m$(DIRMODE) \
179                 "$(DESTDIR)$(portage_base)/pym/portage/tests/lint"; \
180         cd "$(srcdir)/pym/portage/tests/lint"; \
181         install -m$(INSMODE) *.py __test__ \
182                 "$(DESTDIR)$(portage_base)/pym/portage/tests/lint"; \
183         \
184         install -d -m$(DIRMODE) "$(DESTDIR)$(docdir)"; \
185         cd "$(srcdir)"; \
186         install -m $(INSMODE) $(DOCS) "$(DESTDIR)$(docdir)"; \
187         \
188         for x in "" $(LINGUAS); do \
189                 for y in 1 5 ; do \
190                         if [ -d "$(srcdir)/man/$$x" ]; then \
191                                 cd "$(srcdir)/man/$$x"; \
192                                 files=$$(echo *.$$y); \
193                                 if [ -z "$$files" ] || [ "$$files" = "*.$$y" ]; then \
194                                         continue; \
195                                 fi; \
196                                 install -d -m$(DIRMODE) "$(DESTDIR)$(mandir)/$$x/man$$y"; \
197                                 install -m$(INSMODE) *.$$y "$(DESTDIR)$(mandir)/$$x/man$$y"; \
198                         fi; \
199                 done; \
200         done; \
201         \
202         if [ -f "$(srcdir)/doc/portage.html" ] ; then \
203                 install -d -m$(DIRMODE) "$(DESTDIR)$(htmldir)"; \
204                 cd "$(srcdir)/doc"; \
205                 install -m$(INSMODE) *.html "$(DESTDIR)$(htmldir)"; \
206         fi; \
207         \
208         if [ -d "$(WORKDIR)/epydoc" ] ; then \
209                 install -d -m$(DIRMODE) "$(DESTDIR)$(htmldir)"; \
210                 cp -pPR "$(WORKDIR)/epydoc" \
211                         "$(DESTDIR)$(htmldir)/api"; \
212                 cd "$(DESTDIR)$(htmldir)/api"; \
213                 find . -type d | xargs chmod $(DIRMODE); \
214                 find . -type f | xargs chmod $(INSMODE); \
215         fi; \
216
217 clean:
218         set -e; \
219         $(MAKE) -C "$(srcdir)/doc" clean; \
220         rm -rf "$(srcdir)/pym/pysqlite2.py"* \
221                 "$(WORKDIR)/epydoc"; \
222
223 .PHONY: all clean docbook epydoc install test