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) $(DESTDIR)$(bindir)
77 if ( $(PERL) -e '$$fn="$(DESTDIR)$(bindir)/$(LINK)"; exit ((! -f $$fn || -l $$fn) ? 0 : 1);' ); then \
78 echo "Creating a symbolic link from $(LINK_TARGET) to $(LINK) in $(DESTDIR)$(bindir)"; \
79 $(RM) $(DESTDIR)$(bindir)/$(LINK); \
80 $(LN_S) $(LINK_TARGET) $(DESTDIR)$(bindir)/$(LINK); \
82 echo "Creating a symbolic link from $(LINK_TARGET) to $(LINK) in $(DESTDIR)$(bindir) failed: \`$(DESTDIR)$(bindir)/$(LINK)' already exists"; \
83 echo "Perhaps remove \`$(DESTDIR)$(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 "DESTDIR = $(DESTDIR)"
118 @echo "bindir = $(bindir)"
119 @echo "libdir = $(libdir)"
120 @echo "libexecdir = $(libexecdir) # by default, same as libdir"
121 @echo "datadir = $(datadir) # unused for ghc project"
122 @echo "ifacedir = $(ifacedir)"
123 @echo "headerdir = $(headerdir)"
124 @echo "includedir = $(includedir)"
127 # Sometimes useful to separate out the creation of install directories
128 # from the installation itself.
131 $(INSTALL_DIR) $(DESTDIR)$(bindir)
132 $(INSTALL_DIR) $(DESTDIR)$(libdir)
133 $(INSTALL_DIR) $(DESTDIR)$(libexecdir)
134 $(INSTALL_DIR) $(DESTDIR)$(datadir)
136 # Better do this first...
137 install:: install-dirs
140 # Setting user/group ownership for the installed entities
142 ifneq "$(INSTALL_OWNER)" ""
143 SRC_INSTALL_OPTS += -o $(INSTALL_OWNER)
145 ifneq "$(INSTALL_GROUP)" ""
146 SRC_INSTALL_OPTS += -g $(INSTALL_GROUP)
150 ifneq "$(strip $(INSTALL_PROGS))" ""
153 # Here's an interesting one - when using the win32 version
154 # of install (provided via the cygwin toolkit), we have to
155 # supply the .exe suffix, *if* there's no other suffix.
157 # The rule below does this by ferreting out the suffix of each
158 # entry in the INSTALL_PROGS list. If there's no suffix, use
161 INSTALL_PROGS := $(foreach p, $(INSTALL_PROGS), $(addsuffix $(if $(suffix $(p)),,$(exeext)), $(basename $(p))))
163 install:: $(INSTALL_PROGS)
164 $(INSTALL_DIR) $(DESTDIR)$(bindir)
165 for i in $(INSTALL_PROGS); do \
166 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(DESTDIR)$(bindir) ; \
167 if test "$(darwin_TARGET_OS)" = "1"; then \
168 sh $(FPTOOLS_TOP)/mk/fix_install_names.sh $(libdir) $(DESTDIR)$(bindir)/$$i ; \
174 # Just like INSTALL_PROGS, but prefix with install sites bin/lib/data and
175 # install without stripping.
177 ifneq "$(strip $(INSTALL_SCRIPTS))" ""
178 install:: $(INSTALL_SCRIPTS)
179 $(INSTALL_DIR) $(DESTDIR)$(bindir)
180 for i in $(INSTALL_SCRIPTS); do \
181 $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(DESTDIR)$(bindir); \
185 ifneq "$(strip $(INSTALL_LIB_SCRIPTS))" ""
186 install:: $(INSTALL_LIB_SCRIPTS)
187 $(INSTALL_DIR) $(DESTDIR)$(libdir)
188 for i in $(INSTALL_LIB_SCRIPTS); do \
189 $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
193 ifneq "$(strip $(INSTALL_LIBEXEC_SCRIPTS))" ""
194 install:: $(INSTALL_LIBEXEC_SCRIPTS)
195 $(INSTALL_DIR) $(DESTDIR)$(libexecdir)
196 for i in $(INSTALL_LIBEXEC_SCRIPTS); do \
197 $(INSTALL_SCRIPT) $(INSTALL_OPTS) $$i $(DESTDIR)$(libexecdir); \
201 ifneq "$(strip $(INSTALL_LIBS))" ""
202 install:: $(INSTALL_LIBS)
203 $(INSTALL_DIR) $(DESTDIR)$(libdir)
204 for i in $(INSTALL_LIBS); do \
207 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
208 $(RANLIB) $(DESTDIR)$(libdir)/`basename $$i` ;; \
210 $(INSTALL_DATA) -s $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir) ;; \
212 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir) ;; \
214 $(INSTALL_SHLIB) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
215 install_name_tool -id $(DESTDIR)$(libdir)/`basename $$i` $(DESTDIR)$(libdir)/`basename $$i` ;; \
217 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(libdir); \
222 ifneq "$(strip $(INSTALL_LIBEXECS))" ""
224 # See above comment next to defn of INSTALL_PROGS for what
225 # the purpose of this one-liner is.
227 INSTALL_LIBEXECS := $(foreach p, $(INSTALL_LIBEXECS), $(addsuffix $(subst _,,$(subst __,$(exeext),_$(suffix $(p))_)), $(basename $(p))))
229 install:: $(INSTALL_LIBEXECS)
230 $(INSTALL_DIR) $(DESTDIR)$(libexecdir)
231 -for i in $(INSTALL_LIBEXECS); do \
232 $(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i $(DESTDIR)$(libexecdir); \
233 if test "$(darwin_TARGET_OS)" = "1"; then \
234 sh $(FPTOOLS_TOP)/mk/fix_install_names.sh $(libdir) $(DESTDIR)$(libexecdir)/`basename $$i` ; \
239 ifneq "$(strip $(INSTALL_DATAS))" ""
240 install:: $(INSTALL_DATAS)
241 $(INSTALL_DIR) $(DESTDIR)$(datadir)
242 for i in $(INSTALL_DATAS); do \
243 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(datadir); \
247 ifneq "$(strip $(INSTALL_HEADERS))" ""
248 install:: $(INSTALL_HEADERS)
249 $(INSTALL_DIR) $(DESTDIR)$(headerdir)
250 for i in $(INSTALL_HEADERS); do \
251 $(INSTALL_HEADER) $(INSTALL_OPTS) $$i $(DESTDIR)$(headerdir); \
255 ifneq "$(strip $(INSTALL_IFACES))" ""
256 install:: $(INSTALL_IFACES)
257 $(INSTALL_DIR) $(DESTDIR)$(ifacedir)
258 for i in $(INSTALL_IFACES); do \
259 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(ifacedir); \
263 ifneq "$(strip $(INSTALL_IFACES_WITH_DIRS))" ""
264 install:: $(INSTALL_IFACES_WITH_DIRS)
265 $(INSTALL_DIR) $(DESTDIR)$(ifacedir)
266 for i in $(INSTALL_IFACES_WITH_DIRS); do \
267 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(ifacedir)/`dirname $$i`; \
271 ifneq "$(strip $(INSTALL_DOCS))" ""
272 ifneq "$(XMLDocWays)" ""
273 install-docs:: $(INSTALL_DOCS)
274 $(INSTALL_DIR) $(DESTDIR)$(datadir)
275 for i in $(INSTALL_DOCS); do \
276 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(DESTDIR)$(datadir); \
281 # TODO: The following could be an entry for an Obfuscated Makefile Contest...
282 ifneq "$(strip $(INSTALL_XML_DOC))" ""
283 ifneq "$(XMLDocWays)" ""
284 install-docs:: $(foreach i,$(XMLDocWays),$(INSTALL_XML_DOC)$(patsubst %.html-no-chunks,%.html,$(patsubst %.html,%/index.html,.$(i))))
285 $(INSTALL_DIR) $(DESTDIR)$(datadir)
286 for i in $(XMLDocWays); do \
287 if [ $$i = "html" ]; then \
288 $(INSTALL_DIR) $(DESTDIR)$(datadir)/html; \
289 $(INSTALL_DIR) $(DESTDIR)$(datadir)/html/$(INSTALL_XML_DOC); \
290 echo "( cd $(INSTALL_XML_DOC) && $(CP) * $(DESTDIR)$(datadir)/html/$(INSTALL_XML_DOC) )" ; \
291 ( cd $(INSTALL_XML_DOC) && $(CP) * $(DESTDIR)$(datadir)/html/$(INSTALL_XML_DOC) ) ; \
293 $(INSTALL_DIR) $(DESTDIR)$(datadir)/doc; \
294 echo $(INSTALL_DATA) $(INSTALL_OPTS) $(INSTALL_XML_DOC)`echo .$$i | sed s/\.html-no-chunks/.html/` $(DESTDIR)$(datadir)/doc; \
295 $(INSTALL_DATA) $(INSTALL_OPTS) $(INSTALL_XML_DOC)`echo .$$i | sed s/\.html-no-chunks/.html/` $(DESTDIR)$(datadir)/doc; \
297 if [ $$i = "html-no-chunks" ]; then \
298 echo $(CP) $(FPTOOLS_CSS_ABS) $(DESTDIR)$(datadir)/doc; \
299 $(CP) $(FPTOOLS_CSS_ABS) $(DESTDIR)$(datadir)/doc; \
306 # install-strip is from the GNU Makefile standard.
310 $(MAKE) EXTRA_INSTALL_OPTS='-s' install