2 # Makefile for ld version 2
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
)
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
23 INSTALL_PROGRAM
= $(INSTALL
)
24 INSTALL_FILE
= $(INSTALL
)
27 INCLUDE
= $(srcdir)/..
/include
28 INCLUDES
= -I.
-I
$(srcdir) -I
$(INCLUDE
)
31 # Where to find texinfo.tex to format docn with TeX
32 TEXIDIR
= $(srcdir)/..
/texinfo
/fsf
34 # Whether to get roff to put indexing entries on stderr
36 # You neeed this to generate ld-index.ms (or .mm or .me)
39 # Which roff program to use to generate index for texi2roff'd doc
45 SCRIPTS
= ldgld68k.sc ldgld.sc \
46 ldlnk960.sc ldlnk960r.sc ldgld960.sc \
47 ldm88k.sc ldglda29k.sc news.sc h8300hds.sc ebmon29k.sc
49 #### target and host dependent Makefile fragments come in here.
52 CFLAGS
= $(INCLUDES
) $(DEBUG
) $(HDEFINES
) $(TDEFINES
) $(CDEFINES
)
53 LINTFLAGS
= $(INCLUDES
) $(EXTRA_DEF
)
55 .SUFFIXES
: .y .x .xr .xu .xn .xN .sc .scu .scr .scn
$(SUFFIXES
)
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
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.
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
81 sed
$(SED_MAKE_RELOC_WITH_CONSTRUCTORS
) $< >$*.scu
83 sed
$(SED_REMOVE_CONSTRUCTORS
) < $< >$*.scr
85 # Each builtin script file is included as a C string literal.
86 # These are generated by the mkscript filter.
88 if
[ "x"$(LIB_PATH
) = "x" ]; then .
/mkscript
< $< >$*.x
; \
90 (sed
<$< -e
'/SEARCH_DIR(.*)/d' ; \
91 echo
$(LIB_PATH
) | tr
':' ' ' | sed
-e
's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g';) | .
/mkscript
>$*.x
;\
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.)
103 sed
-e
'/text/s/\.text .* BLOCK(\([^)]*\)):/.text \1:/' < $< >$*.xn
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.
112 sed
-e
'/ALIGN/s/ALIGN( *0x[0-9a-fA-F]*00 *)/./' < $< >$*.xN
114 # The xu and xr scripts don't search libraries, so LIB_PATH doesn't matter.
116 sed
$(SED_MAKE_RELOC_WITH_CONSTRUCTORS
) < $< | .
/mkscript
>$*.xu
118 sed
$(SED_MAKE_RELOC_WITH_CONSTRUCTORS
) $(SED_REMOVE_CONSTRUCTORS
) \
119 < $< | .
/mkscript
>$*.xr
122 BFDLIB
=$(unsubdir
)/..
/bfd
$(subdir
)/libbfd.a
123 LIBIBERTY
=$(unsubdir
)/..
/libiberty
$(subdir
)/libiberty.a
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
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
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
138 GENERATED_SOURCES
=ldgram.c ldlex.c ldgram.h
139 GENERATED_HEADERS
=ldgram.h
141 LDSOURCES
=$(LDCSOURCES
) ldgram.y ldlex.l ldgram.h
143 BFDSOURCES
=..
/..
/bfd
/common
/*.c
145 SOURCES
= $(LDSOURCES
) $(BFDSOURCES
)
146 LINTSOURCES
= $(LDCSOURCES
) $(BFDSOURCES
) $(GENERATED_SOURCES
)
148 STAGESTUFF
= *.x
*.x
[ru
] *.sc
[ru
] $(GENERATED_SOURCES
) $(GENERATED_HEADERS
) $(OFILES
) $(LD_PROG
) mkscript
150 all: Makefile
$(LD_PROG
)
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
159 lex -t
$(VPATH
)/ldlex.l
>ldlex.c
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
>$@
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
>$@
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
>$@
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
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
201 #$(BFDLIB): $(BFDSOURCES)
204 $(LD_PROG
): $(OFILES
) $(BFDLIB
) $(LIBIBERTY
)
205 $(CC
) $(CFLAGS
) $(LDFLAGS
) -o
$(LD_PROG
) $(OFILES
) $(BFDLIB
) $(LIBIBERTY
) $(LOADLIBES
)
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)
214 $(HOSTING_EMU
); .
/ld.new
-o ld1
$(HOSTING_CRT0
) $(OFILES
) $(BFDLIB
) $(LIBIBERTY
) $(HOSTING_LIBS
)
217 $(HOSTING_EMU
); .
/ld1
-o ld2
$(HOSTING_CRT0
) $(OFILES
) $(BFDLIB
) $(LIBIBERTY
) $(HOSTING_LIBS
)
220 $(HOSTING_EMU
); .
/ld2
-o ld3
$(HOSTING_CRT0
) $(OFILES
) $(BFDLIB
) $(LIBIBERTY
) $(HOSTING_LIBS
)
222 ######################################################################
223 # DOCUMENTATION TARGETS
226 TEXINPUTS
=${TEXIDIR}:.
:$$TEXINPUTS tex ld.texinfo
228 TEXINPUTS
=${TEXIDIR}:.
:$$TEXINPUTS tex ld.texinfo
230 # info file for online browsing
234 #separate targets for "ms", "me", and "mm" forms of roff doc
235 # (we don't use a variable because we don't trust all makes to handle
236 # a var in the target name right).
239 sed
-e
'/\\input texinfo/d' \
240 -e
'/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
242 texi2roff
$(TEXI2OPT
) -ms
>ld.ms
244 # index for roff output
246 $(ROFF
) -ms
ld.ms
2>&1 1>/dev
/null | \
247 sed
-e
'/: warning:/d' | \
248 texi2index
>ld-index.ms
252 sed
-e
'/\\input texinfo/d' \
253 -e
'/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
255 texi2roff
$(TEXI2OPT
) -mm
>ld.mm
257 # index for roff output
259 $(ROFF
) -mm
ld.mm
2>&1 1>/dev
/null | \
260 sed
-e
'/: warning:/d' | \
261 texi2index
>ld-index.mm
265 sed
-e
'/\\input texinfo/d' \
266 -e
'/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
268 texi2roff
$(TEXI2OPT
) -me
>ld.me
270 # index for roff output
272 $(ROFF
) -me
ld.me
2>&1 1>/dev
/null | \
273 sed
-e
'/: warning:/d' | \
274 texi2index
>ld-index.me
277 ######################################################################
279 mkscript
: $(srcdir)/mkscript.c
280 $(CC
) $(CFLAGS
) $(LDFLAGS
) -o mkscript
$(srcdir)/mkscript.c
$(LOADLIBES
)
282 ldlex.c
: ldlex.l ldgram.h
283 ldlex.o
: ldlex.c ldgram.h
287 ldgld68k.x
:ldgld68k.sc
288 ldgld68kUr.x
:ldgld68kUr.sc
289 ldgld68kr.x
:ldgld68kr.sc
290 h8300hds.x
:h8300hds.sc
292 ldgldUr.x
:ldgldUr.sc
294 ldlnk960.x
:ldlnk960.sc
295 ldlnk960r.x
:ldlnk960r.sc
296 ldgld960.x
:ldgld960.sc
297 ldgldm88k.x
:ldgldm88k.sc
298 ldm88kUr.x
:ldm88kUr.sc
302 h8300hds.x
:h8300hds.sc
303 h8300hds.o
:h8300hds.c
304 ldgld68k.x
:ldgld68k.sc
305 ldglda29k.x
:ldglda29k.sc
306 ldglda29kr.x
:ldglda29kr.sc
307 ldglda29kUr.x
:ldglda29kUr.sc
309 ebmon29k.x
:ebmon29k.sc
310 ebmon29kr.x
:ebmon29kr.sc
311 ebmon29kUr.x
:ebmon29kUr.sc
315 - mv
-f
$(STAGESTUFF
) stage1
316 - (cd stage1
; ln
-s
$(LD_PROG
) ld)
320 - mv
-f
$(STAGESTUFF
) stage2
321 - (cd stage2
; ln
-s
$(LD_PROG
) ld)
325 - mv
-f
$(STAGESTUFF
) stage3
326 - (cd stage3
; ln
-s
$(LD_PROG
) ld)
331 for i in
$(STAGESTUFF
) ; do cmp
$$i $(against
)/$$i ; done
334 - (cd stage1
; mv
-f
* ..
)
339 - (cd stage2
; mv
-f
* ..
)
344 - (cd stage3
; mv
-f
* ..
)
349 - rm -f TAGS
$(OFILES
) $(GENERATED_SOURCES
) $(GENERATED_HEADERS
)
350 - rm -f
*.x
*.x
[runN
] *.sc
[runN
]
352 - rm -f
ld ld1 ld2 ld3
ld.new mkscript
*.o y.output
354 lintlog
:$(SOURCES
) Makefile
355 $(LINT
) -abhxzn
$(LINTFLAGS
) $(LINTSOURCES
) \
356 | grep
-v
"pointer casts may be troublesome" \
357 | grep
-v
"possible pointer alignment problem" \
359 | grep
-v
"conversion from long may lose accuracy" \
360 | grep
-v
"warning: constant argument to NOT" \
361 | grep
-v
"enumeration type clash, operator CAST" \
362 | grep
-v
"warning: constant in conditional context"\
363 | grep
-v
"archive\.c"
366 tags TAGS
:$(SOURCES
) $(HEADERS
)
370 (cd
/4/steve
/ld; tar cf
- $(LDSOURCES
) $(HEADERS
) $(MANSOURCES
)) |
tar xf
-
375 # $(INSTALL_PROGRAM) ld.new $(libsubdir)/ld
376 cp
$(LD_PROG
) $(bindir)/ld.new
377 mv
-f
$(bindir)/ld.new
$(bindir)/ld
379 #-----------------------------------------------------------------------------
380 # 'STANDARD' GNU/960 TARGETS BELOW THIS POINT
382 # 'VERSION' file must be present and contain a string of the form "x.y"
383 #-----------------------------------------------------------------------------
387 echo
"char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > ver960.c
390 # This target should be invoked before building a new release.
391 # 'VERSION' file must be present and contain a string of the form "x.y"
395 MAJ
=`sed 's/\..*//' VERSION` ; \
396 MIN
=`sed 's/.*\.//' VERSION` ; \
397 V
=$$MAJ.
`expr $$MIN + 1` ; \
399 echo
$$V >VERSION
; \
406 # Dummy target to force execution of dependent targets.
410 # Target to uncomment host-specific lines in this makefile. Such lines must
411 # have the following string beginning in column 1: #__<hostname>__#
412 # Original Makefile is backed up as 'Makefile.old'.
414 # Invoke with: make make HOST=xxx
417 -@if
test $(HOST
)x
= x
; then \
418 echo
'\aSpecify "make make HOST=???"'; \
421 grep
-s
"^#The next line was generated by 'make make'" Makefile
; \
422 if
test $$?
= 0 ; then \
423 echo
"\aMakefile has already been processed with 'make make'";\
426 mv
-f Makefile Makefile.old
; \
427 echo
"#The next line was generated by 'make make'" >Makefile
; \
428 echo
"HOST=$(HOST)" >>Makefile
; \
430 sed
"s/^#__$(HOST)__#//" < Makefile.old
>>Makefile
434 Makefile
: $(srcdir)/Makefile.in
$(host_makefile_frag
) $(target_makefile_frag
)
435 $(SHELL
) .
/config.status
437 ### Local Variables: ***
438 ### mode:fundamental ***
439 ### page-delimiter: "^#\f" ***
444 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY