Git init
[framework/base/acl.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 the GNU General Public License as published by
6 # the Free Software Foundation, either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 #
17
18 BUILDRULES = $(TOPDIR)/include/buildrules
19
20 # LCFLAGS, LLDFLAGS, LLDLIBS, LSRCFILES and LDIRT may be specified in
21 # user Makefiles. Note: LSRCFILES is anything other than Makefile, $(CFILES)
22 # $(CXXFILES), or $(HFILES) and is used to construct the manifest list
23 # during the "dist" phase (packaging).
24
25 LDFLAGS += $(LOADERFLAGS) $(LLDFLAGS)
26 LTLDFLAGS += $(LOADERFLAGS)
27 LDLIBS = $(LLDLIBS) $(PLDLIBS) $(MALLOCLIB)
28
29 MAKEOPTS = --no-print-directory
30 SRCFILES = Makefile $(HFILES) $(CFILES) $(LSRCFILES) $(LFILES) $(YFILES)
31
32 DEPDIRT = dep dep.bak
33 MANDIRT = *.[1-9].gz
34 PODIRT = *.tmpo *.mo
35 CDIRT = $(OBJECTS) $(LTOBJECTS) $(LTCOMMAND) $(LTLIBRARY)
36 DIRT = $(LDIRT) $(DEPDIRT) $(MANDIRT) $(PODIRT) $(CDIRT)
37
38 OBJECTS = $(ASFILES:.s=.o) \
39           $(CFILES:.c=.o) \
40           $(LFILES:.l=.o) \
41           $(YFILES:%.y=%.tab.o)
42
43 INSTALL = $(TOPDIR)/include/install-sh -o $(PKG_USER) -g $(PKG_GROUP)
44
45 SHELL = /bin/sh
46 IMAGES_DIR = $(TOPDIR)/all-images
47 DIST_DIR = $(TOPDIR)/dist
48
49 CCF     = $(CC) $(CFLAGS) $(CPPFLAGS)
50 MAKEF   = $(MAKE) $(MAKEOPTS)
51 CXXF    = $(CXX) $(CXXFLAGS)
52
53 # For libtool.
54 LIBNAME = $(basename $(LTLIBRARY))
55 LTOBJECTS = $(OBJECTS:.o=.lo)
56 LTVERSION = $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
57
58 LTLINK = $(LIBTOOL) --mode=link $(CC)
59 LTEXEC = $(LIBTOOL) --mode=execute
60 LTINSTALL = $(LIBTOOL) --mode=install $(INSTALL)
61 LTCOMPILE = $(LIBTOOL) --mode=compile $(CCF)
62
63 ifeq ($(ENABLE_SHARED),yes)
64 LTLDFLAGS += -rpath $(PKG_LIB_DIR)
65 LTLDFLAGS += -version-info $(LTVERSION)
66 endif
67
68 ifeq ($(ENABLE_SHARED),yes)
69 INSTALL_LTLIB = \
70         cd $(TOPDIR)/$(LIBNAME)/.libs; \
71         ../$(INSTALL) -m 755 -d $(PKG_LIB_DIR); \
72         ../$(INSTALL) -m 644 -T so_dot_version $(LIBNAME).lai $(PKG_LIB_DIR); \
73         ../$(INSTALL) -T so_dot_current $(LIBNAME).lai $(PKG_LIB_DIR)
74 endif
75
76 # Libtool thinks the static and shared libs should be in the same dir, so
77 # make the static lib appear in the place we chose as rpath (using the two
78 # symlinks below).
79 # Other things want the shared libs to appear in /usr/lib, else they'll
80 # link with the static libs there.  So, another symlink to get the .so into
81 # /usr/lib.
82 ifeq ($(ENABLE_SHARED),yes)
83 INSTALL_LTLIB_DEV = \
84         cd $(TOPDIR)/$(LIBNAME)/.libs; \
85         ../$(INSTALL) -m 755 -d $(PKG_DEVLIB_DIR); \
86         ../$(INSTALL) -m 644 -T old_lib $(LIBNAME).lai $(PKG_DEVLIB_DIR); \
87         ../$(INSTALL) -m 644 $(LIBNAME).lai $(PKG_DEVLIB_DIR)/$(LIBNAME).la ; \
88         ../$(INSTALL) -m 755 -d $(PKG_LIB_DIR); \
89         ../$(INSTALL) -T so_base $(LIBNAME).lai $(PKG_LIB_DIR); \
90         if test "x$(PKG_DEVLIB_DIR)" != "x$(PKG_LIB_DIR)" ; then \
91         ../$(INSTALL) -S $(PKG_DEVLIB_DIR)/$(LIBNAME).a $(PKG_LIB_DIR)/$(LIBNAME).a; \
92         ../$(INSTALL) -S $(PKG_DEVLIB_DIR)/$(LIBNAME).la $(PKG_LIB_DIR)/$(LIBNAME).la; \
93         ../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).so $(PKG_DEVLIB_DIR)/$(LIBNAME).so; \
94         fi
95 else
96 INSTALL_LTLIB_DEV = $(INSTALL_LTLIB_STATIC)
97 endif
98
99 INSTALL_LTLIB_STATIC = \
100         cd $(TOPDIR)/$(LIBNAME)/.libs; \
101         ../$(INSTALL) -m 755 -d $(PKG_DEVLIB_DIR); \
102         ../$(INSTALL) -m 644 -T old_lib $(LIBNAME).lai $(PKG_DEVLIB_DIR)
103
104 INSTALL_MAN = \
105         @for d in $(MAN_PAGES); do \
106                 first=true; \
107                 for m in `$(AWK) \
108                         '/^\.S[h|H] NAME/ {ok=1; next} ok {print; exit}' $$d \
109                         | $(SED) \
110                                 -e 's/^\.Nm //' -e 's/,/ /g' -e 's/\\-.*//' \
111                                 -e 's/\\\f[0-9]//g' -e 's/  / /g;q'`; \
112                 do \
113                         [ -z "$$m" -o "$$m" = "\\" ] && continue; \
114                         t=$(MAN_DEST)/$$m.$(MAN_SECTION); \
115                         if $$first; then \
116                                 if $(HAVE_ZIPPED_MANPAGES); then \
117                                         $(ZIP) -9 -c $$d > $$d.gz; _sfx=.gz; \
118                                 fi; \
119                                 u=$$m.$(MAN_SECTION)$$_sfx; \
120                                 echo $(INSTALL) -m 644 $${d}$$_sfx $${t}$$_sfx;\
121                                 $(INSTALL) -m 644 $${d}$$_sfx $${t}$$_sfx; \
122                         else \
123                                 echo $(INSTALL) -S $$u $${t}$$_sfx; \
124                                 $(INSTALL) -S $$u $${t}$$_sfx; \
125                         fi; \
126                         first=false; \
127                 done; \
128         done
129
130 ifeq ($(ENABLE_GETTEXT),yes)
131 INSTALL_LINGUAS = \
132         @for l in $(LINGUAS) ""; do \
133                 if test -f "$$l.mo" ; then \
134                         ldir=$(PKG_LOCALE_DIR)/$$l/LC_MESSAGES; \
135                         $(INSTALL) -m 755 -d $$ldir; \
136                         $(INSTALL) -m 644 $$l.mo $$ldir/$(PKG_NAME).mo; \
137                 fi; \
138         done
139 endif
140
141 MAN_MAKERULE = \
142         @for f in *.[12345678] ""; do \
143                 if test ! -z "$$f"; then \
144                         $(ZIP) --best -c < $$f > $$f.gz; \
145                 fi; \
146         done
147
148 DIST_MAKERULE = \
149         $(MAKEF) -C build dist
150
151 SOURCE_MAKERULE = \
152         @test -z "$$DIR" && DIR="."; \
153         for f in $(SRCFILES) ""; do \
154             test -z "$$f" && break; \
155             test -L "$$f" || $(ECHO) $$DIR/$$f; \
156         done; \
157         for d in `echo $(SUBDIRS)` ""; do \
158             test -z "$$d" && break; \
159             if test -d "$$d"; then \
160                 $(MAKEF) DIR=$$DIR/$$d -C $$d $@ || exit $$?; \
161             fi; \
162         done