blob: 8b3a8cfd499c47e9f7ecadbac25482b7a7d1ea5b [file] [log] [blame]
gwt.team.jatc85cb7f2007-03-02 20:13:50 +00001# Copyright 2007 Google Inc.
gwt.team.scottbb80dfcc2006-12-12 07:44:10 +00002#
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.
gwt.team.scottbab0aa682006-12-06 23:14:19 +000014
15##
16# Target settings
17##
gwt.team.jatc8e942d2007-03-07 20:45:51 +000018#JAVA_HOME
19#JAVA_HOME=/usr/lib/j2sdk1.5-sun
20
21# set GWT_TOOLS only if it is not already defined
22GWT_TOOLS ?= ../../../tools
gwt.team.jatc85cb7f2007-03-02 20:13:50 +000023
gwt.team.scottbb80dfcc2006-12-12 07:44:10 +000024GWT_ROOT = ../../
25OBJDIR := $(GWT_ROOT)build/out/jni/linux/
26OUTDIR := $(GWT_ROOT)build/jni/linux/
27OUT := $(OUTDIR)libgwt-ll.so
scottb@google.comeee77382008-03-05 01:14:12 +000028STAGING := $(GWT_ROOT)build/staging/gwt-linux-0.0.0/
gwt.team.scottbab0aa682006-12-06 23:14:19 +000029
30##
gwt.team.jatc85cb7f2007-03-02 20:13:50 +000031# The location to get .class files from for javah
32##
33CLASSDIR := $(GWT_ROOT)build/out/dev/linux/bin
gwt.team.jatc8e942d2007-03-07 20:45:51 +000034
35# use this instead if you want to use eclipse to build the class files during
gwt.team.jatc85cb7f2007-03-02 20:13:50 +000036# development
37#CLASSDIR := $(GWT_ROOT)eclipse/dev/linux/bin
38
39##
gwt.team.scottbab0aa682006-12-06 23:14:19 +000040# Tools
41##
gwt.team.jatc85cb7f2007-03-02 20:13:50 +000042CXX := g++
gwt.team.scottbab0aa682006-12-06 23:14:19 +000043AR := ar
44STRIP := strip
45LD := $(CXX)
gwt.team.jatc8e942d2007-03-07 20:45:51 +000046JAVAH := $(JAVA_HOME)/bin/javah
gwt.team.scottbab0aa682006-12-06 23:14:19 +000047
48##
49# List of source, object, and dependency paths plus the path to them
50##
gwt.team.scottbb80dfcc2006-12-12 07:44:10 +000051SRCDIRS := ./:../core/
52VPATH := .:../core
gwt.team.jata15ecd92007-03-02 21:52:30 +000053SRCS := gwt-ll.cpp LowLevelMoz.cpp JsValueMoz.cpp Tracer.cpp \
gwt.team.jatc85cb7f2007-03-02 20:13:50 +000054 ExternalWrapper.cpp NativeWrapper.cpp JsRootedValue.cpp
gwt.team.scottbab0aa682006-12-06 23:14:19 +000055OBJS := $(addprefix $(OBJDIR),$(SRCS:.cpp=.o))
56DEPS := $(addprefix $(OBJDIR),$(SRCS:.cpp=.d))
57
gwt.team.scottb46c79be2007-07-23 18:13:13 +000058MOZDIR = $(GWT_TOOLS)/sdk/mozilla-1.7.12
gwt.team.mmendeze117df52007-05-23 18:45:55 +000059MOZINC = $(MOZDIR)/include
60MOZLIB = $(MOZDIR)/lib
61
gwt.team.scottbab0aa682006-12-06 23:14:19 +000062##
63# Include path configuration
64##
65SYSINCS := \
gwt.team.scottbb80dfcc2006-12-12 07:44:10 +000066 $(JAVA_HOME)/include \
67 $(JAVA_HOME)/include/linux \
gwt.team.mmendeze117df52007-05-23 18:45:55 +000068 $(MOZINC) $(MOZINC)/extra
gwt.team.scottbab0aa682006-12-06 23:14:19 +000069
gwt.team.jatc85cb7f2007-03-02 20:13:50 +000070INCS := $(OBJDIR)
71INCS := $(addprefix -I ,$(INCS)) $(addprefix -isystem ,$(SYSINCS))
gwt.team.scottbab0aa682006-12-06 23:14:19 +000072
73##
74# Libraries and library path
75##
76LIBS = xpcomglue_s
gwt.team.mmendeze117df52007-05-23 18:45:55 +000077LIBPATH = -L$(MOZLIB)
gwt.team.scottbab0aa682006-12-06 23:14:19 +000078LIBS := $(addprefix -l,$(LIBS))
79
80# for notes on auto-dependency generation, see
81# http://make.paulandlesley.org/autodep.html
82# -MP obviates the need for sed hackery
gwt.team.jatc85cb7f2007-03-02 20:13:50 +000083CFLAGS := -ggdb -m32 -Os -fPIC -fno-omit-frame-pointer -fno-strict-aliasing -D_REENTRANT -MMD -MP -Wno-system-headers $(CFLAGS)
84LDFLAGS := -ggdb -m32 -s -fPIC -fno-omit-frame-pointer -fno-strict-aliasing -D_REENTRANT -Wl,-shared-gcc $(LDFLAGS)
gwt.team.scottbab0aa682006-12-06 23:14:19 +000085
gwt.team.scottbab0aa682006-12-06 23:14:19 +000086#-------------------------------------------------------------------------------
87# Rules
88#-------------------------------------------------------------------------------
89
90##
91# default rule
92##
93all: $(OUT)
gwt.team.jatc85cb7f2007-03-02 20:13:50 +000094
gwt.team.jatc8e942d2007-03-07 20:45:51 +000095# install into prebuilt directory
gwt.team.jatc85cb7f2007-03-02 20:13:50 +000096install: $(OUT)
97 cp $(OUT) prebuilt/
gwt.team.scottbab0aa682006-12-06 23:14:19 +000098
99##
100# Include the dependency rules
101##
102-include $(DEPS)
103
104##
gwt.team.jatc85cb7f2007-03-02 20:13:50 +0000105# javah-generated headers for native methods
106##
107$(OBJDIR)LowLevelMoz.h : $(CLASSDIR)/com/google/gwt/dev/shell/moz/LowLevelMoz.class
108 $(JAVAH) -classpath $(CLASSDIR) -o $(OBJDIR)LowLevelMoz.h com.google.gwt.dev.shell.moz.LowLevelMoz
109
110$(OBJDIR)JsValueMoz.h : $(CLASSDIR)/com/google/gwt/dev/shell/moz/JsValueMoz.class
111 $(JAVAH) -classpath $(CLASSDIR) -o $(OBJDIR)JsValueMoz.h com.google.gwt.dev.shell.moz.JsValueMoz
112
113##
114# Dependency rules for generated headers
115# TODO(jat): autogenerate these and others
116##
gwt.team.jatc8e942d2007-03-07 20:45:51 +0000117$(OBJDIR)LowLevelMoz.o: $(OBJDIR)LowLevelMoz.h $(JAVA_HOME)/include/jni.h
118$(OBJDIR)JsValueMoz.o: $(OBJDIR)JsValueMoz.h $(JAVA_HOME)/include/jni.h
gwt.team.jatc85cb7f2007-03-02 20:13:50 +0000119
120##
gwt.team.scottbab0aa682006-12-06 23:14:19 +0000121# Compilation rule for cpp files
122##
123$(OBJDIR)%.o : $(SRCDIR)%.cpp
124 @[ -d $(OBJDIR) ] || mkdir -p $(OBJDIR)
gwt.team.jatc85cb7f2007-03-02 20:13:50 +0000125 $(CXX) -c $(CFLAGS) $(INCS) -o $@ $<
126
gwt.team.jatc8e942d2007-03-07 20:45:51 +0000127# generate preprocessed output files upon request for debugging
gwt.team.jatc85cb7f2007-03-02 20:13:50 +0000128%.i : $(SRCDIR)%.cpp
129 $(CXX) -E $(CFLAGS) $(INCS) -o $@ $<
130
131%.I : $(SRCDIR)%.cpp
132 $(CXX) -E -dDI $(CFLAGS) $(INCS) -o $@ $<
gwt.team.scottbab0aa682006-12-06 23:14:19 +0000133
134##
135# Actual output file
136##
gwt.team.mmendeze117df52007-05-23 18:45:55 +0000137$(OUT): $(OBJS) $(MOZLIB)/libxpcomglue_s.a
gwt.team.scottbb80dfcc2006-12-12 07:44:10 +0000138 @[ -d $(OUTDIR) ] || mkdir -p $(OUTDIR)
gwt.team.scottbab0aa682006-12-06 23:14:19 +0000139 $(LD) -shared $(LDFLAGS) $(LIBPATH) -o $@ $^ $(LIBS)
gwt.team.jat50ba0eb2007-03-23 20:13:07 +0000140 $(STRIP) --strip-unneeded $@
gwt.team.jatd43ad6c2007-03-19 22:24:12 +0000141
142##
143# copy to staging area for hosted-mode development
144##
145staging: $(OUT)
scottb@google.comeee77382008-03-05 01:14:12 +0000146 @[ -d $(STAGING) ] || mkdir -p $(STAGING)
147 cp $(OUT) $(STAGING)
gwt.team.scottbab0aa682006-12-06 23:14:19 +0000148
149##
150# Clean rule
151##
152clean:
gwt.team.scottbb80dfcc2006-12-12 07:44:10 +0000153 @-rm -rf $(OBJDIR) $(OUT)