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 |
jat@google.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 72 | OMARCH=ppc |
| 73 | endif |
| 74 | ifeq ($(ARCH),ppc) |
| 75 | OMARCH=i386 |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 76 | endif |
| 77 | |
| 78 | # Set OS as well as CFLAGS, CXX, and other common make variables |
| 79 | ifeq ($(shell uname),Linux) |
| 80 | OS=linux |
jat@google.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 81 | BASECFLAGS= -g -O2 -fPIC $(INC) -rdynamic |
| 82 | ARCHCFLAGS=-m$(FLAG32BIT) |
| 83 | ALLARCHCFLAGS=$(ARCHCFLAGS) |
jat@google.com | a0d0bed | 2009-08-18 22:58:15 +0000 | [diff] [blame] | 84 | endif |
| 85 | ifeq ($(shell uname),Darwin) |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 86 | OS=mac |
jat@google.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 87 | BASECFLAGS= -g -O2 -fPIC $(INC) -D__mac |
| 88 | ARCHCFLAGS=-arch $(MARCH) |
| 89 | ALLARCHCFLAGS=-arch i386 -arch ppc |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 90 | AR=libtool |
| 91 | ARFLAGS=-static -o |
jat@google.com | a0d0bed | 2009-08-18 22:58:15 +0000 | [diff] [blame] | 92 | endif |
| 93 | ifeq ($(shell uname),SunOS) |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 94 | OS=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.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 99 | BASECFLAGS= -g0 -Kpic -noex -xO1 -xlibmil -xlibmopt -features=tmplife -xbuiltin=%all -mt $(INC) |
| 100 | ARCHCFLAGS= |
| 101 | ALLARCHCFLAGS= |
jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 102 | CXX= CC |
| 103 | endif |
jat@google.com | 2318196 | 2009-09-03 22:22:56 +0000 | [diff] [blame] | 104 | CFLAGS=$(BASECFLAGS) $(ARCHCFLAGS) |
| 105 | CXXFLAGS = $(CFLAGS) |