blob: b9fd377c79f55b394d4f9a500099ca2a94efad85 [file] [log] [blame]
Ronald Oussoren836b0392006-05-14 19:56:34 +00001# This file can be invoked from the various frameworkinstall... targets in the
2# main Makefile. The next couple of variables are overridden on the
3# commandline in that case.
4
5VERSION=@VERSION@
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +00006builddir = ..
7srcdir=@srcdir@
Ronald Oussoren4fbb0802006-06-11 20:23:29 +00008prefix=@prefix@
Ronald Oussoren836b0392006-05-14 19:56:34 +00009LIBDEST=$(prefix)/lib/python$(VERSION)
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +000010RUNSHARED=@RUNSHARED@
11BUILDEXE=@BUILDEXEEXT@
12BUILDPYTHON=$(builddir)/python$(BUILDEXE)
Ronald Oussoren836b0392006-05-14 19:56:34 +000013DESTDIR=
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +000014LDFLAGS=@LDFLAGS@
Ronald Oussoren5b787322006-06-06 19:50:24 +000015FRAMEWORKUNIXTOOLSPREFIX=@FRAMEWORKUNIXTOOLSPREFIX@
Ronald Oussoren580c7fe2008-05-02 19:45:11 +000016PYTHONFRAMEWORK=@PYTHONFRAMEWORK@
Ronald Oussoren354bb5c2009-03-30 19:56:25 +000017PYTHONFRAMEWORKIDENTIFIER=@PYTHONFRAMEWORKIDENTIFIER@
Ronald Oussoren580c7fe2008-05-02 19:45:11 +000018
Ronald Oussoren836b0392006-05-14 19:56:34 +000019
20# These are normally glimpsed from the previous set
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +000021bindir=$(prefix)/bin
Ronald Oussoren580c7fe2008-05-02 19:45:11 +000022PYTHONAPPSDIR=/Applications/$(PYTHONFRAMEWORK) $(VERSION)
Ronald Oussoren836b0392006-05-14 19:56:34 +000023APPINSTALLDIR=$(prefix)/Resources/Python.app
24
25# Variables for installing the "normal" unix binaries
Ronald Oussoren580c7fe2008-05-02 19:45:11 +000026INSTALLED_PYTHONAPP=$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)
Ronald Oussoren836b0392006-05-14 19:56:34 +000027
28# Items more-or-less copied from the main Makefile
29DIRMODE=755
30FILEMODE=644
31INSTALL=@INSTALL@
32INSTALL_SYMLINK=ln -fsn
33INSTALL_PROGRAM=@INSTALL_PROGRAM@
34INSTALL_SCRIPT= @INSTALL_SCRIPT@
35INSTALL_DATA=@INSTALL_DATA@
36LN=@LN@
37STRIPFLAG=-s
38CPMAC=/Developer/Tools/CpMac
39
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +000040APPTEMPLATE=$(srcdir)/Resources/app
Ronald Oussoren364b2212009-05-19 20:12:17 +000041APPSUBDIRS=MacOS Resources
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +000042CACHERSRC=$(srcdir)/scripts/cachersrc.py
43compileall=$(srcdir)/../Lib/compileall.py
Ronald Oussoren836b0392006-05-14 19:56:34 +000044
45installapps: install_Python install_BuildApplet install_PythonLauncher \
46 install_IDLE checkapplepython install_pythonw install_versionedtools
47
Ronald Oussoren5640ce22008-06-05 12:58:24 +000048installapps4way: install_Python4way install_BuildApplet install_PythonLauncher install_IDLE install_pythonw4way install_versionedtools
49
50
Ronald Oussoren836b0392006-05-14 19:56:34 +000051install_pythonw: pythonw
52 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)"
53 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/python$(VERSION)"
54 ln -sf python$(VERSION) "$(DESTDIR)$(prefix)/bin/python"
55 ln -sf pythonw$(VERSION) "$(DESTDIR)$(prefix)/bin/pythonw"
56
Ronald Oussoren5640ce22008-06-05 12:58:24 +000057
58# Install 3 variants of python/pythonw:
59# - 32-bit (i386 and ppc)
60# - 64-bit (x86_64 and ppc64)
61# - all (all four architectures)
62# - Make 'python' and 'pythonw' aliases for the 32-bit variant
63install_pythonw4way: pythonw-32 pythonw-64 pythonw
64 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw-64 "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)-64"
65 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw-64 "$(DESTDIR)$(prefix)/bin/python$(VERSION)-64"
66 ln -sf python$(VERSION)-64 "$(DESTDIR)$(prefix)/bin/python-64"
67 ln -sf pythonw$(VERSION)-64 "$(DESTDIR)$(prefix)/bin/pythonw-64"
68
69 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw-32 "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)-32"
70 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw-32 "$(DESTDIR)$(prefix)/bin/python$(VERSION)-32"
71 ln -sf python$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/python-32"
72 ln -sf pythonw$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/pythonw-32"
73
74 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)-all"
75 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/python$(VERSION)-all"
76 ln -sf python$(VERSION)-all "$(DESTDIR)$(prefix)/bin/python-all"
77 ln -sf pythonw$(VERSION)-all "$(DESTDIR)$(prefix)/bin/pythonw-all"
78
79 ln -sf pythonw$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)"
80 ln -sf python$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/python$(VERSION)"
81 ln -sf pythonw$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/pythonw"
82 ln -sf python$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/python"
83
Ronald Oussoren836b0392006-05-14 19:56:34 +000084#
85# Install unix tools in /usr/local/bin. These are just aliases for the
86# actual installation inside the framework.
87#
88installunixtools:
Ronald Oussoren5b787322006-06-06 19:50:24 +000089 if [ ! -d "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ]; then \
90 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ;\
Ronald Oussoren836b0392006-05-14 19:56:34 +000091 fi
Ronald Oussoren5b787322006-06-06 19:50:24 +000092 for fn in python pythonw idle pydoc python-config smtpd.py \
93 python$(VERSION) pythonw$(VERSION) idle$(VERSION) \
Ronald Oussoren5640ce22008-06-05 12:58:24 +000094 pydoc$(VERSION) python$(VERSION)-config smtpd$(VERSION).py ;\
Ronald Oussoren836b0392006-05-14 19:56:34 +000095 do \
Ronald Oussoren5b787322006-06-06 19:50:24 +000096 ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\
Ronald Oussoren836b0392006-05-14 19:56:34 +000097 done
98
Ronald Oussoren5640ce22008-06-05 12:58:24 +000099
100# TODO: install symlinks for -32, -64 and -all as well
101installunixtools4way: installunixtools
102
103
Ronald Oussoren5b787322006-06-06 19:50:24 +0000104#
105# Like installunixtools, but only install links to the versioned binaries.
106#
107altinstallunixtools:
108 if [ ! -d "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ]; then \
109 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ;\
110 fi
111 for fn in python$(VERSION) pythonw$(VERSION) idle$(VERSION) \
Mark Dickinson1b6c4c82008-06-25 15:29:32 +0000112 pydoc$(VERSION) python$(VERSION)-config smtpd$(VERSION).py ;\
Ronald Oussoren5b787322006-06-06 19:50:24 +0000113 do \
114 ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\
115 done
116
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000117# TODO: -32, -64 and -all variants
118altinstallunixtools4way: altinstallunixtools
Ronald Oussoren5b787322006-06-06 19:50:24 +0000119
Ronald Oussoren836b0392006-05-14 19:56:34 +0000120# By default most tools are installed without a version in their basename, to
121# make it easier to install (and use) several python versions side-by-side move
122# the tools to a version-specific name and add the non-versioned name as an
123# alias.
124install_versionedtools:
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000125 for fn in idle pydoc ;\
Ronald Oussoren836b0392006-05-14 19:56:34 +0000126 do \
Ronald Oussorenda89b992006-05-23 11:04:24 +0000127 if [ -h "$(DESTDIR)$(prefix)/bin/$${fn}" ]; then \
128 continue ;\
129 fi ;\
Ronald Oussoren836b0392006-05-14 19:56:34 +0000130 mv "$(DESTDIR)$(prefix)/bin/$${fn}" "$(DESTDIR)$(prefix)/bin/$${fn}$(VERSION)" ;\
Ronald Oussoren3e3cb792006-05-18 09:04:15 +0000131 ln -sf "$${fn}$(VERSION)" "$(DESTDIR)$(prefix)/bin/$${fn}" ;\
Ronald Oussoren836b0392006-05-14 19:56:34 +0000132 done
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000133 if [ ! -h "$(DESTDIR)$(prefix)/bin/python-config" ]; then \
134 mv "$(DESTDIR)$(prefix)/bin/python-config" "$(DESTDIR)$(prefix)/bin/python$(VERSION)-config" ;\
135 ln -sf "python$(VERSION)-config" "$(DESTDIR)$(prefix)/bin/python-config" ; \
136 fi
Ronald Oussorenda89b992006-05-23 11:04:24 +0000137 if [ ! -h "$(DESTDIR)$(prefix)/bin/smtpd.py" ]; then \
138 mv "$(DESTDIR)$(prefix)/bin/smtpd.py" "$(DESTDIR)$(prefix)/bin/smtpd$(VERSION).py" ;\
139 ln -sf "smtpd$(VERSION).py" "$(DESTDIR)$(prefix)/bin/smtpd.py" ;\
140 fi
Ronald Oussoren836b0392006-05-14 19:56:34 +0000141
142
Ronald Oussorena6790f12006-09-17 19:23:27 +0000143pythonw: $(srcdir)/Tools/pythonw.c Makefile
Ronald Oussoren836b0392006-05-14 19:56:34 +0000144 $(CC) $(LDFLAGS) -o $@ $(srcdir)/Tools/pythonw.c \
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000145 -DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"'
Ronald Oussoren836b0392006-05-14 19:56:34 +0000146
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000147pythonw-32: $(srcdir)/Tools/pythonw.c Makefile
148 $(CC) $(LDFLAGS) -o $@ -arch i386 -arch ppc $(srcdir)/Tools/pythonw.c \
149 -DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)-32"'
150
151pythonw-64: $(srcdir)/Tools/pythonw.c Makefile
152 $(CC) $(LDFLAGS) -o $@ -arch x86_64 -arch ppc64 $(srcdir)/Tools/pythonw.c \
153 -DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)-64"'
Ronald Oussoren836b0392006-05-14 19:56:34 +0000154
155install_PythonLauncher:
156 cd PythonLauncher && make install DESTDIR=$(DESTDIR)
157
158install_Python:
Ronald Oussoren836b0392006-05-14 19:56:34 +0000159 @for i in "$(PYTHONAPPSDIR)" "$(APPINSTALLDIR)" "$(APPINSTALLDIR)/Contents"; do \
160 if test ! -d "$(DESTDIR)$$i"; then \
161 echo "Creating directory $(DESTDIR)$$i"; \
162 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$$i"; \
163 fi;\
164 done
165 @for i in $(APPSUBDIRS); do \
166 if test ! -d "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; then \
167 echo "Creating directory $(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \
168 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \
169 else true; \
170 fi; \
171 done
172 @for d in . $(APPSUBDIRS); \
173 do \
174 a=$(APPTEMPLATE)/$$d; \
175 if test ! -d $$a; then continue; else true; fi; \
176 b="$(DESTDIR)$(APPINSTALLDIR)/Contents/$$d"; \
177 for i in $$a/*; \
178 do \
179 case $$i in \
180 *CVS) ;; \
181 *.svn) ;; \
182 *.py[co]) ;; \
183 *.orig) ;; \
184 *~) ;; \
185 *idx) \
186 echo $(CPMAC) "$$i" $$b; \
187 $(CPMAC) "$$i" "$$b"; \
188 ;; \
189 *) \
190 if test -d $$i; then continue; fi; \
191 if test -x $$i; then \
192 echo $(INSTALL_SCRIPT) "$$i" "$$b"; \
193 $(INSTALL_SCRIPT) "$$i" "$$b"; \
194 else \
195 echo $(INSTALL_DATA) "$$i" "$$b"; \
196 $(INSTALL_DATA) "$$i" "$$b"; \
197 fi;; \
198 esac; \
199 done; \
200 done
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000201 $(INSTALL_PROGRAM) $(STRIPFLAG) $(BUILDPYTHON) "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"
Ronald Oussoren354bb5c2009-03-30 19:56:25 +0000202 sed -e "s!%bundleid%!$(PYTHONFRAMEWORKIDENTIFIER)!g" \
203 -e "s!%version%!`$(RUNSHARED) $(BUILDPYTHON) \
204 -c 'import platform; print(platform.python_version())'`!g" \
205 < "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist.in" \
206 > "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist"
207 rm "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist.in"
Ronald Oussoren836b0392006-05-14 19:56:34 +0000208
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000209install_Python4way: install_Python
210 lipo -extract i386 -extract ppc7400 -output "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)-32" "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"
211 lipo -extract x86_64 -extract ppc64 -output "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)-64" "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"
212
213
214
Ronald Oussoren836b0392006-05-14 19:56:34 +0000215install_IDLE:
216 cd IDLE && make install
217
218install_BuildApplet:
Ronald Oussoren5aa0b4d2008-07-22 07:06:33 +0000219 $(RUNSHARED) @ARCH_RUN_32BIT@ $(BUILDPYTHON) $(srcdir)/scripts/BuildApplet.py \
Ronald Oussoren836b0392006-05-14 19:56:34 +0000220 --destroot "$(DESTDIR)" \
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000221 --python=$(prefix)/Resources/Python.app/Contents/MacOS/$(PYTHONFRAMEWORK)`test -f "$(DESTDIR)$(prefix)/Resources/Python.app/Contents/MacOS/$(PYTHONFRAMEWORK)-32" && echo "-32"` \
Ronald Oussoren3e3cb792006-05-18 09:04:15 +0000222 --output "$(DESTDIR)$(PYTHONAPPSDIR)/Build Applet.app" \
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +0000223 $(srcdir)/scripts/BuildApplet.py
Ronald Oussoren836b0392006-05-14 19:56:34 +0000224
225MACLIBDEST=$(LIBDEST)/plat-mac
226MACTOOLSDEST=$(prefix)/Mac/Tools
227MACTOOLSSRC=$(srcdir)/Mac/Tools
228MACTOOLSSUBDIRS=IDE
229
230installmacsubtree:
231 @for i in $(MACTOOLSDEST); \
232 do \
233 if test ! -d $(DESTDIR)$$i; then \
234 echo "Creating directory $(DESTDIR)$$i"; \
235 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
236 else true; \
237 fi; \
238 done
239 @for d in $(MACTOOLSSUBDIRS); \
240 do \
241 a=$(MACTOOLSSRC)/$$d; \
242 if test ! -d $$a; then continue; else true; fi; \
243 b=$(DESTDIR)$(MACTOOLSDEST)/$$d; \
244 if test ! -d $$b; then \
245 echo "Creating directory $$b"; \
246 $(INSTALL) -d -m $(DIRMODE) $$b; \
247 else true; \
248 fi; \
249 done
250 @for d in $(MACTOOLSSUBDIRS); \
251 do \
252 a=$(MACTOOLSSRC)/$$d; \
253 if test ! -d $$a; then continue; else true; fi; \
254 b=$(DESTDIR)$(MACTOOLSDEST)/$$d; \
255 for i in $$a/*; \
256 do \
257 case $$i in \
258 *CVS) ;; \
259 *.svn) ;; \
260 *.py[co]) ;; \
261 *.orig) ;; \
262 *~) ;; \
263 *.rsrc) \
264 echo $(CPMAC) $$i $$b ; \
265 $(CPMAC) $$i $$b ; \
266 ;; \
267 *) \
268 if test -d $$i; then continue; fi; \
269 if test -x $$i; then \
270 echo $(INSTALL_SCRIPT) $$i $$b; \
271 $(INSTALL_SCRIPT) $$i $$b; \
272 else \
273 echo $(INSTALL_DATA) $$i $$b; \
274 $(INSTALL_DATA) $$i $$b; \
275 fi;; \
276 esac; \
277 done; \
278 done
279
280
Ronald Oussoren5aa0b4d2008-07-22 07:06:33 +0000281 $(RUNSHARED) @ARCH_RUN_32BIT@ $(BUILDPYTHON) $(CACHERSRC) -v $(DESTDIR)$(MACLIBDEST) $(DESTDIR)$(MACTOOLSDEST)
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +0000282 $(RUNSHARED) $(BUILDPYTHON) -Wi -tt $(compileall) -d $(MACTOOLSDEST) -x badsyntax $(DESTDIR)$(MACTOOLSDEST)
283 $(RUNSHARED) $(BUILDPYTHON) -O -Wi -tt $(compileall) -d $(MACTOOLSDEST) -x badsyntax $(DESTDIR)$(MACTOOLSDEST)
Ronald Oussoren836b0392006-05-14 19:56:34 +0000284
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +0000285$(INSTALLED_PYTHONAPP): install_Python
Ronald Oussoren836b0392006-05-14 19:56:34 +0000286
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +0000287installextras: $(srcdir)/Extras.ReadMe.txt $(srcdir)/Extras.install.py
Ronald Oussoren836b0392006-05-14 19:56:34 +0000288 $(INSTALL) -d "$(DESTDIR)$(PYTHONAPPSDIR)/Extras"
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +0000289 $(INSTALL) $(srcdir)/Extras.ReadMe.txt "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/ReadMe.txt"
290 $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Extras.install.py $(srcdir)/../Demo \
Ronald Oussoren836b0392006-05-14 19:56:34 +0000291 "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo"
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +0000292 $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Extras.install.py $(srcdir)/Demo \
293 "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo.Mac"
Ronald Oussoren836b0392006-05-14 19:56:34 +0000294
295
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +0000296checkapplepython: $(srcdir)/Tools/fixapplepython23.py
297 @if ! $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Tools/fixapplepython23.py -n; then \
Ronald Oussoren836b0392006-05-14 19:56:34 +0000298 echo "* WARNING: Apple-installed Python 2.3 will have trouble building extensions from now on."; \
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +0000299 echo "* WARNING: Run $(srcdir)/Tools/fixapplepython23.py with \"sudo\" to fix this."; \
Ronald Oussoren836b0392006-05-14 19:56:34 +0000300 fi
301
302
303clean:
304 rm pythonw
305 cd PythonLauncher && make clean
306 cd IDLE && make clean
Ronald Oussorena6790f12006-09-17 19:23:27 +0000307
308Makefile: $(srcdir)/Makefile.in ../config.status
309 cd .. && CONFIG_FILES=Mac/Makefile CONFIG_HEADERS= $(SHELL) ./config.status