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