Makefile.in 8.14 KB
Newer Older
1 2 3 4 5
# This file can be invoked from the various frameworkinstall... targets in the 
# main Makefile. The next couple of variables are overridden on the 
# commandline in that case.

VERSION=@VERSION@
6 7
ABIFLAGS=@ABIFLAGS@
LDVERSION=@LDVERSION@
8
ENSUREPIP=@ENSUREPIP@
9 10
builddir = ..
srcdir=@srcdir@
11
prefix=@prefix@
12
exec_prefix=@exec_prefix@
13
LIBDEST=$(prefix)/lib/python$(VERSION)
14 15 16
RUNSHARED=@RUNSHARED@
BUILDEXE=@BUILDEXEEXT@
BUILDPYTHON=$(builddir)/python$(BUILDEXE)
17
DESTDIR=
18 19
LDFLAGS=@LDFLAGS@
FRAMEWORKUNIXTOOLSPREFIX=@FRAMEWORKUNIXTOOLSPREFIX@
Christian Heimes's avatar
Christian Heimes committed
20
PYTHONFRAMEWORK=@PYTHONFRAMEWORK@
21
PYTHONFRAMEWORKIDENTIFIER=@PYTHONFRAMEWORKIDENTIFIER@
22
LIPO_32BIT_FLAGS=@LIPO_32BIT_FLAGS@
23
CC=@CC@
24 25 26
MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
export MACOSX_DEPLOYMENT_TARGET

Christian Heimes's avatar
Christian Heimes committed
27

28 29

# These are normally glimpsed from the previous set
30
BINDIR=		@bindir@
31
PYTHONAPPSDIR=@FRAMEWORKINSTALLAPPSPREFIX@/$(PYTHONFRAMEWORK) $(VERSION)
32 33 34
APPINSTALLDIR=$(prefix)/Resources/Python.app

# Variables for installing the "normal" unix binaries
Christian Heimes's avatar
Christian Heimes committed
35
INSTALLED_PYTHONAPP=$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)
36 37 38 39 40 41 42 43 44 45 46

# Items more-or-less copied from the main Makefile
DIRMODE=755
FILEMODE=644
INSTALL=@INSTALL@
INSTALL_SYMLINK=ln -fsn
INSTALL_PROGRAM=@INSTALL_PROGRAM@
INSTALL_SCRIPT= @INSTALL_SCRIPT@
INSTALL_DATA=@INSTALL_DATA@
LN=@LN@
STRIPFLAG=-s
Ned Deily's avatar
Ned Deily committed
47
CPMAC=CpMac
48

49
APPTEMPLATE=$(srcdir)/Resources/app
50
APPSUBDIRS=MacOS Resources
51
compileall=$(srcdir)/../Lib/compileall.py
52

53
installapps: install_Python install_PythonLauncher install_IDLE
54

