blob: 467bb32176c664f7843ae6f66bcf11593617992b [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@
Ronald Oussoren712979d2010-04-20 19:51:33 +000020MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
21export MACOSX_DEPLOYMENT_TARGET
22
Christian Heimes81ee3ef2008-05-04 22:42:01 +000023
Thomas Wouters477c8d52006-05-27 19:21:47 +000024
25# These are normally glimpsed from the previous set
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000026bindir=$(prefix)/bin
Ronald Oussoren86b33c82010-04-30 11:41:56 +000027PYTHONAPPSDIR=@FRAMEWORKINSTALLAPPSPREFIX@/$(PYTHONFRAMEWORK) $(VERSION)
Thomas Wouters477c8d52006-05-27 19:21:47 +000028APPINSTALLDIR=$(prefix)/Resources/Python.app
29
30# Variables for installing the "normal" unix binaries
Christian Heimes81ee3ef2008-05-04 22:42:01 +000031INSTALLED_PYTHONAPP=$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)
Thomas Wouters477c8d52006-05-27 19:21:47 +000032
33# Items more-or-less copied from the main Makefile
34DIRMODE=755
35FILEMODE=644
36INSTALL=@INSTALL@
37INSTALL_SYMLINK=ln -fsn
38INSTALL_PROGRAM=@INSTALL_PROGRAM@
39INSTALL_SCRIPT= @INSTALL_SCRIPT@
40INSTALL_DATA=@INSTALL_DATA@
41LN=@LN@
42STRIPFLAG=-s
43CPMAC=/Developer/Tools/CpMac
44
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000045APPTEMPLATE=$(srcdir)/Resources/app
Ronald Oussorenf84d7e92009-05-19 11:27:25 +000046APPSUBDIRS=MacOS Resources
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000047compileall=$(srcdir)/../Lib/compileall.py
Thomas Wouters477c8d52006-05-27 19:21:47 +000048
Ronald Oussoren6f6c5622009-12-24 14:03:19 +000049installapps: install_Python install_pythonw install_PythonLauncher install_IDLE \
50 checkapplepython install_versionedtools
Georg Brandlfcaf9102008-07-16 02:17:56 +000051
52
Thomas Wouters477c8d52006-05-27 19:21:47 +000053install_pythonw: pythonw
54 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)"
55 $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/python$(VERSION)"
Ronald Oussoren38e2d8e2009-05-17 10:45:53 +000056 ln -sf python$(VERSION) "$(DESTDIR)$(prefix)/bin/python3"
57 ln -sf pythonw$(VERSION) "$(DESTDIR)$(prefix)/bin/pythonw3"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +000058ifneq ($(LIPO_32BIT_FLAGS),)
59 lipo $(LIPO_32BIT_FLAGS) -output $(DESTDIR)$(prefix)/bin/python$(VERSION)-32 pythonw
60 lipo $(LIPO_32BIT_FLAGS) -output $(DESTDIR)$(prefix)/bin/pythonw$(VERSION)-32 pythonw
Georg Brandlfcaf9102008-07-16 02:17:56 +000061 ln -sf pythonw$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)"
62 ln -sf python$(VERSION)-32 "$(DESTDIR)$(prefix)/bin/python$(VERSION)"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +000063endif
Georg Brandlfcaf9102008-07-16 02:17:56 +000064
Thomas Wouters477c8d52006-05-27 19:21:47 +000065#
66# Install unix tools in /usr/local/bin. These are just aliases for the
67# actual installation inside the framework.
68#
69installunixtools:
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000070 if [ ! -d "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ]; then \
71 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ;\
Thomas Wouters477c8d52006-05-27 19:21:47 +000072 fi
Ronald Oussoren38e2d8e2009-05-17 10:45:53 +000073 for fn in python3 pythonw3 idle3 pydoc3 python3-config \
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000074 python$(VERSION) pythonw$(VERSION) idle$(VERSION) \
Ronald Oussorenafbca492009-05-26 21:18:59 +000075 pydoc$(VERSION) python$(VERSION)-config 2to3 \
76 2to3-$(VERSION) ;\
Thomas Wouters477c8d52006-05-27 19:21:47 +000077 do \
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000078 ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\
Thomas Wouters477c8d52006-05-27 19:21:47 +000079 done
80
Georg Brandlfcaf9102008-07-16 02:17:56 +000081
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000082#
83# Like installunixtools, but only install links to the versioned binaries.
84#
85altinstallunixtools:
86 if [ ! -d "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ]; then \
87 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ;\
88 fi
89 for fn in python$(VERSION) pythonw$(VERSION) idle$(VERSION) \
Ronald Oussorenafbca492009-05-26 21:18:59 +000090 pydoc$(VERSION) python$(VERSION)-config 2to3-$(VERSION);\
Thomas Wouters73e5a5b2006-06-08 15:35:45 +000091 do \
92 ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\
93 done
94
Thomas Wouters477c8d52006-05-27 19:21:47 +000095# By default most tools are installed without a version in their basename, to
96# make it easier to install (and use) several python versions side-by-side move
97# the tools to a version-specific name and add the non-versioned name as an
98# alias.
99install_versionedtools:
Georg Brandlfcaf9102008-07-16 02:17:56 +0000100 for fn in idle pydoc ;\
Thomas Wouters477c8d52006-05-27 19:21:47 +0000101 do \
Ronald Oussoren38e2d8e2009-05-17 10:45:53 +0000102 if [ -h "$(DESTDIR)$(prefix)/bin/$${fn}3" ]; then \
Thomas Wouters477c8d52006-05-27 19:21:47 +0000103 continue ;\
104 fi ;\
Ronald Oussoren38e2d8e2009-05-17 10:45:53 +0000105 mv "$(DESTDIR)$(prefix)/bin/$${fn}3" "$(DESTDIR)$(prefix)/bin/$${fn}$(VERSION)" ;\
106 ln -sf "$${fn}$(VERSION)" "$(DESTDIR)$(prefix)/bin/$${fn}3" ;\
Thomas Wouters477c8d52006-05-27 19:21:47 +0000107 done
Ronald Oussorenafbca492009-05-26 21:18:59 +0000108 mv "$(DESTDIR)$(prefix)/bin/2to3" "$(DESTDIR)$(prefix)/bin/2to3-$(VERSION)"
Ronald Oussoren8e5bda42009-06-07 15:34:13 +0000109 ln -sf "2to3-$(VERSION)" "$(DESTDIR)$(prefix)/bin/2to3"
Ronald Oussoren38e2d8e2009-05-17 10:45:53 +0000110 if [ ! -h "$(DESTDIR)$(prefix)/bin/python3-config" ]; then \
111 mv "$(DESTDIR)$(prefix)/bin/python3-config" "$(DESTDIR)$(prefix)/bin/python$(VERSION)-config" ;\
112 ln -sf "python$(VERSION)-config" "$(DESTDIR)$(prefix)/bin/python3-config" ; \
Thomas Wouters477c8d52006-05-27 19:21:47 +0000113 fi
114
115
Thomas Wouters89f507f2006-12-13 04:49:30 +0000116pythonw: $(srcdir)/Tools/pythonw.c Makefile
Ronald Oussorenb366cda2010-03-07 09:14:06 +0000117 $(CC) $(LDFLAGS) -DPYTHONFRAMEWORK='"$(PYTHONFRAMEWORK)"' -o $@ $(srcdir)/Tools/pythonw.c -I.. -I$(srcdir)/../Include ../$(PYTHONFRAMEWORK).framework/Versions/$(VERSION)/$(PYTHONFRAMEWORK)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000118
119install_PythonLauncher:
120 cd PythonLauncher && make install DESTDIR=$(DESTDIR)
121
122install_Python:
Thomas Wouters477c8d52006-05-27 19:21:47 +0000123 @for i in "$(PYTHONAPPSDIR)" "$(APPINSTALLDIR)" "$(APPINSTALLDIR)/Contents"; do \
124 if test ! -d "$(DESTDIR)$$i"; then \
125 echo "Creating directory $(DESTDIR)$$i"; \
126 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$$i"; \
127 fi;\
128 done
129 @for i in $(APPSUBDIRS); do \
130 if test ! -d "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; then \
131 echo "Creating directory $(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \
132 $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \
133 else true; \
134 fi; \
135 done
136 @for d in . $(APPSUBDIRS); \
137 do \
138 a=$(APPTEMPLATE)/$$d; \
139 if test ! -d $$a; then continue; else true; fi; \
140 b="$(DESTDIR)$(APPINSTALLDIR)/Contents/$$d"; \
141 for i in $$a/*; \
142 do \
143 case $$i in \
144 *CVS) ;; \
145 *.svn) ;; \
146 *.py[co]) ;; \
147 *.orig) ;; \
148 *~) ;; \
149 *idx) \
150 echo $(CPMAC) "$$i" $$b; \
151 $(CPMAC) "$$i" "$$b"; \
152 ;; \
153 *) \
154 if test -d $$i; then continue; fi; \
155 if test -x $$i; then \
156 echo $(INSTALL_SCRIPT) "$$i" "$$b"; \
157 $(INSTALL_SCRIPT) "$$i" "$$b"; \
158 else \
159 echo $(INSTALL_DATA) "$$i" "$$b"; \
160 $(INSTALL_DATA) "$$i" "$$b"; \
161 fi;; \
162 esac; \
163 done; \
164 done
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000165 $(INSTALL_PROGRAM) $(STRIPFLAG) $(BUILDPYTHON) "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"
Ronald Oussorenf29b6b42009-03-30 20:00:00 +0000166 sed -e "s!%bundleid%!$(PYTHONFRAMEWORKIDENTIFIER)!g" \
167 -e "s!%version%!`$(RUNSHARED) $(BUILDPYTHON) \
168 -c 'import platform; print(platform.python_version())'`!g" \
169 < "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist.in" \
170 > "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist"
171 rm "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist.in"
Thomas Wouters477c8d52006-05-27 19:21:47 +0000172
Georg Brandlfcaf9102008-07-16 02:17:56 +0000173
Thomas Wouters477c8d52006-05-27 19:21:47 +0000174install_IDLE:
Benjamin Petersonde9c8692008-07-01 18:23:09 +0000175 test -d "$(DESTDIR)$(PYTHONAPPSDIR)" || mkdir -p "$(DESTDIR)$(PYTHONAPPSDIR)"
Ronald Oussoren827822e2009-02-12 15:01:44 +0000176 -test -d "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app" && rm -rf "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app"
Ronald Oussorenaf118602009-01-02 11:48:29 +0000177 /bin/cp -PR "$(srcdir)/IDLE/IDLE.app" "$(DESTDIR)$(PYTHONAPPSDIR)"
Ronald Oussoren672f62a2009-02-12 15:18:15 +0000178 ln -sf "$(INSTALLED_PYTHONAPP)" "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app/Contents/MacOS/Python"
Ronald Oussorenaf118602009-01-02 11:48:29 +0000179 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 +0000180 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 +0000181 if [ -f "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" ]; then \
182 /bin/cp -p "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" \
183 "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" ; \
184 sed -e 's!name= IDLE Classic Windows!name= IDLE Classic OSX!g' \
185 < "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" \
186 > "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" ; \
187 rm "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" ; \
188 fi
189 if [ -f "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" ]; then \
190 /bin/cp -p "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" \
191 "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def~" ; \
192 sed -e 's!zoom-height=<Alt-Key-2>!zoom-height=<Option-Key-0>!g' \
193 -e 's!<Alt-Key-!<Option-Key-!g' \
194 < "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def~" \
195 > "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" ; \
196 rm "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def~" ; \
197 fi
Benjamin Petersonde9c8692008-07-01 18:23:09 +0000198 touch "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app"
Thomas Wouters477c8d52006-05-27 19:21:47 +0000199
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000200$(INSTALLED_PYTHONAPP): install_Python
Thomas Wouters477c8d52006-05-27 19:21:47 +0000201
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000202installextras: $(srcdir)/Extras.ReadMe.txt $(srcdir)/Extras.install.py
Thomas Wouters477c8d52006-05-27 19:21:47 +0000203 $(INSTALL) -d "$(DESTDIR)$(PYTHONAPPSDIR)/Extras"
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000204 $(INSTALL) $(srcdir)/Extras.ReadMe.txt "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/ReadMe.txt"
205 $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Extras.install.py $(srcdir)/../Demo \
Thomas Wouters477c8d52006-05-27 19:21:47 +0000206 "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo"
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000207 $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Extras.install.py $(srcdir)/Demo \
208 "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo.Mac"
Thomas Wouters477c8d52006-05-27 19:21:47 +0000209
210
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000211checkapplepython: $(srcdir)/Tools/fixapplepython23.py
212 @if ! $(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Tools/fixapplepython23.py -n; then \
Thomas Wouters477c8d52006-05-27 19:21:47 +0000213 echo "* WARNING: Apple-installed Python 2.3 will have trouble building extensions from now on."; \
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000214 echo "* WARNING: Run $(srcdir)/Tools/fixapplepython23.py with \"sudo\" to fix this."; \
Thomas Wouters477c8d52006-05-27 19:21:47 +0000215 fi
216
217
218clean:
219 rm pythonw
220 cd PythonLauncher && make clean
Thomas Wouters89f507f2006-12-13 04:49:30 +0000221
222Makefile: $(srcdir)/Makefile.in ../config.status
223 cd .. && CONFIG_FILES=Mac/Makefile CONFIG_HEADERS= $(SHELL) ./config.status