1# A-A-P recipe for building Vim
2#
3# There are no user choices in here!
4# Put configure arguments in the file config.arg.
5# Later there will be a config.txt file that contains examples and
6# explanations.
7#
8# Optional arguments:
9#  PREFIX=dir           Overrules the install directory.
10#                       Can be specified when installing only.
11#                       Example: aap install PREFIX=$HOME
12#
13@if os.name != "posix":
14    :error Sorry, this recipe only works for Unix-like systems.
15
16# Skip the configure stuff when "link.sh" is executing this recipe recursively
17# to build pathdef.c or not building something and auto/config.aap does exist.
18@if ((_no.TARGETARG != "pathdef" and has_build_target())
19@       or not os.path.exists("auto/config.aap")):
20
21    #
22    # A U T O C O N F
23    #
24
25    # Run autoconf when configure.in has been changed since it was last run.
26    # This is skipped when the signatures in "mysign" are up-to-date.  When
27    # there is no autoconf program skip this (the signature is often the only
28    # thing that's outdated)
29    auto/configure {signfile = mysign} : configure.in
30        @if not program_path("autoconf"):
31            :print Can't find autoconf, using existing configure script.
32        @else:
33            # Move configure aside, autoconf would overwrite it
34            :move {exist} configure configure.save
35            :sys autoconf
36            :cat configure | :eval re.sub('\\./config.log', 'auto/config.log', stdin) | :eval re.sub('>config.log', '>auto/config.log', stdin) >! auto/configure
37            :chmod 755 auto/configure
38            :move configure.save configure
39            :del {force} auto/config.cache auto/config.status
40
41    # Change the configure script to produce config.aap instead of config.mk.
42    auto/configure.aap : auto/configure
43        :print Adjusting auto/configure for A-A-P.
44        :cat auto/configure | :eval re.sub("config.mk", "config.aap", stdin)
45                                                        >! auto/configure.aap
46        :chmod 755 auto/configure.aap
47
48    # The configure script uses the directory where it's located, use a link.
49    configure.aap:  {buildcheck=}
50        :symlink {f} auto/configure.aap configure.aap
51
52    # Dependency: run configure.aap to update config.h and config.aap in the
53    # "auto" directory.
54    # NOTE: we can only build for one architecture, because -MM doesn't work
55    # when building for both.
56    config {virtual} auto/config.h auto/config.aap :
57                         auto/configure.aap configure.aap
58                         config.arg config.h.in config.aap.in
59        # Use "uname -a" to detect the architecture of the system.
60        @ok, uname = redir_system('uname -a', 0)
61        @if string.find(uname, "i386") >= 0:
62        @   arch = "i386"
63        @else:
64        @   arch = "ppc"
65        :print Building for $arch system
66        config_args = `file2string("config.arg")`
67        :sys CONFIG_STATUS=auto/config.status
68                ./configure.aap $config_args
69                    --with-mac-arch=$arch
70                    --cache-file=auto/config.cache
71
72    # Configure arguments: create an empty "config.arg" file when its missing
73    config.arg:
74        :touch {exist} config.arg
75
76    # "auto/config.aap" contains a lot of settings, such as the name of the
77    # executable "Target".
78    # First update it, forcefully if the "reconfig" target was used.
79    @if _no.TARGETARG != "comment" and _no.TARGETARG != "make":
80        @if "reconfig" in var2list(_no.TARGETARG):
81            :del {force} auto/config.cache auto/config.status
82            :update {force} auto/config.aap
83        @else:
84            :update auto/config.aap
85
86# Include the recipe that autoconf generated.
87:include auto/config.aap
88
89# Unfortunately "-M" doesn't work when building for two architectures.  Switch
90# back to PPC only.
91@if string.find(_no.CPPFLAGS, "-arch i386 -arch ppc") >= 0:
92    CPPFLAGS = `string.replace(_no.CPPFLAGS, "-arch i386 -arch ppc", "-arch ppc")`
93
94# A "PREFIX=dir" argument overrules the value of $prefix
95# But don't use the default "/usr/local".
96@if _no.get("PREFIX") and _no.get("PREFIX") != '/usr/local':
97    prefix = $PREFIX
98
99# Don't want "~/" in prefix.
100prefix = `os.path.expanduser(prefix)`
101
102# For Mac.
103APPDIR = $(VIMNAME).app
104
105### Names of the programs and targets
106VIMTARGET       = $VIMNAME$EXESUF
107EXTARGET        = $EXNAME$LNKSUF
108VIEWTARGET      = $VIEWNAME$LNKSUF
109GVIMNAME        = g$VIMNAME
110GVIMTARGET      = $GVIMNAME$LNKSUF
111GVIEWNAME       = g$VIEWNAME
112GVIEWTARGET     = $GVIEWNAME$LNKSUF
113RVIMNAME        = r$VIMNAME
114RVIMTARGET      = $RVIMNAME$LNKSUF
115RVIEWNAME       = r$VIEWNAME
116RVIEWTARGET     = $RVIEWNAME$LNKSUF
117RGVIMNAME       = r$GVIMNAME
118RGVIMTARGET     = $RGVIMNAME$LNKSUF
119RGVIEWNAME      = r$GVIEWNAME
120RGVIEWTARGET    = $RGVIEWNAME$LNKSUF
121VIMDIFFNAME     = $(VIMNAME)diff
122GVIMDIFFNAME    = g$VIMDIFFNAME
123VIMDIFFTARGET   = $VIMDIFFNAME$LNKSUF
124GVIMDIFFTARGET  = $GVIMDIFFNAME$LNKSUF
125EVIMNAME        = e$VIMNAME
126EVIMTARGET      = $EVIMNAME$LNKSUF
127EVIEWNAME       = e$VIEWNAME
128EVIEWTARGET     = $EVIEWNAME$LNKSUF
129
130#
131# G U I  variant
132#
133# The GUI is selected by configure, a lot of other things depend on it.
134#
135:variant GUI
136    GTK
137        GUI_SRC         = gui.c gui_gtk.c gui_gtk_x11.c pty.c gui_beval.c
138                            gui_gtk_f.c
139        GUI_OBJ         =
140        GUI_DEFS        = -DFEAT_GUI_GTK $NARROW_PROTO
141        GUI_IPATH       = $GUI_INC_LOC
142        GUI_LIBS_DIR    = $GUI_LIB_LOC
143        GUI_LIBS1       =
144        GUI_LIBS2       = $GTK_LIBNAME
145        GUI_INSTALL     = install_normal
146        GUI_TARGETS     = installglinks
147        GUI_MAN_TARGETS = yes
148        GUI_TESTTARGET  = gui
149        GUI_BUNDLE      =
150        GUI_TESTARG     =
151    MOTIF
152        GUI_SRC         = gui.c gui_motif.c gui_x11.c pty.c gui_beval.c
153                          gui_xmdlg.c gui_xmebw.c
154        GUI_OBJ         =
155        GUI_DEFS        = -DFEAT_GUI_MOTIF $NARROW_PROTO
156        GUI_IPATH       = $GUI_INC_LOC
157        GUI_LIBS_DIR    = $GUI_LIB_LOC
158        GUI_LIBS1       =
159        GUI_LIBS2       = $MOTIF_LIBNAME -lXt
160        GUI_INSTALL     = install_normal
161        GUI_TARGETS     = installglinks
162        GUI_MAN_TARGETS = yes
163        GUI_TESTTARGET  = gui
164        GUI_BUNDLE      =
165        GUI_TESTARG     =
166    ATHENA
167        # XAW_LIB et al. can be overruled to use Xaw3d widgets
168        XAW_LIB         ?= -lXaw
169        GUI_SRC         =  gui.c gui_athena.c gui_x11.c pty.c gui_beval.c \
170                            gui_at_sb.c gui_at_fs.c
171        GUI_OBJ         =
172        GUI_DEFS        = -DFEAT_GUI_ATHENA $NARROW_PROTO
173        GUI_IPATH       = $GUI_INC_LOC
174        GUI_LIBS_DIR    = $GUI_LIB_LOC
175        GUI_LIBS1       = $XAW_LIB
176        GUI_LIBS2       = -lXt
177        GUI_INSTALL     = install_normal
178        GUI_TARGETS     = installglinks
179        GUI_MAN_TARGETS = yes
180        GUI_TESTTARGET  = gui
181        GUI_BUNDLE      =
182        GUI_TESTARG     =
183    NEXTAW
184        # XAW_LIB et al. can be overruled to use Xaw3d widgets
185        XAW_LIB         ?= -lXaw
186        GUI_SRC         =  gui.c gui_athena.c gui_x11.c pty.c gui_beval.c
187                            gui_at_fs.c
188        GUI_OBJ         =
189        GUI_DEFS        = -DFEAT_GUI_ATHENA -DFEAT_GUI_NEXTAW $NARROW_PROTO
190        GUI_IPATH       = $GUI_INC_LOC
191        GUI_LIBS_DIR    = $GUI_LIB_LOC
192        GUI_LIBS1       = $NEXTAW_LIB
193        GUI_LIBS2       = -lXt
194        GUI_INSTALL     = install_normal
195        GUI_TARGETS     = installglinks
196        GUI_MAN_TARGETS = yes
197        GUI_TESTTARGET  = gui
198        GUI_BUNDLE      =
199        GUI_TESTARG     =
200    CARBONGUI
201        GUI_SRC         =  gui.c gui_mac.c pty.c
202        GUI_OBJ         =
203        GUI_DEFS        = -DFEAT_GUI_MAC -fno-common -fpascal-strings \
204                            -Wall -Wno-unknown-pragmas -mdynamic-no-pic -pipe
205        GUI_IPATH       = $GUI_INC_LOC
206        GUI_LIBS_DIR    = $GUI_LIB_LOC
207        GUI_LIBS1       = -framework Carbon
208        GUI_LIBS2       =
209        GUI_INSTALL     = install_macosx
210        GUI_TARGETS     = installglinks
211        GUI_MAN_TARGETS = yes
212        GUI_TESTTARGET  = gui
213        GUI_BUNDLE      = gui_bundle
214        GUI_TESTARG     = VIMPROG=../$(APPDIR)/Contents/MacOS/$(VIMTARGET)
215    PHOTONGUI
216        GUI_SRC         = gui.c gui_photon.c pty.c
217        GUI_OBJ         =
218        GUI_DEFS        = -DFEAT_GUI_PHOTON
219        GUI_IPATH       =
220        GUI_LIBS_DIR    =
221        GUI_LIBS1       = -lph -lphexlib
222        GUI_LIBS2       =
223        GUI_INSTALL     = install_normal
224        GUI_TARGETS     = installglinks
225        GUI_MAN_TARGETS = yes
226        GUI_TESTTARGET  = gui
227        GUI_BUNDLE      =
228        GUI_TESTARG     =
229    *
230        GUI_SRC         =
231        GUI_OBJ         =
232        GUI_DEFS        =
233        GUI_IPATH       =
234        GUI_LIBS_DIR    =
235        GUI_LIBS1       =
236        GUI_LIBS2       =
237        GUI_INSTALL     = install_normal
238        GUI_TARGETS     =
239        GUI_MAN_TARGETS =
240        GUI_TESTTARGET  =
241        GUI_BUNDLE      =
242        GUI_TESTARG     =
243
244
245PRE_DEFS = -Iproto -I. $DEFS $GUI_DEFS $GUI_IPATH $CPPFLAGS $?(EXTRA_IPATHS)
246POST_DEFS = $X_CFLAGS $LUA_CFLAGS $MZSCHEME_CFLAGS $PERL_CFLAGS $PYTHON_CFLAGS $TCL_CFLAGS $RUBY_CFLAGS $?(EXTRA_DEFS)
247CFLAGS = $PRE_DEFS $CONF_CFLAGS $?(PROFILE_CFLAGS) $POST_DEFS
248CPPFLAGS =
249
250ALL_LIB_DIRS = $GUI_LIBS_DIR $X_LIBS_DIR
251LDFLAGS = $ALL_LIB_DIRS $CONF_LDFLAGS
252LIBS = $GUI_LIBS1 $GUI_X_LIBS $GUI_LIBS2 $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS $CONF_LIBS $?(EXTRA_LIBS) $LUA_LIBS $MZSCHEME_LIBS $PERL_LIBS $PYTHON_LIBS $TCL_LIBS $RUBY_LIBS $?(PROFILE_LIBS)
253
254Target = $VIMNAME
255
256# reconfig target also builds Vim (reconfiguration is handled above).
257reconfig {virtual}: $Target
258
259distclean: clean
260    :del {force} auto/config.h auto/config.aap
261    :del {force} auto/config.cache auto/config.status
262
263
264# Execute the test scripts.  Run these after compiling Vim, before installing.
265#
266# This will produce a lot of garbage on your screen, including a few error
267# messages.  Don't worry about that.
268# If there is a real error, there will be a difference between "test.out" and
269# a "test99.ok" file.
270# If everything is alright, the final message will be "ALL DONE".  If not you
271# get "TEST FAILURE".
272#
273test check:
274    VimProg = ../$Target
275    :execute testdir/main.aap $GUI_TESTTARGET $GUI_TESTARG
276
277testclean {virtual}:
278    :del {force} testdir/*.out testdir/test.log
279
280# When no fetch target exists we are not a child of the ../main.aap recipe,
281# Use ../main.aap to do the fetching.
282# --- If you get an error here for wrong number of arguments, you need to
283#     update to a newer version of A-A-P.
284@if not has_target("fetch"):
285    fetch:
286        :execute ../main.aap fetch
287
288
289# All the source files that need to be compiled.
290# Some are optional and depend on configure.
291# "version.c" is missing, it's always compiled (see below).
292Source =
293        blowfish.c
294        buffer.c
295        charset.c
296        diff.c
297        digraph.c
298        edit.c
299        eval.c
300        ex_cmds.c
301        ex_cmds2.c
302        ex_docmd.c
303        ex_eval.c
304        ex_getln.c
305        fileio.c
306        fold.c
307        getchar.c
308        hardcopy.c
309        hashtab.c
310        if_cscope.c
311        if_xcmdsrv.c
312        main.c
313        mark.c
314        memfile.c
315        memline.c
316        menu.c
317        message.c
318        misc1.c
319        misc2.c
320        move.c
321        mbyte.c
322        normal.c
323        ops.c
324        option.c
325        os_unix.c
326        auto/pathdef.c
327        popupmnu.c
328        quickfix.c
329        regexp.c
330        screen.c
331        search.c
332        sha256.c
333        spell.c
334        syntax.c
335        tag.c
336        term.c
337        ui.c
338        undo.c
339        window.c
340        $OS_EXTRA_SRC
341        $GUI_SRC
342        $HANGULIN_SRC
343        $LUA_SRC
344        $MZSCHEME_SRC
345        $PERL_SRC
346        $NETBEANS_SRC
347        $PYTHON_SRC
348        $TCL_SRC
349        $RUBY_SRC
350        $SNIFF_SRC
351        $WORKSHOP_SRC
352
353Objects =
354        $GUI_OBJ
355
356# TODO: make is still used for subdirectories, need to write a recipe.
357MAKE ?= make
358
359all: $Target $GUI_BUNDLE
360
361# This dependency is required to build auto/osdef.h before automatic
362# dependencies are generated.
363$Source version.c : auto/osdef.h
364
365# Need to mention that the target also depends on version.c, since it's not
366# included in $Source
367$Target : version.c
368
369# Some sources are to be found in the "auto" directory.
370SRCPATH += auto
371
372# When building Vim always compile version.c to get the timestamp.
373:filetype
374    declare my_prog
375:attr {filetype = my_prog} $Target
376
377:program $Target : $Source $Objects
378
379:action build my_prog object
380        version_obj = `src2obj("version.c")`
381        :do compile {target = $version_obj} version.c
382        #:do build {target = $target {filetype = program}} $source $version_obj
383        link_sed = $BDIR/link.sed
384        @if os.path.exists(link_sed):
385            :move {force} $link_sed auto/link.sed
386        @else:
387            :del {force} auto/link.sed
388        :update link2.sh
389        :sys LINK="$?(PURIFY) $?(SHRPENV) $CC $LDFLAGS \
390                -o $target $source $version_obj $LIBS" \
391                MAKE="aap" sh ./link2.sh
392        :copy {force} auto/link.sed $BDIR/link.sed
393
394# "link.sh" must be modified for A-A-P
395link2.sh : link.sh
396    :print Adjusting $-source for A-A-P.
397    :cat $source | :eval re.sub("objects/pathdef.o", "pathdef", stdin)
398                                                                      >! $target
399
400xxd/xxd$EXESUF: xxd/xxd.c
401    :sys cd xxd; CC="$CC" CFLAGS="$CPPFLAGS $CFLAGS" \
402            $MAKE -f Makefile
403
404# Build the language specific files if they were unpacked.
405# Generate the converted .mo files separately, it's no problem if this fails.
406languages {virtual}:
407        @if _no.MAKEMO:
408            :sys cd $PODIR; CC="$CC" $MAKE prefix=$DESTDIR$prefix
409            @try:
410                :sys cd $PODIR; CC="$CC" $MAKE prefix=$DESTDIR$prefix converted
411            @except:
412                :print Generated converted language files failed, continuing
413
414# Update the *.po files for changes in the sources.  Only run manually.
415update-po {virtual}:
416        cd $PODIR; CC="$CC" $MAKE prefix=$DESTDIR$prefix update-po
417
418auto/if_perl.c: if_perl.xs
419        :sys $PERL -e 'unless ( $$] >= 5.005 ) { for (qw(na defgv errgv)) { print "#define PL_$$_ $$_\n" }}' > $target
420        :sys $PERL $PERLLIB/ExtUtils/xsubpp -prototypes -typemap \
421            $PERLLIB/ExtUtils/typemap if_perl.xs >> $target
422
423auto/osdef.h: auto/config.h osdef.sh osdef1.h.in osdef2.h.in
424        :sys CC="$CC $CFLAGS" srcdir=$srcdir sh $srcdir/osdef.sh
425
426pathdef {virtual} : $BDIR/auto/pathdef$OBJSUF
427
428auto/pathdef.c: auto/config.aap
429        :print Creating $target
430        :print >! $target /* pathdef.c */
431        :print >> $target /* This file is automatically created by main.aap */
432        :print >> $target /* DO NOT EDIT!  Change main.aap only. */
433        :print >> $target $#include "vim.h"
434        :print >> $target char_u *default_vim_dir = (char_u *)"$VIMRCLOC";
435        :print >> $target char_u *default_vimruntime_dir = (char_u *)"$?VIMRUNTIMEDIR";
436        v = $CC -c -I$srcdir $CFLAGS
437        @v = string.replace(v, '"', '\\"')
438        :print >> $target char_u *all_cflags = (char_u *)"$v";
439        linkcmd = $CC $LDFLAGS -o $VIMTARGET $LIBS
440        link_sed = $BDIR/link.sed
441        @if os.path.exists(link_sed):
442            # filter $linkcmd through $BDIR/link.sed
443            :print $linkcmd | :syseval sed -f $link_sed | :eval re.sub("\n", "", stdin) | :assign linkcmd
444        @linkcmd = string.replace(linkcmd, '"', '\\"')
445        :print >> $target char_u *all_lflags = (char_u *)"$linkcmd";
446        @if _no.get("COMPILEDBY"):
447            who = $COMPILEDBY
448            where =
449        @else:
450            :syseval whoami | :eval re.sub("\n", "", stdin) | :assign who
451
452            :syseval hostname | :eval re.sub("\n", "", stdin) | :assign where
453        @who = string.replace(who, '"', '\\"')
454        @where = string.replace(where, '"', '\\"')
455        :print >> $target char_u *compiled_user = (char_u *)"$who";
456        :print >> $target char_u *compiled_sys = (char_u *)"$where";
457
458
459### Names of the tools that are also made
460TOOLS = xxd/xxd$EXESUF
461
462# Root of the installation tree.  Empty for a normal install, set to an
463# existing path to install into a special place (for generating a package).
464DESTDIR ?=
465
466### Location of man pages under $MANTOPDIR
467MAN1DIR = /man1
468
469### Location of Vim files (should not need to be changed, and
470### some things might not work when they are changed!)
471VIMDIR = /vim
472@r = re.compile('.*VIM_VERSION_NODOT\\s*"(vim\\d\\d[^"]*)".*', re.S)
473VIMRTDIR = /`r.match(open("version.h").read()).group(1)`
474HELPSUBDIR = /doc
475COLSUBDIR = /colors
476SYNSUBDIR = /syntax
477INDSUBDIR = /indent
478AUTOSUBDIR = /autoload
479PLUGSUBDIR = /plugin
480FTPLUGSUBDIR = /ftplugin
481LANGSUBDIR = /lang
482COMPSUBDIR = /compiler
483KMAPSUBDIR = /keymap
484MACROSUBDIR = /macros
485TOOLSSUBDIR = /tools
486TUTORSUBDIR = /tutor
487SPELLSUBDIR = /spell
488PRINTSUBDIR = /print
489PODIR = po
490
491### VIMLOC      common root of the Vim files (all versions)
492### VIMRTLOC    common root of the runtime Vim files (this version)
493### VIMRCLOC    compiled-in location for global [g]vimrc files (all versions)
494### VIMRUNTIMEDIR  compiled-in location for runtime files (optional)
495### HELPSUBLOC  location for help files
496### COLSUBLOC   location for colorscheme files
497### SYNSUBLOC   location for syntax files
498### INDSUBLOC   location for indent files
499### AUTOSUBLOC  location for standard autoload files
500### PLUGSUBLOC  location for standard plugin files
501### FTPLUGSUBLOC  location for ftplugin files
502### LANGSUBLOC  location for language files
503### COMPSUBLOC  location for compiler files
504### KMAPSUBLOC  location for keymap files
505### MACROSUBLOC location for macro files
506### TOOLSSUBLOC location for tools files
507### TUTORSUBLOC location for tutor files
508### PRINTSUBLOC location for print files
509### SCRIPTLOC   location for script files (menu.vim, bugreport.vim, ..)
510### You can override these if you want to install them somewhere else.
511### Edit feature.h for compile-time settings.
512VIMLOC          = $DATADIR$VIMDIR
513@if not _no.get("VIMRTLOC"):
514    VIMRTLOC        = $DATADIR$VIMDIR$VIMRTDIR
515VIMRCLOC        = $VIMLOC
516HELPSUBLOC      = $VIMRTLOC$HELPSUBDIR
517COLSUBLOC       = $VIMRTLOC$COLSUBDIR
518SYNSUBLOC       = $VIMRTLOC$SYNSUBDIR
519INDSUBLOC       = $VIMRTLOC$INDSUBDIR
520AUTOSUBLOC      = $VIMRTLOC$AUTOSUBDIR
521PLUGSUBLOC      = $VIMRTLOC$PLUGSUBDIR
522FTPLUGSUBLOC    = $VIMRTLOC$FTPLUGSUBDIR
523LANGSUBLOC      = $VIMRTLOC$LANGSUBDIR
524COMPSUBLOC      = $VIMRTLOC$COMPSUBDIR
525KMAPSUBLOC      = $VIMRTLOC$KMAPSUBDIR
526MACROSUBLOC     = $VIMRTLOC$MACROSUBDIR
527TOOLSSUBLOC     = $VIMRTLOC$TOOLSSUBDIR
528TUTORSUBLOC     = $VIMRTLOC$TUTORSUBDIR
529SPELLSUBLOC	= $VIMRTLOC$SPELLSUBDIR
530PRINTSUBLOC     = $VIMRTLOC$PRINTSUBDIR
531SCRIPTLOC       = $VIMRTLOC
532
533### Only set VIMRUNTIMEDIR when VIMRTLOC is set to a different location and
534### the runtime directory is not below it.
535#VIMRUNTIMEDIR = $VIMRTLOC
536
537### Name of the evim file target.
538EVIM_FILE       = $DESTDIR$SCRIPTLOC/evim.vim
539MSWIN_FILE      = $DESTDIR$SCRIPTLOC/mswin.vim
540
541### Name of the menu file target.
542SYS_MENU_FILE   = $DESTDIR$SCRIPTLOC/menu.vim
543SYS_SYNMENU_FILE = $DESTDIR$SCRIPTLOC/synmenu.vim
544SYS_DELMENU_FILE = $DESTDIR$SCRIPTLOC/delmenu.vim
545
546### Name of the bugreport file target.
547SYS_BUGR_FILE   = $DESTDIR$SCRIPTLOC/bugreport.vim
548
549### Name of the file type detection file target.
550SYS_FILETYPE_FILE = $DESTDIR$SCRIPTLOC/filetype.vim
551
552### Name of the file type detection file target.
553SYS_FTOFF_FILE  = $DESTDIR$SCRIPTLOC/ftoff.vim
554
555### Name of the file type detection script file target.
556SYS_SCRIPTS_FILE = $DESTDIR$SCRIPTLOC/scripts.vim
557
558### Name of the ftplugin-on file target.
559SYS_FTPLUGIN_FILE = $DESTDIR$SCRIPTLOC/ftplugin.vim
560
561### Name of the ftplugin-off file target.
562SYS_FTPLUGOF_FILE = $DESTDIR$SCRIPTLOC/ftplugof.vim
563
564### Name of the indent-on file target.
565SYS_INDENT_FILE = $DESTDIR$SCRIPTLOC/indent.vim
566
567### Name of the indent-off file target.
568SYS_INDOFF_FILE = $DESTDIR$SCRIPTLOC/indoff.vim
569
570### Name of the option window script file target.
571SYS_OPTWIN_FILE = $DESTDIR$SCRIPTLOC/optwin.vim
572
573### Permissions for binaries
574BINMOD = 755
575
576### Permissions for man page
577MANMOD = 644
578
579### Permissions for help files
580HELPMOD = 644
581
582### Permissions for Perl and shell scripts
583SCRIPTMOD = 755
584
585### Permission for Vim script files (menu.vim, bugreport.vim, ..)
586VIMSCRIPTMOD = 644
587
588### Permissions for all directories that are created
589DIRMOD = 755
590
591### Permissions for all other files that are created
592FILEMOD = 644
593
594# Where to copy the man and help files from
595HELPSOURCE = ../runtime/doc
596
597# Where to copy the script files from (menu, bugreport)
598SCRIPTSOURCE = ../runtime
599
600# Where to copy the colorscheme files from
601COLSOURCE = ../runtime/colors
602
603# Where to copy the syntax files from
604SYNSOURCE = ../runtime/syntax
605
606# Where to copy the indent files from
607INDSOURCE = ../runtime/indent
608
609# Where to copy the standard plugin files from
610AUTOSOURCE = ../runtime/autoload
611
612# Where to copy the standard plugin files from
613PLUGSOURCE = ../runtime/plugin
614
615# Where to copy the ftplugin files from
616FTPLUGSOURCE = ../runtime/ftplugin
617
618# Where to copy the macro files from
619MACROSOURCE = ../runtime/macros
620
621# Where to copy the tools files from
622TOOLSSOURCE = ../runtime/tools
623
624# Where to copy the tutor files from
625TUTORSOURCE = ../runtime/tutor
626
627# Where to copy the spell files from
628SPELLSOURCE = ../runtime/spell
629
630# Where to look for language specific files
631LANGSOURCE = ../runtime/lang
632
633# Where to look for compiler files
634COMPSOURCE = ../runtime/compiler
635
636# Where to look for keymap files
637KMAPSOURCE = ../runtime/keymap
638
639# Where to look for print resource files
640PRINTSOURCE = ../runtime/print
641
642# abbreviations
643DEST_BIN = $DESTDIR$BINDIR
644DEST_VIM = $DESTDIR$VIMLOC
645DEST_RT = $DESTDIR$VIMRTLOC
646DEST_HELP = $DESTDIR$HELPSUBLOC
647DEST_COL = $DESTDIR$COLSUBLOC
648DEST_SYN = $DESTDIR$SYNSUBLOC
649DEST_IND = $DESTDIR$INDSUBLOC
650DEST_AUTO = $DESTDIR$AUTOSUBLOC
651DEST_PLUG = $DESTDIR$PLUGSUBLOC
652DEST_FTP = $DESTDIR$FTPLUGSUBLOC
653DEST_LANG = $DESTDIR$LANGSUBLOC
654DEST_COMP = $DESTDIR$COMPSUBLOC
655DEST_KMAP = $DESTDIR$KMAPSUBLOC
656DEST_MACRO = $DESTDIR$MACROSUBLOC
657DEST_TOOLS = $DESTDIR$TOOLSSUBLOC
658DEST_TUTOR = $DESTDIR$TUTORSUBLOC
659DEST_SPELL = $DESTDIR$SPELLSUBLOC
660DEST_SCRIPT = $DESTDIR$SCRIPTLOC
661DEST_PRINT = $DESTDIR$PRINTSUBLOC
662DEST_MAN_TOP = $DESTDIR$?(MANDIR)
663
664# We assume that the ".../man/xx/man1/" directory is for latin1 manual pages.
665# Some systems use UTF-8, but these should find the ".../man/xx.UTF-8/man1/"
666# directory first.
667# FreeBSD uses ".../man/xx.ISO8859-1/man1" for latin1, use that one too.
668DEST_MAN = $(DEST_MAN_TOP)$(MAN1DIR)
669DEST_MAN_FR = $(DEST_MAN_TOP)/fr$(MAN1DIR)
670DEST_MAN_FR_I = $(DEST_MAN_TOP)/fr.ISO8859-1$(MAN1DIR)
671DEST_MAN_FR_U = $(DEST_MAN_TOP)/fr.UTF-8$(MAN1DIR)
672DEST_MAN_IT = $(DEST_MAN_TOP)/it$(MAN1DIR)
673DEST_MAN_IT_I = $(DEST_MAN_TOP)/it.ISO8859-1$(MAN1DIR)
674DEST_MAN_IT_U = $(DEST_MAN_TOP)/it.UTF-8$(MAN1DIR)
675DEST_MAN_PL = $(DEST_MAN_TOP)/pl.ISO8859-2$(MAN1DIR)
676DEST_MAN_PL_U = $(DEST_MAN_TOP)/pl.UTF-8$(MAN1DIR)
677DEST_MAN_RU = $(DEST_MAN_TOP)/ru.KOI8-R$(MAN1DIR)
678DEST_MAN_RU_U = $(DEST_MAN_TOP)/ru.UTF-8$(MAN1DIR)
679
680# These are directories, create them when needed.
681:attr {directory = $DIRMOD} $DEST_BIN $DEST_VIM $DEST_RT $DEST_HELP $DEST_COL
682                $DEST_SYN $DEST_IND $DEST_AUTO $DEST_AUTO/xml $DEST_PLUG
683                $DEST_FTP $DEST_LANG
684                $DEST_COMP $DEST_KMAP $DEST_MACRO $DEST_TOOLS $DEST_TUTOR
685                $DEST_SCRIPT $DEST_PRINT $DEST_MAN $DEST_SPELL
686                $DEST_MAN_FR $DEST_MAN_FR_I $DEST_MAN_FR_U $DEST_MAN_IT
687                $DEST_MAN_IT_I $DEST_MAN_IT_U
688                $DEST_MAN_PL $DEST_MAN_PL_U
689                $DEST_MAN_RU $DEST_MAN_RU_U
690
691#
692# I N S T A L L
693#
694install: $GUI_INSTALL
695
696install_normal:
697    @if not os.path.isdir(_no.DEST_BIN):
698        @try:
699            :mkdir $DEST_BIN
700        @except:
701        @   pass
702    @if os.access(_no.DEST_BIN, os.W_OK):
703        # Bin directory is writable, install directly.
704        :update installvim installtools $INSTALL_LANGS install-icons
705    @else:
706        # Bin directory is not writable, need to become root.
707        :print The destination directory "$DEST_BIN" is not writable.
708        :print If this is the wrong directory, use PREFIX to specify another one.
709        :print Otherwise, type the root password to continue installing.
710        :asroot $AAP install
711
712installvim {virtual}: installvimbin  installtutorbin \
713                        installruntime installlinks installmanlinks
714
715installvimbin {virtual}{force}: $Target $DEST_BIN
716        exe = $DEST_BIN/$VIMTARGET
717        @if os.path.exists(exe):
718            # Move the old executable aside and delete it.  Any other method
719            # may cause a crash if the executable is currently being used.
720            :move {force} $exe $(exe).rm
721            :del {force} $(exe).rm
722        :copy $VIMTARGET $DEST_BIN
723        :do strip $exe
724        :chmod $BINMOD $DEST_BIN/$VIMTARGET
725# may create a link to the new executable from /usr/bin/vi
726        @if _no.get("LINKIT"):
727            :sys $LINKIT
728
729# Long list of arguments for the shell script that installs the manual pages
730# for one language.
731INSTALLMANARGS = $(VIMLOC) $(SCRIPTLOC) $(VIMRCLOC) $(HELPSOURCE) $(MANMOD) \
732		$(VIMNAME) $(VIMDIFFNAME) $(EVIMNAME)
733
734# Install most of the runtime files
735installruntime {virtual}: installrtbase installmacros installtutor installspell
736
737# install the help files; first adjust the contents for the location
738installrtbase {virtual}{force}: $HELPSOURCE/vim.1 $DEST_VIM
739                $DEST_RT $DEST_HELP $DEST_COL $DEST_SYN $DEST_IND
740                $DEST_FTP $DEST_AUTO $DEST_AUTO/xml $DEST_PLUG $DEST_TUTOR
741                $DEST_COMP $DEST_SPELL $DEST_PRINT
742        :chmod 755 installman.sh
743        :sys ./installman.sh install $(DEST_MAN) "" $(INSTALLMANARGS)
744
745        :cd $HELPSOURCE
746        @try:
747            XTRA = `glob.glob("*.??x")` `glob.glob("tags-??")`
748        @except:
749            XTRA =       # It's OK if there are no matches.
750        :copy *.txt tags $XTRA $DEST_HELP
751        :cd -
752        :cd $DEST_HELP
753        :chmod $HELPMOD *.txt tags $XTRA
754        :cd -
755        :copy  $HELPSOURCE/*.pl $DEST_HELP
756        :chmod $SCRIPTMOD $DEST_HELP/*.pl
757# install the menu files
758        :copy $SCRIPTSOURCE/menu.vim $SYS_MENU_FILE
759        :chmod $VIMSCRIPTMOD $SYS_MENU_FILE
760        :copy $SCRIPTSOURCE/synmenu.vim $SYS_SYNMENU_FILE
761        :chmod $VIMSCRIPTMOD $SYS_SYNMENU_FILE
762        :copy $SCRIPTSOURCE/delmenu.vim $SYS_DELMENU_FILE
763        :chmod $VIMSCRIPTMOD $SYS_DELMENU_FILE
764# install the evim file
765        :copy $SCRIPTSOURCE/mswin.vim $MSWIN_FILE
766        :chmod $VIMSCRIPTMOD $MSWIN_FILE
767        :copy $SCRIPTSOURCE/evim.vim $EVIM_FILE
768        :chmod $VIMSCRIPTMOD $EVIM_FILE
769# install the bugreport file
770        :copy $SCRIPTSOURCE/bugreport.vim $SYS_BUGR_FILE
771        :chmod $VIMSCRIPTMOD $SYS_BUGR_FILE
772# install the example vimrc files
773        :copy $SCRIPTSOURCE/vimrc_example.vim $DEST_SCRIPT
774        :chmod $VIMSCRIPTMOD $DEST_SCRIPT/vimrc_example.vim
775        :copy $SCRIPTSOURCE/gvimrc_example.vim $DEST_SCRIPT
776        :chmod $VIMSCRIPTMOD $DEST_SCRIPT/gvimrc_example.vim
777# install the file type detection files
778        :copy $SCRIPTSOURCE/filetype.vim $SYS_FILETYPE_FILE
779        :chmod $VIMSCRIPTMOD $SYS_FILETYPE_FILE
780        :copy $SCRIPTSOURCE/ftoff.vim $SYS_FTOFF_FILE
781        :chmod $VIMSCRIPTMOD $SYS_FTOFF_FILE
782        :copy $SCRIPTSOURCE/scripts.vim $SYS_SCRIPTS_FILE
783        :chmod $VIMSCRIPTMOD $SYS_SCRIPTS_FILE
784        :copy $SCRIPTSOURCE/ftplugin.vim $SYS_FTPLUGIN_FILE
785        :chmod $VIMSCRIPTMOD $SYS_FTPLUGIN_FILE
786        :copy $SCRIPTSOURCE/ftplugof.vim $SYS_FTPLUGOF_FILE
787        :chmod $VIMSCRIPTMOD $SYS_FTPLUGOF_FILE
788        :copy $SCRIPTSOURCE/indent.vim $SYS_INDENT_FILE
789        :chmod $VIMSCRIPTMOD $SYS_INDENT_FILE
790        :copy $SCRIPTSOURCE/indoff.vim $SYS_INDOFF_FILE
791        :chmod $VIMSCRIPTMOD $SYS_INDOFF_FILE
792        :copy $SCRIPTSOURCE/optwin.vim $SYS_OPTWIN_FILE
793        :chmod $VIMSCRIPTMOD $SYS_OPTWIN_FILE
794# install the print resource files
795        :copy $PRINTSOURCE/*.ps $DEST_PRINT
796        :chmod $FILEMOD $DEST_PRINT/*.ps
797# install the colorscheme files
798        :copy $COLSOURCE/*.vim $COLSOURCE/README.txt $DEST_COL
799        :chmod $HELPMOD $DEST_COL/*.vim $DEST_COL/README.txt
800# install the syntax files
801        :copy $SYNSOURCE/*.vim $SYNSOURCE/README.txt $DEST_SYN
802        :chmod $HELPMOD $DEST_SYN/*.vim $DEST_SYN/README.txt
803# install the indent files
804        :copy $INDSOURCE/*.vim $INDSOURCE/README.txt $DEST_IND
805        :chmod $HELPMOD $DEST_IND/*.vim
806# install the standard autoload files
807        :copy $AUTOSOURCE/*.vim $AUTOSOURCE/README.txt $DEST_AUTO
808        :chmod $HELPMOD $DEST_AUTO/*.vim $DEST_AUTO/README.txt
809        :copy $AUTOSOURCE/xml/*.vim $DEST_AUTO/xml
810        :chmod $HELPMOD $DEST_AUTO/xml/*.vim
811# install the standard plugin files
812        :copy $PLUGSOURCE/*.vim $PLUGSOURCE/README.txt $DEST_PLUG
813        :chmod $HELPMOD $DEST_PLUG/*.vim $DEST_PLUG/README.txt
814# install the ftplugin files
815        :copy $FTPLUGSOURCE/*.vim $FTPLUGSOURCE/README.txt $DEST_FTP
816        :chmod $HELPMOD $DEST_FTP/*.vim $DEST_FTP/README.txt
817# install the compiler files
818        :copy $COMPSOURCE/*.vim $COMPSOURCE/README.txt $DEST_COMP
819        :chmod $HELPMOD $DEST_COMP/*.vim $DEST_COMP/README.txt
820
821installmacros {virtual}{force}: $MACROSOURCE $DEST_VIM $DEST_RT $DEST_MACRO
822        :copy {recursive}{force} $MACROSOURCE/* $DEST_MACRO
823        # Delete any CVS and AAPDIR directories.
824        # Use the ":tree" command if possible.  It was added later, fall back
825        # to using "find" when it doesn't work.
826        @try:
827           :tree $DEST_MACRO {dirname = CVS}
828              :del {recursive} $name
829           :tree $DEST_MACRO {dirname = AAPDIR}
830              :del {recursive} $name
831           :tree $DEST_MACRO {dirname = .*}
832              :chmod $DIRMOD $name
833           :tree $DEST_MACRO {filename = .*}
834              :chmod $FILEMOD $name
835        @except:
836        @  ok, cvsdirs = redir_system('find %s -name CVS -print' % _no.DEST_MACRO)
837        @  if ok and cvsdirs:
838             :del {recursive} $cvsdirs
839           :sys chmod $DIRMOD ``find $DEST_MACRO -type d -print``
840           :sys chmod $FILEMOD ``find $DEST_MACRO -type f -print``
841        :chmod $SCRIPTMOD $DEST_MACRO/less.sh
842
843# install the tutor files
844installtutorbin {virtual}{force}: $DEST_VIM
845        :copy vimtutor $DEST_BIN/$(VIMNAME)tutor
846        :chmod $SCRIPTMOD $DEST_BIN/$(VIMNAME)tutor
847
848installtutor {virtual}{force}: $DEST_RT $DEST_TUTOR
849        :copy $TUTORSOURCE/tutor* $TUTORSOURCE/README* $DEST_TUTOR
850        :chmod $HELPMOD $DEST_TUTOR/*
851
852# Install the spell files, if they exist.  This assumes at least the English
853# spell file is there.
854installspell {virtual}: $(DEST_VIM) $(DEST_RT) $(DEST_SPELL)
855	enspl = $(SPELLSOURCE)/en.latin1.spl
856        @if os.path.exists(enspl):
857            :copy $(SPELLSOURCE)/*.spl $(SPELLSOURCE)/*.vim $(DEST_SPELL)
858            :chmod $(HELPMOD) $(DEST_SPELL)/*.spl $(DEST_SPELL)/*.vim
859            @try:
860                :copy $(SPELLSOURCE)/*.sug $(DEST_SPELL)
861                :chmod $(HELPMOD) $(DEST_SPELL)/*.sug
862            @except:
863            @   pass
864
865# install helper program xxd
866installtools {virtual}{force}: $TOOLS $DEST_BIN $DEST_MAN \
867                $TOOLSSOURCE $DEST_VIM $DEST_RT $DEST_TOOLS \
868                $INSTALL_TOOL_LANGS
869        xxd = $DEST_BIN/xxd$EXESUF
870        @if os.path.exists(xxd):
871          :move {force} $xxd $(xxd).rm
872          :del $(xxd).rm
873        :copy xxd/xxd$EXESUF $DEST_BIN
874        :do strip $DEST_BIN/xxd$EXESUF
875        :chmod $BINMOD $DEST_BIN/xxd$EXESUF
876        :chmod 755 installman.sh
877        :sys ./installman.sh xxd $(DEST_MAN) "" $(INSTALLMANARGS)
878#
879# install the runtime tools
880        @try:
881        @  if aap_has(":tree"):
882              # New method: copy everything and delete CVS and AAPDIR dirs
883              :copy {recursive} $TOOLSSOURCE/* $DEST_TOOLS
884              :tree $DEST_TOOLS {dirname = CVS}
885                 :delete {recursive} $name
886              :tree $DEST_TOOLS {dirname = AAPDIR}
887                 :delete {recursive} $name
888        @except:
889            # Old method: copy only specific files and directories.
890            :copy {recursive} $TOOLSSOURCE/README.txt $TOOLSSOURCE/[a-z]* $DEST_TOOLS
891        :chmod $FILEMOD $DEST_TOOLS/*
892# replace the path in some tools
893        :progsearch perlpath perl
894        @if perlpath:
895            :cat $TOOLSSOURCE/efm_perl.pl |
896                    :eval re.sub("/usr/bin/perl", perlpath, stdin)
897                    >! $DEST_TOOLS/efm_perl.pl
898        @else:
899            :copy $TOOLSSOURCE/efm_perl.pl $DEST_TOOLS
900
901        :progsearch awkpath nawk gawk awk
902        @if awkpath:
903            :cat $TOOLSSOURCE/mve.awk |
904                    :eval re.sub("/usr/bin/nawk", awkpath, stdin)
905                    >! $DEST_TOOLS/mve.awk
906        @else:
907            :copy $TOOLSSOURCE/mve.awk $DEST_TOOLS
908
909        :sys chmod $SCRIPTMOD ``grep -l "^#!" $DEST_TOOLS/*``
910
911# install the language specific files for tools, if they were unpacked
912install-tool-languages:
913        :chmod 755 installman.sh
914        :sys ./installman.sh xxd $(DEST_MAN_FR) "-fr" $(INSTALLMANARGS)
915	:sys ./installman.sh xxd $(DEST_MAN_FR_I) "-fr" $(INSTALLMANARGS)
916	:sys ./installman.sh xxd $(DEST_MAN_FR_U) "-fr.UTF-8" $(INSTALLMANARGS)
917	:sys ./installman.sh xxd $(DEST_MAN_IT) "-it" $(INSTALLMANARGS)
918	:sys ./installman.sh xxd $(DEST_MAN_IT_I) "-it" $(INSTALLMANARGS)
919	:sys ./installman.sh xxd $(DEST_MAN_IT_U) "-it.UTF-8" $(INSTALLMANARGS)
920	:sys ./installman.sh xxd $(DEST_MAN_PL) "-pl" $(INSTALLMANARGS)
921	:sys ./installman.sh xxd $(DEST_MAN_PL_U) "-pl.UTF-8" $(INSTALLMANARGS)
922	:sys ./installman.sh xxd $(DEST_MAN_RU) "-ru" $(INSTALLMANARGS)
923	:sys ./installman.sh xxd $(DEST_MAN_RU_U) "-ru.UTF-8" $(INSTALLMANARGS)
924
925# install the language specific files, if they were unpacked
926install-languages {virtual}{force}: languages $DEST_LANG $DEST_KMAP
927        :chmod 755 installman.sh
928        :sys ./installman.sh install $(DEST_MAN_FR) "-fr" $(INSTALLMANARGS)
929	:sys ./installman.sh install $(DEST_MAN_FR_I) "-fr" $(INSTALLMANARGS)
930	:sys ./installman.sh install $(DEST_MAN_FR_U) "-fr.UTF-8" $(INSTALLMANARGS)
931	:sys ./installman.sh install $(DEST_MAN_IT) "-it" $(INSTALLMANARGS)
932	:sys ./installman.sh install $(DEST_MAN_IT_I) "-it" $(INSTALLMANARGS)
933	:sys ./installman.sh install $(DEST_MAN_IT_U) "-it.UTF-8" $(INSTALLMANARGS)
934	:sys ./installman.sh install $(DEST_MAN_PL) "-pl" $(INSTALLMANARGS)
935	:sys ./installman.sh install $(DEST_MAN_PL_U) "-pl.UTF-8" $(INSTALLMANARGS)
936	:sys ./installman.sh install $(DEST_MAN_RU) "-ru" $(INSTALLMANARGS)
937	:sys ./installman.sh install $(DEST_MAN_RU_U) "-ru.UTF-8" $(INSTALLMANARGS)
938        :chmod 755 installml.sh
939	:sys ./installml.sh install "$(GUI_MAN_TARGETS)" \
940		$(DEST_MAN_FR) $(INSTALLMLARGS)
941        :sys ./installml.sh install "$(GUI_MAN_TARGETS)" \
942		$(DEST_MAN_FR_I) $(INSTALLMLARGS)
943        :sys ./installml.sh install "$(GUI_MAN_TARGETS)" \
944		$(DEST_MAN_FR_U) $(INSTALLMLARGS)
945        :sys ./installml.sh install "$(GUI_MAN_TARGETS)" \
946		$(DEST_MAN_IT) $(INSTALLMLARGS)
947        :sys ./installml.sh install "$(GUI_MAN_TARGETS)" \
948		$(DEST_MAN_IT_I) $(INSTALLMLARGS)
949        :sys ./installml.sh install "$(GUI_MAN_TARGETS)" \
950		$(DEST_MAN_IT_U) $(INSTALLMLARGS)
951        :sys ./installml.sh install "$(GUI_MAN_TARGETS)" \
952		$(DEST_MAN_PL) $(INSTALLMLARGS)
953        :sys ./installml.sh install "$(GUI_MAN_TARGETS)" \
954		$(DEST_MAN_PL_U) $(INSTALLMLARGS)
955        :sys ./installml.sh install "$(GUI_MAN_TARGETS)" \
956		$(DEST_MAN_RU) $(INSTALLMLARGS)
957        :sys ./installml.sh install "$(GUI_MAN_TARGETS)" \
958		$(DEST_MAN_RU_U) $(INSTALLMLARGS)
959
960        @if _no.MAKEMO:
961           :sys cd $PODIR; $MAKE prefix=$DESTDIR$prefix \
962                    LOCALEDIR=$DEST_LANG INSTALL_DATA=cp FILEMOD=$FILEMOD install
963        @if os.path.exists(_no.LANGSOURCE):
964           :print installing language files
965           :copy $LANGSOURCE/README.txt $LANGSOURCE/*.vim $DEST_LANG
966           :chmod $FILEMOD $DEST_LANG/*.vim
967        @if os.path.exists(_no.KMAPSOURCE):
968           :copy $KMAPSOURCE/README.txt $KMAPSOURCE/*.vim $DEST_KMAP
969           :chmod $FILEMOD $DEST_KMAP/*.vim
970
971# install the icons for KDE, if the directory exists and the icon doesn't.
972ICON48PATH = $DESTDIR$DATADIR/icons/hicolor/48x48/apps
973ICON32PATH = $DESTDIR$DATADIR/icons/locolor/32x32/apps
974ICON16PATH = $DESTDIR$DATADIR/icons/locolor/16x16/apps
975KDEPATH = $HOME/.kde/share/icons
976install-icons {virtual}:
977        gp = $ICON48PATH/gvim.png
978        @if os.path.isdir(_no.ICON48PATH) and not os.path.exists(gp):
979           :copy $SCRIPTSOURCE/vim48x48.png $gp
980        gp = $ICON32PATH/gvim.png
981        @if os.path.isdir(_no.ICON32PATH) and not os.path.exists(gp):
982           :copy $SCRIPTSOURCE/vim32x32.png $gp
983        gp = $ICON16PATH/gvim.png
984        @if os.path.isdir(_no.ICON16PATH) and not os.path.exists(gp):
985           :copy $SCRIPTSOURCE/vim16x16.png $gp
986
987
988$HELPSOURCE/vim.1 $MACROSOURCE $TOOLSSOURCE:
989        @if not os.path.exists(_no.TOOLSSOURCE):
990            :print Runtime files not found.
991            :error You need to unpack the runtime archive before running "make install".
992
993# create links from various names to vim.  This is only done when the links
994# (or executables with the same name) don't exist yet.
995installlinks {virtual}: $GUI_TARGETS \
996                        $DEST_BIN/$EXTARGET \
997                        $DEST_BIN/$VIEWTARGET \
998                        $DEST_BIN/$RVIMTARGET \
999                        $DEST_BIN/$RVIEWTARGET \
1000                        $INSTALLVIMDIFF
1001
1002installglinks {virtual}: $DEST_BIN/$GVIMTARGET \
1003                        $DEST_BIN/$GVIEWTARGET \
1004                        $DEST_BIN/$RGVIMTARGET \
1005                        $DEST_BIN/$RGVIEWTARGET \
1006                        $DEST_BIN/$EVIMTARGET \
1007                        $DEST_BIN/$EVIEWTARGET \
1008                        $INSTALLGVIMDIFF
1009
1010installvimdiff {virtual}: $DEST_BIN/$VIMDIFFTARGET
1011installgvimdiff {virtual}: $DEST_BIN/$GVIMDIFFTARGET
1012
1013# These dependencies use an empty buildcheck so that they are only done when
1014# the target doesn't exist.
1015$DEST_BIN/$EXTARGET: {buildcheck = }
1016    :sys cd $DEST_BIN; ln -s $VIMTARGET $EXTARGET
1017
1018$DEST_BIN/$VIEWTARGET: {buildcheck = }
1019    :sys cd $DEST_BIN; ln -s $VIMTARGET $VIEWTARGET
1020
1021$DEST_BIN/$GVIMTARGET: {buildcheck = }
1022    :sys cd $DEST_BIN; ln -s $VIMTARGET $GVIMTARGET
1023
1024$DEST_BIN/$GVIEWTARGET: {buildcheck = }
1025    :sys cd $DEST_BIN; ln -s $VIMTARGET $GVIEWTARGET
1026
1027$DEST_BIN/$RVIMTARGET: {buildcheck = }
1028    :sys cd $DEST_BIN; ln -s $VIMTARGET $RVIMTARGET
1029
1030$DEST_BIN/$RVIEWTARGET: {buildcheck = }
1031    :sys cd $DEST_BIN; ln -s $VIMTARGET $RVIEWTARGET
1032
1033$DEST_BIN/$RGVIMTARGET: {buildcheck = }
1034    :sys cd $DEST_BIN; ln -s $VIMTARGET $RGVIMTARGET
1035
1036$DEST_BIN/$RGVIEWTARGET: {buildcheck = }
1037    :sys cd $DEST_BIN; ln -s $VIMTARGET $RGVIEWTARGET
1038
1039$DEST_BIN/$VIMDIFFTARGET: {buildcheck = }
1040    :sys cd $DEST_BIN; ln -s $VIMTARGET $VIMDIFFTARGET
1041
1042$DEST_BIN/$GVIMDIFFTARGET: {buildcheck = }
1043    :sys cd $DEST_BIN; ln -s $VIMTARGET $GVIMDIFFTARGET
1044
1045$DEST_BIN/$EVIMTARGET: {buildcheck = }
1046    :sys cd $DEST_BIN; ln -s $VIMTARGET $EVIMTARGET
1047
1048$DEST_BIN/$EVIEWTARGET: {buildcheck = }
1049    :sys cd $DEST_BIN; ln -s $VIMTARGET $EVIEWTARGET
1050
1051# create links for the manual pages with various names to vim.  This is only
1052# done when the links (or manpages with the same name) don't exist yet.
1053INSTALLMLARGS = $(VIMNAME) $(VIMDIFFNAME) $(EVIMNAME) \
1054		$(EXNAME) $(VIEWNAME) $(RVIMNAME) $(RVIEWNAME) \
1055		$(GVIMNAME) $(GVIEWNAME) $(RGVIMNAME) $(RGVIEWNAME) \
1056		$(GVIMDIFFNAME) $(EVIEWNAME)
1057
1058installmanlinks {virtual}:
1059    :chmod 755 installml.sh
1060    :sys ./installml.sh install "$(GUI_MAN_TARGETS)" \
1061		$(DEST_MAN) $(INSTALLMLARGS)
1062
1063#
1064# U N I N S T A L L
1065#
1066uninstall {virtual}{force}: uninstall_runtime
1067    :del {force} $DEST_BIN/$VIMTARGET
1068    :del {force} $DEST_BIN/vimtutor
1069    :del {force} $DEST_BIN/$EXTARGET $DEST_BIN/$VIEWTARGET
1070    :del {force} $DEST_BIN/$GVIMTARGET $DEST_BIN/$GVIEWTARGET
1071    :del {force} $DEST_BIN/$RVIMTARGET $DEST_BIN/$RVIEWTARGET
1072    :del {force} $DEST_BIN/$RGVIMTARGET $DEST_BIN/$RGVIEWTARGET
1073    :del {force} $DEST_BIN/$VIMDIFFTARGET $DEST_BIN/$GVIMDIFFTARGET
1074    :del {force} $DEST_BIN/$EVIMTARGET $DEST_BIN/$EVIEWTARGET
1075    :del {force} $DEST_BIN/xxd$EXESUF
1076
1077# Note: "deldir" will fail if any files were added after "make install", that
1078# is intentionally: Keep files the user added.
1079uninstall_runtime {virtual}{force}:
1080    :chmod 755 installman.sh
1081    :sys ./installman.sh uninstall $(DEST_MAN) "" $(INSTALLMANARGS)
1082    :sys ./installman.sh uninstall $(DEST_MAN_FR) "" $(INSTALLMANARGS)
1083    :sys ./installman.sh uninstall $(DEST_MAN_FR_I) "" $(INSTALLMANARGS)
1084    :sys ./installman.sh uninstall $(DEST_MAN_FR_U) "" $(INSTALLMANARGS)
1085    :sys ./installman.sh uninstall $(DEST_MAN_IT) "" $(INSTALLMANARGS)
1086    :sys ./installman.sh uninstall $(DEST_MAN_IT_I) "" $(INSTALLMANARGS)
1087    :sys ./installman.sh uninstall $(DEST_MAN_IT_U) "" $(INSTALLMANARGS)
1088    :sys ./installman.sh uninstall $(DEST_MAN_PL) "" $(INSTALLMANARGS)
1089    :sys ./installman.sh uninstall $(DEST_MAN_PL_U) "" $(INSTALLMANARGS)
1090    :sys ./installman.sh uninstall $(DEST_MAN_RU) "" $(INSTALLMANARGS)
1091    :sys ./installman.sh uninstall $(DEST_MAN_RU_U) "" $(INSTALLMANARGS)
1092    :chmod 755 installml.sh
1093    :sys ./installml.sh uninstall "$(GUI_MAN_TARGETS)" \
1094            $(DEST_MAN) $(INSTALLMLARGS)
1095    :sys ./installml.sh uninstall "$(GUI_MAN_TARGETS)" \
1096            $(DEST_MAN_FR) $(INSTALLMLARGS)
1097    :sys ./installml.sh uninstall "$(GUI_MAN_TARGETS)" \
1098            $(DEST_MAN_FR_I) $(INSTALLMLARGS)
1099    :sys ./installml.sh uninstall "$(GUI_MAN_TARGETS)" \
1100            $(DEST_MAN_FR_U) $(INSTALLMLARGS)
1101    :sys ./installml.sh uninstall "$(GUI_MAN_TARGETS)" \
1102            $(DEST_MAN_IT) $(INSTALLMLARGS)
1103    :sys ./installml.sh uninstall "$(GUI_MAN_TARGETS)" \
1104            $(DEST_MAN_IT_I) $(INSTALLMLARGS)
1105    :sys ./installml.sh uninstall "$(GUI_MAN_TARGETS)" \
1106            $(DEST_MAN_IT_U) $(INSTALLMLARGS)
1107    :sys ./installml.sh uninstall "$(GUI_MAN_TARGETS)" \
1108            $(DEST_MAN_PL) $(INSTALLMLARGS)
1109    :sys ./installml.sh uninstall "$(GUI_MAN_TARGETS)" \
1110            $(DEST_MAN_PL_U) $(INSTALLMLARGS)
1111    :sys ./installml.sh uninstall "$(GUI_MAN_TARGETS)" \
1112            $(DEST_MAN_RU) $(INSTALLMLARGS)
1113    :sys ./installml.sh uninstall "$(GUI_MAN_TARGETS)" \
1114            $(DEST_MAN_RU_U) $(INSTALLMLARGS)
1115    :del {force} $DEST_MAN/xxd.1
1116    :del {force} $(DEST_MAN_FR)/xxd.1 $(DEST_MAN_FR_I)/xxd.1 $(DEST_MAN_FR_U)/xxd.1
1117    :del {force} $(DEST_MAN_IT)/xxd.1 $(DEST_MAN_IT_I)/xxd.1 $(DEST_MAN_IT_U)/xxd.1
1118    :del {force} $(DEST_MAN_PL)/xxd.1 $(DEST_MAN_PL_U)/xxd.1
1119    :del {force} $(DEST_MAN_RU)/xxd.1 $(DEST_MAN_RU_U)/xxd.1
1120
1121    :del {force} $DEST_HELP/*.txt $DEST_HELP/tags $DEST_HELP/*.pl
1122    :del {force} $SYS_MENU_FILE $SYS_SYNMENU_FILE $SYS_DELMENU_FILE
1123    :del {force} $SYS_BUGR_FILE $EVIM_FILE $MSWIN_FILE
1124    :del {force} $DEST_SCRIPT/gvimrc_example.vim $DEST_SCRIPT/vimrc_example.vim
1125    :del {force} $SYS_FILETYPE_FILE $SYS_FTOFF_FILE $SYS_SCRIPTS_FILE
1126    :del {force} $SYS_INDOFF_FILE $SYS_INDENT_FILE
1127    :del {force} $SYS_FTPLUGOF_FILE $SYS_FTPLUGIN_FILE
1128    :del {force} $SYS_OPTWIN_FILE
1129    :del {force} $DEST_COL/*.vim $DEST_COL/README.txt
1130    :del {force} $DEST_SYN/*.vim $DEST_SYN/README.txt
1131    :del {force} $DEST_IND/*.vim $DEST_IND/README.txt
1132    :del {force} $DEST_PRINT/*.ps
1133    :del {force}{recursive} $DEST_MACRO
1134    :del {force}{recursive} $DEST_TUTOR
1135    :del {force}{recursive} $DEST_SPELL
1136    :del {force}{recursive} $DEST_TOOLS
1137    :del {force}{recursive} $DEST_LANG
1138    :del {force}{recursive} $DEST_KMAP
1139    :del {force}{recursive} $DEST_COMP
1140    :deldir {force} $DEST_HELP $DEST_COL $DEST_SYN $DEST_IND
1141    :del {force}{recursive} $DEST_FTP/*.vim $DEST_FTP/README.txt
1142    :del {force} $DEST_AUTO/*.vim $DEST_AUTO/README.txt $DEST_AUTO/xml/*.vim
1143    :del {force} $DEST_PLUG/*.vim $DEST_PLUG/README.txt
1144    :deldir {force} $DEST_FTP $DEST_AUTO/xml $DEST_AUTO $DEST_PLUG $DEST_PRINT $DEST_RT
1145#       This will fail when other Vim versions are installed, no worries.
1146    @try:
1147        :deldir $DEST_VIM
1148    @except:
1149        :print Cannot delete $DEST_VIM
1150
1151###############################################################################
1152### MacOS X installation
1153###
1154### This installs a runnable Vim.app in $(prefix)
1155
1156REZ    = /Developer/Tools/Rez
1157RESDIR = $(APPDIR)/Contents/Resources
1158@r = re.compile('.*VIM_VERSION_SHORT\\s*"(\\d[^"]*)".*', re.S)
1159VERSION = /`r.match(open("version.h").read()).group(1)`
1160
1161### Common flags
1162M4FLAGSX = $?(M4FLAGS) -DAPP_EXE=$(VIMNAME) -DAPP_NAME=$(VIMNAME) \
1163		-DAPP_VER=$(VERSION)
1164
1165# Resources used for the Mac are in one directory.
1166RSRC_DIR = os_mac_rsrc
1167
1168:attr {directory = $DIRMOD} $RESDIR
1169
1170install_macosx {virtual}: gui_bundle
1171# Remove the link to the runtime dir, don't want to copy all of that.
1172        :delete {force} $(RESDIR)/vim/runtime
1173        :copy {r} $APPDIR $DESTDIR$prefix
1174        :tree $DESTDIR$prefix {dirname = AAPDIR}
1175             :delete {recursive} $name
1176# Install the runtime files.  Recursive!
1177	:mkdir {r}{f} $DESTDIR$prefix/$RESDIR/vim/runtime
1178#	:mkdir $(DESTDIR)$(prefix)/$(APPDIR)/bin
1179        :execute main.aap PREFIX=$DESTDIR$prefix/$RESDIR/vim VIMRTLOC=$DESTDIR$prefix/$RESDIR/vim/runtime installruntime
1180# Put the link back.
1181        :symlink `os.getcwd()`/../runtime $RESDIR/vim/runtime
1182# TODO: Create the vimtutor application.
1183
1184gui_bundle {virtual}: $(RESDIR) bundle-dir bundle-executable bundle-info \
1185                        bundle-resource bundle-language
1186
1187bundle-dir {virtual}: $(APPDIR)/Contents $(VIMTARGET)
1188# Make a link to the runtime directory, so that we can try out the executable
1189# without installing it.
1190        :mkdir {r}{f} $(RESDIR)/vim
1191        :symlink {quiet} `os.getcwd()`/../runtime $(RESDIR)/vim/runtime
1192
1193bundle-executable {virtual}: $(VIMTARGET)
1194        :mkdir {r}{f} $(APPDIR)/Contents/MacOS
1195        :copy $(VIMTARGET) $(APPDIR)/Contents/MacOS/$(VIMTARGET)
1196
1197bundle-info {virtual}:  bundle-dir
1198        :print Creating PkgInfo
1199        :print "APPLVIM!" >! $(APPDIR)/Contents/PkgInfo
1200        :print Creating Info.plist
1201        :sys m4 $(M4FLAGSX) infplist.xml > $(APPDIR)/Contents/Info.plist
1202
1203bundle-resource {virtual}: bundle-dir bundle-rsrc
1204        :copy {force} $(RSRC_DIR)/*.icns $(RESDIR)
1205
1206### Classic resources
1207# Resource fork (in the form of a .rsrc file) for Classic Vim (Mac OS 9)
1208# This file is also required for OS X Vim.
1209bundle-rsrc {virtual}: os_mac.rsr.hqx
1210    :print Creating resource fork
1211    :sys python dehqx.py $source
1212    :del {force} gui_mac.rsrc
1213    :move gui_mac.rsrc.rsrcfork $(RESDIR)/$(VIMNAME).rsrc
1214
1215# po/Make_osx.pl says something about generating a Mac message file
1216# for Ukrananian.  Would somebody using Mac OS X in Ukranian
1217# *really* be upset that Carbon Vim was not localised in
1218# Ukranian?
1219#
1220#bundle-language: bundle-dir po/Make_osx.pl
1221#	cd po && perl Make_osx.pl --outdir ../$(RESDIR) $(MULTILANG)
1222bundle-language {virtual}: bundle-dir
1223
1224$(APPDIR)/Contents:
1225    :mkdir {r} $(APPDIR)/Contents/MacOS
1226    :mkdir {r} $(RESDIR)/English.lproj
1227
1228
1229# vim: sts=4 sw=4 :
1230