blob: 43e7fe0c4d0b23fe693cd2082b4ab7113aeb60b8 [file] [log] [blame]
jat@google.com134be542009-08-03 15:30:11 +00001# Copyright 2009 Google Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15# This Makefile fragment sets the following make variables according to the
16# current platform:
17# ARCH - the Mozilla architecture name, such as x86, x86_64, ppc, etc
18# FLAG32BIT - 32 or 64
19# MARCH - the Mac architecture, such as i386 or ppc
20# OS - linux, mac, or sun
21# CFLAGS - appropriate C compiler flags for this platform
22# CXXFLAGS - appropriate C++ compiler flags for this platform
23# Also, various stanard make variables are overridden if necessary, such as AR
24#
25# If ARCH is already set, that is used instead of uname -m to get the
26# architecture to build. This can be used to build a 32-bit plugin on a 64-bit
27# platform, for example: make ARCH=x86
28
29ARCH ?= $(shell uname -m)
30
31# default is 32 bits
32FLAG32BIT=32
33
34# Figure out 64-bit platforms, canonicalize ARCH and MARCH
35ifeq ($(ARCH),x86_64)
36FLAG32BIT=64
jat@google.coma0d0bed2009-08-18 22:58:15 +000037endif
38ifeq ($(ARCH),sparc)
jat@google.com134be542009-08-03 15:30:11 +000039FLAG32BIT=64
jat@google.coma0d0bed2009-08-18 22:58:15 +000040endif
41ifeq ($(ARCH),alpha)
jat@google.com134be542009-08-03 15:30:11 +000042FLAG32BIT=64
jat@google.coma0d0bed2009-08-18 22:58:15 +000043endif
44ifeq ($(ARCH),ia64)
jat@google.com134be542009-08-03 15:30:11 +000045FLAG32BIT=64
jat@google.coma0d0bed2009-08-18 22:58:15 +000046endif
47ifeq ($(ARCH),athlon)
jat@google.com134be542009-08-03 15:30:11 +000048ARCH=x86
jat@google.coma0d0bed2009-08-18 22:58:15 +000049endif
50ifeq ($(ARCH),i386)
jat@google.com134be542009-08-03 15:30:11 +000051ARCH=x86
jat@google.coma0d0bed2009-08-18 22:58:15 +000052endif
53ifeq ($(ARCH),i486)
jat@google.com134be542009-08-03 15:30:11 +000054ARCH=x86
jat@google.coma0d0bed2009-08-18 22:58:15 +000055endif
56ifeq ($(ARCH),i586)
jat@google.com134be542009-08-03 15:30:11 +000057ARCH=x86
jat@google.coma0d0bed2009-08-18 22:58:15 +000058endif
59ifeq ($(ARCH),i686)
jat@google.com134be542009-08-03 15:30:11 +000060ARCH=x86
jat@google.coma0d0bed2009-08-18 22:58:15 +000061endif
62ifeq ($(ARCH),i86pc)
jat@google.com134be542009-08-03 15:30:11 +000063ARCH=x86
jat@google.coma0d0bed2009-08-18 22:58:15 +000064endif
65ifeq ($(ARCH),Macintosh)
jat@google.com134be542009-08-03 15:30:11 +000066ARCH=ppc
67endif
jat@google.coma0d0bed2009-08-18 22:58:15 +000068
jat@google.com134be542009-08-03 15:30:11 +000069MARCH=$(ARCH)
70ifeq ($(ARCH),x86)
71MARCH=i386
72endif
73
conroy@google.com7927b9d2011-06-24 15:39:48 +000074# Default to Debug off
75DEBUG ?=
codefu@google.com977045b2011-05-31 17:15:12 +000076ifeq ($(DEBUG),TRUE)
77DEBUGCFLAGS= -g
78else
conroy@google.com7927b9d2011-06-24 15:39:48 +000079DEBUGCFLAGS=
codefu@google.com977045b2011-05-31 17:15:12 +000080endif
81
jat@google.com134be542009-08-03 15:30:11 +000082# Set OS as well as CFLAGS, CXX, and other common make variables
83ifeq ($(shell uname),Linux)
84OS=linux
codefu@google.com977045b2011-05-31 17:15:12 +000085BASECFLAGS= $(DEBUGCFLAGS) -O2 -fPIC $(INC) -rdynamic
86ARCHCFLAGS= -m$(FLAG32BIT)
87ALLARCHCFLAGS= -m$(FLAG32BIT)
jat@google.coma0d0bed2009-08-18 22:58:15 +000088endif
89ifeq ($(shell uname),Darwin)
jat@google.com134be542009-08-03 15:30:11 +000090OS=mac
codefu@google.com977045b2011-05-31 17:15:12 +000091BASECFLAGS= $(DEBUGCFLAGS) -O2 -fPIC $(INC) -D__mac -mmacosx-version-min=10.5
jat@google.com23181962009-09-03 22:22:56 +000092ARCHCFLAGS=-arch $(MARCH)
conroy@google.come3153e52011-01-24 12:30:43 +000093ALLARCHCFLAGS=-arch i386 -arch ppc -arch x86_64
jat@google.com134be542009-08-03 15:30:11 +000094AR=libtool
95ARFLAGS=-static -o
jat@google.coma0d0bed2009-08-18 22:58:15 +000096endif
97ifeq ($(shell uname),SunOS)
jat@google.com134be542009-08-03 15:30:11 +000098OS=sun
codefu@google.com977045b2011-05-31 17:15:12 +000099ifeq ($(DEBUG),TRUE)
100DEBUGCFLAGS= -g0
101endif
jat@google.com134be542009-08-03 15:30:11 +0000102#CFLAGS=-fast -g0 -Kpic $(INC) -Bdynamic -noex
103# SunC appears to miscompile Socket::writeByte by not incrementing the
104# buffer pointer, so no optimization for now
105#CFLAGS=-g -Kpic $(INC) -Bdynamic -noex
codefu@google.com977045b2011-05-31 17:15:12 +0000106BASECFLAGS= $(DEBUGCFLAGS) -Kpic -noex -xO1 -xlibmil -xlibmopt -features=tmplife -xbuiltin=%all -mt $(INC)
jat@google.com23181962009-09-03 22:22:56 +0000107ARCHCFLAGS=
108ALLARCHCFLAGS=
jat@google.com134be542009-08-03 15:30:11 +0000109CXX= CC
110endif
jat@google.com23181962009-09-03 22:22:56 +0000111CFLAGS=$(BASECFLAGS) $(ARCHCFLAGS)
112CXXFLAGS = $(CFLAGS)