jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 1 | # 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 | |
| 29 | ARCH ?= $(shell uname -m) |
| 30 | |
| 31 | # default is 32 bits |
| 32 | FLAG32BIT=32 |
| 33 | |
| 34 | # Figure out 64-bit platforms, canonicalize ARCH and MARCH |
| 35 | ifeq ($(ARCH),x86_64) |
| 36 | FLAG32BIT=64 |
jat@google.com | a0d0bed | 2009-08-18 22:58:15 +0000 | [diff] [blame] | 37 | endif |
| 38 | ifeq ($(ARCH),sparc) |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 39 | FLAG32BIT=64 |
jat@google.com | a0d0bed | 2009-08-18 22:58:15 +0000 | [diff] [blame] | 40 | endif |
| 41 | ifeq ($(ARCH),alpha) |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 42 | FLAG32BIT=64 |
jat@google.com | a0d0bed | 2009-08-18 22:58:15 +0000 | [diff] [blame] | 43 | endif |
| 44 | ifeq ($(ARCH),ia64) |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 45 | FLAG32BIT=64 |
jat@google.com | a0d0bed | 2009-08-18 22:58:15 +0000 | [diff] [blame] | 46 | endif |
| 47 | ifeq ($(ARCH),athlon) |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 48 | ARCH=x86 |
jat@google.com | a0d0bed | 2009-08-18 22:58:15 +0000 | [diff] [blame] | 49 | endif |
| 50 | ifeq ($(ARCH),i386) |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 51 | ARCH=x86 |
jat@google.com | a0d0bed | 2009-08-18 22:58:15 +0000 | [diff] [blame] | 52 | endif |
| 53 | ifeq ($(ARCH),i486) |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 54 | ARCH=x86 |
jat@google.com | a0d0bed | 2009-08-18 22:58:15 +0000 | [diff] [blame] | 55 | endif |
| 56 | ifeq ($(ARCH),i586) |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 57 | ARCH=x86 |
jat@google.com | a0d0bed | 2009-08-18 22:58:15 +0000 | [diff] [blame] | 58 | endif |
| 59 | ifeq ($(ARCH),i686) |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 60 | ARCH=x86 |
jat@google.com | a0d0bed | 2009-08-18 22:58:15 +0000 | [diff] [blame] | 61 | endif |
| 62 | ifeq ($(ARCH),i86pc) |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 63 | ARCH=x86 |
jat@google.com | a0d0bed | 2009-08-18 22:58:15 +0000 | [diff] [blame] | 64 | endif |
| 65 | ifeq ($(ARCH),Macintosh) |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 66 | ARCH=ppc |
| 67 | endif |
jat@google.com | a0d0bed | 2009-08-18 22:58:15 +0000 | [diff] [blame] | 68 | |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 69 | MARCH=$(ARCH) |
| 70 | ifeq ($(ARCH),x86) |
| 71 | MARCH=i386 |
| 72 | endif |
| 73 | |
conroy@google.com | 7927b9d | 2011-06-24 15:39:48 +0000 | [diff] [blame] | 74 | # Default to Debug off |
| 75 | DEBUG ?= |
codefu@google.com | 977045b | 2011-05-31 17:15:12 +0000 | [diff] [blame] | 76 | ifeq ($(DEBUG),TRUE) |
| 77 | DEBUGCFLAGS= -g |
| 78 | else |
conroy@google.com | 7927b9d | 2011-06-24 15:39:48 +0000 | [diff] [blame] | 79 | DEBUGCFLAGS= |
codefu@google.com | 977045b | 2011-05-31 17:15:12 +0000 | [diff] [blame] | 80 | endif |
| 81 | |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 82 | # Set OS as well as CFLAGS, CXX, and other common make variables |
| 83 | ifeq ($(shell uname),Linux) |
| 84 | OS=linux |
codefu@google.com | 977045b | 2011-05-31 17:15:12 +0000 | [diff] [blame] | 85 | BASECFLAGS= $(DEBUGCFLAGS) -O2 -fPIC $(INC) -rdynamic |
| 86 | ARCHCFLAGS= -m$(FLAG32BIT) |
| 87 | ALLARCHCFLAGS= -m$(FLAG32BIT) |
jat@google.com | a0d0bed | 2009-08-18 22:58:15 +0000 | [diff] [blame] | 88 | endif |
| 89 | ifeq ($(shell uname),Darwin) |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 90 | OS=mac |
codefu@google.com | 977045b | 2011-05-31 17:15:12 +0000 | [diff] [blame] | 91 | BASECFLAGS= $(DEBUGCFLAGS) -O2 -fPIC $(INC) -D__mac -mmacosx-version-min=10.5 |
jat@google.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 92 | ARCHCFLAGS=-arch $(MARCH) |
conroy@google.com | e3153e5 | 2011-01-24 12:30:43 +0000 | [diff] [blame] | 93 | ALLARCHCFLAGS=-arch i386 -arch ppc -arch x86_64 |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 94 | AR=libtool |
| 95 | ARFLAGS=-static -o |
jat@google.com | a0d0bed | 2009-08-18 22:58:15 +0000 | [diff] [blame] | 96 | endif |
| 97 | ifeq ($(shell uname),SunOS) |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 98 | OS=sun |
codefu@google.com | 977045b | 2011-05-31 17:15:12 +0000 | [diff] [blame] | 99 | ifeq ($(DEBUG),TRUE) |
| 100 | DEBUGCFLAGS= -g0 |
| 101 | endif |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 102 | #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.com | 977045b | 2011-05-31 17:15:12 +0000 | [diff] [blame] | 106 | BASECFLAGS= $(DEBUGCFLAGS) -Kpic -noex -xO1 -xlibmil -xlibmopt -features=tmplife -xbuiltin=%all -mt $(INC) |
jat@google.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 107 | ARCHCFLAGS= |
| 108 | ALLARCHCFLAGS= |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 109 | CXX= CC |
| 110 | endif |
jat@google.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 111 | CFLAGS=$(BASECFLAGS) $(ARCHCFLAGS) |
| 112 | CXXFLAGS = $(CFLAGS) |