2 # install* installcheck installdirs
5 # Some of the above targets have a version that
6 # recursively invokes that target in sub-directories.
7 # This relies on the importing Makefile setting SUBDIRS
9 # The recursive targets are marked with a * above
12 ##################################################################
13 # GNU Standard targets
15 # Every Makefile should define the following targets
18 # Compile the program and copy the executables, libraries, and so on
19 # to the file names where they should reside for actual use. If
20 # there is a simple test to verify that a program is properly
21 # installed, this target should run that test.
23 # The commands should create all the directories in which files are
24 # to be installed, if they don't already exist. This includes the
25 # directories specified as the values of the variables prefix and
26 # exec_prefix , as well as all subdirectories that are needed. One
27 # way to do this is by means of an installdirs target as described
30 # Use `-' before any command for installing a man page, so that make
31 # will ignore any errors. This is in case there are systems that
32 # don't have the Unix man page documentation system installed.
34 # The following targets are suggested as conventional names, for programs
35 # in which they are useful.
38 # Perform installation tests (if any). The user must build and
39 # install the program before running the tests. You should not
40 # assume that `$(bindir)' is in the search path.
43 # It's useful to add a target named `installdirs' to create the
44 # directories where files are installed, and their parent
45 # directories. There is a script called `mkinstalldirs' which is
46 # convenient for this; find it in the Texinfo package.
47 # (GHC: we use a close relative of the suggested script, situated
48 # in glafp-utils/mkdirhier -- SOF)
52 # ---------------------------------------------------------------------------
55 # links to programs: we sometimes install a program as
56 # <name>-<version> with a link from <name> to the real program.
60 ifeq "$(LINK_TARGET)" ""
62 LINK_TARGET = $(HS_PROG)
65 LINK_TARGET = $(C_PROG)
67 $(error Cannot deduce LINK_TARGET)
73 # install links to script drivers.
76 @$(INSTALL_DIR) $(bindir)
77 @if ( $(PERL) -e '$$fn="$(bindir)/$(LINK)"; exit ((! -f $$fn || -l $$fn) ? 0 : 1);' ); then \
78 echo "Creating a symbolic link from $(LINK_TARGET) to $(LINK) in $(bindir)"; \
79 $(RM) $(bindir)/$(LINK); \
80 $(LN_S) $(LINK_TARGET) $(bindir)/$(LINK); \
82 echo "Creating a symbolic link from $(LINK_TARGET) to $(LINK) in $(bindir) failed: \`$(bindir)/$(LINK)' already exists"; \
83 echo "Perhaps remove \`$(bindir)/$(LINK)' manually?"; \
90 ###########################################
92 # Targets: install install-strip
94 ###########################################
96 # For each of these variables that is defined, you
97 # get one install rule
99 # INSTALL_PROGS executable programs in $(bindir)
100 # INSTALL_SCRIPTS executable scripts in $(bindir)
101 # INSTALL_LIBS platform-dependent libraries in $(libdir) (ranlib'ed)
102 # INSTALL_LIB_SCRIPTS platform-dependent scripts in $(libdir)
103 # INSTALL_LIBEXECS platform-dependent execs in $(libdir)
104 # INSTALL_DATAS platform-independent files in $(datadir)
105 # INSTALL_IFACES platform-dependent interface files in $(ifacedir)
107 # If the installation directory variable is undefined, the install rule simply
108 # emits a suitable error message.
110 # Remember, too, that the installation directory variables ($(bindir) and
111 # friends can be overridden from their original settings in mk/config.mk.in
114 .PHONY: install install-docs installdirs install-strip install-dirs install-docs show-install
117 @echo "bindir = $(bindir)"
118 @echo "libdir = $(libdir)"
119 @echo "libexecdir = $(libexecdir) # by default, same as libdir"
120 @echo "datadir = $(datadir) # unused for ghc project"
123 # Sometimes useful to separate out the creation of install directories
124 # from the installation itself.
127 @$(INSTALL_DIR) $(bindir)
128 @$(INSTALL_DIR) $(libdir)
129 @$(INSTALL_DIR) $(libexecdir)
130 @$(INSTALL_DIR) $(datadir)
132 # Better do this first...
133 # but we won't for the moment, do it on-demand from
134 # within the various install targets instead.
135 #install:: install-dirs
138 # Setting user/group ownership for the installed entities
140 ifneq "$(INSTALL_OWNER)" ""
141 SRC_INSTALL_OPTS += -o $(INSTALL_OWNER)
143 ifneq "$(INSTALL_GROUP)" ""
144 SRC_INSTALL_OPTS += -g $(INSTALL_GROUP)
148 ifneq "$(strip $(INSTALL_PROGS))" ""
151 # Here's an interesting one - when using the win32 version
152 # of install (provided via the cygwin toolkit), we have to
153 # supply the .exe suffix, *if* there's no other suffix.
155 # The rule below does this by ferreting out the suffix of each
156 # entry in the INSTALL_PROGS list. If there's no suffix, use
159 INSTALL_PROGS := $(foreach p, $(INSTALL_PROGS), $(addsuffix $(if $(suffix $(p)),,$(exeext)), $(basename $(p))))
161 install:: $(INSTALL_PROGS)
162 @$(INSTALL_DIR) $(bindir)
163 @for i in $(INSTALL_PROGS); do \
164 echo $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(bindir); \
165 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(bindir) ; \
166 if test "$(darwin_TARGET_OS)" = "1"; then \
167 sh $(FPTOOLS_TOP)/mk/fix_install_names.sh $(libdir) $(bindir)/$$i ; \
173 # Just like INSTALL_PROGS, but prefix with install sites bin/lib/data and
174 # install without stripping.
176 ifneq "$(strip $(INSTALL_SCRIPTS))" ""
177 install:: $(INSTALL_SCRIPTS)
178 @$(INSTALL_DIR) $(bindir)
179 for i in $(INSTALL_SCRIPTS); do \
180 $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(bindir); \
184 ifneq "$(strip $(INSTALL_LIB_SCRIPTS))" ""
185 install:: $(INSTALL_LIB_SCRIPTS)
186 @$(INSTALL_DIR) $(libdir)
187 for i in $(INSTALL_LIB_SCRIPTS); do \
188 $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(libdir); \
192 ifneq "$(strip $(INSTALL_LIBEXEC_SCRIPTS))" ""
193 install:: $(INSTALL_LIBEXEC_SCRIPTS)
194 @$(INSTALL_DIR) $(libexecdir)
195 for i in $(INSTALL_LIBEXEC_SCRIPTS); do \
196 $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(libexecdir); \
200 ifneq "$(strip $(INSTALL_LIBS))" ""
201 install:: $(INSTALL_LIBS)
202 @$(INSTALL_DIR) $(libdir)
203 for i in $(INSTALL_LIBS); do \
206 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(libdir); \
207 $(RANLIB) $(libdir)/`basename $$i` ;; \
209 $(INSTALL_DATA) -s $(INSTALL_OPTS) $$i $(libdir) ;; \
211 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(libdir) ;; \
213 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(libdir); \
214 install_name_tool -id $(libdir)/`basename $$i` $(libdir)/`basename $$i` ;; \
216 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(libdir); \
221 ifneq "$(strip $(INSTALL_LIBEXECS))" ""
223 # See above comment next to defn of INSTALL_PROGS for what
224 # the purpose of this one-liner is.
226 INSTALL_LIBEXECS := $(foreach p, $(INSTALL_LIBEXECS), $(addsuffix $(subst _,,$(subst __,$(exeext),_$(suffix $(p))_)), $(basename $(p))))
228 install:: $(INSTALL_LIBEXECS)
229 @$(INSTALL_DIR) $(libexecdir)
230 -for i in $(INSTALL_LIBEXECS); do \
231 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(libexecdir); \
232 if test "$(darwin_TARGET_OS)" = "1"; then \
233 sh $(FPTOOLS_TOP)/mk/fix_install_names.sh $(libdir) $(libexecdir)/`basename $$i` ; \
238 ifneq "$(strip $(INSTALL_DATAS))" ""
239 install:: $(INSTALL_DATAS)
240 @$(INSTALL_DIR) $(datadir)
241 for i in $(INSTALL_DATAS); do \
242 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir); \
246 ifneq "$(strip $(INSTALL_IFACES))" ""
247 install:: $(INSTALL_IFACES)
248 @$(INSTALL_DIR) $(ifacedir)
249 for i in $(INSTALL_IFACES); do \
250 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(ifacedir); \
254 ifneq "$(strip $(INSTALL_IFACES_WITH_DIRS))" ""
255 install:: $(INSTALL_IFACES_WITH_DIRS)
256 @$(INSTALL_DIR) $(ifacedir)
257 for i in $(INSTALL_IFACES_WITH_DIRS); do \
258 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(ifacedir)/`dirname $$i`; \
262 ifneq "$(strip $(INSTALL_INCLUDES))" ""
263 install:: $(INSTALL_INCLUDES)
264 @$(INSTALL_DIR) $(includedir)
265 for i in $(INSTALL_INCLUDES); do \
266 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(includedir); \
270 ifneq "$(strip $(INSTALL_DOCS))" ""
271 ifneq "$(XMLDocWays)" ""
272 install-docs:: $(INSTALL_DOCS)
273 @$(INSTALL_DIR) $(datadir)
274 for i in $(INSTALL_DOCS); do \
275 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir); \
280 # TODO: The following could be an entry for an Obfuscated Makefile Contest...
281 ifneq "$(strip $(INSTALL_XML_DOC))" ""
282 ifneq "$(XMLDocWays)" ""
283 install-docs:: $(foreach i,$(XMLDocWays),$(INSTALL_XML_DOC)$(patsubst %.html-no-chunks,%.html,$(patsubst %.html,%/index.html,.$(i))))
284 @$(INSTALL_DIR) $(datadir)
285 @for i in $(XMLDocWays); do \
286 if [ $$i = "html" ]; then \
287 $(INSTALL_DIR) $(datadir)/html; \
288 $(INSTALL_DIR) $(datadir)/html/$(INSTALL_XML_DOC); \
289 echo "( cd $(INSTALL_XML_DOC) && $(CP) * $(datadir)/html/$(INSTALL_XML_DOC) )" ; \
290 ( cd $(INSTALL_XML_DOC) && $(CP) * $(datadir)/html/$(INSTALL_XML_DOC) ) ; \
292 $(INSTALL_DIR) $(datadir)/doc; \
293 echo $(INSTALL_DATA) $(INSTALL_OPTS) $(INSTALL_XML_DOC)`echo .$$i | sed s/\.html-no-chunks/.html/` $(datadir)/doc; \
294 $(INSTALL_DATA) $(INSTALL_OPTS) $(INSTALL_XML_DOC)`echo .$$i | sed s/\.html-no-chunks/.html/` $(datadir)/doc; \
296 if [ $$i = "html-no-chunks" ]; then \
297 echo $(CP) $(FPTOOLS_CSS_ABS) $(datadir)/doc; \
298 $(CP) $(FPTOOLS_CSS_ABS) $(datadir)/doc; \
305 # install-strip is from the GNU Makefile standard.
309 @$(MAKE) EXTRA_INSTALL_OPTS='-s' install