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`
30 bindir = $(ddestdir)/bin
31 gcclibdir = $(ddestdir)/lib/gcc/$(target_alias)$(version)
33 # Seach path to override the default search path for -lfoo libraries.
34 # If LIB_PATH is empty, the ones in the script (if any) are left alone.
35 # Otherwise, they are replaced with the ones given in LIB_PATH,
36 # which may have the form: LIB_PATH=/lib:/usr/local/lib
40 INSTALL_PROGRAM = $(INSTALL)
41 INSTALL_FILE = $(INSTALL)
44 INCLUDE = $(srcdir)/../include
45 INCLUDES = -I. -I$(srcdir) -I$(INCLUDE)
48 # Where to find texinfo.tex to format docn with TeX
49 TEXIDIR = $(srcdir)/../texinfo/fsf
51 # Whether to get roff to put indexing entries on stderr
53 # You neeed this to generate ld-index.ms (or .mm or .me)
56 # Which roff program to use to generate index for texi2roff'd doc
62 SCRIPTS = ldgld68k.sc ldgld.sc \
63 ldlnk960.sc ldlnk960r.sc ldgld960.sc \
64 i386aout.sc ldm88k.sc ldglda29k.sc news.sc h8300hds.sc ebmon29k.sc
66 #### target and host dependent Makefile fragments come in here.
69 CFLAGS = $(INCLUDES) $(MINUS_G) $(HDEFINES) $(TDEFINES) $(CDEFINES)
70 LINTFLAGS = $(INCLUDES) $(EXTRA_DEF)
72 .SUFFIXES: .y .x .xr .xu .xn .xN .sc .scu .scr .scn $(SUFFIXES)
74 # go directly to ld.new in case this ld isn't capable of
75 # linking native object on this host. It can be renamed on
79 # A .sc script file is needed for each emulation mode.
80 # sed is used to transform this script into two variant forms:
81 # A .scr script is for linking without relocation (-r flag).
82 # A .scu script is like .scr, but *do* create constructors.
83 # A .scn script is for linking with -N flag (mix text and data on same page).
84 # A .scN script is for linking with -N flag (mix text and data on same page).
85 # The diference is that segments should (need) not be page aligned.
87 # A sed pattern to translate .sc to .scu:
88 SED_MAKE_RELOC_WITH_CONSTRUCTORS=\
89 -e "/If relocating/,/End if relocating/d" \
90 -e "/=/s/[_a-zA-Z.]* *= .*//g" \
91 -e '/>/s/} *> *[a-zA-Z]*/}/' \
92 -e "/text/s/[.]text .*:/.text :/" \
93 -e "/data/s/[.]data .*:/.data :/"
94 # A sed pattern to translate .scu to .scr:
95 SED_REMOVE_CONSTRUCTORS= -e /CONSTRUCTORS/d
98 sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) $< >$*.scu
100 sed $(SED_REMOVE_CONSTRUCTORS) < $< >$*.scr
102 # Each builtin script file is included as a C string literal.
103 # These are generated by the mkscript filter.
105 if [ "x"$(LIB_PATH) = "x" ]; then ./mkscript < $< >$*.x ; \
107 (sed <$< -e '/SEARCH_DIR(.*)/d' ; \
108 echo $(LIB_PATH) | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g';) | ./mkscript >$*.x;\
111 # The .xn script is used if the -n flag is given (write-protect text)..
112 # Sunos starts the text segment for demand-paged binaries at 0x2020
113 # and other binaries at 0x2000, since the exec header is paged in
114 # with the text. Some other Unix variants do the same.
115 # For -n and -N flags the offset of the exec header must be removed.
116 # This sed script does this if the master script contains
117 # a line of the form ".text 0xAAAA BLOCK(0xBBBB):" - the
118 # output will contain ".text 0xBBBB:". (For Sunos AAAA=2020 and BBBB=2000.)
120 sed -e '/text/s/\.text .* BLOCK(\([^)]*\)):/.text \1:/' < $< >$*.xn
122 # The .xN script is used if the -N flag is given (don't write-protect text).
123 # This is like -n, except that the data segment need not be page-aligned.
124 # So get rid of commands for page-alignment: We assume these use ALIGN
125 # with a hex constant that end with 00, since any normal page size is be
126 # at least divisible by 256. We use the 00 to avoid matching
127 # anything that tries to align of (say) 8-byte boundaries.
129 sed -e '/ALIGN/s/ALIGN( *0x[0-9a-fA-F]*00 *)/./' < $< >$*.xN
131 # The xu and xr scripts don't search libraries, so LIB_PATH doesn't matter.
133 sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) < $< | ./mkscript >$*.xu
135 sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) $(SED_REMOVE_CONSTRUCTORS) \
136 < $< | ./mkscript >$*.xr
139 BFDLIB=$(unsubdir)/../bfd$(subdir)/libbfd.a
140 LIBIBERTY=$(unsubdir)/../libiberty$(subdir)/libiberty.a
142 OFILES= ldgram.o ldlex.o ldlang.o ldctor.o ldmain.o ldindr.o \
143 ldwarn.o ldwrite.o ldexp.o ldlnk960.o ld__gld68k.o ld__i386aout.o \
144 ld__m88k.o ld__glda29k.o ld__news.o h8300hds.o ld__ebmon29k.o \
145 ld__gld.o ldgld960.o ldemul.o ldver.o ldmisc.o ldsym.o ldvanilla.o ldfile.o
147 HEADERS=config.h ldmain.h ldmain.h ldwarn.h ldmisc.h ldindr.h \
148 ldsym.h ldctor.h ldlang.h ldexp.h \
149 ldlex.h ldwrite.h ldver.h ldemul.h ldfile.h ldgram.h ld.h
153 LDCSOURCES=ldlang.c ldctor.c ldindr.c ldmain.c ldwrite.c ldwarn.c ldlnk960.c \
154 ld__gld.c ld__gld68k.c ld__m88k.c ld__ebmon29k.c \
155 ldgld960.c ldemul.c ldver.c ldmisc.c ldexp.c ldsym.c ldfile.c ldvanilla.c
157 GENERATED_SOURCES=ldgram.c ldlex.c ldgram.h ld__*.c
158 GENERATED_HEADERS=ldgram.h
160 LDSOURCES=$(LDCSOURCES) ldgram.y ldlex.l ldgram.h
162 BFDSOURCES=../../bfd/common/*.c
164 SOURCES= $(LDSOURCES) $(BFDSOURCES)
165 LINTSOURCES= $(LDCSOURCES) $(BFDSOURCES) $(GENERATED_SOURCES)
167 STAGESTUFF = *.x *.x[ru] *.sc[ru] $(GENERATED_SOURCES) $(GENERATED_HEADERS) $(OFILES) $(LD_PROG) mkscript
169 all: Makefile $(LD_PROG) ld.info
171 ldgram.h ldgram.c: ldgram.y
172 $(BISON) $(BISONFLAGS) -d $(VPATH)/ldgram.y -o ldgram.c
173 # These are in case BISON is really yacc (which ignores -o).
174 if [ -f y.tab.c -a ! -f ldgram.c ]; then mv y.tab.c ldgram.c; else true ; fi
175 if [ -f y.tab.h -a ! -f ldgram.h ]; then mv y.tab.h ldgram.h; else true ; fi
178 lex -t $(VPATH)/ldlex.l >ldlex.c
180 # These all start with ld__ so 'make clean' can find them.
182 ld__gld.c: $(srcdir)/ldtemplate
183 sed -e s/"<ldtarget>"/ldgld/g -e s/"<arch>"/m68k/g \
184 -e s/"<target>"//g -e s/"<TARGET>"//g <$(srcdir)/ldtemplate >$@
185 ld__news.c: $(srcdir)/ldtemplate
186 sed -e s/"<ldtarget>"/news/g -e s/"<arch>"/m68k/g \
187 -e s/"<target>"/news/g -e s/"<TARGET>"/NEWS/g <$(srcdir)/ldtemplate >$@
189 ld__i386aout.c: $(srcdir)/ldtemplate
190 sed -e s/"<ldtarget>"/i386aout/g -e s/"<arch>"/i386/g \
191 -e s/"<target>"/i386aout/g -e s/"<TARGET>"/I386AOUT/g <$(srcdir)/ldtemplate >$@
194 ld__ebmon29k.c: $(srcdir)/ldtemplate
195 sed -e s/"<ldtarget>"/ebmon29k/g -e s/"<arch>"/a29k/g \
196 -e s/"gld<target>"/ebmon29k/g -e s/"GLD<TARGET>"/EBMON29K/g \
197 -e s/"<ldtarget>.x"/ebmon.x/ <$(srcdir)/ldtemplate >$@
199 ld__gld68k.c: $(srcdir)/ldtemplate
200 sed -e s/"<ldtarget>"/ldgld68k/g -e s/"<arch>"/m68k/g \
201 -e s/"<target>"/68k/g -e s/"<TARGET>"/68K/g <$(srcdir)/ldtemplate >$@
202 ld__glda29k.c: $(srcdir)/ldtemplate
203 sed -e s/"<ldtarget>"/ldglda29k/g -e s/"<arch>"/a29k/g \
204 -e s/"<target>"/29k/g -e s/"<TARGET>"/29K/g <$(srcdir)/ldtemplate >$@
205 ld__m88k.c: $(srcdir)/ldtemplate
206 sed -e s/"<ldtarget>"/ldm88k/g -e s/"<arch>"/m88k/g \
207 -e s/"<target>"/m88kbcs/g -e s/"<TARGET>"/M88KBCS/g <$(srcdir)/ldtemplate >$@
209 # The .c files for these are generated from ldtemplete.
210 ld__gld.o: ./mkscript ldgld.x ldgld.xr ldgld.xu ldgld.xn ldgld.xN
211 ld__news.o: ./mkscript news.x news.xr news.xu news.xn news.xN
212 ld__i386aout.o: ./mkscript i386aout.x i386aout.xr i386aout.xu i386aout.xn i386aout.xN
213 ld__ebmon29k.o: ./mkscript ebmon29k.x ebmon29k.xr ebmon29k.xu \
214 ebmon29k.xn ebmon29k.xN
215 ld__gld68k.o: ./mkscript ldgld68k.x ldgld68k.xr ldgld68k.xu \
216 ldgld68k.xn ldgld68k.xN
217 ld__glda29k.o: ./mkscript ldglda29k.x ldglda29k.xr ldglda29k.xu \
218 ldglda29k.xn ldglda29k.xN
219 ld__m88k.o: ./mkscript ldm88k.x ldm88k.xr ldm88k.xu ldm88k.xn ldm88k.xN
221 # The .c files for these are (for now) specially written (not ldtemplete).
222 ldgld960.o: ./mkscript ldgld960.x
223 ldlnk960.o: ./mkscript ldlnk960.x ldlnk960.xr
224 h8300hds.o: ./mkscript h8300hds.x
227 #$(BFDLIB): $(BFDSOURCES)
230 $(LD_PROG): $(OFILES) $(BFDLIB) $(LIBIBERTY)
231 $(CC) $(CFLAGS) $(LDFLAGS) -o $(LD_PROG) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(LOADLIBES)
234 # 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
235 # gld -o ld /lib/crt0.o $(OFILES) $(BFDLIB) $(LIBIBERTY) -lc /usr/local/lib/gcc/sparc/1.91/gnulib
236 # $(CC) -Bstatic -o ld.new $(OFILES) $(BFDLIB) $(LIBIBERTY)
240 $(HOSTING_EMU); ./ld.new -o ld1 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS)
243 $(HOSTING_EMU); ./ld1 -o ld2 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS)
246 $(HOSTING_EMU); ./ld2 -o ld3 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS)
248 ######################################################################
249 # DOCUMENTATION TARGETS
251 ld.dvi: $(srcdir)/ld.texinfo
252 TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex $(srcdir)/ld.texinfo
254 TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex $(srcdir)/ld.texinfo
256 # info file for online browsing
257 ld.info: $(srcdir)/ld.texinfo
258 - $(MAKEINFO) -o ld.info $(srcdir)/ld.texinfo
260 #separate targets for "ms", "me", and "mm" forms of roff doc
261 # (we don't use a variable because we don't trust all makes to handle
262 # a var in the target name right).
264 ld.ms: $(srcdir)/ld.texinfo
265 sed -e '/\\input texinfo/d' \
266 -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
267 $(srcdir)/ld.texinfo | \
268 texi2roff $(TEXI2OPT) -ms >ld.ms
270 # index for roff output
272 $(ROFF) -ms ld.ms 2>&1 1>/dev/null | \
273 sed -e '/: warning:/d' | \
274 texi2index >ld-index.ms
277 ld.mm: $(srcdir)/ld.texinfo
278 sed -e '/\\input texinfo/d' \
279 -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
282 $(srcdir)/ld.texinfo | \
283 texi2roff $(TEXI2OPT) -mm | \
284 sed -e 's/---/\\(em/g' \
287 # index for roff output
289 $(ROFF) -mm ld.mm 2>&1 1>/dev/null | \
290 sed -e '/: warning:/d' | \
291 texi2index >ld-index.mm
294 ld.me: $(srcdir)/ld.texinfo
295 sed -e '/\\input texinfo/d' \
296 -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
297 $(srcdir)/ld.texinfo | \
298 texi2roff $(TEXI2OPT) -me >ld.me
300 # index for roff output
302 $(ROFF) -me ld.me 2>&1 1>/dev/null | \
303 sed -e '/: warning:/d' | \
304 texi2index >ld-index.me
307 ######################################################################
309 mkscript: $(srcdir)/mkscript.c
310 $(CC) $(CFLAGS) $(LDFLAGS) -o mkscript $(srcdir)/mkscript.c $(LOADLIBES)
312 ldlex.c: ldlex.l ldgram.h
313 ldlex.o: ldlex.c ldgram.h
317 ldgld68k.x :ldgld68k.sc
318 ldgld68kUr.x :ldgld68kUr.sc
319 ldgld68kr.x :ldgld68kr.sc
320 h8300hds.x:h8300hds.sc
322 ldgldUr.x :ldgldUr.sc
324 ldlnk960.x :ldlnk960.sc
325 ldlnk960r.x :ldlnk960r.sc
326 ldgld960.x :ldgld960.sc
327 ldgldm88k.x :ldgldm88k.sc
328 ldm88kUr.x :ldm88kUr.sc
332 i386aout.x:i386aout.sc
333 h8300hds.x:h8300hds.sc
334 h8300hds.o:h8300hds.c
335 ldgld68k.x:ldgld68k.sc
336 ldglda29k.x :ldglda29k.sc
337 ldglda29kr.x :ldglda29kr.sc
338 ldglda29kUr.x :ldglda29kUr.sc
340 ebmon29k.x :ebmon29k.sc
341 ebmon29kr.x :ebmon29kr.sc
342 ebmon29kUr.x :ebmon29kUr.sc
346 - mv -f $(STAGESTUFF) stage1
347 - (cd stage1 ; ln -s $(LD_PROG) ld)
351 - mv -f $(STAGESTUFF) stage2
352 - (cd stage2 ; ln -s $(LD_PROG) ld)
356 - mv -f $(STAGESTUFF) stage3
357 - (cd stage3 ; ln -s $(LD_PROG) ld)
362 for i in $(STAGESTUFF) ; do cmp $$i $(against)/$$i ; done
365 - (cd stage1 ; mv -f * ..)
370 - (cd stage2 ; mv -f * ..)
375 - (cd stage3 ; mv -f * ..)
380 - rm -f TAGS $(OFILES) $(GENERATED_SOURCES) $(GENERATED_HEADERS)
381 - rm -f *.x *.x[runN] *.sc[runN]
383 - rm -f ld ld1 ld2 ld3 ld.new mkscript *.o y.output
385 lintlog:$(SOURCES) Makefile
386 $(LINT) -abhxzn $(LINTFLAGS) $(LINTSOURCES) \
387 | grep -v "pointer casts may be troublesome" \
388 | grep -v "possible pointer alignment problem" \
390 | grep -v "conversion from long may lose accuracy" \
391 | grep -v "warning: constant argument to NOT" \
392 | grep -v "enumeration type clash, operator CAST" \
393 | grep -v "warning: constant in conditional context"\
394 | grep -v "archive\.c"
397 tags TAGS:$(SOURCES) $(HEADERS)
404 $(INSTALL_PROGRAM) ld.new $(ddestdir)/bin/ld
405 $(INSTALL_PROGRAM) ld.new $(gcclibdir)/ld
406 for i in ld.info* ; do \
407 echo Installing $$i... ; \
408 (cp $$i $(idestdir)/info/$$i.new \
409 && mv -f $(idestdir)/info/$$i.new $(idestdir)/info/$$i) \
413 # Something like the following might make sense for install, but doesn't work
414 # - it is too fragile, depending on a gcc binary int the right place.
415 # Perhaps using gcc/version.c might work?
416 # # If $(gcclibdir) exists, install ld there, and put a link to it
417 # # from $(bindir); otherwise put ld in $(bindir).
418 # if ([ -x $(unsubdir)/../gcc$(subdir)/gcc -a -d $(gcclibdir) ]); then \
419 # $(INSTALL_PROGRAM) ld.new $(gcclibdir)/ld; \
420 # cd $(bindir); rm -f ld; ln -s $(gcclibdir)/ld ld; \
422 # $(INSTALL_PROGRAM) ld.new $(bindir)/ld; \
425 #-----------------------------------------------------------------------------
426 # 'STANDARD' GNU/960 TARGETS BELOW THIS POINT
428 # 'VERSION' file must be present and contain a string of the form "x.y"
429 #-----------------------------------------------------------------------------
433 echo "char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > ver960.c
436 # This target should be invoked before building a new release.
437 # 'VERSION' file must be present and contain a string of the form "x.y"
441 MAJ=`sed 's/\..*//' VERSION` ; \
442 MIN=`sed 's/.*\.//' VERSION` ; \
443 V=$$MAJ.`expr $$MIN + 1` ; \
445 echo $$V >VERSION ; \
452 # Dummy target to force execution of dependent targets.
456 # Target to uncomment host-specific lines in this makefile. Such lines must
457 # have the following string beginning in column 1: #__<hostname>__#
458 # Original Makefile is backed up as 'Makefile.old'.
460 # Invoke with: make make HOST=xxx
463 -@if test $(HOST)x = x ; then \
464 echo '
\aSpecify "make make HOST=???"'; \
467 grep -s "^#The next line was generated by 'make make'" Makefile; \
468 if test $$? = 0 ; then \
469 echo "
\aMakefile has already been processed with 'make make'";\
472 mv -f Makefile Makefile.old; \
473 echo "#The next line was generated by 'make make'" >Makefile ; \
474 echo "HOST=$(HOST)" >>Makefile ; \
476 sed "s/^#__$(HOST)__#//" < Makefile.old >>Makefile
480 Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)
481 $(SHELL) ./config.status
483 ### Local Variables: ***
484 ### mode:fundamental ***
485 ### page-delimiter: "^#
\f" ***
490 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY