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