Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame^] | 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 | |
| 5 | VERSION=@VERSION@ |
| 6 | builddir = ../.. |
| 7 | srcdir = @srcdir@ |
| 8 | prefix=/Library/Frameworks/Python.framework/Versions/$(VERSION) |
| 9 | LIBDEST=$(prefix)/lib/python$(VERSION) |
| 10 | BUILDPYTHON=$(builddir)/python.exe |
| 11 | DESTDIR= |
| 12 | |
| 13 | # These are normally glimpsed from the previous set |
| 14 | bindir=@exec_prefix@/bin |
| 15 | PYTHONAPPSDIR=/Applications/MacPython $(VERSION) |
| 16 | APPINSTALLDIR=$(prefix)/Resources/Python.app |
| 17 | |
| 18 | # Variables for installing the "normal" unix binaries |
| 19 | INSTALLED_PYDOC=$(prefix)/bin/pydoc |
| 20 | INSTALLED_IDLE=$(prefix)/bin/idle |
| 21 | INSTALLED_PYTHON=$(prefix)/bin/python |
| 22 | INSTALLED_PYTHONW=$(prefix)/bin/pythonw |
| 23 | INSTALLED_PYTHONAPP=$(APPINSTALLDIR)/Contents/MacOS/Python |
| 24 | |
| 25 | # Items more-or-less copied from the main Makefile |
| 26 | DIRMODE=755 |
| 27 | FILEMODE=644 |
| 28 | INSTALL=@INSTALL@ |
| 29 | INSTALL_SYMLINK=ln -fsn |
| 30 | INSTALL_PROGRAM=@INSTALL_PROGRAM@ |
| 31 | INSTALL_SCRIPT= @INSTALL_SCRIPT@ |
| 32 | INSTALL_DATA=@INSTALL_DATA@ |
| 33 | LN=@LN@ |
| 34 | STRIPFLAG=-s |
| 35 | CPMAC=/Developer/Tools/CpMac |
| 36 | |
| 37 | APPTEMPLATE=$(srcdir)/../OSXResources/app |
| 38 | APPSUBDIRS=MacOS Resources Resources/English.lproj \ |
| 39 | Resources/English.lproj/Documentation \ |
| 40 | Resources/English.lproj/Documentation/doc \ |
| 41 | Resources/English.lproj/Documentation/ide |
| 42 | DOCDIR=$(srcdir)/../OSXResources/app/Resources/English.lproj/Documentation |
| 43 | DOCINDEX=$(DOCDIR)/"Documentation idx" |
| 44 | CACHERSRC=$(srcdir)/../scripts/cachersrc.py |
| 45 | compileall=$(srcdir)/../../Lib/compileall.py |
| 46 | |
| 47 | installapps: install_Python install_BuildApplet install_PythonLauncher \ |
| 48 | install_IDLE checkapplepython install_pythonw install_versionedtools |
| 49 | |
| 50 | install_pythonw: pythonw |
| 51 | $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/pythonw$(VERSION)" |
| 52 | $(INSTALL_PROGRAM) $(STRIPFLAG) pythonw "$(DESTDIR)$(prefix)/bin/python$(VERSION)" |
| 53 | ln -sf python$(VERSION) "$(DESTDIR)$(prefix)/bin/python" |
| 54 | ln -sf pythonw$(VERSION) "$(DESTDIR)$(prefix)/bin/pythonw" |
| 55 | |
| 56 | # |
| 57 | # Install unix tools in /usr/local/bin. These are just aliases for the |
| 58 | # actual installation inside the framework. |
| 59 | # |
| 60 | installunixtools: |
| 61 | if [ ! -d "$(DESTDIR)/usr/local/bin" ]; then \ |
| 62 | $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)/usr/local/bin" ;\ |
| 63 | fi |
| 64 | for fn in `ls "$(DESTDIR)$(prefix)/bin/"` ; \ |
| 65 | do \ |
| 66 | ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)/usr/local/bin/$${fn}" ;\ |
| 67 | done |
| 68 | |
| 69 | # By default most tools are installed without a version in their basename, to |
| 70 | # make it easier to install (and use) several python versions side-by-side move |
| 71 | # the tools to a version-specific name and add the non-versioned name as an |
| 72 | # alias. |
| 73 | install_versionedtools: |
| 74 | for fn in idle pydoc python-config ;\ |
| 75 | do \ |
| 76 | if [ -h "$(DESTDIR)$(prefix)/bin/$${fn}" ]; then \ |
| 77 | continue ;\ |
| 78 | fi ;\ |
| 79 | mv "$(DESTDIR)$(prefix)/bin/$${fn}" "$(DESTDIR)$(prefix)/bin/$${fn}$(VERSION)" ;\ |
| 80 | ln -sf "$${fn}$(VERSION)" "$(DESTDIR)$(prefix)/bin/$${fn}" ;\ |
| 81 | done |
| 82 | if [ ! -h "$(DESTDIR)$(prefix)/bin/smtpd.py" ]; then \ |
| 83 | mv "$(DESTDIR)$(prefix)/bin/smtpd.py" "$(DESTDIR)$(prefix)/bin/smtpd$(VERSION).py" ;\ |
| 84 | ln -sf "smtpd$(VERSION).py" "$(DESTDIR)$(prefix)/bin/smtpd.py" ;\ |
| 85 | fi |
| 86 | |
| 87 | |
| 88 | pythonw: $(srcdir)/Tools/pythonw.c |
| 89 | $(CC) $(LDFLAGS) -o $@ $(srcdir)/Tools/pythonw.c \ |
| 90 | -DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/Python"' |
| 91 | |
| 92 | |
| 93 | install_PythonLauncher: |
| 94 | cd PythonLauncher && make install DESTDIR=$(DESTDIR) |
| 95 | |
| 96 | install_Python: |
| 97 | @if test ! -f $(DOCINDEX); then \ |
| 98 | echo WARNING: you should run Apple Help Indexing Tool on $(DOCDIR); \ |
| 99 | fi |
| 100 | @for i in "$(PYTHONAPPSDIR)" "$(APPINSTALLDIR)" "$(APPINSTALLDIR)/Contents"; do \ |
| 101 | if test ! -d "$(DESTDIR)$$i"; then \ |
| 102 | echo "Creating directory $(DESTDIR)$$i"; \ |
| 103 | $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$$i"; \ |
| 104 | fi;\ |
| 105 | done |
| 106 | @for i in $(APPSUBDIRS); do \ |
| 107 | if test ! -d "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; then \ |
| 108 | echo "Creating directory $(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \ |
| 109 | $(INSTALL) -d -m $(DIRMODE) "$(DESTDIR)$(APPINSTALLDIR)/Contents/$$i"; \ |
| 110 | else true; \ |
| 111 | fi; \ |
| 112 | done |
| 113 | @for d in . $(APPSUBDIRS); \ |
| 114 | do \ |
| 115 | a=$(APPTEMPLATE)/$$d; \ |
| 116 | if test ! -d $$a; then continue; else true; fi; \ |
| 117 | b="$(DESTDIR)$(APPINSTALLDIR)/Contents/$$d"; \ |
| 118 | for i in $$a/*; \ |
| 119 | do \ |
| 120 | case $$i in \ |
| 121 | *CVS) ;; \ |
| 122 | *.svn) ;; \ |
| 123 | *.py[co]) ;; \ |
| 124 | *.orig) ;; \ |
| 125 | *~) ;; \ |
| 126 | *idx) \ |
| 127 | echo $(CPMAC) "$$i" $$b; \ |
| 128 | $(CPMAC) "$$i" "$$b"; \ |
| 129 | ;; \ |
| 130 | *) \ |
| 131 | if test -d $$i; then continue; fi; \ |
| 132 | if test -x $$i; then \ |
| 133 | echo $(INSTALL_SCRIPT) "$$i" "$$b"; \ |
| 134 | $(INSTALL_SCRIPT) "$$i" "$$b"; \ |
| 135 | else \ |
| 136 | echo $(INSTALL_DATA) "$$i" "$$b"; \ |
| 137 | $(INSTALL_DATA) "$$i" "$$b"; \ |
| 138 | fi;; \ |
| 139 | esac; \ |
| 140 | done; \ |
| 141 | done |
| 142 | $(INSTALL_PROGRAM) $(STRIPFLAG) $(BUILDPYTHON) "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/Python" |
| 143 | |
| 144 | install_IDLE: |
| 145 | cd IDLE && make install |
| 146 | |
| 147 | install_BuildApplet: |
| 148 | $(BUILDPYTHON) $(srcdir)/../scripts/BuildApplet.py \ |
| 149 | --destroot "$(DESTDIR)" \ |
| 150 | --python $(INSTALLED_PYTHONAPP) \ |
| 151 | --output "$(DESTDIR)$(PYTHONAPPSDIR)/Build Applet.app" \ |
| 152 | $(srcdir)/../scripts/BuildApplet.py |
| 153 | |
| 154 | MACLIBDEST=$(LIBDEST)/plat-mac |
| 155 | MACTOOLSDEST=$(prefix)/Mac/Tools |
| 156 | MACTOOLSSRC=$(srcdir)/Mac/Tools |
| 157 | MACTOOLSSUBDIRS=IDE |
| 158 | |
| 159 | installmacsubtree: |
| 160 | @for i in $(MACTOOLSDEST); \ |
| 161 | do \ |
| 162 | if test ! -d $(DESTDIR)$$i; then \ |
| 163 | echo "Creating directory $(DESTDIR)$$i"; \ |
| 164 | $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \ |
| 165 | else true; \ |
| 166 | fi; \ |
| 167 | done |
| 168 | @for d in $(MACTOOLSSUBDIRS); \ |
| 169 | do \ |
| 170 | a=$(MACTOOLSSRC)/$$d; \ |
| 171 | if test ! -d $$a; then continue; else true; fi; \ |
| 172 | b=$(DESTDIR)$(MACTOOLSDEST)/$$d; \ |
| 173 | if test ! -d $$b; then \ |
| 174 | echo "Creating directory $$b"; \ |
| 175 | $(INSTALL) -d -m $(DIRMODE) $$b; \ |
| 176 | else true; \ |
| 177 | fi; \ |
| 178 | done |
| 179 | @for d in $(MACTOOLSSUBDIRS); \ |
| 180 | do \ |
| 181 | a=$(MACTOOLSSRC)/$$d; \ |
| 182 | if test ! -d $$a; then continue; else true; fi; \ |
| 183 | b=$(DESTDIR)$(MACTOOLSDEST)/$$d; \ |
| 184 | for i in $$a/*; \ |
| 185 | do \ |
| 186 | case $$i in \ |
| 187 | *CVS) ;; \ |
| 188 | *.svn) ;; \ |
| 189 | *.py[co]) ;; \ |
| 190 | *.orig) ;; \ |
| 191 | *~) ;; \ |
| 192 | *.rsrc) \ |
| 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 | |
| 209 | |
| 210 | $(BUILDPYTHON) $(CACHERSRC) -v $(DESTDIR)$(MACLIBDEST) $(DESTDIR)$(MACTOOLSDEST) |
| 211 | $(BUILDPYTHON) -Wi -tt $(compileall) -d $(MACTOOLSDEST) -x badsyntax $(DESTDIR)$(MACTOOLSDEST) |
| 212 | $(BUILDPYTHON) -O -Wi -tt $(compileall) -d $(MACTOOLSDEST) -x badsyntax $(DESTDIR)$(MACTOOLSDEST) |
| 213 | |
| 214 | # |
| 215 | # We use the full name here in stead of $(INSTALLED_PYTHONAPP), because |
| 216 | # the latter may be overridden by Makefile.jaguar when building for a pre-installed |
| 217 | $(INSTALLED_PYTHONAPP)/Contents/MacOS/Python: install_Python |
| 218 | |
| 219 | # $(INSTALLED_PYTHON) has to be done by the main Makefile, we cannot do that here. |
| 220 | # At least this rule will give an error if it doesn't exist. |
| 221 | |
| 222 | installextras: |
| 223 | $(INSTALL) -d "$(DESTDIR)$(PYTHONAPPSDIR)/Extras" |
| 224 | $(INSTALL) $(srcdir)/Mac/OSX/Extras.ReadMe.txt "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/ReadMe.txt" |
| 225 | $(BUILDPYTHON) $(srcdir)/Mac/OSX/Extras.install.py $(srcdir)/Demo \ |
| 226 | "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo" |
| 227 | |
| 228 | |
| 229 | checkapplepython: |
| 230 | @if ! $(BUILDPYTHON) $(srcdir)/fixapplepython23.py -n; then \ |
| 231 | echo "* WARNING: Apple-installed Python 2.3 will have trouble building extensions from now on."; \ |
| 232 | echo "* WARNING: Run $(srcdir)/fixapplepython23.py with \"sudo\" to fix this."; \ |
| 233 | fi |
| 234 | |
| 235 | |
| 236 | clean: |
| 237 | rm pythonw |
| 238 | cd PythonLauncher && make clean |
| 239 | cd IDLE && make clean |
| 240 | |
| 241 | |