• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 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@
6ABIFLAGS=@ABIFLAGS@
7LDVERSION=@LDVERSION@
8ENSUREPIP=@ENSUREPIP@
9builddir = ..
10srcdir=@srcdir@
11prefix=@prefix@
12exec_prefix=@exec_prefix@
13LIBDEST=$(prefix)/lib/python$(VERSION)
14RUNSHARED=@RUNSHARED@
15BUILDEXE=@BUILDEXEEXT@
16BUILDPYTHON=$(builddir)/python$(BUILDEXE)
17DESTDIR=
18LDFLAGS=@LDFLAGS@
19FRAMEWORKUNIXTOOLSPREFIX=@FRAMEWORKUNIXTOOLSPREFIX@
20PYTHONFRAMEWORK=@PYTHONFRAMEWORK@
21PYTHONFRAMEWORKIDENTIFIER=@PYTHONFRAMEWORKIDENTIFIER@
22LIPO_32BIT_FLAGS=@LIPO_32BIT_FLAGS@
23CC=@CC@
24MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
25export MACOSX_DEPLOYMENT_TARGET
26
27
28
29# These are normally glimpsed from the previous set
30BINDIR=		@bindir@
31PYTHONAPPSDIR=@FRAMEWORKINSTALLAPPSPREFIX@/$(PYTHONFRAMEWORK) $(VERSION)
32APPINSTALLDIR=$(prefix)/Resources/Python.app
33
34# Variables for installing the "normal" unix binaries
35INSTALLED_PYTHONAPP=$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)
36
37# Items more-or-less copied from the main Makefile
38DIRMODE=755
39FILEMODE=644
40INSTALL=@INSTALL@
41INSTALL_SYMLINK=ln -fsn
42INSTALL_PROGRAM=@INSTALL_PROGRAM@
43INSTALL_SCRIPT= @INSTALL_SCRIPT@
44INSTALL_DATA=@INSTALL_DATA@
45LN=@LN@
46STRIPFLAG=-s
47CPMAC=CpMac
48
49APPTEMPLATE=$(srcdir)/Resources/app
50APPSUBDIRS=MacOS Resources
51compileall=$(srcdir)/../Lib/compileall.py
52
53installapps: install_Python install_PythonLauncher install_IDLE
54
55#
56# Install unix tools in /usr/local/bin. These are just aliases for the
57# actual installation inside the framework.
58#
59installunixtools:
60	if [ ! -d "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ]; then  \
61		$(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ;\
62	fi
63	cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
64	for fn in \
65			2to3 \
66			idle3 \
67			pydoc3 \
68			python3 \
69			python3-config \
70			; \
71	do \
72		rm -f $${fn} ; \
73		$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
74	done
75	-if test "x$(VERSION)" != "x$(LDVERSION)"; then \
76		cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
77		for fn in \
78				python$(VERSION)-config \
79				; \
80		do \
81			rm -f $${fn} ;\
82			$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
83		done ;\
84	fi
85	-if test "x$(LIPO_32BIT_FLAGS)" != "x"; then \
86		cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
87		for fn in \
88				python3-32 \
89				; \
90		do \
91			rm -f $${fn} ;\
92			$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
93		done ;\
94	fi
95	-if test "x$(ENSUREPIP)" != "xno"  ; then \
96		cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
97		for fn in \
98				pip3 \
99				; \
100		do \
101			rm -f $${fn} ;\
102			$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
103		done ;\
104	fi
105
106#
107# Like installunixtools, but only install links to the versioned binaries.
108#
109altinstallunixtools:
110	if [ ! -d "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ]; then  \
111		$(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ;\
112	fi
113	cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
114	for fn in \
115			2to3-$(VERSION) \
116			idle$(VERSION) \
117			pydoc$(VERSION) \
118			python$(VERSION) \
119			python$(LDVERSION)-config \
120			; \
121	do \
122		rm -f $${fn} ;\
123		$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
124	done
125	-if test "x$(VERSION)" != "x$(LDVERSION)"; then \
126		cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
127		for fn in \
128				python$(LDVERSION) \
129				; \
130		do \
131			rm -f $${fn} ;\
132			$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
133		done ;\
134	fi
135	-if test "x$(LIPO_32BIT_FLAGS)" != "x"; then \
136		cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
137		for fn in \
138				python$(VERSION)-32 \
139				; \
140		do \
141			rm -f $${fn} ;\
142			$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
143		done ;\
144	fi
145	-if test "x$(ENSUREPIP)" != "xno"  ; then \
146		cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
147		for fn in \
148				easy_install-$(VERSION) \
149				pip$(VERSION) \
150				; \
151		do \
152			rm -f $${fn} ;\
153			$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
154		done ;\
155	fi
156
157pythonw: $(srcdir)/Tools/pythonw.c Makefile
158	$(CC) $(LDFLAGS) -DPYTHONFRAMEWORK='"$(PYTHONFRAMEWORK)"' -o $@ \
159		$(srcdir)/Tools/pythonw.c -I.. -I$(srcdir)/../Include \
160		../$(PYTHONFRAMEWORK).framework/Versions/$(VERSION)/$(PYTHONFRAMEWORK)
161
162install_PythonLauncher:
163	cd PythonLauncher && make install DESTDIR=$(DESTDIR)
164
165install_Python:
166	@for i in "$(PYTHONAPPSDIR)" "$(APPINSTALLDIR)" "$(APPINSTALLDIR)/Contents"; do \
167		if test ! -d "$(DESTDIR)$$i"; then \
168			echo "Creating directory $(DESTDIR)$$i"; \
169			$(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$$i"; \
170		fi;\
171	done
172	@for i in $(APPSUBDIRS); do \
173		if test ! -d "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; then \
174			echo "Creating directory $(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \
175			$(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \
176		else	true; \
177		fi; \
178	done
179	@for d in . $(APPSUBDIRS); \
180	do \
181		a=$(APPTEMPLATE)/$$d; \
182		if test ! -d $$a; then continue; else true; fi; \
183		b="$(DESTDIR)$(APPINSTALLDIR)/Contents/$$d"; \
184		for i in $$a/*; \
185		do \
186			case $$i in \
187			*CVS) ;; \
188			*.svn) ;; \
189			*.py[co]) ;; \
190			*.orig) ;; \
191			*~) ;; \
192			*idx) \
193				echo $(CPMAC) "$$i" $$b; \
194				$(CPMAC) "$$i" "$$b"; \
195				;; \
196			*) \
197				if test -d $$i; then continue; fi; \
198				if test -x $$i; then \
199				    echo $(INSTALL_SCRIPT) "$$i" "$$b"; \
200				    $(INSTALL_SCRIPT) "$$i" "$$b"; \
201				else \
202				    echo $(INSTALL_DATA) "$$i" "$$b"; \
203				    $(INSTALL_DATA) "$$i" "$$b"; \
204				fi;; \
205			esac; \
206		done; \
207	done
208	$(INSTALL_PROGRAM) $(STRIPFLAG) $(BUILDPYTHON) "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"
209	sed -e "s!%bundleid%!$(PYTHONFRAMEWORKIDENTIFIER)!g" \
210		-e "s!%version%!`$(RUNSHARED) $(BUILDPYTHON) \
211		-c 'import platform; print(platform.python_version())'`!g" \
212		< "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist.in" \
213		> "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist"
214	rm "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist.in"
215
216
217install_IDLE:
218	test -d "$(DESTDIR)$(PYTHONAPPSDIR)" || mkdir -p "$(DESTDIR)$(PYTHONAPPSDIR)"
219	-test -d "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app" && rm -rf "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app"
220	/bin/cp -PR "$(srcdir)/IDLE/IDLE.app" "$(DESTDIR)$(PYTHONAPPSDIR)"
221	ln -sf "$(INSTALLED_PYTHONAPP)" "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app/Contents/MacOS/Python"
222	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"
223	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"
224	if [ -f "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" ]; then \
225		/bin/cp -p "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" \
226			"$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" ; \
227		sed -e 's!name= IDLE Classic Windows!name= IDLE Classic OSX!g' \
228			< "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" \
229			> "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" ; \
230		rm "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" ; \
231	fi
232	if [ -f "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" ]; then \
233		/bin/cp -p "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" \
234			"$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def~" ; \
235		sed -e 's!zoom-height=<Alt-Key-2>!zoom-height=<Option-Key-0>!g' \
236			-e 's!<Alt-Key-!<Option-Key-!g' \
237			< "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def~" \
238			> "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" ; \
239		rm "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def~" ; \
240	fi
241	touch "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app"
242
243$(INSTALLED_PYTHONAPP): install_Python
244
245installextras: $(srcdir)/Extras.install.py
246	$(INSTALL) -d "$(DESTDIR)$(prefix)/share/doc/python$(VERSION)/examples"
247	$(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Extras.install.py $(srcdir)/../Tools \
248		"$(DESTDIR)$(prefix)/share/doc/python$(VERSION)/examples/Tools" ; \
249		chmod -R ugo+rX,go-w "$(DESTDIR)$(prefix)/share/doc/python$(VERSION)/examples/Tools"
250
251clean:
252	rm pythonw
253	cd PythonLauncher && make clean
254
255Makefile: $(srcdir)/Makefile.in ../config.status
256	cd .. && CONFIG_FILES=Mac/Makefile CONFIG_HEADERS= $(SHELL) ./config.status
257