emerge-webrsync: use portageq from same prefix
[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
31 LOGROTATE_FILES = elog-save-summary
32 BINDIR_FILES = ebuild egencache emerge emerge-webrsync \
33         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
38 ifdef PYTHONPATH
39         PYTHONPATH := $(srcdir)/pym:$(PYTHONPATH)
40 else
41         PYTHONPATH := $(srcdir)/pym
42 endif
43
44 all: docbook epydoc
45
46 docbook:
47         set -e; \
48         touch "$(srcdir)/doc/fragment/date"; \
49         $(MAKE) -C "$(srcdir)/doc" xhtml xhtml-nochunks
50
51 epydoc:
52         set -e; \
53         # workaround for bug 282760 \
54         touch "$(srcdir)/pym/pysqlite2.py"; \
55         env PYTHONPATH="$(PYTHONPATH)" epydoc \
56                 -o "$(WORKDIR)/epydoc" \
57                 --name $(PN) \
58                 --url "$(HOMEPAGE)" \
59                 $(EPYDOC_OPTS) \
60                 $$(cd "$(srcdir)" && find pym -name '*.py' | sed \
61                 -e s:/__init__.py$$:: \
62                 -e s:\.py$$:: \
63                 -e s:^pym/:: \
64                 -e s:/:.:g \
65                 | sort); \
66         rm -f "$(srcdir)/pym/pysqlite2.py"* \
67                 "$(WORKDIR)/epydoc/pysqlite2-"* \
68                 "$(WORKDIR)/epydoc/api-objects.txt"; \
69
70 test:
71         set -e; \
72         "$(srcdir)/pym/portage/tests/runTests"; \
73
74 install:
75         set -e; \
76         cd "$(srcdir)/cnf"; \
77         install -d -m$(DIRMODE) "$(DESTDIR)$(sysconfdir)"; \
78         install -m$(INSMODE) $(SYSCONFDIR_FILES) "$(DESTDIR)$(sysconfdir)"; \
79         \
80         install -d -m$(DIRMODE) "$(DESTDIR)$(portage_confdir)"; \
81         cd "$(srcdir)/cnf"; \
82         install -m$(INSMODE) $(PORTAGE_CONFDIR_FILES) \
83                 "$(DESTDIR)$(portage_confdir)"; \
84         ln -sf "..$(portage_confdir)/make.globals" "$(DESTDIR)$(sysconfdir)"; \
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 1 5 ; do \
189                 install -d -m$(DIRMODE) "$(DESTDIR)$(mandir)/man$$x"; \
190                 cd "$(srcdir)/man"; \
191                 install -m$(INSMODE) *.$$x "$(DESTDIR)$(mandir)/man$$x"; \
192         done; \
193         \
194         if [ -f "$(srcdir)/doc/portage.html" ] ; then \
195                 install -d -m$(DIRMODE) "$(DESTDIR)$(htmldir)"; \
196                 cd "$(srcdir)/doc"; \
197                 install -m$(INSMODE) *.html "$(DESTDIR)$(htmldir)"; \
198         fi; \
199         \
200         if [ -d "$(WORKDIR)/epydoc" ] ; then \
201                 install -d -m$(DIRMODE) "$(DESTDIR)$(htmldir)"; \
202                 cp -pPR "$(WORKDIR)/epydoc" \
203                         "$(DESTDIR)$(htmldir)/api"; \
204                 cd "$(DESTDIR)$(htmldir)/api"; \
205                 find . -type d | xargs chmod $(DIRMODE); \
206                 find . -type f | xargs chmod $(INSMODE); \
207         fi; \
208
209 clean:
210         set -e; \
211         $(MAKE) -C "$(srcdir)/doc" clean; \
212         rm -rf "$(srcdir)/pym/pysqlite2.py"* \
213                 "$(WORKDIR)/epydoc"; \
214
215 .PHONY: all clean docbook epydoc install test