55 56 57 58 59
#
# Install unix tools in /usr/local/bin. These are just aliases for the 
# actual installation inside the framework.
#
installunixtools:
60 61
	if [ ! -d "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ]; then  \
		$(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ;\
62
	fi
63 64 65 66 67 68 69 70 71
	cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
	for fn in \
			2to3 \
			idle3 \
			pydoc3 \
			python3 \
			python3-config \
			pyvenv \
			; \
72
	do \
73 74
		rm -f $${fn} ; \
		$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
75
	done
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
	-if test "x$(VERSION)" != "x$(LDVERSION)"; then \
		cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
		for fn in \
				python$(VERSION)-config \
				; \
		do \
			rm -f $${fn} ;\
			$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
		done ;\
	fi
	-if test "x$(LIPO_32BIT_FLAGS)" != "x"; then \
		cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
		for fn in \
				python3-32 \
				; \
		do \
			rm -f $${fn} ;\
			$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
		done ;\
	fi
96 97 98 99 100 101 102 103 104 105
	-if test "x$(ENSUREPIP)" != "xno"  ; then \
		cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
		for fn in \
				pip3 \
				; \
		do \
			rm -f $${fn} ;\
			$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
		done ;\
	fi
106

107 108 109 110 111 112 113
#
# Like installunixtools, but only install links to the versioned binaries.
#
altinstallunixtools:
	if [ ! -d "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ]; then  \
		$(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" ;\
	fi
114 115 116 117 118 119 120 121 122
	cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
	for fn in \
			2to3-$(VERSION) \
			idle$(VERSION) \
			pydoc$(VERSION) \
			python$(VERSION) \
			python$(LDVERSION)-config \
			pyvenv-$(VERSION) \
			; \
123
	do \
124 125
		rm -f $${fn} ;\
		$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
126
	done
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
	-if test "x$(VERSION)" != "x$(LDVERSION)"; then \
		cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
		for fn in \
				python$(LDVERSION) \
				; \
		do \
			rm -f $${fn} ;\
			$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
		done ;\
	fi
	-if test "x$(LIPO_32BIT_FLAGS)" != "x"; then \
		cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
		for fn in \
				python$(VERSION)-32 \
				; \
		do \
			rm -f $${fn} ;\
			$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
		done ;\
	fi
147 148 149 150 151 152 153 154 155 156 157
	-if test "x$(ENSUREPIP)" != "xno"  ; then \
		cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \
		for fn in \
				easy_install-$(VERSION) \
				pip$(VERSION) \
				; \
		do \
			rm -f $${fn} ;\
			$(LN) -s $(BINDIR)/$${fn} $${fn} ;\
		done ;\
	fi
158

159
pythonw: $(srcdir)/Tools/pythonw.c Makefile
160 161 162
	$(CC) $(LDFLAGS) -DPYTHONFRAMEWORK='"$(PYTHONFRAMEWORK)"' -o $@ \
		$(srcdir)/Tools/pythonw.c -I.. -I$(srcdir)/../Include \
		../$(PYTHONFRAMEWORK).framework/Versions/$(VERSION)/$(PYTHONFRAMEWORK)
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209

install_PythonLauncher:
	cd PythonLauncher && make install DESTDIR=$(DESTDIR)

install_Python:
	@for i in "$(PYTHONAPPSDIR)" "$(APPINSTALLDIR)" "$(APPINSTALLDIR)/Contents"; do \
		if test ! -d "$(DESTDIR)$$i"; then \
			echo "Creating directory $(DESTDIR)$$i"; \
			$(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$$i"; \
		fi;\
	done
	@for i in $(APPSUBDIRS); do \
		if test ! -d "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; then \
			echo "Creating directory $(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \
			$(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \
		else	true; \
		fi; \
	done
	@for d in . $(APPSUBDIRS); \
	do \
		a=$(APPTEMPLATE)/$$d; \
		if test ! -d $$a; then continue; else true; fi; \
		b="$(DESTDIR)$(APPINSTALLDIR)/Contents/$$d"; \
		for i in $$a/*; \
		do \
			case $$i in \
			*CVS) ;; \
			*.svn) ;; \
			*.py[co]) ;; \
			*.orig) ;; \
			*~) ;; \
			*idx) \
				echo $(CPMAC) "$$i" $$b; \
				$(CPMAC) "$$i" "$$b"; \
				;; \
			*) \
				if test -d $$i; then continue; fi; \
				if test -x $$i; then \
				    echo $(INSTALL_SCRIPT) "$$i" "$$b"; \
				    $(INSTALL_SCRIPT) "$$i" "$$b"; \
				else \
				    echo $(INSTALL_DATA) "$$i" "$$b"; \
				    $(INSTALL_DATA) "$$i" "$$b"; \
				fi;; \
			esac; \
		done; \
	done
Christian Heimes's avatar
Christian Heimes committed
210
	$(INSTALL_PROGRAM) $(STRIPFLAG) $(BUILDPYTHON) "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"
211 212 213 214 215 216
	sed -e "s!%bundleid%!$(PYTHONFRAMEWORKIDENTIFIER)!g" \
		-e "s!%version%!`$(RUNSHARED) $(BUILDPYTHON) \
		-c 'import platform; print(platform.python_version())'`!g" \
		< "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist.in" \
		> "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist"
	rm "$(DESTDIR)$(APPINSTALLDIR)/Contents/Info.plist.in"
217

218

219
install_IDLE:
220
	test -d "$(DESTDIR)$(PYTHONAPPSDIR)" || mkdir -p "$(DESTDIR)$(PYTHONAPPSDIR)"
221
	-test -d "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app" && rm -rf "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app"
Ronald Oussoren's avatar
Ronald Oussoren committed
222
	/bin/cp -PR "$(srcdir)/IDLE/IDLE.app" "$(DESTDIR)$(PYTHONAPPSDIR)"
223
	ln -sf "$(INSTALLED_PYTHONAPP)" "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app/Contents/MacOS/Python"
224 225 226 227
ifneq ($(LIPO_32BIT_FLAGS),)
	rm "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app/Contents/MacOS/Python"
	lipo $(LIPO_32BIT_FLAGS) -output "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app/Contents/MacOS/Python" "$(BUILDPYTHON)"
endif
Ronald Oussoren's avatar
Ronald Oussoren committed
228
	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"
229
	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"
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
	if [ -f "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" ]; then \
		/bin/cp -p "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" \
			"$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" ; \
		sed -e 's!name= IDLE Classic Windows!name= IDLE Classic OSX!g' \
			< "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" \
			> "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def" ; \
		rm "$(DESTDIR)$(LIBDEST)/idlelib/config-main.def~" ; \
	fi
	if [ -f "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" ]; then \
		/bin/cp -p "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" \
			"$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def~" ; \
		sed -e 's!zoom-height=<Alt-Key-2>!zoom-height=<Option-Key-0>!g' \
			-e 's!<Alt-Key-!<Option-Key-!g' \
			< "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def~" \
			> "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def" ; \
		rm "$(DESTDIR)$(LIBDEST)/idlelib/config-extensions.def~" ; \
	fi
247
	touch "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app"
248

249
$(INSTALLED_PYTHONAPP): install_Python
250

251 252
installextras: $(srcdir)/Extras.install.py
	$(INSTALL) -d "$(DESTDIR)$(prefix)/share/doc/python$(VERSION)/examples"
253
	$(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Extras.install.py $(srcdir)/../Tools \
254 255
		"$(DESTDIR)$(prefix)/share/doc/python$(VERSION)/examples/Tools" ; \
		chmod -R ugo+rX,go-w "$(DESTDIR)$(prefix)/share/doc/python$(VERSION)/examples/Tools"
256 257 258 259

clean:
	rm pythonw
	cd PythonLauncher && make clean
260 261 262

Makefile: $(srcdir)/Makefile.in ../config.status
	cd .. && CONFIG_FILES=Mac/Makefile CONFIG_HEADERS= $(SHELL) ./config.status