RepoConfigLoader: PORTDIR/repos.conf interaction
[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.conf.example 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 -d -m$(DIRMODE) "$(DESTDIR)$(portage_setsdir)"; \
86         cd "$(S)/cnf/sets"; \
87         install -m$(INSMODE) *.conf "$(DESTDIR)$(portage_setsdir)"; \
88         \
89         install -d -m$(DIRMODE) "$(DESTDIR)$(sysconfdir)/logrotate.d"; \
90         cd "$(srcdir)/cnf/logrotate.d"; \
91         install -m$(INSMODE) $(LOGROTATE_FILES) \
92                 "$(DESTDIR)$(sysconfdir)/logrotate.d"; \
93         \
94         for x in $$(cd "$(srcdir)" && find bin -type d) ; do \
95                 cd "$(srcdir)/$$x"; \
96                 install -d -m$(DIRMODE) "$(DESTDIR)$(portage_base)/$$x"; \
97                 files=$$(find . -mindepth 1 -maxdepth 1 -type f ! -type l); \
98                 if [ -n "$$files" ] ; then \
99                         install -m$(EXEMODE) $$files \
100                                 "$(DESTDIR)$(portage_base)/$$x"; \
101                 fi; \
102                 symlinks=$$(find . -mindepth 1 -maxdepth 1 -type l); \
103                 if [ -n "$$symlinks" ] ; then \
104                         cp -P $$symlinks "$(DESTDIR)$(portage_base)/$$x"; \
105                 fi; \
106         done; \
107         \
108         for x in $$(cd "$(srcdir)" && find pym/* -type d \
109                 ! -path "pym/portage/tests*") ; do \
110                 cd "$(srcdir)/$$x"; \
111                 files=$$(echo *.py); \
112                 if [ -z "$$files" ] || [ "$$files" = "*.py" ]; then \
113                         # __pycache__ directories contain no py files \
114                         continue; \
115                 fi; \
116                 install -d -m$(DIRMODE) "$(DESTDIR)$(portage_base)/$$x"; \
117                 install -m$(INSMODE) $$files "$(DESTDIR)$(portage_base)/$$x"; \
118         done; \
119         \
120         install -d -m$(DIRMODE) "$(DESTDIR)$(bindir)"; \
121         relative_path=".."; \
122         x=$(bindir) ; \
123         y="$(portage_base)"; \
124         if [ "$${x#$(prefix)}" != "$$x" ] && \
125                 [ "$${y#$(prefix)}" != "$$y" ]; then \
126                 x=$${x#$(prefix)}; \
127                 y=$${y#$(prefix)}; \
128         fi; \
129         x=$${x%/*}; \
130         while [ -n "$$x" ] ; do \
131                 relative_path=$${relative_path}/..; \
132                 x=$${x%/*}; \
133         done; \
134         relative_path=$$relative_path$$y; \
135         for x in $(BINDIR_FILES) ; do \
136                 ln -sf "$$relative_path/bin/$$x" \
137                         "$(DESTDIR)$(bindir)/$$x"; \
138         done; \
139         \
140         install -d -m$(DIRMODE) "$(DESTDIR)$(sbindir)"; \
141         relative_path=".."; \
142         x=$(sbindir) ; \
143         y="$(portage_base)"; \
144         if [ "$${x#$(prefix)}" != "$$x" ] && \
145                 [ "$${y#$(prefix)}" != "$$y" ]; then \
146                 x=$${x#$(prefix)}; \
147                 y=$${y#$(prefix)}; \
148         fi; \
149         x=$${x%/*}; \
150         while [ -n "$$x" ] ; do \
151                 relative_path=$${relative_path}/..; \
152                 x=$${x%/*}; \
153         done; \
154         relative_path=$$relative_path$$y; \
155         for x in $(SBINDIR_FILES) ; do \
156                 ln -sf "$$relative_path/bin/$$x" \
157                         "$(DESTDIR)$(sbindir)/$$x"; \
158         done; \
159         \
160         ln -sf "$$relative_path/bin/env-update" \
161                 "$(DESTDIR)$(sbindir)/update-env"; \
162         ln -sf "$$relative_path/bin/etc-update" \
163                 "$(DESTDIR)$(sbindir)/update-etc"; \
164         \
165         # We install some minimal tests for use as a preinst sanity check. \
166         # These tests must be able to run without a full source tree and \
167         # without relying on a previous portage instance being installed. \
168         install -d -m$(DIRMODE) \
169                 "$(DESTDIR)$(portage_base)/pym/portage/tests"; \
170         install -m$(EXEMODE) "$(srcdir)/pym/portage/tests/runTests" \
171                 "$(DESTDIR)$(portage_base)/pym/portage/tests"; \
172         cd "$(srcdir)/pym/portage/tests"; \
173         install -m$(INSMODE) *.py \
174                 "$(DESTDIR)$(portage_base)/pym/portage/tests"; \
175         install -d -m$(DIRMODE) \
176                 "$(DESTDIR)$(portage_base)/pym/portage/tests/lint"; \
177         cd "$(srcdir)/pym/portage/tests/lint"; \
178         install -m$(INSMODE) *.py __test__ \
179                 "$(DESTDIR)$(portage_base)/pym/portage/tests/lint"; \
180         \
181         install -d -m$(DIRMODE) "$(DESTDIR)$(docdir)"; \
182         cd "$(srcdir)"; \
183         install -m $(INSMODE) $(DOCS) "$(DESTDIR)$(docdir)"; \
184         \
185         for x in "" $(LINGUAS); do \
186                 for y in 1 5 ; do \
187                         if [ -d "$(srcdir)/man/$$x" ]; then \
188                                 cd "$(srcdir)/man/$$x"; \
189                                 files=$$(echo *.$$y); \
190                                 if [ -z "$$files" ] || [ "$$files" = "*.$$y" ]; then \
191                                         continue; \
192                                 fi; \
193                                 install -d -m$(DIRMODE) "$(DESTDIR)$(mandir)/$$x/man$$y"; \
194                                 install -m$(INSMODE) *.$$y "$(DESTDIR)$(mandir)/$$x/man$$y"; \
195                         fi; \
196                 done; \
197         done; \
198         \
199         if [ -f "$(srcdir)/doc/portage.html" ] ; then \
200                 install -d -m$(DIRMODE) "$(DESTDIR)$(htmldir)"; \
201                 cd "$(srcdir)/doc"; \
202                 install -m$(INSMODE) *.html "$(DESTDIR)$(htmldir)"; \
203         fi; \
204         \
205         if [ -d "$(WORKDIR)/epydoc" ] ; then \
206                 install -d -m$(DIRMODE) "$(DESTDIR)$(htmldir)"; \
207                 cp -pPR "$(WORKDIR)/epydoc" \
208                         "$(DESTDIR)$(htmldir)/api"; \
209                 cd "$(DESTDIR)$(htmldir)/api"; \
210                 find . -type d | xargs chmod $(DIRMODE); \
211                 find . -type f | xargs chmod $(INSMODE); \
212         fi; \
213
214 clean:
215         set -e; \
216         $(MAKE) -C "$(srcdir)/doc" clean; \
217         rm -rf "$(srcdir)/pym/pysqlite2.py"* \
218                 "$(WORKDIR)/epydoc"; \
219
220 .PHONY: all clean docbook epydoc install test