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 ProfUNO lifetime example of the Developers Guide
23
24PRJ=../../../..
25SETTINGS=$(PRJ)/settings
26
27include $(SETTINGS)/settings.mk
28include $(SETTINGS)/std.mk
29include $(SETTINGS)/dk.mk
30
31# Define non-platform/compiler specific settings
32COMPONENT_NAME=ProfUnoLifetime
33OUT_COMP_CLASS=$(OUT_CLASS)/$(COMPONENT_NAME)
34OUT_COMP_INC=$(OUT_INC)/$(COMPONENT_NAME)
35OUT_COMP_GEN=$(OUT_MISC)/$(COMPONENT_NAME)
36OUT_COMP_OBJ=$(OUT_OBJ)/$(COMPONENT_NAME)
37
38JAVAFILES  = \
39	MyUnoObject.java
40
41CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/JavaComp/%.class,$(JAVAFILES))
42
43CXXFILES = object_lifetime.cxx
44
45OBJFILES = $(patsubst %.cxx,$(OUT_COMP_OBJ)/%.$(OBJ_EXT),$(CXXFILES))
46
47SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
48		$(PATH_SEPARATOR)$(OUT_COMP_CLASS))
49
50
51# Targets
52.PHONY: ALL
53ALL : \
54    ProUNOLifetimeExamples
55
56include $(SETTINGS)/stdtarget.mk
57
58$(OUT_COMP_CLASS)/%.class : %.java
59	-$(MKDIR) $(subst /,$(PS),$(@D))
60	$(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $<
61
62$(OUT_COMP_OBJ)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
63	-$(MKDIR) $(subst /,$(PS),$(@D))
64	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
65
66$(OUT_BIN)/$(COMPONENT_NAME)$(EXE_EXT) : $(OBJFILES)
67	-$(MKDIR) $(subst /,$(PS),$(@D))
68	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
69ifeq "$(OS)" "WIN"
70	$(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(OUT_COMP_GEN)/$(subst $(EXE_EXT),.map,$(@F)) \
71	  $(OBJFILES) $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB)
72else
73	$(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $(OBJFILES) \
74	  $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STDC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALHELPERDYLIB) $(SALDYLIB)
75ifeq "$(OS)" "MACOSX"
76	$(INSTALL_NAME_URELIBS_BIN)  $@
77endif
78endif
79
80ProUNOLifetimeExamples : $(OUT_BIN)/$(COMPONENT_NAME)$(EXE_EXT) $(OUT_COMP_CLASS)/MyUnoObject.class
81	@echo --------------------------------------------------------------------------------
82	@echo Please use one of the following commands to execute the examples!
83	@echo -
84	@echo $(MAKE) MyUnoObject.run
85	@echo $(MAKE) ProfUnoLifetime.runexe
86	@echo --------------------------------------------------------------------------------
87
88%.run: $(OUT_COMP_CLASS)/%.class
89	$(SDK_JAVA) -classpath "$(SDK_CLASSPATH)" $(basename $@)
90
91%.runexe: $(OUT_BIN)/%$(EXE_EXT)
92	cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@)
93
94.PHONY: clean
95clean :
96	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
97	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
98	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
99	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_OBJ))
100	-$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/$(COMPONENT_NAME)$(EXE_EXT)))
101