jat@google.com | 64a55cb | 2009-10-16 14:16:57 +0000 | [diff] [blame] | 1 | # 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 |
| 22 | GWT_TOOLS ?= ../../../tools |
| 23 | |
| 24 | GWT_ROOT = ../../ |
| 25 | OBJDIR := $(GWT_ROOT)build/out/jni/linux/ |
| 26 | OUTDIR := $(GWT_ROOT)build/jni/linux/ |
| 27 | OUT := $(OUTDIR)libgwt-ll.so |
| 28 | STAGING := $(GWT_ROOT)build/staging/gwt-linux-0.0.0/ |
| 29 | |
| 30 | ## |
| 31 | # The location to get .class files from for javah |
| 32 | ## |
| 33 | CLASSDIR := $(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 | ## |
| 42 | CXX := g++ |
| 43 | AR := ar |
| 44 | STRIP := strip |
| 45 | LD := $(CXX) |
| 46 | JAVAH := $(JAVA_HOME)/bin/javah |
| 47 | |
| 48 | ## |
| 49 | # List of source, object, and dependency paths plus the path to them |
| 50 | ## |
| 51 | SRCDIRS := ./:../core/ |
| 52 | VPATH := .:../core |
| 53 | SRCS := gwt-ll.cpp LowLevelMoz.cpp JsValueMoz.cpp Tracer.cpp \ |
| 54 | ExternalWrapper.cpp NativeWrapper.cpp JsRootedValue.cpp |
| 55 | OBJS := $(addprefix $(OBJDIR),$(SRCS:.cpp=.o)) |
| 56 | DEPS := $(addprefix $(OBJDIR),$(SRCS:.cpp=.d)) |
| 57 | |
| 58 | MOZDIR = $(GWT_TOOLS)/sdk/mozilla-1.7.12 |
| 59 | MOZINC = $(MOZDIR)/include |
| 60 | MOZLIB = $(MOZDIR)/lib |
| 61 | |
| 62 | ## |
| 63 | # Include path configuration |
| 64 | ## |
| 65 | SYSINCS := \ |
| 66 | $(JAVA_HOME)/include \ |
| 67 | $(JAVA_HOME)/include/linux \ |
| 68 | $(MOZINC) $(MOZINC)/extra |
| 69 | |
| 70 | INCS := $(OBJDIR) |
| 71 | INCS := $(addprefix -I ,$(INCS)) $(addprefix -isystem ,$(SYSINCS)) |
| 72 | |
| 73 | ## |
| 74 | # Libraries and library path |
| 75 | ## |
| 76 | LIBS = xpcomglue_s |
| 77 | LIBPATH = -L$(MOZLIB) |
| 78 | LIBS := $(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 |
| 83 | CFLAGS := -ggdb -m32 -Os -fPIC -fno-omit-frame-pointer -fno-strict-aliasing -D_REENTRANT -MMD -MP -Wno-system-headers $(CFLAGS) |
| 84 | LDFLAGS := -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 | ## |
| 93 | all: $(OUT) |
| 94 | |
| 95 | # install into prebuilt directory |
| 96 | install: $(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 | ## |
| 145 | staging: $(OUT) |
| 146 | @[ -d $(STAGING) ] || mkdir -p $(STAGING) |
| 147 | cp $(OUT) $(STAGING) |
| 148 | |
| 149 | ## |
| 150 | # Clean rule |
| 151 | ## |
| 152 | clean: |
| 153 | @-rm -rf $(OBJDIR) $(OUT) |