summaryrefslogtreecommitdiff
path: root/lib/am/common-targets.mk
blob: 349cbfa5ff4ae7460b33b26e81b5e8e4a09d3308 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
## automake - create Makefile.in from Makefile.am
## Copyright (C) 2001-2014 Free Software Foundation, Inc.

## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2, or (at your option)
## any later version.

## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program.  If not, see <http://www.gnu.org/licenses/>.

## Handle our "flagship" targets 'all', 'install' and 'check', as
## well as timely creation of config headers and $(BUILT_SOURCES).

# ------------------- #
#  The 'all' target.  #
# ------------------- #

.PHONY: all all-am all-local
ifdef SUBDIRS
.PHONY: all-recursive
endif

all-am: all-local $(am.all.targets)
all: $(if $(SUBDIRS),all-recursive,all-am)

# --------------------- #
#  The 'check' target.  #
# --------------------- #

.PHONY: check check-am check-local
ifdef SUBDIRS
.PHONY: check-recursive
endif

# The check target must depend on the local equivalent of 'all', to
# ensure all the primary targets are built; then it must build the
# local check dependencies, and finally run the actual tests (as given
# by $(TESTS), by DejaGNU, and by the 'check-local' target).
am.test-suite.check-targets = check-DEJAGNU check-TESTS check-local
.PHONY: $(am.test-suite.check-targets)
check-am: $(am.test-suite.check-targets)
$(am.test-suite.check-targets): all-am $(am.test-suite.deps)

check: $(if $(SUBDIRS),check-recursive,check-am)

## ----------------------------------------- ##
## installdirs -- Creating the installdirs.  ##
## ----------------------------------------- ##

.PHONY: installdirs installdirs-local
ifdef SUBDIRS
.PHONY: installdirs-am
RECURSIVE_TARGETS += installdirs-recursive
installdirs: installdirs-recursive
endif

$(if $(SUBDIRS),installdirs-am,installdirs): installdirs-local
ifdef am__installdirs
# The reason we loop over $(am__installdirs), instead of simply running
# "$(MKDIR_P) $(am__installdirs), is that directories variable such as
# "$(DESTDIR)$(mydir)" can potentially expand to "" if $(mydir) is
# conditionally defined.  BTW,  directories in $(am__installdirs) are
# already quoted in order to support installation paths with spaces.
	for dir in $(am__installdirs); do \
	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
	done
endif

# ------------------ #
#  Install targets.  #
# ------------------ #

.PHONY: install install-exec install-data uninstall
.PHONY: install-exec-am install-data-am uninstall-am

ifdef SUBDIRS
RECURSIVE_TARGETS += install-data-recursive install-exec-recursive
RECURSIVE_TARGETS += install-recursive uninstall-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
else
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
endif

install: $(if $(SUBDIRS),install-recursive,install-am)

.PHONY: install-am
install-am: all-am
	@$(MAKE) install-exec-am install-data-am


.PHONY: installcheck
ifdef SUBDIRS
installcheck: installcheck-recursive
else
installcheck: installcheck-am
.PHONY: installcheck-am
installcheck-am:
endif

## If you ever modify this, keep in mind that INSTALL_PROGRAM is used
## in subdirectories, so never set it to a value relative to the top
## directory.
.PHONY: install-strip
## Beware that there are two variables used to install programs:
##   INSTALL_PROGRAM is used for ordinary *_PROGRAMS
##   install_sh_PROGRAM is used for nobase_*_PROGRAMS (because install-sh
##                                                     creates directories)
## It's OK to override both with INSTALL_STRIP_PROGRAM, because
## INSTALL_STRIP_PROGRAM uses install-sh (see m4/strip.m4 for a rationale).
##
## Use double quotes for the *_PROGRAM settings because we might need to
## interpolate some backquotes at runtime.
##
## The case for empty $(STRIP) is separate so that it is quoted correctly for
## multiple words, but does not expand to an empty words if STRIP is empty.
install-strip:
	$(MAKE) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
	        install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
		INSTALL_STRIP_FLAG=-s \
		$(if $(STRIP),"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'") \
		install

# Allow parallel install with forced relink.  See commit Automake bd4a1d5
# of 2000-10-19 for a little more background.
# FIXME: this is gross, and is debatable how useful and/or needed this
# workaround still is today.  This is something that should be eventually
# discussed with the Libtool guys.
ifdef bin_PROGRAMS
  ifdef lib_LTLIBRARIES
    install-binPROGRAMS: install-libLTLIBRARIES
  endif
  ifdef nobase_lib_LTLIBRARIES
    install-binPROGRAMS: install-nobase_libLTLIBRARIES
  endif
endif

# -------------------------------------- #
#  $(BUILT_SOURCES) and config headers.  #
# -------------------------------------- #

# We need to make sure $(BUILT_SOURCES) files are built before
# any "ordinary" target (all, check, install, ...) is run.
# Ditto for config.h (or files specified in AC_CONFIG_HEADERS).
# But of course, we shouldn't attempt to build any of them when
# running in dry mode.
am.built-early = $(am.config-hdr.local) $(BUILT_SOURCES)
ifeq ($(am.make.dry-run),true)
# A trick to make the "make -n" output more useful, albeit not
# completely accurate.
all check install: | $(am.built-early)
else
# Also, with this implementation, a recursive make call in the recipe
# of any $(BUILT_SOURCES) (or any of its prerequisites) could cause an
# infinite recursion (complete with fork bomb, yuck), if we are not
# careful.  The following hack takes care of the problem.
$(am.built-early): am.hack.making-built-sources = yes
export am.hack.making-built-sources
ifndef am.hack.making-built-sources
$(foreach x,$(am.built-early),$(eval -include .am/built-sources/$(x)))
.am/built-sources/%: | %
	@$(am.cmd.ensure-target-dir-exists)
	@touch $@
endif
endif