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