blob: f07dfd511e717f4655d6a833fd7e29906381fb4c [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
jat@google.com23181962009-09-03 22:22:56 +000072OMARCH=ppc
73endif
74ifeq ($(ARCH),ppc)
75OMARCH=i386
jat@google.com134be542009-08-03 15:30:11 +000076endif
77
78# Set OS as well as CFLAGS, CXX, and other common make variables
79ifeq ($(shell uname),Linux)
80OS=linux
jat@google.com23181962009-09-03 22:22:56 +000081BASECFLAGS= -g -O2 -fPIC $(INC) -rdynamic
82ARCHCFLAGS=-m$(FLAG32BIT)
83ALLARCHCFLAGS=$(ARCHCFLAGS)
jat@google.coma0d0bed2009-08-18 22:58:15 +000084endif
85ifeq ($(shell uname),Darwin)
jat@google.com134be542009-08-03 15:30:11 +000086OS=mac
jat@google.com23181962009-09-03 22:22:56 +000087BASECFLAGS= -g -O2 -fPIC $(INC) -D__mac
88ARCHCFLAGS=-arch $(MARCH)
89ALLARCHCFLAGS=-arch i386 -arch ppc
jat@google.com134be542009-08-03 15:30:11 +000090AR=libtool
91ARFLAGS=-static -o
jat@google.coma0d0bed2009-08-18 22:58:15 +000092endif
93ifeq ($(shell uname),SunOS)
jat@google.com134be542009-08-03 15:30:11 +000094OS=sun
95#CFLAGS=-fast -g0 -Kpic $(INC) -Bdynamic -noex
96# SunC appears to miscompile Socket::writeByte by not incrementing the
97# buffer pointer, so no optimization for now
98#CFLAGS=-g -Kpic $(INC) -Bdynamic -noex
jat@google.com23181962009-09-03 22:22:56 +000099BASECFLAGS= -g0 -Kpic -noex -xO1 -xlibmil -xlibmopt -features=tmplife -xbuiltin=%all -mt $(INC)
100ARCHCFLAGS=
101ALLARCHCFLAGS=
jat@google.com134be542009-08-03 15:30:11 +0000102CXX= CC
103endif
jat@google.com23181962009-09-03 22:22:56 +0000104CFLAGS=$(BASECFLAGS) $(ARCHCFLAGS)
105CXXFLAGS = $(CFLAGS)