blob: a6d78fbd444193882bd0b265cfd33cd40906c344 [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 Oussoren92919a62009-12-24 13:30:58 +000018LIPO_32BIT_FLAGS=@LIPO_32BIT_FLAGS@
Ronald Oussorena55af9a2010-01-17 16:25:57 +000019CC=@CC@
Ronald Oussoren1bf02022010-04-20 08:53:12 +000020MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
21export MACOSX_DEPLOYMENT_TARGET
Ronald Oussoren836b0392006-05-14 19:56:34 +000022
23# These are normally glimpsed from the previous set
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +000024bindir=$(prefix)/bin
Ronald Oussoren01d149f2010-04-30 11:20:14 +000025PYTHONAPPSDIR=@FRAMEWORKINSTALLAPPSPREFIX@/$(PYTHONFRAMEWORK) $(VERSION)
Ronald Oussoren836b0392006-05-14 19:56:34 +000026APPINSTALLDIR=$(prefix)/Resources/Python.app
27
28# Variables for installing the "normal" unix binaries
Ronald Oussoren580c7fe2008-05-02 19:45:11 +000029INSTALLED_PYTHONAPP=$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)
Ronald Oussoren836b0392006-05-14 19:56:34 +000030
31# Items more-or-less copied from the main Makefile
32DIRMODE=755
33FILEMODE=644
34INSTALL=@INSTALL@
35INSTALL_SYMLINK=ln -fsn
36INSTALL_PROGRAM=@INSTALL_PROGRAM@
37INSTALL_SCRIPT= @INSTALL_SCRIPT@
38INSTALL_DATA=@INSTALL_DATA@
39LN=@LN@
40STRIPFLAG=-s
41CPMAC=/Developer/Tools/CpMac
42
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +000043APPTEMPLATE=$(srcdir)/Resources/app
Ronald Oussoren364b2212009-05-19 20:12:17 +000044APPSUBDIRS=MacOS Resources
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +000045CACHERSRC=$(srcdir)/scripts/cachersrc.py
46compileall=$(srcdir)/../Lib/compileall.py
Ronald Oussoren836b0392006-05-14 19:56:34 +000047
Ronald Oussoren92919a62009-12-24 13:30:58 +000048installapps: install_Python install_pythonw install_BuildApplet install_PythonLauncher \
49 install_IDLE checkapplepython install_versionedtools
Ronald Oussoren5640ce22008-06-05 12:58:24 +000050
51
Ronald Oussoren836b0392006-05-14 19:56:34 +000052install_pythonw: pythonw
53 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)"
54 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/python$(VERSION)"
Ned Deilyc5df5632012-02-19 02:19:12 +010055 ln -sf python$(VERSION) "$(DESTDIR)$(prefix)/bin/python2"
56 ln -sf python2 "$(DESTDIR)$(prefix)/bin/python"
57 ln -sf pythonw$(VERSION) "$(DESTDIR)$(prefix)/bin/pythonw2"
58 ln -sf pythonw2 "$(DESTDIR)$(prefix)/bin/pythonw"
Ronald Oussoren92919a62009-12-24 13:30:58 +000059ifneq ($(LIPO_32BIT_FLAGS),)
60 lipo $(LIPO_32BIT_FLAGS) -output $(DESTDIR)$(prefix)/bin/python$(VERSION)-32 pythonw
61 lipo $(LIPO_32BIT_FLAGS) -output $(DESTDIR)$(prefix)/bin/pythonw$(VERSION)-32 pythonw
Ned Deilyc5df5632012-02-19 02:19:12 +010062 ln -sf python$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/python2-32"
63 ln -sf python2-32 "$(DESTDIR)$(prefix)/bin/python-32"
64 ln -sf pythonw$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/pythonw2-32"
65 ln -sf pythonw2-32 "$(DESTDIR)$(prefix)/bin/pythonw-32"
Ronald Oussoren92919a62009-12-24 13:30:58 +000066endif
Ronald Oussoren5640ce22008-06-05 12:58:24 +000067
Ronald Oussoren5640ce22008-06-05 12:58:24 +000068
Ronald Oussoren836b0392006-05-14 19:56:34 +000069#
70# Install unix tools in /usr/local/bin. These are just aliases for the
71# actual installation inside the framework.
72#
73installunixtools:
Ronald Oussoren5b787322006-06-06 19:50:24 +000074 if [ ! -d "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ]; then \
75 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ;\
Ronald Oussoren836b0392006-05-14 19:56:34 +000076 fi
Ronald Oussoren0969c672010-07-29 13:18:19 +000077 for fn in python pythonw idle pydoc python-config smtpd.py 2to3 \
Ned Deilyc5df5632012-02-19 02:19:12 +010078 python2 pythonw2 idle2 \
79 pydoc2 python2-config smtpd2.py \
80 2to3-2 \
Ronald Oussoren5b787322006-06-06 19:50:24 +000081 python$(VERSION) pythonw$(VERSION) idle$(VERSION) \
Ronald Oussoren0969c672010-07-29 13:18:19 +000082 pydoc$(VERSION) python$(VERSION)-config smtpd$(VERSION).py \
83 2to3-$(VERSION) ;\
Ronald Oussoren836b0392006-05-14 19:56:34 +000084 do \
Ronald Oussoren5b787322006-06-06 19:50:24 +000085 ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\
Ronald Oussoren836b0392006-05-14 19:56:34 +000086 done
Ned Deily22f63b52011-05-28 05:56:14 -070087ifneq ($(LIPO_32BIT_FLAGS),)
88 for fn in python-32 pythonw-32 \
Ned Deilyc5df5632012-02-19 02:19:12 +010089 python2-32 pythonw2-32 \
Ned Deily22f63b52011-05-28 05:56:14 -070090 python$(VERSION)-32 pythonw$(VERSION)-32 ;\
91 do \
92 ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\
93 done
94endif
Ronald Oussoren836b0392006-05-14 19:56:34 +000095
Ronald Oussoren5640ce22008-06-05 12:58:24 +000096
Ronald Oussoren5b787322006-06-06 19:50:24 +000097#
98# Like installunixtools, but only install links to the versioned binaries.
99#
100altinstallunixtools:
101 if [ ! -d "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ]; then \
102 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ;\
103 fi
104 for fn in python$(VERSION) pythonw$(VERSION) idle$(VERSION) \
Mark Dickinson1b6c4c82008-06-25 15:29:32 +0000105 pydoc$(VERSION) python$(VERSION)-config smtpd$(VERSION).py ;\
Ronald Oussoren5b787322006-06-06 19:50:24 +0000106 do \
107 ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\
108 done
Ned Deily22f63b52011-05-28 05:56:14 -0700109ifneq ($(LIPO_32BIT_FLAGS),)
110 for fn in python$(VERSION)-32 pythonw$(VERSION)-32 ;\
111 do \
112 ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\
113 done
114endif
Ronald Oussoren0969c672010-07-29 13:18:19 +0000115 ln -fs "$(prefix)/bin/2to3-$(VERSION)" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/2to3-$(VERSION)" ;\
Ronald Oussoren5b787322006-06-06 19:50:24 +0000116
Ronald Oussoren836b0392006-05-14 19:56:34 +0000117# By default most tools are installed without a version in their basename, to
118# make it easier to install (and use) several python versions side-by-side move
119# the tools to a version-specific name and add the non-versioned name as an
120# alias.
121install_versionedtools:
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000122 for fn in idle pydoc ;\
Ronald Oussoren836b0392006-05-14 19:56:34 +0000123 do \
Ronald Oussorenda89b992006-05-23 11:04:24 +0000124 if [ -h "$(DESTDIR)$(prefix)/bin/$${fn}" ]; then \
125 continue ;\
126 fi ;\
Ronald Oussoren836b0392006-05-14 19:56:34 +0000127 mv "$(DESTDIR)$(prefix)/bin/$${fn}" "$(DESTDIR)$(prefix)/bin/$${fn}$(VERSION)" ;\
Ned Deilyc5df5632012-02-19 02:19:12 +0100128 ln -sf "$${fn}$(VERSION)" "$(DESTDIR)$(prefix)/bin/$${fn}2" ;\
129 ln -sf "$${fn}2" "$(DESTDIR)$(prefix)/bin/$${fn}" ;\
Ronald Oussoren836b0392006-05-14 19:56:34 +0000130 done
Ronald Oussorenda89b992006-05-23 11:04:24 +0000131 if [ ! -h "$(DESTDIR)$(prefix)/bin/smtpd.py" ]; then \
132 mv "$(DESTDIR)$(prefix)/bin/smtpd.py" "$(DESTDIR)$(prefix)/bin/smtpd$(VERSION).py" ;\
Ned Deilyc5df5632012-02-19 02:19:12 +0100133 ln -sf "smtpd$(VERSION).py" "$(DESTDIR)$(prefix)/bin/smtpd2.py" ;\
134 ln -sf "smtpd2.py" "$(DESTDIR)$(prefix)/bin/smtpd.py" ;\
Ronald Oussorenda89b992006-05-23 11:04:24 +0000135 fi
Ronald Oussoren0969c672010-07-29 13:18:19 +0000136 if [ ! -h "$(DESTDIR)$(prefix)/bin/2to3" ]; then \
137 mv "$(DESTDIR)$(prefix)/bin/2to3" "$(DESTDIR)$(prefix)/bin/2to3-$(VERSION)" ;\
Ned Deilyc5df5632012-02-19 02:19:12 +0100138 ln -sf "2to3-$(VERSION)" "$(DESTDIR)$(prefix)/bin/2to3-2" ;\
139 ln -sf "2to3-2" "$(DESTDIR)$(prefix)/bin/2to3" ;\
Ronald Oussoren0969c672010-07-29 13:18:19 +0000140 fi
Ronald Oussoren836b0392006-05-14 19:56:34 +0000141
142
Ronald Oussorena6790f12006-09-17 19:23:27 +0000143pythonw: $(srcdir)/Tools/pythonw.c Makefile
Ronald Oussoren2a4ab812010-03-07 09:04:06 +0000144 $(CC) $(LDFLAGS) -DPYTHONFRAMEWORK='"$(PYTHONFRAMEWORK)"' -o $@ $(srcdir)/Tools/pythonw.c -I.. -I$(srcdir)/../Include ../$(PYTHONFRAMEWORK).framework/Versions/$(VERSION)/$(PYTHONFRAMEWORK)
Ronald Oussoren836b0392006-05-14 19:56:34 +0000145
146install_PythonLauncher:
147 cd PythonLauncher && make install DESTDIR=$(DESTDIR)
148
149install_Python:
Ronald Oussoren836b0392006-05-14 19:56:34 +0000150 @for i in "$(PYTHONAPPSDIR)" "$(APPINSTALLDIR)" "$(APPINSTALLDIR)/Contents"; do \
151 if test ! -d "$(DESTDIR)$$i"; then \
152 echo "Creating directory $(DESTDIR)$$i"; \
153 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$$i"; \
154 fi;\
155 done
156 @for i in $(APPSUBDIRS); do \
157 if test ! -d "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; then \
158 echo "Creating directory $(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \
159 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \
160 else true; \
161 fi; \
162 done
163 @for d in . $(APPSUBDIRS); \
164 do \
165 a=$(APPTEMPLATE)/$$d; \
166 if test ! -d $$a; then continue; else true; fi; \
167 b="$(DESTDIR)$(APPINSTALLDIR)/Contents/$$d"; \
168 for i in $$a/*; \
169 do \
170 case $$i in \
171 *CVS) ;; \
172 *.svn) ;; \
173 *.py[co]) ;; \
174 *.orig) ;; \
175 *~) ;; \
176 *idx) \
177 echo $(CPMAC) "$$i" $$b; \
178 $(CPMAC) "$$i" "$$b"; \
179 ;; \
180 *) \
181 if test -d $$i; then continue; fi; \
182 if test -x $$i; then \
183 echo $(INSTALL_SCRIPT) "$$i" "$$b"; \
184 $(INSTALL_SCRIPT) "$$i" "$$b"; \
185 else \
186 echo $(INSTALL_DATA) "$$i" "$$b"; \
187 $(INSTALL_DATA) "$$i" "$$b"; \
188 fi;; \
189 esac; \
190 done; \
191 done
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000192 $(INSTALL_PROGRAM) $(STRIPFLAG) $(BUILDPYTHON) "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"
Ronald Oussoren354bb5c2009-03-30 19:56:25 +0000193 sed -e "s!%bundleid%!$(PYTHONFRAMEWORKIDENTIFIER)!g" \
194 -e "s!%version%!`$(RUNSHARED) $(BUILDPYTHON) \
195 -c 'import platform; print(platform.python_version())'`!g" \
196 < "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist.in" \
197 > "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist"
198 rm "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist.in"
Ronald Oussoren836b0392006-05-14 19:56:34 +0000199
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000200
Ronald Oussoren836b0392006-05-14 19:56:34 +0000201install_IDLE:
202 cd IDLE && make install
203
204install_BuildApplet:
Ronald Oussoren5aa0b4d2008-07-22 07:06:33 +0000205 $(RUNSHARED) @ARCH_RUN_32BIT@ $(BUILDPYTHON) $(srcdir)/scripts/BuildApplet.py \
Ronald Oussoren836b0392006-05-14 19:56:34 +0000206 --destroot "$(DESTDIR)" \
Ronald Oussoren92919a62009-12-24 13:30:58 +0000207 --python=$(prefix)/Resources/Python.app/Contents/MacOS/Python \
Ronald Oussoren3e3cb792006-05-18 09:04:15 +0000208 --output "$(DESTDIR)$(PYTHONAPPSDIR)/Build Applet.app" \
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +0000209 $(srcdir)/scripts/BuildApplet.py
Ronald Oussoren92919a62009-12-24 13:30:58 +0000210ifneq ($(LIPO_32BIT_FLAGS),)
211 rm "$(DESTDIR)$(PYTHONAPPSDIR)/Build Applet.app/Contents/MacOS/Python"
212 lipo $(LIPO_32BIT_FLAGS) -output "$(DESTDIR)$(PYTHONAPPSDIR)/Build Applet.app/Contents/MacOS/Python" $(BUILDPYTHON)
213endif
Ronald Oussoren836b0392006-05-14 19:56:34 +0000214
215MACLIBDEST=$(LIBDEST)/plat-mac
216MACTOOLSDEST=$(prefix)/Mac/Tools
217MACTOOLSSRC=$(srcdir)/Mac/Tools
218MACTOOLSSUBDIRS=IDE
219
220installmacsubtree:
221 @for i in $(MACTOOLSDEST); \
222 do \
223 if test ! -d $(DESTDIR)$$i; then \
224 echo "Creating directory $(DESTDIR)$$i"; \
225 $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
226 else true; \
227 fi; \
228 done
229 @for d in $(MACTOOLSSUBDIRS); \
230 do \
231 a=$(MACTOOLSSRC)/$$d; \
232 if test ! -d $$a; then continue; else true; fi; \
233 b=$(DESTDIR)$(MACTOOLSDEST)/$$d; \
234 if test ! -d $$b; then \
235 echo "Creating directory $$b"; \
236 $(INSTALL) -d -m $(DIRMODE) $$b; \
237 else true; \
238 fi; \
239 done
240 @for d in $(MACTOOLSSUBDIRS); \
241 do \
242 a=$(MACTOOLSSRC)/$$d; \
243 if test ! -d $$a; then continue; else true; fi; \
244 b=$(DESTDIR)$(MACTOOLSDEST)/$$d; \
245 for i in $$a/*; \
246 do \
247 case $$i in \
248 *CVS) ;; \
249 *.svn) ;; \
250 *.py[co]) ;; \
251 *.orig) ;; \
252 *~) ;; \
253 *.rsrc) \
254 echo $(CPMAC) $$i $$b ; \
255 $(CPMAC) $$i $$b ; \
256 ;; \
257 *) \
258 if test -d $$i; then continue; fi; \
259 if test -x $$i; then \
260 echo $(INSTALL_SCRIPT) $$i $$b; \
261 $(INSTALL_SCRIPT) $$i $$b; \
262 else \
263 echo $(INSTALL_DATA) $$i $$b; \
264 $(INSTALL_DATA) $$i $$b; \
265 fi;; \
266 esac; \
267 done; \
268 done
269
270
Ronald Oussoren5aa0b4d2008-07-22 07:06:33 +0000271 $(RUNSHARED) @ARCH_RUN_32BIT@ $(BUILDPYTHON) $(CACHERSRC) -v $(DESTDIR)$(MACLIBDEST) $(DESTDIR)$(MACTOOLSDEST)
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +0000272 $(RUNSHARED) $(BUILDPYTHON) -Wi -tt $(compileall) -d $(MACTOOLSDEST) -x badsyntax $(DESTDIR)$(MACTOOLSDEST)
273 $(RUNSHARED) $(BUILDPYTHON) -O -Wi -tt $(compileall) -d $(MACTOOLSDEST) -x badsyntax $(DESTDIR)$(MACTOOLSDEST)
Ronald Oussoren836b0392006-05-14 19:56:34 +0000274
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +0000275$(INSTALLED_PYTHONAPP): install_Python
Ronald Oussoren836b0392006-05-14 19:56:34 +0000276
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +0000277installextras: $(srcdir)/Extras.ReadMe.txt $(srcdir)/Extras.install.py
Ronald Oussoren836b0392006-05-14 19:56:34 +0000278 $(INSTALL) -d "$(DESTDIR)$(PYTHONAPPSDIR)/Extras"
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +0000279 $(INSTALL) $(srcdir)/Extras.ReadMe.txt "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/ReadMe.txt"
280 $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Extras.install.py $(srcdir)/../Demo \
Ronald Oussoren836b0392006-05-14 19:56:34 +0000281 "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo"
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +0000282 $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Extras.install.py $(srcdir)/Demo \
283 "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo.Mac"
Ronald Oussoren836b0392006-05-14 19:56:34 +0000284
285
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +0000286checkapplepython: $(srcdir)/Tools/fixapplepython23.py
287 @if ! $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Tools/fixapplepython23.py -n; then \
Ronald Oussoren836b0392006-05-14 19:56:34 +0000288 echo "* WARNING: Apple-installed Python 2.3 will have trouble building extensions from now on."; \
Ronald Oussoren32f5d8f2006-06-07 19:02:03 +0000289 echo "* WARNING: Run $(srcdir)/Tools/fixapplepython23.py with \"sudo\" to fix this."; \
Ronald Oussoren836b0392006-05-14 19:56:34 +0000290 fi
291
292
293clean:
294 rm pythonw
295 cd PythonLauncher && make clean
296 cd IDLE && make clean
Ronald Oussorena6790f12006-09-17 19:23:27 +0000297
298Makefile: $(srcdir)/Makefile.in ../config.status
299 cd .. && CONFIG_FILES=Mac/Makefile CONFIG_HEADERS= $(SHELL) ./config.status