1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20#************************************************************** 21 22 23 24PRJ=.. 25PRJNAME=mysqlc 26 27.INCLUDE : $(PRJ)$/version.mk 28 29TARGET=mysqlc 30ENABLE_EXCEPTIONS=TRUE 31LIBTARGET=NO 32EXTENSIONNAME:=mysql-connector-ooo 33 34.IF "$(SYSTEM_MYSQL)" == "YES" 35EXTERNAL_WARNINGS_NOT_ERRORS = TRUE 36.ENDIF 37 38# --- Settings ----------------------------------------------------- 39 40.INCLUDE : settings.mk 41 42#------------------------------------------------------------------- 43 44#---- extension version 45EXTENSION_VERSION_BASE=$(MYSQLC_VERSION_MAJOR).$(MYSQLC_VERSION_MINOR).$(MYSQLC_VERSION_MICRO) 46.IF ( "$(CWS_WORK_STAMP)" == "" ) || ( "$(UPDATER)" == "YES" ) 47 EXTENSION_VERSION=$(EXTENSION_VERSION_BASE) 48.ELSE 49 EXTENSION_VERSION=$(EXTENSION_VERSION_BASE).cws.$(CWS_WORK_STAMP) 50.ENDIF 51 52#---- extension title package name 53.IF "$(MYSQLC_STATUS)" == "final" 54 EXTENSION_TITLE:=$(MYSQLC_TITLE) 55 EXTENSION_ZIPNAME:=$(EXTENSIONNAME) 56.ELSE 57 EXTENSION_TITLE:=$(MYSQLC_TITLE) ($(MYSQLC_STATUS)) 58 EXTENSION_ZIPNAME:=$(EXTENSIONNAME) 59.ENDIF 60 61#------------------------------------------------------------------- 62 63# set default symbol visibility / scope to hidden 64.IF "$(COMNAME)" == "gcc3" 65.IF "$(HAVE_GCC_VISIBILITY_FEATURE)" == "TRUE" 66 CFLAGS += -fvisibility=hidden 67.ENDIF # HAVE_GCC_VISIBILITY_FEATURE 68.ENDIF # gcc3 69 70.IF "$(COMNAME)" == "sunpro5" 71.IF "$(CCNUMVER)" >= "00050005" 72 CFLAGS += -xldscope=hidden 73.ENDIF # 5.5 74.ENDIF # sunpro5 75 76#------------------------------------------------------------------- 77 78# The headers delivered from C/C++ have a habit of putting a ";" after the closing bracked of a namespace, which 79# yields a warning with Solaris' compiler. Until this is fixed in C/C++, silence this warning 80.IF "$(OS)" == "SOLARIS" 81 CFLAGSWARNCXX+=,wemptydecl 82 CFLAGSWARNCXX:=$(CFLAGSWARNCXX:s/ ,/,/) 83.ENDIF 84 85#------------------------------------------------------------------- 86.IF "$(ENABLE_MYSQLC)" != "YES" 87@all: 88 @echo "Mysql native driver extension build disabled." 89.ENDIF 90 91# use the static version 92.IF "$(GUI)"=="WNT" 93 MYSQL_LIBDIR=$(LIBMYSQL_PATH)$/lib 94 MYSQL_INCDIR=$(LIBMYSQL_PATH)$/include 95.ELSE 96 .IF "$(SYSTEM_MYSQL)" != "YES" 97 MYSQL_LIBDIR=$(LIBMYSQL_PATH)$/lib 98 MYSQL_INCDIR=$(LIBMYSQL_PATH)$/include 99 .ENDIF 100.ENDIF 101 102.IF "$(SYSTEM_MYSQL)" == "YES" 103CFLAGS+=-DSYSTEM_MYSQL 104.ENDIF 105 106.IF "$(SYSTEM_MYSQL_CPPCONN)" == "YES" 107CFLAGS+=-DSYSTEM_MYSQL_CPPCONN 108.ENDIF 109 110CDEFS+=-DCPPDBC_EXPORTS -DCPPCONN_LIB_BUILD 111.IF "$(SYSTEM_MYSQL_CPPCONN)" == "YES" 112CDEFS += -DCPPCONN_LIB=\"$(shell readlink /usr/lib/libmysqlcppconn.so)\" 113.IF "$(USE_SYSTEM_STL)"!="YES" 114CDEFS += -DADAPT_EXT_STL 115.ENDIF 116.ENDIF 117 118# --------------- MySQL settings ------------------ 119.IF "$(GUI)"!="WNT" 120 .IF "$(SYSTEM_MYSQL)" != "YES" 121 MYSQL_INC+=-I$(MYSQL_INCDIR) 122 .IF "$(OS)"=="MACOSX" 123 MYSQL_LIBFILE=$(MYSQL_LIBDIR)$/$(DLLPRE)mysql.16$(DLLPOST) 124 .ELSE 125 MYSQL_LIBFILE=$(MYSQL_LIBDIR)$/$(DLLPRE)mysql$(DLLPOST).16 126 .ENDIF 127 128 # checkdll will complain if we do not point it to the libmysql lib 129 EXTRALIBPATHS=-L$(MYSQL_LIBDIR) 130 .ENDIF 131 132 MYSQL_CPPCONN_LIB+=-lmysqlcppconn 133.ENDIF 134 135CFLAGS+=-I..$/..$/inc $(MYSQL_INC) \ 136 -DMYSQLC_VERSION_MAJOR=$(MYSQLC_VERSION_MAJOR) \ 137 -DMYSQLC_VERSION_MINOR=$(MYSQLC_VERSION_MINOR) \ 138 -DMYSQLC_VERSION_MICRO=$(MYSQLC_VERSION_MICRO) \ 139 $(MYSQL_DEFINES) 140 141# provide the name of the MySQL client lib to the C++ code 142.IF "$(SYSTEM_MYSQL)" != "YES" 143CDEFS += -DMYSQL_LIB=\"$(MYSQL_LIBFILE:f)\" 144.ENDIF 145 146#-------------------------------------------------- 147 148SHL1DLLPRE= 149SHL1TARGET=$(TARGET).uno 150LIB1TARGET=$(SLB)$/$(SHL1TARGET).lib 151LIB1OBJFILES= \ 152 $(SLO)$/mysqlc_driver.obj \ 153 $(SLO)$/mysqlc_services.obj \ 154 $(SLO)$/mysqlc_connection.obj \ 155 $(SLO)$/mysqlc_resultset.obj \ 156 $(SLO)$/mysqlc_resultsetmetadata.obj \ 157 $(SLO)$/mysqlc_statement.obj \ 158 $(SLO)$/mysqlc_preparedstatement.obj \ 159 $(SLO)$/mysqlc_databasemetadata.obj \ 160 $(SLO)$/mysqlc_types.obj \ 161 $(SLO)$/mysqlc_general.obj \ 162 $(SLO)$/mysqlc_propertyids.obj 163 164SHL1STDLIBS= \ 165 $(MYSQL_LIB) \ 166 $(MYSQL_CPPCONN_LIB) \ 167 $(CPPULIB) \ 168 $(SALLIB) \ 169 $(SALHELPERLIB) \ 170 $(CPPUHELPERLIB) 171 172SHL1VERSIONMAP=$(TARGET).map 173SHL1LIBS= $(LIB1TARGET) 174SHL1DEF= $(MISC)$/$(SHL1TARGET).def 175SHL1RPATH=OXT 176DEF1NAME= $(SHL1TARGET) 177 178# create Extension ----------------------------- 179 180# DESCRIPTION_SRC is the source file which is copied into the extension 181# It is defaulted to "description.xml", but we want to pre-process it, so we use an intermediate 182# file 183DESCRIPTION_SRC = $(MISC)$/description.xml 184 185COMPONENT_XCU=\ 186 registry$/data$/org$/openoffice$/Office$/DataAccess$/Drivers.xcu 187 188COMPONENT_MERGED_XCU= \ 189 $(foreach,i,$(COMPONENT_XCU) $(EXTENSIONDIR)$/$i) 190 191COMPONENT_LIBRARY = \ 192 $(EXTENSIONDIR)$/$(SHL1TARGET)$(DLLPOST) 193 194COMPONENT_MYSQL_LIBFILE = \ 195 $(EXTENSIONDIR)$/$(MYSQL_LIBFILE:f) 196 197COMPONENT_MYSQL_CPPCONN_FILE=\ 198 $(EXTENSIONDIR)$/$(MYSQL_CPPCONNFILE:f) 199 200COMPONENT_LIBRARIES=\ 201 $(COMPONENT_LIBRARY) 202 203COMPONENT_IMAGES= \ 204 $(EXTENSIONDIR)$/images$/extension_32.png \ 205 $(EXTENSIONDIR)$/images$/extension_32_h.png 206 207 208# ........ component description ........ 209# one file for each WITH_LANG token 210DESC_LANGS=$(WITH_LANG) 211.IF "$(DESC_LANGS)" == "" 212 DESC_LANGS=en-US 213.ENDIF 214COMPONENT_DESCRIPTIONS=$/$(foreach,lang,$(DESC_LANGS) description$/description_$(lang).txt) 215COMPONENT_DESCRIPTIONS_PACKDEP= \ 216 $(foreach,i,$(COMPONENT_DESCRIPTIONS) $(EXTENSIONDIR)$/$i) 217 218# WITH_LANG might contain languages which we actually do not have a description for (yet) 219# Find those, and treat the specially 220 221# first, find those locales which we actually have a description file for 222EXISTING_DESCRIPTIONS=$(foreach,i,$(shell $(FIND) .$/description -name "description_*.txt") $(i:f)) 223EXISTING_LANGS=$(foreach,i,$(EXISTING_DESCRIPTIONS) $(i:s,description_,,:s,.txt,,)) 224 225# then, create a version of WITH_LANG where we stripped all those locales 226EXISTING_LANGS_NORMALIZED=$(strip $(EXISTING_LANGS)) 227EXISTING_LANGS_NORMALIZED:=+$(EXISTING_LANGS_NORMALIZED:s/ /+/)+ 228MISSING_LANGS=$(foreach,lang,$(WITH_LANG) $(eq,$(EXISTING_LANGS_NORMALIZED:s/+$(lang)+//),$(EXISTING_LANGS_NORMALIZED) $(lang) )) 229 230# ........ dependencies for packaging the extension ........ 231EXTENSION_PACKDEPS=makefile.mk $(COMPONENT_IMAGES) $(COMPONENT_DESCRIPTIONS_PACKDEP) $(COMPONENT_MERGED_XCU) 232 233.IF "$(SYSTEM_MYSQL)" != "YES" 234EXTENSION_PACKDEPS+=$(COMPONENT_MYSQL_LIBFILE) 235.ENDIF 236 237# --- Targets ------------------------------------------------------ 238.INCLUDE : extension_pre.mk 239.INCLUDE : target.mk 240.INCLUDE : extension_post.mk 241 242$(COMPONENT_IMAGES) : $(SOLARSRC)$/$(RSCDEFIMG)$/desktop$/res$/$$(@:f) 243 @@-$(MKDIRHIER) $(@:d) 244 $(COPY) $< $@ 245 246# existing descriptions: just copy 247$(EXTENSIONDIR)$/description$/%.txt: .$/description$/%.txt 248 @@-$(MKDIRHIER) $(@:d) 249 @$(COPY) $< $@ > $(NULLDEV) 250 251# xcu files: copy 252# the following is a hack for now - need to find out the generic mechanism later 253 254$(EXTENSIONDIR)$/registry$/data$/org$/openoffice$/Office$/DataAccess$/Drivers.xcu : .$/registry$/data$/org$/openoffice$/Office$/DataAccess$/Drivers.xcu 255 @@-$(MKDIRHIER) $(EXTENSIONDIR)$/registry$/data$/org$/openoffice$/Office$/DataAccess 256 @$(COPY) $< $(EXTENSIONDIR)$/registry$/data$/org$/openoffice$/Office$/DataAccess$/Drivers.xcu > $(NULLDEV) 257 258# The below doesn't work - it's completely beyond me .... $@ is some strange path when echoed, so the whole construct 259# doesn't work .... :( 260 261#$(foreach,i,$(COMPONENT_XCU) $(EXTENSIONDIR)$/$i : $i) 262# @echo ----------------- 263# @echo $@ 264# @echo $< 265# @echo ----------------- 266# -$(MKDIRHIER) $(@:d) 267# (COPY) $< $@ 268# @echo ----------------- 269 270# non-existing descriptions: copy from the English version 271.IF "$(strip $(MISSING_LANGS))" != "" 272$(foreach,i,$(MISSING_LANGS) $(EXTENSIONDIR)$/description$/description_$i.txt): .$/description$/description_en-US.txt 273 @echo ------ WARNING: .$/description$/$(@:f) not found, falling back to English description 274 @@-$(MKDIRHIER) $(@:d) 275 @$(COPY) $< $@ > $(NULLDEV) 276.ENDIF 277 278$(DESCRIPTION_SRC): description.xml 279 +-$(RM) $@ 280 $(TYPE) description.xml | $(SED) "s/#VERSION#/$(EXTENSION_VERSION)/" | $(SED) "s,#TITLE#,$(EXTENSION_TITLE)," > $@ 281 282.IF "$(SYSTEM_MYSQL)" != "YES" 283# --- the MySQL client lib needs to be copied 284$(COMPONENT_MYSQL_LIBFILE): $(MYSQL_LIBFILE) 285 @@-$(MKDIRHIER) $(@:d) 286 @$(COPY) $< $@ > $(NULLDEV) 287 .IF "$(OS)" == "MACOSX" 288 install_name_tool -id @__________________________________________________OOO/$(MYSQL_LIBFILE:f) $@ 289 .ENDIF 290.ENDIF 291 292.IF "$(OS)" == "MACOSX" 293$(EXTENSION_TARGET): adjust_libmysql_path 294 295adjust_libmysql_path: $(EXTENSIONDIR)$/$(SHL1TARGET)$(DLLPOST) 296 install_name_tool -change $(MYSQL_LIBFILE:f) @loader_path/$(MYSQL_LIBFILE:f) $(EXTENSIONDIR)$/$(SHL1TARGET)$(DLLPOST) 297.ENDIF 298