| 1 |
# Licensed to the Apache Software Foundation (ASF) under one |
| 2 |
# or more contributor license agreements. See the NOTICE file |
| 3 |
# distributed with this work for additional information |
| 4 |
# regarding copyright ownership. The ASF licenses this file |
| 5 |
# to you under the Apache License, Version 2.0 (the |
| 6 |
# "License"); you may not use this file except in compliance |
| 7 |
# with the License. You may obtain a copy of the License at |
| 8 |
# |
| 9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
# |
| 11 |
# Unless required by applicable law or agreed to in writing, |
| 12 |
# software distributed under the License is distributed on an |
| 13 |
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 |
# KIND, either express or implied. See the License for the |
| 15 |
# specific language governing permissions and limitations |
| 16 |
# under the License. |
| 17 |
|
| 18 |
|
| 19 |
# Makefile for building Poi4R |
| 20 |
# |
| 21 |
# Supported operating systems: Linux, Mac OS X and Windows. |
| 22 |
# See INSTALL file for requirements. |
| 23 |
# |
| 24 |
# Steps to build |
| 25 |
# 1. Edit the sections below as documented |
| 26 |
# 2. make all |
| 27 |
# 3. make install |
| 28 |
# |
| 29 |
# The install target installs the Poi4R python extension in python's |
| 30 |
# site-packages directory. On Mac OS X, it also installs the gcj runtime |
| 31 |
# libraries into $(PREFIX)/lib. |
| 32 |
# |
| 33 |
# To successfully import the Poi4R extension into Ruby, all required |
| 34 |
# libraries need to be found. If the locations you chose are non-standard, |
| 35 |
# the relevant DYLD_LIBRARY_PATH (Mac OS X), LD_LIBRARY_PATH (Linux), or |
| 36 |
# PATH (Windows) need to be set accordingly. |
| 37 |
# |
| 38 |
|
| 39 |
|
| 40 |
VERSION=0.1.0 |
| 41 |
POI_VER=$(shell grep '<property name="version.id"' ../../../build.xml | awk -F'"' '{print $$4}') |
| 42 |
RUBY_VER=1.8 |
| 43 |
|
| 44 |
POI4R:=$(shell pwd) |
| 45 |
POI=$(POI4R)/poi-$(POI_VER) |
| 46 |
#DEBUG=1 |
| 47 |
|
| 48 |
# |
| 49 |
# You need to uncomment and edit the variables below in the section |
| 50 |
# corresponding to your operating system. |
| 51 |
# |
| 52 |
# PREFIX: where programs are normally installed on your system (Unix). |
| 53 |
# PREFIX_RUBY: where your version of python is installed. |
| 54 |
# GCJ_HOME: where GCC/GCJ is installed. |
| 55 |
# Windows drive-absolute paths need to be expressed cygwin style. |
| 56 |
# |
| 57 |
|
| 58 |
# Mac OS X (Darwin) |
| 59 |
#PREFIX=/usr/local |
| 60 |
#PREFIX_RUBY=/Library/Frameworks/Ruby.framework/Versions/$(RUBY_VER) |
| 61 |
#SWIG=$(PREFIX)/bin/swig |
| 62 |
#GCJ_HOME=/usr/local/gcc-3.4.1 |
| 63 |
#DB=$(POI4R)/db-$(DB_VER) |
| 64 |
#PREFIX_DB=/usr/local/BerkeleyDB.$(DB_LIB_VER) |
| 65 |
|
| 66 |
# Linux |
| 67 |
PREFIX=/usr |
| 68 |
PREFIX_RUBY=$(PREFIX) |
| 69 |
SWIG=$(PREFIX)/bin/swig |
| 70 |
GCJ_HOME=/usr |
| 71 |
#DB=$(POI4R)/db-$(DB_VER) |
| 72 |
#PREFIX_DB=$(PREFIX)/BerkeleyDB.$(DB_LIB_VER) |
| 73 |
|
| 74 |
# Windows |
| 75 |
#PREFIX_RUBY=/cygdrive/o/Python-2.3.2 |
| 76 |
#SWIG=/cygdrive/c/utils/bin/swig.exe |
| 77 |
#GCJ_HOME=/cygdrive/o/mingw-3.1 |
| 78 |
#DB=/cygdrive/o/db-$(DB_VER) |
| 79 |
#PREFIX_DB=$(DB) |
| 80 |
|
| 81 |
# |
| 82 |
# No edits required below |
| 83 |
# |
| 84 |
|
| 85 |
OS=$(shell uname) |
| 86 |
ifeq ($(findstring CYGWIN,$(OS)),CYGWIN) |
| 87 |
OS=Cygwin |
| 88 |
endif |
| 89 |
ifeq ($(findstring WINNT,$(OS)),WINNT) |
| 90 |
OS=Cygwin |
| 91 |
endif |
| 92 |
|
| 93 |
ifeq ($(DEBUG),1) |
| 94 |
COMP_OPT=DEBUG=1 |
| 95 |
SUFFIX=d |
| 96 |
_SUFFIX=_d |
| 97 |
BINDIR=debug |
| 98 |
else |
| 99 |
COMP_OPT= |
| 100 |
SUFFIX= |
| 101 |
_SUFFIX= |
| 102 |
BINDIR=release |
| 103 |
endif |
| 104 |
|
| 105 |
SWIG_OPT=-DSWIG_COBJECT_TYPES -DPOI4R_VER="'$(VERSION)'" -DPOI_VER="'$(POI_VER)'" |
| 106 |
|
| 107 |
JCCFLAGS=--encoding=UTF-8 |
| 108 |
#JCCFLAGS=--encoding=UTF-8 -findirect-dispatch |
| 109 |
|
| 110 |
ifeq ($(OS),Darwin) |
| 111 |
RUBY_SITE=$(PREFIX_RUBY)/lib/ruby$(RUBY_VER)/site-packages |
| 112 |
RUBY_INC=$(PREFIX_RUBY)/lib/ruby$(RUBY_VER) |
| 113 |
POI4R=$(BINDIR)/poi4r.so |
| 114 |
ifeq ($(DEBUG),1) |
| 115 |
CCFLAGS=-O0 -g |
| 116 |
LDFLAGS=-g |
| 117 |
else |
| 118 |
CCFLAGS=-O2 |
| 119 |
LDFLAGS= |
| 120 |
endif |
| 121 |
else |
| 122 |
|
| 123 |
ifeq ($(OS),Linux) |
| 124 |
RUBY_SITE=$(PREFIX_RUBY)/lib/ruby/site-ruby/$(RUBY_VER)/ |
| 125 |
RUBY_INC=$(PREFIX_RUBY)/lib/ruby/$(RUBY_VER)/i686-linux |
| 126 |
POI4R_LIB=$(BINDIR)/poi4r.so |
| 127 |
ifeq ($(DEBUG),1) |
| 128 |
CCFLAGS=-O0 -g -fPIC |
| 129 |
LDFLAGS=-g |
| 130 |
else |
| 131 |
CCFLAGS=-O2 -fPIC |
| 132 |
LDFLAGS= |
| 133 |
endif |
| 134 |
else |
| 135 |
|
| 136 |
ifeq ($(OS),Cygwin) |
| 137 |
RUBY_SITE=`cygpath -aw $(PREFIX_RUBY)/Lib/site-packages` |
| 138 |
RUBY_INC=`cygpath -aw $(PREFIX_RUBY)/Include` |
| 139 |
RUBY_PC=`cygpath -aw $(PREFIX_RUBY)/PC` |
| 140 |
POI4R_LIB=$(BINDIR)/poi4r$(_SUFFIX).so |
| 141 |
ifeq ($(DEBUG),1) |
| 142 |
CCFLAGS=-O -g |
| 143 |
LDFLAGS=-g |
| 144 |
else |
| 145 |
CCFLAGS=-O2 |
| 146 |
LDFLAGS= |
| 147 |
endif |
| 148 |
else |
| 149 |
|
| 150 |
RUBY=unknown |
| 151 |
RUBY_SITE=unknown |
| 152 |
endif |
| 153 |
endif |
| 154 |
endif |
| 155 |
|
| 156 |
CLASSES=$(BINDIR)/classes |
| 157 |
JAR_CLASSES=$(CLASSES)/jar |
| 158 |
|
| 159 |
CC=$(GCJ_HOME)/bin/gcc |
| 160 |
CXX=$(GCJ_HOME)/bin/g++ |
| 161 |
JCC=$(GCJ_HOME)/bin/gcj |
| 162 |
JCCH=$(GCJ_HOME)/bin/gcjh |
| 163 |
JAR=$(GCJ_HOME)/bin/jar |
| 164 |
POI_ZIP=poi-$(POI_VER).jar |
| 165 |
POI_JAR=poi-$(POI_VER).jar |
| 166 |
POI_JAR_WC=poi-$(POI_VER)-*.jar |
| 167 |
|
| 168 |
POI4R_CP:=$(BINDIR)/$(POI_JAR):$(CLASSES) |
| 169 |
|
| 170 |
OBJS=$(BINDIR)/poi.o $(BINDIR)/io.java.o $(BINDIR)/io.cpp.o |
| 171 |
|
| 172 |
LIBS=$(POI4R_LIB) |
| 173 |
|
| 174 |
default: all |
| 175 |
|
| 176 |
patches: |
| 177 |
|
| 178 |
|
| 179 |
env: |
| 180 |
ifndef PREFIX_RUBY |
| 181 |
@echo Operating system is $(OS) |
| 182 |
@echo You need to edit that section of the Makefile |
| 183 |
@false |
| 184 |
else |
| 185 |
@true |
| 186 |
endif |
| 187 |
|
| 188 |
|
| 189 |
$(BINDIR): |
| 190 |
mkdir -p $(BINDIR)/classes/jar |
| 191 |
|
| 192 |
|
| 193 |
DISTRIB=Poi-$(VERSION) |
| 194 |
|
| 195 |
ifeq ($(OS),Cygwin) |
| 196 |
POI4R_CP:=`cygpath -awp $(POI4R_CP)` |
| 197 |
endif |
| 198 |
|
| 199 |
|
| 200 |
ifeq ($(OS),Cygwin) |
| 201 |
_poi=`cygpath -aw $(POI)` |
| 202 |
else |
| 203 |
_poi=$(POI) |
| 204 |
endif |
| 205 |
|
| 206 |
$(BINDIR)/$(POI_JAR): |
| 207 |
cp ../../../build/dist/$(POI_JAR_WC) $(BINDIR)/$(POI_JAR) |
| 208 |
cd $(JAR_CLASSES); $(JAR) -xf ../../$(POI_JAR) |
| 209 |
|
| 210 |
$(BINDIR)/io.java.o: java/org/apache/poi/RubyOutputStream.java |
| 211 |
$(JCC) $(JCCFLAGS) -C -d $(CLASSES) java/org/apache/poi/RubyOutputStream.java |
| 212 |
$(JCC) $(JCCFLAGS) $(CCFLAGS) -I$(GCJ_HOME)/include -c -o $@ java/org/apache/poi/RubyOutputStream.java |
| 213 |
|
| 214 |
$(CLASSES)/org/apache/poi/RubyOutputStream.h: $(BINDIR)/io.java.o Makefile |
| 215 |
mkdir -p $(CLASSES)/org/apache/poi/hssf/usermodel |
| 216 |
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFWorkbook |
| 217 |
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFSheet |
| 218 |
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFRow |
| 219 |
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFCell |
| 220 |
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFHeader |
| 221 |
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFFooter |
| 222 |
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFFont |
| 223 |
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFDataFormat |
| 224 |
$(JCCH) -d $(CLASSES) --classpath=$(JAR_CLASSES) org.apache.poi.hssf.usermodel.HSSFCellStyle |
| 225 |
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.poi.RubyOutputStream |
| 226 |
|
| 227 |
|
| 228 |
$(BINDIR)/io.cpp.o: $(CLASSES)/org/apache/poi/RubyOutputStream.h cpp/RubyIO.cpp $(BINDIR)/io.java.o |
| 229 |
$(JCC) -I$(RUBY_INC) -I$(GCJ_HOME)/include -I$(CLASSES) $(CCFLAGS) -c -o $@ cpp/RubyIO.cpp |
| 230 |
|
| 231 |
$(BINDIR)/poi.o: $(BINDIR)/$(POI_JAR) |
| 232 |
$(JCC) $(JCCFLAGS) $(CCFLAGS) -c -o $@ $(BINDIR)/$(POI_JAR) |
| 233 |
|
| 234 |
Poi4R_wrap.cxx: $(BINDIR)/io.cpp.o Poi4R.i |
| 235 |
ifdef SWIG |
| 236 |
$(SWIG) $(SWIG_OPT) -I$(CLASSES) -c++ -ruby Poi4R.i |
| 237 |
endif |
| 238 |
|
| 239 |
|
| 240 |
ifeq ($(OS),Darwin) |
| 241 |
$(POI4R_LIB): $(OBJS) Poi4R_wrap.cxx |
| 242 |
$(CXX) -shared -bundle -o $@ $(CCFLAGS) $(SWIG_OPT) $(DB_INC) -I$(GCJ_HOME)/include -I$(CLASSES) -I$(RUBY_INC) Poi4R_wrap.cxx $(OBJS) -L$(GCJ_HOME)/lib -lgcj -liconv -undefined suppress -flat_namespace -multiply_defined suppress |
| 243 |
else |
| 244 |
|
| 245 |
ifeq ($(OS),Linux) |
| 246 |
$(POI4R_LIB): $(OBJS) Poi4R_wrap.cxx |
| 247 |
$(CXX) -shared -o $@ $(CCFLAGS) $(SWIG_OPT) $(DB_INC) -I$(CLASSES) -I$(RUBY_INC) Poi4R_wrap.cxx $(OBJS) -lgcj |
| 248 |
else |
| 249 |
|
| 250 |
ifeq ($(OS),Cygwin) |
| 251 |
$(POI4R_LIB): $(OBJS) Poi4R_wrap.cxx |
| 252 |
$(CXX) -c $(CCFLAGS) $(PYDBG) -D_NO_OLDNAMES -D_off_t=off_t $(SWIG_OPT) $(DB_INC) -I$(CLASSES) -I$(RUBY_PC) -I$(RUBY_INC) -o $(BINDIR)/Poi4R_wrap.o Poi4R_wrap.cxx |
| 253 |
$(CXX) -shared $(LDFLAGS) -o $@ $(OBJS) `cygpath -aw $(PREFIX_RUBY)/python23$(_SUFFIX).dll` $(BINDIR)/Poi4R_wrap.o -lgcj -lwin32k -lws2_32 |
| 254 |
endif |
| 255 |
endif |
| 256 |
endif |
| 257 |
|
| 258 |
|
| 259 |
all: env $(BINDIR) $(LIBS) |
| 260 |
@echo build of $(POI4R_LIB) complete |
| 261 |
|
| 262 |
install:: all |
| 263 |
install Poi4R.rb $(RUBY_SITE) |
| 264 |
install $(POI4R_LIB) $(RUBY_SITE) |
| 265 |
|
| 266 |
ifeq ($(OS),Darwin) |
| 267 |
install:: |
| 268 |
install $(GCJ_HOME)/lib/libgcj.5.dylib $(PREFIX)/lib |
| 269 |
install $(GCJ_HOME)/lib/libstdc++.6.dylib $(PREFIX)/lib |
| 270 |
install $(GCJ_HOME)/lib/libgcc_s.1.0.dylib $(PREFIX)/lib |
| 271 |
else |
| 272 |
|
| 273 |
ifeq ($(OS),Linux) |
| 274 |
install:: |
| 275 |
|
| 276 |
else |
| 277 |
|
| 278 |
ifeq ($(OS),Cygwin) |
| 279 |
install:: |
| 280 |
|
| 281 |
endif |
| 282 |
endif |
| 283 |
endif |
| 284 |
|
| 285 |
|
| 286 |
clean: |
| 287 |
rm -rf $(BINDIR) Poi4R.rb* Poi4R_wrap.cxx |
| 288 |
|
| 289 |
realclean: clean |
| 290 |
rm -rf $(POI) $(STORE) $(DISTRIB) |
| 291 |
|
| 292 |
distrib:: |
| 293 |
mkdir -p $(DISTRIB)/python |
| 294 |
install Poi4R.rb $(DISTRIB)/python |
| 295 |
install $(POI4R_LIB) $(DISTRIB)/python |
| 296 |
install README $(DISTRIB) |
| 297 |
|
| 298 |
ifeq ($(OS),Darwin) |
| 299 |
distrib:: |
| 300 |
ifdef DB |
| 301 |
mkdir -p $(DISTRIB)/db |
| 302 |
install $(LIBDB_JAVA_LIB) $(DISTRIB)/db |
| 303 |
install libdb_java-$(DB_LIB_VER).la.osx $(DISTRIB)/db |
| 304 |
endif |
| 305 |
mkdir -p $(DISTRIB)/gcj |
| 306 |
install $(GCJ_HOME)/lib/libgcj.5.dylib $(DISTRIB)/gcj |
| 307 |
install $(GCJ_HOME)/lib/libstdc++.6.dylib $(DISTRIB)/gcj |
| 308 |
install $(GCJ_HOME)/lib/libgcc_s.1.0.dylib $(DISTRIB)/gcj |
| 309 |
else |
| 310 |
|
| 311 |
ifeq ($(OS),Linux) |
| 312 |
distrib:: |
| 313 |
ifdef DB |
| 314 |
mkdir -p $(DISTRIB)/db |
| 315 |
install $(LIBDB_JAVA_LIB) $(DISTRIB)/db |
| 316 |
endif |
| 317 |
mkdir -p $(DISTRIB)/gcj |
| 318 |
install $(GCJ_HOME)/lib/libgcj.so.5 $(DISTRIB)/gcj |
| 319 |
install $(GCJ_HOME)/lib/libstdc++.so.6 $(DISTRIB)/gcj |
| 320 |
install $(GCJ_HOME)/lib/libgcc_s.so.1 $(DISTRIB)/gcj |
| 321 |
else |
| 322 |
|
| 323 |
ifeq ($(OS),Cygwin) |
| 324 |
distrib:: |
| 325 |
ifdef DB |
| 326 |
mkdir -p $(DISTRIB)/db |
| 327 |
install $(LIBDB_JAVA_LIB) $(DISTRIB)/db |
| 328 |
endif |
| 329 |
endif |
| 330 |
endif |
| 331 |
endif |
| 332 |
|