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 ProfUNO lifetime 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
45COMPONENT_NAME=ProfUnoLifetime
46OUT_COMP_CLASS=$(OUT_CLASS)/$(COMPONENT_NAME)
47OUT_COMP_INC=$(OUT_INC)/$(COMPONENT_NAME)
48OUT_COMP_GEN=$(OUT_MISC)/$(COMPONENT_NAME)
49OUT_COMP_OBJ=$(OUT_OBJ)/$(COMPONENT_NAME)
50
51JAVAFILES  = \
52	MyUnoObject.java
53
54CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/JavaComp/%.class,$(JAVAFILES))
55
56CXXFILES = object_lifetime.cxx
57
58OBJFILES = $(patsubst %.cxx,$(OUT_COMP_OBJ)/%.$(OBJ_EXT),$(CXXFILES))
59
60SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
61		$(PATH_SEPARATOR)$(OUT_COMP_CLASS))
62
63
64# Targets
65.PHONY: ALL
66ALL : \
67    ProUNOLifetimeExamples
68
69include $(SETTINGS)/stdtarget.mk
70
71$(OUT_COMP_CLASS)/%.class : %.java
72	-$(MKDIR) $(subst /,$(PS),$(@D))
73	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $<
74
75$(OUT_COMP_OBJ)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
76	-$(MKDIR) $(subst /,$(PS),$(@D))
77	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
78
79$(OUT_BIN)/$(COMPONENT_NAME)$(EXE_EXT) : $(OBJFILES)
80	-$(MKDIR) $(subst /,$(PS),$(@D))
81	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
82ifeq "$(OS)" "WIN"
83	$(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(OUT_COMP_GEN)/$(subst $(EXE_EXT),.map,$(@F)) \
84	  $(OBJFILES) $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB)
85else
86	$(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $(OBJFILES) \
87	  $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) $(STDC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALHELPERDYLIB) $(SALDYLIB)
88ifeq "$(OS)" "MACOSX"
89	$(INSTALL_NAME_URELIBS_BIN)  $@
90endif
91endif
92
93ProUNOLifetimeExamples : $(OUT_BIN)/$(COMPONENT_NAME)$(EXE_EXT) $(OUT_COMP_CLASS)/MyUnoObject.class
94	@echo --------------------------------------------------------------------------------
95	@echo Please use one of the following commands to execute the examples!
96	@echo -
97	@echo $(MAKE) MyUnoObject.run
98	@echo $(MAKE) ProfUnoLifetime.runexe
99	@echo --------------------------------------------------------------------------------
100
101%.run: $(OUT_COMP_CLASS)/%.class
102	$(SDK_JAVA) -classpath "$(SDK_CLASSPATH)" $(basename $@)
103
104%.runexe: $(OUT_BIN)/%$(EXE_EXT)
105	cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@)
106
107.PHONY: clean
108clean :
109	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
110	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
111	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
112	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_OBJ))
113	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/$(COMPONENT_NAME)$(EXE_EXT)))
114