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