generic/574: fix sporadic failure with test_dummy_encryption
[xfstests-dev.git] / include / buildmacros
1 # SPDX-License-Identifier: GPL-2.0
2 # Copyright (c) 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
3 #
4
5 BUILDRULES = $(TOPDIR)/include/buildrules
6
7 # LCFLAGS, LLDFLAGS, LLDLIBS, LSRCFILES and LDIRT may be specified in
8 # user Makefiles. Note: LSRCFILES is anything other than Makefile, $(CFILES)
9 # $(CXXFILES), or $(HFILES) and is used to construct the manifest list
10 # during the "dist" phase (packaging).
11
12 LDFLAGS += $(LOADERFLAGS) $(LLDFLAGS)
13 LDLIBS = $(LLDLIBS) $(PLDLIBS) $(MALLOCLIB)
14
15 MAKEOPTS = --no-print-directory Q=$(Q)
16 SRCFILES = Makefile $(HFILES) $(CFILES) $(LSRCFILES) $(LFILES) $(YFILES)
17
18 DEPDIRT = dep dep.bak
19 MANDIRT = *.[1-9].gz
20 PODIRT = *.tmpo *.mo
21 CDIRT = $(OBJECTS) $(LTOBJECTS) $(LTCOMMAND) $(LTLIBRARY)
22 DIRT = $(LDIRT) $(DEPDIRT) $(MANDIRT) $(PODIRT) $(CDIRT)
23
24 OBJECTS = $(ASFILES:.s=.o) \
25           $(CFILES:.c=.o) \
26           $(LFILES:.l=.o) \
27           $(YFILES:%.y=%.tab.o)
28
29 INSTALL = $(TOPDIR)/install-sh -o $(PKG_USER) -g $(PKG_GROUP)
30
31 IMAGES_DIR = $(TOPDIR)/all-images
32 DIST_DIR = $(TOPDIR)/dist
33
34 CCF     = $(CC) $(CFLAGS) $(CPPFLAGS)
35 MAKEF   = $(MAKE) $(MAKEOPTS)
36 CXXF    = $(CXX) $(CXXFLAGS)
37
38 # For libtool.
39 LIBNAME = $(basename $(LTLIBRARY))
40 LTOBJECTS = $(OBJECTS:.o=.lo)
41 LTVERSION = $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
42
43 LTLINK = $(LIBTOOL) --quiet --tag=CC --mode=link $(CC)
44 LTEXEC = $(LIBTOOL) --quiet --mode=execute
45 LTINSTALL = $(LIBTOOL) --quiet --mode=install $(INSTALL)
46 LTCOMPILE = $(LIBTOOL) --quiet --tag=CC --mode=compile $(CCF)
47
48 ifeq ($(ENABLE_SHARED),yes)
49 LTLDFLAGS += -rpath $(PKG_LIB_DIR)
50 LTLDFLAGS += -version-info $(LTVERSION)
51 endif
52
53 ifeq ($(ENABLE_SHARED),yes)
54 INSTALL_LTLIB = \
55         cd $(TOPDIR)/$(LIBNAME)/.libs; \
56         ../$(INSTALL) -m 755 -d $(PKG_LIB_DIR); \
57         ../$(INSTALL) -m 755 -T so_dot_version $(LIBNAME).lai $(PKG_LIB_DIR); \
58         ../$(INSTALL) -T so_dot_current $(LIBNAME).lai $(PKG_LIB_DIR)
59 endif
60
61 # Libtool thinks the static and shared libs should be in the same dir, so
62 # make the static lib appear in the place we chose as rpath (using the two
63 # symlinks below).
64 # Other things want the shared libs to appear in /usr/lib, else they'll
65 # link with the static libs there.  So, another symlink to get the .so into
66 # /usr/lib.
67 ifeq ($(ENABLE_SHARED),yes)
68 INSTALL_LTLIB_DEV = \
69         cd $(TOPDIR)/$(LIBNAME)/.libs; \
70         ../$(INSTALL) -m 755 -d $(PKG_DEVLIB_DIR); \
71         ../$(INSTALL) -m 644 -T old_lib $(LIBNAME).lai $(PKG_DEVLIB_DIR); \
72         ../$(INSTALL) -m 644 $(LIBNAME).lai $(PKG_DEVLIB_DIR)/$(LIBNAME).la ; \
73         ../$(INSTALL) -m 755 -d $(PKG_LIB_DIR); \
74         ../$(INSTALL) -T so_base $(LIBNAME).lai $(PKG_LIB_DIR); \
75         ../$(INSTALL) -S $(PKG_DEVLIB_DIR)/$(LIBNAME).a $(PKG_LIB_DIR)/$(LIBNAME).a; \
76         ../$(INSTALL) -S $(PKG_DEVLIB_DIR)/$(LIBNAME).la $(PKG_LIB_DIR)/$(LIBNAME).la; \
77         ../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).so $(PKG_DEVLIB_DIR)/$(LIBNAME).so
78 else
79 INSTALL_LTLIB_DEV = $(INSTALL_LTLIB_STATIC)
80 endif
81
82 INSTALL_LTLIB_STATIC = \
83         cd $(TOPDIR)/$(LIBNAME)/.libs; \
84         ../$(INSTALL) -m 755 -d $(PKG_DEVLIB_DIR); \
85         ../$(INSTALL) -m 644 -T old_lib $(LIBNAME).lai $(PKG_DEVLIB_DIR)
86
87 INSTALL_MAN = \
88         @for d in $(MAN_PAGES); do \
89                 first=true; \
90                 for m in `$(AWK) \
91                         '/^\.S[h|H] NAME/ {ok=1; next} ok {print; exit}' $$d \
92                         | $(SED) \
93                                 -e 's/^\.Nm //' -e 's/,/ /g' -e 's/\\-.*//' \
94                                 -e 's/\\\f[0-9]//g' -e 's/  / /g;q'`; \
95                 do \
96                         [ -z "$$m" -o "$$m" = "\\" ] && continue; \
97                         t=$(MAN_DEST)/$$m.$(MAN_SECTION); \
98                         if $$first; then \
99                                 if $(HAVE_ZIPPED_MANPAGES); then \
100                                         $(ZIP) -9 -c $$d > $$d.gz; _sfx=.gz; \
101                                 fi; \
102                                 u=$$m.$(MAN_SECTION)$$_sfx; \
103                                 echo $(INSTALL) -m 644 $${d}$$_sfx $${t}$$_sfx;\
104                                 $(INSTALL) -m 644 $${d}$$_sfx $${t}$$_sfx; \
105                         else \
106                                 echo $(INSTALL) -S $$u $${t}$$_sfx; \
107                                 $(INSTALL) -S $$u $${t}$$_sfx; \
108                         fi; \
109                         first=false; \
110                 done; \
111         done
112
113 ifeq ($(ENABLE_GETTEXT),yes)
114 INSTALL_LINGUAS = \
115         @for l in $(LINGUAS) ""; do \
116                 if test -f "$$l.mo" ; then \
117                         ldir=$(PKG_LOCALE_DIR)/$$l/LC_MESSAGES; \
118                         $(INSTALL) -m 755 -d $$ldir; \
119                         $(INSTALL) -m 644 $$l.mo $$ldir/$(PKG_NAME).mo; \
120                 fi; \
121         done
122 endif
123
124 MAN_MAKERULE = \
125         @for f in *.[12345678] ""; do \
126                 if test ! -z "$$f"; then \
127                         $(ZIP) --best -c < $$f > $$f.gz; \
128                 fi; \
129         done
130
131 DIST_MAKERULE = \
132         $(MAKEF) -C build dist
133
134 SOURCE_MAKERULE = \
135         @test -z "$$DIR" && DIR="."; \
136         for f in $(SRCFILES) ""; do \
137             test -z "$$f" && break; \
138             test -L "$$f" || $(ECHO) $$DIR/$$f; \
139         done; \
140         for d in `echo $(SUBDIRS)` ""; do \
141             test -z "$$d" && break; \
142             if test -d "$$d"; then \
143                 $(MAKEF) DIR=$$DIR/$$d -C $$d $@ || exit $$?; \
144             fi; \
145         done