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