* Makefile.in, ldtemplate: Need to use separate scripts
[deliverable/binutils-gdb.git] / ld / Makefile.in
1 #
2 # Makefile for ld version 2
3 #
4 # $Id$
5 #
6
7 srcdir = .
8
9 destdir = /usr/local
10
11 version=`$(unsubdir)/../gcc$(subdir)/gcc -dumpversion`
12 bindir = $(destdir)/H-$(host_alias)/T-$(target_alias)/bin
13 libdir = $(destdir)/H-$(host_alias)/T-$(target_alias)/lib
14 libsubdir = $(libdir)/gcc/$(target)/$(version)
15
16 # Seach path to override the default search path for -lfoo libraries.
17 # If LIB_PATH is empty, the ones in the script (if any) are left alone.
18 # Otherwise, they are replaced with the ones given in LIB_PATH,
19 # which may have the form: LIB_PATH=/lib:/usr/local/lib
20 LIB_PATH =
21
22 INSTALL = install -c
23 INSTALL_PROGRAM = $(INSTALL)
24 INSTALL_FILE = $(INSTALL)
25
26 BASEDIR = ../..
27 INCLUDE = $(srcdir)/../include
28 INCLUDES = -I. -I$(srcdir) -I$(INCLUDE)
29 DEBUG = -g
30
31 # Where to find texinfo.tex to format docn with TeX
32 TEXIDIR = $(srcdir)/../texinfo/fsf
33
34 # Whether to get roff to put indexing entries on stderr
35 #TEXI2OPT =
36 # You neeed this to generate ld-index.ms
37 TEXI2OPT = -i
38
39 # Which roff program to use to generate index for texi2roff'd doc
40 ROFF = groff
41
42 BISON = bison
43 BISONFLAGS = -v
44
45 SCRIPTS = ldgld68k.sc ldgld.sc \
46 ldlnk960.sc ldlnk960r.sc ldgld960.sc \
47 ldm88k.sc ldglda29k.sc news.sc h8300hds.sc ebmon29k.sc
48
49 #### target and host dependent Makefile fragments come in here.
50 ###
51
52 CFLAGS = $(INCLUDES) $(DEBUG) $(HDEFINES) $(TDEFINES) $(CDEFINES)
53 LINTFLAGS = $(INCLUDES) $(EXTRA_DEF)
54
55 .SUFFIXES: .y .x .xr .xu .xn .xN .sc .scu .scr .scn $(SUFFIXES)
56
57 # go directly to ld.new in case this ld isn't capable of
58 # linking native object on this host. It can be renamed on
59 # install.
60 LD_PROG = ld.new
61
62 # A .sc script file is needed for each emulation mode.
63 # sed is used to transform this script into two variant forms:
64 # A .scr script is for linking without relocation (-r flag).
65 # A .scu script is like .scr, but *do* create constructors.
66 # A .scn script is for linking with -N flag (mix text and data on same page).
67 # A .scN script is for linking with -N flag (mix text and data on same page).
68 # The diference is that segments should (need) not be page aligned.
69
70 # A sed pattern to translate .sc to .scu:
71 SED_MAKE_RELOC_WITH_CONSTRUCTORS=\
72 -e "/If relocating/,/End if relocating/d" \
73 -e "/=/s/[_a-zA-Z.]* *= .*//g" \
74 -e '/>/s/} *> *[a-zA-Z]*/}/' \
75 -e "/text/s/[.]text .*:/.text :/" \
76 -e "/data/s/[.]data .*:/.data :/"
77 # A sed pattern to translate .scu to .scr:
78 SED_REMOVE_CONSTRUCTORS= -e /CONSTRUCTORS/d
79
80 .sc.scu:
81 sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) $< >$*.scu
82 .scu.scr:
83 sed $(SED_REMOVE_CONSTRUCTORS) < $< >$*.scr
84
85 # Each builtin script file is included as a C string literal.
86 # These are generated by the mkscript filter.
87 .sc.x:
88 if [ "x"$(LIB_PATH) = "x" ]; then ./mkscript < $< >$*.x ; \
89 else \
90 (sed <$< -e '/SEARCH_DIR(.*)/d' ; \
91 echo $(LIB_PATH) | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g';) | ./mkscript >$*.x;\
92 fi
93
94 # The .xn script is used if the -n flag is given (write-protect text)..
95 # Sunos starts the text segment for demand-paged binaries at 0x2020
96 # and other binaries at 0x2000, since the exec header is paged in
97 # with the text. Some other Unix variants do the same.
98 # For -n and -N flags the offset of the exec header must be removed.
99 # This sed script does this if the master script contains
100 # a line of the form ".text 0xAAAA BLOCK(0xBBBB):" - the
101 # output will contain ".text 0xBBBB:". (For Sunos AAAA=2020 and BBBB=2000.)
102 .x.xn:
103 sed -e '/text/s/\.text .* BLOCK(\([^)]*\)):/.text \1:/' < $< >$*.xn
104
105 # The .xN script is used if the -N flag is given (don't write-protect text).
106 # This is like -n, except that the data segment need not be page-aligned.
107 # So get rid of commands for page-alignment: We assume these use ALIGN
108 # with a hex constant that end with 00, since any normal page size is be
109 # at least divisible by 256. We use the 00 to avoid matching
110 # anything that tries to align of (say) 8-byte boundaries.
111 .xn.xN:
112 sed -e '/ALIGN/s/ALIGN( *0x[0-9a-fA-F]*00 *)/./' < $< >$*.xN
113
114 # The xu and xr scripts don't search libraries, so LIB_PATH doesn't matter.
115 .sc.xu:
116 sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) < $< | ./mkscript >$*.xu
117 .sc.xr:
118 sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) $(SED_REMOVE_CONSTRUCTORS) \
119 < $< | ./mkscript >$*.xr
120
121 # for self hosting
122 BFDLIB=$(unsubdir)/../bfd$(subdir)/libbfd.a
123 LIBIBERTY=$(unsubdir)/../libiberty$(subdir)/libiberty.a
124
125 OFILES= ldgram.o ldlex.o ldlang.o ldmain.o ldwarn.o ldwrite.o ldexp.o ldlnk960.o ldgld68k.o ldindr.o \
126 ldm88k.o ldglda29k.o news.o h8300hds.o ebmon29k.o \
127 ldgld.o ldgld960.o ldemul.o ldver.o ldmisc.o ldsym.o ldvanilla.o ldfile.o
128
129 HEADERS=config.h ldmain.h ldmain.h ldwarn.h ldmisc.h ldindr.h ldsym.h ldlang.h ldexp.h \
130 ldlex.h ldwrite.h ldver.h ldemul.h ldfile.h ldgram.h ld.h
131
132 MANSOURCES=ld.tex
133
134 LDCSOURCES=ldlang.c ldindr.c ldmain.c ldwrite.c ldwarn.c ldlnk960.c ldgld.c ldgld68k.c \
135 ldm88k.c ldgld29k.c \
136 ldgld960.c ldemul.c ldver.c ldmisc.c ldexp.c ldsym.c ldfile.c ldvanilla.c
137
138 GENERATED_SOURCES=ldgram.c ldlex.c ldgram.h
139 GENERATED_HEADERS=ldgram.h
140
141 LDSOURCES=$(LDCSOURCES) ldgram.y ldlex.l ldgram.h
142
143 BFDSOURCES=../../bfd/common/*.c
144
145 SOURCES= $(LDSOURCES) $(BFDSOURCES)
146 LINTSOURCES= $(LDCSOURCES) $(BFDSOURCES) $(GENERATED_SOURCES)
147
148 STAGESTUFF = *.x *.x[ru] *.sc[ru] $(GENERATED_SOURCES) $(GENERATED_HEADERS) $(OFILES) $(LD_PROG) mkscript
149
150 all: Makefile $(LD_PROG)
151
152 ldgram.h ldgram.c: ldgram.y
153 $(BISON) $(BISONFLAGS) -d $(VPATH)/ldgram.y -o ldgram.c
154 # These are in case BISON is really yacc (which ignores -o).
155 if [ -f y.tab.c -a ! -f ldgram.c ]; then mv y.tab.c ldgram.c; else true ; fi
156 if [ -f y.tab.h -a ! -f ldgram.h ]; then mv y.tab.h ldgram.h; else true ; fi
157
158 ldlex.c: ldlex.l
159 lex -t $(VPATH)/ldlex.l >ldlex.c
160
161
162 ldgld.c: $(srcdir)/ldtemplate
163 sed -e s/"<ldtarget>"/ldgld/g -e s/"<arch>"/m68k/g \
164 -e s/"<target>"//g -e s/"<TARGET>"//g <$(srcdir)/ldtemplate >$@
165 news.c: $(srcdir)/ldtemplate
166 sed -e s/"<ldtarget>"/news/g -e s/"<arch>"/m68k/g \
167 -e s/"<target>"/news/g -e s/"<TARGET>"/NEWS/g <$(srcdir)/ldtemplate >$@
168
169 ebmon29k.c: $(srcdir)/ldtemplate
170 sed -e s/"<ldtarget>"/ebmon29k/g -e s/"<arch>"/a29k/g \
171 -e s/"gld<target>"/ebmon29k/g -e s/"GLD<TARGET>"/EBMON29K/g \
172 -e s/"<ldtarget>.x"/ebmon.x/ <$(srcdir)/ldtemplate >$@
173
174 ldgld68k.c: $(srcdir)/ldtemplate
175 sed -e s/"<ldtarget>"/ldgld68k/g -e s/"<arch>"/m68k/g \
176 -e s/"<target>"/68k/g -e s/"<TARGET>"/68K/g <$(srcdir)/ldtemplate >$@
177 ldglda29k.c: $(srcdir)/ldtemplate
178 sed -e s/"<ldtarget>"/ldglda29k/g -e s/"<arch>"/a29k/g \
179 -e s/"<target>"/29k/g -e s/"<TARGET>"/29K/g <$(srcdir)/ldtemplate >$@
180 ldm88k.c: $(srcdir)/ldtemplate
181 sed -e s/"<ldtarget>"/ldm88k/g -e s/"<arch>"/m88k/g \
182 -e s/"<target>"/m88kbcs/g -e s/"<TARGET>"/M88KBCS/g <$(srcdir)/ldtemplate >$@
183
184 # The .c files for these are generated from ldtemplete.
185 ldgld.o: ./mkscript ldgld.x ldgld.xr ldgld.xu ldgld.xn ldgld.xN
186 news.o: ./mkscript news.x news.xr news.xu news.xn news.xN
187 ebmon29k.o: ./mkscript ebmon29k.x ebmon29k.xr ebmon29k.xu \
188 ebmon29k.xn ebmon29k.xN
189 ldgld68k.o: ./mkscript ldgld68k.x ldgld68k.xr ldgld68k.xu \
190 ldgld68k.xn ldgld68k.xN
191 ldglda29k.o: ./mkscript ldglda29k.x ldglda29k.xr ldglda29k.xu \
192 ldglda29k.xn ldglda29k.xN
193 ldm88k.o: ./mkscript ldm88k.x ldm88k.xr ldm88k.xu ldm88k.xn ldm88k.xN
194
195 # The .c files for these are (for now) specially written (not ldtemplete).
196 ldgld960.o: ./mkscript ldgld960.x
197 ldlnk960.o: ./mkscript ldlnk960.x ldlnk960.xr
198 h8300hds.o: ./mkscript h8300hds.x
199
200
201 #$(BFDLIB): $(BFDSOURCES)
202 # (cd ../bfd; make)
203
204 $(LD_PROG): $(OFILES) $(BFDLIB) $(LIBIBERTY)
205 $(CC) $(CFLAGS) $(LDFLAGS) -o $(LD_PROG) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(LOADLIBES)
206
207 # (cd ../bfd; make)
208 # LDEMULATION=gld; export LDEMULATION; GNUTARGET=a.out-sunos-big;./ldok -format a.out-sunos-big -o ld /lib/crt0.o $(OFILES) $(BFDLIB) $(LIBIBERTY) -lc /usr/local/lib/gcc/sparc/1.91/gnulib
209 # gld -o ld /lib/crt0.o $(OFILES) $(BFDLIB) $(LIBIBERTY) -lc /usr/local/lib/gcc/sparc/1.91/gnulib
210 # $(CC) -Bstatic -o ld.new $(OFILES) $(BFDLIB) $(LIBIBERTY)
211
212
213 ld1: ld.new
214 $(HOSTING_EMU); ./ld.new -o ld1 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS)
215
216 ld2: ld1
217 $(HOSTING_EMU); ./ld1 -o ld2 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS)
218
219 ld3: ld2
220 $(HOSTING_EMU); ./ld2 -o ld3 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS)
221
222 ######################################################################
223 # DOCUMENTATION TARGETS
224 # TeX output
225 ld.dvi: ld.texinfo
226 TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex ld.texinfo
227 texindex ld.??
228 TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex ld.texinfo
229
230 # info file for online browsing
231 ld.info: ld.texinfo
232 makeinfo ld.texinfo
233
234 # roff output (-ms)
235 # edit instances of "ms" to "me" or "mm" to suit your preferences.
236 # (we don't use a variable because we don't trust all makes to handle
237 # a var in the target name right).
238 ld.ms: ld.texinfo
239 sed -e '/\\input texinfo/d' \
240 -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
241 ld.texinfo | \
242 texi2roff $(TEXI2OPT) -ms >ld.ms
243
244 # index for roff output
245 ld-index.ms: ld.ms
246 $(ROFF) -ms ld.ms 2>&1 1>/dev/null | \
247 sed -e '/: warning:/d' | \
248 texi2index >ld-index.ms
249
250 ######################################################################
251
252 mkscript: $(srcdir)/mkscript.c
253 $(CC) $(CFLAGS) $(LDFLAGS) -o mkscript $(srcdir)/mkscript.c $(LOADLIBES)
254
255 ldlex.c: ldlex.l ldgram.h
256 ldlex.o: ldlex.c ldgram.h
257 ldgram.o: ldgram.c
258 ldgram.c:ldgram.y
259
260 ldgld68k.x :ldgld68k.sc
261 ldgld68kUr.x :ldgld68kUr.sc
262 ldgld68kr.x :ldgld68kr.sc
263 h8300hds.x:h8300hds.sc
264 ldgld.x :ldgld.sc
265 ldgldUr.x :ldgldUr.sc
266 ldgldr.x :ldgldr.sc
267 ldlnk960.x :ldlnk960.sc
268 ldlnk960r.x :ldlnk960r.sc
269 ldgld960.x :ldgld960.sc
270 ldgldm88k.x :ldgldm88k.sc
271 ldm88kUr.x :ldm88kUr.sc
272 ldm88kr.x:ldm88kr.sc
273 ldm88k.x:ldm88k.sc
274 news.x:news.sc
275 h8300hds.x:h8300hds.sc
276 h8300hds.o:h8300hds.c
277 ldgld68k.x:ldgld68k.sc
278 ldglda29k.x :ldglda29k.sc
279 ldglda29kr.x :ldglda29kr.sc
280 ldglda29kUr.x :ldglda29kUr.sc
281
282 ebmon29k.x :ebmon29k.sc
283 ebmon29kr.x :ebmon29kr.sc
284 ebmon29kUr.x :ebmon29kUr.sc
285
286 stage1: force
287 - mkdir stage1
288 - mv -f $(STAGESTUFF) stage1
289 - (cd stage1 ; ln -s $(LD_PROG) ld)
290
291 stage2: force
292 - mkdir stage2
293 - mv -f $(STAGESTUFF) stage2
294 - (cd stage2 ; ln -s $(LD_PROG) ld)
295
296 stage3: force
297 - mkdir stage3
298 - mv -f $(STAGESTUFF) stage3
299 - (cd stage3 ; ln -s $(LD_PROG) ld)
300
301 against=stage2
302
303 comparison: force
304 for i in $(STAGESTUFF) ; do cmp $$i $(against)/$$i ; done
305
306 de-stage1: force
307 - (cd stage1 ; mv -f * ..)
308 - rm ld
309 - rmdir stage1
310
311 de-stage2: force
312 - (cd stage2 ; mv -f * ..)
313 - rm ld
314 - rmdir stage2
315
316 de-stage3: force
317 - (cd stage3 ; mv -f * ..)
318 - rm ld
319 - rmdir stage3
320
321 clean:
322 - rm -f TAGS $(OFILES) $(GENERATED_SOURCES) $(GENERATED_HEADERS)
323 - rm -f *.x *.x[runN] *.sc[runN]
324 - rm -f ld.?? ld.???
325 - rm -f ld ld1 ld2 ld3 ld.new mkscript *.o y.output
326
327 lintlog:$(SOURCES) Makefile
328 $(LINT) -abhxzn $(LINTFLAGS) $(LINTSOURCES) \
329 | grep -v "pointer casts may be troublesome" \
330 | grep -v "possible pointer alignment problem" \
331 | grep -v "ignore" \
332 | grep -v "conversion from long may lose accuracy" \
333 | grep -v "warning: constant argument to NOT" \
334 | grep -v "enumeration type clash, operator CAST" \
335 | grep -v "warning: constant in conditional context"\
336 | grep -v "archive\.c"
337
338
339 tags TAGS:$(SOURCES) $(HEADERS)
340 etags -t $?
341
342 release:
343 (cd /4/steve/ld; tar cf - $(LDSOURCES) $(HEADERS) $(MANSOURCES)) | tar xf -
344
345 objdump:objdump.c
346
347 install: $(LD_PROG)
348 # $(INSTALL_PROGRAM) ld.new $(libsubdir)/ld
349 cp $(LD_PROG) $(bindir)/ld.new
350 mv -f $(bindir)/ld.new $(bindir)/ld
351
352 #-----------------------------------------------------------------------------
353 # 'STANDARD' GNU/960 TARGETS BELOW THIS POINT
354 #
355 # 'VERSION' file must be present and contain a string of the form "x.y"
356 #-----------------------------------------------------------------------------
357
358 ver960.c: FORCE
359 rm -f ver960.c
360 echo "char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > ver960.c
361
362
363 # This target should be invoked before building a new release.
364 # 'VERSION' file must be present and contain a string of the form "x.y"
365 #
366 roll:
367 @V=`cat VERSION` ; \
368 MAJ=`sed 's/\..*//' VERSION` ; \
369 MIN=`sed 's/.*\.//' VERSION` ; \
370 V=$$MAJ.`expr $$MIN + 1` ; \
371 rm -f VERSION ; \
372 echo $$V >VERSION ; \
373 echo Version $$V
374
375
376 dep: $(LDSOURCES)
377 mkdep $(CFLAGS) $?
378
379 # Dummy target to force execution of dependent targets.
380 #
381 force:
382
383 # Target to uncomment host-specific lines in this makefile. Such lines must
384 # have the following string beginning in column 1: #__<hostname>__#
385 # Original Makefile is backed up as 'Makefile.old'.
386 #
387 # Invoke with: make make HOST=xxx
388 #
389 make:
390 -@if test $(HOST)x = x ; then \
391 echo '\aSpecify "make make HOST=???"'; \
392 exit 1; \
393 fi ; \
394 grep -s "^#The next line was generated by 'make make'" Makefile; \
395 if test $$? = 0 ; then \
396 echo "\aMakefile has already been processed with 'make make'";\
397 exit 1; \
398 fi ; \
399 mv -f Makefile Makefile.old; \
400 echo "#The next line was generated by 'make make'" >Makefile ; \
401 echo "HOST=$(HOST)" >>Makefile ; \
402 echo >>Makefile ; \
403 sed "s/^#__$(HOST)__#//" < Makefile.old >>Makefile
404
405 #\f
406
407 Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)
408 $(SHELL) ./config.status
409
410 ### Local Variables: ***
411 ### mode:fundamental ***
412 ### page-delimiter: "^#\f" ***
413 ### End: ***
414 ### end of file
415
416
417 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
This page took 0.038322 seconds and 5 git commands to generate.