# # # # Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. # # This program is free software; you can redistribute it and/or modify it # under the terms of version 2 of the GNU General Public License as # published by the Free Software Foundation. # # This program is distributed in the hope that it would be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # Further, this software is distributed without any warranty that it is # free of the rightful claim of any third person regarding infringement # or the like. Any license provided herein, whether implied or # otherwise, applies only to this software file. Patent licenses, if # any, provided herein do not apply to combinations of this program with # other software, or any other product whatsoever. # # You should have received a copy of the GNU General Public License along # with this program; if not, write the Free Software Foundation, Inc., 59 # Temple Place - Suite 330, Boston MA 02111-1307, USA. # # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, # Mountain View, CA 94043, or: # # http://www.sgi.com # # For further information regarding this notice, see: # # http://oss.sgi.com/projects/GenInfo/NoticeExplan # # #ident "$Revision: 1.4 $" # # This file has been heavily hacked for building on Linux # # Common makefile definitions. # # Notes: # - Definitions with the same names only need to be passed on the # command line of recursive makes if they would be redefined by # the sub-makefile. Definitions passed on the command line are # not reset by the environment or the definitions in the makefile. # - C++ style macros are deprecated and will be removed when out of use. # They must be interwoven in definitions to keep upward compatibility. # # - The contents of this header are changed based on some variables # should be defined BEFORE including this file: # OBJECT_STYLE - define basic ABI/ISA that should be used to create product. # this also sets LD search paths, C/C++/Fortran/Pascal options. # NO_OBJECT_STYLE - disable all this new OBJECT_STYLE business. # Note that if one does this all the info in releasedefs about # compiler versions, default compilation modes etc will be ignored. # Only smake-files can do this. # NO_LSRCH - do not set any library searching rules for LD options. # ASTYLE - by default, the ABI/ISA for C is used for assembler - # setting ASTYLE (to be assembler options) can override the OBJECT_STYLE # to permit fine-tuning of asm code. # NO_STARTOPT - don't set any of the DSO start option macros - this # will keep the global so_locations files from being updated. # COMMONRULES= $(BUILD_TOT)/linux/make/gcommonrules COMMONTARGS= clobber clean rmtargets fluff tags # # Make tools, i.e., programs which must exist on both native and cross # development systems to build the software. # AR = ar ifeq ($(BUILD_ABI), I64BIT) ifeq ($(BUILD_HOST), IA32) AR = ia64-sgi-linux-ar endif endif AWK = awk SIZEDEFS = -D_LONGLONG -D_MIPS_SZINT=32 ifeq ($(BUILD_ABI), I64BIT) #ifeq ($(BUILD_ABI), A64BIT) SIZEDEFS += -D_MIPS_SZPTR=64 -D_MIPS_SZLONG=64 -D_LP64 else ifeq ($(BUILD_ABI), A64BIT) SIZEDEFS += -D_MIPS_SZPTR=64 -D_MIPS_SZLONG=64 -D_LP64 else SIZEDEFS += -D_MIPS_SZPTR=32 -D_MIPS_SZLONG=32 endif #endif endif ifeq ($(BUILD_OS), LINUX) ifeq ($(BUILD_OS), TRU64) ENDIAN = -D_MIPSEL else ENDIAN = -D_MIPSEB endif endif ifeq ($(BUILD_COMPILER), GNU) ASNAME = gcc CCNAME = gcc C++NAME = g++ F77 = g77 # Some machines don't have g77 installation F90 = g77 # GNU f90 is not available yet endif ifeq ($(BUILD_COMPILER), SGI) # sgi compiler should be in path in order to be found ASNAME = sgicc CCNAME = sgicc C++NAME = sgiCC F77 = sgif90 F90 = sgif90 endif ifeq ($(BUILD_COMPILER), VENDOR) CCNAME = cc ifeq ($(BUILD_OS), TRU64) CCNAME = gcc C++NAME = g++ ASNAME = g++ else ASNAME = cc C++NAME = CC endif F77 = f77 F90 = f90 endif #AS = $(ASNAME) -D_SGI_SOURCE #C++ = $(C++NAME) -D_SGI_SOURCE -D_LANGUAGE_C_PLUS_PLUS #CC = $(CCNAME) -D_SGI_SOURCE -D_LANGUAGE_C AS_DEFAULT_FLAGS = -D_SGI_SOURCE C++_DEFAULT_FLAGS = -D_SGI_SOURCE -D_LANGUAGE_C_PLUS_PLUS CC_DEFAULT_FLAGS = -D_SGI_SOURCE -D_LANGUAGE_C ifeq ($(BUILD_COMPILER), GNU) AS_DEFAULT_FLAGS += -funsigned-char -D__GNU_BUG_WORKAROUND CC_DEFAULT_FLAGS += -Wformat -funsigned-char -D__GNU_BUG_WORKAROUND C++_DEFAULT_FLAGS += -Wformat -funsigned-char -D__GNU_BUG_WORKAROUND -D_NOTHREADS endif ifdef CC override CC += $(CC_DEFAULT_FLAGS) else CC = $(CCNAME) $(CC_DEFAULT_FLAGS) endif ifdef CXX override CXX += $(C++_DEFAULT_FLAGS) else CXX = $(C++NAME) $(C++_DEFAULT_FLAGS) endif #C++C = $(CXX) ECHO = echo FC = $(F77) LEX = flex LD = ld ifeq ($(BUILD_ABI), I64BIT) ifeq ($(BUILD_HOST), IA32) LD = ia64-sgi-linux-ld endif endif LINT = glint NM = nm SHELL = sh SIZE = size STRIP = strip # TLINK = lndir YACC = yacc AWK = awk ECHO = echo M4 = m4 # # The native C compiler, which must be used when building programs that are # run on the build host from a makefile. # HOST_CC = gcc -funsigned-char -D_SGI_SOURCE -D__GNU_BUG_WORKAROUND -D_LONGLONG -D_MIPS_SZPTR=32 -D_MIPS_SZINT=32 -D_MIPS_SZLONG=32 -D_LANGUAGE_C HOST_C++ = g++ -funsigned-char -D_SGI_SOURCE -D__GNU_BUG_WORKAROUND -D_NOTHREADS -D_LONGLONG -D_MIPS_SZPTR=32 -D_MIPS_SZINT=32 -D_MIPS_SZLONG=32 -D_LANGUAGE_C_PLUS_PLUS HOST_CXX = $(HOST_C++) ifeq ($(BUILD_COMPILER), VENDOR) ifeq ($(BUILD_OS), IRIX) ifeq ($(BUILD_OS), SOLARIS) WOFF= -fullwarn endif endif else WOFF= -Wimplicit-function-declaration endif # # Default C version, optimizer, common global options, and make-depend options. # CVERSION = ifndef OPTIMIZER OPTIMIZER = -O endif ifeq ($(BUILD_COMPILER), VENDOR) MKDEPOPT = else MKDEPOPT = endif COMMONGOPTS=$(OPTIMIZER) $(MKDEPOPT) $(ENDIAN) CSTYLE= GCOPTS = $(CSTYLE) $(OPTIMIZER) $(ENDIAN) $(SIZEDEFS) $(MKDEPOPT) $(WOFF) GCDEFS = # # Cc flags, composed of: # variable (V*) (set on the command line), # local (L*) (defined in the makefile), # global (defined in this file), # parts, in that order. This ordering has been used so that the variable or # locally specified include directories are searched before the globally # specified ones. # CFLAGS += $(CVERSION) $(VCFLAGS) $(LCFLAGS) $(GCFLAGS) # # Each of these three components is divided into defines (-D's and -U's), # includes (-I's), and other options. By segregating the different # classes of flag to cc, the defines (CDEFS) and includes (CINCS) can be # easily given to other programs, e.g., lint. # # Notes: # - The local assignments should be to LCOPTS, LCDEFS, and LCINCS, not to # LCFLAGS, although CFLAGS will be correctly set if this is done. # - If a program cannot be optimized, it should override the setting of # OPTIMIZER with a line such as "OPTIMIZER=" in its make file. # - If a program cannot be compiled with ANSI C, its makefile # should set CVERSION=-cckr # VCFLAGS = $(VCDEFS) $(VCINCS) $(VCOPTS) LCFLAGS = $(LCDEFS) $(LCINCS) $(LCOPTS) GCFLAGS = $(GCDEFS) $(GCINCS) $(GCOPTS) COPTS = $(VCOPTS) $(LCOPTS) $(GCOPTS) CDEFS = $(VCDEFS) $(LCDEFS) $(GCDEFS) CINCS = $(VCINCS) $(LCINCS) $(GCINCS) # # CXX flags are decomposed using the same hierarchy as C flags. # C++FLAGS += $(CVERSION) $(VCXXFLAGS) $(LCXXFLAGS) $(GCXXFLAGS) CXXFLAGS += $(C++FLAGS) GC++OPTS = $(CSTYLE) $(OPTIMIZER) $(CXX_OPTIMIZER) $(ENDIAN) $(SIZEDEFS) \ $(MKDEPOPT) GC++DEFS = VCXXFLAGS = $(VCXXDEFS) $(VCXXINCS) $(VCXXOPTS) $(VC++FLAGS) LCXXFLAGS = $(LCXXDEFS) $(LCXXINCS) $(LCXXOPTS) $(LC++FLAGS) GCXXFLAGS = $(GC++FLAGS) CXXOPTS = $(VCXXOPTS) $(LCXXOPTS) $(GCXXOPTS) $(C++OPTS) CXXDEFS = $(VCXXDEFS) $(LCXXDEFS) $(GCXXDEFS) $(C++DEFS) CXXINCS = $(VCXXINCS) $(LCXXINCS) $(GCXXINCS) $(C++INCS) VC++FLAGS = $(VC++DEFS) $(VC++INCS) $(VC++OPTS) LC++FLAGS = $(LC++DEFS) $(LC++INCS) $(LC++OPTS) GC++FLAGS = $(GC++DEFS) $(GC++INCS) $(GC++OPTS) C++OPTS = $(VC++OPTS) $(LC++OPTS) $(GC++OPTS) C++DEFS = $(VC++DEFS) $(LC++DEFS) $(GC++DEFS) C++INCS = $(VC++INCS) $(LC++INCS) $(GC++INCS) # # Loader flags, composed of library (-l's) and option parts, with # the libraries appearing last. Both of these are divided into variable, # local, and global parts. The composition of LDFLAGS is done in the # other "direction" from CFLAGS so that all the -L's, which are part of # LDOPTS, appear before any of the -l's, which are part of LDLIBS. # Another benefit of segregating the libraries from the remaining of the # loader options is that the libraries alone can easily be given to # another program, e.g., lint. # # Notes: # - -s belongs in GCOPTS or in the IDB program that does the actual # installation. # #if !defined(NO_LSRCH) LSRCH_N32_M3 = -L$(ROOT)/usr/lib32/mips3 -L$(ROOT)/usr/lib32 LSRCH_N32_M4 = -L$(ROOT)/usr/lib32/mips4 -L$(ROOT)/usr/lib32 LSRCH_64_M3 = -L$(ROOT)/usr/lib64/mips3 -L$(ROOT)/usr/lib64 LSRCH_64_M4 = -L$(ROOT)/usr/lib64/mips4 -L$(ROOT)/usr/lib64 #endif GLDOPTS= GLDLIBS= GLDOPTS_I32 = GLDOPTS_I64 = GLDOPTS_N32_M3= -mips3 -n32 $(LD_QUICKSTART_INFO) -nostdlib $(LSRCH_N32_M3) GLDOPTS_N32_M4= -mips4 -n32 $(LD_QUICKSTART_INFO) -nostdlib $(LSRCH_N32_M4) GLDOPTS_R32 = -r32 $(LD_QUICKSTART_INFO) -nostdlib $(LSRCH_R32) GLDOPTS_64_M3 = -mips3 -64 $(LD_QUICKSTART_INFO) -nostdlib $(LSRCH_64_M3) GLDOPTS_64_M4 = -mips4 -64 $(LD_QUICKSTART_INFO) -nostdlib $(LSRCH_64_M4) # # LDFLAG layout # LDFLAGS = $(LDOPTS) $(LDLIBS) $(ENDIAN) LDOPTS = $(VLDOPTS) $(LLDOPTS) $(GLDOPTS) LDLIBS = $(VLDLIBS) $(LLDLIBS) $(GLDLIBS) LDOPTS_I32 =$(VLDOPTS) $(LLDOPTS) $(LLDOPTS_I32) $(GLDOPTS_I32) LDOPTS_I64 =$(VLDOPTS) $(LLDOPTS) $(LLDOPTS_I64) $(GLDOPTS_I64) LDOPTS_N32 =$(VLDOPTS) $(LLDOPTS) $(LLDOPTS_N32_M3) $(GLDOPTS_N32) LDOPTS_N32_M3=$(VLDOPTS) $(LLDOPTS) $(LLDOPTS_N32_M3) $(GLDOPTS_N32_M3) LDOPTS_N32_M4=$(VLDOPTS) $(LLDOPTS) $(LLDOPTS_N32_M4) $(GLDOPTS_N32_M4) LDOPTS_64 =$(VLDOPTS) $(LLDOPTS) $(LLDOPTS_64_M3) $(GLDOPTS_64) LDOPTS_64_M3 =$(VLDOPTS) $(LLDOPTS) $(LLDOPTS_64_M3) $(GLDOPTS_64_M3) LDOPTS_64_M4 =$(VLDOPTS) $(LLDOPTS) $(LLDOPTS_64_M4) $(GLDOPTS_64_M4) # # Loader options for making shared objects. By default, shared objects # are all registered in a global location file. # Redefine $(DSOSTARTOPT) to not update the registry file # # By default the DT_SONAME section is set to the name of the target shared # object. Redefine $(DSONAMEOPT) to allow the DT_SONAME section to be # something other than the targeted shared object name. # # DSOs are typically all made in one top level makefile, in place, rather # than in subdirectories - therefore all the various flags must be # present with no conditionals # # # To build a DSO that doesn't use lib*rules: # # $(LD) $(LDDSOOPTS) $(LDOPTS) $(OBJECTS) $(LDLIBS) -o $@ # # Note that LDOPTS must be before the OBJECTS and LDLIBS must be after. # For local .so's make it easy to not update any registry files # # # Note: To turn off -no_unresolved for a specific library Makefile, add: # LD_NO_UNRESOLVED= LD_NO_UNRESOLVED=-no_unresolved # Note: To turn off -quickstart_info for specific Makefile add: # LD_QUICKSTART_INFO= LD_QUICKSTART_INFO=-quickstart_info ifeq ($(BUILD_OS), IRIX) CXXFLAGS += -LANG:std DSONAMEOPT = -soname $@ else DSONAMEOPT = endif # # SGI specific versioning. Redefine $(DSOVERSION) to change version number. # Redefine $(DSOVERSIONOPT) to skip versioning. # DSOVERSION = sgi1.0 DSOVERSIONOPT = -set_version $(DSOVERSION) LDDSOOPTS= $(VLDDSOOPTS) $(LLDDSOOPTS) $(GLDDSOOPTS) LDDSOOPTS_I32= $(LDDSOOPTS) LDDSOOPTS_I64= $(LDDSOOPTS) LDDSOOPTS_N32= $(LDDSOOPTS) $(GLDDSOOPTS_N32) LDDSOOPTS_632= $(LDDSOOPTS) $(GLDDSOOPTS_64) GLDDSOOPTS = -elf -shared ifeq ($(BUILD_OS), IRIX) GLDDSOOPTS += -all endif ifeq ($(BUILD_COMPILER), VENDOR) GLDDSOOPTS += $(MKDEPOPT) $(DSONAMEOPT) else GLDDSOOPTS += $(DSONAMEOPT) endif GLDDSOOPTS_N32 = $(LD_NO_UNRESOLVED) $(LD_QUICKSTART_INFO) \ $(DSOSTARTOPT_N32) $(DSOVERSIONOPT) GLDDSOOPTS_64 = $(LD_NO_UNRESOLVED) $(LD_QUICKSTART_INFO) \ $(DSOSTARTOPT_64) $(DSOVERSIONOPT) # # F77 flags are just like cc flags. # FFLAGS= $(VFFLAGS) $(LFFLAGS) $(GFFLAGS) VFFLAGS = $(VF77DEFS) $(VF77INCS) $(VF77OPTS) LFFLAGS = $(LF77DEFS) $(LF77INCS) $(LF77OPTS) GFFLAGS = $(GF77DEFS) $(GF77INCS) $(GF77OPTS) F77OPTS = $(VF77OPTS) $(LF77OPTS) $(GF77OPTS) F77DEFS = $(VF77DEFS) $(LF77DEFS) $(GF77DEFS) F77INCS = $(VF77INCS) $(LF77INCS) $(GF77INCS) GF77OPTS= $(CSTYLE) $(OPTIMIZER) $(ENDIAN) $(SIZEDEFS) $(MKDEPOPT) GF77DEFS= $(GCDEFS) GF77INCS= $(GCINCS) # # as flags are just like cc flags. # By default, ASTYLE is the same as CSTYLE, but some may need to make # the asm more aggressive than 'C' and can set ASTYLE. Users of 'make' # always get ASTYLE == CSTYLE # ifndef ASTYLE ASTYLE=$(CSTYLE) endif ASFLAGS = $(VASFLAGS) $(LASFLAGS) $(GASFLAGS) VASFLAGS = $(VASDEFS) $(VASINCS) $(VASOPTS) LASFLAGS = $(LASDEFS) $(LASINCS) $(LASOPTS) GASFLAGS = $(GASDEFS) $(GASINCS) $(GASOPTS) ASOPTS = $(VASOPTS) $(LASOPTS) $(GASOPTS) ASDEFS = $(VASDEFS) $(LASDEFS) $(GASDEFS) ASINCS = $(VASINCS) $(LASINCS) $(GASINCS) GASOPTS = $(ASTYLE) $(OPTIMIZER) $(ENDIAN) $(SIZEDEFS) $(MKDEPOPT) GASDEFS = $(GCDEFS) GASINCS = $(GCINCS) # # The install command to use. # INSTALL = install # # MKDEPFILE is the name of the dependency database, included by commonrules. # MKDEPFILE = .d_* # # Flags to handle yacc and lex automatic dependency generation # YACCMKDEPFLAGS= LEXMKDEPFLAGS= # # Convenient command macros that include the flags macros. # # You should always invoke make in makefiles via $(MAKE), as make passes # all command-line variables through the environment to sub-makes. # # Never use just $(CCF), etc. in rules that link executables; LDFLAGS # needs to be included after your objects in the command line. # ASF = $(AS) $(ASFLAGS) C++F = $(CXX) $(CXXFLAGS) CXXF = $(C++F) CCF = $(CC) $(CFLAGS) F77F = $(F77) $(FFLAGS) F90F = $(F90) $(FFLAGS) LDF = $(LD) $(LDFLAGS) LEXF = $(LEX) $(LFLAGS) YACCF = $(YACC) $(YFLAGS) # # Rule macros for nonterminal makefiles that iterate over subdirectories, # making the current target. Set *SUBDIRS to the relevant list of kids. # # Set NOSUBMESG to any value to suppress a warning that subdirectories # are not present. This is useful with mandefs/rules # SUBDIR_MAKERULE= \ if test ! -d $$d; then \ if test "$(NOSUBMESG)" = "" ; then \ echo "SKIPPING $$d: No such directory."; \ fi \ else \ echo " (cd $$d; $(MAKE) $${RULE:=$@})"; \ (cd $$d; ${MAKE} $${RULE:=$@}); \ fi SUBDIRS_MAKERULE= \ @for d in $(SUBDIRS); do $(SUBDIR_MAKERULE); done HEADERS_SUBDIRS_MAKERULE= \ @for d in $(HEADERS_SUBDIRS); do $(SUBDIR_MAKERULE); done EXPORTS_SUBDIRS_MAKERULE= \ @for d in $(EXPORTS_SUBDIRS); do $(SUBDIR_MAKERULE); done # # Override the system.mk rule for assembly files. # .s.o : $(AS) $(ASFLAGS) -c $< # # Library .c.o rule macros -- someday, cc -r will do the right thing and # the G-number will be happily forgotten. # LIBRARY_AS_MAKERULE= \ $(ASF) -c $< LIBRARY_CC_MAKERULE= \ $(CCF) -c $< LIBRARY_CXX_MAKERULE= \ $(CXXF) -c $< LIBRARY_C++_MAKERULE= \ $(C++F) -c $< # # The macro naming commonrules' always-unsatisfied target, which is useful # in directory dependencies to guarantee that even directories having future # mtimes due to timewarps will be "made". # _FORCE=$(COMMONPREF)_force # # Permit dependencies for Null-suffix targets # .MAKEOPTS: -N # # Convenience file list macros: # - Commondefs defines the following lists: SOURCES, enumerating all # source files; OBJECTS, the .o files derived from compilable source; # and DIRT, which lists intermediates and temporary files to be # removed by clean. # - The including (parent) makefile may define source file lists for # the standard suffixes: CFILES for .c, ASFILES for .s, YFILES for # .y, etc. We combine all such lists into SOURCES. The including # makefile need not define CFILES &c before including commondefs. # # CXXFILES=$(C++FILES) SOURCES=$(HFILES) $(ASFILES) $(CXXFILES) $(CFILES) $(EFILES) $(FFILES) \ $(LFILES) $(PFILES) $(RFILES) $(SHFILES) $(YFILES) CXXO1=$(CXXFILES:.c++=.o) CXXO2=$(CXXO1:.cxx=.o) CXXO3=$(CXXO2:.C=.o) CXXOALL=$(CXXO3) YO1=$(YFILES:.y=.o) YO2=$(YO1:.yxx=.o) YO3=$(YO2:.Y=.o) YOALL=$(YO3) LO1=$(LFILES:.l=.o) LO2=$(LO1:.lxx=.o) LO3=$(LO2:.L=.o) LOALL=$(LO3) OBJECTS=$(ASFILES:.s=.o) $(CXXOALL) $(CFILES:.c=.o) $(EFILES:.e=.o) \ $(FFILES:.f=.o) $(LOALL) $(PFILES:.p=.o) $(RFILES:.r=.o) \ $(YOALL) # # Makefiles should set LDIRT only # # Make include files that extend commondefs should set XDIRT for dirt # generated by the extension. It should also provide an XfooDIRT macro for # the benefit of any extensions to itself. The intent is that the user's # Makefile will just worry about its own dirt. # DIRT=$(GDIRT) $(VDIRT) $(LDIRT) $(XDIRT) GDIRT=*.[doue] a.out core lex.yy.[co] y.tab.[cho] $(_FORCE) ar.tmp.* # # This exitop should be used by those who are building the FTR database. # The reason for this is that inst will sort a 'sort -u' on the exitops, # so if all of them are identical, we only do the work once. # A typical install line that uses the FTR_EXITOP_IDB should look similar # to this: # # $(INSTALL) $(FTR_EXITOP_IDB) -idb $(IDB_TAG) -m 444 -F $(FTRDIR) sgidemos.ftr# # IDB_TAG - is defined in the spec file for a given subsystem. # FTRDIR - is the directory usr/lib/filetype/{install,system,default} # sgidemos.ftr - is the ftr file that goes into FTRDIR. # FTR_EXITOP_IDB= -idb 'exitop( " \ if [ -r \$$rbase/usr/lib/filetype/Makefile ]; then \ chroot $$rbase /bin/sh -c \"cd usr/lib/filetype; make > /dev/null\"; \ fi" )' # # Local definitions. These are used for debugging purposes. Make sure that # the product builds properly without the local definitions, unless you check # in the local definitions! # # To access a localdefs file outside the current directory, set LOCALDEFS on # the command line, and likewise for localrules. Or you can have localdefs # just sinclude the appropriate other include file. # LOCALDEFS = ./localdefs LOCALRULES = ./localrules -include $(LOCALDEFS) # This variable selects between a developer build and a release build. # A release will remove all objects and dependency files after building # the components. A developer release will leave objects and dependency # file intact. ifeq ($(Open64BuildType), ) Open64BuildType=Open64BuildDevelopment endif