Merge branch 'maint'
[platform/upstream/automake.git] / lib / am / ltlib.am
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1994-2012 Free Software Foundation, Inc.
3
4 ## This program is free software; you can redistribute it and/or modify
5 ## it under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; either version 2, or (at your option)
7 ## any later version.
8
9 ## This program is distributed in the hope that it will be useful,
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ## GNU General Public License for more details.
13
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 if %?INSTALL%
18 include inst-vars.am
19 endif %?INSTALL%
20
21 ## ------------ ##
22 ## Installing.  ##
23 ## ------------ ##
24
25 if %?INSTALL%
26 am__installdirs += "$(DESTDIR)$(%NDIR%dir)"
27 .PHONY install-%EXEC?exec:data%-am: install-%DIR%LTLIBRARIES
28 install-%DIR%LTLIBRARIES: $(%DIR%_LTLIBRARIES)
29         @$(NORMAL_INSTALL)
30 if %?BASE%
31 ## Funny invocation because Makefile variable can be empty, leading to
32 ## a syntax error in sh.
33         @list='$(%DIR%_LTLIBRARIES)'; test -n "$(%NDIR%dir)" || list=; \
34         list2=; for p in $$list; do \
35           if test -f $$p; then \
36             list2="$$list2 $$p"; \
37           else :; fi; \
38         done; \
39         test -z "$$list2" || { \
40           echo " $(MKDIR_P) '$(DESTDIR)$(%NDIR%dir)'"; \
41           $(MKDIR_P) '$(DESTDIR)$(%NDIR%dir)' || exit 1; \
42 ## Note that we explicitly set the libtool mode.  This avoids any lossage
43 ## if the program doesn't have a name that libtool expects.
44 ## Use INSTALL and not INSTALL_DATA because libtool knows the right
45 ## permissions to use.
46 ?LIBTOOL?         echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(%NDIR%dir)'"; \
47 ?LIBTOOL?         $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(%NDIR%dir)"; \
48 ?!LIBTOOL?        echo " $(INSTALL) $(INSTALL_STRIP_FLAG) $$list '$(DESTDIR)$(%NDIR%dir)'"; \
49 ?!LIBTOOL?        $(INSTALL) $(INSTALL_STRIP_FLAG) $$list "$(DESTDIR)$(%NDIR%dir)"; \
50         }
51 else !%?BASE%
52         @list='$(%DIR%_LTLIBRARIES)'; test -n "$(%NDIR%dir)"  || list=; \
53         if test -n "$$list"; then \
54             echo " $(MKDIR_P) '$(DESTDIR)$(%NDIR%dir)'"; \
55             $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)" || exit 1; \
56         fi; \
57         for p in $$list; do if test -f "$$p"; then echo "$$p $$p"; else :; fi; done | \
58         sed '/ .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
59         $(AWK) 'BEGIN { cur = "." } \
60           { if ($$2 == cur) { files = files " " $$1 } \
61             else { print cur, files; files = $$1; cur = $$2 } } \
62           END { print cur, files }' | \
63         while read dir files; do \
64           test -z "$$files" || { \
65             test "x$$dir" = x. || { \
66               echo " $(MKDIR_P) '$(DESTDIR)$(%NDIR%dir)/$$dir'"; \
67               $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)/$$dir"; }; \
68 ## Note that we explicitly set the libtool mode.  This avoids any lossage
69 ## if the program doesn't have a name that libtool expects.
70 ## Use INSTALL and not INSTALL_DATA because libtool knows the right
71 ## permissions to use.
72 ?LIBTOOL?           echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$files '$(DESTDIR)$(%NDIR%dir)/$$dir'"; \
73 ?LIBTOOL?           $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$files "$(DESTDIR)$(%NDIR%dir)/$$dir" || exit $$?; \
74 ?!LIBTOOL?          echo " $(INSTALL) $(INSTALL_STRIP_FLAG) $$files '$(DESTDIR)$(%NDIR%dir)/$$dir'"; \
75 ?!LIBTOOL?          $(INSTALL) $(INSTALL_STRIP_FLAG) $$files "$(DESTDIR)$(%NDIR%dir)/$$dir" || exit $$?; \
76           }; \
77         done
78 endif !%?BASE%
79 endif %?INSTALL%
80
81
82 ## -------------- ##
83 ## Uninstalling.  ##
84 ## -------------- ##
85
86 if %?INSTALL%
87 .PHONY uninstall-am: uninstall-%DIR%LTLIBRARIES
88 uninstall-%DIR%LTLIBRARIES:
89         @$(NORMAL_UNINSTALL)
90         @list='$(%DIR%_LTLIBRARIES)'; test -n "$(%NDIR%dir)" || list=; \
91         for p in $$list; do \
92           %BASE?$(am__strip_dir):f=$$p;% \
93 ?LIBTOOL?         echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(%NDIR%dir)/$$f'"; \
94 ?LIBTOOL?         $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(%NDIR%dir)/$$f"; \
95 ?!LIBTOOL?        echo " rm -f '$(DESTDIR)$(%NDIR%dir)/$$f'"; \
96 ?!LIBTOOL?        rm -f "$(DESTDIR)$(%NDIR%dir)/$$f"; \
97         done
98 endif %?INSTALL%
99
100
101 ## ---------- ##
102 ## Cleaning.  ##
103 ## ---------- ##
104
105 .PHONY clean-am: clean-%DIR%LTLIBRARIES
106 clean-%DIR%LTLIBRARIES:
107         -test -z "$(%DIR%_LTLIBRARIES)" || rm -f $(%DIR%_LTLIBRARIES)
108 ## 'so_locations' files are created by some linkers (IRIX, OSF) when
109 ## building a shared object.  Libtool places these files in the
110 ## directory where the shared object is created.
111         @list='$(%DIR%_LTLIBRARIES)'; \
112         locs=`for p in $$list; do echo $$p; done | \
113               sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
114               sort -u`; \
115         test -z "$$locs" || { \
116           echo rm -f $${locs}; \
117           rm -f $${locs}; \
118         }