bce094c29e68066aea45cb0d644c9dcbbe6f7c16
[xfstests-dev.git] / include / buildmacros
1 #
2 # Copyright (c) 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
3 #
4 # This program is free software; you can redistribute it and/or modify it
5 # under the terms of version 2 of the GNU General Public License as
6 # published by the Free Software Foundation.
7 #
8 # This program is distributed in the hope that it would be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 #
12 # Further, this software is distributed without any warranty that it is
13 # free of the rightful claim of any third person regarding infringement
14 # or the like.  Any license provided herein, whether implied or
15 # otherwise, applies only to this software file.  Patent licenses, if
16 # any, provided herein do not apply to combinations of this program with
17 # other software, or any other product whatsoever.
18 #
19 # You should have received a copy of the GNU General Public License along
20 # with this program; if not, write the Free Software Foundation, Inc., 59
21 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 #
23 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 # Mountain View, CA  94043, or:
25 #
26 # http://www.sgi.com
27 #
28 # For further information regarding this notice, see:
29 #
30 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 #
32
33 BUILDRULES = $(TOPDIR)/include/buildrules
34
35 # LCFLAGS, LLDFLAGS, LLDLIBS, LSRCFILES and LDIRT may be specified in
36 # user Makefiles. Note: LSRCFILES is anything other than Makefile, $(CFILES)
37 # $(CXXFILES), or $(HFILES) and is used to construct the manifest list
38 # during the "dist" phase (packaging).
39
40 LDFLAGS = $(LLDFLAGS)
41 LDLIBS = $(LLDLIBS) $(PLDLIBS) $(MALLOCLIB)
42
43 MAKEOPTS = --no-print-directory
44 SRCFILES = Makefile $(HFILES) $(CFILES) $(LSRCFILES) $(LFILES) $(YFILES)
45
46 DEPDIRT = dep dep.bak
47 MANDIRT = *.[1-9].gz
48 PODIRT = *.tmpo *.mo
49 CDIRT = $(OBJECTS) $(LTOBJECTS) $(LTCOMMAND) $(LTLIBRARY)
50 DIRT = $(LDIRT) $(DEPDIRT) $(MANDIRT) $(PODIRT) $(CDIRT)
51
52 OBJECTS = $(ASFILES:.s=.o) \
53           $(CFILES:.c=.o) \
54           $(LFILES:.l=.o) \
55           $(YFILES:%.y=%.tab.o)
56
57 INSTALL = $(TOPDIR)/install-sh -o $(PKG_USER) -g $(PKG_GROUP)
58
59 SHELL = /bin/sh
60 IMAGES_DIR = $(TOPDIR)/all-images
61 DIST_DIR = $(TOPDIR)/dist
62
63 CCF     = $(CC) $(CFLAGS) $(CPPFLAGS)
64 MAKEF   = $(MAKE) $(MAKEOPTS)
65 CXXF    = $(CXX) $(CXXFLAGS)
66
67 # For libtool.
68 LIBNAME = $(basename $(LTLIBRARY))
69 LTOBJECTS = $(OBJECTS:.o=.lo)
70 LTVERSION = $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
71
72 LTLINK = $(LIBTOOL) --mode=link $(CC)
73 LTEXEC = $(LIBTOOL) --mode=execute
74 LTINSTALL = $(LIBTOOL) --mode=install $(INSTALL)
75 LTCOMPILE = $(LIBTOOL) --mode=compile $(CCF) -D_REENTRANT -fno-strict-aliasing
76
77 ifeq ($(ENABLE_SHARED),yes)
78 LTLDFLAGS += -rpath $(PKG_LIB_DIR)
79 LTLDFLAGS += -version-info $(LTVERSION)
80 endif
81
82 ifeq ($(ENABLE_SHARED),yes)
83 INSTALL_LTLIB = \
84         cd $(TOPDIR)/$(LIBNAME)/.libs; \
85         ../$(INSTALL) -m 755 -d $(PKG_LIB_DIR); \
86         ../$(INSTALL) -m 644 -T so_dot_version $(LIBNAME).lai $(PKG_LIB_DIR); \
87         test "$(PKG_DISTRIBUTION)" = debian || \
88         ../$(INSTALL) -T so_dot_current $(LIBNAME).lai $(PKG_LIB_DIR)
89 endif
90
91 # Libtool thinks the static and shared libs should be in the same dir, so
92 # make the static lib appear in the place we chose as rpath (using the two
93 # symlinks below).
94 # Other things want the shared libs to appear in /usr/lib, else they'll
95 # link with the static libs there.  So, another symlink to get the .so into
96 # /usr/lib.
97 ifeq ($(ENABLE_SHARED),yes)
98 INSTALL_LTLIB_DEV = \
99         cd $(TOPDIR)/$(LIBNAME)/.libs; \
100         ../$(INSTALL) -m 755 -d $(PKG_DEVLIB_DIR); \
101         ../$(INSTALL) -m 644 -T old_lib $(LIBNAME).lai $(PKG_DEVLIB_DIR); \
102         ../$(INSTALL) -m 644 $(LIBNAME).lai $(PKG_DEVLIB_DIR)/$(LIBNAME).la ; \
103         ../$(INSTALL) -m 755 -d $(PKG_LIB_DIR); \
104         ../$(INSTALL) -T so_base $(LIBNAME).lai $(PKG_LIB_DIR); \
105         ../$(INSTALL) -S $(PKG_DEVLIB_DIR)/$(LIBNAME).a $(PKG_LIB_DIR)/$(LIBNAME).a; \
106         ../$(INSTALL) -S $(PKG_DEVLIB_DIR)/$(LIBNAME).la $(PKG_LIB_DIR)/$(LIBNAME).la; \
107         ../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).so $(PKG_DEVLIB_DIR)/$(LIBNAME).so
108 else
109 INSTALL_LTLIB_DEV = $(INSTALL_LTLIB_STATIC)
110 endif
111
112 INSTALL_LTLIB_STATIC = \
113         cd $(TOPDIR)/$(LIBNAME)/.libs; \
114         ../$(INSTALL) -m 755 -d $(PKG_DEVLIB_DIR); \
115         ../$(INSTALL) -m 644 -T old_lib $(LIBNAME).lai $(PKG_DEVLIB_DIR)
116
117 INSTALL_MAN = \
118         @for d in $(MAN_PAGES); do \
119                 first=true; \
120                 for m in `$(AWK) \
121                         '/^\.S[h|H] NAME/ {ok=1; next} ok {print; exit}' $$d \
122                         | $(SED) \
123                                 -e 's/^\.Nm //' -e 's/,/ /g' -e 's/\\-.*//' \
124                                 -e 's/\\\f[0-9]//g' -e 's/  / /g;q'`; \
125                 do \
126                         [ -z "$$m" -o "$$m" = "\\" ] && continue; \
127                         t=$(MAN_DEST)/$$m.$(MAN_SECTION); \
128                         if $$first; then \
129                                 if $(HAVE_ZIPPED_MANPAGES); then \
130                                         $(ZIP) -9 -c $$d > $$d.gz; _sfx=.gz; \
131                                 fi; \
132                                 u=$$m.$(MAN_SECTION)$$_sfx; \
133                                 echo $(INSTALL) -m 644 $${d}$$_sfx $${t}$$_sfx;\
134                                 $(INSTALL) -m 644 $${d}$$_sfx $${t}$$_sfx; \
135                         else \
136                                 echo $(INSTALL) -S $$u $${t}$$_sfx; \
137                                 $(INSTALL) -S $$u $${t}$$_sfx; \
138                         fi; \
139                         first=false; \
140                 done; \
141         done
142
143 ifeq ($(ENABLE_GETTEXT),yes)
144 INSTALL_LINGUAS = \
145         @for l in $(LINGUAS) ""; do \
146                 if test -f "$$l.mo" ; then \
147                         ldir=$(PKG_LOCALE_DIR)/$$l/LC_MESSAGES; \
148                         $(INSTALL) -m 755 -d $$ldir; \
149                         $(INSTALL) -m 644 $$l.mo $$ldir/$(PKG_NAME).mo; \
150                 fi; \
151         done
152 endif
153
154 SUBDIRS_MAKERULE = \
155         @for d in $(SUBDIRS) ""; do \
156                 if test -d "$$d" -a ! -z "$$d"; then \
157                         $(ECHO) === $$d ===; \
158                         $(MAKEF) -C $$d $@ || exit $$?; \
159                 fi; \
160         done
161
162 MAN_MAKERULE = \
163         @for f in *.[12345678] ""; do \
164                 if test ! -z "$$f"; then \
165                         $(ZIP) --best -c < $$f > $$f.gz; \
166                 fi; \
167         done
168
169 DIST_MAKERULE = \
170         $(MAKEF) -C build dist
171
172 SOURCE_MAKERULE = \
173         @test -z "$$DIR" && DIR="."; \
174         for f in $(SRCFILES) ""; do \
175             if test ! -z "$$f"; then $(ECHO) $$DIR/$$f; fi;\
176         done; \
177         for d in `echo $(SUBDIRS)` ; do \
178             if test -d "$$d" -a ! -z "$$d"; then \
179                 $(MAKEF) DIR=$$DIR/$$d -C $$d $@ || exit $$?; \
180             fi; \
181         done