Option to jump with up on keyboard.
[supertux.git] / mk / jam / install.jam
1 #============================================================================
2 # Rules for installation
3 #============================================================================
4
5 COPYDIRS ?= "cp -R" ;
6
7 INSTALL ?= "install" ;
8 INSTALL_PROGRAM ?= $(INSTALL) ;
9 INSTALL_SCRIPT ?= $(INSTALL) ;
10 INSTALL_DATA ?= "$(INSTALL) -m644" ;
11
12 # set some paths
13 appdatadir ?= [ ConcatDirs $(datadir) $(PACKAGE_NAME) ] ;
14 appdocdir ?= [ ConcatDirs $(datadir) doc $(PACKAGE_NAME)-$(PACKAGE_VERSION) ] ;
15 appconfdir ?= [ ConcatDirs $(sysconfdir) $(PACKAGE_NAME) ] ;
16 plugindir ?= [ ConcatDirs $(libdir) $(PACKAGE_NAME) ] ;
17 applicationsdir ?= [ ConcatDirs $(datadir) applications ] ;
18 pixmapsdir ?= [ ConcatDirs $(datadir) pixmaps ] ;
19
20 ##  InstallHeader headername [ : subdir ]
21 ##    DoInstall a headerfile into the includedir directory. A subdirectory
22 ##    relative to the includedir can be specified.
23 rule InstallHeader
24 {
25     SEARCH on $(<:G=installheader) = $(SUBDIR) ;
26     Depends install_include : [ DoInstall $(<:G=installheader) : $(includedir) $(2) ] ;
27 }
28
29 ##  InstallShellScript scriptname [ : subdir ]
30 ##    Installs a shell script into the bindir directory. A subdirectory
31 ##    relative to the bindir can be specified.
32 rule InstallShellScript
33 {
34     SEARCH on $(<:G=installscript) = $(SUBDIR) ;
35     Depends install_shellscript 
36         : [ DoInstall $(<:G=installscript) : $(bindir) $(2) : $(INSTALL_SCRIPT) ]
37     ;
38 }
39
40 ##  InstallData files [ : subdir ]
41 ##    Installs data files
42 rule InstallData
43 {
44     SEARCH on $(<:G=installdata) = $(SUBDIR) ;
45     Depends install_data : [ DoInstall $(<:G=installdata) : $(appdatadir) $(2) ] ;
46 }
47
48 ##  InstallConfig files [ : subdir ]
49 ##    Installs configuration files
50 rule InstallConfig
51 {
52     SEARCH on $(<:G=installconfig) = $(SUBDIR) ;
53     Depends install_config : [ DoInstall $(<:G=installconfig) : $(appconfdir) $(2) ] ;
54 }
55
56 ##  InstallDoc files [ : subdir ]
57 ##    Installs documentation files
58 rule InstallDoc
59 {
60     SEARCH on $(<:G=installdoc) = $(SUBDIR) ;
61     Depends install_doc : [ DoInstall $(<:G=installdoc) : $(appdocdir) $(2) ] ;
62 }
63
64 ##  InstallMan files
65 ##    DoInstall man files
66 rule InstallMan
67 {
68     local dir i ;
69     
70     SEARCH on $(<:G=installman) = $(SUBDIR) ;
71     for i in $(<:G=installman) {
72         dir = $(mandir) ;
73         switch $(i:S) {
74             case .1 : dir += man1 ;
75             case .2 : dir += man2 ;
76             case .3 : dir += man3 ;
77             case .4 : dir += man4 ;
78             case .5 : dir += man5 ;
79             case .6 : dir += man6 ;
80             case .7 : dir += man7 ;
81             case .8 : dir += man8 ;
82             case .9 : dir += man9 ;
83             case * :
84                 echo "WARNING: manfile has no *.[0-9] ending." ;
85         }
86         Depends install_man : [ DoInstall $(i) : $(dir) ] ;
87     }
88 }
89
90 ##  InstallPixmap files [ : subdir ]
91 ##    Install a pixmap
92 rule InstallPixmap
93 {
94     LOCATE on $(<:G=installpixmap) = $(SUBDIR) ;
95     Depends install_data
96         : [ DoInstall $(<:G=installpixmap) : $(pixmapsdir) $(2) ] ;
97 }
98
99 ##  InstallDesktop files [ : subdir ]
100 ##    Install a .desktop file (menu entries for kde/gnome and others)
101 rule InstallDesktop
102 {
103     LOCATE on $(<:G=installdesktop) = $(SUBDIR) ;
104     Depends install_bin
105         : [ DoInstall $(<:G=installdesktop) : $(applicationsdir) $(2) ] ;
106 }
107
108 ##  DoInstall sourcename : directories [ : installapp ] [ : options ]
109 ##    Creates a new installtarget for the given sources. The target(s) are
110 ##    returned as function result.
111 rule DoInstall
112 {
113     local targets target i dir gdir ;
114     dir = [ ConcatDirs $(DESTDIR) $(2) ] ;
115
116     gdir = $(dir:G=dir) ;
117     MkDir $(gdir) ;
118   
119     for i in $(<) {
120         target = $(i:BSR=$(dir):G=install) ;
121         targets += $(target) ;
122         Depends $(target) : $(gdir) $(i) ;
123         Install1 $(target) : $(i) ;
124
125         if $(3) {
126             INSTALL on $(target) = $(3) ;
127         } else {
128             INSTALL on $(target) = $(INSTALL_DATA) ;
129         }
130     }
131
132     # We want to package all files we install
133     if ! [ IsElem nopackage : $(4) ] {
134         Package $(<) ;
135     }
136
137     Always $(targets) ;
138     return $(targets) ;
139 }
140
141 #----------------------------------------------------------------------------
142
143 INSTALLTARGETS = install_bin install_plugin install_lib install_header
144                  install_shellscript install_data install_config
145                  install_doc ;
146
147 Always install $(INSTALLTARGETS) ;
148 NotFile install $(INSTALLTARGETS) ;
149 Depends install : $(INSTALLTARGETS) ;
150
151 Help install : "Install $(PACKAGE_NAME)" ;
152
153 actions Install1
154 {
155   $(INSTALL) "$(>)" "$(<:D)" $(INSTALLIBS) ;
156 }
157
158 actions CopyDirs
159 {
160   $(COPYDIRS) "$(>)" "$(<)"
161 }
162