blob: 31d3b9f42274f34778fcd6d556d121d562cc95cc [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@
Ronald Oussoren6f6c5622009-12-24 14:03:19 +000018LIPO_32BIT_FLAGS=@LIPO_32BIT_FLAGS@
Ronald Oussoren755740f2010-02-07 19:56:39 +000019CC=@CC@
Christian Heimes81ee3ef2008-05-04 22:42:01 +000020
Thomas Wouters477c8d52006-05-27 19:21:47 +000021
22# These are normally glimpsed from the previous set
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000023bindir=$(prefix)/bin
Christian Heimes81ee3ef2008-05-04 22:42:01 +000024PYTHONAPPSDIR=/Applications/$(PYTHONFRAMEWORK) $(VERSION)
Thomas Wouters477c8d52006-05-27 19:21:47 +000025APPINSTALLDIR=$(prefix)/Resources/Python.app
26
27# Variables for installing the "normal" unix binaries
Christian Heimes81ee3ef2008-05-04 22:42:01 +000028INSTALLED_PYTHONAPP=$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)
Thomas Wouters477c8d52006-05-27 19:21:47 +000029
30# Items more-or-less copied from the main Makefile
31DIRMODE=755
32FILEMODE=644
33INSTALL=@INSTALL@
34INSTALL_SYMLINK=ln -fsn
35INSTALL_PROGRAM=@INSTALL_PROGRAM@
36INSTALL_SCRIPT= @INSTALL_SCRIPT@
37INSTALL_DATA=@INSTALL_DATA@
38LN=@LN@
39STRIPFLAG=-s
40CPMAC=/Developer/Tools/CpMac
41
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000042APPTEMPLATE=$(srcdir)/Resources/app
Ronald Oussorenf84d7e92009-05-19 11:27:25 +000043APPSUBDIRS=MacOS Resources
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000044compileall=$(srcdir)/../Lib/compileall.py
Thomas Wouters477c8d52006-05-27 19:21:47 +000045
Ronald Oussoren6f6c5622009-12-24 14:03:19 +000046installapps: install_Python install_pythonw install_PythonLauncher install_IDLE \
47 checkapplepython install_versionedtools
Georg Brandlfcaf9102008-07-16 02:17:56 +000048
49
Thomas Wouters477c8d52006-05-27 19:21:47 +000050install_pythonw: pythonw
51 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)"
52 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/python$(VERSION)"
Ronald Oussoren38e2d8e2009-05-17 10:45:53 +000053 ln -sf python$(VERSION) "$(DESTDIR)$(prefix)/bin/python3"
54 ln -sf pythonw$(VERSION) "$(DESTDIR)$(prefix)/bin/pythonw3"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +000055ifneq ($(LIPO_32BIT_FLAGS),)
56 lipo $(LIPO_32BIT_FLAGS) -output $(DESTDIR)$(prefix)/bin/python$(VERSION)-32 pythonw
57 lipo $(LIPO_32BIT_FLAGS) -output $(DESTDIR)$(prefix)/bin/pythonw$(VERSION)-32 pythonw
Georg Brandlfcaf9102008-07-16 02:17:56 +000058 ln -sf pythonw$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)"
59 ln -sf python$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/python$(VERSION)"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +000060endif
Georg Brandlfcaf9102008-07-16 02:17:56 +000061
Thomas Wouters477c8d52006-05-27 19:21:47 +000062#
63# Install unix tools in /usr/local/bin. These are just aliases for the
64# actual installation inside the framework.
65#
66installunixtools:
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000067 if [ ! -d "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ]; then \
68 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ;\
Thomas Wouters477c8d52006-05-27 19:21:47 +000069 fi
Ronald Oussoren38e2d8e2009-05-17 10:45:53 +000070 for fn in python3 pythonw3 idle3 pydoc3 python3-config \
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000071 python$(VERSION) pythonw$(VERSION) idle$(VERSION) \
Ronald Oussorenafbca492009-05-26 21:18:59 +000072 pydoc$(VERSION) python$(VERSION)-config 2to3 \
73 2to3-$(VERSION) ;\
Thomas Wouters477c8d52006-05-27 19:21:47 +000074 do \
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000075 ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\
Thomas Wouters477c8d52006-05-27 19:21:47 +000076 done
77
Georg Brandlfcaf9102008-07-16 02:17:56 +000078
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000079#
80# Like installunixtools, but only install links to the versioned binaries.
81#
82altinstallunixtools:
83 if [ ! -d "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ]; then \
84 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ;\
85 fi
86 for fn in python$(VERSION) pythonw$(VERSION) idle$(VERSION) \
Ronald Oussorenafbca492009-05-26 21:18:59 +000087 pydoc$(VERSION) python$(VERSION)-config 2to3-$(VERSION);\
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000088 do \
89 ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\
90 done
91
Thomas Wouters477c8d52006-05-27 19:21:47 +000092# By default most tools are installed without a version in their basename, to
93# make it easier to install (and use) several python versions side-by-side move
94# the tools to a version-specific name and add the non-versioned name as an
95# alias.
96install_versionedtools:
Georg Brandlfcaf9102008-07-16 02:17:56 +000097 for fn in idle pydoc ;\
Thomas Wouters477c8d52006-05-27 19:21:47 +000098 do \
Ronald Oussoren38e2d8e2009-05-17 10:45:53 +000099 if [ -h "$(DESTDIR)$(prefix)/bin/$${fn}3" ]; then \
Thomas Wouters477c8d52006-05-27 19:21:47 +0000100 continue ;\
101 fi ;\
Ronald Oussoren38e2d8e2009-05-17 10:45:53 +0000102 mv "$(DESTDIR)$(prefix)/bin/$${fn}3" "$(DESTDIR)$(prefix)/bin/$${fn}$(VERSION)" ;\
103 ln -sf "$${fn}$(VERSION)" "$(DESTDIR)$(prefix)/bin/$${fn}3" ;\
Thomas Wouters477c8d52006-05-27 19:21:47 +0000104 done
Ronald Oussorenafbca492009-05-26 21:18:59 +0000105 mv "$(DESTDIR)$(prefix)/bin/2to3" "$(DESTDIR)$(prefix)/bin/2to3-$(VERSION)"
Ronald Oussoren8e5bda42009-06-07 15:34:13 +0000106 ln -sf "2to3-$(VERSION)" "$(DESTDIR)$(prefix)/bin/2to3"
Ronald Oussoren38e2d8e2009-05-17 10:45:53 +0000107 if [ ! -h "$(DESTDIR)$(prefix)/bin/python3-config" ]; then \
108 mv "$(DESTDIR)$(prefix)/bin/python3-config" "$(DESTDIR)$(prefix)/bin/python$(VERSION)-config" ;\
109 ln -sf "python$(VERSION)-config" "$(DESTDIR)$(prefix)/bin/python3-config" ; \
Thomas Wouters477c8d52006-05-27 19:21:47 +0000110 fi
111
112
Thomas Wouters89f507f2006-12-13 04:49:30 +0000113pythonw: $(srcdir)/Tools/pythonw.c Makefile
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000114 $(CC) $(LDFLAGS) -o $@ $(srcdir)/Tools/pythonw.c -I.. -I$(srcdir)/../Include ../$(PYTHONFRAMEWORK).framework/Versions/$(VERSION)/$(PYTHONFRAMEWORK)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000115
116install_PythonLauncher:
117 cd PythonLauncher && make install DESTDIR=$(DESTDIR)
118
119install_Python:
Thomas Wouters477c8d52006-05-27 19:21:47 +0000120 @for i in "$(PYTHONAPPSDIR)" "$(APPINSTALLDIR)" "$(APPINSTALLDIR)/Contents"; do \
121 if test ! -d "$(DESTDIR)$$i"; then \
122 echo "Creating directory $(DESTDIR)$$i"; \
123 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$$i"; \
124 fi;\
125 done
126 @for i in $(APPSUBDIRS); do \
127 if test ! -d "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; then \
128 echo "Creating directory $(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \
129 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \
130 else true; \
131 fi; \
132 done
133 @for d in . $(APPSUBDIRS); \
134 do \
135 a=$(APPTEMPLATE)/$$d; \
136 if test ! -d $$a; then continue; else true; fi; \
137 b="$(DESTDIR)$(APPINSTALLDIR)/Contents/$$d"; \
138 for i in $$a/*; \
139 do \
140 case $$i in \
141 *CVS) ;; \
142 *.svn) ;; \
143 *.py[co]) ;; \
144 *.orig) ;; \
145 *~) ;; \
146 *idx) \
147 echo $(CPMAC) "$$i" $$b; \
148 $(CPMAC) "$$i" "$$b"; \
149 ;; \
150 *) \
151 if test -d $$i; then continue; fi; \
152 if test -x $$i; then \
153 echo $(INSTALL_SCRIPT) "$$i" "$$b"; \
154 $(INSTALL_SCRIPT) "$$i" "$$b"; \
155 else \
156 echo $(INSTALL_DATA) "$$i" "$$b"; \
157 $(INSTALL_DATA) "$$i" "$$b"; \
158 fi;; \
159 esac; \
160 done; \
161 done
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000162 $(INSTALL_PROGRAM) $(STRIPFLAG) $(BUILDPYTHON) "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"
Ronald Oussorenf29b6b42009-03-30 20:00:00 +0000163 sed -e "s!%bundleid%!$(PYTHONFRAMEWORKIDENTIFIER)!g" \
164 -e "s!%version%!`$(RUNSHARED) $(BUILDPYTHON) \
165 -c 'import platform; print(platform.python_version())'`!g" \
166 < "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist.in" \
167 > "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist"
168 rm "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist.in"
Thomas Wouters477c8d52006-05-27 19:21:47 +0000169
Georg Brandlfcaf9102008-07-16 02:17:56 +0000170
Thomas Wouters477c8d52006-05-27 19:21:47 +0000171install_IDLE:
Benjamin Petersonde9c8692008-07-01 18:23:09 +0000172 test -d "$(DESTDIR)$(PYTHONAPPSDIR)" || mkdir -p "$(DESTDIR)$(PYTHONAPPSDIR)"
Ronald Oussoren827822e2009-02-12 15:01:44 +0000173 -test -d "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app" && rm -rf "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app"
Ronald Oussorenaf118602009-01-02 11:48:29 +0000174 /bin/cp -PR "$(srcdir)/IDLE/IDLE.app" "$(DESTDIR)$(PYTHONAPPSDIR)"
Ronald Oussoren672f62a2009-02-12 15:18:15 +0000175 ln -sf "$(INSTALLED_PYTHONAPP)" "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app/Contents/MacOS/Python"
Ronald Oussorenaf118602009-01-02 11:48:29 +0000176 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 +0000177 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 +0000178 if [ -f "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" ]; then \
179 /bin/cp -p "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" \
180 "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" ; \
181 sed -e 's!name= IDLE Classic Windows!name= IDLE Classic OSX!g' \
182 < "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" \
183 > "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" ; \
184 rm "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" ; \
185 fi
186 if [ -f "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" ]; then \
187 /bin/cp -p "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" \
188 "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def~" ; \
189 sed -e 's!zoom-height=<Alt-Key-2>!zoom-height=<Option-Key-0>!g' \
190 -e 's!<Alt-Key-!<Option-Key-!g' \
191 < "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def~" \
192 > "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" ; \
193 rm "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def~" ; \
194 fi
Benjamin Petersonde9c8692008-07-01 18:23:09 +0000195 touch "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app"
Thomas Wouters477c8d52006-05-27 19:21:47 +0000196
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000197$(INSTALLED_PYTHONAPP): install_Python
Thomas Wouters477c8d52006-05-27 19:21:47 +0000198
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000199installextras: $(srcdir)/Extras.ReadMe.txt $(srcdir)/Extras.install.py
Thomas Wouters477c8d52006-05-27 19:21:47 +0000200 $(INSTALL) -d "$(DESTDIR)$(PYTHONAPPSDIR)/Extras"
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000201 $(INSTALL) $(srcdir)/Extras.ReadMe.txt "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/ReadMe.txt"
202 $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Extras.install.py $(srcdir)/../Demo \
Thomas Wouters477c8d52006-05-27 19:21:47 +0000203 "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo"
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000204 $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Extras.install.py $(srcdir)/Demo \
205 "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo.Mac"
Thomas Wouters477c8d52006-05-27 19:21:47 +0000206
207
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000208checkapplepython: $(srcdir)/Tools/fixapplepython23.py
209 @if ! $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Tools/fixapplepython23.py -n; then \
Thomas Wouters477c8d52006-05-27 19:21:47 +0000210 echo "* WARNING: Apple-installed Python 2.3 will have trouble building extensions from now on."; \
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000211 echo "* WARNING: Run $(srcdir)/Tools/fixapplepython23.py with \"sudo\" to fix this."; \
Thomas Wouters477c8d52006-05-27 19:21:47 +0000212 fi
213
214
215clean:
216 rm pythonw
217 cd PythonLauncher && make clean
Thomas Wouters89f507f2006-12-13 04:49:30 +0000218
219Makefile: $(srcdir)/Makefile.in ../config.status
220 cd .. && CONFIG_FILES=Mac/Makefile CONFIG_HEADERS= $(SHELL) ./config.status