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