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