xfstests: Clean up build output
[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 : $(addsuffix -clean,$(SUBDIRS))
10         $(Q)rm -f $(DIRT)
11         $(Q)rm -fr .libs
12
13 %-clean:
14         @echo "Cleaning $*"
15         $(Q)$(MAKE) $(MAKEOPTS) -q -C $* clean || $(MAKE) $(MAKEOPTS) -C $* clean
16
17 # Never blow away subdirs
18 ifdef SUBDIRS
19 .PRECIOUS: $(SUBDIRS)
20 .PHONY: $(SUBDIRS)
21
22 $(SUBDIRS):
23         @echo "Building $@"
24         $(Q)$(MAKE) $(MAKEOPTS) -q -C $@ || $(MAKE) $(MAKEOPTS) -C $@
25 endif
26
27 #
28 # Standard targets
29 #
30
31 ifdef LTCOMMAND
32 $(LTCOMMAND) : $(SUBDIRS) $(OBJECTS) $(LTDEPENDENCIES)
33         @echo "    [LD] $*"
34         $(Q)$(LTLINK) -o $@ $(LDFLAGS) $(OBJECTS) $(LDLIBS)
35 endif
36
37 ifdef LTLIBRARY
38 $(LTLIBRARY) : $(SUBDIRS) $(LTOBJECTS)
39         @echo "    [LD] $*"
40         $(Q)$(LTLINK) $(LTLDFLAGS) -o $(LTLIBRARY) $(LTOBJECTS) $(LTLIBS)
41
42 %.lo: %.c
43         @echo "    [CC] $@"
44         $(Q)$(LTCOMPILE) -c $<
45 else
46 %.o: %.c
47         @echo "    [CC] $@"
48         $(Q)$(CC) $(CFLAGS) -c $<
49
50 endif
51
52 ifdef POTHEAD
53 %.pot: $(XGETTEXTFILES)
54         $(XGETTEXT) --language=C --keyword=_ -o $@ $(XGETTEXTFILES)
55
56 # Generate temp .po files, to check whether translations need updating.
57 # Not by default, due to gettext output differences between versions.
58 %.po: $(POTHEAD)
59 #       $(MSGMERGE) -o $@.tmpo $@ $(POTHEAD)
60 #       if ! diff $@.tmpo $@ >/dev/null; then echo "$@ dated, see $@.tmpo"; fi
61
62 %.mo: %.po
63         $(MSGFMT) -o $@ $<
64 endif
65
66 source :
67         $(SOURCE_MAKERULE)
68
69 endif # _BUILDRULES_INCLUDED_
70
71 $(_FORCE):
72
73 .PHONY : depend
74
75 DEPENDSCRIPT := $(MAKEDEPEND) $(DEPENDFLAGS) -f - -- $(CFLAGS) -- $(CFILES) | \
76         $(SED) -e 's,`pwd`,$(TOPDIR),g' \
77             -e 's,  */[^ ]*,,g' \
78             -e '/^[^ ]*: *$$/d' \
79             -e '/^ *$$/d'
80
81 ifdef LTLIBRARY
82 DEPENDSCRIPT := $(DEPENDSCRIPT) | $(SED) -e 's,^\([^:]*\)\.o,\1.lo,'
83 endif
84
85 depend : $(CFILES) $(HFILES) $(addsuffix -depend,$(SUBDIRS))
86         $(DEPENDSCRIPT) > .dep
87         test -s .dep || rm -f .dep
88
89 %-depend:
90         $(MAKE) -C $* depend
91
92 # Include dep, but only if it exists
93 ifeq ($(shell test -f .dep && echo .dep), .dep)
94 include .dep
95 else
96 ifdef LTLIBRARY
97 $(LTOBJECTS): $(HFILES)
98 else
99 $(OBJECTS): $(HFILES)
100 endif
101 endif