xref: /aoo41x/main/solenv/inc/_tg_app.mk (revision 1e1ac450)
1d71964d5SAndrew Rist# *************************************************************
2d71964d5SAndrew Rist#
3d71964d5SAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
4d71964d5SAndrew Rist#  or more contributor license agreements.  See the NOTICE file
5d71964d5SAndrew Rist#  distributed with this work for additional information
6d71964d5SAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
7d71964d5SAndrew Rist#  to you under the Apache License, Version 2.0 (the
8d71964d5SAndrew Rist#  "License"); you may not use this file except in compliance
9d71964d5SAndrew Rist#  with the License.  You may obtain a copy of the License at
10d71964d5SAndrew Rist#
11d71964d5SAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
12d71964d5SAndrew Rist#
13d71964d5SAndrew Rist#  Unless required by applicable law or agreed to in writing,
14d71964d5SAndrew Rist#  software distributed under the License is distributed on an
15d71964d5SAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16d71964d5SAndrew Rist#  KIND, either express or implied.  See the License for the
17d71964d5SAndrew Rist#  specific language governing permissions and limitations
18d71964d5SAndrew Rist#  under the License.
19d71964d5SAndrew Rist#
20d71964d5SAndrew Rist# *************************************************************
218badc1b4SHerbert Dürr
22*1e1ac450SHerbert DürrCC_PATH*="$(CC_PATH)"
238badc1b4SHerbert Dürr
24cdf0e10cSrcweir# unroll begin
25cdf0e10cSrcweir
26cdf0e10cSrcweir.IF "$(GUI)" == "OS2" && "$(TARGETTYPE)" == "GUI"
27cdf0e10cSrcweirAPP1DEF = $(MISC)/$(APP1TARGET).def
28cdf0e10cSrcweir.ENDIF
29cdf0e10cSrcweir
30cdf0e10cSrcweir.IF "$(APP1LINKTYPE)" != ""
31cdf0e10cSrcweir#must be either STATIC or SHARED
32cdf0e10cSrcweirAPP1LINKTYPEFLAG=$(APPLINK$(APP1LINKTYPE))
33cdf0e10cSrcweir.ENDIF
34cdf0e10cSrcweir
35cdf0e10cSrcweir# decide how to link
36cdf0e10cSrcweir.IF "$(APP1CODETYPE)"=="C"
37cdf0e10cSrcweirAPP1LINKER=$(LINKC)
38cdf0e10cSrcweirAPP1STDLIB=$(subst,CPPRUNTIME, $(STDLIB))
39cdf0e10cSrcweirAPP1LINKFLAGS+=$(LINKCFLAGS)
40cdf0e10cSrcweir.ELSE			# "$(APP1CODETYPE)"=="C"
41cdf0e10cSrcweirAPP1LINKER=$(LINK)
42cdf0e10cSrcweirAPP1STDLIB=$(subst,CPPRUNTIME,$(STDLIBCPP) $(STDLIB))
43cdf0e10cSrcweirAPP1LINKFLAGS+=$(LINKFLAGS)
44cdf0e10cSrcweir.ENDIF			# "$(APP1CODETYPE)"=="C"
45cdf0e10cSrcweir
46cdf0e10cSrcweirAPP1RPATH*=OOO
47cdf0e10cSrcweirLINKFLAGSRUNPATH_$(APP1RPATH)*=/ERROR:/Bad_APP1RPATH_value
48cdf0e10cSrcweir.IF "$(OS)" != "MACOSX"
49cdf0e10cSrcweirAPP1LINKFLAGS+=$(LINKFLAGSRUNPATH_$(APP1RPATH))
50cdf0e10cSrcweir.ENDIF
51cdf0e10cSrcweir
52cdf0e10cSrcweir.IF "$(APP1STACK)" != ""
53cdf0e10cSrcweir.IF "$(LINKFLAGSTACK)" != ""
54cdf0e10cSrcweirAPP1STACKN=$(LINKFLAGSTACK)$(APP1STACK)
55cdf0e10cSrcweir.ENDIF
56cdf0e10cSrcweir.ELSE
57cdf0e10cSrcweirAPP1STACKN=
58cdf0e10cSrcweir.ENDIF
59cdf0e10cSrcweir
60cdf0e10cSrcweir.IF "$(APP1NOSAL)"==""
61cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
62cdf0e10cSrcweirAPP1OBJS+= $(STDOBJVCL)
63cdf0e10cSrcweir.ENDIF
64cdf0e10cSrcweir.ENDIF
65cdf0e10cSrcweir
66cdf0e10cSrcweir.IF "$(GUI)$(COM)" == "WNTGCC"
67cdf0e10cSrcweirAPP1RESO=
68cdf0e10cSrcweir.IF "$(APP1LINKRES)" != "" || "$(APP1RES)" != ""
69cdf0e10cSrcweirAPP1RESO=$(MISC)/$(APP1TARGET:b)_res.o
70cdf0e10cSrcweir.ENDIF
71cdf0e10cSrcweir.ENDIF
72cdf0e10cSrcweir
73cdf0e10cSrcweir.IF "$(GUI)" == "UNX"
74cdf0e10cSrcweirAPP1DEPN+:=$(APP1DEPNU)
75cdf0e10cSrcweirUSE_APP1DEF=
76cdf0e10cSrcweir.ENDIF
77cdf0e10cSrcweir
78cdf0e10cSrcweir.IF "$(APP1TARGETN)"!=""
79cdf0e10cSrcweir
80cdf0e10cSrcweir.IF "$(APP1PRODUCTNAME)"!=""
81cdf0e10cSrcweirAPP1PRODUCTDEF+:=-DPRODUCT_NAME=\"$(APP1PRODUCTNAME)\"
82cdf0e10cSrcweir.ENDIF			# "$(APP1PRODUCTNAME)"!=""
83cdf0e10cSrcweir
84cdf0e10cSrcweir.IF "$(linkinc)"!=""
85cdf0e10cSrcweir.IF "$(GUI)"=="WNT" || "$(GUI)"=="OS2"
86cdf0e10cSrcweir.IF "$(APP1LIBS)"!=""
87cdf0e10cSrcweir$(MISC)/$(APP1TARGET)_linkinc.ls .PHONY:
88cdf0e10cSrcweir	@@-$(RM) $@
89cdf0e10cSrcweir	sed -f $(SOLARENV)/bin/chrel.sed $(foreach,i,$(APP1LIBS) $(i:s/.lib/.lin/)) >> $@
90cdf0e10cSrcweir.ENDIF          #"$(APP1LIBS)"!=""
91cdf0e10cSrcweir.ENDIF
92cdf0e10cSrcweir
93cdf0e10cSrcweirLINKINCTARGETS+=$(MISC)/$(APP1TARGETN:b)_linkinc.ls
94cdf0e10cSrcweir$(APP1TARGETN) : $(LINKINCTARGETS)
95cdf0e10cSrcweir.ENDIF          # "$(linkinc)"!=""
96cdf0e10cSrcweir
97cdf0e10cSrcweir# Allow for target specific LIBSALCPPRT override
98cdf0e10cSrcweirAPP1LIBSALCPPRT*=$(LIBSALCPPRT)
99cdf0e10cSrcweir
100cdf0e10cSrcweir$(APP1TARGETN): $(APP1OBJS) $(APP1LIBS) \
101cdf0e10cSrcweir	$(APP1RES) \
102cdf0e10cSrcweir	$(APP1ICON) $(APP1DEPN) $(USE_APP1DEF)
103cdf0e10cSrcweir	@echo "Making:   " $(@:f)
104cdf0e10cSrcweir.IF "$(GUI)"=="UNX"
105cdf0e10cSrcweir.IF "$(OS)"=="MACOSX"
106cdf0e10cSrcweir	@echo unx
107cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).list
108cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_1.cmd
109cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).strip
110cdf0e10cSrcweir	@echo $(STDSLO) $(APP1OBJS:s/.obj/.o/) \
111cdf0e10cSrcweir	`cat /dev/null $(APP1LIBS) | sed s\#$(ROUT)\#$(OUT)\#g` | tr -s " " "\n" > $(MISC)/$(@:b).list
112cdf0e10cSrcweir	@echo -n $(APP1LINKER) $(APP1LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) -o $@ \
113cdf0e10cSrcweir	$(APP1LINKTYPEFLAG) $(APP1STDLIBS) $(APP1STDLIB) $(STDLIB1) -filelist $(MISC)/$(@:b).list > $(MISC)/$(TARGET).$(@:b)_1.cmd
114cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-dylib-link-list.pl \
115cdf0e10cSrcweir        `cat $(MISC)/$(TARGET).$(@:b)_1.cmd` \
116cdf0e10cSrcweir        >> $(MISC)/$(TARGET).$(@:b)_1.cmd
117cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
118cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_1.cmd
119cdf0e10cSrcweir  .ENDIF
120cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_1.cmd
121cdf0e10cSrcweir# Need to strip __objcInit symbol to avoid duplicate symbols when loading
122cdf0e10cSrcweir# libraries at runtime
1238badc1b4SHerbert Dürr	@-$(CC_PATH)nm $@ | grep -v ' U ' | $(AWK) '{ print $$NF }' | grep -F -x '__objcInit' > $(MISC)/$(@:b).strip
1248badc1b4SHerbert Dürr	@$(CC_PATH)strip -i -R $(MISC)/$(@:b).strip -X $@
125cdf0e10cSrcweir	@ls -l $@
126cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-change-install-names.pl \
127cdf0e10cSrcweir        app $(APP1RPATH) $@
128cdf0e10cSrcweir.IF "$(TARGETTYPE)"=="GUI"
129cdf0e10cSrcweir	@echo "Making:   " $(@:f).app
130cdf0e10cSrcweir	@macosx-create-bundle $@
131cdf0e10cSrcweir.ENDIF		# "$(TARGETTYPE)"=="GUI"
132cdf0e10cSrcweir.ELSE		# "$(OS)"=="MACOSX"
133cdf0e10cSrcweir	@echo unx
134cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_1.cmd
135cdf0e10cSrcweir	@echo $(APP1LINKER) $(APP1LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
136cdf0e10cSrcweir	$(APP1OBJS:s/.obj/.o/) '\' >  $(MISC)/$(TARGET).$(@:b)_1.cmd
137cdf0e10cSrcweir	@cat $(mktmp /dev/null $(APP1LIBS)) | xargs -n 1 cat | sed s\#$(ROUT)\#$(OUT)\#g | sed 's#$$# \\#'  >> $(MISC)/$(TARGET).$(@:b)_1.cmd
138cdf0e10cSrcweir	@echo $(APP1LINKTYPEFLAG) $(APP1LIBSALCPPRT) $(APP1STDLIBS) $(APP1STDLIB) $(STDLIB1) -o $@ >> $(MISC)/$(TARGET).$(@:b)_1.cmd
139cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
140cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_1.cmd
141cdf0e10cSrcweir  .ENDIF
142cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_1.cmd
143cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
144cdf0e10cSrcweir	@ls -l $@
145cdf0e10cSrcweir  .ENDIF
146cdf0e10cSrcweir.ENDIF		# "$(OS)"=="MACOSX"
147cdf0e10cSrcweir.ENDIF
148cdf0e10cSrcweir.IF "$(GUI)" == "WNT"
149cdf0e10cSrcweir	@@-$(MKDIR) $(@:d:d)
150cdf0e10cSrcweir.IF "$(APP1LINKRES)" != ""
151cdf0e10cSrcweir	@@-$(RM) $(MISC)/$(APP1LINKRES:b).rc
152cdf0e10cSrcweir.IF "$(APP1ICON)" != ""
153cdf0e10cSrcweir	@-echo 1 ICON $(EMQ)"$(APP1ICON:s/\/\\/)$(EMQ)" >> $(MISC)/$(APP1LINKRES:b).rc
154cdf0e10cSrcweir.ENDIF		# "$(APP1ICON)" != ""
155cdf0e10cSrcweir.IF "$(APP1VERINFO)" != ""
156cdf0e10cSrcweir	@-echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP1LINKRES:b).rc
157cdf0e10cSrcweir	@-echo $(EMQ)#include  $(EMQ)"$(APP1VERINFO)$(EMQ)" >> $(MISC)/$(APP1LINKRES:b).rc
158cdf0e10cSrcweir.ENDIF		# "$(APP1VERINFO)" != ""
159cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -DWIN32 $(APP1PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP1LINKRES:b).rc
160cdf0e10cSrcweir.ENDIF			# "$(APP1LINKRES)" != ""
161cdf0e10cSrcweir.IF "$(COM)" == "GCC"
162cdf0e10cSrcweir	@echo mingw
163cdf0e10cSrcweir.IF "$(APP1LINKRES)" != "" || "$(APP1RES)" != ""
164cdf0e10cSrcweir	@cat $(APP1LINKRES) $(subst,/res/,/res{$(subst,$(BIN), $(@:d))} $(APP1RES)) >  $(MISC)/$(@:b)_all.res
165cdf0e10cSrcweir	windres $(MISC)/$(@:b)_all.res $(APP1RESO)
166cdf0e10cSrcweir.ENDIF
167cdf0e10cSrcweir	@echo $(LINK) $(LINKFLAGS) $(LINKFLAGSAPP) $(MINGWSSTDOBJ) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
168cdf0e10cSrcweir		$(APP1BASEX) $(APP1STACKN) -o $@ $(APP1OBJS) \
169cdf0e10cSrcweir		-Wl,-Map,$(MISC)/$(@:b).map $(STDOBJ) $(APP1RESO) \
170cdf0e10cSrcweir		`$(TYPE) /dev/null $(APP1LIBS) | sed s#$(ROUT)#$(OUT)#g` \
171cdf0e10cSrcweir		$(APP_LINKTYPE) $(APP1LIBSALCPPRT) \
172cdf0e10cSrcweir		-Wl,--start-group $(APP1STDLIBS) -Wl,--end-group $(APP1STDLIB) \
173cdf0e10cSrcweir		$(STDLIB1) $(MINGWSSTDENDOBJ) > $(MISC)/$(TARGET).$(@:b)_1.cmd
174cdf0e10cSrcweir  # need this empty line, else dmake somehow gets confused by the .IFs and .ENDIFs
175cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
176cdf0e10cSrcweir	@$(TYPE)  $(MISC)/$(TARGET).$(@:b)_1.cmd
177cdf0e10cSrcweir  .ENDIF
178cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_1.cmd
179cdf0e10cSrcweir	@ls -l $@
180cdf0e10cSrcweir.ELSE	# "$(COM)" == "GCC"
181cdf0e10cSrcweir.IF "$(linkinc)" == ""
182cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP1LINKER) @$(mktmp \
183cdf0e10cSrcweir		$(APP1LINKFLAGS) \
184cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP1BASEX) \
185cdf0e10cSrcweir		$(APP1STACKN) \
186cdf0e10cSrcweir		-out:$@ \
187cdf0e10cSrcweir		-map:$(MISC)/{$(subst,/,_ $(APP1TARGET)).map} \
188cdf0e10cSrcweir		$(STDOBJ) \
189cdf0e10cSrcweir		$(APP1LINKRES) \
190cdf0e10cSrcweir		$(APP1RES) \
191cdf0e10cSrcweir		$(APP1OBJS) \
192cdf0e10cSrcweir		$(APP1LIBS) \
193cdf0e10cSrcweir		$(APP1STDLIBS) \
194cdf0e10cSrcweir		$(APP1STDLIB) $(STDLIB1) \
195cdf0e10cSrcweir		)
196cdf0e10cSrcweir	@-echo linking $@.manifest ...
197cdf0e10cSrcweir.IF "$(VISTA_MANIFEST)"!=""
198cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -manifest $(TRUSTED_MANIFEST_LOCATION)/trustedinfo.manifest -out:$@.tmanifest$(EMQ) $(FI)
199cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.tmanifest -outputresource:$@$(EMQ);1 $(FI)
200cdf0e10cSrcweir.ELSE
201cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -outputresource:$@$(EMQ);1 $(FI)
202cdf0e10cSrcweir.ENDIF # "$(VISTA_MANIFEST)"!=""
203cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(RM:s/+//) $@.manifest $(FI)
204cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.tmanifest $(THEN) $(RM:s/+//) $@.tmanifest $(FI)
205cdf0e10cSrcweir.ELSE
206cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP1TARGET).lnk
207cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP1TARGET).lst
208cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\linkobj.lst
209cdf0e10cSrcweir		for %_i in ($(MISC)\*.obj) do type %_i >> $(MISC)\linkobj.lst
210cdf0e10cSrcweir	type $(mktmp,$(MISC)\$(APP1TARGET).lst
211cdf0e10cSrcweir		$(APP1LINKFLAGS) \
212cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP1BASEX) \
213cdf0e10cSrcweir		$(APP1STACKN) \
214cdf0e10cSrcweir		-out:$@ \
215cdf0e10cSrcweir		$(STDOBJ) \
216cdf0e10cSrcweir		$(APP1LINKRES) \
217cdf0e10cSrcweir		$(APP1RES) \
218cdf0e10cSrcweir		$(APP1OBJS) \
219cdf0e10cSrcweir		$(APP1LIBS) \
220cdf0e10cSrcweir		$(APP1STDLIBS) \
221cdf0e10cSrcweir		$(APP1STDLIB) $(STDLIB1))
222cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(SED) -e 's/\(\.\.\\\)\{2,4\}/..\\/g' $(MISC)\$(APP1TARGETN:b)_linkobj.lst >> $(MISC)\$(APP1TARGET).lst
223cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(IFEXIST) $(MISC)/$(APP1TARGET).lst $(THEN) type $(MISC)/$(APP1TARGET).lst  >> $(MISC)/$(APP1TARGET).lnk $(FI)
224cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(APP1LINKER) @$(MISC)\$(APP1TARGET).lnk
225cdf0e10cSrcweir.ENDIF		# "$(linkinc)" == ""
226cdf0e10cSrcweir.ENDIF		# "$(COM)" == "GCC"
227cdf0e10cSrcweir.IF "$(APP1TARGET)" == "loader"
228cdf0e10cSrcweir	$(COMMAND_ECHO)$(PERL) loader.pl $@
229cdf0e10cSrcweir	$(COMMAND_ECHO)$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
230cdf0e10cSrcweir	$(COMMAND_ECHO)$(RM) $@
231cdf0e10cSrcweir	$(COMMAND_ECHO)$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
232cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
233cdf0e10cSrcweir
234cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "WNT"
235cdf0e10cSrcweir
236cdf0e10cSrcweir.IF "$(GUI)" == "OS2"
237534c536dSYuri Dario	@+-$(MKDIR) $(@:d:d) > $(NULLDEV)
238cdf0e10cSrcweir.IF "$(APP1LINKRES)" != ""
239534c536dSYuri Dario	@+-$(RM) $(MISC)/$(APP1LINKRES:b).rc > $(NULLDEV)
240cdf0e10cSrcweir.IF "$(APP1ICON)" != ""
241534c536dSYuri Dario	@-+echo ICON 1 $(EMQ)"$(APP1ICON:s#/#\\\\#)$(EMQ)" >> $(MISC)$/$(APP1LINKRES:b).rc
242cdf0e10cSrcweir.ENDIF		# "$(APP1ICON)" != ""
243cdf0e10cSrcweir.IF "$(APP1VERINFO)" != ""
244cdf0e10cSrcweir	@-+echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP1LINKRES:b).rc
245cdf0e10cSrcweir	@-+echo $(EMQ)#include  $(EMQ)"$(APP1VERINFO)$(EMQ)" >> $(MISC)/$(APP1LINKRES:b).rc
246cdf0e10cSrcweir.ENDIF		# "$(APP1VERINFO)" != ""
247cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -r -DOS2 $(APP1PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP1LINKRES:b).rc
248cdf0e10cSrcweir.ENDIF			# "$(APP1LINKRES)" != ""
249cdf0e10cSrcweir
250cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
251cdf0e10cSrcweir	@echo NAME $(APP1TARGET) WINDOWAPI > $(MISC)/$(APP1TARGET).def
252cdf0e10cSrcweir.ENDIF
253cdf0e10cSrcweir
254cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP1LINKER) -v \
255cdf0e10cSrcweir		$(APP1LINKFLAGS) \
256cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP1BASEX) \
257cdf0e10cSrcweir		$(APP1STACKN) \
258cdf0e10cSrcweir		-o $@ \
259cdf0e10cSrcweir		-Zmap -L$(LB) \
260cdf0e10cSrcweir		-L$(SOLARVERSION)/$(INPATH)/lib \
261cdf0e10cSrcweir		$(STDOBJ) \
262cdf0e10cSrcweir		$(APP1LINKRES) \
263cdf0e10cSrcweir		$(APP1RES) \
264cdf0e10cSrcweir		$(APP1DEF) \
265cdf0e10cSrcweir		$(APP1OBJS) \
266cdf0e10cSrcweir		$(APP1LIBS) \
267534c536dSYuri Dario		$(APP1STDLIBS) \
268534c536dSYuri Dario		$(APP1STDLIB) $(STDLIB1)
269cdf0e10cSrcweir
270cdf0e10cSrcweir
271cdf0e10cSrcweir.IF "$(APP1TARGET)" == "loader"
272cdf0e10cSrcweir	$(COMMAND_ECHO)+$(PERL) loader.pl $@
273cdf0e10cSrcweir	$(COMMAND_ECHO)+$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
274cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RM) $@
275cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
276cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
277cdf0e10cSrcweir
278cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "OS2"
279cdf0e10cSrcweir
280cdf0e10cSrcweir.ENDIF			# "$(APP1TARGETN)"!=""
281cdf0e10cSrcweir
282cdf0e10cSrcweir
283cdf0e10cSrcweir# Instruction for linking
284cdf0e10cSrcweir# unroll begin
285cdf0e10cSrcweir
286cdf0e10cSrcweir.IF "$(GUI)" == "OS2" && "$(TARGETTYPE)" == "GUI"
287cdf0e10cSrcweirAPP2DEF = $(MISC)/$(APP2TARGET).def
288cdf0e10cSrcweir.ENDIF
289cdf0e10cSrcweir
290cdf0e10cSrcweir.IF "$(APP2LINKTYPE)" != ""
291cdf0e10cSrcweir#must be either STATIC or SHARED
292cdf0e10cSrcweirAPP2LINKTYPEFLAG=$(APPLINK$(APP2LINKTYPE))
293cdf0e10cSrcweir.ENDIF
294cdf0e10cSrcweir
295cdf0e10cSrcweir# decide how to link
296cdf0e10cSrcweir.IF "$(APP2CODETYPE)"=="C"
297cdf0e10cSrcweirAPP2LINKER=$(LINKC)
298cdf0e10cSrcweirAPP2STDLIB=$(subst,CPPRUNTIME, $(STDLIB))
299cdf0e10cSrcweirAPP2LINKFLAGS+=$(LINKCFLAGS)
300cdf0e10cSrcweir.ELSE			# "$(APP2CODETYPE)"=="C"
301cdf0e10cSrcweirAPP2LINKER=$(LINK)
302cdf0e10cSrcweirAPP2STDLIB=$(subst,CPPRUNTIME,$(STDLIBCPP) $(STDLIB))
303cdf0e10cSrcweirAPP2LINKFLAGS+=$(LINKFLAGS)
304cdf0e10cSrcweir.ENDIF			# "$(APP2CODETYPE)"=="C"
305cdf0e10cSrcweir
306cdf0e10cSrcweirAPP2RPATH*=OOO
307cdf0e10cSrcweirLINKFLAGSRUNPATH_$(APP2RPATH)*=/ERROR:/Bad_APP2RPATH_value
308cdf0e10cSrcweir.IF "$(OS)" != "MACOSX"
309cdf0e10cSrcweirAPP2LINKFLAGS+=$(LINKFLAGSRUNPATH_$(APP2RPATH))
310cdf0e10cSrcweir.ENDIF
311cdf0e10cSrcweir
312cdf0e10cSrcweir.IF "$(APP2STACK)" != ""
313cdf0e10cSrcweir.IF "$(LINKFLAGSTACK)" != ""
314cdf0e10cSrcweirAPP2STACKN=$(LINKFLAGSTACK)$(APP2STACK)
315cdf0e10cSrcweir.ENDIF
316cdf0e10cSrcweir.ELSE
317cdf0e10cSrcweirAPP2STACKN=
318cdf0e10cSrcweir.ENDIF
319cdf0e10cSrcweir
320cdf0e10cSrcweir.IF "$(APP2NOSAL)"==""
321cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
322cdf0e10cSrcweirAPP2OBJS+= $(STDOBJVCL)
323cdf0e10cSrcweir.ENDIF
324cdf0e10cSrcweir.ENDIF
325cdf0e10cSrcweir
326cdf0e10cSrcweir.IF "$(GUI)$(COM)" == "WNTGCC"
327cdf0e10cSrcweirAPP2RESO=
328cdf0e10cSrcweir.IF "$(APP2LINKRES)" != "" || "$(APP2RES)" != ""
329cdf0e10cSrcweirAPP2RESO=$(MISC)/$(APP2TARGET:b)_res.o
330cdf0e10cSrcweir.ENDIF
331cdf0e10cSrcweir.ENDIF
332cdf0e10cSrcweir
333cdf0e10cSrcweir.IF "$(GUI)" == "UNX"
334cdf0e10cSrcweirAPP2DEPN+:=$(APP2DEPNU)
335cdf0e10cSrcweirUSE_APP2DEF=
336cdf0e10cSrcweir.ENDIF
337cdf0e10cSrcweir
338cdf0e10cSrcweir.IF "$(APP2TARGETN)"!=""
339cdf0e10cSrcweir
340cdf0e10cSrcweir.IF "$(APP2PRODUCTNAME)"!=""
341cdf0e10cSrcweirAPP2PRODUCTDEF+:=-DPRODUCT_NAME=\"$(APP2PRODUCTNAME)\"
342cdf0e10cSrcweir.ENDIF			# "$(APP2PRODUCTNAME)"!=""
343cdf0e10cSrcweir
344cdf0e10cSrcweir.IF "$(linkinc)"!=""
345cdf0e10cSrcweir.IF "$(GUI)"=="WNT" || "$(GUI)"=="OS2"
346cdf0e10cSrcweir.IF "$(APP2LIBS)"!=""
347cdf0e10cSrcweir$(MISC)/$(APP2TARGET)_linkinc.ls .PHONY:
348cdf0e10cSrcweir	@@-$(RM) $@
349cdf0e10cSrcweir	sed -f $(SOLARENV)/bin/chrel.sed $(foreach,i,$(APP2LIBS) $(i:s/.lib/.lin/)) >> $@
350cdf0e10cSrcweir.ENDIF          #"$(APP2LIBS)"!=""
351cdf0e10cSrcweir.ENDIF
352cdf0e10cSrcweir
353cdf0e10cSrcweirLINKINCTARGETS+=$(MISC)/$(APP2TARGETN:b)_linkinc.ls
354cdf0e10cSrcweir$(APP2TARGETN) : $(LINKINCTARGETS)
355cdf0e10cSrcweir.ENDIF          # "$(linkinc)"!=""
356cdf0e10cSrcweir
357cdf0e10cSrcweir# Allow for target specific LIBSALCPPRT override
358cdf0e10cSrcweirAPP2LIBSALCPPRT*=$(LIBSALCPPRT)
359cdf0e10cSrcweir
360cdf0e10cSrcweir$(APP2TARGETN): $(APP2OBJS) $(APP2LIBS) \
361cdf0e10cSrcweir	$(APP2RES) \
362cdf0e10cSrcweir	$(APP2ICON) $(APP2DEPN) $(USE_APP2DEF)
363cdf0e10cSrcweir	@echo "Making:   " $(@:f)
364cdf0e10cSrcweir.IF "$(GUI)"=="UNX"
365cdf0e10cSrcweir.IF "$(OS)"=="MACOSX"
366cdf0e10cSrcweir	@echo unx
367cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).list
368cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_2.cmd
369cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).strip
370cdf0e10cSrcweir	@echo $(STDSLO) $(APP2OBJS:s/.obj/.o/) \
371cdf0e10cSrcweir	`cat /dev/null $(APP2LIBS) | sed s\#$(ROUT)\#$(OUT)\#g` | tr -s " " "\n" > $(MISC)/$(@:b).list
372cdf0e10cSrcweir	@echo -n $(APP2LINKER) $(APP2LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) -o $@ \
373cdf0e10cSrcweir	$(APP2LINKTYPEFLAG) $(APP2STDLIBS) $(APP2STDLIB) $(STDLIB2) -filelist $(MISC)/$(@:b).list > $(MISC)/$(TARGET).$(@:b)_2.cmd
374cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-dylib-link-list.pl \
375cdf0e10cSrcweir        `cat $(MISC)/$(TARGET).$(@:b)_2.cmd` \
376cdf0e10cSrcweir        >> $(MISC)/$(TARGET).$(@:b)_2.cmd
377cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
378cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_2.cmd
379cdf0e10cSrcweir  .ENDIF
380cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_2.cmd
381cdf0e10cSrcweir# Need to strip __objcInit symbol to avoid duplicate symbols when loading
382cdf0e10cSrcweir# libraries at runtime
3838badc1b4SHerbert Dürr	@-$(CC_PATH)nm $@ | grep -v ' U ' | $(AWK) '{ print $$NF }' | grep -F -x '__objcInit' > $(MISC)/$(@:b).strip
3848badc1b4SHerbert Dürr	@$(CC_PATH)strip -i -R $(MISC)/$(@:b).strip -X $@
385cdf0e10cSrcweir	@ls -l $@
386cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-change-install-names.pl \
387cdf0e10cSrcweir        app $(APP2RPATH) $@
388cdf0e10cSrcweir.IF "$(TARGETTYPE)"=="GUI"
389cdf0e10cSrcweir	@echo "Making:   " $(@:f).app
390cdf0e10cSrcweir	@macosx-create-bundle $@
391cdf0e10cSrcweir.ENDIF		# "$(TARGETTYPE)"=="GUI"
392cdf0e10cSrcweir.ELSE		# "$(OS)"=="MACOSX"
393cdf0e10cSrcweir	@echo unx
394cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_2.cmd
395cdf0e10cSrcweir	@echo $(APP2LINKER) $(APP2LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
396cdf0e10cSrcweir	$(APP2OBJS:s/.obj/.o/) '\' >  $(MISC)/$(TARGET).$(@:b)_2.cmd
397cdf0e10cSrcweir	@cat $(mktmp /dev/null $(APP2LIBS)) | xargs -n 1 cat | sed s\#$(ROUT)\#$(OUT)\#g | sed 's#$$# \\#'  >> $(MISC)/$(TARGET).$(@:b)_2.cmd
398cdf0e10cSrcweir	@echo $(APP2LINKTYPEFLAG) $(APP2LIBSALCPPRT) $(APP2STDLIBS) $(APP2STDLIB) $(STDLIB2) -o $@ >> $(MISC)/$(TARGET).$(@:b)_2.cmd
399cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
400cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_2.cmd
401cdf0e10cSrcweir  .ENDIF
402cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_2.cmd
403cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
404cdf0e10cSrcweir	@ls -l $@
405cdf0e10cSrcweir  .ENDIF
406cdf0e10cSrcweir.ENDIF		# "$(OS)"=="MACOSX"
407cdf0e10cSrcweir.ENDIF
408cdf0e10cSrcweir.IF "$(GUI)" == "WNT"
409cdf0e10cSrcweir	@@-$(MKDIR) $(@:d:d)
410cdf0e10cSrcweir.IF "$(APP2LINKRES)" != ""
411cdf0e10cSrcweir	@@-$(RM) $(MISC)/$(APP2LINKRES:b).rc
412cdf0e10cSrcweir.IF "$(APP2ICON)" != ""
413cdf0e10cSrcweir	@-echo 1 ICON $(EMQ)"$(APP2ICON:s/\/\\/)$(EMQ)" >> $(MISC)/$(APP2LINKRES:b).rc
414cdf0e10cSrcweir.ENDIF		# "$(APP2ICON)" != ""
415cdf0e10cSrcweir.IF "$(APP2VERINFO)" != ""
416cdf0e10cSrcweir	@-echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP2LINKRES:b).rc
417cdf0e10cSrcweir	@-echo $(EMQ)#include  $(EMQ)"$(APP2VERINFO)$(EMQ)" >> $(MISC)/$(APP2LINKRES:b).rc
418cdf0e10cSrcweir.ENDIF		# "$(APP2VERINFO)" != ""
419cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -DWIN32 $(APP2PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP2LINKRES:b).rc
420cdf0e10cSrcweir.ENDIF			# "$(APP2LINKRES)" != ""
421cdf0e10cSrcweir.IF "$(COM)" == "GCC"
422cdf0e10cSrcweir	@echo mingw
423cdf0e10cSrcweir.IF "$(APP2LINKRES)" != "" || "$(APP2RES)" != ""
424cdf0e10cSrcweir	@cat $(APP2LINKRES) $(subst,/res/,/res{$(subst,$(BIN), $(@:d))} $(APP2RES)) >  $(MISC)/$(@:b)_all.res
425cdf0e10cSrcweir	windres $(MISC)/$(@:b)_all.res $(APP2RESO)
426cdf0e10cSrcweir.ENDIF
427cdf0e10cSrcweir	@echo $(LINK) $(LINKFLAGS) $(LINKFLAGSAPP) $(MINGWSSTDOBJ) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
428cdf0e10cSrcweir		$(APP2BASEX) $(APP2STACKN) -o $@ $(APP2OBJS) \
429cdf0e10cSrcweir		-Wl,-Map,$(MISC)/$(@:b).map $(STDOBJ) $(APP2RESO) \
430cdf0e10cSrcweir		`$(TYPE) /dev/null $(APP2LIBS) | sed s#$(ROUT)#$(OUT)#g` \
431cdf0e10cSrcweir		$(APP_LINKTYPE) $(APP2LIBSALCPPRT) \
432cdf0e10cSrcweir		-Wl,--start-group $(APP2STDLIBS) -Wl,--end-group $(APP2STDLIB) \
433cdf0e10cSrcweir		$(STDLIB2) $(MINGWSSTDENDOBJ) > $(MISC)/$(TARGET).$(@:b)_2.cmd
434cdf0e10cSrcweir  # need this empty line, else dmake somehow gets confused by the .IFs and .ENDIFs
435cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
436cdf0e10cSrcweir	@$(TYPE)  $(MISC)/$(TARGET).$(@:b)_2.cmd
437cdf0e10cSrcweir  .ENDIF
438cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_2.cmd
439cdf0e10cSrcweir	@ls -l $@
440cdf0e10cSrcweir.ELSE	# "$(COM)" == "GCC"
441cdf0e10cSrcweir.IF "$(linkinc)" == ""
442cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP2LINKER) @$(mktmp \
443cdf0e10cSrcweir		$(APP2LINKFLAGS) \
444cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP2BASEX) \
445cdf0e10cSrcweir		$(APP2STACKN) \
446cdf0e10cSrcweir		-out:$@ \
447cdf0e10cSrcweir		-map:$(MISC)/{$(subst,/,_ $(APP2TARGET)).map} \
448cdf0e10cSrcweir		$(STDOBJ) \
449cdf0e10cSrcweir		$(APP2LINKRES) \
450cdf0e10cSrcweir		$(APP2RES) \
451cdf0e10cSrcweir		$(APP2OBJS) \
452cdf0e10cSrcweir		$(APP2LIBS) \
453cdf0e10cSrcweir		$(APP2STDLIBS) \
454cdf0e10cSrcweir		$(APP2STDLIB) $(STDLIB2) \
455cdf0e10cSrcweir		)
456cdf0e10cSrcweir	@-echo linking $@.manifest ...
457cdf0e10cSrcweir.IF "$(VISTA_MANIFEST)"!=""
458cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -manifest $(TRUSTED_MANIFEST_LOCATION)/trustedinfo.manifest -out:$@.tmanifest$(EMQ) $(FI)
459cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.tmanifest -outputresource:$@$(EMQ);1 $(FI)
460cdf0e10cSrcweir.ELSE
461cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -outputresource:$@$(EMQ);1 $(FI)
462cdf0e10cSrcweir.ENDIF # "$(VISTA_MANIFEST)"!=""
463cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(RM:s/+//) $@.manifest $(FI)
464cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.tmanifest $(THEN) $(RM:s/+//) $@.tmanifest $(FI)
465cdf0e10cSrcweir.ELSE
466cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP2TARGET).lnk
467cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP2TARGET).lst
468cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\linkobj.lst
469cdf0e10cSrcweir		for %_i in ($(MISC)\*.obj) do type %_i >> $(MISC)\linkobj.lst
470cdf0e10cSrcweir	type $(mktmp,$(MISC)\$(APP2TARGET).lst
471cdf0e10cSrcweir		$(APP2LINKFLAGS) \
472cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP2BASEX) \
473cdf0e10cSrcweir		$(APP2STACKN) \
474cdf0e10cSrcweir		-out:$@ \
475cdf0e10cSrcweir		$(STDOBJ) \
476cdf0e10cSrcweir		$(APP2LINKRES) \
477cdf0e10cSrcweir		$(APP2RES) \
478cdf0e10cSrcweir		$(APP2OBJS) \
479cdf0e10cSrcweir		$(APP2LIBS) \
480cdf0e10cSrcweir		$(APP2STDLIBS) \
481cdf0e10cSrcweir		$(APP2STDLIB) $(STDLIB2))
482cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(SED) -e 's/\(\.\.\\\)\{2,4\}/..\\/g' $(MISC)\$(APP2TARGETN:b)_linkobj.lst >> $(MISC)\$(APP2TARGET).lst
483cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(IFEXIST) $(MISC)/$(APP2TARGET).lst $(THEN) type $(MISC)/$(APP2TARGET).lst  >> $(MISC)/$(APP2TARGET).lnk $(FI)
484cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(APP2LINKER) @$(MISC)\$(APP2TARGET).lnk
485cdf0e10cSrcweir.ENDIF		# "$(linkinc)" == ""
486cdf0e10cSrcweir.ENDIF		# "$(COM)" == "GCC"
487cdf0e10cSrcweir.IF "$(APP2TARGET)" == "loader"
488cdf0e10cSrcweir	$(COMMAND_ECHO)$(PERL) loader.pl $@
489cdf0e10cSrcweir	$(COMMAND_ECHO)$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
490cdf0e10cSrcweir	$(COMMAND_ECHO)$(RM) $@
491cdf0e10cSrcweir	$(COMMAND_ECHO)$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
492cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
493cdf0e10cSrcweir
494cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "WNT"
495cdf0e10cSrcweir
496cdf0e10cSrcweir.IF "$(GUI)" == "OS2"
497534c536dSYuri Dario	@+-$(MKDIR) $(@:d:d) > $(NULLDEV)
498cdf0e10cSrcweir.IF "$(APP2LINKRES)" != ""
499534c536dSYuri Dario	@+-$(RM) $(MISC)/$(APP2LINKRES:b).rc > $(NULLDEV)
500cdf0e10cSrcweir.IF "$(APP2ICON)" != ""
501534c536dSYuri Dario	@-+echo ICON 1 $(EMQ)"$(APP2ICON:s#/#\\\\#)$(EMQ)" >> $(MISC)$/$(APP2LINKRES:b).rc
502cdf0e10cSrcweir.ENDIF		# "$(APP2ICON)" != ""
503cdf0e10cSrcweir.IF "$(APP2VERINFO)" != ""
504cdf0e10cSrcweir	@-+echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP2LINKRES:b).rc
505cdf0e10cSrcweir	@-+echo $(EMQ)#include  $(EMQ)"$(APP2VERINFO)$(EMQ)" >> $(MISC)/$(APP2LINKRES:b).rc
506cdf0e10cSrcweir.ENDIF		# "$(APP2VERINFO)" != ""
507cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -r -DOS2 $(APP2PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP2LINKRES:b).rc
508cdf0e10cSrcweir.ENDIF			# "$(APP2LINKRES)" != ""
509cdf0e10cSrcweir
510cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
511cdf0e10cSrcweir	@echo NAME $(APP2TARGET) WINDOWAPI > $(MISC)/$(APP2TARGET).def
512cdf0e10cSrcweir.ENDIF
513cdf0e10cSrcweir
514cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP2LINKER) -v \
515cdf0e10cSrcweir		$(APP2LINKFLAGS) \
516cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP2BASEX) \
517cdf0e10cSrcweir		$(APP2STACKN) \
518cdf0e10cSrcweir		-o $@ \
519cdf0e10cSrcweir		-Zmap -L$(LB) \
520cdf0e10cSrcweir		-L$(SOLARVERSION)/$(INPATH)/lib \
521cdf0e10cSrcweir		$(STDOBJ) \
522cdf0e10cSrcweir		$(APP2LINKRES) \
523cdf0e10cSrcweir		$(APP2RES) \
524cdf0e10cSrcweir		$(APP2DEF) \
525cdf0e10cSrcweir		$(APP2OBJS) \
526cdf0e10cSrcweir		$(APP2LIBS) \
527534c536dSYuri Dario		$(APP2STDLIBS) \
528534c536dSYuri Dario		$(APP2STDLIB) $(STDLIB2)
529cdf0e10cSrcweir
530cdf0e10cSrcweir
531cdf0e10cSrcweir.IF "$(APP2TARGET)" == "loader"
532cdf0e10cSrcweir	$(COMMAND_ECHO)+$(PERL) loader.pl $@
533cdf0e10cSrcweir	$(COMMAND_ECHO)+$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
534cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RM) $@
535cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
536cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
537cdf0e10cSrcweir
538cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "OS2"
539cdf0e10cSrcweir
540cdf0e10cSrcweir.ENDIF			# "$(APP2TARGETN)"!=""
541cdf0e10cSrcweir
542cdf0e10cSrcweir
543cdf0e10cSrcweir# Instruction for linking
544cdf0e10cSrcweir# unroll begin
545cdf0e10cSrcweir
546cdf0e10cSrcweir.IF "$(GUI)" == "OS2" && "$(TARGETTYPE)" == "GUI"
547cdf0e10cSrcweirAPP3DEF = $(MISC)/$(APP3TARGET).def
548cdf0e10cSrcweir.ENDIF
549cdf0e10cSrcweir
550cdf0e10cSrcweir.IF "$(APP3LINKTYPE)" != ""
551cdf0e10cSrcweir#must be either STATIC or SHARED
552cdf0e10cSrcweirAPP3LINKTYPEFLAG=$(APPLINK$(APP3LINKTYPE))
553cdf0e10cSrcweir.ENDIF
554cdf0e10cSrcweir
555cdf0e10cSrcweir# decide how to link
556cdf0e10cSrcweir.IF "$(APP3CODETYPE)"=="C"
557cdf0e10cSrcweirAPP3LINKER=$(LINKC)
558cdf0e10cSrcweirAPP3STDLIB=$(subst,CPPRUNTIME, $(STDLIB))
559cdf0e10cSrcweirAPP3LINKFLAGS+=$(LINKCFLAGS)
560cdf0e10cSrcweir.ELSE			# "$(APP3CODETYPE)"=="C"
561cdf0e10cSrcweirAPP3LINKER=$(LINK)
562cdf0e10cSrcweirAPP3STDLIB=$(subst,CPPRUNTIME,$(STDLIBCPP) $(STDLIB))
563cdf0e10cSrcweirAPP3LINKFLAGS+=$(LINKFLAGS)
564cdf0e10cSrcweir.ENDIF			# "$(APP3CODETYPE)"=="C"
565cdf0e10cSrcweir
566cdf0e10cSrcweirAPP3RPATH*=OOO
567cdf0e10cSrcweirLINKFLAGSRUNPATH_$(APP3RPATH)*=/ERROR:/Bad_APP3RPATH_value
568cdf0e10cSrcweir.IF "$(OS)" != "MACOSX"
569cdf0e10cSrcweirAPP3LINKFLAGS+=$(LINKFLAGSRUNPATH_$(APP3RPATH))
570cdf0e10cSrcweir.ENDIF
571cdf0e10cSrcweir
572cdf0e10cSrcweir.IF "$(APP3STACK)" != ""
573cdf0e10cSrcweir.IF "$(LINKFLAGSTACK)" != ""
574cdf0e10cSrcweirAPP3STACKN=$(LINKFLAGSTACK)$(APP3STACK)
575cdf0e10cSrcweir.ENDIF
576cdf0e10cSrcweir.ELSE
577cdf0e10cSrcweirAPP3STACKN=
578cdf0e10cSrcweir.ENDIF
579cdf0e10cSrcweir
580cdf0e10cSrcweir.IF "$(APP3NOSAL)"==""
581cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
582cdf0e10cSrcweirAPP3OBJS+= $(STDOBJVCL)
583cdf0e10cSrcweir.ENDIF
584cdf0e10cSrcweir.ENDIF
585cdf0e10cSrcweir
586cdf0e10cSrcweir.IF "$(GUI)$(COM)" == "WNTGCC"
587cdf0e10cSrcweirAPP3RESO=
588cdf0e10cSrcweir.IF "$(APP3LINKRES)" != "" || "$(APP3RES)" != ""
589cdf0e10cSrcweirAPP3RESO=$(MISC)/$(APP3TARGET:b)_res.o
590cdf0e10cSrcweir.ENDIF
591cdf0e10cSrcweir.ENDIF
592cdf0e10cSrcweir
593cdf0e10cSrcweir.IF "$(GUI)" == "UNX"
594cdf0e10cSrcweirAPP3DEPN+:=$(APP3DEPNU)
595cdf0e10cSrcweirUSE_APP3DEF=
596cdf0e10cSrcweir.ENDIF
597cdf0e10cSrcweir
598cdf0e10cSrcweir.IF "$(APP3TARGETN)"!=""
599cdf0e10cSrcweir
600cdf0e10cSrcweir.IF "$(APP3PRODUCTNAME)"!=""
601cdf0e10cSrcweirAPP3PRODUCTDEF+:=-DPRODUCT_NAME=\"$(APP3PRODUCTNAME)\"
602cdf0e10cSrcweir.ENDIF			# "$(APP3PRODUCTNAME)"!=""
603cdf0e10cSrcweir
604cdf0e10cSrcweir.IF "$(linkinc)"!=""
605cdf0e10cSrcweir.IF "$(GUI)"=="WNT" || "$(GUI)"=="OS2"
606cdf0e10cSrcweir.IF "$(APP3LIBS)"!=""
607cdf0e10cSrcweir$(MISC)/$(APP3TARGET)_linkinc.ls .PHONY:
608cdf0e10cSrcweir	@@-$(RM) $@
609cdf0e10cSrcweir	sed -f $(SOLARENV)/bin/chrel.sed $(foreach,i,$(APP3LIBS) $(i:s/.lib/.lin/)) >> $@
610cdf0e10cSrcweir.ENDIF          #"$(APP3LIBS)"!=""
611cdf0e10cSrcweir.ENDIF
612cdf0e10cSrcweir
613cdf0e10cSrcweirLINKINCTARGETS+=$(MISC)/$(APP3TARGETN:b)_linkinc.ls
614cdf0e10cSrcweir$(APP3TARGETN) : $(LINKINCTARGETS)
615cdf0e10cSrcweir.ENDIF          # "$(linkinc)"!=""
616cdf0e10cSrcweir
617cdf0e10cSrcweir# Allow for target specific LIBSALCPPRT override
618cdf0e10cSrcweirAPP3LIBSALCPPRT*=$(LIBSALCPPRT)
619cdf0e10cSrcweir
620cdf0e10cSrcweir$(APP3TARGETN): $(APP3OBJS) $(APP3LIBS) \
621cdf0e10cSrcweir	$(APP3RES) \
622cdf0e10cSrcweir	$(APP3ICON) $(APP3DEPN) $(USE_APP3DEF)
623cdf0e10cSrcweir	@echo "Making:   " $(@:f)
624cdf0e10cSrcweir.IF "$(GUI)"=="UNX"
625cdf0e10cSrcweir.IF "$(OS)"=="MACOSX"
626cdf0e10cSrcweir	@echo unx
627cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).list
628cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_3.cmd
629cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).strip
630cdf0e10cSrcweir	@echo $(STDSLO) $(APP3OBJS:s/.obj/.o/) \
631cdf0e10cSrcweir	`cat /dev/null $(APP3LIBS) | sed s\#$(ROUT)\#$(OUT)\#g` | tr -s " " "\n" > $(MISC)/$(@:b).list
632cdf0e10cSrcweir	@echo -n $(APP3LINKER) $(APP3LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) -o $@ \
633cdf0e10cSrcweir	$(APP3LINKTYPEFLAG) $(APP3STDLIBS) $(APP3STDLIB) $(STDLIB3) -filelist $(MISC)/$(@:b).list > $(MISC)/$(TARGET).$(@:b)_3.cmd
634cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-dylib-link-list.pl \
635cdf0e10cSrcweir        `cat $(MISC)/$(TARGET).$(@:b)_3.cmd` \
636cdf0e10cSrcweir        >> $(MISC)/$(TARGET).$(@:b)_3.cmd
637cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
638cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_3.cmd
639cdf0e10cSrcweir  .ENDIF
640cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_3.cmd
641cdf0e10cSrcweir# Need to strip __objcInit symbol to avoid duplicate symbols when loading
642cdf0e10cSrcweir# libraries at runtime
6438badc1b4SHerbert Dürr	@-$(CC_PATH)nm $@ | grep -v ' U ' | $(AWK) '{ print $$NF }' | grep -F -x '__objcInit' > $(MISC)/$(@:b).strip
6448badc1b4SHerbert Dürr	@$(CC_PATH)strip -i -R $(MISC)/$(@:b).strip -X $@
645cdf0e10cSrcweir	@ls -l $@
646cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-change-install-names.pl \
647cdf0e10cSrcweir        app $(APP3RPATH) $@
648cdf0e10cSrcweir.IF "$(TARGETTYPE)"=="GUI"
649cdf0e10cSrcweir	@echo "Making:   " $(@:f).app
650cdf0e10cSrcweir	@macosx-create-bundle $@
651cdf0e10cSrcweir.ENDIF		# "$(TARGETTYPE)"=="GUI"
652cdf0e10cSrcweir.ELSE		# "$(OS)"=="MACOSX"
653cdf0e10cSrcweir	@echo unx
654cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_3.cmd
655cdf0e10cSrcweir	@echo $(APP3LINKER) $(APP3LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
656cdf0e10cSrcweir	$(APP3OBJS:s/.obj/.o/) '\' >  $(MISC)/$(TARGET).$(@:b)_3.cmd
657cdf0e10cSrcweir	@cat $(mktmp /dev/null $(APP3LIBS)) | xargs -n 1 cat | sed s\#$(ROUT)\#$(OUT)\#g | sed 's#$$# \\#'  >> $(MISC)/$(TARGET).$(@:b)_3.cmd
658cdf0e10cSrcweir	@echo $(APP3LINKTYPEFLAG) $(APP3LIBSALCPPRT) $(APP3STDLIBS) $(APP3STDLIB) $(STDLIB3) -o $@ >> $(MISC)/$(TARGET).$(@:b)_3.cmd
659cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
660cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_3.cmd
661cdf0e10cSrcweir  .ENDIF
662cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_3.cmd
663cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
664cdf0e10cSrcweir	@ls -l $@
665cdf0e10cSrcweir  .ENDIF
666cdf0e10cSrcweir.ENDIF		# "$(OS)"=="MACOSX"
667cdf0e10cSrcweir.ENDIF
668cdf0e10cSrcweir.IF "$(GUI)" == "WNT"
669cdf0e10cSrcweir	@@-$(MKDIR) $(@:d:d)
670cdf0e10cSrcweir.IF "$(APP3LINKRES)" != ""
671cdf0e10cSrcweir	@@-$(RM) $(MISC)/$(APP3LINKRES:b).rc
672cdf0e10cSrcweir.IF "$(APP3ICON)" != ""
673cdf0e10cSrcweir	@-echo 1 ICON $(EMQ)"$(APP3ICON:s/\/\\/)$(EMQ)" >> $(MISC)/$(APP3LINKRES:b).rc
674cdf0e10cSrcweir.ENDIF		# "$(APP3ICON)" != ""
675cdf0e10cSrcweir.IF "$(APP3VERINFO)" != ""
676cdf0e10cSrcweir	@-echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP3LINKRES:b).rc
677cdf0e10cSrcweir	@-echo $(EMQ)#include  $(EMQ)"$(APP3VERINFO)$(EMQ)" >> $(MISC)/$(APP3LINKRES:b).rc
678cdf0e10cSrcweir.ENDIF		# "$(APP3VERINFO)" != ""
679cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -DWIN32 $(APP3PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP3LINKRES:b).rc
680cdf0e10cSrcweir.ENDIF			# "$(APP3LINKRES)" != ""
681cdf0e10cSrcweir.IF "$(COM)" == "GCC"
682cdf0e10cSrcweir	@echo mingw
683cdf0e10cSrcweir.IF "$(APP3LINKRES)" != "" || "$(APP3RES)" != ""
684cdf0e10cSrcweir	@cat $(APP3LINKRES) $(subst,/res/,/res{$(subst,$(BIN), $(@:d))} $(APP3RES)) >  $(MISC)/$(@:b)_all.res
685cdf0e10cSrcweir	windres $(MISC)/$(@:b)_all.res $(APP3RESO)
686cdf0e10cSrcweir.ENDIF
687cdf0e10cSrcweir	@echo $(LINK) $(LINKFLAGS) $(LINKFLAGSAPP) $(MINGWSSTDOBJ) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
688cdf0e10cSrcweir		$(APP3BASEX) $(APP3STACKN) -o $@ $(APP3OBJS) \
689cdf0e10cSrcweir		-Wl,-Map,$(MISC)/$(@:b).map $(STDOBJ) $(APP3RESO) \
690cdf0e10cSrcweir		`$(TYPE) /dev/null $(APP3LIBS) | sed s#$(ROUT)#$(OUT)#g` \
691cdf0e10cSrcweir		$(APP_LINKTYPE) $(APP3LIBSALCPPRT) \
692cdf0e10cSrcweir		-Wl,--start-group $(APP3STDLIBS) -Wl,--end-group $(APP3STDLIB) \
693cdf0e10cSrcweir		$(STDLIB3) $(MINGWSSTDENDOBJ) > $(MISC)/$(TARGET).$(@:b)_3.cmd
694cdf0e10cSrcweir  # need this empty line, else dmake somehow gets confused by the .IFs and .ENDIFs
695cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
696cdf0e10cSrcweir	@$(TYPE)  $(MISC)/$(TARGET).$(@:b)_3.cmd
697cdf0e10cSrcweir  .ENDIF
698cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_3.cmd
699cdf0e10cSrcweir	@ls -l $@
700cdf0e10cSrcweir.ELSE	# "$(COM)" == "GCC"
701cdf0e10cSrcweir.IF "$(linkinc)" == ""
702cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP3LINKER) @$(mktmp \
703cdf0e10cSrcweir		$(APP3LINKFLAGS) \
704cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP3BASEX) \
705cdf0e10cSrcweir		$(APP3STACKN) \
706cdf0e10cSrcweir		-out:$@ \
707cdf0e10cSrcweir		-map:$(MISC)/{$(subst,/,_ $(APP3TARGET)).map} \
708cdf0e10cSrcweir		$(STDOBJ) \
709cdf0e10cSrcweir		$(APP3LINKRES) \
710cdf0e10cSrcweir		$(APP3RES) \
711cdf0e10cSrcweir		$(APP3OBJS) \
712cdf0e10cSrcweir		$(APP3LIBS) \
713cdf0e10cSrcweir		$(APP3STDLIBS) \
714cdf0e10cSrcweir		$(APP3STDLIB) $(STDLIB3) \
715cdf0e10cSrcweir		)
716cdf0e10cSrcweir	@-echo linking $@.manifest ...
717cdf0e10cSrcweir.IF "$(VISTA_MANIFEST)"!=""
718cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -manifest $(TRUSTED_MANIFEST_LOCATION)/trustedinfo.manifest -out:$@.tmanifest$(EMQ) $(FI)
719cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.tmanifest -outputresource:$@$(EMQ);1 $(FI)
720cdf0e10cSrcweir.ELSE
721cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -outputresource:$@$(EMQ);1 $(FI)
722cdf0e10cSrcweir.ENDIF # "$(VISTA_MANIFEST)"!=""
723cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(RM:s/+//) $@.manifest $(FI)
724cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.tmanifest $(THEN) $(RM:s/+//) $@.tmanifest $(FI)
725cdf0e10cSrcweir.ELSE
726cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP3TARGET).lnk
727cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP3TARGET).lst
728cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\linkobj.lst
729cdf0e10cSrcweir		for %_i in ($(MISC)\*.obj) do type %_i >> $(MISC)\linkobj.lst
730cdf0e10cSrcweir	type $(mktmp,$(MISC)\$(APP3TARGET).lst
731cdf0e10cSrcweir		$(APP3LINKFLAGS) \
732cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP3BASEX) \
733cdf0e10cSrcweir		$(APP3STACKN) \
734cdf0e10cSrcweir		-out:$@ \
735cdf0e10cSrcweir		$(STDOBJ) \
736cdf0e10cSrcweir		$(APP3LINKRES) \
737cdf0e10cSrcweir		$(APP3RES) \
738cdf0e10cSrcweir		$(APP3OBJS) \
739cdf0e10cSrcweir		$(APP3LIBS) \
740cdf0e10cSrcweir		$(APP3STDLIBS) \
741cdf0e10cSrcweir		$(APP3STDLIB) $(STDLIB3))
742cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(SED) -e 's/\(\.\.\\\)\{2,4\}/..\\/g' $(MISC)\$(APP3TARGETN:b)_linkobj.lst >> $(MISC)\$(APP3TARGET).lst
743cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(IFEXIST) $(MISC)/$(APP3TARGET).lst $(THEN) type $(MISC)/$(APP3TARGET).lst  >> $(MISC)/$(APP3TARGET).lnk $(FI)
744cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(APP3LINKER) @$(MISC)\$(APP3TARGET).lnk
745cdf0e10cSrcweir.ENDIF		# "$(linkinc)" == ""
746cdf0e10cSrcweir.ENDIF		# "$(COM)" == "GCC"
747cdf0e10cSrcweir.IF "$(APP3TARGET)" == "loader"
748cdf0e10cSrcweir	$(COMMAND_ECHO)$(PERL) loader.pl $@
749cdf0e10cSrcweir	$(COMMAND_ECHO)$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
750cdf0e10cSrcweir	$(COMMAND_ECHO)$(RM) $@
751cdf0e10cSrcweir	$(COMMAND_ECHO)$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
752cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
753cdf0e10cSrcweir
754cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "WNT"
755cdf0e10cSrcweir
756cdf0e10cSrcweir.IF "$(GUI)" == "OS2"
757534c536dSYuri Dario	@+-$(MKDIR) $(@:d:d) > $(NULLDEV)
758cdf0e10cSrcweir.IF "$(APP3LINKRES)" != ""
759534c536dSYuri Dario	@+-$(RM) $(MISC)/$(APP3LINKRES:b).rc > $(NULLDEV)
760cdf0e10cSrcweir.IF "$(APP3ICON)" != ""
761534c536dSYuri Dario	@-+echo ICON 1 $(EMQ)"$(APP3ICON:s#/#\\\\#)$(EMQ)" >> $(MISC)$/$(APP3LINKRES:b).rc
762cdf0e10cSrcweir.ENDIF		# "$(APP3ICON)" != ""
763cdf0e10cSrcweir.IF "$(APP3VERINFO)" != ""
764cdf0e10cSrcweir	@-+echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP3LINKRES:b).rc
765cdf0e10cSrcweir	@-+echo $(EMQ)#include  $(EMQ)"$(APP3VERINFO)$(EMQ)" >> $(MISC)/$(APP3LINKRES:b).rc
766cdf0e10cSrcweir.ENDIF		# "$(APP3VERINFO)" != ""
767cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -r -DOS2 $(APP3PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP3LINKRES:b).rc
768cdf0e10cSrcweir.ENDIF			# "$(APP3LINKRES)" != ""
769cdf0e10cSrcweir
770cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
771cdf0e10cSrcweir	@echo NAME $(APP3TARGET) WINDOWAPI > $(MISC)/$(APP3TARGET).def
772cdf0e10cSrcweir.ENDIF
773cdf0e10cSrcweir
774cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP3LINKER) -v \
775cdf0e10cSrcweir		$(APP3LINKFLAGS) \
776cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP3BASEX) \
777cdf0e10cSrcweir		$(APP3STACKN) \
778cdf0e10cSrcweir		-o $@ \
779cdf0e10cSrcweir		-Zmap -L$(LB) \
780cdf0e10cSrcweir		-L$(SOLARVERSION)/$(INPATH)/lib \
781cdf0e10cSrcweir		$(STDOBJ) \
782cdf0e10cSrcweir		$(APP3LINKRES) \
783cdf0e10cSrcweir		$(APP3RES) \
784cdf0e10cSrcweir		$(APP3DEF) \
785cdf0e10cSrcweir		$(APP3OBJS) \
786cdf0e10cSrcweir		$(APP3LIBS) \
787534c536dSYuri Dario		$(APP3STDLIBS) \
788534c536dSYuri Dario		$(APP3STDLIB) $(STDLIB3)
789cdf0e10cSrcweir
790cdf0e10cSrcweir
791cdf0e10cSrcweir.IF "$(APP3TARGET)" == "loader"
792cdf0e10cSrcweir	$(COMMAND_ECHO)+$(PERL) loader.pl $@
793cdf0e10cSrcweir	$(COMMAND_ECHO)+$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
794cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RM) $@
795cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
796cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
797cdf0e10cSrcweir
798cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "OS2"
799cdf0e10cSrcweir
800cdf0e10cSrcweir.ENDIF			# "$(APP3TARGETN)"!=""
801cdf0e10cSrcweir
802cdf0e10cSrcweir
803cdf0e10cSrcweir# Instruction for linking
804cdf0e10cSrcweir# unroll begin
805cdf0e10cSrcweir
806cdf0e10cSrcweir.IF "$(GUI)" == "OS2" && "$(TARGETTYPE)" == "GUI"
807cdf0e10cSrcweirAPP4DEF = $(MISC)/$(APP4TARGET).def
808cdf0e10cSrcweir.ENDIF
809cdf0e10cSrcweir
810cdf0e10cSrcweir.IF "$(APP4LINKTYPE)" != ""
811cdf0e10cSrcweir#must be either STATIC or SHARED
812cdf0e10cSrcweirAPP4LINKTYPEFLAG=$(APPLINK$(APP4LINKTYPE))
813cdf0e10cSrcweir.ENDIF
814cdf0e10cSrcweir
815cdf0e10cSrcweir# decide how to link
816cdf0e10cSrcweir.IF "$(APP4CODETYPE)"=="C"
817cdf0e10cSrcweirAPP4LINKER=$(LINKC)
818cdf0e10cSrcweirAPP4STDLIB=$(subst,CPPRUNTIME, $(STDLIB))
819cdf0e10cSrcweirAPP4LINKFLAGS+=$(LINKCFLAGS)
820cdf0e10cSrcweir.ELSE			# "$(APP4CODETYPE)"=="C"
821cdf0e10cSrcweirAPP4LINKER=$(LINK)
822cdf0e10cSrcweirAPP4STDLIB=$(subst,CPPRUNTIME,$(STDLIBCPP) $(STDLIB))
823cdf0e10cSrcweirAPP4LINKFLAGS+=$(LINKFLAGS)
824cdf0e10cSrcweir.ENDIF			# "$(APP4CODETYPE)"=="C"
825cdf0e10cSrcweir
826cdf0e10cSrcweirAPP4RPATH*=OOO
827cdf0e10cSrcweirLINKFLAGSRUNPATH_$(APP4RPATH)*=/ERROR:/Bad_APP4RPATH_value
828cdf0e10cSrcweir.IF "$(OS)" != "MACOSX"
829cdf0e10cSrcweirAPP4LINKFLAGS+=$(LINKFLAGSRUNPATH_$(APP4RPATH))
830cdf0e10cSrcweir.ENDIF
831cdf0e10cSrcweir
832cdf0e10cSrcweir.IF "$(APP4STACK)" != ""
833cdf0e10cSrcweir.IF "$(LINKFLAGSTACK)" != ""
834cdf0e10cSrcweirAPP4STACKN=$(LINKFLAGSTACK)$(APP4STACK)
835cdf0e10cSrcweir.ENDIF
836cdf0e10cSrcweir.ELSE
837cdf0e10cSrcweirAPP4STACKN=
838cdf0e10cSrcweir.ENDIF
839cdf0e10cSrcweir
840cdf0e10cSrcweir.IF "$(APP4NOSAL)"==""
841cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
842cdf0e10cSrcweirAPP4OBJS+= $(STDOBJVCL)
843cdf0e10cSrcweir.ENDIF
844cdf0e10cSrcweir.ENDIF
845cdf0e10cSrcweir
846cdf0e10cSrcweir.IF "$(GUI)$(COM)" == "WNTGCC"
847cdf0e10cSrcweirAPP4RESO=
848cdf0e10cSrcweir.IF "$(APP4LINKRES)" != "" || "$(APP4RES)" != ""
849cdf0e10cSrcweirAPP4RESO=$(MISC)/$(APP4TARGET:b)_res.o
850cdf0e10cSrcweir.ENDIF
851cdf0e10cSrcweir.ENDIF
852cdf0e10cSrcweir
853cdf0e10cSrcweir.IF "$(GUI)" == "UNX"
854cdf0e10cSrcweirAPP4DEPN+:=$(APP4DEPNU)
855cdf0e10cSrcweirUSE_APP4DEF=
856cdf0e10cSrcweir.ENDIF
857cdf0e10cSrcweir
858cdf0e10cSrcweir.IF "$(APP4TARGETN)"!=""
859cdf0e10cSrcweir
860cdf0e10cSrcweir.IF "$(APP4PRODUCTNAME)"!=""
861cdf0e10cSrcweirAPP4PRODUCTDEF+:=-DPRODUCT_NAME=\"$(APP4PRODUCTNAME)\"
862cdf0e10cSrcweir.ENDIF			# "$(APP4PRODUCTNAME)"!=""
863cdf0e10cSrcweir
864cdf0e10cSrcweir.IF "$(linkinc)"!=""
865cdf0e10cSrcweir.IF "$(GUI)"=="WNT" || "$(GUI)"=="OS2"
866cdf0e10cSrcweir.IF "$(APP4LIBS)"!=""
867cdf0e10cSrcweir$(MISC)/$(APP4TARGET)_linkinc.ls .PHONY:
868cdf0e10cSrcweir	@@-$(RM) $@
869cdf0e10cSrcweir	sed -f $(SOLARENV)/bin/chrel.sed $(foreach,i,$(APP4LIBS) $(i:s/.lib/.lin/)) >> $@
870cdf0e10cSrcweir.ENDIF          #"$(APP4LIBS)"!=""
871cdf0e10cSrcweir.ENDIF
872cdf0e10cSrcweir
873cdf0e10cSrcweirLINKINCTARGETS+=$(MISC)/$(APP4TARGETN:b)_linkinc.ls
874cdf0e10cSrcweir$(APP4TARGETN) : $(LINKINCTARGETS)
875cdf0e10cSrcweir.ENDIF          # "$(linkinc)"!=""
876cdf0e10cSrcweir
877cdf0e10cSrcweir# Allow for target specific LIBSALCPPRT override
878cdf0e10cSrcweirAPP4LIBSALCPPRT*=$(LIBSALCPPRT)
879cdf0e10cSrcweir
880cdf0e10cSrcweir$(APP4TARGETN): $(APP4OBJS) $(APP4LIBS) \
881cdf0e10cSrcweir	$(APP4RES) \
882cdf0e10cSrcweir	$(APP4ICON) $(APP4DEPN) $(USE_APP4DEF)
883cdf0e10cSrcweir	@echo "Making:   " $(@:f)
884cdf0e10cSrcweir.IF "$(GUI)"=="UNX"
885cdf0e10cSrcweir.IF "$(OS)"=="MACOSX"
886cdf0e10cSrcweir	@echo unx
887cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).list
888cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_4.cmd
889cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).strip
890cdf0e10cSrcweir	@echo $(STDSLO) $(APP4OBJS:s/.obj/.o/) \
891cdf0e10cSrcweir	`cat /dev/null $(APP4LIBS) | sed s\#$(ROUT)\#$(OUT)\#g` | tr -s " " "\n" > $(MISC)/$(@:b).list
892cdf0e10cSrcweir	@echo -n $(APP4LINKER) $(APP4LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) -o $@ \
893cdf0e10cSrcweir	$(APP4LINKTYPEFLAG) $(APP4STDLIBS) $(APP4STDLIB) $(STDLIB4) -filelist $(MISC)/$(@:b).list > $(MISC)/$(TARGET).$(@:b)_4.cmd
894cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-dylib-link-list.pl \
895cdf0e10cSrcweir        `cat $(MISC)/$(TARGET).$(@:b)_4.cmd` \
896cdf0e10cSrcweir        >> $(MISC)/$(TARGET).$(@:b)_4.cmd
897cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
898cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_4.cmd
899cdf0e10cSrcweir  .ENDIF
900cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_4.cmd
901cdf0e10cSrcweir# Need to strip __objcInit symbol to avoid duplicate symbols when loading
902cdf0e10cSrcweir# libraries at runtime
9038badc1b4SHerbert Dürr	@-$(CC_PATH)nm $@ | grep -v ' U ' | $(AWK) '{ print $$NF }' | grep -F -x '__objcInit' > $(MISC)/$(@:b).strip
9048badc1b4SHerbert Dürr	@$(CC_PATH)strip -i -R $(MISC)/$(@:b).strip -X $@
905cdf0e10cSrcweir	@ls -l $@
906cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-change-install-names.pl \
907cdf0e10cSrcweir        app $(APP4RPATH) $@
908cdf0e10cSrcweir.IF "$(TARGETTYPE)"=="GUI"
909cdf0e10cSrcweir	@echo "Making:   " $(@:f).app
910cdf0e10cSrcweir	@macosx-create-bundle $@
911cdf0e10cSrcweir.ENDIF		# "$(TARGETTYPE)"=="GUI"
912cdf0e10cSrcweir.ELSE		# "$(OS)"=="MACOSX"
913cdf0e10cSrcweir	@echo unx
914cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_4.cmd
915cdf0e10cSrcweir	@echo $(APP4LINKER) $(APP4LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
916cdf0e10cSrcweir	$(APP4OBJS:s/.obj/.o/) '\' >  $(MISC)/$(TARGET).$(@:b)_4.cmd
917cdf0e10cSrcweir	@cat $(mktmp /dev/null $(APP4LIBS)) | xargs -n 1 cat | sed s\#$(ROUT)\#$(OUT)\#g | sed 's#$$# \\#'  >> $(MISC)/$(TARGET).$(@:b)_4.cmd
918cdf0e10cSrcweir	@echo $(APP4LINKTYPEFLAG) $(APP4LIBSALCPPRT) $(APP4STDLIBS) $(APP4STDLIB) $(STDLIB4) -o $@ >> $(MISC)/$(TARGET).$(@:b)_4.cmd
919cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
920cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_4.cmd
921cdf0e10cSrcweir  .ENDIF
922cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_4.cmd
923cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
924cdf0e10cSrcweir	@ls -l $@
925cdf0e10cSrcweir  .ENDIF
926cdf0e10cSrcweir.ENDIF		# "$(OS)"=="MACOSX"
927cdf0e10cSrcweir.ENDIF
928cdf0e10cSrcweir.IF "$(GUI)" == "WNT"
929cdf0e10cSrcweir	@@-$(MKDIR) $(@:d:d)
930cdf0e10cSrcweir.IF "$(APP4LINKRES)" != ""
931cdf0e10cSrcweir	@@-$(RM) $(MISC)/$(APP4LINKRES:b).rc
932cdf0e10cSrcweir.IF "$(APP4ICON)" != ""
933cdf0e10cSrcweir	@-echo 1 ICON $(EMQ)"$(APP4ICON:s/\/\\/)$(EMQ)" >> $(MISC)/$(APP4LINKRES:b).rc
934cdf0e10cSrcweir.ENDIF		# "$(APP4ICON)" != ""
935cdf0e10cSrcweir.IF "$(APP4VERINFO)" != ""
936cdf0e10cSrcweir	@-echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP4LINKRES:b).rc
937cdf0e10cSrcweir	@-echo $(EMQ)#include  $(EMQ)"$(APP4VERINFO)$(EMQ)" >> $(MISC)/$(APP4LINKRES:b).rc
938cdf0e10cSrcweir.ENDIF		# "$(APP4VERINFO)" != ""
939cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -DWIN32 $(APP4PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP4LINKRES:b).rc
940cdf0e10cSrcweir.ENDIF			# "$(APP4LINKRES)" != ""
941cdf0e10cSrcweir.IF "$(COM)" == "GCC"
942cdf0e10cSrcweir	@echo mingw
943cdf0e10cSrcweir.IF "$(APP4LINKRES)" != "" || "$(APP4RES)" != ""
944cdf0e10cSrcweir	@cat $(APP4LINKRES) $(subst,/res/,/res{$(subst,$(BIN), $(@:d))} $(APP4RES)) >  $(MISC)/$(@:b)_all.res
945cdf0e10cSrcweir	windres $(MISC)/$(@:b)_all.res $(APP4RESO)
946cdf0e10cSrcweir.ENDIF
947cdf0e10cSrcweir	@echo $(LINK) $(LINKFLAGS) $(LINKFLAGSAPP) $(MINGWSSTDOBJ) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
948cdf0e10cSrcweir		$(APP4BASEX) $(APP4STACKN) -o $@ $(APP4OBJS) \
949cdf0e10cSrcweir		-Wl,-Map,$(MISC)/$(@:b).map $(STDOBJ) $(APP4RESO) \
950cdf0e10cSrcweir		`$(TYPE) /dev/null $(APP4LIBS) | sed s#$(ROUT)#$(OUT)#g` \
951cdf0e10cSrcweir		$(APP_LINKTYPE) $(APP4LIBSALCPPRT) \
952cdf0e10cSrcweir		-Wl,--start-group $(APP4STDLIBS) -Wl,--end-group $(APP4STDLIB) \
953cdf0e10cSrcweir		$(STDLIB4) $(MINGWSSTDENDOBJ) > $(MISC)/$(TARGET).$(@:b)_4.cmd
954cdf0e10cSrcweir  # need this empty line, else dmake somehow gets confused by the .IFs and .ENDIFs
955cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
956cdf0e10cSrcweir	@$(TYPE)  $(MISC)/$(TARGET).$(@:b)_4.cmd
957cdf0e10cSrcweir  .ENDIF
958cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_4.cmd
959cdf0e10cSrcweir	@ls -l $@
960cdf0e10cSrcweir.ELSE	# "$(COM)" == "GCC"
961cdf0e10cSrcweir.IF "$(linkinc)" == ""
962cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP4LINKER) @$(mktmp \
963cdf0e10cSrcweir		$(APP4LINKFLAGS) \
964cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP4BASEX) \
965cdf0e10cSrcweir		$(APP4STACKN) \
966cdf0e10cSrcweir		-out:$@ \
967cdf0e10cSrcweir		-map:$(MISC)/{$(subst,/,_ $(APP4TARGET)).map} \
968cdf0e10cSrcweir		$(STDOBJ) \
969cdf0e10cSrcweir		$(APP4LINKRES) \
970cdf0e10cSrcweir		$(APP4RES) \
971cdf0e10cSrcweir		$(APP4OBJS) \
972cdf0e10cSrcweir		$(APP4LIBS) \
973cdf0e10cSrcweir		$(APP4STDLIBS) \
974cdf0e10cSrcweir		$(APP4STDLIB) $(STDLIB4) \
975cdf0e10cSrcweir		)
976cdf0e10cSrcweir	@-echo linking $@.manifest ...
977cdf0e10cSrcweir.IF "$(VISTA_MANIFEST)"!=""
978cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -manifest $(TRUSTED_MANIFEST_LOCATION)/trustedinfo.manifest -out:$@.tmanifest$(EMQ) $(FI)
979cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.tmanifest -outputresource:$@$(EMQ);1 $(FI)
980cdf0e10cSrcweir.ELSE
981cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -outputresource:$@$(EMQ);1 $(FI)
982cdf0e10cSrcweir.ENDIF # "$(VISTA_MANIFEST)"!=""
983cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(RM:s/+//) $@.manifest $(FI)
984cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.tmanifest $(THEN) $(RM:s/+//) $@.tmanifest $(FI)
985cdf0e10cSrcweir.ELSE
986cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP4TARGET).lnk
987cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP4TARGET).lst
988cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\linkobj.lst
989cdf0e10cSrcweir		for %_i in ($(MISC)\*.obj) do type %_i >> $(MISC)\linkobj.lst
990cdf0e10cSrcweir	type $(mktmp,$(MISC)\$(APP4TARGET).lst
991cdf0e10cSrcweir		$(APP4LINKFLAGS) \
992cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP4BASEX) \
993cdf0e10cSrcweir		$(APP4STACKN) \
994cdf0e10cSrcweir		-out:$@ \
995cdf0e10cSrcweir		$(STDOBJ) \
996cdf0e10cSrcweir		$(APP4LINKRES) \
997cdf0e10cSrcweir		$(APP4RES) \
998cdf0e10cSrcweir		$(APP4OBJS) \
999cdf0e10cSrcweir		$(APP4LIBS) \
1000cdf0e10cSrcweir		$(APP4STDLIBS) \
1001cdf0e10cSrcweir		$(APP4STDLIB) $(STDLIB4))
1002cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(SED) -e 's/\(\.\.\\\)\{2,4\}/..\\/g' $(MISC)\$(APP4TARGETN:b)_linkobj.lst >> $(MISC)\$(APP4TARGET).lst
1003cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(IFEXIST) $(MISC)/$(APP4TARGET).lst $(THEN) type $(MISC)/$(APP4TARGET).lst  >> $(MISC)/$(APP4TARGET).lnk $(FI)
1004cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(APP4LINKER) @$(MISC)\$(APP4TARGET).lnk
1005cdf0e10cSrcweir.ENDIF		# "$(linkinc)" == ""
1006cdf0e10cSrcweir.ENDIF		# "$(COM)" == "GCC"
1007cdf0e10cSrcweir.IF "$(APP4TARGET)" == "loader"
1008cdf0e10cSrcweir	$(COMMAND_ECHO)$(PERL) loader.pl $@
1009cdf0e10cSrcweir	$(COMMAND_ECHO)$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
1010cdf0e10cSrcweir	$(COMMAND_ECHO)$(RM) $@
1011cdf0e10cSrcweir	$(COMMAND_ECHO)$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
1012cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
1013cdf0e10cSrcweir
1014cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "WNT"
1015cdf0e10cSrcweir
1016cdf0e10cSrcweir.IF "$(GUI)" == "OS2"
1017534c536dSYuri Dario	@+-$(MKDIR) $(@:d:d) > $(NULLDEV)
1018cdf0e10cSrcweir.IF "$(APP4LINKRES)" != ""
1019534c536dSYuri Dario	@+-$(RM) $(MISC)/$(APP4LINKRES:b).rc > $(NULLDEV)
1020cdf0e10cSrcweir.IF "$(APP4ICON)" != ""
1021534c536dSYuri Dario	@-+echo ICON 1 $(EMQ)"$(APP4ICON:s#/#\\\\#)$(EMQ)" >> $(MISC)$/$(APP4LINKRES:b).rc
1022cdf0e10cSrcweir.ENDIF		# "$(APP4ICON)" != ""
1023cdf0e10cSrcweir.IF "$(APP4VERINFO)" != ""
1024cdf0e10cSrcweir	@-+echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP4LINKRES:b).rc
1025cdf0e10cSrcweir	@-+echo $(EMQ)#include  $(EMQ)"$(APP4VERINFO)$(EMQ)" >> $(MISC)/$(APP4LINKRES:b).rc
1026cdf0e10cSrcweir.ENDIF		# "$(APP4VERINFO)" != ""
1027cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -r -DOS2 $(APP4PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP4LINKRES:b).rc
1028cdf0e10cSrcweir.ENDIF			# "$(APP4LINKRES)" != ""
1029cdf0e10cSrcweir
1030cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
1031cdf0e10cSrcweir	@echo NAME $(APP4TARGET) WINDOWAPI > $(MISC)/$(APP4TARGET).def
1032cdf0e10cSrcweir.ENDIF
1033cdf0e10cSrcweir
1034cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP4LINKER) -v \
1035cdf0e10cSrcweir		$(APP4LINKFLAGS) \
1036cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP4BASEX) \
1037cdf0e10cSrcweir		$(APP4STACKN) \
1038cdf0e10cSrcweir		-o $@ \
1039cdf0e10cSrcweir		-Zmap -L$(LB) \
1040cdf0e10cSrcweir		-L$(SOLARVERSION)/$(INPATH)/lib \
1041cdf0e10cSrcweir		$(STDOBJ) \
1042cdf0e10cSrcweir		$(APP4LINKRES) \
1043cdf0e10cSrcweir		$(APP4RES) \
1044cdf0e10cSrcweir		$(APP4DEF) \
1045cdf0e10cSrcweir		$(APP4OBJS) \
1046cdf0e10cSrcweir		$(APP4LIBS) \
1047534c536dSYuri Dario		$(APP4STDLIBS) \
1048534c536dSYuri Dario		$(APP4STDLIB) $(STDLIB4)
1049cdf0e10cSrcweir
1050cdf0e10cSrcweir
1051cdf0e10cSrcweir.IF "$(APP4TARGET)" == "loader"
1052cdf0e10cSrcweir	$(COMMAND_ECHO)+$(PERL) loader.pl $@
1053cdf0e10cSrcweir	$(COMMAND_ECHO)+$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
1054cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RM) $@
1055cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
1056cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
1057cdf0e10cSrcweir
1058cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "OS2"
1059cdf0e10cSrcweir
1060cdf0e10cSrcweir.ENDIF			# "$(APP4TARGETN)"!=""
1061cdf0e10cSrcweir
1062cdf0e10cSrcweir
1063cdf0e10cSrcweir# Instruction for linking
1064cdf0e10cSrcweir# unroll begin
1065cdf0e10cSrcweir
1066cdf0e10cSrcweir.IF "$(GUI)" == "OS2" && "$(TARGETTYPE)" == "GUI"
1067cdf0e10cSrcweirAPP5DEF = $(MISC)/$(APP5TARGET).def
1068cdf0e10cSrcweir.ENDIF
1069cdf0e10cSrcweir
1070cdf0e10cSrcweir.IF "$(APP5LINKTYPE)" != ""
1071cdf0e10cSrcweir#must be either STATIC or SHARED
1072cdf0e10cSrcweirAPP5LINKTYPEFLAG=$(APPLINK$(APP5LINKTYPE))
1073cdf0e10cSrcweir.ENDIF
1074cdf0e10cSrcweir
1075cdf0e10cSrcweir# decide how to link
1076cdf0e10cSrcweir.IF "$(APP5CODETYPE)"=="C"
1077cdf0e10cSrcweirAPP5LINKER=$(LINKC)
1078cdf0e10cSrcweirAPP5STDLIB=$(subst,CPPRUNTIME, $(STDLIB))
1079cdf0e10cSrcweirAPP5LINKFLAGS+=$(LINKCFLAGS)
1080cdf0e10cSrcweir.ELSE			# "$(APP5CODETYPE)"=="C"
1081cdf0e10cSrcweirAPP5LINKER=$(LINK)
1082cdf0e10cSrcweirAPP5STDLIB=$(subst,CPPRUNTIME,$(STDLIBCPP) $(STDLIB))
1083cdf0e10cSrcweirAPP5LINKFLAGS+=$(LINKFLAGS)
1084cdf0e10cSrcweir.ENDIF			# "$(APP5CODETYPE)"=="C"
1085cdf0e10cSrcweir
1086cdf0e10cSrcweirAPP5RPATH*=OOO
1087cdf0e10cSrcweirLINKFLAGSRUNPATH_$(APP5RPATH)*=/ERROR:/Bad_APP5RPATH_value
1088cdf0e10cSrcweir.IF "$(OS)" != "MACOSX"
1089cdf0e10cSrcweirAPP5LINKFLAGS+=$(LINKFLAGSRUNPATH_$(APP5RPATH))
1090cdf0e10cSrcweir.ENDIF
1091cdf0e10cSrcweir
1092cdf0e10cSrcweir.IF "$(APP5STACK)" != ""
1093cdf0e10cSrcweir.IF "$(LINKFLAGSTACK)" != ""
1094cdf0e10cSrcweirAPP5STACKN=$(LINKFLAGSTACK)$(APP5STACK)
1095cdf0e10cSrcweir.ENDIF
1096cdf0e10cSrcweir.ELSE
1097cdf0e10cSrcweirAPP5STACKN=
1098cdf0e10cSrcweir.ENDIF
1099cdf0e10cSrcweir
1100cdf0e10cSrcweir.IF "$(APP5NOSAL)"==""
1101cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
1102cdf0e10cSrcweirAPP5OBJS+= $(STDOBJVCL)
1103cdf0e10cSrcweir.ENDIF
1104cdf0e10cSrcweir.ENDIF
1105cdf0e10cSrcweir
1106cdf0e10cSrcweir.IF "$(GUI)$(COM)" == "WNTGCC"
1107cdf0e10cSrcweirAPP5RESO=
1108cdf0e10cSrcweir.IF "$(APP5LINKRES)" != "" || "$(APP5RES)" != ""
1109cdf0e10cSrcweirAPP5RESO=$(MISC)/$(APP5TARGET:b)_res.o
1110cdf0e10cSrcweir.ENDIF
1111cdf0e10cSrcweir.ENDIF
1112cdf0e10cSrcweir
1113cdf0e10cSrcweir.IF "$(GUI)" == "UNX"
1114cdf0e10cSrcweirAPP5DEPN+:=$(APP5DEPNU)
1115cdf0e10cSrcweirUSE_APP5DEF=
1116cdf0e10cSrcweir.ENDIF
1117cdf0e10cSrcweir
1118cdf0e10cSrcweir.IF "$(APP5TARGETN)"!=""
1119cdf0e10cSrcweir
1120cdf0e10cSrcweir.IF "$(APP5PRODUCTNAME)"!=""
1121cdf0e10cSrcweirAPP5PRODUCTDEF+:=-DPRODUCT_NAME=\"$(APP5PRODUCTNAME)\"
1122cdf0e10cSrcweir.ENDIF			# "$(APP5PRODUCTNAME)"!=""
1123cdf0e10cSrcweir
1124cdf0e10cSrcweir.IF "$(linkinc)"!=""
1125cdf0e10cSrcweir.IF "$(GUI)"=="WNT" || "$(GUI)"=="OS2"
1126cdf0e10cSrcweir.IF "$(APP5LIBS)"!=""
1127cdf0e10cSrcweir$(MISC)/$(APP5TARGET)_linkinc.ls .PHONY:
1128cdf0e10cSrcweir	@@-$(RM) $@
1129cdf0e10cSrcweir	sed -f $(SOLARENV)/bin/chrel.sed $(foreach,i,$(APP5LIBS) $(i:s/.lib/.lin/)) >> $@
1130cdf0e10cSrcweir.ENDIF          #"$(APP5LIBS)"!=""
1131cdf0e10cSrcweir.ENDIF
1132cdf0e10cSrcweir
1133cdf0e10cSrcweirLINKINCTARGETS+=$(MISC)/$(APP5TARGETN:b)_linkinc.ls
1134cdf0e10cSrcweir$(APP5TARGETN) : $(LINKINCTARGETS)
1135cdf0e10cSrcweir.ENDIF          # "$(linkinc)"!=""
1136cdf0e10cSrcweir
1137cdf0e10cSrcweir# Allow for target specific LIBSALCPPRT override
1138cdf0e10cSrcweirAPP5LIBSALCPPRT*=$(LIBSALCPPRT)
1139cdf0e10cSrcweir
1140cdf0e10cSrcweir$(APP5TARGETN): $(APP5OBJS) $(APP5LIBS) \
1141cdf0e10cSrcweir	$(APP5RES) \
1142cdf0e10cSrcweir	$(APP5ICON) $(APP5DEPN) $(USE_APP5DEF)
1143cdf0e10cSrcweir	@echo "Making:   " $(@:f)
1144cdf0e10cSrcweir.IF "$(GUI)"=="UNX"
1145cdf0e10cSrcweir.IF "$(OS)"=="MACOSX"
1146cdf0e10cSrcweir	@echo unx
1147cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).list
1148cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_5.cmd
1149cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).strip
1150cdf0e10cSrcweir	@echo $(STDSLO) $(APP5OBJS:s/.obj/.o/) \
1151cdf0e10cSrcweir	`cat /dev/null $(APP5LIBS) | sed s\#$(ROUT)\#$(OUT)\#g` | tr -s " " "\n" > $(MISC)/$(@:b).list
1152cdf0e10cSrcweir	@echo -n $(APP5LINKER) $(APP5LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) -o $@ \
1153cdf0e10cSrcweir	$(APP5LINKTYPEFLAG) $(APP5STDLIBS) $(APP5STDLIB) $(STDLIB5) -filelist $(MISC)/$(@:b).list > $(MISC)/$(TARGET).$(@:b)_5.cmd
1154cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-dylib-link-list.pl \
1155cdf0e10cSrcweir        `cat $(MISC)/$(TARGET).$(@:b)_5.cmd` \
1156cdf0e10cSrcweir        >> $(MISC)/$(TARGET).$(@:b)_5.cmd
1157cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
1158cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_5.cmd
1159cdf0e10cSrcweir  .ENDIF
1160cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_5.cmd
1161cdf0e10cSrcweir# Need to strip __objcInit symbol to avoid duplicate symbols when loading
1162cdf0e10cSrcweir# libraries at runtime
11638badc1b4SHerbert Dürr	@-$(CC_PATH)nm $@ | grep -v ' U ' | $(AWK) '{ print $$NF }' | grep -F -x '__objcInit' > $(MISC)/$(@:b).strip
11648badc1b4SHerbert Dürr	@$(CC_PATH)strip -i -R $(MISC)/$(@:b).strip -X $@
1165cdf0e10cSrcweir	@ls -l $@
1166cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-change-install-names.pl \
1167cdf0e10cSrcweir        app $(APP5RPATH) $@
1168cdf0e10cSrcweir.IF "$(TARGETTYPE)"=="GUI"
1169cdf0e10cSrcweir	@echo "Making:   " $(@:f).app
1170cdf0e10cSrcweir	@macosx-create-bundle $@
1171cdf0e10cSrcweir.ENDIF		# "$(TARGETTYPE)"=="GUI"
1172cdf0e10cSrcweir.ELSE		# "$(OS)"=="MACOSX"
1173cdf0e10cSrcweir	@echo unx
1174cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_5.cmd
1175cdf0e10cSrcweir	@echo $(APP5LINKER) $(APP5LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
1176cdf0e10cSrcweir	$(APP5OBJS:s/.obj/.o/) '\' >  $(MISC)/$(TARGET).$(@:b)_5.cmd
1177cdf0e10cSrcweir	@cat $(mktmp /dev/null $(APP5LIBS)) | xargs -n 1 cat | sed s\#$(ROUT)\#$(OUT)\#g | sed 's#$$# \\#'  >> $(MISC)/$(TARGET).$(@:b)_5.cmd
1178cdf0e10cSrcweir	@echo $(APP5LINKTYPEFLAG) $(APP5LIBSALCPPRT) $(APP5STDLIBS) $(APP5STDLIB) $(STDLIB5) -o $@ >> $(MISC)/$(TARGET).$(@:b)_5.cmd
1179cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
1180cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_5.cmd
1181cdf0e10cSrcweir  .ENDIF
1182cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_5.cmd
1183cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
1184cdf0e10cSrcweir	@ls -l $@
1185cdf0e10cSrcweir  .ENDIF
1186cdf0e10cSrcweir.ENDIF		# "$(OS)"=="MACOSX"
1187cdf0e10cSrcweir.ENDIF
1188cdf0e10cSrcweir.IF "$(GUI)" == "WNT"
1189cdf0e10cSrcweir	@@-$(MKDIR) $(@:d:d)
1190cdf0e10cSrcweir.IF "$(APP5LINKRES)" != ""
1191cdf0e10cSrcweir	@@-$(RM) $(MISC)/$(APP5LINKRES:b).rc
1192cdf0e10cSrcweir.IF "$(APP5ICON)" != ""
1193cdf0e10cSrcweir	@-echo 1 ICON $(EMQ)"$(APP5ICON:s/\/\\/)$(EMQ)" >> $(MISC)/$(APP5LINKRES:b).rc
1194cdf0e10cSrcweir.ENDIF		# "$(APP5ICON)" != ""
1195cdf0e10cSrcweir.IF "$(APP5VERINFO)" != ""
1196cdf0e10cSrcweir	@-echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP5LINKRES:b).rc
1197cdf0e10cSrcweir	@-echo $(EMQ)#include  $(EMQ)"$(APP5VERINFO)$(EMQ)" >> $(MISC)/$(APP5LINKRES:b).rc
1198cdf0e10cSrcweir.ENDIF		# "$(APP5VERINFO)" != ""
1199cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -DWIN32 $(APP5PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP5LINKRES:b).rc
1200cdf0e10cSrcweir.ENDIF			# "$(APP5LINKRES)" != ""
1201cdf0e10cSrcweir.IF "$(COM)" == "GCC"
1202cdf0e10cSrcweir	@echo mingw
1203cdf0e10cSrcweir.IF "$(APP5LINKRES)" != "" || "$(APP5RES)" != ""
1204cdf0e10cSrcweir	@cat $(APP5LINKRES) $(subst,/res/,/res{$(subst,$(BIN), $(@:d))} $(APP5RES)) >  $(MISC)/$(@:b)_all.res
1205cdf0e10cSrcweir	windres $(MISC)/$(@:b)_all.res $(APP5RESO)
1206cdf0e10cSrcweir.ENDIF
1207cdf0e10cSrcweir	@echo $(LINK) $(LINKFLAGS) $(LINKFLAGSAPP) $(MINGWSSTDOBJ) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
1208cdf0e10cSrcweir		$(APP5BASEX) $(APP5STACKN) -o $@ $(APP5OBJS) \
1209cdf0e10cSrcweir		-Wl,-Map,$(MISC)/$(@:b).map $(STDOBJ) $(APP5RESO) \
1210cdf0e10cSrcweir		`$(TYPE) /dev/null $(APP5LIBS) | sed s#$(ROUT)#$(OUT)#g` \
1211cdf0e10cSrcweir		$(APP_LINKTYPE) $(APP5LIBSALCPPRT) \
1212cdf0e10cSrcweir		-Wl,--start-group $(APP5STDLIBS) -Wl,--end-group $(APP5STDLIB) \
1213cdf0e10cSrcweir		$(STDLIB5) $(MINGWSSTDENDOBJ) > $(MISC)/$(TARGET).$(@:b)_5.cmd
1214cdf0e10cSrcweir  # need this empty line, else dmake somehow gets confused by the .IFs and .ENDIFs
1215cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
1216cdf0e10cSrcweir	@$(TYPE)  $(MISC)/$(TARGET).$(@:b)_5.cmd
1217cdf0e10cSrcweir  .ENDIF
1218cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_5.cmd
1219cdf0e10cSrcweir	@ls -l $@
1220cdf0e10cSrcweir.ELSE	# "$(COM)" == "GCC"
1221cdf0e10cSrcweir.IF "$(linkinc)" == ""
1222cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP5LINKER) @$(mktmp \
1223cdf0e10cSrcweir		$(APP5LINKFLAGS) \
1224cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP5BASEX) \
1225cdf0e10cSrcweir		$(APP5STACKN) \
1226cdf0e10cSrcweir		-out:$@ \
1227cdf0e10cSrcweir		-map:$(MISC)/{$(subst,/,_ $(APP5TARGET)).map} \
1228cdf0e10cSrcweir		$(STDOBJ) \
1229cdf0e10cSrcweir		$(APP5LINKRES) \
1230cdf0e10cSrcweir		$(APP5RES) \
1231cdf0e10cSrcweir		$(APP5OBJS) \
1232cdf0e10cSrcweir		$(APP5LIBS) \
1233cdf0e10cSrcweir		$(APP5STDLIBS) \
1234cdf0e10cSrcweir		$(APP5STDLIB) $(STDLIB5) \
1235cdf0e10cSrcweir		)
1236cdf0e10cSrcweir	@-echo linking $@.manifest ...
1237cdf0e10cSrcweir.IF "$(VISTA_MANIFEST)"!=""
1238cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -manifest $(TRUSTED_MANIFEST_LOCATION)/trustedinfo.manifest -out:$@.tmanifest$(EMQ) $(FI)
1239cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.tmanifest -outputresource:$@$(EMQ);1 $(FI)
1240cdf0e10cSrcweir.ELSE
1241cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -outputresource:$@$(EMQ);1 $(FI)
1242cdf0e10cSrcweir.ENDIF # "$(VISTA_MANIFEST)"!=""
1243cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(RM:s/+//) $@.manifest $(FI)
1244cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.tmanifest $(THEN) $(RM:s/+//) $@.tmanifest $(FI)
1245cdf0e10cSrcweir.ELSE
1246cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP5TARGET).lnk
1247cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP5TARGET).lst
1248cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\linkobj.lst
1249cdf0e10cSrcweir		for %_i in ($(MISC)\*.obj) do type %_i >> $(MISC)\linkobj.lst
1250cdf0e10cSrcweir	type $(mktmp,$(MISC)\$(APP5TARGET).lst
1251cdf0e10cSrcweir		$(APP5LINKFLAGS) \
1252cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP5BASEX) \
1253cdf0e10cSrcweir		$(APP5STACKN) \
1254cdf0e10cSrcweir		-out:$@ \
1255cdf0e10cSrcweir		$(STDOBJ) \
1256cdf0e10cSrcweir		$(APP5LINKRES) \
1257cdf0e10cSrcweir		$(APP5RES) \
1258cdf0e10cSrcweir		$(APP5OBJS) \
1259cdf0e10cSrcweir		$(APP5LIBS) \
1260cdf0e10cSrcweir		$(APP5STDLIBS) \
1261cdf0e10cSrcweir		$(APP5STDLIB) $(STDLIB5))
1262cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(SED) -e 's/\(\.\.\\\)\{2,4\}/..\\/g' $(MISC)\$(APP5TARGETN:b)_linkobj.lst >> $(MISC)\$(APP5TARGET).lst
1263cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(IFEXIST) $(MISC)/$(APP5TARGET).lst $(THEN) type $(MISC)/$(APP5TARGET).lst  >> $(MISC)/$(APP5TARGET).lnk $(FI)
1264cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(APP5LINKER) @$(MISC)\$(APP5TARGET).lnk
1265cdf0e10cSrcweir.ENDIF		# "$(linkinc)" == ""
1266cdf0e10cSrcweir.ENDIF		# "$(COM)" == "GCC"
1267cdf0e10cSrcweir.IF "$(APP5TARGET)" == "loader"
1268cdf0e10cSrcweir	$(COMMAND_ECHO)$(PERL) loader.pl $@
1269cdf0e10cSrcweir	$(COMMAND_ECHO)$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
1270cdf0e10cSrcweir	$(COMMAND_ECHO)$(RM) $@
1271cdf0e10cSrcweir	$(COMMAND_ECHO)$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
1272cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
1273cdf0e10cSrcweir
1274cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "WNT"
1275cdf0e10cSrcweir
1276cdf0e10cSrcweir.IF "$(GUI)" == "OS2"
1277534c536dSYuri Dario	@+-$(MKDIR) $(@:d:d) > $(NULLDEV)
1278cdf0e10cSrcweir.IF "$(APP5LINKRES)" != ""
1279534c536dSYuri Dario	@+-$(RM) $(MISC)/$(APP5LINKRES:b).rc > $(NULLDEV)
1280cdf0e10cSrcweir.IF "$(APP5ICON)" != ""
1281534c536dSYuri Dario	@-+echo ICON 1 $(EMQ)"$(APP5ICON:s#/#\\\\#)$(EMQ)" >> $(MISC)$/$(APP5LINKRES:b).rc
1282cdf0e10cSrcweir.ENDIF		# "$(APP5ICON)" != ""
1283cdf0e10cSrcweir.IF "$(APP5VERINFO)" != ""
1284cdf0e10cSrcweir	@-+echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP5LINKRES:b).rc
1285cdf0e10cSrcweir	@-+echo $(EMQ)#include  $(EMQ)"$(APP5VERINFO)$(EMQ)" >> $(MISC)/$(APP5LINKRES:b).rc
1286cdf0e10cSrcweir.ENDIF		# "$(APP5VERINFO)" != ""
1287cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -r -DOS2 $(APP5PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP5LINKRES:b).rc
1288cdf0e10cSrcweir.ENDIF			# "$(APP5LINKRES)" != ""
1289cdf0e10cSrcweir
1290cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
1291cdf0e10cSrcweir	@echo NAME $(APP5TARGET) WINDOWAPI > $(MISC)/$(APP5TARGET).def
1292cdf0e10cSrcweir.ENDIF
1293cdf0e10cSrcweir
1294cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP5LINKER) -v \
1295cdf0e10cSrcweir		$(APP5LINKFLAGS) \
1296cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP5BASEX) \
1297cdf0e10cSrcweir		$(APP5STACKN) \
1298cdf0e10cSrcweir		-o $@ \
1299cdf0e10cSrcweir		-Zmap -L$(LB) \
1300cdf0e10cSrcweir		-L$(SOLARVERSION)/$(INPATH)/lib \
1301cdf0e10cSrcweir		$(STDOBJ) \
1302cdf0e10cSrcweir		$(APP5LINKRES) \
1303cdf0e10cSrcweir		$(APP5RES) \
1304cdf0e10cSrcweir		$(APP5DEF) \
1305cdf0e10cSrcweir		$(APP5OBJS) \
1306cdf0e10cSrcweir		$(APP5LIBS) \
1307534c536dSYuri Dario		$(APP5STDLIBS) \
1308534c536dSYuri Dario		$(APP5STDLIB) $(STDLIB5)
1309cdf0e10cSrcweir
1310cdf0e10cSrcweir
1311cdf0e10cSrcweir.IF "$(APP5TARGET)" == "loader"
1312cdf0e10cSrcweir	$(COMMAND_ECHO)+$(PERL) loader.pl $@
1313cdf0e10cSrcweir	$(COMMAND_ECHO)+$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
1314cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RM) $@
1315cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
1316cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
1317cdf0e10cSrcweir
1318cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "OS2"
1319cdf0e10cSrcweir
1320cdf0e10cSrcweir.ENDIF			# "$(APP5TARGETN)"!=""
1321cdf0e10cSrcweir
1322cdf0e10cSrcweir
1323cdf0e10cSrcweir# Instruction for linking
1324cdf0e10cSrcweir# unroll begin
1325cdf0e10cSrcweir
1326cdf0e10cSrcweir.IF "$(GUI)" == "OS2" && "$(TARGETTYPE)" == "GUI"
1327cdf0e10cSrcweirAPP6DEF = $(MISC)/$(APP6TARGET).def
1328cdf0e10cSrcweir.ENDIF
1329cdf0e10cSrcweir
1330cdf0e10cSrcweir.IF "$(APP6LINKTYPE)" != ""
1331cdf0e10cSrcweir#must be either STATIC or SHARED
1332cdf0e10cSrcweirAPP6LINKTYPEFLAG=$(APPLINK$(APP6LINKTYPE))
1333cdf0e10cSrcweir.ENDIF
1334cdf0e10cSrcweir
1335cdf0e10cSrcweir# decide how to link
1336cdf0e10cSrcweir.IF "$(APP6CODETYPE)"=="C"
1337cdf0e10cSrcweirAPP6LINKER=$(LINKC)
1338cdf0e10cSrcweirAPP6STDLIB=$(subst,CPPRUNTIME, $(STDLIB))
1339cdf0e10cSrcweirAPP6LINKFLAGS+=$(LINKCFLAGS)
1340cdf0e10cSrcweir.ELSE			# "$(APP6CODETYPE)"=="C"
1341cdf0e10cSrcweirAPP6LINKER=$(LINK)
1342cdf0e10cSrcweirAPP6STDLIB=$(subst,CPPRUNTIME,$(STDLIBCPP) $(STDLIB))
1343cdf0e10cSrcweirAPP6LINKFLAGS+=$(LINKFLAGS)
1344cdf0e10cSrcweir.ENDIF			# "$(APP6CODETYPE)"=="C"
1345cdf0e10cSrcweir
1346cdf0e10cSrcweirAPP6RPATH*=OOO
1347cdf0e10cSrcweirLINKFLAGSRUNPATH_$(APP6RPATH)*=/ERROR:/Bad_APP6RPATH_value
1348cdf0e10cSrcweir.IF "$(OS)" != "MACOSX"
1349cdf0e10cSrcweirAPP6LINKFLAGS+=$(LINKFLAGSRUNPATH_$(APP6RPATH))
1350cdf0e10cSrcweir.ENDIF
1351cdf0e10cSrcweir
1352cdf0e10cSrcweir.IF "$(APP6STACK)" != ""
1353cdf0e10cSrcweir.IF "$(LINKFLAGSTACK)" != ""
1354cdf0e10cSrcweirAPP6STACKN=$(LINKFLAGSTACK)$(APP6STACK)
1355cdf0e10cSrcweir.ENDIF
1356cdf0e10cSrcweir.ELSE
1357cdf0e10cSrcweirAPP6STACKN=
1358cdf0e10cSrcweir.ENDIF
1359cdf0e10cSrcweir
1360cdf0e10cSrcweir.IF "$(APP6NOSAL)"==""
1361cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
1362cdf0e10cSrcweirAPP6OBJS+= $(STDOBJVCL)
1363cdf0e10cSrcweir.ENDIF
1364cdf0e10cSrcweir.ENDIF
1365cdf0e10cSrcweir
1366cdf0e10cSrcweir.IF "$(GUI)$(COM)" == "WNTGCC"
1367cdf0e10cSrcweirAPP6RESO=
1368cdf0e10cSrcweir.IF "$(APP6LINKRES)" != "" || "$(APP6RES)" != ""
1369cdf0e10cSrcweirAPP6RESO=$(MISC)/$(APP6TARGET:b)_res.o
1370cdf0e10cSrcweir.ENDIF
1371cdf0e10cSrcweir.ENDIF
1372cdf0e10cSrcweir
1373cdf0e10cSrcweir.IF "$(GUI)" == "UNX"
1374cdf0e10cSrcweirAPP6DEPN+:=$(APP6DEPNU)
1375cdf0e10cSrcweirUSE_APP6DEF=
1376cdf0e10cSrcweir.ENDIF
1377cdf0e10cSrcweir
1378cdf0e10cSrcweir.IF "$(APP6TARGETN)"!=""
1379cdf0e10cSrcweir
1380cdf0e10cSrcweir.IF "$(APP6PRODUCTNAME)"!=""
1381cdf0e10cSrcweirAPP6PRODUCTDEF+:=-DPRODUCT_NAME=\"$(APP6PRODUCTNAME)\"
1382cdf0e10cSrcweir.ENDIF			# "$(APP6PRODUCTNAME)"!=""
1383cdf0e10cSrcweir
1384cdf0e10cSrcweir.IF "$(linkinc)"!=""
1385cdf0e10cSrcweir.IF "$(GUI)"=="WNT" || "$(GUI)"=="OS2"
1386cdf0e10cSrcweir.IF "$(APP6LIBS)"!=""
1387cdf0e10cSrcweir$(MISC)/$(APP6TARGET)_linkinc.ls .PHONY:
1388cdf0e10cSrcweir	@@-$(RM) $@
1389cdf0e10cSrcweir	sed -f $(SOLARENV)/bin/chrel.sed $(foreach,i,$(APP6LIBS) $(i:s/.lib/.lin/)) >> $@
1390cdf0e10cSrcweir.ENDIF          #"$(APP6LIBS)"!=""
1391cdf0e10cSrcweir.ENDIF
1392cdf0e10cSrcweir
1393cdf0e10cSrcweirLINKINCTARGETS+=$(MISC)/$(APP6TARGETN:b)_linkinc.ls
1394cdf0e10cSrcweir$(APP6TARGETN) : $(LINKINCTARGETS)
1395cdf0e10cSrcweir.ENDIF          # "$(linkinc)"!=""
1396cdf0e10cSrcweir
1397cdf0e10cSrcweir# Allow for target specific LIBSALCPPRT override
1398cdf0e10cSrcweirAPP6LIBSALCPPRT*=$(LIBSALCPPRT)
1399cdf0e10cSrcweir
1400cdf0e10cSrcweir$(APP6TARGETN): $(APP6OBJS) $(APP6LIBS) \
1401cdf0e10cSrcweir	$(APP6RES) \
1402cdf0e10cSrcweir	$(APP6ICON) $(APP6DEPN) $(USE_APP6DEF)
1403cdf0e10cSrcweir	@echo "Making:   " $(@:f)
1404cdf0e10cSrcweir.IF "$(GUI)"=="UNX"
1405cdf0e10cSrcweir.IF "$(OS)"=="MACOSX"
1406cdf0e10cSrcweir	@echo unx
1407cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).list
1408cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_6.cmd
1409cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).strip
1410cdf0e10cSrcweir	@echo $(STDSLO) $(APP6OBJS:s/.obj/.o/) \
1411cdf0e10cSrcweir	`cat /dev/null $(APP6LIBS) | sed s\#$(ROUT)\#$(OUT)\#g` | tr -s " " "\n" > $(MISC)/$(@:b).list
1412cdf0e10cSrcweir	@echo -n $(APP6LINKER) $(APP6LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) -o $@ \
1413cdf0e10cSrcweir	$(APP6LINKTYPEFLAG) $(APP6STDLIBS) $(APP6STDLIB) $(STDLIB6) -filelist $(MISC)/$(@:b).list > $(MISC)/$(TARGET).$(@:b)_6.cmd
1414cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-dylib-link-list.pl \
1415cdf0e10cSrcweir        `cat $(MISC)/$(TARGET).$(@:b)_6.cmd` \
1416cdf0e10cSrcweir        >> $(MISC)/$(TARGET).$(@:b)_6.cmd
1417cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
1418cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_6.cmd
1419cdf0e10cSrcweir  .ENDIF
1420cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_6.cmd
1421cdf0e10cSrcweir# Need to strip __objcInit symbol to avoid duplicate symbols when loading
1422cdf0e10cSrcweir# libraries at runtime
14238badc1b4SHerbert Dürr	@-$(CC_PATH)nm $@ | grep -v ' U ' | $(AWK) '{ print $$NF }' | grep -F -x '__objcInit' > $(MISC)/$(@:b).strip
14248badc1b4SHerbert Dürr	@$(CC_PATH)strip -i -R $(MISC)/$(@:b).strip -X $@
1425cdf0e10cSrcweir	@ls -l $@
1426cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-change-install-names.pl \
1427cdf0e10cSrcweir        app $(APP6RPATH) $@
1428cdf0e10cSrcweir.IF "$(TARGETTYPE)"=="GUI"
1429cdf0e10cSrcweir	@echo "Making:   " $(@:f).app
1430cdf0e10cSrcweir	@macosx-create-bundle $@
1431cdf0e10cSrcweir.ENDIF		# "$(TARGETTYPE)"=="GUI"
1432cdf0e10cSrcweir.ELSE		# "$(OS)"=="MACOSX"
1433cdf0e10cSrcweir	@echo unx
1434cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_6.cmd
1435cdf0e10cSrcweir	@echo $(APP6LINKER) $(APP6LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
1436cdf0e10cSrcweir	$(APP6OBJS:s/.obj/.o/) '\' >  $(MISC)/$(TARGET).$(@:b)_6.cmd
1437cdf0e10cSrcweir	@cat $(mktmp /dev/null $(APP6LIBS)) | xargs -n 1 cat | sed s\#$(ROUT)\#$(OUT)\#g | sed 's#$$# \\#'  >> $(MISC)/$(TARGET).$(@:b)_6.cmd
1438cdf0e10cSrcweir	@echo $(APP6LINKTYPEFLAG) $(APP6LIBSALCPPRT) $(APP6STDLIBS) $(APP6STDLIB) $(STDLIB6) -o $@ >> $(MISC)/$(TARGET).$(@:b)_6.cmd
1439cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
1440cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_6.cmd
1441cdf0e10cSrcweir  .ENDIF
1442cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_6.cmd
1443cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
1444cdf0e10cSrcweir	@ls -l $@
1445cdf0e10cSrcweir  .ENDIF
1446cdf0e10cSrcweir.ENDIF		# "$(OS)"=="MACOSX"
1447cdf0e10cSrcweir.ENDIF
1448cdf0e10cSrcweir.IF "$(GUI)" == "WNT"
1449cdf0e10cSrcweir	@@-$(MKDIR) $(@:d:d)
1450cdf0e10cSrcweir.IF "$(APP6LINKRES)" != ""
1451cdf0e10cSrcweir	@@-$(RM) $(MISC)/$(APP6LINKRES:b).rc
1452cdf0e10cSrcweir.IF "$(APP6ICON)" != ""
1453cdf0e10cSrcweir	@-echo 1 ICON $(EMQ)"$(APP6ICON:s/\/\\/)$(EMQ)" >> $(MISC)/$(APP6LINKRES:b).rc
1454cdf0e10cSrcweir.ENDIF		# "$(APP6ICON)" != ""
1455cdf0e10cSrcweir.IF "$(APP6VERINFO)" != ""
1456cdf0e10cSrcweir	@-echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP6LINKRES:b).rc
1457cdf0e10cSrcweir	@-echo $(EMQ)#include  $(EMQ)"$(APP6VERINFO)$(EMQ)" >> $(MISC)/$(APP6LINKRES:b).rc
1458cdf0e10cSrcweir.ENDIF		# "$(APP6VERINFO)" != ""
1459cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -DWIN32 $(APP6PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP6LINKRES:b).rc
1460cdf0e10cSrcweir.ENDIF			# "$(APP6LINKRES)" != ""
1461cdf0e10cSrcweir.IF "$(COM)" == "GCC"
1462cdf0e10cSrcweir	@echo mingw
1463cdf0e10cSrcweir.IF "$(APP6LINKRES)" != "" || "$(APP6RES)" != ""
1464cdf0e10cSrcweir	@cat $(APP6LINKRES) $(subst,/res/,/res{$(subst,$(BIN), $(@:d))} $(APP6RES)) >  $(MISC)/$(@:b)_all.res
1465cdf0e10cSrcweir	windres $(MISC)/$(@:b)_all.res $(APP6RESO)
1466cdf0e10cSrcweir.ENDIF
1467cdf0e10cSrcweir	@echo $(LINK) $(LINKFLAGS) $(LINKFLAGSAPP) $(MINGWSSTDOBJ) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
1468cdf0e10cSrcweir		$(APP6BASEX) $(APP6STACKN) -o $@ $(APP6OBJS) \
1469cdf0e10cSrcweir		-Wl,-Map,$(MISC)/$(@:b).map $(STDOBJ) $(APP6RESO) \
1470cdf0e10cSrcweir		`$(TYPE) /dev/null $(APP6LIBS) | sed s#$(ROUT)#$(OUT)#g` \
1471cdf0e10cSrcweir		$(APP_LINKTYPE) $(APP6LIBSALCPPRT) \
1472cdf0e10cSrcweir		-Wl,--start-group $(APP6STDLIBS) -Wl,--end-group $(APP6STDLIB) \
1473cdf0e10cSrcweir		$(STDLIB6) $(MINGWSSTDENDOBJ) > $(MISC)/$(TARGET).$(@:b)_6.cmd
1474cdf0e10cSrcweir  # need this empty line, else dmake somehow gets confused by the .IFs and .ENDIFs
1475cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
1476cdf0e10cSrcweir	@$(TYPE)  $(MISC)/$(TARGET).$(@:b)_6.cmd
1477cdf0e10cSrcweir  .ENDIF
1478cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_6.cmd
1479cdf0e10cSrcweir	@ls -l $@
1480cdf0e10cSrcweir.ELSE	# "$(COM)" == "GCC"
1481cdf0e10cSrcweir.IF "$(linkinc)" == ""
1482cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP6LINKER) @$(mktmp \
1483cdf0e10cSrcweir		$(APP6LINKFLAGS) \
1484cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP6BASEX) \
1485cdf0e10cSrcweir		$(APP6STACKN) \
1486cdf0e10cSrcweir		-out:$@ \
1487cdf0e10cSrcweir		-map:$(MISC)/{$(subst,/,_ $(APP6TARGET)).map} \
1488cdf0e10cSrcweir		$(STDOBJ) \
1489cdf0e10cSrcweir		$(APP6LINKRES) \
1490cdf0e10cSrcweir		$(APP6RES) \
1491cdf0e10cSrcweir		$(APP6OBJS) \
1492cdf0e10cSrcweir		$(APP6LIBS) \
1493cdf0e10cSrcweir		$(APP6STDLIBS) \
1494cdf0e10cSrcweir		$(APP6STDLIB) $(STDLIB6) \
1495cdf0e10cSrcweir		)
1496cdf0e10cSrcweir	@-echo linking $@.manifest ...
1497cdf0e10cSrcweir.IF "$(VISTA_MANIFEST)"!=""
1498cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -manifest $(TRUSTED_MANIFEST_LOCATION)/trustedinfo.manifest -out:$@.tmanifest$(EMQ) $(FI)
1499cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.tmanifest -outputresource:$@$(EMQ);1 $(FI)
1500cdf0e10cSrcweir.ELSE
1501cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -outputresource:$@$(EMQ);1 $(FI)
1502cdf0e10cSrcweir.ENDIF # "$(VISTA_MANIFEST)"!=""
1503cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(RM:s/+//) $@.manifest $(FI)
1504cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.tmanifest $(THEN) $(RM:s/+//) $@.tmanifest $(FI)
1505cdf0e10cSrcweir.ELSE
1506cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP6TARGET).lnk
1507cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP6TARGET).lst
1508cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\linkobj.lst
1509cdf0e10cSrcweir		for %_i in ($(MISC)\*.obj) do type %_i >> $(MISC)\linkobj.lst
1510cdf0e10cSrcweir	type $(mktmp,$(MISC)\$(APP6TARGET).lst
1511cdf0e10cSrcweir		$(APP6LINKFLAGS) \
1512cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP6BASEX) \
1513cdf0e10cSrcweir		$(APP6STACKN) \
1514cdf0e10cSrcweir		-out:$@ \
1515cdf0e10cSrcweir		$(STDOBJ) \
1516cdf0e10cSrcweir		$(APP6LINKRES) \
1517cdf0e10cSrcweir		$(APP6RES) \
1518cdf0e10cSrcweir		$(APP6OBJS) \
1519cdf0e10cSrcweir		$(APP6LIBS) \
1520cdf0e10cSrcweir		$(APP6STDLIBS) \
1521cdf0e10cSrcweir		$(APP6STDLIB) $(STDLIB6))
1522cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(SED) -e 's/\(\.\.\\\)\{2,4\}/..\\/g' $(MISC)\$(APP6TARGETN:b)_linkobj.lst >> $(MISC)\$(APP6TARGET).lst
1523cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(IFEXIST) $(MISC)/$(APP6TARGET).lst $(THEN) type $(MISC)/$(APP6TARGET).lst  >> $(MISC)/$(APP6TARGET).lnk $(FI)
1524cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(APP6LINKER) @$(MISC)\$(APP6TARGET).lnk
1525cdf0e10cSrcweir.ENDIF		# "$(linkinc)" == ""
1526cdf0e10cSrcweir.ENDIF		# "$(COM)" == "GCC"
1527cdf0e10cSrcweir.IF "$(APP6TARGET)" == "loader"
1528cdf0e10cSrcweir	$(COMMAND_ECHO)$(PERL) loader.pl $@
1529cdf0e10cSrcweir	$(COMMAND_ECHO)$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
1530cdf0e10cSrcweir	$(COMMAND_ECHO)$(RM) $@
1531cdf0e10cSrcweir	$(COMMAND_ECHO)$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
1532cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
1533cdf0e10cSrcweir
1534cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "WNT"
1535cdf0e10cSrcweir
1536cdf0e10cSrcweir.IF "$(GUI)" == "OS2"
1537534c536dSYuri Dario	@+-$(MKDIR) $(@:d:d) > $(NULLDEV)
1538cdf0e10cSrcweir.IF "$(APP6LINKRES)" != ""
1539534c536dSYuri Dario	@+-$(RM) $(MISC)/$(APP6LINKRES:b).rc > $(NULLDEV)
1540cdf0e10cSrcweir.IF "$(APP6ICON)" != ""
1541534c536dSYuri Dario	@-+echo ICON 1 $(EMQ)"$(APP6ICON:s#/#\\\\#)$(EMQ)" >> $(MISC)$/$(APP6LINKRES:b).rc
1542cdf0e10cSrcweir.ENDIF		# "$(APP6ICON)" != ""
1543cdf0e10cSrcweir.IF "$(APP6VERINFO)" != ""
1544cdf0e10cSrcweir	@-+echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP6LINKRES:b).rc
1545cdf0e10cSrcweir	@-+echo $(EMQ)#include  $(EMQ)"$(APP6VERINFO)$(EMQ)" >> $(MISC)/$(APP6LINKRES:b).rc
1546cdf0e10cSrcweir.ENDIF		# "$(APP6VERINFO)" != ""
1547cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -r -DOS2 $(APP6PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP6LINKRES:b).rc
1548cdf0e10cSrcweir.ENDIF			# "$(APP6LINKRES)" != ""
1549cdf0e10cSrcweir
1550cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
1551cdf0e10cSrcweir	@echo NAME $(APP6TARGET) WINDOWAPI > $(MISC)/$(APP6TARGET).def
1552cdf0e10cSrcweir.ENDIF
1553cdf0e10cSrcweir
1554cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP6LINKER) -v \
1555cdf0e10cSrcweir		$(APP6LINKFLAGS) \
1556cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP6BASEX) \
1557cdf0e10cSrcweir		$(APP6STACKN) \
1558cdf0e10cSrcweir		-o $@ \
1559cdf0e10cSrcweir		-Zmap -L$(LB) \
1560cdf0e10cSrcweir		-L$(SOLARVERSION)/$(INPATH)/lib \
1561cdf0e10cSrcweir		$(STDOBJ) \
1562cdf0e10cSrcweir		$(APP6LINKRES) \
1563cdf0e10cSrcweir		$(APP6RES) \
1564cdf0e10cSrcweir		$(APP6DEF) \
1565cdf0e10cSrcweir		$(APP6OBJS) \
1566cdf0e10cSrcweir		$(APP6LIBS) \
1567534c536dSYuri Dario		$(APP6STDLIBS) \
1568534c536dSYuri Dario		$(APP6STDLIB) $(STDLIB6)
1569cdf0e10cSrcweir
1570cdf0e10cSrcweir
1571cdf0e10cSrcweir.IF "$(APP6TARGET)" == "loader"
1572cdf0e10cSrcweir	$(COMMAND_ECHO)+$(PERL) loader.pl $@
1573cdf0e10cSrcweir	$(COMMAND_ECHO)+$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
1574cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RM) $@
1575cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
1576cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
1577cdf0e10cSrcweir
1578cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "OS2"
1579cdf0e10cSrcweir
1580cdf0e10cSrcweir.ENDIF			# "$(APP6TARGETN)"!=""
1581cdf0e10cSrcweir
1582cdf0e10cSrcweir
1583cdf0e10cSrcweir# Instruction for linking
1584cdf0e10cSrcweir# unroll begin
1585cdf0e10cSrcweir
1586cdf0e10cSrcweir.IF "$(GUI)" == "OS2" && "$(TARGETTYPE)" == "GUI"
1587cdf0e10cSrcweirAPP7DEF = $(MISC)/$(APP7TARGET).def
1588cdf0e10cSrcweir.ENDIF
1589cdf0e10cSrcweir
1590cdf0e10cSrcweir.IF "$(APP7LINKTYPE)" != ""
1591cdf0e10cSrcweir#must be either STATIC or SHARED
1592cdf0e10cSrcweirAPP7LINKTYPEFLAG=$(APPLINK$(APP7LINKTYPE))
1593cdf0e10cSrcweir.ENDIF
1594cdf0e10cSrcweir
1595cdf0e10cSrcweir# decide how to link
1596cdf0e10cSrcweir.IF "$(APP7CODETYPE)"=="C"
1597cdf0e10cSrcweirAPP7LINKER=$(LINKC)
1598cdf0e10cSrcweirAPP7STDLIB=$(subst,CPPRUNTIME, $(STDLIB))
1599cdf0e10cSrcweirAPP7LINKFLAGS+=$(LINKCFLAGS)
1600cdf0e10cSrcweir.ELSE			# "$(APP7CODETYPE)"=="C"
1601cdf0e10cSrcweirAPP7LINKER=$(LINK)
1602cdf0e10cSrcweirAPP7STDLIB=$(subst,CPPRUNTIME,$(STDLIBCPP) $(STDLIB))
1603cdf0e10cSrcweirAPP7LINKFLAGS+=$(LINKFLAGS)
1604cdf0e10cSrcweir.ENDIF			# "$(APP7CODETYPE)"=="C"
1605cdf0e10cSrcweir
1606cdf0e10cSrcweirAPP7RPATH*=OOO
1607cdf0e10cSrcweirLINKFLAGSRUNPATH_$(APP7RPATH)*=/ERROR:/Bad_APP7RPATH_value
1608cdf0e10cSrcweir.IF "$(OS)" != "MACOSX"
1609cdf0e10cSrcweirAPP7LINKFLAGS+=$(LINKFLAGSRUNPATH_$(APP7RPATH))
1610cdf0e10cSrcweir.ENDIF
1611cdf0e10cSrcweir
1612cdf0e10cSrcweir.IF "$(APP7STACK)" != ""
1613cdf0e10cSrcweir.IF "$(LINKFLAGSTACK)" != ""
1614cdf0e10cSrcweirAPP7STACKN=$(LINKFLAGSTACK)$(APP7STACK)
1615cdf0e10cSrcweir.ENDIF
1616cdf0e10cSrcweir.ELSE
1617cdf0e10cSrcweirAPP7STACKN=
1618cdf0e10cSrcweir.ENDIF
1619cdf0e10cSrcweir
1620cdf0e10cSrcweir.IF "$(APP7NOSAL)"==""
1621cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
1622cdf0e10cSrcweirAPP7OBJS+= $(STDOBJVCL)
1623cdf0e10cSrcweir.ENDIF
1624cdf0e10cSrcweir.ENDIF
1625cdf0e10cSrcweir
1626cdf0e10cSrcweir.IF "$(GUI)$(COM)" == "WNTGCC"
1627cdf0e10cSrcweirAPP7RESO=
1628cdf0e10cSrcweir.IF "$(APP7LINKRES)" != "" || "$(APP7RES)" != ""
1629cdf0e10cSrcweirAPP7RESO=$(MISC)/$(APP7TARGET:b)_res.o
1630cdf0e10cSrcweir.ENDIF
1631cdf0e10cSrcweir.ENDIF
1632cdf0e10cSrcweir
1633cdf0e10cSrcweir.IF "$(GUI)" == "UNX"
1634cdf0e10cSrcweirAPP7DEPN+:=$(APP7DEPNU)
1635cdf0e10cSrcweirUSE_APP7DEF=
1636cdf0e10cSrcweir.ENDIF
1637cdf0e10cSrcweir
1638cdf0e10cSrcweir.IF "$(APP7TARGETN)"!=""
1639cdf0e10cSrcweir
1640cdf0e10cSrcweir.IF "$(APP7PRODUCTNAME)"!=""
1641cdf0e10cSrcweirAPP7PRODUCTDEF+:=-DPRODUCT_NAME=\"$(APP7PRODUCTNAME)\"
1642cdf0e10cSrcweir.ENDIF			# "$(APP7PRODUCTNAME)"!=""
1643cdf0e10cSrcweir
1644cdf0e10cSrcweir.IF "$(linkinc)"!=""
1645cdf0e10cSrcweir.IF "$(GUI)"=="WNT" || "$(GUI)"=="OS2"
1646cdf0e10cSrcweir.IF "$(APP7LIBS)"!=""
1647cdf0e10cSrcweir$(MISC)/$(APP7TARGET)_linkinc.ls .PHONY:
1648cdf0e10cSrcweir	@@-$(RM) $@
1649cdf0e10cSrcweir	sed -f $(SOLARENV)/bin/chrel.sed $(foreach,i,$(APP7LIBS) $(i:s/.lib/.lin/)) >> $@
1650cdf0e10cSrcweir.ENDIF          #"$(APP7LIBS)"!=""
1651cdf0e10cSrcweir.ENDIF
1652cdf0e10cSrcweir
1653cdf0e10cSrcweirLINKINCTARGETS+=$(MISC)/$(APP7TARGETN:b)_linkinc.ls
1654cdf0e10cSrcweir$(APP7TARGETN) : $(LINKINCTARGETS)
1655cdf0e10cSrcweir.ENDIF          # "$(linkinc)"!=""
1656cdf0e10cSrcweir
1657cdf0e10cSrcweir# Allow for target specific LIBSALCPPRT override
1658cdf0e10cSrcweirAPP7LIBSALCPPRT*=$(LIBSALCPPRT)
1659cdf0e10cSrcweir
1660cdf0e10cSrcweir$(APP7TARGETN): $(APP7OBJS) $(APP7LIBS) \
1661cdf0e10cSrcweir	$(APP7RES) \
1662cdf0e10cSrcweir	$(APP7ICON) $(APP7DEPN) $(USE_APP7DEF)
1663cdf0e10cSrcweir	@echo "Making:   " $(@:f)
1664cdf0e10cSrcweir.IF "$(GUI)"=="UNX"
1665cdf0e10cSrcweir.IF "$(OS)"=="MACOSX"
1666cdf0e10cSrcweir	@echo unx
1667cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).list
1668cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_7.cmd
1669cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).strip
1670cdf0e10cSrcweir	@echo $(STDSLO) $(APP7OBJS:s/.obj/.o/) \
1671cdf0e10cSrcweir	`cat /dev/null $(APP7LIBS) | sed s\#$(ROUT)\#$(OUT)\#g` | tr -s " " "\n" > $(MISC)/$(@:b).list
1672cdf0e10cSrcweir	@echo -n $(APP7LINKER) $(APP7LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) -o $@ \
1673cdf0e10cSrcweir	$(APP7LINKTYPEFLAG) $(APP7STDLIBS) $(APP7STDLIB) $(STDLIB7) -filelist $(MISC)/$(@:b).list > $(MISC)/$(TARGET).$(@:b)_7.cmd
1674cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-dylib-link-list.pl \
1675cdf0e10cSrcweir        `cat $(MISC)/$(TARGET).$(@:b)_7.cmd` \
1676cdf0e10cSrcweir        >> $(MISC)/$(TARGET).$(@:b)_7.cmd
1677cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
1678cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_7.cmd
1679cdf0e10cSrcweir  .ENDIF
1680cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_7.cmd
1681cdf0e10cSrcweir# Need to strip __objcInit symbol to avoid duplicate symbols when loading
1682cdf0e10cSrcweir# libraries at runtime
16838badc1b4SHerbert Dürr	@-$(CC_PATH)nm $@ | grep -v ' U ' | $(AWK) '{ print $$NF }' | grep -F -x '__objcInit' > $(MISC)/$(@:b).strip
16848badc1b4SHerbert Dürr	@$(CC_PATH)strip -i -R $(MISC)/$(@:b).strip -X $@
1685cdf0e10cSrcweir	@ls -l $@
1686cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-change-install-names.pl \
1687cdf0e10cSrcweir        app $(APP7RPATH) $@
1688cdf0e10cSrcweir.IF "$(TARGETTYPE)"=="GUI"
1689cdf0e10cSrcweir	@echo "Making:   " $(@:f).app
1690cdf0e10cSrcweir	@macosx-create-bundle $@
1691cdf0e10cSrcweir.ENDIF		# "$(TARGETTYPE)"=="GUI"
1692cdf0e10cSrcweir.ELSE		# "$(OS)"=="MACOSX"
1693cdf0e10cSrcweir	@echo unx
1694cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_7.cmd
1695cdf0e10cSrcweir	@echo $(APP7LINKER) $(APP7LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
1696cdf0e10cSrcweir	$(APP7OBJS:s/.obj/.o/) '\' >  $(MISC)/$(TARGET).$(@:b)_7.cmd
1697cdf0e10cSrcweir	@cat $(mktmp /dev/null $(APP7LIBS)) | xargs -n 1 cat | sed s\#$(ROUT)\#$(OUT)\#g | sed 's#$$# \\#'  >> $(MISC)/$(TARGET).$(@:b)_7.cmd
1698cdf0e10cSrcweir	@echo $(APP7LINKTYPEFLAG) $(APP7LIBSALCPPRT) $(APP7STDLIBS) $(APP7STDLIB) $(STDLIB7) -o $@ >> $(MISC)/$(TARGET).$(@:b)_7.cmd
1699cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
1700cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_7.cmd
1701cdf0e10cSrcweir  .ENDIF
1702cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_7.cmd
1703cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
1704cdf0e10cSrcweir	@ls -l $@
1705cdf0e10cSrcweir  .ENDIF
1706cdf0e10cSrcweir.ENDIF		# "$(OS)"=="MACOSX"
1707cdf0e10cSrcweir.ENDIF
1708cdf0e10cSrcweir.IF "$(GUI)" == "WNT"
1709cdf0e10cSrcweir	@@-$(MKDIR) $(@:d:d)
1710cdf0e10cSrcweir.IF "$(APP7LINKRES)" != ""
1711cdf0e10cSrcweir	@@-$(RM) $(MISC)/$(APP7LINKRES:b).rc
1712cdf0e10cSrcweir.IF "$(APP7ICON)" != ""
1713cdf0e10cSrcweir	@-echo 1 ICON $(EMQ)"$(APP7ICON:s/\/\\/)$(EMQ)" >> $(MISC)/$(APP7LINKRES:b).rc
1714cdf0e10cSrcweir.ENDIF		# "$(APP7ICON)" != ""
1715cdf0e10cSrcweir.IF "$(APP7VERINFO)" != ""
1716cdf0e10cSrcweir	@-echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP7LINKRES:b).rc
1717cdf0e10cSrcweir	@-echo $(EMQ)#include  $(EMQ)"$(APP7VERINFO)$(EMQ)" >> $(MISC)/$(APP7LINKRES:b).rc
1718cdf0e10cSrcweir.ENDIF		# "$(APP7VERINFO)" != ""
1719cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -DWIN32 $(APP7PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP7LINKRES:b).rc
1720cdf0e10cSrcweir.ENDIF			# "$(APP7LINKRES)" != ""
1721cdf0e10cSrcweir.IF "$(COM)" == "GCC"
1722cdf0e10cSrcweir	@echo mingw
1723cdf0e10cSrcweir.IF "$(APP7LINKRES)" != "" || "$(APP7RES)" != ""
1724cdf0e10cSrcweir	@cat $(APP7LINKRES) $(subst,/res/,/res{$(subst,$(BIN), $(@:d))} $(APP7RES)) >  $(MISC)/$(@:b)_all.res
1725cdf0e10cSrcweir	windres $(MISC)/$(@:b)_all.res $(APP7RESO)
1726cdf0e10cSrcweir.ENDIF
1727cdf0e10cSrcweir	@echo $(LINK) $(LINKFLAGS) $(LINKFLAGSAPP) $(MINGWSSTDOBJ) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
1728cdf0e10cSrcweir		$(APP7BASEX) $(APP7STACKN) -o $@ $(APP7OBJS) \
1729cdf0e10cSrcweir		-Wl,-Map,$(MISC)/$(@:b).map $(STDOBJ) $(APP7RESO) \
1730cdf0e10cSrcweir		`$(TYPE) /dev/null $(APP7LIBS) | sed s#$(ROUT)#$(OUT)#g` \
1731cdf0e10cSrcweir		$(APP_LINKTYPE) $(APP7LIBSALCPPRT) \
1732cdf0e10cSrcweir		-Wl,--start-group $(APP7STDLIBS) -Wl,--end-group $(APP7STDLIB) \
1733cdf0e10cSrcweir		$(STDLIB7) $(MINGWSSTDENDOBJ) > $(MISC)/$(TARGET).$(@:b)_7.cmd
1734cdf0e10cSrcweir  # need this empty line, else dmake somehow gets confused by the .IFs and .ENDIFs
1735cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
1736cdf0e10cSrcweir	@$(TYPE)  $(MISC)/$(TARGET).$(@:b)_7.cmd
1737cdf0e10cSrcweir  .ENDIF
1738cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_7.cmd
1739cdf0e10cSrcweir	@ls -l $@
1740cdf0e10cSrcweir.ELSE	# "$(COM)" == "GCC"
1741cdf0e10cSrcweir.IF "$(linkinc)" == ""
1742cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP7LINKER) @$(mktmp \
1743cdf0e10cSrcweir		$(APP7LINKFLAGS) \
1744cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP7BASEX) \
1745cdf0e10cSrcweir		$(APP7STACKN) \
1746cdf0e10cSrcweir		-out:$@ \
1747cdf0e10cSrcweir		-map:$(MISC)/{$(subst,/,_ $(APP7TARGET)).map} \
1748cdf0e10cSrcweir		$(STDOBJ) \
1749cdf0e10cSrcweir		$(APP7LINKRES) \
1750cdf0e10cSrcweir		$(APP7RES) \
1751cdf0e10cSrcweir		$(APP7OBJS) \
1752cdf0e10cSrcweir		$(APP7LIBS) \
1753cdf0e10cSrcweir		$(APP7STDLIBS) \
1754cdf0e10cSrcweir		$(APP7STDLIB) $(STDLIB7) \
1755cdf0e10cSrcweir		)
1756cdf0e10cSrcweir	@-echo linking $@.manifest ...
1757cdf0e10cSrcweir.IF "$(VISTA_MANIFEST)"!=""
1758cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -manifest $(TRUSTED_MANIFEST_LOCATION)/trustedinfo.manifest -out:$@.tmanifest$(EMQ) $(FI)
1759cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.tmanifest -outputresource:$@$(EMQ);1 $(FI)
1760cdf0e10cSrcweir.ELSE
1761cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -outputresource:$@$(EMQ);1 $(FI)
1762cdf0e10cSrcweir.ENDIF # "$(VISTA_MANIFEST)"!=""
1763cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(RM:s/+//) $@.manifest $(FI)
1764cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.tmanifest $(THEN) $(RM:s/+//) $@.tmanifest $(FI)
1765cdf0e10cSrcweir.ELSE
1766cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP7TARGET).lnk
1767cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP7TARGET).lst
1768cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\linkobj.lst
1769cdf0e10cSrcweir		for %_i in ($(MISC)\*.obj) do type %_i >> $(MISC)\linkobj.lst
1770cdf0e10cSrcweir	type $(mktmp,$(MISC)\$(APP7TARGET).lst
1771cdf0e10cSrcweir		$(APP7LINKFLAGS) \
1772cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP7BASEX) \
1773cdf0e10cSrcweir		$(APP7STACKN) \
1774cdf0e10cSrcweir		-out:$@ \
1775cdf0e10cSrcweir		$(STDOBJ) \
1776cdf0e10cSrcweir		$(APP7LINKRES) \
1777cdf0e10cSrcweir		$(APP7RES) \
1778cdf0e10cSrcweir		$(APP7OBJS) \
1779cdf0e10cSrcweir		$(APP7LIBS) \
1780cdf0e10cSrcweir		$(APP7STDLIBS) \
1781cdf0e10cSrcweir		$(APP7STDLIB) $(STDLIB7))
1782cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(SED) -e 's/\(\.\.\\\)\{2,4\}/..\\/g' $(MISC)\$(APP7TARGETN:b)_linkobj.lst >> $(MISC)\$(APP7TARGET).lst
1783cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(IFEXIST) $(MISC)/$(APP7TARGET).lst $(THEN) type $(MISC)/$(APP7TARGET).lst  >> $(MISC)/$(APP7TARGET).lnk $(FI)
1784cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(APP7LINKER) @$(MISC)\$(APP7TARGET).lnk
1785cdf0e10cSrcweir.ENDIF		# "$(linkinc)" == ""
1786cdf0e10cSrcweir.ENDIF		# "$(COM)" == "GCC"
1787cdf0e10cSrcweir.IF "$(APP7TARGET)" == "loader"
1788cdf0e10cSrcweir	$(COMMAND_ECHO)$(PERL) loader.pl $@
1789cdf0e10cSrcweir	$(COMMAND_ECHO)$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
1790cdf0e10cSrcweir	$(COMMAND_ECHO)$(RM) $@
1791cdf0e10cSrcweir	$(COMMAND_ECHO)$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
1792cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
1793cdf0e10cSrcweir
1794cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "WNT"
1795cdf0e10cSrcweir
1796cdf0e10cSrcweir.IF "$(GUI)" == "OS2"
1797534c536dSYuri Dario	@+-$(MKDIR) $(@:d:d) > $(NULLDEV)
1798cdf0e10cSrcweir.IF "$(APP7LINKRES)" != ""
1799534c536dSYuri Dario	@+-$(RM) $(MISC)/$(APP7LINKRES:b).rc > $(NULLDEV)
1800cdf0e10cSrcweir.IF "$(APP7ICON)" != ""
1801534c536dSYuri Dario	@-+echo ICON 1 $(EMQ)"$(APP7ICON:s#/#\\\\#)$(EMQ)" >> $(MISC)$/$(APP7LINKRES:b).rc
1802cdf0e10cSrcweir.ENDIF		# "$(APP7ICON)" != ""
1803cdf0e10cSrcweir.IF "$(APP7VERINFO)" != ""
1804cdf0e10cSrcweir	@-+echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP7LINKRES:b).rc
1805cdf0e10cSrcweir	@-+echo $(EMQ)#include  $(EMQ)"$(APP7VERINFO)$(EMQ)" >> $(MISC)/$(APP7LINKRES:b).rc
1806cdf0e10cSrcweir.ENDIF		# "$(APP7VERINFO)" != ""
1807cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -r -DOS2 $(APP7PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP7LINKRES:b).rc
1808cdf0e10cSrcweir.ENDIF			# "$(APP7LINKRES)" != ""
1809cdf0e10cSrcweir
1810cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
1811cdf0e10cSrcweir	@echo NAME $(APP7TARGET) WINDOWAPI > $(MISC)/$(APP7TARGET).def
1812cdf0e10cSrcweir.ENDIF
1813cdf0e10cSrcweir
1814cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP7LINKER) -v \
1815cdf0e10cSrcweir		$(APP7LINKFLAGS) \
1816cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP7BASEX) \
1817cdf0e10cSrcweir		$(APP7STACKN) \
1818cdf0e10cSrcweir		-o $@ \
1819cdf0e10cSrcweir		-Zmap -L$(LB) \
1820cdf0e10cSrcweir		-L$(SOLARVERSION)/$(INPATH)/lib \
1821cdf0e10cSrcweir		$(STDOBJ) \
1822cdf0e10cSrcweir		$(APP7LINKRES) \
1823cdf0e10cSrcweir		$(APP7RES) \
1824cdf0e10cSrcweir		$(APP7DEF) \
1825cdf0e10cSrcweir		$(APP7OBJS) \
1826cdf0e10cSrcweir		$(APP7LIBS) \
1827534c536dSYuri Dario		$(APP7STDLIBS) \
1828534c536dSYuri Dario		$(APP7STDLIB) $(STDLIB7)
1829cdf0e10cSrcweir
1830cdf0e10cSrcweir
1831cdf0e10cSrcweir.IF "$(APP7TARGET)" == "loader"
1832cdf0e10cSrcweir	$(COMMAND_ECHO)+$(PERL) loader.pl $@
1833cdf0e10cSrcweir	$(COMMAND_ECHO)+$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
1834cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RM) $@
1835cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
1836cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
1837cdf0e10cSrcweir
1838cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "OS2"
1839cdf0e10cSrcweir
1840cdf0e10cSrcweir.ENDIF			# "$(APP7TARGETN)"!=""
1841cdf0e10cSrcweir
1842cdf0e10cSrcweir
1843cdf0e10cSrcweir# Instruction for linking
1844cdf0e10cSrcweir# unroll begin
1845cdf0e10cSrcweir
1846cdf0e10cSrcweir.IF "$(GUI)" == "OS2" && "$(TARGETTYPE)" == "GUI"
1847cdf0e10cSrcweirAPP8DEF = $(MISC)/$(APP8TARGET).def
1848cdf0e10cSrcweir.ENDIF
1849cdf0e10cSrcweir
1850cdf0e10cSrcweir.IF "$(APP8LINKTYPE)" != ""
1851cdf0e10cSrcweir#must be either STATIC or SHARED
1852cdf0e10cSrcweirAPP8LINKTYPEFLAG=$(APPLINK$(APP8LINKTYPE))
1853cdf0e10cSrcweir.ENDIF
1854cdf0e10cSrcweir
1855cdf0e10cSrcweir# decide how to link
1856cdf0e10cSrcweir.IF "$(APP8CODETYPE)"=="C"
1857cdf0e10cSrcweirAPP8LINKER=$(LINKC)
1858cdf0e10cSrcweirAPP8STDLIB=$(subst,CPPRUNTIME, $(STDLIB))
1859cdf0e10cSrcweirAPP8LINKFLAGS+=$(LINKCFLAGS)
1860cdf0e10cSrcweir.ELSE			# "$(APP8CODETYPE)"=="C"
1861cdf0e10cSrcweirAPP8LINKER=$(LINK)
1862cdf0e10cSrcweirAPP8STDLIB=$(subst,CPPRUNTIME,$(STDLIBCPP) $(STDLIB))
1863cdf0e10cSrcweirAPP8LINKFLAGS+=$(LINKFLAGS)
1864cdf0e10cSrcweir.ENDIF			# "$(APP8CODETYPE)"=="C"
1865cdf0e10cSrcweir
1866cdf0e10cSrcweirAPP8RPATH*=OOO
1867cdf0e10cSrcweirLINKFLAGSRUNPATH_$(APP8RPATH)*=/ERROR:/Bad_APP8RPATH_value
1868cdf0e10cSrcweir.IF "$(OS)" != "MACOSX"
1869cdf0e10cSrcweirAPP8LINKFLAGS+=$(LINKFLAGSRUNPATH_$(APP8RPATH))
1870cdf0e10cSrcweir.ENDIF
1871cdf0e10cSrcweir
1872cdf0e10cSrcweir.IF "$(APP8STACK)" != ""
1873cdf0e10cSrcweir.IF "$(LINKFLAGSTACK)" != ""
1874cdf0e10cSrcweirAPP8STACKN=$(LINKFLAGSTACK)$(APP8STACK)
1875cdf0e10cSrcweir.ENDIF
1876cdf0e10cSrcweir.ELSE
1877cdf0e10cSrcweirAPP8STACKN=
1878cdf0e10cSrcweir.ENDIF
1879cdf0e10cSrcweir
1880cdf0e10cSrcweir.IF "$(APP8NOSAL)"==""
1881cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
1882cdf0e10cSrcweirAPP8OBJS+= $(STDOBJVCL)
1883cdf0e10cSrcweir.ENDIF
1884cdf0e10cSrcweir.ENDIF
1885cdf0e10cSrcweir
1886cdf0e10cSrcweir.IF "$(GUI)$(COM)" == "WNTGCC"
1887cdf0e10cSrcweirAPP8RESO=
1888cdf0e10cSrcweir.IF "$(APP8LINKRES)" != "" || "$(APP8RES)" != ""
1889cdf0e10cSrcweirAPP8RESO=$(MISC)/$(APP8TARGET:b)_res.o
1890cdf0e10cSrcweir.ENDIF
1891cdf0e10cSrcweir.ENDIF
1892cdf0e10cSrcweir
1893cdf0e10cSrcweir.IF "$(GUI)" == "UNX"
1894cdf0e10cSrcweirAPP8DEPN+:=$(APP8DEPNU)
1895cdf0e10cSrcweirUSE_APP8DEF=
1896cdf0e10cSrcweir.ENDIF
1897cdf0e10cSrcweir
1898cdf0e10cSrcweir.IF "$(APP8TARGETN)"!=""
1899cdf0e10cSrcweir
1900cdf0e10cSrcweir.IF "$(APP8PRODUCTNAME)"!=""
1901cdf0e10cSrcweirAPP8PRODUCTDEF+:=-DPRODUCT_NAME=\"$(APP8PRODUCTNAME)\"
1902cdf0e10cSrcweir.ENDIF			# "$(APP8PRODUCTNAME)"!=""
1903cdf0e10cSrcweir
1904cdf0e10cSrcweir.IF "$(linkinc)"!=""
1905cdf0e10cSrcweir.IF "$(GUI)"=="WNT" || "$(GUI)"=="OS2"
1906cdf0e10cSrcweir.IF "$(APP8LIBS)"!=""
1907cdf0e10cSrcweir$(MISC)/$(APP8TARGET)_linkinc.ls .PHONY:
1908cdf0e10cSrcweir	@@-$(RM) $@
1909cdf0e10cSrcweir	sed -f $(SOLARENV)/bin/chrel.sed $(foreach,i,$(APP8LIBS) $(i:s/.lib/.lin/)) >> $@
1910cdf0e10cSrcweir.ENDIF          #"$(APP8LIBS)"!=""
1911cdf0e10cSrcweir.ENDIF
1912cdf0e10cSrcweir
1913cdf0e10cSrcweirLINKINCTARGETS+=$(MISC)/$(APP8TARGETN:b)_linkinc.ls
1914cdf0e10cSrcweir$(APP8TARGETN) : $(LINKINCTARGETS)
1915cdf0e10cSrcweir.ENDIF          # "$(linkinc)"!=""
1916cdf0e10cSrcweir
1917cdf0e10cSrcweir# Allow for target specific LIBSALCPPRT override
1918cdf0e10cSrcweirAPP8LIBSALCPPRT*=$(LIBSALCPPRT)
1919cdf0e10cSrcweir
1920cdf0e10cSrcweir$(APP8TARGETN): $(APP8OBJS) $(APP8LIBS) \
1921cdf0e10cSrcweir	$(APP8RES) \
1922cdf0e10cSrcweir	$(APP8ICON) $(APP8DEPN) $(USE_APP8DEF)
1923cdf0e10cSrcweir	@echo "Making:   " $(@:f)
1924cdf0e10cSrcweir.IF "$(GUI)"=="UNX"
1925cdf0e10cSrcweir.IF "$(OS)"=="MACOSX"
1926cdf0e10cSrcweir	@echo unx
1927cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).list
1928cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_8.cmd
1929cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).strip
1930cdf0e10cSrcweir	@echo $(STDSLO) $(APP8OBJS:s/.obj/.o/) \
1931cdf0e10cSrcweir	`cat /dev/null $(APP8LIBS) | sed s\#$(ROUT)\#$(OUT)\#g` | tr -s " " "\n" > $(MISC)/$(@:b).list
1932cdf0e10cSrcweir	@echo -n $(APP8LINKER) $(APP8LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) -o $@ \
1933cdf0e10cSrcweir	$(APP8LINKTYPEFLAG) $(APP8STDLIBS) $(APP8STDLIB) $(STDLIB8) -filelist $(MISC)/$(@:b).list > $(MISC)/$(TARGET).$(@:b)_8.cmd
1934cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-dylib-link-list.pl \
1935cdf0e10cSrcweir        `cat $(MISC)/$(TARGET).$(@:b)_8.cmd` \
1936cdf0e10cSrcweir        >> $(MISC)/$(TARGET).$(@:b)_8.cmd
1937cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
1938cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_8.cmd
1939cdf0e10cSrcweir  .ENDIF
1940cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_8.cmd
1941cdf0e10cSrcweir# Need to strip __objcInit symbol to avoid duplicate symbols when loading
1942cdf0e10cSrcweir# libraries at runtime
19438badc1b4SHerbert Dürr	@-$(CC_PATH)nm $@ | grep -v ' U ' | $(AWK) '{ print $$NF }' | grep -F -x '__objcInit' > $(MISC)/$(@:b).strip
19448badc1b4SHerbert Dürr	@$(CC_PATH)strip -i -R $(MISC)/$(@:b).strip -X $@
1945cdf0e10cSrcweir	@ls -l $@
1946cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-change-install-names.pl \
1947cdf0e10cSrcweir        app $(APP8RPATH) $@
1948cdf0e10cSrcweir.IF "$(TARGETTYPE)"=="GUI"
1949cdf0e10cSrcweir	@echo "Making:   " $(@:f).app
1950cdf0e10cSrcweir	@macosx-create-bundle $@
1951cdf0e10cSrcweir.ENDIF		# "$(TARGETTYPE)"=="GUI"
1952cdf0e10cSrcweir.ELSE		# "$(OS)"=="MACOSX"
1953cdf0e10cSrcweir	@echo unx
1954cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_8.cmd
1955cdf0e10cSrcweir	@echo $(APP8LINKER) $(APP8LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
1956cdf0e10cSrcweir	$(APP8OBJS:s/.obj/.o/) '\' >  $(MISC)/$(TARGET).$(@:b)_8.cmd
1957cdf0e10cSrcweir	@cat $(mktmp /dev/null $(APP8LIBS)) | xargs -n 1 cat | sed s\#$(ROUT)\#$(OUT)\#g | sed 's#$$# \\#'  >> $(MISC)/$(TARGET).$(@:b)_8.cmd
1958cdf0e10cSrcweir	@echo $(APP8LINKTYPEFLAG) $(APP8LIBSALCPPRT) $(APP8STDLIBS) $(APP8STDLIB) $(STDLIB8) -o $@ >> $(MISC)/$(TARGET).$(@:b)_8.cmd
1959cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
1960cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_8.cmd
1961cdf0e10cSrcweir  .ENDIF
1962cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_8.cmd
1963cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
1964cdf0e10cSrcweir	@ls -l $@
1965cdf0e10cSrcweir  .ENDIF
1966cdf0e10cSrcweir.ENDIF		# "$(OS)"=="MACOSX"
1967cdf0e10cSrcweir.ENDIF
1968cdf0e10cSrcweir.IF "$(GUI)" == "WNT"
1969cdf0e10cSrcweir	@@-$(MKDIR) $(@:d:d)
1970cdf0e10cSrcweir.IF "$(APP8LINKRES)" != ""
1971cdf0e10cSrcweir	@@-$(RM) $(MISC)/$(APP8LINKRES:b).rc
1972cdf0e10cSrcweir.IF "$(APP8ICON)" != ""
1973cdf0e10cSrcweir	@-echo 1 ICON $(EMQ)"$(APP8ICON:s/\/\\/)$(EMQ)" >> $(MISC)/$(APP8LINKRES:b).rc
1974cdf0e10cSrcweir.ENDIF		# "$(APP8ICON)" != ""
1975cdf0e10cSrcweir.IF "$(APP8VERINFO)" != ""
1976cdf0e10cSrcweir	@-echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP8LINKRES:b).rc
1977cdf0e10cSrcweir	@-echo $(EMQ)#include  $(EMQ)"$(APP8VERINFO)$(EMQ)" >> $(MISC)/$(APP8LINKRES:b).rc
1978cdf0e10cSrcweir.ENDIF		# "$(APP8VERINFO)" != ""
1979cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -DWIN32 $(APP8PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP8LINKRES:b).rc
1980cdf0e10cSrcweir.ENDIF			# "$(APP8LINKRES)" != ""
1981cdf0e10cSrcweir.IF "$(COM)" == "GCC"
1982cdf0e10cSrcweir	@echo mingw
1983cdf0e10cSrcweir.IF "$(APP8LINKRES)" != "" || "$(APP8RES)" != ""
1984cdf0e10cSrcweir	@cat $(APP8LINKRES) $(subst,/res/,/res{$(subst,$(BIN), $(@:d))} $(APP8RES)) >  $(MISC)/$(@:b)_all.res
1985cdf0e10cSrcweir	windres $(MISC)/$(@:b)_all.res $(APP8RESO)
1986cdf0e10cSrcweir.ENDIF
1987cdf0e10cSrcweir	@echo $(LINK) $(LINKFLAGS) $(LINKFLAGSAPP) $(MINGWSSTDOBJ) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
1988cdf0e10cSrcweir		$(APP8BASEX) $(APP8STACKN) -o $@ $(APP8OBJS) \
1989cdf0e10cSrcweir		-Wl,-Map,$(MISC)/$(@:b).map $(STDOBJ) $(APP8RESO) \
1990cdf0e10cSrcweir		`$(TYPE) /dev/null $(APP8LIBS) | sed s#$(ROUT)#$(OUT)#g` \
1991cdf0e10cSrcweir		$(APP_LINKTYPE) $(APP8LIBSALCPPRT) \
1992cdf0e10cSrcweir		-Wl,--start-group $(APP8STDLIBS) -Wl,--end-group $(APP8STDLIB) \
1993cdf0e10cSrcweir		$(STDLIB8) $(MINGWSSTDENDOBJ) > $(MISC)/$(TARGET).$(@:b)_8.cmd
1994cdf0e10cSrcweir  # need this empty line, else dmake somehow gets confused by the .IFs and .ENDIFs
1995cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
1996cdf0e10cSrcweir	@$(TYPE)  $(MISC)/$(TARGET).$(@:b)_8.cmd
1997cdf0e10cSrcweir  .ENDIF
1998cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_8.cmd
1999cdf0e10cSrcweir	@ls -l $@
2000cdf0e10cSrcweir.ELSE	# "$(COM)" == "GCC"
2001cdf0e10cSrcweir.IF "$(linkinc)" == ""
2002cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP8LINKER) @$(mktmp \
2003cdf0e10cSrcweir		$(APP8LINKFLAGS) \
2004cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP8BASEX) \
2005cdf0e10cSrcweir		$(APP8STACKN) \
2006cdf0e10cSrcweir		-out:$@ \
2007cdf0e10cSrcweir		-map:$(MISC)/{$(subst,/,_ $(APP8TARGET)).map} \
2008cdf0e10cSrcweir		$(STDOBJ) \
2009cdf0e10cSrcweir		$(APP8LINKRES) \
2010cdf0e10cSrcweir		$(APP8RES) \
2011cdf0e10cSrcweir		$(APP8OBJS) \
2012cdf0e10cSrcweir		$(APP8LIBS) \
2013cdf0e10cSrcweir		$(APP8STDLIBS) \
2014cdf0e10cSrcweir		$(APP8STDLIB) $(STDLIB8) \
2015cdf0e10cSrcweir		)
2016cdf0e10cSrcweir	@-echo linking $@.manifest ...
2017cdf0e10cSrcweir.IF "$(VISTA_MANIFEST)"!=""
2018cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -manifest $(TRUSTED_MANIFEST_LOCATION)/trustedinfo.manifest -out:$@.tmanifest$(EMQ) $(FI)
2019cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.tmanifest -outputresource:$@$(EMQ);1 $(FI)
2020cdf0e10cSrcweir.ELSE
2021cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -outputresource:$@$(EMQ);1 $(FI)
2022cdf0e10cSrcweir.ENDIF # "$(VISTA_MANIFEST)"!=""
2023cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(RM:s/+//) $@.manifest $(FI)
2024cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.tmanifest $(THEN) $(RM:s/+//) $@.tmanifest $(FI)
2025cdf0e10cSrcweir.ELSE
2026cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP8TARGET).lnk
2027cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP8TARGET).lst
2028cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\linkobj.lst
2029cdf0e10cSrcweir		for %_i in ($(MISC)\*.obj) do type %_i >> $(MISC)\linkobj.lst
2030cdf0e10cSrcweir	type $(mktmp,$(MISC)\$(APP8TARGET).lst
2031cdf0e10cSrcweir		$(APP8LINKFLAGS) \
2032cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP8BASEX) \
2033cdf0e10cSrcweir		$(APP8STACKN) \
2034cdf0e10cSrcweir		-out:$@ \
2035cdf0e10cSrcweir		$(STDOBJ) \
2036cdf0e10cSrcweir		$(APP8LINKRES) \
2037cdf0e10cSrcweir		$(APP8RES) \
2038cdf0e10cSrcweir		$(APP8OBJS) \
2039cdf0e10cSrcweir		$(APP8LIBS) \
2040cdf0e10cSrcweir		$(APP8STDLIBS) \
2041cdf0e10cSrcweir		$(APP8STDLIB) $(STDLIB8))
2042cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(SED) -e 's/\(\.\.\\\)\{2,4\}/..\\/g' $(MISC)\$(APP8TARGETN:b)_linkobj.lst >> $(MISC)\$(APP8TARGET).lst
2043cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(IFEXIST) $(MISC)/$(APP8TARGET).lst $(THEN) type $(MISC)/$(APP8TARGET).lst  >> $(MISC)/$(APP8TARGET).lnk $(FI)
2044cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(APP8LINKER) @$(MISC)\$(APP8TARGET).lnk
2045cdf0e10cSrcweir.ENDIF		# "$(linkinc)" == ""
2046cdf0e10cSrcweir.ENDIF		# "$(COM)" == "GCC"
2047cdf0e10cSrcweir.IF "$(APP8TARGET)" == "loader"
2048cdf0e10cSrcweir	$(COMMAND_ECHO)$(PERL) loader.pl $@
2049cdf0e10cSrcweir	$(COMMAND_ECHO)$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
2050cdf0e10cSrcweir	$(COMMAND_ECHO)$(RM) $@
2051cdf0e10cSrcweir	$(COMMAND_ECHO)$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
2052cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
2053cdf0e10cSrcweir
2054cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "WNT"
2055cdf0e10cSrcweir
2056cdf0e10cSrcweir.IF "$(GUI)" == "OS2"
2057534c536dSYuri Dario	@+-$(MKDIR) $(@:d:d) > $(NULLDEV)
2058cdf0e10cSrcweir.IF "$(APP8LINKRES)" != ""
2059534c536dSYuri Dario	@+-$(RM) $(MISC)/$(APP8LINKRES:b).rc > $(NULLDEV)
2060cdf0e10cSrcweir.IF "$(APP8ICON)" != ""
2061534c536dSYuri Dario	@-+echo ICON 1 $(EMQ)"$(APP8ICON:s#/#\\\\#)$(EMQ)" >> $(MISC)$/$(APP8LINKRES:b).rc
2062cdf0e10cSrcweir.ENDIF		# "$(APP8ICON)" != ""
2063cdf0e10cSrcweir.IF "$(APP8VERINFO)" != ""
2064cdf0e10cSrcweir	@-+echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP8LINKRES:b).rc
2065cdf0e10cSrcweir	@-+echo $(EMQ)#include  $(EMQ)"$(APP8VERINFO)$(EMQ)" >> $(MISC)/$(APP8LINKRES:b).rc
2066cdf0e10cSrcweir.ENDIF		# "$(APP8VERINFO)" != ""
2067cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -r -DOS2 $(APP8PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP8LINKRES:b).rc
2068cdf0e10cSrcweir.ENDIF			# "$(APP8LINKRES)" != ""
2069cdf0e10cSrcweir
2070cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
2071cdf0e10cSrcweir	@echo NAME $(APP8TARGET) WINDOWAPI > $(MISC)/$(APP8TARGET).def
2072cdf0e10cSrcweir.ENDIF
2073cdf0e10cSrcweir
2074cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP8LINKER) -v \
2075cdf0e10cSrcweir		$(APP8LINKFLAGS) \
2076cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP8BASEX) \
2077cdf0e10cSrcweir		$(APP8STACKN) \
2078cdf0e10cSrcweir		-o $@ \
2079cdf0e10cSrcweir		-Zmap -L$(LB) \
2080cdf0e10cSrcweir		-L$(SOLARVERSION)/$(INPATH)/lib \
2081cdf0e10cSrcweir		$(STDOBJ) \
2082cdf0e10cSrcweir		$(APP8LINKRES) \
2083cdf0e10cSrcweir		$(APP8RES) \
2084cdf0e10cSrcweir		$(APP8DEF) \
2085cdf0e10cSrcweir		$(APP8OBJS) \
2086cdf0e10cSrcweir		$(APP8LIBS) \
2087534c536dSYuri Dario		$(APP8STDLIBS) \
2088534c536dSYuri Dario		$(APP8STDLIB) $(STDLIB8)
2089cdf0e10cSrcweir
2090cdf0e10cSrcweir
2091cdf0e10cSrcweir.IF "$(APP8TARGET)" == "loader"
2092cdf0e10cSrcweir	$(COMMAND_ECHO)+$(PERL) loader.pl $@
2093cdf0e10cSrcweir	$(COMMAND_ECHO)+$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
2094cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RM) $@
2095cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
2096cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
2097cdf0e10cSrcweir
2098cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "OS2"
2099cdf0e10cSrcweir
2100cdf0e10cSrcweir.ENDIF			# "$(APP8TARGETN)"!=""
2101cdf0e10cSrcweir
2102cdf0e10cSrcweir
2103cdf0e10cSrcweir# Instruction for linking
2104cdf0e10cSrcweir# unroll begin
2105cdf0e10cSrcweir
2106cdf0e10cSrcweir.IF "$(GUI)" == "OS2" && "$(TARGETTYPE)" == "GUI"
2107cdf0e10cSrcweirAPP9DEF = $(MISC)/$(APP9TARGET).def
2108cdf0e10cSrcweir.ENDIF
2109cdf0e10cSrcweir
2110cdf0e10cSrcweir.IF "$(APP9LINKTYPE)" != ""
2111cdf0e10cSrcweir#must be either STATIC or SHARED
2112cdf0e10cSrcweirAPP9LINKTYPEFLAG=$(APPLINK$(APP9LINKTYPE))
2113cdf0e10cSrcweir.ENDIF
2114cdf0e10cSrcweir
2115cdf0e10cSrcweir# decide how to link
2116cdf0e10cSrcweir.IF "$(APP9CODETYPE)"=="C"
2117cdf0e10cSrcweirAPP9LINKER=$(LINKC)
2118cdf0e10cSrcweirAPP9STDLIB=$(subst,CPPRUNTIME, $(STDLIB))
2119cdf0e10cSrcweirAPP9LINKFLAGS+=$(LINKCFLAGS)
2120cdf0e10cSrcweir.ELSE			# "$(APP9CODETYPE)"=="C"
2121cdf0e10cSrcweirAPP9LINKER=$(LINK)
2122cdf0e10cSrcweirAPP9STDLIB=$(subst,CPPRUNTIME,$(STDLIBCPP) $(STDLIB))
2123cdf0e10cSrcweirAPP9LINKFLAGS+=$(LINKFLAGS)
2124cdf0e10cSrcweir.ENDIF			# "$(APP9CODETYPE)"=="C"
2125cdf0e10cSrcweir
2126cdf0e10cSrcweirAPP9RPATH*=OOO
2127cdf0e10cSrcweirLINKFLAGSRUNPATH_$(APP9RPATH)*=/ERROR:/Bad_APP9RPATH_value
2128cdf0e10cSrcweir.IF "$(OS)" != "MACOSX"
2129cdf0e10cSrcweirAPP9LINKFLAGS+=$(LINKFLAGSRUNPATH_$(APP9RPATH))
2130cdf0e10cSrcweir.ENDIF
2131cdf0e10cSrcweir
2132cdf0e10cSrcweir.IF "$(APP9STACK)" != ""
2133cdf0e10cSrcweir.IF "$(LINKFLAGSTACK)" != ""
2134cdf0e10cSrcweirAPP9STACKN=$(LINKFLAGSTACK)$(APP9STACK)
2135cdf0e10cSrcweir.ENDIF
2136cdf0e10cSrcweir.ELSE
2137cdf0e10cSrcweirAPP9STACKN=
2138cdf0e10cSrcweir.ENDIF
2139cdf0e10cSrcweir
2140cdf0e10cSrcweir.IF "$(APP9NOSAL)"==""
2141cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
2142cdf0e10cSrcweirAPP9OBJS+= $(STDOBJVCL)
2143cdf0e10cSrcweir.ENDIF
2144cdf0e10cSrcweir.ENDIF
2145cdf0e10cSrcweir
2146cdf0e10cSrcweir.IF "$(GUI)$(COM)" == "WNTGCC"
2147cdf0e10cSrcweirAPP9RESO=
2148cdf0e10cSrcweir.IF "$(APP9LINKRES)" != "" || "$(APP9RES)" != ""
2149cdf0e10cSrcweirAPP9RESO=$(MISC)/$(APP9TARGET:b)_res.o
2150cdf0e10cSrcweir.ENDIF
2151cdf0e10cSrcweir.ENDIF
2152cdf0e10cSrcweir
2153cdf0e10cSrcweir.IF "$(GUI)" == "UNX"
2154cdf0e10cSrcweirAPP9DEPN+:=$(APP9DEPNU)
2155cdf0e10cSrcweirUSE_APP9DEF=
2156cdf0e10cSrcweir.ENDIF
2157cdf0e10cSrcweir
2158cdf0e10cSrcweir.IF "$(APP9TARGETN)"!=""
2159cdf0e10cSrcweir
2160cdf0e10cSrcweir.IF "$(APP9PRODUCTNAME)"!=""
2161cdf0e10cSrcweirAPP9PRODUCTDEF+:=-DPRODUCT_NAME=\"$(APP9PRODUCTNAME)\"
2162cdf0e10cSrcweir.ENDIF			# "$(APP9PRODUCTNAME)"!=""
2163cdf0e10cSrcweir
2164cdf0e10cSrcweir.IF "$(linkinc)"!=""
2165cdf0e10cSrcweir.IF "$(GUI)"=="WNT" || "$(GUI)"=="OS2"
2166cdf0e10cSrcweir.IF "$(APP9LIBS)"!=""
2167cdf0e10cSrcweir$(MISC)/$(APP9TARGET)_linkinc.ls .PHONY:
2168cdf0e10cSrcweir	@@-$(RM) $@
2169cdf0e10cSrcweir	sed -f $(SOLARENV)/bin/chrel.sed $(foreach,i,$(APP9LIBS) $(i:s/.lib/.lin/)) >> $@
2170cdf0e10cSrcweir.ENDIF          #"$(APP9LIBS)"!=""
2171cdf0e10cSrcweir.ENDIF
2172cdf0e10cSrcweir
2173cdf0e10cSrcweirLINKINCTARGETS+=$(MISC)/$(APP9TARGETN:b)_linkinc.ls
2174cdf0e10cSrcweir$(APP9TARGETN) : $(LINKINCTARGETS)
2175cdf0e10cSrcweir.ENDIF          # "$(linkinc)"!=""
2176cdf0e10cSrcweir
2177cdf0e10cSrcweir# Allow for target specific LIBSALCPPRT override
2178cdf0e10cSrcweirAPP9LIBSALCPPRT*=$(LIBSALCPPRT)
2179cdf0e10cSrcweir
2180cdf0e10cSrcweir$(APP9TARGETN): $(APP9OBJS) $(APP9LIBS) \
2181cdf0e10cSrcweir	$(APP9RES) \
2182cdf0e10cSrcweir	$(APP9ICON) $(APP9DEPN) $(USE_APP9DEF)
2183cdf0e10cSrcweir	@echo "Making:   " $(@:f)
2184cdf0e10cSrcweir.IF "$(GUI)"=="UNX"
2185cdf0e10cSrcweir.IF "$(OS)"=="MACOSX"
2186cdf0e10cSrcweir	@echo unx
2187cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).list
2188cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_9.cmd
2189cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).strip
2190cdf0e10cSrcweir	@echo $(STDSLO) $(APP9OBJS:s/.obj/.o/) \
2191cdf0e10cSrcweir	`cat /dev/null $(APP9LIBS) | sed s\#$(ROUT)\#$(OUT)\#g` | tr -s " " "\n" > $(MISC)/$(@:b).list
2192cdf0e10cSrcweir	@echo -n $(APP9LINKER) $(APP9LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) -o $@ \
2193cdf0e10cSrcweir	$(APP9LINKTYPEFLAG) $(APP9STDLIBS) $(APP9STDLIB) $(STDLIB9) -filelist $(MISC)/$(@:b).list > $(MISC)/$(TARGET).$(@:b)_9.cmd
2194cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-dylib-link-list.pl \
2195cdf0e10cSrcweir        `cat $(MISC)/$(TARGET).$(@:b)_9.cmd` \
2196cdf0e10cSrcweir        >> $(MISC)/$(TARGET).$(@:b)_9.cmd
2197cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
2198cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_9.cmd
2199cdf0e10cSrcweir  .ENDIF
2200cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_9.cmd
2201cdf0e10cSrcweir# Need to strip __objcInit symbol to avoid duplicate symbols when loading
2202cdf0e10cSrcweir# libraries at runtime
22038badc1b4SHerbert Dürr	@-$(CC_PATH)nm $@ | grep -v ' U ' | $(AWK) '{ print $$NF }' | grep -F -x '__objcInit' > $(MISC)/$(@:b).strip
22048badc1b4SHerbert Dürr	@$(CC_PATH)strip -i -R $(MISC)/$(@:b).strip -X $@
2205cdf0e10cSrcweir	@ls -l $@
2206cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-change-install-names.pl \
2207cdf0e10cSrcweir        app $(APP9RPATH) $@
2208cdf0e10cSrcweir.IF "$(TARGETTYPE)"=="GUI"
2209cdf0e10cSrcweir	@echo "Making:   " $(@:f).app
2210cdf0e10cSrcweir	@macosx-create-bundle $@
2211cdf0e10cSrcweir.ENDIF		# "$(TARGETTYPE)"=="GUI"
2212cdf0e10cSrcweir.ELSE		# "$(OS)"=="MACOSX"
2213cdf0e10cSrcweir	@echo unx
2214cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_9.cmd
2215cdf0e10cSrcweir	@echo $(APP9LINKER) $(APP9LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
2216cdf0e10cSrcweir	$(APP9OBJS:s/.obj/.o/) '\' >  $(MISC)/$(TARGET).$(@:b)_9.cmd
2217cdf0e10cSrcweir	@cat $(mktmp /dev/null $(APP9LIBS)) | xargs -n 1 cat | sed s\#$(ROUT)\#$(OUT)\#g | sed 's#$$# \\#'  >> $(MISC)/$(TARGET).$(@:b)_9.cmd
2218cdf0e10cSrcweir	@echo $(APP9LINKTYPEFLAG) $(APP9LIBSALCPPRT) $(APP9STDLIBS) $(APP9STDLIB) $(STDLIB9) -o $@ >> $(MISC)/$(TARGET).$(@:b)_9.cmd
2219cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
2220cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_9.cmd
2221cdf0e10cSrcweir  .ENDIF
2222cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_9.cmd
2223cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
2224cdf0e10cSrcweir	@ls -l $@
2225cdf0e10cSrcweir  .ENDIF
2226cdf0e10cSrcweir.ENDIF		# "$(OS)"=="MACOSX"
2227cdf0e10cSrcweir.ENDIF
2228cdf0e10cSrcweir.IF "$(GUI)" == "WNT"
2229cdf0e10cSrcweir	@@-$(MKDIR) $(@:d:d)
2230cdf0e10cSrcweir.IF "$(APP9LINKRES)" != ""
2231cdf0e10cSrcweir	@@-$(RM) $(MISC)/$(APP9LINKRES:b).rc
2232cdf0e10cSrcweir.IF "$(APP9ICON)" != ""
2233cdf0e10cSrcweir	@-echo 1 ICON $(EMQ)"$(APP9ICON:s/\/\\/)$(EMQ)" >> $(MISC)/$(APP9LINKRES:b).rc
2234cdf0e10cSrcweir.ENDIF		# "$(APP9ICON)" != ""
2235cdf0e10cSrcweir.IF "$(APP9VERINFO)" != ""
2236cdf0e10cSrcweir	@-echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP9LINKRES:b).rc
2237cdf0e10cSrcweir	@-echo $(EMQ)#include  $(EMQ)"$(APP9VERINFO)$(EMQ)" >> $(MISC)/$(APP9LINKRES:b).rc
2238cdf0e10cSrcweir.ENDIF		# "$(APP9VERINFO)" != ""
2239cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -DWIN32 $(APP9PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP9LINKRES:b).rc
2240cdf0e10cSrcweir.ENDIF			# "$(APP9LINKRES)" != ""
2241cdf0e10cSrcweir.IF "$(COM)" == "GCC"
2242cdf0e10cSrcweir	@echo mingw
2243cdf0e10cSrcweir.IF "$(APP9LINKRES)" != "" || "$(APP9RES)" != ""
2244cdf0e10cSrcweir	@cat $(APP9LINKRES) $(subst,/res/,/res{$(subst,$(BIN), $(@:d))} $(APP9RES)) >  $(MISC)/$(@:b)_all.res
2245cdf0e10cSrcweir	windres $(MISC)/$(@:b)_all.res $(APP9RESO)
2246cdf0e10cSrcweir.ENDIF
2247cdf0e10cSrcweir	@echo $(LINK) $(LINKFLAGS) $(LINKFLAGSAPP) $(MINGWSSTDOBJ) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
2248cdf0e10cSrcweir		$(APP9BASEX) $(APP9STACKN) -o $@ $(APP9OBJS) \
2249cdf0e10cSrcweir		-Wl,-Map,$(MISC)/$(@:b).map $(STDOBJ) $(APP9RESO) \
2250cdf0e10cSrcweir		`$(TYPE) /dev/null $(APP9LIBS) | sed s#$(ROUT)#$(OUT)#g` \
2251cdf0e10cSrcweir		$(APP_LINKTYPE) $(APP9LIBSALCPPRT) \
2252cdf0e10cSrcweir		-Wl,--start-group $(APP9STDLIBS) -Wl,--end-group $(APP9STDLIB) \
2253cdf0e10cSrcweir		$(STDLIB9) $(MINGWSSTDENDOBJ) > $(MISC)/$(TARGET).$(@:b)_9.cmd
2254cdf0e10cSrcweir  # need this empty line, else dmake somehow gets confused by the .IFs and .ENDIFs
2255cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
2256cdf0e10cSrcweir	@$(TYPE)  $(MISC)/$(TARGET).$(@:b)_9.cmd
2257cdf0e10cSrcweir  .ENDIF
2258cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_9.cmd
2259cdf0e10cSrcweir	@ls -l $@
2260cdf0e10cSrcweir.ELSE	# "$(COM)" == "GCC"
2261cdf0e10cSrcweir.IF "$(linkinc)" == ""
2262cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP9LINKER) @$(mktmp \
2263cdf0e10cSrcweir		$(APP9LINKFLAGS) \
2264cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP9BASEX) \
2265cdf0e10cSrcweir		$(APP9STACKN) \
2266cdf0e10cSrcweir		-out:$@ \
2267cdf0e10cSrcweir		-map:$(MISC)/{$(subst,/,_ $(APP9TARGET)).map} \
2268cdf0e10cSrcweir		$(STDOBJ) \
2269cdf0e10cSrcweir		$(APP9LINKRES) \
2270cdf0e10cSrcweir		$(APP9RES) \
2271cdf0e10cSrcweir		$(APP9OBJS) \
2272cdf0e10cSrcweir		$(APP9LIBS) \
2273cdf0e10cSrcweir		$(APP9STDLIBS) \
2274cdf0e10cSrcweir		$(APP9STDLIB) $(STDLIB9) \
2275cdf0e10cSrcweir		)
2276cdf0e10cSrcweir	@-echo linking $@.manifest ...
2277cdf0e10cSrcweir.IF "$(VISTA_MANIFEST)"!=""
2278cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -manifest $(TRUSTED_MANIFEST_LOCATION)/trustedinfo.manifest -out:$@.tmanifest$(EMQ) $(FI)
2279cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.tmanifest -outputresource:$@$(EMQ);1 $(FI)
2280cdf0e10cSrcweir.ELSE
2281cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -outputresource:$@$(EMQ);1 $(FI)
2282cdf0e10cSrcweir.ENDIF # "$(VISTA_MANIFEST)"!=""
2283cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(RM:s/+//) $@.manifest $(FI)
2284cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.tmanifest $(THEN) $(RM:s/+//) $@.tmanifest $(FI)
2285cdf0e10cSrcweir.ELSE
2286cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP9TARGET).lnk
2287cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP9TARGET).lst
2288cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\linkobj.lst
2289cdf0e10cSrcweir		for %_i in ($(MISC)\*.obj) do type %_i >> $(MISC)\linkobj.lst
2290cdf0e10cSrcweir	type $(mktmp,$(MISC)\$(APP9TARGET).lst
2291cdf0e10cSrcweir		$(APP9LINKFLAGS) \
2292cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP9BASEX) \
2293cdf0e10cSrcweir		$(APP9STACKN) \
2294cdf0e10cSrcweir		-out:$@ \
2295cdf0e10cSrcweir		$(STDOBJ) \
2296cdf0e10cSrcweir		$(APP9LINKRES) \
2297cdf0e10cSrcweir		$(APP9RES) \
2298cdf0e10cSrcweir		$(APP9OBJS) \
2299cdf0e10cSrcweir		$(APP9LIBS) \
2300cdf0e10cSrcweir		$(APP9STDLIBS) \
2301cdf0e10cSrcweir		$(APP9STDLIB) $(STDLIB9))
2302cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(SED) -e 's/\(\.\.\\\)\{2,4\}/..\\/g' $(MISC)\$(APP9TARGETN:b)_linkobj.lst >> $(MISC)\$(APP9TARGET).lst
2303cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(IFEXIST) $(MISC)/$(APP9TARGET).lst $(THEN) type $(MISC)/$(APP9TARGET).lst  >> $(MISC)/$(APP9TARGET).lnk $(FI)
2304cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(APP9LINKER) @$(MISC)\$(APP9TARGET).lnk
2305cdf0e10cSrcweir.ENDIF		# "$(linkinc)" == ""
2306cdf0e10cSrcweir.ENDIF		# "$(COM)" == "GCC"
2307cdf0e10cSrcweir.IF "$(APP9TARGET)" == "loader"
2308cdf0e10cSrcweir	$(COMMAND_ECHO)$(PERL) loader.pl $@
2309cdf0e10cSrcweir	$(COMMAND_ECHO)$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
2310cdf0e10cSrcweir	$(COMMAND_ECHO)$(RM) $@
2311cdf0e10cSrcweir	$(COMMAND_ECHO)$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
2312cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
2313cdf0e10cSrcweir
2314cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "WNT"
2315cdf0e10cSrcweir
2316cdf0e10cSrcweir.IF "$(GUI)" == "OS2"
2317534c536dSYuri Dario	@+-$(MKDIR) $(@:d:d) > $(NULLDEV)
2318cdf0e10cSrcweir.IF "$(APP9LINKRES)" != ""
2319534c536dSYuri Dario	@+-$(RM) $(MISC)/$(APP9LINKRES:b).rc > $(NULLDEV)
2320cdf0e10cSrcweir.IF "$(APP9ICON)" != ""
2321534c536dSYuri Dario	@-+echo ICON 1 $(EMQ)"$(APP9ICON:s#/#\\\\#)$(EMQ)" >> $(MISC)$/$(APP9LINKRES:b).rc
2322cdf0e10cSrcweir.ENDIF		# "$(APP9ICON)" != ""
2323cdf0e10cSrcweir.IF "$(APP9VERINFO)" != ""
2324cdf0e10cSrcweir	@-+echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP9LINKRES:b).rc
2325cdf0e10cSrcweir	@-+echo $(EMQ)#include  $(EMQ)"$(APP9VERINFO)$(EMQ)" >> $(MISC)/$(APP9LINKRES:b).rc
2326cdf0e10cSrcweir.ENDIF		# "$(APP9VERINFO)" != ""
2327cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -r -DOS2 $(APP9PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP9LINKRES:b).rc
2328cdf0e10cSrcweir.ENDIF			# "$(APP9LINKRES)" != ""
2329cdf0e10cSrcweir
2330cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
2331cdf0e10cSrcweir	@echo NAME $(APP9TARGET) WINDOWAPI > $(MISC)/$(APP9TARGET).def
2332cdf0e10cSrcweir.ENDIF
2333cdf0e10cSrcweir
2334cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP9LINKER) -v \
2335cdf0e10cSrcweir		$(APP9LINKFLAGS) \
2336cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP9BASEX) \
2337cdf0e10cSrcweir		$(APP9STACKN) \
2338cdf0e10cSrcweir		-o $@ \
2339cdf0e10cSrcweir		-Zmap -L$(LB) \
2340cdf0e10cSrcweir		-L$(SOLARVERSION)/$(INPATH)/lib \
2341cdf0e10cSrcweir		$(STDOBJ) \
2342cdf0e10cSrcweir		$(APP9LINKRES) \
2343cdf0e10cSrcweir		$(APP9RES) \
2344cdf0e10cSrcweir		$(APP9DEF) \
2345cdf0e10cSrcweir		$(APP9OBJS) \
2346cdf0e10cSrcweir		$(APP9LIBS) \
2347534c536dSYuri Dario		$(APP9STDLIBS) \
2348534c536dSYuri Dario		$(APP9STDLIB) $(STDLIB9)
2349cdf0e10cSrcweir
2350cdf0e10cSrcweir
2351cdf0e10cSrcweir.IF "$(APP9TARGET)" == "loader"
2352cdf0e10cSrcweir	$(COMMAND_ECHO)+$(PERL) loader.pl $@
2353cdf0e10cSrcweir	$(COMMAND_ECHO)+$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
2354cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RM) $@
2355cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
2356cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
2357cdf0e10cSrcweir
2358cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "OS2"
2359cdf0e10cSrcweir
2360cdf0e10cSrcweir.ENDIF			# "$(APP9TARGETN)"!=""
2361cdf0e10cSrcweir
2362cdf0e10cSrcweir
2363cdf0e10cSrcweir# Instruction for linking
2364cdf0e10cSrcweir# unroll begin
2365cdf0e10cSrcweir
2366cdf0e10cSrcweir.IF "$(GUI)" == "OS2" && "$(TARGETTYPE)" == "GUI"
2367cdf0e10cSrcweirAPP10DEF = $(MISC)/$(APP10TARGET).def
2368cdf0e10cSrcweir.ENDIF
2369cdf0e10cSrcweir
2370cdf0e10cSrcweir.IF "$(APP10LINKTYPE)" != ""
2371cdf0e10cSrcweir#must be either STATIC or SHARED
2372cdf0e10cSrcweirAPP10LINKTYPEFLAG=$(APPLINK$(APP10LINKTYPE))
2373cdf0e10cSrcweir.ENDIF
2374cdf0e10cSrcweir
2375cdf0e10cSrcweir# decide how to link
2376cdf0e10cSrcweir.IF "$(APP10CODETYPE)"=="C"
2377cdf0e10cSrcweirAPP10LINKER=$(LINKC)
2378cdf0e10cSrcweirAPP10STDLIB=$(subst,CPPRUNTIME, $(STDLIB))
2379cdf0e10cSrcweirAPP10LINKFLAGS+=$(LINKCFLAGS)
2380cdf0e10cSrcweir.ELSE			# "$(APP10CODETYPE)"=="C"
2381cdf0e10cSrcweirAPP10LINKER=$(LINK)
2382cdf0e10cSrcweirAPP10STDLIB=$(subst,CPPRUNTIME,$(STDLIBCPP) $(STDLIB))
2383cdf0e10cSrcweirAPP10LINKFLAGS+=$(LINKFLAGS)
2384cdf0e10cSrcweir.ENDIF			# "$(APP10CODETYPE)"=="C"
2385cdf0e10cSrcweir
2386cdf0e10cSrcweirAPP10RPATH*=OOO
2387cdf0e10cSrcweirLINKFLAGSRUNPATH_$(APP10RPATH)*=/ERROR:/Bad_APP10RPATH_value
2388cdf0e10cSrcweir.IF "$(OS)" != "MACOSX"
2389cdf0e10cSrcweirAPP10LINKFLAGS+=$(LINKFLAGSRUNPATH_$(APP10RPATH))
2390cdf0e10cSrcweir.ENDIF
2391cdf0e10cSrcweir
2392cdf0e10cSrcweir.IF "$(APP10STACK)" != ""
2393cdf0e10cSrcweir.IF "$(LINKFLAGSTACK)" != ""
2394cdf0e10cSrcweirAPP10STACKN=$(LINKFLAGSTACK)$(APP10STACK)
2395cdf0e10cSrcweir.ENDIF
2396cdf0e10cSrcweir.ELSE
2397cdf0e10cSrcweirAPP10STACKN=
2398cdf0e10cSrcweir.ENDIF
2399cdf0e10cSrcweir
2400cdf0e10cSrcweir.IF "$(APP10NOSAL)"==""
2401cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
2402cdf0e10cSrcweirAPP10OBJS+= $(STDOBJVCL)
2403cdf0e10cSrcweir.ENDIF
2404cdf0e10cSrcweir.ENDIF
2405cdf0e10cSrcweir
2406cdf0e10cSrcweir.IF "$(GUI)$(COM)" == "WNTGCC"
2407cdf0e10cSrcweirAPP10RESO=
2408cdf0e10cSrcweir.IF "$(APP10LINKRES)" != "" || "$(APP10RES)" != ""
2409cdf0e10cSrcweirAPP10RESO=$(MISC)/$(APP10TARGET:b)_res.o
2410cdf0e10cSrcweir.ENDIF
2411cdf0e10cSrcweir.ENDIF
2412cdf0e10cSrcweir
2413cdf0e10cSrcweir.IF "$(GUI)" == "UNX"
2414cdf0e10cSrcweirAPP10DEPN+:=$(APP10DEPNU)
2415cdf0e10cSrcweirUSE_APP10DEF=
2416cdf0e10cSrcweir.ENDIF
2417cdf0e10cSrcweir
2418cdf0e10cSrcweir.IF "$(APP10TARGETN)"!=""
2419cdf0e10cSrcweir
2420cdf0e10cSrcweir.IF "$(APP10PRODUCTNAME)"!=""
2421cdf0e10cSrcweirAPP10PRODUCTDEF+:=-DPRODUCT_NAME=\"$(APP10PRODUCTNAME)\"
2422cdf0e10cSrcweir.ENDIF			# "$(APP10PRODUCTNAME)"!=""
2423cdf0e10cSrcweir
2424cdf0e10cSrcweir.IF "$(linkinc)"!=""
2425cdf0e10cSrcweir.IF "$(GUI)"=="WNT" || "$(GUI)"=="OS2"
2426cdf0e10cSrcweir.IF "$(APP10LIBS)"!=""
2427cdf0e10cSrcweir$(MISC)/$(APP10TARGET)_linkinc.ls .PHONY:
2428cdf0e10cSrcweir	@@-$(RM) $@
2429cdf0e10cSrcweir	sed -f $(SOLARENV)/bin/chrel.sed $(foreach,i,$(APP10LIBS) $(i:s/.lib/.lin/)) >> $@
2430cdf0e10cSrcweir.ENDIF          #"$(APP10LIBS)"!=""
2431cdf0e10cSrcweir.ENDIF
2432cdf0e10cSrcweir
2433cdf0e10cSrcweirLINKINCTARGETS+=$(MISC)/$(APP10TARGETN:b)_linkinc.ls
2434cdf0e10cSrcweir$(APP10TARGETN) : $(LINKINCTARGETS)
2435cdf0e10cSrcweir.ENDIF          # "$(linkinc)"!=""
2436cdf0e10cSrcweir
2437cdf0e10cSrcweir# Allow for target specific LIBSALCPPRT override
2438cdf0e10cSrcweirAPP10LIBSALCPPRT*=$(LIBSALCPPRT)
2439cdf0e10cSrcweir
2440cdf0e10cSrcweir$(APP10TARGETN): $(APP10OBJS) $(APP10LIBS) \
2441cdf0e10cSrcweir	$(APP10RES) \
2442cdf0e10cSrcweir	$(APP10ICON) $(APP10DEPN) $(USE_APP10DEF)
2443cdf0e10cSrcweir	@echo "Making:   " $(@:f)
2444cdf0e10cSrcweir.IF "$(GUI)"=="UNX"
2445cdf0e10cSrcweir.IF "$(OS)"=="MACOSX"
2446cdf0e10cSrcweir	@echo unx
2447cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).list
2448cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_10.cmd
2449cdf0e10cSrcweir	@-$(RM) $(MISC)/$(@:b).strip
2450cdf0e10cSrcweir	@echo $(STDSLO) $(APP10OBJS:s/.obj/.o/) \
2451cdf0e10cSrcweir	`cat /dev/null $(APP10LIBS) | sed s\#$(ROUT)\#$(OUT)\#g` | tr -s " " "\n" > $(MISC)/$(@:b).list
2452cdf0e10cSrcweir	@echo -n $(APP10LINKER) $(APP10LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) -o $@ \
2453cdf0e10cSrcweir	$(APP10LINKTYPEFLAG) $(APP10STDLIBS) $(APP10STDLIB) $(STDLIB10) -filelist $(MISC)/$(@:b).list > $(MISC)/$(TARGET).$(@:b)_10.cmd
2454cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-dylib-link-list.pl \
2455cdf0e10cSrcweir        `cat $(MISC)/$(TARGET).$(@:b)_10.cmd` \
2456cdf0e10cSrcweir        >> $(MISC)/$(TARGET).$(@:b)_10.cmd
2457cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
2458cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_10.cmd
2459cdf0e10cSrcweir  .ENDIF
2460cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_10.cmd
2461cdf0e10cSrcweir# Need to strip __objcInit symbol to avoid duplicate symbols when loading
2462cdf0e10cSrcweir# libraries at runtime
24638badc1b4SHerbert Dürr	@-$(CC_PATH)nm $@ | grep -v ' U ' | $(AWK) '{ print $$NF }' | grep -F -x '__objcInit' > $(MISC)/$(@:b).strip
24648badc1b4SHerbert Dürr	@$(CC_PATH)strip -i -R $(MISC)/$(@:b).strip -X $@
2465cdf0e10cSrcweir	@ls -l $@
2466cdf0e10cSrcweir    @$(PERL) $(SOLARENV)/bin/macosx-change-install-names.pl \
2467cdf0e10cSrcweir        app $(APP10RPATH) $@
2468cdf0e10cSrcweir.IF "$(TARGETTYPE)"=="GUI"
2469cdf0e10cSrcweir	@echo "Making:   " $(@:f).app
2470cdf0e10cSrcweir	@macosx-create-bundle $@
2471cdf0e10cSrcweir.ENDIF		# "$(TARGETTYPE)"=="GUI"
2472cdf0e10cSrcweir.ELSE		# "$(OS)"=="MACOSX"
2473cdf0e10cSrcweir	@echo unx
2474cdf0e10cSrcweir	@-$(RM) $(MISC)/$(TARGET).$(@:b)_10.cmd
2475cdf0e10cSrcweir	@echo $(APP10LINKER) $(APP10LINKFLAGS) $(LINKFLAGSAPP) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
2476cdf0e10cSrcweir	$(APP10OBJS:s/.obj/.o/) '\' >  $(MISC)/$(TARGET).$(@:b)_10.cmd
2477cdf0e10cSrcweir	@cat $(mktmp /dev/null $(APP10LIBS)) | xargs -n 1 cat | sed s\#$(ROUT)\#$(OUT)\#g | sed 's#$$# \\#'  >> $(MISC)/$(TARGET).$(@:b)_10.cmd
2478cdf0e10cSrcweir	@echo $(APP10LINKTYPEFLAG) $(APP10LIBSALCPPRT) $(APP10STDLIBS) $(APP10STDLIB) $(STDLIB10) -o $@ >> $(MISC)/$(TARGET).$(@:b)_10.cmd
2479cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
2480cdf0e10cSrcweir	@cat $(MISC)/$(TARGET).$(@:b)_10.cmd
2481cdf0e10cSrcweir  .ENDIF
2482cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_10.cmd
2483cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
2484cdf0e10cSrcweir	@ls -l $@
2485cdf0e10cSrcweir  .ENDIF
2486cdf0e10cSrcweir.ENDIF		# "$(OS)"=="MACOSX"
2487cdf0e10cSrcweir.ENDIF
2488cdf0e10cSrcweir.IF "$(GUI)" == "WNT"
2489cdf0e10cSrcweir	@@-$(MKDIR) $(@:d:d)
2490cdf0e10cSrcweir.IF "$(APP10LINKRES)" != ""
2491cdf0e10cSrcweir	@@-$(RM) $(MISC)/$(APP10LINKRES:b).rc
2492cdf0e10cSrcweir.IF "$(APP10ICON)" != ""
2493cdf0e10cSrcweir	@-echo 1 ICON $(EMQ)"$(APP10ICON:s/\/\\/)$(EMQ)" >> $(MISC)/$(APP10LINKRES:b).rc
2494cdf0e10cSrcweir.ENDIF		# "$(APP10ICON)" != ""
2495cdf0e10cSrcweir.IF "$(APP10VERINFO)" != ""
2496cdf0e10cSrcweir	@-echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP10LINKRES:b).rc
2497cdf0e10cSrcweir	@-echo $(EMQ)#include  $(EMQ)"$(APP10VERINFO)$(EMQ)" >> $(MISC)/$(APP10LINKRES:b).rc
2498cdf0e10cSrcweir.ENDIF		# "$(APP10VERINFO)" != ""
2499cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -DWIN32 $(APP10PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP10LINKRES:b).rc
2500cdf0e10cSrcweir.ENDIF			# "$(APP10LINKRES)" != ""
2501cdf0e10cSrcweir.IF "$(COM)" == "GCC"
2502cdf0e10cSrcweir	@echo mingw
2503cdf0e10cSrcweir.IF "$(APP10LINKRES)" != "" || "$(APP10RES)" != ""
2504cdf0e10cSrcweir	@cat $(APP10LINKRES) $(subst,/res/,/res{$(subst,$(BIN), $(@:d))} $(APP10RES)) >  $(MISC)/$(@:b)_all.res
2505cdf0e10cSrcweir	windres $(MISC)/$(@:b)_all.res $(APP10RESO)
2506cdf0e10cSrcweir.ENDIF
2507cdf0e10cSrcweir	@echo $(LINK) $(LINKFLAGS) $(LINKFLAGSAPP) $(MINGWSSTDOBJ) -L$(PRJ)/$(INPATH)/lib $(SOLARLIB) $(STDSLO) \
2508cdf0e10cSrcweir		$(APP10BASEX) $(APP10STACKN) -o $@ $(APP10OBJS) \
2509cdf0e10cSrcweir		-Wl,-Map,$(MISC)/$(@:b).map $(STDOBJ) $(APP10RESO) \
2510cdf0e10cSrcweir		`$(TYPE) /dev/null $(APP10LIBS) | sed s#$(ROUT)#$(OUT)#g` \
2511cdf0e10cSrcweir		$(APP_LINKTYPE) $(APP10LIBSALCPPRT) \
2512cdf0e10cSrcweir		-Wl,--start-group $(APP10STDLIBS) -Wl,--end-group $(APP10STDLIB) \
2513cdf0e10cSrcweir		$(STDLIB10) $(MINGWSSTDENDOBJ) > $(MISC)/$(TARGET).$(@:b)_10.cmd
2514cdf0e10cSrcweir  # need this empty line, else dmake somehow gets confused by the .IFs and .ENDIFs
2515cdf0e10cSrcweir  .IF "$(VERBOSE)" == "TRUE"
2516cdf0e10cSrcweir	@$(TYPE)  $(MISC)/$(TARGET).$(@:b)_10.cmd
2517cdf0e10cSrcweir  .ENDIF
2518cdf0e10cSrcweir	@+source $(MISC)/$(TARGET).$(@:b)_10.cmd
2519cdf0e10cSrcweir	@ls -l $@
2520cdf0e10cSrcweir.ELSE	# "$(COM)" == "GCC"
2521cdf0e10cSrcweir.IF "$(linkinc)" == ""
2522cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP10LINKER) @$(mktmp \
2523cdf0e10cSrcweir		$(APP10LINKFLAGS) \
2524cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP10BASEX) \
2525cdf0e10cSrcweir		$(APP10STACKN) \
2526cdf0e10cSrcweir		-out:$@ \
2527cdf0e10cSrcweir		-map:$(MISC)/{$(subst,/,_ $(APP10TARGET)).map} \
2528cdf0e10cSrcweir		$(STDOBJ) \
2529cdf0e10cSrcweir		$(APP10LINKRES) \
2530cdf0e10cSrcweir		$(APP10RES) \
2531cdf0e10cSrcweir		$(APP10OBJS) \
2532cdf0e10cSrcweir		$(APP10LIBS) \
2533cdf0e10cSrcweir		$(APP10STDLIBS) \
2534cdf0e10cSrcweir		$(APP10STDLIB) $(STDLIB10) \
2535cdf0e10cSrcweir		)
2536cdf0e10cSrcweir	@-echo linking $@.manifest ...
2537cdf0e10cSrcweir.IF "$(VISTA_MANIFEST)"!=""
2538cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -manifest $(TRUSTED_MANIFEST_LOCATION)/trustedinfo.manifest -out:$@.tmanifest$(EMQ) $(FI)
2539cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.tmanifest -outputresource:$@$(EMQ);1 $(FI)
2540cdf0e10cSrcweir.ELSE
2541cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(MT) $(MTFLAGS) -manifest $@.manifest -outputresource:$@$(EMQ);1 $(FI)
2542cdf0e10cSrcweir.ENDIF # "$(VISTA_MANIFEST)"!=""
2543cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.manifest $(THEN) $(RM:s/+//) $@.manifest $(FI)
2544cdf0e10cSrcweir	$(COMMAND_ECHO)$(IFEXIST) $@.tmanifest $(THEN) $(RM:s/+//) $@.tmanifest $(FI)
2545cdf0e10cSrcweir.ELSE
2546cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP10TARGET).lnk
2547cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\$(APP10TARGET).lst
2548cdf0e10cSrcweir		$(COMMAND_ECHO)-$(RM) $(MISC)\linkobj.lst
2549cdf0e10cSrcweir		for %_i in ($(MISC)\*.obj) do type %_i >> $(MISC)\linkobj.lst
2550cdf0e10cSrcweir	type $(mktmp,$(MISC)\$(APP10TARGET).lst
2551cdf0e10cSrcweir		$(APP10LINKFLAGS) \
2552cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP10BASEX) \
2553cdf0e10cSrcweir		$(APP10STACKN) \
2554cdf0e10cSrcweir		-out:$@ \
2555cdf0e10cSrcweir		$(STDOBJ) \
2556cdf0e10cSrcweir		$(APP10LINKRES) \
2557cdf0e10cSrcweir		$(APP10RES) \
2558cdf0e10cSrcweir		$(APP10OBJS) \
2559cdf0e10cSrcweir		$(APP10LIBS) \
2560cdf0e10cSrcweir		$(APP10STDLIBS) \
2561cdf0e10cSrcweir		$(APP10STDLIB) $(STDLIB10))
2562cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(SED) -e 's/\(\.\.\\\)\{2,4\}/..\\/g' $(MISC)\$(APP10TARGETN:b)_linkobj.lst >> $(MISC)\$(APP10TARGET).lst
2563cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(IFEXIST) $(MISC)/$(APP10TARGET).lst $(THEN) type $(MISC)/$(APP10TARGET).lst  >> $(MISC)/$(APP10TARGET).lnk $(FI)
2564cdf0e10cSrcweir		$(COMMAND_ECHO)$(SED)$(APP10LINKER) @$(MISC)\$(APP10TARGET).lnk
2565cdf0e10cSrcweir.ENDIF		# "$(linkinc)" == ""
2566cdf0e10cSrcweir.ENDIF		# "$(COM)" == "GCC"
2567cdf0e10cSrcweir.IF "$(APP10TARGET)" == "loader"
2568cdf0e10cSrcweir	$(COMMAND_ECHO)$(PERL) loader.pl $@
2569cdf0e10cSrcweir	$(COMMAND_ECHO)$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
2570cdf0e10cSrcweir	$(COMMAND_ECHO)$(RM) $@
2571cdf0e10cSrcweir	$(COMMAND_ECHO)$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
2572cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
2573cdf0e10cSrcweir
2574cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "WNT"
2575cdf0e10cSrcweir
2576cdf0e10cSrcweir.IF "$(GUI)" == "OS2"
2577534c536dSYuri Dario	@+-$(MKDIR) $(@:d:d) > $(NULLDEV)
2578cdf0e10cSrcweir.IF "$(APP10LINKRES)" != ""
2579534c536dSYuri Dario	@+-$(RM) $(MISC)/$(APP10LINKRES:b).rc > $(NULLDEV)
2580cdf0e10cSrcweir.IF "$(APP10ICON)" != ""
2581534c536dSYuri Dario	@-+echo ICON 1 $(EMQ)"$(APP10ICON:s#/#\\\\#)$(EMQ)" >> $(MISC)$/$(APP10LINKRES:b).rc
2582cdf0e10cSrcweir.ENDIF		# "$(APP10ICON)" != ""
2583cdf0e10cSrcweir.IF "$(APP10VERINFO)" != ""
2584cdf0e10cSrcweir	@-+echo $(EMQ)#define VERVARIANT	$(BUILD) >> $(MISC)/$(APP10LINKRES:b).rc
2585cdf0e10cSrcweir	@-+echo $(EMQ)#include  $(EMQ)"$(APP10VERINFO)$(EMQ)" >> $(MISC)/$(APP10LINKRES:b).rc
2586cdf0e10cSrcweir.ENDIF		# "$(APP10VERINFO)" != ""
2587cdf0e10cSrcweir	$(COMMAND_ECHO)$(RC) -r -DOS2 $(APP10PRODUCTDEF) -I$(SOLARRESDIR) $(INCLUDE) $(RCLINKFLAGS) $(MISC)/$(APP10LINKRES:b).rc
2588cdf0e10cSrcweir.ENDIF			# "$(APP10LINKRES)" != ""
2589cdf0e10cSrcweir
2590cdf0e10cSrcweir.IF "$(TARGETTYPE)" == "GUI"
2591cdf0e10cSrcweir	@echo NAME $(APP10TARGET) WINDOWAPI > $(MISC)/$(APP10TARGET).def
2592cdf0e10cSrcweir.ENDIF
2593cdf0e10cSrcweir
2594cdf0e10cSrcweir	$(COMMAND_ECHO)$(APP10LINKER) -v \
2595cdf0e10cSrcweir		$(APP10LINKFLAGS) \
2596cdf0e10cSrcweir		$(LINKFLAGSAPP) $(APP10BASEX) \
2597cdf0e10cSrcweir		$(APP10STACKN) \
2598cdf0e10cSrcweir		-o $@ \
2599cdf0e10cSrcweir		-Zmap -L$(LB) \
2600cdf0e10cSrcweir		-L$(SOLARVERSION)/$(INPATH)/lib \
2601cdf0e10cSrcweir		$(STDOBJ) \
2602cdf0e10cSrcweir		$(APP10LINKRES) \
2603cdf0e10cSrcweir		$(APP10RES) \
2604cdf0e10cSrcweir		$(APP10DEF) \
2605cdf0e10cSrcweir		$(APP10OBJS) \
2606cdf0e10cSrcweir		$(APP10LIBS) \
2607534c536dSYuri Dario		$(APP10STDLIBS) \
2608534c536dSYuri Dario		$(APP10STDLIB) $(STDLIB10)
2609cdf0e10cSrcweir
2610cdf0e10cSrcweir
2611cdf0e10cSrcweir.IF "$(APP10TARGET)" == "loader"
2612cdf0e10cSrcweir	$(COMMAND_ECHO)+$(PERL) loader.pl $@
2613cdf0e10cSrcweir	$(COMMAND_ECHO)+$(TYPE) $(@) $(@:d)unloader.exe > $(@:d)_new.exe
2614cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RM) $@
2615cdf0e10cSrcweir	$(COMMAND_ECHO)+$(RENAME) $(@:d)_new.exe $(@:d)loader.exe
2616cdf0e10cSrcweir.ENDIF			# "$(TARGET)" == "setup"
2617cdf0e10cSrcweir
2618cdf0e10cSrcweir.ENDIF			# "$(GUI)" == "OS2"
2619cdf0e10cSrcweir
2620cdf0e10cSrcweir.ENDIF			# "$(APP10TARGETN)"!=""
2621cdf0e10cSrcweir
2622cdf0e10cSrcweir
2623cdf0e10cSrcweir# Instruction for linking
2624