fix make depend for libtool libraries
[xfstests-dev.git] / include / buildrules
1 #
2 # Copyright (c) 1999, 2001-2003 Silicon Graphics, Inc.  All Rights Reserved.
3 #
4 ifndef _BUILDRULES_INCLUDED_
5 _BUILDRULES_INCLUDED_ = 1
6
7 include $(TOPDIR)/include/builddefs
8
9 clean clobber : $(SUBDIRS)
10         rm -f $(DIRT)
11         @rm -fr .libs
12         $(SUBDIRS_MAKERULE)
13
14 # Never blow away subdirs
15 ifdef SUBDIRS
16 .PRECIOUS: $(SUBDIRS)
17 $(SUBDIRS):
18         $(SUBDIRS_MAKERULE)
19 endif
20
21 #
22 # Standard targets
23 #
24
25 ifdef LTCOMMAND
26 $(LTCOMMAND) : $(SUBDIRS) $(OBJECTS) $(LTDEPENDENCIES)
27         $(LTLINK) -o $@ $(LDFLAGS) $(OBJECTS) $(LDLIBS)
28 endif
29
30 ifdef LTLIBRARY
31 $(LTLIBRARY) : $(SUBDIRS) $(LTOBJECTS)
32         $(LTLINK) $(LTLDFLAGS) -o $(LTLIBRARY) $(LTOBJECTS) $(LTLIBS)
33
34 %.lo: %.c
35         $(LTCOMPILE) -c $<
36 endif
37
38 ifdef POTHEAD
39 %.pot: $(XGETTEXTFILES)
40         $(XGETTEXT) --language=C --keyword=_ -o $@ $(XGETTEXTFILES)
41
42 # Generate temp .po files, to check whether translations need updating.
43 # Not by default, due to gettext output differences between versions.
44 %.po: $(POTHEAD)
45 #       $(MSGMERGE) -o $@.tmpo $@ $(POTHEAD)
46 #       if ! diff $@.tmpo $@ >/dev/null; then echo "$@ dated, see $@.tmpo"; fi
47
48 %.mo: %.po
49         $(MSGFMT) -o $@ $<
50 endif
51
52 source :
53         $(SOURCE_MAKERULE)
54
55 endif # _BUILDRULES_INCLUDED_
56
57 $(_FORCE):
58
59 .PHONY : depend
60
61 DEPENDSCRIPT := $(MAKEDEPEND) $(DEPENDFLAGS) -f - -- $(CFLAGS) -- $(CFILES) | \
62         $(SED) -e 's,`pwd`,$(TOPDIR),g' \
63             -e 's,  */[^ ]*,,g' \
64             -e '/^[^ ]*: *$$/d' \
65             -e '/^ *$$/d'
66
67 ifdef LTLIBRARY
68 DEPENDSCRIPT := $(DEPENDSCRIPT) | $(SED) -e 's,^\([^:]*\)\.o,\1.lo,'
69 endif
70
71 depend : $(CFILES) $(HFILES)
72         $(SUBDIRS_MAKERULE)
73         $(DEPENDSCRIPT) > .dep
74         test -s .dep || rm -f .dep
75
76 # Include dep, but only if it exists
77 ifeq ($(shell test -f .dep && echo .dep), .dep)
78 include .dep
79 else
80 ifdef LTLIBRARY
81 $(LTOBJECTS): $(HFILES)
82 else
83 $(OBJECTS): $(HFILES)
84 endif
85 endif