1 # SPDX-License-Identifier: GPL-2.0
2 # Copyright (c) 1999, 2001-2003 Silicon Graphics, Inc. All Rights Reserved.
4 ifndef _BUILDRULES_INCLUDED_
5 _BUILDRULES_INCLUDED_ = 1
7 include $(TOPDIR)/include/builddefs
9 depend: $(addsuffix -depend,$(SUBDIRS))
12 $(Q)$(MAKE) $(MAKEOPTS) -q -C $* depend || \
13 $(MAKE) $(MAKEOPTS) -C $* depend
15 clean clobber : $(addsuffix -clean,$(SUBDIRS))
17 $(Q)rm -fr .libs .ltdep .dep
21 $(Q)$(MAKE) $(MAKEOPTS) -q -C $* clean || \
22 $(MAKE) $(MAKEOPTS) -C $* clean
24 # Never blow away subdirs
31 $(Q)$(MAKE) $(MAKEOPTS) -q -C $@ || $(MAKE) $(MAKEOPTS) -C $@
39 $(LTCOMMAND) : $(SUBDIRS) $(OBJECTS) $(LTDEPENDENCIES)
41 $(Q)$(LTLINK) -o $@ $(LDFLAGS) $(OBJECTS) $(LDLIBS)
45 $(LTLIBRARY) : $(SUBDIRS) $(LTOBJECTS)
47 $(Q)$(LTLINK) $(LTLDFLAGS) -o $(LTLIBRARY) $(LTOBJECTS) $(LTLIBS)
51 $(Q)$(LTCOMPILE) -c $<
55 $(Q)$(CC) $(CFLAGS) -c $<
60 %.pot: $(XGETTEXTFILES)
61 $(XGETTEXT) --language=C --keyword=_ -o $@ $(XGETTEXTFILES)
63 # Generate temp .po files, to check whether translations need updating.
64 # Not by default, due to gettext output differences between versions.
66 # $(MSGMERGE) -o $@.tmpo $@ $(POTHEAD)
67 # if ! diff $@.tmpo $@ >/dev/null; then echo "$@ dated, see $@.tmpo"; fi
76 endif # _BUILDRULES_INCLUDED_
80 # dependency build is automatic, relies on gcc -MM to generate.
83 MAKEDEP := $(MAKEDEPEND) $(CFLAGS)
85 .ltdep: $(CFILES) $(HFILES)
87 $(Q)if [ -n "$$( echo $(CFILES))" ]; then \
88 $(MAKEDEP) $(CFILES) | \
89 $(SED) -e 's,^\([^:]*\)\.o,\1.lo,' > .ltdep; \
91 cp /dev/null .ltdep; \
94 .dep: $(CFILES) $(HFILES)
96 $(Q)if [ -n "$$( echo $(CFILES))" ]; then \
97 $(MAKEDEP) $(CFILES) | \
98 $(SED) -e 's,^\([^:]*\)\.o,\1,' > .dep; \
103 # Gather files for installing into two lists:
104 # TESTS with executable scripts and OUTFILES with all the test outputs.
105 # Makefile has a very small matching, so we have to go this long way.
107 # Start with all test related files:
108 ALLFILES = $(wildcard [0-9]??*)
110 # Now build a list of known output files. Unfortunately, the
111 # multiple output test files are poorly handled as makefiles don't
112 # handle wildcarded multi-suffix matching. Hence we separate the
113 # processing of these right now.
114 EXTENDED_OUTFILES = $(wildcard [0-9]??*.out.*)
115 EXTENDED_OUTFILE_CFGS = $(wildcard [0-9]??.cfg)
116 BASIC_OUTFILES = $(wildcard [0-9]??*.out)
117 OUTFILES = $(EXTENDED_OUTFILES) $(EXTENDED_OUTFILE_CFGS) $(BASIC_OUTFILES)
119 # Strip suffix to get matching tests. We want to strip from the
120 # first "." to the end, but makefiles don't have a built in
121 # operative for that. So:
123 # Hack: strip the multiple segments after .out with repeated basename calls.
124 EXTFILTER1 = $(basename $(EXTENDED_OUTFILES))
125 EXTFILTER2 = $(basename $(EXTFILTER1))
126 EXTFILTER3 = $(basename $(EXTFILTER2))
127 EXTFILTER4 = $(basename $(EXTFILTER3))
130 FILTER = $(basename $(EXTFILTER4) $(BASIC_OUTFILES))
132 # finally, select the test files by filtering against against the
133 # stripped output files and sort them to remove duplicates.
134 TESTS = $(sort $(filter $(ALLFILES), $(FILTER)))