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