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 # Builds the Databse SDBC driver skeleton example of the Developers Guide.
23 
24 PRJ=../../../..
25 SETTINGS=$(PRJ)/settings
26 
27 include $(SETTINGS)/settings.mk
28 include $(SETTINGS)/std.mk
29 include $(SETTINGS)/dk.mk
30 
31 # Define non-platform/compiler specific settings
32 COMP_NAME=DatabaseSDBCDriverSkeleton
33 COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
34 COMP_LIBRARY=$(SHAREDLIB_OUT)/$(COMP_IMPL_NAME)
35 OUT_COMP_INC=$(OUT_INC)/$(COMP_NAME)
36 OUT_COMP_MISC=$(OUT_MISC)/$(COMP_NAME)
37 OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
38 COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
39 COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
40 COMP_UNOPKG_MANIFEST = $(OUT_COMP_MISC)/$(COMP_NAME)/META-INF/manifest.xml
41 #COMP_MAPFILE = $(OUT_COMP_MISC)/$(COMP_NAME).uno.map
42 COMP_COMPONENTS = $(OUT_COMP_MISC)/$(COMP_NAME).components
43 
44 COMP_REGISTERFLAG = $(OUT_COMP_MISC)/devguide_$(COMP_NAME)_register_component.flag
45 
46 CXXFILES = SConnection.cxx \
47 	SDatabaseMetaData.cxx \
48 	propertyids.cxx \
49 	SDriver.cxx \
50 	SPreparedStatement.cxx \
51 	SResultSet.cxx \
52 	SResultSetMetaData.cxx \
53 	SServices.cxx \
54 	SStatement.cxx
55 
56 SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
57 
58 # Targets
59 .PHONY: ALL
60 ALL : \
61 	DatabaseSDBCDriverSkeletonExample
62 
63 include $(SETTINGS)/stdtarget.mk
64 
65 $(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
66 	-$(MKDIR) $(subst /,$(PS),$(@D))
67 	$(CC) $(CC_FLAGS) $(CC_INCLUDES) $(STL_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
68 
69 #$(COMP_MAPFILE) : $(SLOFILES)
70 #	-$(MKDIR) $(subst /,$(PS),$(@D))
71 #	cat $(PRJ)/settings/component.uno.map > $(COMP_MAPFILE)
72 #ifeq "$(OS)" "MACOSX"
73 #	nm -gx $(SLOFILES) | $(ADDSYMBOLS) >> $(COMP_MAPFILE)
74 #endif
75 
76 ifeq "$(OS)" "WIN"
77 $(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
78 	-$(MKDIR) $(subst /,$(PS),$(@D))
79 	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_MISC))
80 	$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
81 	/MAP:$(OUT_COMP_MISC)/$(COMP_NAME).map $(SLOFILES) \
82 	 $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) msvcrt.lib kernel32.lib
83 	$(LINK_MANIFEST)
84 else
85 $(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
86 	-$(MKDIR) $(subst /,$(PS),$(@D))
87 	$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
88 	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
89 ifeq "$(OS)" "MACOSX"
90 	$(INSTALL_NAME_URELIBS)  $@
91 endif
92 endif
93 
94 # rule for component package manifest
95 $(OUT_COMP_MISC)/%/manifest.xml :
96 	-$(MKDIR) $(subst /,$(PS),$(@D))
97 	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
98 	@echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
99 	@echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
100 	@echo $(SQM)  $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@
101 	@echo $(SQM)                       $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@
102 	@echo $(OSEP)/manifest:manifest$(CSEP) >> $@
103 
104 $(COMP_COMPONENTS) :
105 	-$(MKDIR) $(subst /,$(PS),$(@D))
106 	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
107 	@echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
108 	@echo $(SQM)  $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
109 	@echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)com.sun.star.comp.sdbc.SkeletonDriver$(QM)"$(CSEP) >> $@
110 	@echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)com.sun.star.sdbc.Driver$(QM)"/$(CSEP) >> $@
111 	@echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
112 	@echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
113 	@echo $(OSEP)/components$(CSEP) >> $@
114 
115 $(COMP_PACKAGE) : $(COMP_LIBRARY) $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
116 	-$(MKDIR) $(subst /,$(PS),$(@D)) && $(DEL) $(subst \\,\,$(subst /,$(PS),$@))
117 	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_MISC)/$(UNOPKG_PLATFORM))
118 	$(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_MISC)/$(UNOPKG_PLATFORM))
119 	cd $(subst /,$(PS),$(OUT_COMP_MISC)) && $(SDK_ZIP) ../../bin/$(@F) $(COMP_NAME).components
120 	cd $(subst /,$(PS),$(OUT_COMP_MISC)) && $(SDK_ZIP) -u ../../bin/$(@F) $(UNOPKG_PLATFORM)/$(<F)
121 	cd $(subst /,$(PS),$(OUT_COMP_MISC)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
122 
123 $(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
124 ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
125 	-$(MKDIR) $(subst /,$(PS),$(@D))
126 	-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
127 	$(DEPLOYTOOL) $(COMP_PACKAGE_URL)
128 	@echo flagged > $(subst /,$(PS),$@)
129 else
130 	@echo --------------------------------------------------------------------------------
131 	@echo  If you want to install your component automatically, please set the environment
132 	@echo  variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
133 	@echo  possible if no office instance is running.
134 	@echo --------------------------------------------------------------------------------
135 endif
136 
137 DatabaseSDBCDriverSkeletonExample : $(COMP_REGISTERFLAG)
138 	@echo --------------------------------------------------------------------------------
139 	@echo The Database SDBC skeleton driver component was installed if SDK_AUTO_DEPLOYMENT = YES.
140 	@echo You can use this component inside your office installation, see the example
141 	@echo description and the howto of implementing a sdbc driver.
142 	@echo --------------------------------------------------------------------------------
143 
144 .PHONY: clean
145 clean :
146 	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
147 	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_MISC))
148 	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
149 	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_LIBRARY)))
150 	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_COMPONENTS)))
151 	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_REGISTERFLAG)))
152 	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
153