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