blob: 40db0088a05293e14bbf919fa03500fd12322e66 [file] [log] [blame]
Thomas Wouters477c8d52006-05-27 19:21:47 +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@
Thomas Wouters73e5a5b2006-06-08 15:35:45 +00006builddir = ..
7srcdir=@srcdir@
Thomas Wouters0e3f5912006-08-11 14:57:12 +00008prefix=@prefix@
Thomas Wouters477c8d52006-05-27 19:21:47 +00009LIBDEST=$(prefix)/lib/python$(VERSION)
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000010RUNSHARED=@RUNSHARED@
11BUILDEXE=@BUILDEXEEXT@
12BUILDPYTHON=$(builddir)/python$(BUILDEXE)
Thomas Wouters477c8d52006-05-27 19:21:47 +000013DESTDIR=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000014LDFLAGS=@LDFLAGS@
15FRAMEWORKUNIXTOOLSPREFIX=@FRAMEWORKUNIXTOOLSPREFIX@
Christian Heimes81ee3ef2008-05-04 22:42:01 +000016PYTHONFRAMEWORK=@PYTHONFRAMEWORK@
Ronald Oussorenf29b6b42009-03-30 20:00:00 +000017PYTHONFRAMEWORKIDENTIFIER=@PYTHONFRAMEWORKIDENTIFIER@
Christian Heimes81ee3ef2008-05-04 22:42:01 +000018
Thomas Wouters477c8d52006-05-27 19:21:47 +000019
20# These are normally glimpsed from the previous set
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000021bindir=$(prefix)/bin
Christian Heimes81ee3ef2008-05-04 22:42:01 +000022PYTHONAPPSDIR=/Applications/$(PYTHONFRAMEWORK) $(VERSION)
Thomas Wouters477c8d52006-05-27 19:21:47 +000023APPINSTALLDIR=$(prefix)/Resources/Python.app
24
25# Variables for installing the "normal" unix binaries
Christian Heimes81ee3ef2008-05-04 22:42:01 +000026INSTALLED_PYTHONAPP=$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)
Thomas Wouters477c8d52006-05-27 19:21:47 +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
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000040APPTEMPLATE=$(srcdir)/Resources/app
Thomas Wouters477c8d52006-05-27 19:21:47 +000041APPSUBDIRS=MacOS Resources Resources/English.lproj \
42 Resources/English.lproj/Documentation \
43 Resources/English.lproj/Documentation/doc \
44 Resources/English.lproj/Documentation/ide
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000045DOCDIR=$(srcdir)/Resources/app/Resources/English.lproj/Documentation
Thomas Wouters477c8d52006-05-27 19:21:47 +000046DOCINDEX=$(DOCDIR)/"Documentation idx"
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000047compileall=$(srcdir)/../Lib/compileall.py
Thomas Wouters477c8d52006-05-27 19:21:47 +000048
Georg Brandl59f8d832008-07-19 09:58:13 +000049installapps: install_Python install_PythonLauncher install_IDLE \
50 checkapplepython install_pythonw install_versionedtools
Thomas Wouters477c8d52006-05-27 19:21:47 +000051
Georg Brandl59f8d832008-07-19 09:58:13 +000052installapps4way: install_Python4way install_PythonLauncher \
Ronald Oussoren672f62a2009-02-12 15:18:15 +000053 install_IDLE4way install_pythonw4way install_versionedtools
Georg Brandlfcaf9102008-07-16 02:17:56 +000054
55
Thomas Wouters477c8d52006-05-27 19:21:47 +000056install_pythonw: pythonw
57 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)"
58 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/python$(VERSION)"
59 ln -sf python$(VERSION) "$(DESTDIR)$(prefix)/bin/python"
60 ln -sf pythonw$(VERSION) "$(DESTDIR)$(prefix)/bin/pythonw"
61
Georg Brandlfcaf9102008-07-16 02:17:56 +000062
63# Install 3 variants of python/pythonw:
64# - 32-bit (i386 and ppc)
65# - 64-bit (x86_64 and ppc64)
66# - all (all four architectures)
67# - Make 'python' and 'pythonw' aliases for the 32-bit variant
68install_pythonw4way: pythonw-32 pythonw-64 pythonw
69 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw-64 "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)-64"
70 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw-64 "$(DESTDIR)$(prefix)/bin/python$(VERSION)-64"
71 ln -sf python$(VERSION)-64 "$(DESTDIR)$(prefix)/bin/python-64"
72 ln -sf pythonw$(VERSION)-64 "$(DESTDIR)$(prefix)/bin/pythonw-64"
73
74 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw-32 "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)-32"
75 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw-32 "$(DESTDIR)$(prefix)/bin/python$(VERSION)-32"
76 ln -sf python$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/python-32"
77 ln -sf pythonw$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/pythonw-32"
78
79 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)-all"
80 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/python$(VERSION)-all"
81 ln -sf python$(VERSION)-all "$(DESTDIR)$(prefix)/bin/python-all"
82 ln -sf pythonw$(VERSION)-all "$(DESTDIR)$(prefix)/bin/pythonw-all"
83
84 ln -sf pythonw$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)"
85 ln -sf python$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/python$(VERSION)"
86 ln -sf pythonw$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/pythonw"
87 ln -sf python$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/python"
88
Thomas Wouters477c8d52006-05-27 19:21:47 +000089#
90# Install unix tools in /usr/local/bin. These are just aliases for the
91# actual installation inside the framework.
92#
93installunixtools:
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000094 if [ ! -d "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ]; then \
95 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ;\
Thomas Wouters477c8d52006-05-27 19:21:47 +000096 fi
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000097 for fn in python pythonw idle pydoc python-config smtpd.py \
98 python$(VERSION) pythonw$(VERSION) idle$(VERSION) \
Georg Brandlfcaf9102008-07-16 02:17:56 +000099 pydoc$(VERSION) python$(VERSION)-config smtpd$(VERSION).py ;\
Thomas Wouters477c8d52006-05-27 19:21:47 +0000100 do \
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000101 ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\
Thomas Wouters477c8d52006-05-27 19:21:47 +0000102 done
103
Georg Brandlfcaf9102008-07-16 02:17:56 +0000104
105# TODO: install symlinks for -32, -64 and -all as well
106installunixtools4way: installunixtools
107
108
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000109#
110# Like installunixtools, but only install links to the versioned binaries.
111#
112altinstallunixtools:
113 if [ ! -d "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ]; then \
114 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ;\
115 fi
116 for fn in python$(VERSION) pythonw$(VERSION) idle$(VERSION) \
Georg Brandl3ccb7872008-07-16 03:00:45 +0000117 pydoc$(VERSION) python$(VERSION)-config smtpd$(VERSION).py ;\
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000118 do \
119 ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\
120 done
121
Georg Brandlfcaf9102008-07-16 02:17:56 +0000122# TODO: -32, -64 and -all variants
123altinstallunixtools4way: altinstallunixtools
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000124
Thomas Wouters477c8d52006-05-27 19:21:47 +0000125# By default most tools are installed without a version in their basename, to
126# make it easier to install (and use) several python versions side-by-side move
127# the tools to a version-specific name and add the non-versioned name as an
128# alias.
129install_versionedtools:
Georg Brandlfcaf9102008-07-16 02:17:56 +0000130 for fn in idle pydoc ;\
Thomas Wouters477c8d52006-05-27 19:21:47 +0000131 do \
132 if [ -h "$(DESTDIR)$(prefix)/bin/$${fn}" ]; then \
133 continue ;\
134 fi ;\
135 mv "$(DESTDIR)$(prefix)/bin/$${fn}" "$(DESTDIR)$(prefix)/bin/$${fn}$(VERSION)" ;\
136 ln -sf "$${fn}$(VERSION)" "$(DESTDIR)$(prefix)/bin/$${fn}" ;\
137 done
Georg Brandlfcaf9102008-07-16 02:17:56 +0000138 if [ ! -h "$(DESTDIR)$(prefix)/bin/python-config" ]; then \
139 mv "$(DESTDIR)$(prefix)/bin/python-config" "$(DESTDIR)$(prefix)/bin/python$(VERSION)-config" ;\
140 ln -sf "python$(VERSION)-config" "$(DESTDIR)$(prefix)/bin/python-config" ; \
141 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000142 if [ ! -h "$(DESTDIR)$(prefix)/bin/smtpd.py" ]; then \
143 mv "$(DESTDIR)$(prefix)/bin/smtpd.py" "$(DESTDIR)$(prefix)/bin/smtpd$(VERSION).py" ;\
144 ln -sf "smtpd$(VERSION).py" "$(DESTDIR)$(prefix)/bin/smtpd.py" ;\
145 fi
146
147
Thomas Wouters89f507f2006-12-13 04:49:30 +0000148pythonw: $(srcdir)/Tools/pythonw.c Makefile
Thomas Wouters477c8d52006-05-27 19:21:47 +0000149 $(CC) $(LDFLAGS) -o $@ $(srcdir)/Tools/pythonw.c \
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000150 -DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"'
Thomas Wouters477c8d52006-05-27 19:21:47 +0000151
Georg Brandlfcaf9102008-07-16 02:17:56 +0000152pythonw-32: $(srcdir)/Tools/pythonw.c Makefile
153 $(CC) $(LDFLAGS) -o $@ -arch i386 -arch ppc $(srcdir)/Tools/pythonw.c \
154 -DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)-32"'
155
156pythonw-64: $(srcdir)/Tools/pythonw.c Makefile
157 $(CC) $(LDFLAGS) -o $@ -arch x86_64 -arch ppc64 $(srcdir)/Tools/pythonw.c \
158 -DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)-64"'
Thomas Wouters477c8d52006-05-27 19:21:47 +0000159
160install_PythonLauncher:
161 cd PythonLauncher && make install DESTDIR=$(DESTDIR)
162
163install_Python:
164 @if test ! -f $(DOCINDEX); then \
165 echo WARNING: you should run Apple Help Indexing Tool on $(DOCDIR); \
166 fi
167 @for i in "$(PYTHONAPPSDIR)" "$(APPINSTALLDIR)" "$(APPINSTALLDIR)/Contents"; do \
168 if test ! -d "$(DESTDIR)$$i"; then \
169 echo "Creating directory $(DESTDIR)$$i"; \
170 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$$i"; \
171 fi;\
172 done
173 @for i in $(APPSUBDIRS); do \
174 if test ! -d "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; then \
175 echo "Creating directory $(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \
176 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \
177 else true; \
178 fi; \
179 done
180 @for d in . $(APPSUBDIRS); \
181 do \
182 a=$(APPTEMPLATE)/$$d; \
183 if test ! -d $$a; then continue; else true; fi; \
184 b="$(DESTDIR)$(APPINSTALLDIR)/Contents/$$d"; \
185 for i in $$a/*; \
186 do \
187 case $$i in \
188 *CVS) ;; \
189 *.svn) ;; \
190 *.py[co]) ;; \
191 *.orig) ;; \
192 *~) ;; \
193 *idx) \
194 echo $(CPMAC) "$$i" $$b; \
195 $(CPMAC) "$$i" "$$b"; \
196 ;; \
197 *) \
198 if test -d $$i; then continue; fi; \
199 if test -x $$i; then \
200 echo $(INSTALL_SCRIPT) "$$i" "$$b"; \
201 $(INSTALL_SCRIPT) "$$i" "$$b"; \
202 else \
203 echo $(INSTALL_DATA) "$$i" "$$b"; \
204 $(INSTALL_DATA) "$$i" "$$b"; \
205 fi;; \
206 esac; \
207 done; \
208 done
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000209 $(INSTALL_PROGRAM) $(STRIPFLAG) $(BUILDPYTHON) "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"
Ronald Oussorenf29b6b42009-03-30 20:00:00 +0000210 sed -e "s!%bundleid%!$(PYTHONFRAMEWORKIDENTIFIER)!g" \
211 -e "s!%version%!`$(RUNSHARED) $(BUILDPYTHON) \
212 -c 'import platform; print(platform.python_version())'`!g" \
213 < "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist.in" \
214 > "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist"
215 rm "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist.in"
Thomas Wouters477c8d52006-05-27 19:21:47 +0000216
Georg Brandlfcaf9102008-07-16 02:17:56 +0000217install_Python4way: install_Python
218 lipo -extract i386 -extract ppc7400 -output "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)-32" "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"
219 lipo -extract x86_64 -extract ppc64 -output "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)-64" "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"
220
221
222
Thomas Wouters477c8d52006-05-27 19:21:47 +0000223install_IDLE:
Benjamin Petersonde9c8692008-07-01 18:23:09 +0000224 test -d "$(DESTDIR)$(PYTHONAPPSDIR)" || mkdir -p "$(DESTDIR)$(PYTHONAPPSDIR)"
Ronald Oussoren827822e2009-02-12 15:01:44 +0000225 -test -d "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app" && rm -rf "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app"
Ronald Oussorenaf118602009-01-02 11:48:29 +0000226 /bin/cp -PR "$(srcdir)/IDLE/IDLE.app" "$(DESTDIR)$(PYTHONAPPSDIR)"
Ronald Oussoren672f62a2009-02-12 15:18:15 +0000227 ln -sf "$(INSTALLED_PYTHONAPP)" "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app/Contents/MacOS/Python"
Ronald Oussorenaf118602009-01-02 11:48:29 +0000228 sed -e "s!%prefix%!$(prefix)!g" -e 's!%exe%!$(PYTHONFRAMEWORK)!g' < "$(srcdir)/IDLE/IDLE.app/Contents/MacOS/IDLE" > "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app/Contents/MacOS/IDLE"
Ronald Oussoren21600152008-12-30 12:59:02 +0000229 sed "s!%version%!`$(RUNSHARED) $(BUILDPYTHON) -c 'import platform; print(platform.python_version())'`!g" < "$(srcdir)/IDLE/IDLE.app/Contents/Info.plist" > "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app/Contents/Info.plist"
Ronald Oussoren711b5782009-02-12 15:12:03 +0000230 if [ -f "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" ]; then \
231 /bin/cp -p "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" \
232 "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" ; \
233 sed -e 's!name= IDLE Classic Windows!name= IDLE Classic OSX!g' \
234 < "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" \
235 > "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" ; \
236 rm "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" ; \
237 fi
238 if [ -f "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" ]; then \
239 /bin/cp -p "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" \
240 "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def~" ; \
241 sed -e 's!zoom-height=<Alt-Key-2>!zoom-height=<Option-Key-0>!g' \
242 -e 's!<Alt-Key-!<Option-Key-!g' \
243 < "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def~" \
244 > "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" ; \
245 rm "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def~" ; \
246 fi
Benjamin Petersonde9c8692008-07-01 18:23:09 +0000247 touch "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app"
Thomas Wouters477c8d52006-05-27 19:21:47 +0000248
Ronald Oussoren672f62a2009-02-12 15:18:15 +0000249install_IDLE4way: install_IDLE
250 ln -sf "$(INSTALLED_PYTHONAPP)-32" "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app/Contents/MacOS/Python"
251 sed -e "s!%prefix%!$(prefix)!g" -e 's!%exe%!$(PYTHONFRAMEWORK)-32!g' < "$(srcdir)/IDLE/IDLE.app/Contents/MacOS/IDLE" > "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app/Contents/MacOS/IDLE"
252 touch "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app"
253
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000254$(INSTALLED_PYTHONAPP): install_Python
Thomas Wouters477c8d52006-05-27 19:21:47 +0000255
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000256installextras: $(srcdir)/Extras.ReadMe.txt $(srcdir)/Extras.install.py
Thomas Wouters477c8d52006-05-27 19:21:47 +0000257 $(INSTALL) -d "$(DESTDIR)$(PYTHONAPPSDIR)/Extras"
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000258 $(INSTALL) $(srcdir)/Extras.ReadMe.txt "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/ReadMe.txt"
259 $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Extras.install.py $(srcdir)/../Demo \
Thomas Wouters477c8d52006-05-27 19:21:47 +0000260 "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo"
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000261 $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Extras.install.py $(srcdir)/Demo \
262 "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo.Mac"
Thomas Wouters477c8d52006-05-27 19:21:47 +0000263
264
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000265checkapplepython: $(srcdir)/Tools/fixapplepython23.py
266 @if ! $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Tools/fixapplepython23.py -n; then \
Thomas Wouters477c8d52006-05-27 19:21:47 +0000267 echo "* WARNING: Apple-installed Python 2.3 will have trouble building extensions from now on."; \
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000268 echo "* WARNING: Run $(srcdir)/Tools/fixapplepython23.py with \"sudo\" to fix this."; \
Thomas Wouters477c8d52006-05-27 19:21:47 +0000269 fi
270
271
272clean:
273 rm pythonw
274 cd PythonLauncher && make clean
Thomas Wouters89f507f2006-12-13 04:49:30 +0000275
276Makefile: $(srcdir)/Makefile.in ../config.status
277 cd .. && CONFIG_FILES=Mac/Makefile CONFIG_HEADERS= $(SHELL) ./config.status