blob: 8b3a8cfd499c47e9f7ecadbac25482b7a7d1ea5b [file] [log] [blame]
jat@google.com64a55cb2009-10-16 14:16:57 +00001# Copyright 2007 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##
16# Target settings
17##
18#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
23
24GWT_ROOT = ../../
25OBJDIR := $(GWT_ROOT)build/out/jni/linux/
26OUTDIR := $(GWT_ROOT)build/jni/linux/
27OUT := $(OUTDIR)libgwt-ll.so
28STAGING := $(GWT_ROOT)build/staging/gwt-linux-0.0.0/
29
30##
31# The location to get .class files from for javah
32##
33CLASSDIR := $(GWT_ROOT)build/out/dev/linux/bin
34
35# use this instead if you want to use eclipse to build the class files during
36# development
37#CLASSDIR := $(GWT_ROOT)eclipse/dev/linux/bin
38
39##
40# Tools
41##
42CXX := g++
43AR := ar
44STRIP := strip
45LD := $(CXX)
46JAVAH := $(JAVA_HOME)/bin/javah
47
48##
49# List of source, object, and dependency paths plus the path to them
50##
51SRCDIRS := ./:../core/
52VPATH := .:../core
53SRCS := gwt-ll.cpp LowLevelMoz.cpp JsValueMoz.cpp Tracer.cpp \
54 ExternalWrapper.cpp NativeWrapper.cpp JsRootedValue.cpp
55OBJS := $(addprefix $(OBJDIR),$(SRCS:.cpp=.o))
56DEPS := $(addprefix $(OBJDIR),$(SRCS:.cpp=.d))
57
58MOZDIR = $(GWT_TOOLS)/sdk/mozilla-1.7.12
59MOZINC = $(MOZDIR)/include
60MOZLIB = $(MOZDIR)/lib
61
62##
63# Include path configuration
64##
65SYSINCS := \
66 $(JAVA_HOME)/include \
67 $(JAVA_HOME)/include/linux \
68 $(MOZINC) $(MOZINC)/extra
69
70INCS := $(OBJDIR)
71INCS := $(addprefix -I ,$(INCS)) $(addprefix -isystem ,$(SYSINCS))
72
73##
74# Libraries and library path
75##
76LIBS = xpcomglue_s
77LIBPATH = -L$(MOZLIB)
78LIBS := $(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
83CFLAGS := -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)
85
86#-------------------------------------------------------------------------------
87# Rules
88#-------------------------------------------------------------------------------
89
90##
91# default rule
92##
93all: $(OUT)
94
95# install into prebuilt directory
96install: $(OUT)
97 cp $(OUT) prebuilt/
98
99##
100# Include the dependency rules
101##
102-include $(DEPS)
103
104##
105# 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##
117$(OBJDIR)LowLevelMoz.o: $(OBJDIR)LowLevelMoz.h $(JAVA_HOME)/include/jni.h
118$(OBJDIR)JsValueMoz.o: $(OBJDIR)JsValueMoz.h $(JAVA_HOME)/include/jni.h
119
120##
121# Compilation rule for cpp files
122##
123$(OBJDIR)%.o : $(SRCDIR)%.cpp
124 @[ -d $(OBJDIR) ] || mkdir -p $(OBJDIR)
125 $(CXX) -c $(CFLAGS) $(INCS) -o $@ $<
126
127# generate preprocessed output files upon request for debugging
128%.i : $(SRCDIR)%.cpp
129 $(CXX) -E $(CFLAGS) $(INCS) -o $@ $<
130
131%.I : $(SRCDIR)%.cpp
132 $(CXX) -E -dDI $(CFLAGS) $(INCS) -o $@ $<
133
134##
135# Actual output file
136##
137$(OUT): $(OBJS) $(MOZLIB)/libxpcomglue_s.a
138 @[ -d $(OUTDIR) ] || mkdir -p $(OUTDIR)
139 $(LD) -shared $(LDFLAGS) $(LIBPATH) -o $@ $^ $(LIBS)
140 $(STRIP) --strip-unneeded $@
141
142##
143# copy to staging area for hosted-mode development
144##
145staging: $(OUT)
146 @[ -d $(STAGING) ] || mkdir -p $(STAGING)
147 cp $(OUT) $(STAGING)
148
149##
150# Clean rule
151##
152clean:
153 @-rm -rf $(OBJDIR) $(OUT)