xref: /aoo41x/main/solenv/inc/tg_app.mk (revision 1e1ac450)
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
22CC_PATH*="$(CC_PATH)"
23
24#######################################################
25# instructions for linking
26# unroll begin
27
28.IF "$(GUI)" == "OS2" && "$(TARGETTYPE)" == "GUI"
29APP$(TNR)DEF = $(MISC)/$(APP$(TNR)TARGET).def
30.ENDIF
31
32.IF "$(APP$(TNR)LINKTYPE)" != ""
33#must be either STATIC or SHARED
34APP$(TNR)LINKTYPEFLAG=$(APPLINK$(APP$(TNR)LINKTYPE))
35.ENDIF
36
37# decide how to link
38.IF "$(APP$(TNR)CODETYPE)"=="C"
39APP$(TNR)LINKER=$(LINKC)
40APP$(TNR)STDLIB=$(subst,CPPRUNTIME, $(STDLIB))
41APP$(TNR)LINKFLAGS+=$(LINKCFLAGS)
42.ELSE			# "$(APP$(TNR)CODETYPE)"=="C"
43APP$(TNR)LINKER=$(LINK)
44APP$(TNR)STDLIB=$(subst,CPPRUNTIME,$(STDLIBCPP) $(STDLIB))
45APP$(TNR)LINKFLAGS+=$(LINKFLAGS)
46.ENDIF			# "$(APP$(TNR)CODETYPE)"=="C"
47
48APP$(TNR)RPATH*=OOO
49LINKFLAGSRUNPATH_$(APP$(TNR)RPATH)*=/ERROR:/Bad_APP$(TNR)RPATH_value
50.IF "$(OS)" != "MACOSX"
51APP$(TNR)LINKFLAGS+=$(LINKFLAGSRUNPATH_$(APP$(TNR)RPATH))
52.ENDIF
53
54.IF "$(APP$(TNR)STACK)" != ""
55.IF "$(LINKFLAGSTACK)" != ""
56APP$(TNR)STACKN=$(LINKFLAGSTACK)$(APP$(TNR)STACK)
57.ENDIF
58.ELSE
59APP$(TNR)STACKN=
60.ENDIF
61
62.IF "$(APP$(TNR)NOSAL)"==""
63.IF "$(TARGETTYPE)" == "GUI"
64APP$(TNR)OBJS+= $(STDOBJVCL)
65.ENDIF
66.ENDIF
67
68.IF "$(GUI)$(COM)" == "WNTGCC"
69APP$(TNR)RESO=
70.IF "$(APP$(TNR)LINKRES)" != "" || "$(APP$(TNR)RES)" != ""
71APP$(TNR)RESO=$(MISC)/$(APP$(TNR)TARGET:b)_res.o
72.ENDIF
73.ENDIF
74
75.IF "$(GUI)" == "UNX"
76APP$(TNR)DEPN+:=$(APP$(TNR)DEPNU)
77USE_APP$(TNR)DEF=
78.ENDIF
79
80.IF "$(APP$(TNR)TARGETN)"!=""
81
82.IF "$(APP$(TNR)PRODUCTNAME)"!=""
83APP$(TNR)PRODUCTDEF+:=-DPRODUCT_NAME=\"$(APP$(TNR)PRODUCTNAME)\"
84.ENDIF			# "$(APP$(TNR)PRODUCTNAME)"!=""
85
86.IF "$(linkinc)"!=""
87.IF "$(GUI)"=="WNT" || "$(GUI)"=="OS2"
88.IF "$(APP$(TNR)LIBS)"!=""
89$(MISC)/$(APP$(TNR)TARGET)_linkinc.ls .PHONY:
90	@@-$(RM) $@
91	sed -f $(SOLARENV)/bin/chrel.sed $(foreach,i,$(APP$(TNR)LIBS) $(i:s/.lib/.lin/)) >> $@
92.ENDIF          #"$(APP$(TNR)LIBS)"!=""
93.ENDIF
94
95LINKINCTARGETS+=$(MISC)/$(APP$(TNR)TARGETN:b)_linkinc.ls
96$(APP$(TNR)TARGETN) : $(LINKINCTARGETS)
97.ENDIF          # "$(linkinc)"!=""
98
99# Allow for target specific LIBSALCPPRT override
100APP$(TNR)LIBSALCPPRT*=$(LIBSALCPPRT)
101
102$(APP$(TNR)TARGETN): $(APP$(TNR)OBJS) $(APP$(TNR)LIBS) \
103	$(APP$(TNR)RES) \
104	$(APP$(TNR)ICON) $(APP$(TNR)DEPN) $(USE_APP$(TNR)DEF)
105	@echo "Making:   " $(@:f)
106.IF "$(GUI)"=="UNX"
107.IF "$(OS)"=="MACOSX"
108	@echo unx
109	@-$(RM) $(MISC)/$(@:b).list
110	@-$(RM) $(MISC)/$(TARGET).$(@:b)_$(TNR).cmd
111	@-$(RM) $(MISC)/$(@:b).strip
112	@echo $(STDSLO) $(APP$(TNR)OBJS:s/.obj/.o/) \
113	`cat /dev/null $(APP$(TNR)LIBS) | sed s\#$(ROUT)\#$(OUT)\#g` | tr -s " " "\n" > $(MISC)/$(@:b).list
114	@echo -n $(APP$(TNR)LINKER) $(APP$(TNR)LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) -o $@ \
115	$(APP$(TNR)LINKTYPEFLAG) $(APP$(TNR)STDLIBS) $(APP$(TNR)STDLIB) $(STDLIB$(TNR)) -filelist $(MISC)/$(@:b).list > $(MISC)/$(TARGET).$(@:b)_$(TNR).cmd
116    @$(PERL) $(SOLARENV)/bin/macosx-dylib-link-list.pl \
117        `cat $(MISC)/$(TARGET).$(@:b)_$(TNR).cmd` \
118        >> $(MISC)/$(TARGET).$(@:b)_$(TNR).cmd
119  .IF "$(VERBOSE)" == "TRUE"
120	@cat $(MISC)/$(TARGET).$(@:b)_$(TNR).cmd
121  .ENDIF
122	@+source $(MISC)/$(TARGET).$(@:b)_$(TNR).cmd
123# Need to strip __objcInit symbol to avoid duplicate symbols when loading
124# libraries at runtime
125	@-$(CC_PATH)nm $@ | grep -v ' U ' | $(AWK) '{ print $$NF }' | grep -F -x '__objcInit' > $(MISC)/$(@:b).strip
126	@$(CC_PATH)strip -i -R $(MISC)/$(@:b).strip -X $@
127	@ls -l $@
128    @$(PERL) $(SOLARENV)/bin/macosx-change-install-names.pl \
129        app $(APP$(TNR)RPATH) $@
130.IF "$(TARGETTYPE)"=="GUI"
131	@echo "Making:   " $(@:f).app
132	@macosx-create-bundle $@
133.ENDIF		# "$(TARGETTYPE)"=="GUI"
134.ELSE		# "$(OS)"=="MACOSX"
135	@echo unx
136	@-$(RM) $(MISC)/$(TARGET).$(@:b)_$(TNR).cmd
137	@echo $(APP$(TNR)LINKER) $(APP$(TNR)LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
138	$(APP$(TNR)OBJS:s/.obj/.o/) '\' >  $(MISC)/$(TARGET).$(@:b)_$(TNR).cmd
139	@cat $(mktmp /dev/null $(APP$(TNR)LIBS)) | xargs -n 1 cat | sed s\#$(ROUT)\#$(OUT)\#g | sed 's#$$# \\#'  >> $(MISC)/$(TARGET).$(@:b)_$(TNR).cmd
140	@echo $(APP$(TNR)LINKTYPEFLAG) $(APP$(TNR)LIBSALCPPRT) $(APP$(TNR)STDLIBS) $(APP$(TNR)STDLIB) $(STDLIB$(TNR)) -o $@ >> $(MISC)/$(TARGET).$(@:b)_$(TNR).cmd
141  .IF "$(VERBOSE)" == "TRUE"
142	@cat $(MISC)/$(TARGET).$(@:b)_$(TNR).cmd
143  .ENDIF
144	@+source $(MISC)/$(TARGET).$(@:b)_$(TNR).cmd
145  .IF "$(VERBOSE)" == "TRUE"
146	@ls -l $@
147  .ENDIF
148.ENDIF		# "$(OS)"=="MACOSX"
149.ENDIF
150.IF "$(GUI)" == "WNT"
151	@@-$(MKDIR) $(@:d:d)
152.IF "$(APP$(TNR)LINKRES)" != ""
153	@@-$(RM) $(MISC)/$(APP$(TNR)LINKRES:b).rc
154.IF "$(APP$(TNR)ICON)" != ""
155	@-echo 1 ICON $(EMQ)"$(APP$(TNR)ICON:s/\/\\/)$(EMQ)" >> $(MISC)/$(APP$(TNR)LINKRES:b).rc
156.ENDIF		# "$(APP$(TNR)ICON)" != ""
157.IF "$(APP$(TNR)VERINFO)" != ""
158	@-echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP$(TNR)LINKRES:b).rc
159	@-echo $(EMQ)#include  $(EMQ)"$(APP$(TNR)VERINFO)$(EMQ)" >> $(MISC)/$(APP$(TNR)LINKRES:b).rc
160.ENDIF		# "$(APP$(TNR)VERINFO)" != ""
161	$(COMMAND_ECHO)$(RC) -DWIN32 $(APP$(TNR)PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP$(TNR)LINKRES:b).rc
162.ENDIF			# "$(APP$(TNR)LINKRES)" != ""
163.IF "$(COM)" == "GCC"
164	@echo mingw
165.IF "$(APP$(TNR)LINKRES)" != "" || "$(APP$(TNR)RES)" != ""
166	@cat $(APP$(TNR)LINKRES) $(subst,/res/,/res{$(subst,$(BIN), $(@:d))} $(APP$(TNR)RES)) >  $(MISC)/$(@:b)_all.res
167	windres $(MISC)/$(@:b)_all.res $(APP$(TNR)RESO)
168.ENDIF
169	@echo $(LINK) $(LINKFLAGS) $(LINKFLAGSAPP) $(MINGWSSTDOBJ) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
170		$(APP$(TNR)BASEX) $(APP$(TNR)STACKN) -o $@ $(APP$(TNR)OBJS) \
171		-Wl,-Map,$(MISC)/$(@:b).map $(STDOBJ) $(APP$(TNR)RESO) \
172		`$(TYPE) /dev/null $(APP$(TNR)LIBS) | sed s#$(ROUT)#$(OUT)#g` \
173		$(APP_LINKTYPE) $(APP$(TNR)LIBSALCPPRT) \
174		-Wl,--start-group $(APP$(TNR)STDLIBS) -Wl,--end-group $(APP$(TNR)STDLIB) \
175		$(STDLIB$(TNR)) $(MINGWSSTDENDOBJ) > $(MISC)/$(TARGET).$(@:b)_$(TNR).cmd
176  # need this empty line, else dmake somehow gets confused by the .IFs and .ENDIFs
177  .IF "$(VERBOSE)" == "TRUE"
178	@$(TYPE)  $(MISC)/$(TARGET).$(@:b)_$(TNR).cmd
179  .ENDIF
180	@+source $(MISC)/$(TARGET).$(@:b)_$(TNR).cmd
181	@ls -l $@
182.ELSE	# "$(COM)" == "GCC"
183.IF "$(linkinc)" == ""
184	$(COMMAND_ECHO)$(APP$(TNR)LINKER) @$(mktmp \
185		$(APP$(TNR)LINKFLAGS) \
186		$(LINKFLAGSAPP) $(APP$(TNR)BASEX) \
187		$(APP$(TNR)STACKN) \
188		-out:$@ \
189		-map:$(MISC)/{$(subst,/,_ $(APP$(TNR)TARGET)).map} \
190		$(STDOBJ) \
191		$(APP$(TNR)LINKRES) \
192		$(APP$(TNR)RES) \
193		$(APP$(TNR)OBJS) \
194		$(APP$(TNR)LIBS) \
195		$(APP$(TNR)STDLIBS) \
196		$(APP$(TNR)STDLIB) $(STDLIB$(TNR)) \
197		)
198	@-echo linking $@.manifest ...
199.IF "$(VISTA_MANIFEST)"!=""
200	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -manifest $(TRUSTED_MANIFEST_LOCATION)/trustedinfo.manifest -out:$@.tmanifest$(EMQ) $(FI)
201	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.tmanifest -outputresource:$@$(EMQ);1 $(FI)
202.ELSE
203	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -outputresource:$@$(EMQ);1 $(FI)
204.ENDIF # "$(VISTA_MANIFEST)"!=""
205	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(RM:s/+//) $@.manifest $(FI)
206	$(COMMAND_ECHO)$(IFEXIST) $@.tmanifest $(THEN) $(RM:s/+//) $@.tmanifest $(FI)
207.ELSE
208		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP$(TNR)TARGET).lnk
209		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP$(TNR)TARGET).lst
210		$(COMMAND_ECHO)-$(RM) $(MISC)\linkobj.lst
211		for %_i in ($(MISC)\*.obj) do type %_i >> $(MISC)\linkobj.lst
212	type $(mktmp,$(MISC)\$(APP$(TNR)TARGET).lst
213		$(APP$(TNR)LINKFLAGS) \
214		$(LINKFLAGSAPP) $(APP$(TNR)BASEX) \
215		$(APP$(TNR)STACKN) \
216		-out:$@ \
217		$(STDOBJ) \
218		$(APP$(TNR)LINKRES) \
219		$(APP$(TNR)RES) \
220		$(APP$(TNR)OBJS) \
221		$(APP$(TNR)LIBS) \
222		$(APP$(TNR)STDLIBS) \
223		$(APP$(TNR)STDLIB) $(STDLIB$(TNR)))
224		$(COMMAND_ECHO)$(SED)$(SED) -e 's/\(\.\.\\\)\{2,4\}/..\\/g' $(MISC)\$(APP$(TNR)TARGETN:b)_linkobj.lst >> $(MISC)\$(APP$(TNR)TARGET).lst
225		$(COMMAND_ECHO)$(SED)$(IFEXIST) $(MISC)/$(APP$(TNR)TARGET).lst $(THEN) type $(MISC)/$(APP$(TNR)TARGET).lst  >> $(MISC)/$(APP$(TNR)TARGET).lnk $(FI)
226		$(COMMAND_ECHO)$(SED)$(APP$(TNR)LINKER) @$(MISC)\$(APP$(TNR)TARGET).lnk
227.ENDIF		# "$(linkinc)" == ""
228.ENDIF		# "$(COM)" == "GCC"
229.IF "$(APP$(TNR)TARGET)" == "loader"
230	$(COMMAND_ECHO)$(PERL) loader.pl $@
231	$(COMMAND_ECHO)$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
232	$(COMMAND_ECHO)$(RM) $@
233	$(COMMAND_ECHO)$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
234.ENDIF			# "$(TARGET)" == "setup"
235
236.ENDIF			# "$(GUI)" == "WNT"
237
238.IF "$(GUI)" == "OS2"
239	@+-$(MKDIR) $(@:d:d) > $(NULLDEV)
240.IF "$(APP$(TNR)LINKRES)" != ""
241	@+-$(RM) $(MISC)/$(APP$(TNR)LINKRES:b).rc > $(NULLDEV)
242.IF "$(APP$(TNR)ICON)" != ""
243	@-+echo ICON 1 $(EMQ)"$(APP$(TNR)ICON:s#/#\\\\#)$(EMQ)" >> $(MISC)$/$(APP$(TNR)LINKRES:b).rc
244.ENDIF		# "$(APP$(TNR)ICON)" != ""
245.IF "$(APP$(TNR)VERINFO)" != ""
246	@-+echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP$(TNR)LINKRES:b).rc
247	@-+echo $(EMQ)#include  $(EMQ)"$(APP$(TNR)VERINFO)$(EMQ)" >> $(MISC)/$(APP$(TNR)LINKRES:b).rc
248.ENDIF		# "$(APP$(TNR)VERINFO)" != ""
249	$(COMMAND_ECHO)$(RC) -r -DOS2 $(APP$(TNR)PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP$(TNR)LINKRES:b).rc
250.ENDIF			# "$(APP$(TNR)LINKRES)" != ""
251
252.IF "$(TARGETTYPE)" == "GUI"
253	@echo NAME $(APP$(TNR)TARGET) WINDOWAPI > $(MISC)/$(APP$(TNR)TARGET).def
254.ENDIF
255
256	$(COMMAND_ECHO)$(APP$(TNR)LINKER) -v \
257		$(APP$(TNR)LINKFLAGS) \
258		$(LINKFLAGSAPP) $(APP$(TNR)BASEX) \
259		$(APP$(TNR)STACKN) \
260		-o $@ \
261		-Zmap -L$(LB) \
262		-L$(SOLARVERSION)/$(INPATH)/lib \
263		$(STDOBJ) \
264		$(APP$(TNR)LINKRES) \
265		$(APP$(TNR)RES) \
266		$(APP$(TNR)DEF) \
267		$(APP$(TNR)OBJS) \
268		$(APP$(TNR)LIBS) \
269		$(APP$(TNR)STDLIBS) \
270		$(APP$(TNR)STDLIB) $(STDLIB$(TNR))
271
272
273.IF "$(APP$(TNR)TARGET)" == "loader"
274	$(COMMAND_ECHO)+$(PERL) loader.pl $@
275	$(COMMAND_ECHO)+$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
276	$(COMMAND_ECHO)+$(RM) $@
277	$(COMMAND_ECHO)+$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
278.ENDIF			# "$(TARGET)" == "setup"
279
280.ENDIF			# "$(GUI)" == "OS2"
281
282.ENDIF			# "$(APP$(TNR)TARGETN)"!=""
283
284
285# Instruction for linking
286# unroll end
287#######################################################
288
289