1
# Copyright (c) 1991-2000 Silicon Graphics, Inc.
2
# This document is licensed under the SGI Free Software B license.
5
# http://oss.sgi.com/projects/FreeB
8
# $Header: //depot/main/tools/include/commondefs#43 $
10
COMMONRULES=$(ROOT)/usr/include/make/commonrules
12
# what OS are we running on
14
ifeq ($(subst 64,,$(OS)), IRIX)
17
ifeq (CYGWIN,$(findstring CYGWIN,$(OS)))
21
# various source-level directories
22
TOOLSSRC = $(TOPDIR)/tools
23
GFXINCLUDESRC = $(TOPDIR)/gfx/include
24
OGLLIBSRC = $(TOPDIR)/gfx/lib/opengl
25
GLXLIBSRC = $(TOPDIR)/glx
27
# SGI Free Software B license
28
OSSCOPYRIGHT = $(TOPDIR)/doc/release/OSSCOPYRIGHT
45
# M4 options - run GNU M4 in compatibility mode
46
# rdist options - Red Hat 5.2 must have daemon location specified
52
RDIST_OPTS = -p /usr/sbin/rdistd
55
# override default gmake CXX with what we have
60
# what language are we using? Default to ansi with extended defines
65
CVERSION= -ansi -include $(ROOT)/usr/include/make/linuxdefs
68
# WARN is the warning option
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
82
-woff 1155,1174,1506,1201,1209,3170
94
-Wmissing-prototypes \
95
-Wmissing-declarations \
99
# default optimization
100
ifeq ($(subst y,1,$(GLDEBUG)),1)
105
WARN += -Wuninitialized
109
# how to make dependencies
111
MKDEPOPT = -MDupdate Makedepend
117
override GCOPTS = $(OPTIMIZER) $(MKDEPOPT) $(WARN)
118
override GCXXOPTS = $(OPTIMIZER) $(MKDEPOPT) $(WARN)
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
125
# where to install include files?
126
INCLUDE_LOCATION = $(ROOT)/usr/include
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).
132
override GCINCS = -nostdinc -I$(ROOT)$(INCLDIR) -I$(INCLDIR)
133
override GCXXINCS = -nostdinc -I$(ROOT)$(INCLDIR) -I$(INCLDIR)
136
override GCINCS = -I$(ROOT)$(INCLDIR)
137
override GCXXINCS = -I$(ROOT)$(INCLDIR) -I$(INCLDIR)
141
override GCDEFS = -DDEBUG -UNDEBUG
142
override GCXXDEFS = -DDEBUG -UNDEBUG
144
override GCDEFS = -UDEBUG -DNDEBUG
145
override GCXXDEFS = -UDEBUG -DNDEBUG
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.
156
CFLAGS = $(CVERSION) $(VCFLAGS) $(LCFLAGS) $(GCFLAGS)
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.
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
172
VCFLAGS = $(VCDEFS) $(VCINCS) $(VCOPTS)
173
LCFLAGS = $(LCDEFS) $(LCINCS) $(LCOPTS)
174
GCFLAGS = $(GCDEFS) $(GCINCS) $(GCOPTS)
176
COPTS = $(VCOPTS) $(LCOPTS) $(GCOPTS)
177
CDEFS = $(VCDEFS) $(LCDEFS) $(GCDEFS)
178
CINCS = $(VCINCS) $(LCINCS) $(GCINCS)
181
# CXX flags are decomposed using the same hierarchy as C flags.
183
CXXFLAGS = $(CVERSION) $(VCXXFLAGS) $(LCXXFLAGS) $(GCXXFLAGS)
185
VCXXFLAGS = $(VCXXDEFS) $(VCXXINCS) $(VCXXOPTS)
186
LCXXFLAGS = $(LCXXDEFS) $(LCXXINCS) $(LCXXOPTS)
187
GCXXFLAGS = $(GCXXDEFS) $(GCXXINCS) $(GCXXOPTS)
189
CXXOPTS = $(VCXXOPTS) $(LCXXOPTS) $(GCXXOPTS)
190
CXXDEFS = $(VCXXDEFS) $(LCXXDEFS) $(GCXXDEFS)
191
CXXINCS = $(VCXXINCS) $(LCXXINCS) $(GCXXINCS)
194
# Do something for the linker
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.
205
override GLDOPTS += -L$(ROOT)/usr/lib32
206
override GLDDSOOPTS += -L$(ROOT)/usr/lib32
209
override GLDOPTS += -L$(ROOT)/usr/lib -L$(XTOPDIR)/xc/exports/lib
210
override GLDDSOOPTS += -L$(ROOT)/usr/lib -L$(XTOPDIR)/xc/exports/lib
213
# options used for DSO's.
215
DSONAMEOPT = -soname $(DSONAME)
216
ifneq ($(DSOEXPORTS),)
217
DSOEXPORTSOPT = -exports_file $(DSOEXPORTS)
219
override GLDDSOOPTS += -elf -shared -all $(DSOEXPORTSOPT) $(DSONAMEOPT)
223
DSONAMEOPT = -soname=$(DSONAME)
224
ifneq ($(DSOEXPORTS),)
225
DSOEXPORTSOPT = $(addprefix -u ,$(shell cat $(DSOEXPORTS)))
227
DSOEXPORTSOPT = --whole-archive
229
override GLDDSOOPTS += -shared $(DSOEXPORTSOPT) $(DSONAMEOPT)
232
LDDSOOPTS = $(VLDDSOOPTS) $(LLDDSOOPTS) $(GLDDSOOPTS)
233
LDDSOLIBS = $(VLDDSOLIBS) $(LLDDSOLIBS) $(GLDDSOLIBS)
234
LDDSOFLAGS = $(LDDSOOPTS) $(LDDSOLIBS) $(ENDIAN)
236
LDOPTS = $(VLDOPTS) $(LLDOPTS) $(GLDOPTS)
237
LDLIBS = $(VLDLIBS) $(LLDLIBS) $(GLDLIBS)
238
LDFLAGS = $(LDOPTS) $(LDLIBS) $(ENDIAN)
240
# where to install libraries
243
LIB_LOCATION = $(ROOT)/usr/lib32
246
LIB_LOCATION = $(ROOT)/usr/lib
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
255
ASFLAGS = $(VASFLAGS) $(LASFLAGS) $(GASFLAGS)
257
VASFLAGS = $(VASDEFS) $(VASINCS) $(VASOPTS)
258
LASFLAGS = $(LASDEFS) $(LASINCS) $(LASOPTS)
259
GASFLAGS = $(GASDEFS) $(GASINCS) $(GASOPTS)
261
ASOPTS = $(VASOPTS) $(LASOPTS) $(GASOPTS)
262
ASDEFS = $(VASDEFS) $(LASDEFS) $(GASDEFS)
263
ASINCS = $(VASINCS) $(LASINCS) $(GASINCS)
265
override GASOPTS = $(OPTIMIZER) $(MKDEPOPT)
266
override GASDEFS = $(GCDEFS)
267
override GASINCS = $(GCINCS)
270
# the install command to use
272
INSTALL = $(ROOT)/usr/bin/gfxinstall
273
INSTALLFLAGS = -v -m 0444
276
# Convenient command macros that include the flags macros.
278
# You should always invoke make in makefiles via $(MAKE), as make passes
279
# all command-line variables through the environment to sub-makes.
281
# Never use just $(CCF), etc. in rules that link executables; LDFLAGS
282
# needs to be included after your objects in the command line.
284
ASF = $(AS) $(ASFLAGS)
285
CXXF = $(CXX) $(CXXFLAGS)
287
CCF = $(CC) $(CFLAGS)
288
LDF = $(LD) $(LDFLAGS)
289
LEXF = $(LEX) $(LFLAGS)
290
YACCF = $(YACC) $(YFLAGS)
294
COMMONTARGS = clobber clean rmtargets
296
ALLTARGS = headers headers_install libs libs_install install apps distsi \
300
# Rule macros for nonterminal makefiles that iterate over subdirectories,
301
# making the current target. Set *SUBDIRS to the relevant list of kids.
303
# Set NOSUBMESG to any value to suppress a warning that subdirectories
304
# are not present. This is useful with mandefs/rules
307
if test ! -d $$d; then \
308
if test "$(NOSUBMESG)" = "" ; then \
309
echo "SKIPPING $$d: No such directory."; \
312
$(ECHO) "\t$(MAKE) -C $$d $${RULE:=$@}"; \
313
$(MAKE) -C $$d $${RULE:=$@}; \
317
+@for d in $(SUBDIRS); do $(SUBDIR_MAKERULE); done
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)
333
if test ! -d $@; then \
334
if test "$(NOSUBMESG)" = "" ; then \
335
echo "SKIPPING $@: No such directory."; \
338
echo "\t(cd $@; $(MAKE) $(__DORULE))"; \
339
(cd $@; ${MAKE} $(__DORULE)); \
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
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.
353
SOURCES=$(HFILES) $(ASFILES) $(CCFILES) $(C++FILES) $(CXXFILES) $(CFILES) \
354
$(EFILES) $(FFILES) $(LFILES) $(PFILES) $(RFILES) $(SHFILES) $(YFILES)
356
CXXO1=$(CXXFILES:.c++=.o) $(C++FILES:.c++=.o) $(CCFILES:.c++=.o)
357
CXXO2=$(CXXO1:.cxx=.o)
359
CXXO4=$(CXXO3:.cc=.o)
369
OBJECTS=$(ASFILES:.s=.o) $(CXXOALL) $(CFILES:.c=.o) $(EFILES:.e=.o) \
370
$(FFILES:.f=.o) $(LOALL) $(PFILES:.p=.o) $(RFILES:.r=.o) \
377
MKDEPFILE = Makedepend
380
MKDEPFILE = $(OBJECTS:.o=.d)
386
DISTFILE_EXT = Distfile
387
DISTFILE_INT = Distfile.int
389
DISTFILE = $(DISTFILE_EXT)
392
DISTFILE = $(DISTFILE_EXT)
394
DISTFILE = $(DISTFILE_EXT) $(DISTFILE_INT)
401
DIRT=$(GDIRT) $(VDIRT) $(LDIRT)
402
override GDIRT=*.o a.out core lex.yy.[co] y.tab.[cho] ar.tmp.* so_locations
404
LOCALDEFS = ./localdefs
405
LOCALRULES = ./localrules
407
-include $(LOCALDEFS)