6fd971746a08b64ada100a31cd6c04ad25244e02
[clinton/guile-figl.git] / upstream-man-pages / man3 / usr / include / make / commondefs
1 # Copyright (c) 1991-2000 Silicon Graphics, Inc.
2 # This document is licensed under the SGI Free Software B license.
3 # For details, see
4 #
5 # http://oss.sgi.com/projects/FreeB
6 #
7 # $Date$ $Revision$
8 # $Header: //depot/main/tools/include/commondefs#43 $
9
10 COMMONRULES=$(ROOT)/usr/include/make/commonrules
11
12 # what OS are we running on
13 OS=$(shell uname)
14 ifeq ($(subst 64,,$(OS)), IRIX)
15 OS=IRIX
16 endif
17 ifeq (CYGWIN,$(findstring CYGWIN,$(OS)))
18 OS=Linux
19 endif
20
21 # various source-level directories
22 TOOLSSRC = $(TOPDIR)/tools
23 GFXINCLUDESRC = $(TOPDIR)/gfx/include
24 OGLLIBSRC = $(TOPDIR)/gfx/lib/opengl
25 GLXLIBSRC = $(TOPDIR)/glx
26
27 # SGI Free Software B license
28 OSSCOPYRIGHT = $(TOPDIR)/doc/release/OSSCOPYRIGHT
29
30 # shell-related defs
31 SHELL = /bin/sh
32 AWK = awk
33 ifeq ($(OS),IRIX)
34 ECHO = /bin/echo
35 endif
36 ifeq ($(OS),Linux)
37 ECHO = /bin/echo -e
38 endif
39 RM = rm -f
40 MV = mv
41 PERL = perl
42 SED = sed
43 UNIQ = uniq
44
45 # M4 options - run GNU M4 in compatibility mode
46 # rdist options - Red Hat 5.2 must have daemon location specified
47 ifeq ($(OS),IRIX)
48 M4OPTS =
49 endif
50 ifeq ($(OS),Linux)
51 M4OPTS = -G
52 RDIST_OPTS = -p /usr/sbin/rdistd
53 endif
54
55 # override default gmake CXX with what we have
56 ifeq ($(OS),IRIX)
57 CXX = CC
58 endif
59
60 # what language are we using? Default to ansi with extended defines
61 ifeq ($(OS),IRIX)
62 CVERSION = -xansi
63 endif
64 ifeq ($(OS),Linux)
65 CVERSION= -ansi -include $(ROOT)/usr/include/make/linuxdefs
66 endif
67
68 # WARN is the warning option
69 ifeq ($(OS),IRIX)
70 #
71 # Turn of explicitly some warnings on IRIX. Specifically:
72 # 1155: unrecognized #pragma
73 # 1174: parameter/variable "???" was declared but never referenced
74 # 1201: trailing comma is nonstandard (last element in struct assnment)
75 # 1209: controlling expression is constant
76 # 1506: implicit conversion from "???" to "???": rounding, sign
77 # extension, or loss of accuracy may result
78 # 3170: "???" not marked as intrinsic because it is not declared
79 # as a function
80 #
81 WARN = -fullwarn \
82 -woff 1155,1174,1506,1201,1209,3170
83 endif
84 ifeq ($(OS),Linux)
85 WARN = -Wimplicit \
86 -Wreturn-type \
87 -Wswitch \
88 -Wcomment \
89 -Wformat \
90 -Wchar-subscripts \
91 -Wparentheses \
92 -Wpointer-arith \
93 -Wcast-qual \
94 -Wmissing-prototypes \
95 -Wmissing-declarations \
96 $(NULL)
97 endif
98
99 # default optimization
100 ifeq ($(subst y,1,$(GLDEBUG)),1)
101 OPTIMIZER=-g
102 else
103 OPTIMIZER=-O2
104 ifeq ($(OS),Linux)
105 WARN += -Wuninitialized
106 endif
107 endif
108
109 # how to make dependencies
110 ifeq ($(OS),IRIX)
111 MKDEPOPT = -MDupdate Makedepend
112 endif
113 ifeq ($(OS),Linux)
114 MKDEPOPT = -MD
115 endif
116
117 override GCOPTS = $(OPTIMIZER) $(MKDEPOPT) $(WARN)
118 override GCXXOPTS = $(OPTIMIZER) $(MKDEPOPT) $(WARN)
119
120 # where is the default include directory?
121 # (we don't grab it off $ROOT, to avoid populating $ROOT with system
122 # includes. Yes, I know... You don't like the idea.
123 INCLDIR = /usr/include
124
125 # where to install include files?
126 INCLUDE_LOCATION = $(ROOT)/usr/include
127
128 # we would like to use nostdinc on Linux, but unfortunately, it also
129 # removes include directories with no well-known fixed path (ie. the
130 # gcc install directory).
131 ifeq ($(OS),IRIX)
132 override GCINCS = -nostdinc -I$(ROOT)$(INCLDIR) -I$(INCLDIR)
133 override GCXXINCS = -nostdinc -I$(ROOT)$(INCLDIR) -I$(INCLDIR)
134 endif
135 ifeq ($(OS),Linux)
136 override GCINCS = -I$(ROOT)$(INCLDIR)
137 override GCXXINCS = -I$(ROOT)$(INCLDIR) -I$(INCLDIR)
138 endif
139
140 ifeq ($(GLDEBUG),1)
141 override GCDEFS = -DDEBUG -UNDEBUG
142 override GCXXDEFS = -DDEBUG -UNDEBUG
143 else
144 override GCDEFS = -UDEBUG -DNDEBUG
145 override GCXXDEFS = -UDEBUG -DNDEBUG
146 endif
147
148 #
149 # Cc flags, composed of:
150 # variable (V*) (set on the command line)
151 # local (L*) (set in the makefile)
152 # global (G*) (defined in this file, not overrideable)
153 # in that order. This is done so that the locally defined includes
154 # are searched before the globally defined ones.
155 #
156 CFLAGS = $(CVERSION) $(VCFLAGS) $(LCFLAGS) $(GCFLAGS)
157
158 #
159 # Each of these three components is divided into defines (-D's and -U's),
160 # includes (-I's), and other options. By segregating the different
161 # classes of flag to cc, the defines (CDEFS) and includes (CINCS) can be
162 # easily given to other programs, e.g., lint.
163 #
164 # Notes:
165 # - The local assignments should be to LCOPTS, LCDEFS, and LCINCS, not to
166 # LCFLAGS, although CFLAGS will be correctly set if this is done.
167 # - If a program cannot be optimized, it should override the setting of
168 # OPTIMIZER with a line such as "OPTIMIZER=" in its make file.
169 # - If a program cannot be compiled with ANSI C, its makefile
170 # should set CVERSION=-cckr
171 #
172 VCFLAGS = $(VCDEFS) $(VCINCS) $(VCOPTS)
173 LCFLAGS = $(LCDEFS) $(LCINCS) $(LCOPTS)
174 GCFLAGS = $(GCDEFS) $(GCINCS) $(GCOPTS)
175
176 COPTS = $(VCOPTS) $(LCOPTS) $(GCOPTS)
177 CDEFS = $(VCDEFS) $(LCDEFS) $(GCDEFS)
178 CINCS = $(VCINCS) $(LCINCS) $(GCINCS)
179
180 #
181 # CXX flags are decomposed using the same hierarchy as C flags.
182 #
183 CXXFLAGS = $(CVERSION) $(VCXXFLAGS) $(LCXXFLAGS) $(GCXXFLAGS)
184
185 VCXXFLAGS = $(VCXXDEFS) $(VCXXINCS) $(VCXXOPTS)
186 LCXXFLAGS = $(LCXXDEFS) $(LCXXINCS) $(LCXXOPTS)
187 GCXXFLAGS = $(GCXXDEFS) $(GCXXINCS) $(GCXXOPTS)
188
189 CXXOPTS = $(VCXXOPTS) $(LCXXOPTS) $(GCXXOPTS)
190 CXXDEFS = $(VCXXDEFS) $(LCXXDEFS) $(GCXXDEFS)
191 CXXINCS = $(VCXXINCS) $(LCXXINCS) $(GCXXINCS)
192
193 #
194 # Do something for the linker
195 #
196 #
197 # Library paths (-L's) are part of LDOPTS.
198 # Libraries (-l's) are part of LDLIBS.
199 # This is done so that there is a guarantee that all library paths are
200 # included before the libraries.
201 #
202 override GLDOPTS=
203 override GLDDSOOPTS=
204 ifeq ($(OS),IRIX)
205 override GLDOPTS += -L$(ROOT)/usr/lib32
206 override GLDDSOOPTS += -L$(ROOT)/usr/lib32
207 endif
208 ifeq ($(OS),Linux)
209 override GLDOPTS += -L$(ROOT)/usr/lib -L$(XTOPDIR)/xc/exports/lib
210 override GLDDSOOPTS += -L$(ROOT)/usr/lib -L$(XTOPDIR)/xc/exports/lib
211 endif
212
213 # options used for DSO's.
214 ifeq ($(OS),IRIX)
215 DSONAMEOPT = -soname $(DSONAME)
216 ifneq ($(DSOEXPORTS),)
217 DSOEXPORTSOPT = -exports_file $(DSOEXPORTS)
218 endif
219 override GLDDSOOPTS += -elf -shared -all $(DSOEXPORTSOPT) $(DSONAMEOPT)
220 endif
221
222 ifeq ($(OS),Linux)
223 DSONAMEOPT = -soname=$(DSONAME)
224 ifneq ($(DSOEXPORTS),)
225 DSOEXPORTSOPT = $(addprefix -u ,$(shell cat $(DSOEXPORTS)))
226 else
227 DSOEXPORTSOPT = --whole-archive
228 endif
229 override GLDDSOOPTS += -shared $(DSOEXPORTSOPT) $(DSONAMEOPT)
230 endif
231
232 LDDSOOPTS = $(VLDDSOOPTS) $(LLDDSOOPTS) $(GLDDSOOPTS)
233 LDDSOLIBS = $(VLDDSOLIBS) $(LLDDSOLIBS) $(GLDDSOLIBS)
234 LDDSOFLAGS = $(LDDSOOPTS) $(LDDSOLIBS) $(ENDIAN)
235
236 LDOPTS = $(VLDOPTS) $(LLDOPTS) $(GLDOPTS)
237 LDLIBS = $(VLDLIBS) $(LLDLIBS) $(GLDLIBS)
238 LDFLAGS = $(LDOPTS) $(LDLIBS) $(ENDIAN)
239
240 # where to install libraries
241 ifeq ($(OS),IRIX)
242 OBJECT_STYLE = N32
243 LIB_LOCATION = $(ROOT)/usr/lib32
244 endif
245 ifeq ($(OS),Linux)
246 LIB_LOCATION = $(ROOT)/usr/lib
247 endif
248
249 #
250 # as flags are just like cc flags.
251 # By default, ASTYLE is the same as CSTYLE, but some may need to make
252 # the asm more aggressive than 'C' and can set ASTYLE. Users of 'make'
253 # always get ASTYLE == CSTYLE
254 #
255 ASFLAGS = $(VASFLAGS) $(LASFLAGS) $(GASFLAGS)
256
257 VASFLAGS = $(VASDEFS) $(VASINCS) $(VASOPTS)
258 LASFLAGS = $(LASDEFS) $(LASINCS) $(LASOPTS)
259 GASFLAGS = $(GASDEFS) $(GASINCS) $(GASOPTS)
260
261 ASOPTS = $(VASOPTS) $(LASOPTS) $(GASOPTS)
262 ASDEFS = $(VASDEFS) $(LASDEFS) $(GASDEFS)
263 ASINCS = $(VASINCS) $(LASINCS) $(GASINCS)
264
265 override GASOPTS = $(OPTIMIZER) $(MKDEPOPT)
266 override GASDEFS = $(GCDEFS)
267 override GASINCS = $(GCINCS)
268
269 #
270 # the install command to use
271 #
272 INSTALL = $(ROOT)/usr/bin/gfxinstall
273 INSTALLFLAGS = -v -m 0444
274
275 #
276 # Convenient command macros that include the flags macros.
277 #
278 # You should always invoke make in makefiles via $(MAKE), as make passes
279 # all command-line variables through the environment to sub-makes.
280 #
281 # Never use just $(CCF), etc. in rules that link executables; LDFLAGS
282 # needs to be included after your objects in the command line.
283 #
284 ASF = $(AS) $(ASFLAGS)
285 CXXF = $(CXX) $(CXXFLAGS)
286 C++F = $(CXXF)
287 CCF = $(CC) $(CFLAGS)
288 LDF = $(LD) $(LDFLAGS)
289 LEXF = $(LEX) $(LFLAGS)
290 YACCF = $(YACC) $(YFLAGS)
291
292 # Targets
293
294 COMMONTARGS = clobber clean rmtargets
295
296 ALLTARGS = headers headers_install libs libs_install install apps distsi \
297 $(COMMONTARGS)
298
299 #
300 # Rule macros for nonterminal makefiles that iterate over subdirectories,
301 # making the current target. Set *SUBDIRS to the relevant list of kids.
302 #
303 # Set NOSUBMESG to any value to suppress a warning that subdirectories
304 # are not present. This is useful with mandefs/rules
305 #
306 SUBDIR_MAKERULE= \
307 if test ! -d $$d; then \
308 if test "$(NOSUBMESG)" = "" ; then \
309 echo "SKIPPING $$d: No such directory."; \
310 fi \
311 else \
312 $(ECHO) "\t$(MAKE) -C $$d $${RULE:=$@}"; \
313 $(MAKE) -C $$d $${RULE:=$@}; \
314 fi
315
316 SUBDIRS_MAKERULE= \
317 +@for d in $(SUBDIRS); do $(SUBDIR_MAKERULE); done
318
319 #
320 # One problem with the above rules is that if a make fails, and -k is
321 # set, the entire for loop might stop. This is because make still can
322 # (and XPG requires it) exit with an error status if the -k option is set.
323 # This is an alternate rule for SUBDIRS when it is desired that -k keep
324 # working on the next SUBDIR if the previous one failed. Its not quite
325 # as compact a rule as the previous ones.
326 # A standard usage would be:
327 # default install $(COMMONTARGS): $(_FORCE)
328 # $(MAKE) __DORULE=$@ $(SUBDIRS)
329 # $(SUBDIRS): $(_FORCE)
330 # @$(NSUBDIR_MAKERULE)
331
332 NSUBDIR_MAKERULE= \
333 if test ! -d $@; then \
334 if test "$(NOSUBMESG)" = "" ; then \
335 echo "SKIPPING $@: No such directory."; \
336 fi \
337 else \
338 echo "\t(cd $@; $(MAKE) $(__DORULE))"; \
339 (cd $@; ${MAKE} $(__DORULE)); \
340 fi
341
342 #
343 # Convenience file list macros:
344 # - Commondefs defines the following lists: SOURCES, enumerating all
345 # source files; OBJECTS, the .o files derived from compilable source;
346 # and DIRT, which lists intermediates and temporary files to be
347 # removed by clean.
348 # - The including (parent) makefile may define source file lists for
349 # the standard suffixes: CFILES for .c, ASFILES for .s, YFILES for
350 # .y, etc. We combine all such lists into SOURCES. The including
351 # makefile need not define CFILES &c before including commondefs.
352 #
353 SOURCES=$(HFILES) $(ASFILES) $(CCFILES) $(C++FILES) $(CXXFILES) $(CFILES) \
354 $(EFILES) $(FFILES) $(LFILES) $(PFILES) $(RFILES) $(SHFILES) $(YFILES)
355
356 CXXO1=$(CXXFILES:.c++=.o) $(C++FILES:.c++=.o) $(CCFILES:.c++=.o)
357 CXXO2=$(CXXO1:.cxx=.o)
358 CXXO3=$(CXXO2:.C=.o)
359 CXXO4=$(CXXO3:.cc=.o)
360 CXXOALL=$(CXXO4)
361 YO1=$(YFILES:.y=.o)
362 YO2=$(YO1:.yxx=.o)
363 YO3=$(YO2:.Y=.o)
364 YOALL=$(YO3)
365 LO1=$(LFILES:.l=.o)
366 LO2=$(LO1:.lxx=.o)
367 LO3=$(LO2:.L=.o)
368 LOALL=$(LO3)
369 OBJECTS=$(ASFILES:.s=.o) $(CXXOALL) $(CFILES:.c=.o) $(EFILES:.e=.o) \
370 $(FFILES:.f=.o) $(LOALL) $(PFILES:.p=.o) $(RFILES:.r=.o) \
371 $(YOALL)
372
373 #
374 # dependency file(s)
375 #
376 ifeq ($(OS),IRIX)
377 MKDEPFILE = Makedepend
378 endif
379 ifeq ($(OS),Linux)
380 MKDEPFILE = $(OBJECTS:.o=.d)
381 endif
382
383 #
384 # distribution file
385 #
386 DISTFILE_EXT = Distfile
387 DISTFILE_INT = Distfile.int
388 ifeq ($(OS),IRIX)
389 DISTFILE = $(DISTFILE_EXT)
390 else
391 ifeq ($(OS),Linux)
392 DISTFILE = $(DISTFILE_EXT)
393 else
394 DISTFILE = $(DISTFILE_EXT) $(DISTFILE_INT)
395 endif
396 endif
397
398 #
399 # dirt stuff
400 #
401 DIRT=$(GDIRT) $(VDIRT) $(LDIRT)
402 override GDIRT=*.o a.out core lex.yy.[co] y.tab.[cho] ar.tmp.* so_locations
403
404 LOCALDEFS = ./localdefs
405 LOCALRULES = ./localrules
406
407 -include $(LOCALDEFS)