1 # Makefile for the GNU linker ld (version 2)
2 # Copyright (C) 1989-1991 Free Software Foundation, Inc.
4 # This file is part of GNU ld..
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.
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.
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.
28 version
=`$(unsubdir)/../gcc$(subdir)/gcc -dumpversion`
29 bindir = $(ddestdir
)/bin
30 gcclibdir
= $(ddestdir
)/lib
/gcc
/$(target_alias
)/$(version
)
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
39 INSTALL_PROGRAM
= $(INSTALL
)
40 INSTALL_FILE
= $(INSTALL
)
43 INCLUDE
= $(srcdir)/..
/include
44 INCLUDES
= -I.
-I
$(srcdir) -I
$(INCLUDE
)
47 # Where to find texinfo.tex to format docn with TeX
48 TEXIDIR
= $(srcdir)/..
/texinfo
/fsf
50 # Whether to get roff to put indexing entries on stderr
52 # You neeed this to generate ld-index.ms (or .mm or .me)
55 # Which roff program to use to generate index for texi2roff'd doc
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
65 #### target and host dependent Makefile fragments come in here.
68 CFLAGS
= $(INCLUDES
) $(DEBUG
) $(HDEFINES
) $(TDEFINES
) $(CDEFINES
)
69 LINTFLAGS
= $(INCLUDES
) $(EXTRA_DEF
)
71 .SUFFIXES
: .y .x .xr .xu .xn .xN .sc .scu .scr .scn
$(SUFFIXES
)
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
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.
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
97 sed
$(SED_MAKE_RELOC_WITH_CONSTRUCTORS
) $< >$*.scu
99 sed
$(SED_REMOVE_CONSTRUCTORS
) < $< >$*.scr
101 # Each builtin script file is included as a C string literal.
102 # These are generated by the mkscript filter.
104 if
[ "x"$(LIB_PATH
) = "x" ]; then .
/mkscript
< $< >$*.x
; \
106 (sed
<$< -e
'/SEARCH_DIR(.*)/d' ; \
107 echo
$(LIB_PATH
) | tr
':' ' ' | sed
-e
's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g';) | .
/mkscript
>$*.x
;\
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.)
119 sed
-e
'/text/s/\.text .* BLOCK(\([^)]*\)):/.text \1:/' < $< >$*.xn
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.
128 sed
-e
'/ALIGN/s/ALIGN( *0x[0-9a-fA-F]*00 *)/./' < $< >$*.xN
130 # The xu and xr scripts don't search libraries, so LIB_PATH doesn't matter.
132 sed
$(SED_MAKE_RELOC_WITH_CONSTRUCTORS
) < $< | .
/mkscript
>$*.xu
134 sed
$(SED_MAKE_RELOC_WITH_CONSTRUCTORS
) $(SED_REMOVE_CONSTRUCTORS
) \
135 < $< | .
/mkscript
>$*.xr
138 BFDLIB
=$(unsubdir
)/..
/bfd
$(subdir
)/libbfd.a
139 LIBIBERTY
=$(unsubdir
)/..
/libiberty
$(subdir
)/libiberty.a
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
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
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
156 GENERATED_SOURCES
=ldgram.c ldlex.c ldgram.h
157 GENERATED_HEADERS
=ldgram.h
159 LDSOURCES
=$(LDCSOURCES
) ldgram.y ldlex.l ldgram.h
161 BFDSOURCES
=..
/..
/bfd
/common
/*.c
163 SOURCES
= $(LDSOURCES
) $(BFDSOURCES
)
164 LINTSOURCES
= $(LDCSOURCES
) $(BFDSOURCES
) $(GENERATED_SOURCES
)
166 STAGESTUFF
= *.x
*.x
[ru
] *.sc
[ru
] $(GENERATED_SOURCES
) $(GENERATED_HEADERS
) $(OFILES
) $(LD_PROG
) mkscript
168 all: Makefile
$(LD_PROG
)
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
177 lex -t
$(VPATH
)/ldlex.l
>ldlex.c
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
>$@
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
>$@
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
>$@
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
>$@
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
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
225 #$(BFDLIB): $(BFDSOURCES)
228 $(LD_PROG
): $(OFILES
) $(BFDLIB
) $(LIBIBERTY
)
229 $(CC
) $(CFLAGS
) $(LDFLAGS
) -o
$(LD_PROG
) $(OFILES
) $(BFDLIB
) $(LIBIBERTY
) $(LOADLIBES
)
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)
238 $(HOSTING_EMU
); .
/ld.new
-o ld1
$(HOSTING_CRT0
) $(OFILES
) $(BFDLIB
) $(LIBIBERTY
) $(HOSTING_LIBS
)
241 $(HOSTING_EMU
); .
/ld1
-o ld2
$(HOSTING_CRT0
) $(OFILES
) $(BFDLIB
) $(LIBIBERTY
) $(HOSTING_LIBS
)
244 $(HOSTING_EMU
); .
/ld2
-o ld3
$(HOSTING_CRT0
) $(OFILES
) $(BFDLIB
) $(LIBIBERTY
) $(HOSTING_LIBS
)
246 ######################################################################
247 # DOCUMENTATION TARGETS
250 TEXINPUTS
=${TEXIDIR}:.
:$$TEXINPUTS tex ld.texinfo
252 TEXINPUTS
=${TEXIDIR}:.
:$$TEXINPUTS tex ld.texinfo
254 # info file for online browsing
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).
263 sed
-e
'/\\input texinfo/d' \
264 -e
'/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
266 texi2roff
$(TEXI2OPT
) -ms
>ld.ms
268 # index for roff output
270 $(ROFF
) -ms
ld.ms
2>&1 1>/dev
/null | \
271 sed
-e
'/: warning:/d' | \
272 texi2index
>ld-index.ms
276 sed
-e
'/\\input texinfo/d' \
277 -e
'/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
279 texi2roff
$(TEXI2OPT
) -mm
>ld.mm
281 # index for roff output
283 $(ROFF
) -mm
ld.mm
2>&1 1>/dev
/null | \
284 sed
-e
'/: warning:/d' | \
285 texi2index
>ld-index.mm
289 sed
-e
'/\\input texinfo/d' \
290 -e
'/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
292 texi2roff
$(TEXI2OPT
) -me
>ld.me
294 # index for roff output
296 $(ROFF
) -me
ld.me
2>&1 1>/dev
/null | \
297 sed
-e
'/: warning:/d' | \
298 texi2index
>ld-index.me
301 ######################################################################
303 mkscript
: $(srcdir)/mkscript.c
304 $(CC
) $(CFLAGS
) $(LDFLAGS
) -o mkscript
$(srcdir)/mkscript.c
$(LOADLIBES
)
306 ldlex.c
: ldlex.l ldgram.h
307 ldlex.o
: ldlex.c ldgram.h
311 ldgld68k.x
:ldgld68k.sc
312 ldgld68kUr.x
:ldgld68kUr.sc
313 ldgld68kr.x
:ldgld68kr.sc
314 h8300hds.x
:h8300hds.sc
316 ldgldUr.x
:ldgldUr.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
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
334 ebmon29k.x
:ebmon29k.sc
335 ebmon29kr.x
:ebmon29kr.sc
336 ebmon29kUr.x
:ebmon29kUr.sc
340 - mv
-f
$(STAGESTUFF
) stage1
341 - (cd stage1
; ln
-s
$(LD_PROG
) ld)
345 - mv
-f
$(STAGESTUFF
) stage2
346 - (cd stage2
; ln
-s
$(LD_PROG
) ld)
350 - mv
-f
$(STAGESTUFF
) stage3
351 - (cd stage3
; ln
-s
$(LD_PROG
) ld)
356 for i in
$(STAGESTUFF
) ; do cmp
$$i $(against
)/$$i ; done
359 - (cd stage1
; mv
-f
* ..
)
364 - (cd stage2
; mv
-f
* ..
)
369 - (cd stage3
; mv
-f
* ..
)
374 - rm -f TAGS
$(OFILES
) $(GENERATED_SOURCES
) $(GENERATED_HEADERS
)
375 - rm -f
*.x
*.x
[runN
] *.sc
[runN
]
377 - rm -f
ld ld1 ld2 ld3
ld.new mkscript
*.o y.output
379 lintlog
:$(SOURCES
) Makefile
380 $(LINT
) -abhxzn
$(LINTFLAGS
) $(LINTSOURCES
) \
381 | grep
-v
"pointer casts may be troublesome" \
382 | grep
-v
"possible pointer alignment problem" \
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"
391 tags TAGS
:$(SOURCES
) $(HEADERS
)
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; \
408 # $(INSTALL_PROGRAM) ld.new $(bindir)/ld; \
411 #-----------------------------------------------------------------------------
412 # 'STANDARD' GNU/960 TARGETS BELOW THIS POINT
414 # 'VERSION' file must be present and contain a string of the form "x.y"
415 #-----------------------------------------------------------------------------
419 echo
"char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > ver960.c
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"
427 MAJ
=`sed 's/\..*//' VERSION` ; \
428 MIN
=`sed 's/.*\.//' VERSION` ; \
429 V
=$$MAJ.
`expr $$MIN + 1` ; \
431 echo
$$V >VERSION
; \
438 # Dummy target to force execution of dependent targets.
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'.
446 # Invoke with: make make HOST=xxx
449 -@if
test $(HOST
)x
= x
; then \
450 echo
'\aSpecify "make make HOST=???"'; \
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'";\
458 mv
-f Makefile Makefile.old
; \
459 echo
"#The next line was generated by 'make make'" >Makefile
; \
460 echo
"HOST=$(HOST)" >>Makefile
; \
462 sed
"s/^#__$(HOST)__#//" < Makefile.old
>>Makefile
466 Makefile
: $(srcdir)/Makefile.in
$(host_makefile_frag
) $(target_makefile_frag
)
467 $(SHELL
) .
/config.status
469 ### Local Variables: ***
470 ### mode:fundamental ***
471 ### page-delimiter: "^#\f" ***
476 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY