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#
24#  The Contents of this file are made available subject to the terms of
25#  the BSD license.
26#
27#  Copyright 2000, 2010 Oracle and/or its affiliates.
28#  All rights reserved.
29#
30#  Redistribution and use in source and binary forms, with or without
31#  modification, are permitted provided that the following conditions
32#  are met:
33#  1. Redistributions of source code must retain the above copyright
34#     notice, this list of conditions and the following disclaimer.
35#  2. Redistributions in binary form must reproduce the above copyright
36#     notice, this list of conditions and the following disclaimer in the
37#     documentation and/or other materials provided with the distribution.
38#  3. Neither the name of Sun Microsystems, Inc. nor the names of its
39#     contributors may be used to endorse or promote products derived
40#     from this software without specific prior written permission.
41#
42#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
45#  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
46#  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
47#  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
48#  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
49#  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
50#  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
51#  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
52#  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53#
54#**************************************************************************
55
56# Builds the Databse SDBC driver skeleton example of the Developers Guide.
57
58PRJ=../../../..
59SETTINGS=$(PRJ)/settings
60
61include $(SETTINGS)/settings.mk
62include $(SETTINGS)/std.mk
63include $(SETTINGS)/dk.mk
64
65# Define non-platform/compiler specific settings
66COMP_NAME=DatabaseSDBCDriverSkeleton
67COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
68COMP_LIBRARY=$(SHAREDLIB_OUT)/$(COMP_IMPL_NAME)
69OUT_COMP_INC=$(OUT_INC)/$(COMP_NAME)
70OUT_COMP_MISC=$(OUT_MISC)/$(COMP_NAME)
71OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
72COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
73COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
74COMP_UNOPKG_MANIFEST = $(OUT_COMP_MISC)/$(COMP_NAME)/META-INF/manifest.xml
75#COMP_MAPFILE = $(OUT_COMP_MISC)/$(COMP_NAME).uno.map
76COMP_COMPONENTS = $(OUT_COMP_MISC)/$(COMP_NAME).components
77
78COMP_REGISTERFLAG = $(OUT_COMP_MISC)/devguide_$(COMP_NAME)_register_component.flag
79
80CXXFILES = SConnection.cxx \
81	SDatabaseMetaData.cxx \
82	propertyids.cxx \
83	SDriver.cxx \
84	SPreparedStatement.cxx \
85	SResultSet.cxx \
86	SResultSetMetaData.cxx \
87	SServices.cxx \
88	SStatement.cxx
89
90SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
91
92# Targets
93.PHONY: ALL
94ALL : \
95	DatabaseSDBCDriverSkeletonExample
96
97include $(SETTINGS)/stdtarget.mk
98
99$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
100	-$(MKDIR) $(subst /,$(PS),$(@D))
101	$(CC) $(CC_FLAGS) $(CC_INCLUDES) $(STL_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
102
103#$(COMP_MAPFILE) : $(SLOFILES)
104#	-$(MKDIR) $(subst /,$(PS),$(@D))
105#	cat $(PRJ)/settings/component.uno.map > $(COMP_MAPFILE)
106#ifeq "$(OS)" "MACOSX"
107#	nm -gx $(SLOFILES) | $(ADDSYMBOLS) >> $(COMP_MAPFILE)
108#endif
109
110ifeq "$(OS)" "WIN"
111$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
112	-$(MKDIR) $(subst /,$(PS),$(@D))
113	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_MISC))
114	$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
115	/MAP:$(OUT_COMP_MISC)/$(COMP_NAME).map $(SLOFILES) \
116	 $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
117	$(LINK_MANIFEST)
118else
119$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
120	-$(MKDIR) $(subst /,$(PS),$(@D))
121	$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
122	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
123ifeq "$(OS)" "MACOSX"
124	$(INSTALL_NAME_URELIBS)  $@
125endif
126endif
127
128# rule for component package manifest
129$(OUT_COMP_MISC)/%/manifest.xml :
130	-$(MKDIR) $(subst /,$(PS),$(@D))
131	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
132	@echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
133	@echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
134	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@
135	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@
136	@echo $(OSEP)/manifest:manifest$(CSEP) >> $@
137
138$(COMP_COMPONENTS) :
139	-$(MKDIR) $(subst /,$(PS),$(@D))
140	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
141	@echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
142	@echo $(SQM)  $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
143	@echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)com.sun.star.comp.sdbc.SkeletonDriver$(QM)"$(CSEP) >> $@
144	@echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)com.sun.star.sdbc.Driver$(QM)"/$(CSEP) >> $@
145	@echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
146	@echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
147	@echo $(OSEP)/components$(CSEP) >> $@
148
149$(COMP_PACKAGE) : $(COMP_LIBRARY) $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
150	-$(MKDIR) $(subst /,$(PS),$(@D)) && $(DEL) $(subst \\,\,$(subst /,$(PS),$@))
151	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_MISC)/$(UNOPKG_PLATFORM))
152	$(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_MISC)/$(UNOPKG_PLATFORM))
153	cd $(subst /,$(PS),$(OUT_COMP_MISC)) && $(SDK_ZIP) ../../bin/$(@F) $(COMP_NAME).components
154	cd $(subst /,$(PS),$(OUT_COMP_MISC)) && $(SDK_ZIP) -u ../../bin/$(@F) $(UNOPKG_PLATFORM)/$(<F)
155	cd $(subst /,$(PS),$(OUT_COMP_MISC)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
156
157$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
158ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
159	-$(MKDIR) $(subst /,$(PS),$(@D))
160	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
161	$(DEPLOYTOOL) $(COMP_PACKAGE_URL)
162	@echo flagged > $(subst /,$(PS),$@)
163else
164	@echo --------------------------------------------------------------------------------
165	@echo  If you want to install your component automatically, please set the environment
166	@echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
167	@echo  possible if no office instance is running.
168	@echo --------------------------------------------------------------------------------
169endif
170
171DatabaseSDBCDriverSkeletonExample : $(COMP_REGISTERFLAG)
172	@echo --------------------------------------------------------------------------------
173	@echo The Database SDBC skeleton driver component was installed if SDK_AUTO_DEPLOYMENT = YES.
174	@echo You can use this component inside your office installation, see the example
175	@echo description and the howto of implementing a sdbc driver.
176	@echo --------------------------------------------------------------------------------
177
178.PHONY: clean
179clean :
180	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
181	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_MISC))
182	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
183	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_LIBRARY)))
184	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_COMPONENTS)))
185	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_REGISTERFLAG)))
186	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
187