build: Generate versioned scripts at make time
[automake.git] / bin / Makefile.inc
blob62dd483d909f97ca8200b8e5cc75215119e44f3a
1 ## Copyright (C) 1995-2017 Free Software Foundation, Inc.
2 ##
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 2, or (at your option)
6 ## any later version.
7 ##
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 ## GNU General Public License for more details.
13 ## You should have received a copy of the GNU General Public License
14 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 ## ----------------------------------- ##
17 ##  The automake and aclocal scripts.  ##
18 ## ----------------------------------- ##
20 bin_SCRIPTS = %D%/automake %D%/aclocal
21 nodist_noinst_SCRIPTS += \
22   %D%/aclocal-$(APIVERSION) \
23   %D%/automake-$(APIVERSION)
25 CLEANFILES += \
26   $(bin_SCRIPTS) \
27   %D%/aclocal-$(APIVERSION) \
28   %D%/automake-$(APIVERSION)
30 # Used by maintainer checks and such.
31 automake_in = $(srcdir)/%D%/automake.in
32 aclocal_in  = $(srcdir)/%D%/aclocal.in
33 automake_script = %D%/automake
34 aclocal_script  = %D%/aclocal
36 AUTOMAKESOURCES = $(automake_in) $(aclocal_in)
37 TAGS_FILES += $(AUTOMAKESOURCES)
38 EXTRA_DIST += $(AUTOMAKESOURCES)
40 # Make versioned links.  We only run the transform on the root name;
41 # then we make a versioned link with the transformed base name.  This
42 # seemed like the most reasonable approach.
43 install-exec-hook:
44         @$(POST_INSTALL)
45         @for p in $(bin_SCRIPTS); do \
46           f=`echo $$p | sed -e 's,.*/,,' -e '$(transform)'`; \
47           fv="$$f-$(APIVERSION)"; \
48           rm -f "$(DESTDIR)$(bindir)/$$fv"; \
49           echo " $(LN) '$(DESTDIR)$(bindir)/$$f' '$(DESTDIR)$(bindir)/$$fv'"; \
50           $(LN) "$(DESTDIR)$(bindir)/$$f" "$(DESTDIR)$(bindir)/$$fv"; \
51         done
53 uninstall-hook:
54         @for p in $(bin_SCRIPTS); do \
55           f=`echo $$p | sed -e 's,.*/,,' -e '$(transform)'`; \
56           fv="$$f-$(APIVERSION)"; \
57           rm -f "$(DESTDIR)$(bindir)/$$fv"; \
58         done
60 # These files depend on Makefile so they are rebuilt if $(VERSION),
61 # $(datadir) or other do_subst'ituted variables change.
62 %D%/automake: %D%/automake.in
63 %D%/aclocal: %D%/aclocal.in
64 %D%/automake %D%/aclocal: Makefile %D%/gen-perl-protos
65         $(AM_V_GEN)rm -f $@ $@-t $@-t2 \
66           && $(MKDIR_P) $(@D) \
67 ## Common substitutions.
68           && in=$@.in && $(do_subst) <$(srcdir)/$$in >$@-t \
69 ## Auto-compute prototypes of perl subroutines.
70           && $(PERL) -w $(srcdir)/%D%/gen-perl-protos $@-t > $@-t2 \
71           && mv -f $@-t2 $@-t \
72 ## We can't use '$(generated_file_finalize)' here, because currently
73 ## Automake contains occurrences of unexpanded @substitutions@ in
74 ## comments, and that is perfectly legit.
75           && chmod a+x,a-w $@-t && mv -f $@-t $@
76 EXTRA_DIST += %D%/gen-perl-protos
78 %D%/aclocal-$(APIVERSION): %D%/aclocal
79         $(AM_V_GEN) rm -f $@; \
80         $(LN) %D%/aclocal $@
82 %D%/automake-$(APIVERSION): %D%/automake
83         $(AM_V_GEN) rm -f $@; \
84         $(LN) %D%/automake $@
86 # vim: ft=automake noet