# Main Recipe for Agide. # Last Change: 2004 Jun 06 # These targets can be used: :attr all {comment = Create a tags file (requires Exuberant ctags)} :attr tags {comment = Create a tags file (requires Exuberant ctags)} :attr check {comment = Check for obvious problems in the Python code} :attr install {comment = Install Agide; uses location of Aap; use PREFIX=path to specify location of "bin/agide" and manual page} :attr uninstall {comment = Uninstall current version of Agide; use PREFIX=path to specify from where; use VERSION=1.123 to specify a different version} all: tags tags {virtual}: :sys ctags -R . # Run pychecker on the Python sources. check: :sys ./check.py :include filelist.aap # Set $Files to the list of files. # Message translations. :child lang/main.aap # Install the Agide files. They need to be placed relative to the Aap "Exec" # directory. install: @if os.name == 'posix': # Get the version string from AgideVersion.py. :cat AgideVersion.py | :eval re.search('version_string = "(\\d[^"]*)"', stdin).group(1) | :assign Version # If user supplied a PREFIX then install Agide under that tree, # otherwise try to guess the Aap directory based on AAP command used. prefix = $?_arg.PREFIX @if prefix: dir = $prefix/lib/aap @if not os.path.isdir(dir) or not glob(dir + '/Exec-*'): :error Aap is not installed under the given PREFIX. @else: # Get the AAP command used: ".../python .../Exec-1.234/aap" @dir = var2list(_no.AAP) @if len(dir) < 2 or string.find(dir[1], "Exec") < 0: :error Cannot determine installation directory of Aap. @dir = dir[1][:string.find(dir[1], "Exec") - 1] # The other files are installd in $PREFIX, if specified. # When not defined use the directory where aap is located. @if os.path.basename(dir) != "aap": :error Unusual location for Aap: $dir @prefix = os.path.dirname(dir) @if os.path.basename(prefix) != "lib": :error Unusual location for Aap: $dir @prefix = os.path.dirname(prefix) @if not os.access(dir, os.W_OK): :error Install directory is not writable: $dir installdir = $dir/Agide-$Version @if not os.access(prefix, os.W_OK): :error Install directory is not writable: $prefix bindir = $prefix/bin mandir = $prefix/man/man1 @if not os.path.isdir(mandir): # Linux uses "man", BSD uses "man". mandir = $prefix/man/man1 # Copy the Agide files. :mkdir {f} $installdir :copy {r}{keepdir} $Files $installdir # Compile *.py files into *.pyc. This must be done after copying, # otherwise they won't be used. @if not skipbuild(): @import compileall @compileall.compile_dir(installdir, 1) # Install the manual page. :mkdir {r}{f} $mandir :copy {f} agide.1 $mandir # Install the language translations. # Skip this when it fails (msgfmt may not be available). @try: :update mofiles :copy {r}{keepdir} lang/*/LC_MESSAGES/agide.mo $installdir @except: :print Could not install message translations. # Create a symbolic link for the program. :print Creating a symbolic link for "agide" in $bindir :mkdir {f} $bindir :symlink {f} $installdir/agide $bindir/agide @elif os.name in ["win32", "mswin", "nt"]: # On MS-Windows we write an agide.bat file in the Windows directory. # That is ugly but the only solution that works reliably everywhere. PREFIX = $?_arg.PREFIX @if not PREFIX: PREFIX = `os.environ.get("WINDIR")` @if not PREFIX: PREFIX = `os.environ.get("SystemRoot")` @if not PREFIX: :print Do not know where to install Agide, please use a PREFIX argument. :print Example: "aap install PREFIX=C:/bin". @else: :progsearch pyloc python @if pyloc: pyloc = python # "python" is in $PATH, don't add path @else: pyloc = `sys.executable` main = `string.replace(os.path.abspath("agide.py"), "\\", "\\\\")` :cat agide.bat | :eval re.sub("agide.py", '"' + main + '"', stdin) | :eval re.sub("python", '"' + pyloc + '"', stdin) >! $PREFIX/agide.bat :print Installed $PREFIX/agide.bat. # Compile *.py files into *.pyc. @if not skipbuild(): @import compileall @compileall.compile_dir(".", 1) # Handle the language translations. # Skip this when it fails (msgfmt may not be available). @try: :update mofiles @except: :print Could not install message translations. @else: :print Sorry, installing is not supported on this platform. # # Uninstall: reverse of install. # Most of the work is to figure out where the files are. # uninstall: @if os.name == 'posix': prefix = $?_arg.PREFIX version = $?VERSION @if not prefix: # Get the AAP command used: ".../python .../Exec-1.234/aap" @dir = var2list(_no.AAP) @if len(dir) < 2 or string.find(dir[1], "Exec") < 0: :error Cannot determine installation directory of Aap. @dir = dir[1][:string.find(dir[1], "Exec") - 1] @if os.path.basename(dir) != "aap": :error Unusual location for Aap: $dir @prefix = os.path.dirname(dir) @if os.path.basename(prefix) != "lib": :error Unusual location for Aap: $dir @prefix = os.path.dirname(prefix) @else: prefix = `os.path.expanduser(prefix)` dir = $prefix/lib/aap/ @if not version: @l = glob(dir + '/Agide-*') @if not l: :error Cannot find Agide in $dir @if len(l) > 1: :print Found: `l` :error Multiple versions found, please specify VERSION. dir = `l[0]` version = `dir[-5:]` @else: dir = $dir/Agide-$version @if not os.access(dir, os.W_OK): :error Install directory is not writable: $dir mandir = $prefix/man/man1 @if not os.path.isdir(mandir): # Linux uses "man", BSD uses "man". mandir = $prefix/man/man1 @if not os.access(mandir, os.W_OK): :error Install directory is not writable: $mandir # Only delete the bin/agide symlink if it points to the version we # uninstall. @try: n = $prefix/bin/agide @if string.find(os.readlink(n), version) >= 0: :del {f} $n @except: @ pass :del {r}{f} $dir # XXX: The manual is always deleted, also when it is for another # version! :del {f} $mandir/agide.1 @elif os.name in ["win32", "mswin", "nt"]: # Delete the agide.bat file that was installed in the Windows directory. PREFIX = $?_arg.PREFIX @if not PREFIX: PREFIX = `os.environ.get("WINDIR")` @if not PREFIX: PREFIX = `os.environ.get("SystemRoot")` @if PREFIX: agide_bat = $PREFIX/agide.bat @if not os.path.exists(agide_bat): PREFIX = @if not PREFIX: # Can't find it, try searching in $PATH. Don't accept agide.bat in # the current directory. :progsearch agide_bat agide.bat @if agide_bat == os.path.abspath("agide.bat"): agide_bat = @if not (agide_bat and os.path.exists(agide_bat)): :print Do not know where "agide.bat" is, please use a PREFIX argument. :print Example: "aap uninstall PREFIX=C:/bin". @else: :delete $agide_bat dir = `os.path.abspath(".")` :print You can now delete the Agide directory "$dir". @else: :print Sorry, uninstalling is not supported on this platform. # vim: sts=4 sw=4 :