aboutsummaryrefslogtreecommitdiff
path: root/ld/Makefile.in
blob: 71523b1e8a8caf6f6e0b1622289fc78216f4b336 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
#
# Makefile for ld version 2
#
# $Id$
#

srcdir = .

destdir = /usr/local

version=`$(unsubdir)/../gcc$(subdir)/gcc -dumpversion`
bindir = $(destdir)/H-$(host_alias)/T-$(target_alias)/bin
libdir = $(destdir)/H-$(host_alias)/T-$(target_alias)/lib
libsubdir = $(libdir)/gcc/$(target)/$(version)

# Seach path to override the default search path for -lfoo libraries.
# If LIB_PATH is empty, the ones in the script (if any) are left alone.
# Otherwise, they are replaced with the ones given in LIB_PATH,
# which may have the form: LIB_PATH=/lib:/usr/local/lib
LIB_PATH =

INSTALL = install -c
INSTALL_PROGRAM = $(INSTALL)
INSTALL_FILE = $(INSTALL)

BASEDIR	= ../..
INCLUDE	= $(srcdir)/../include
INCLUDES = -I. -I$(srcdir)  -I$(INCLUDE) 
DEBUG	= -g

# Where to find texinfo.tex to format docn with TeX
TEXIDIR = $(srcdir)/../texinfo/fsf

# Whether to get roff to put indexing entries on stderr
#TEXI2OPT =
# You neeed this to generate ld-index.ms
TEXI2OPT = -i

# Which roff program to use to generate index for texi2roff'd doc
ROFF = groff

BISON = bison
BISONFLAGS = -v

SCRIPTS = ldgld68k.sc ldgld.sc \
	ldlnk960.sc ldlnk960r.sc ldgld960.sc \
	ldm88k.sc ldglda29k.sc news.sc h8300hds.sc ebmon29k.sc

#### target and host dependent Makefile fragments come in here.
###

CFLAGS	= $(INCLUDES) $(DEBUG) $(HDEFINES) $(TDEFINES) $(CDEFINES)
LINTFLAGS =  $(INCLUDES) $(EXTRA_DEF) 

.SUFFIXES: .y .x .xr .xu .xn .sc .scu .scr .scn $(SUFFIXES)

# go directly to ld.new in case this ld isn't capable of
# linking native object on this host.  It can be renamed on
# install.
LD_PROG	= ld.new

# A .sc script file is needed for each emulation mode.
# sed is used to transform this script into two variant forms:
# A .scr script is for linking without relocation (-r flag).
# A .scu script is like .scr, but *do* create constructors.
# A .scu script is for linking to non-demand-paged output (-N or -n).
# The diference is that segments should (need) not be page aligned.

# A sed pattern to translate .sc to .scu:
SED_MAKE_RELOC_WITH_CONSTRUCTORS=\
  -e "/If relocating/,/End if relocating/d" \
  -e "/=/s/[_a-zA-Z.]* *= .*//g" \
  -e '/>/s/} *> *[a-zA-Z]*/}/' \
  -e "/text/s/[.]text .*:/.text :/" \
  -e "/data/s/[.]data .*:/.data :/"
# A sed pattern to translate .scu to .scr:
SED_REMOVE_CONSTRUCTORS= -e /CONSTRUCTORS/d
# A sed pattern to translate .sc to .scn:
# We assume that any reasonable page size ends with 00
# (Some things are aligned on 8-byte boundaries; ignore those.)
SED_DONT_ALIGN= -e '/ALIGN/s/ALIGN( *0x[0-9a-fA-F]*00 *)/./'

.sc.scu:
	sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) $< >$*.scu
.sc.scn:
	sed $(SED_DONT_ALIGN) $< >$*.scn
.scu.scr:
	sed $(SED_REMOVE_CONSTRUCTORS) < $< >$*.scr

# Each .sc .scr .scu or .scn script is filtered by mkscript
# into a string literal that can be included in a .c program.
.sc.x:
	if [ "x"$(LIB_PATH) = "x" ]; then ./mkscript < $< >$*.x ; \
	else \
	  (sed <$< -e '/SEARCH_DIR(.*)/d' ; \
	  echo $(LIB_PATH) | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g';) | ./mkscript >$*.x;\
	fi
#	./mkscript < $< >$*.x 
.scu.xu:
	./mkscript < $< >$*.xu
.scr.xr:
	./mkscript < $< >$*.xr
.scn.xn:
	./mkscript < $< >$*.xn
.sc.xu:
	sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) < $< | ./mkscript >$*.xu
.sc.xr:
	sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) $(SED_REMOVE_CONSTRUCTORS) \
	< $< | ./mkscript >$*.xr
.sc.xn:
	sed $(SED_DONT_ALIGN) < $< | ./mkscript >$*.xn

# for self hosting
BFDLIB=$(unsubdir)/../bfd$(subdir)/libbfd.a
LIBIBERTY=$(unsubdir)/../libiberty$(subdir)/libiberty.a

OFILES= ldgram.o ldlex.o ldlang.o ldmain.o ldwarn.o ldwrite.o ldexp.o ldlnk960.o ldgld68k.o ldindr.o \
	ldm88k.o ldglda29k.o news.o h8300hds.o ebmon29k.o \
	ldgld.o ldgld960.o ldemul.o ldver.o ldmisc.o ldsym.o ldvanilla.o ldfile.o

HEADERS=config.h ldmain.h ldmain.h ldwarn.h ldmisc.h ldindr.h ldsym.h ldlang.h ldexp.h \
	ldlex.h ldwrite.h ldver.h ldemul.h ldfile.h ldgram.h ld.h

MANSOURCES=ld.tex

LDCSOURCES=ldlang.c ldindr.c ldmain.c ldwrite.c ldwarn.c ldlnk960.c ldgld.c ldgld68k.c \
	ldm88k.c ldgld29k.c \
	ldgld960.c ldemul.c ldver.c ldmisc.c ldexp.c ldsym.c ldfile.c ldvanilla.c

GENERATED_SOURCES=ldgram.c ldlex.c ldgram.h 
GENERATED_HEADERS=ldgram.h

LDSOURCES=$(LDCSOURCES) ldgram.y ldlex.l ldgram.h

BFDSOURCES=../../bfd/common/*.c

SOURCES= $(LDSOURCES) $(BFDSOURCES)
LINTSOURCES=   $(LDCSOURCES) $(BFDSOURCES) $(GENERATED_SOURCES)

STAGESTUFF = *.x *.x[ru] *.sc[ru] $(GENERATED_SOURCES) $(GENERATED_HEADERS) $(OFILES) $(LD_PROG) mkscript

all: Makefile $(LD_PROG)

ldgram.h ldgram.c: ldgram.y
	$(BISON) $(BISONFLAGS) -d $(VPATH)/ldgram.y -o ldgram.c
#	These are in case BISON is really yacc (which ignores -o).
	if [ -f y.tab.c -a ! -f ldgram.c ]; then mv y.tab.c ldgram.c; else true ; fi
	if [ -f y.tab.h -a ! -f ldgram.h ]; then mv y.tab.h ldgram.h; else true ; fi

ldlex.c: ldlex.l
	lex -t $(VPATH)/ldlex.l >ldlex.c


ldgld.c: $(srcdir)/ldtemplate
	sed -e s/"<ldtarget>"/ldgld/g -e s/"<arch>"/m68k/g \
	-e s/"<target>"//g -e s/"<TARGET>"//g <$< >$@
news.c: $(srcdir)/ldtemplate
	sed -e s/"<ldtarget>"/news/g -e s/"<arch>"/m68k/g \
	-e s/"<target>"/news/g -e s/"<TARGET>"/NEWS/g <$< >$@

ebmon29k.c: $(srcdir)/ldtemplate
	sed -e s/"<ldtarget>"/ebmon29k/g -e s/"<arch>"/a29k/g \
	-e s/"gld<target>"/ebmon29k/g -e s/"GLD<TARGET>"/EBMON29K/g \
	-e s/"<ldtarget>.x"/ebmon.x/ <$< >$@

ldgld68k.c: $(srcdir)/ldtemplate
	sed -e s/"<ldtarget>"/ldgld68k/g -e s/"<arch>"/m68k/g \
	-e s/"<target>"/68k/g -e s/"<TARGET>"/68K/g <$< >$@
ldglda29k.c: $(srcdir)/ldtemplate
	sed -e s/"<ldtarget>"/ldglda29k/g -e s/"<arch>"/a29k/g \
	-e s/"<target>"/29k/g -e s/"<TARGET>"/29K/g <$< >$@
ldm88k.c: $(srcdir)/ldtemplate
	sed -e s/"<ldtarget>"/ldm88k/g -e s/"<arch>"/m88k/g \
	-e s/"<target>"/m88kbcs/g -e s/"<TARGET>"/M88KBCS/g <$< >$@

# The .c files for these are generated from ldtemplete.
ldgld.o: ./mkscript ldgld.x ldgld.xr ldgld.xu ldgld.xn
news.o: ./mkscript news.x news.xr news.xu news.xn
ebmon29k.o: ./mkscript ebmon29k.x ebmon29k.xr ebmon29k.xu ebmon29k.xn
ldgld68k.o: ./mkscript ldgld68k.x ldgld68k.xr ldgld68k.xu ldgld68k.xn
ldglda29k.o: ./mkscript ldglda29k.x ldglda29k.xr ldglda29k.xu ldglda29k.xn
ldm88k.o: ./mkscript ldm88k.x ldm88k.xr ldm88k.xu ldm88k.xn

# The .c files for these are (for now) specially written (not ldtemplete).
ldgld960.o: ./mkscript ldgld960.x
ldlnk960.o: ./mkscript ldlnk960.x ldlnk960.xr
h8300hds.o: ./mkscript h8300hds.x


#$(BFDLIB): $(BFDSOURCES)
#	(cd ../bfd; make)

$(LD_PROG): $(OFILES) $(BFDLIB) $(LIBIBERTY)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $(LD_PROG) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(LOADLIBES)

#	(cd ../bfd; make)
#	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
#	gld -o ld /lib/crt0.o   $(OFILES) $(BFDLIB) $(LIBIBERTY) -lc /usr/local/lib/gcc/sparc/1.91/gnulib
#	$(CC) -Bstatic -o ld.new $(OFILES) $(BFDLIB) $(LIBIBERTY)


ld1: ld.new
	$(HOSTING_EMU); ./ld.new -o ld1 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS)

ld2: ld1
	$(HOSTING_EMU); ./ld1 -o ld2 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS)

ld3: ld2
	$(HOSTING_EMU); ./ld2 -o ld3 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS)

######################################################################
# DOCUMENTATION TARGETS
# TeX output
ld.dvi: ld.texinfo
	TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex ld.texinfo
	texindex ld.??
	TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex ld.texinfo

# info file for online browsing
ld.info: ld.texinfo
	makeinfo ld.texinfo

# roff output (-ms)
#   edit instances of "ms" to "me" or "mm" to suit your preferences.
#   (we don't use a variable because we don't trust all makes to handle
#   a var in the target name right).
ld.ms: ld.texinfo
	sed -e '/\\input texinfo/d' \
		-e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
		ld.texinfo | \
	texi2roff $(TEXI2OPT) -ms >ld.ms 

# index for roff output
ld-index.ms: ld.ms
	$(ROFF) -ms ld.ms 2>&1 1>/dev/null | \
		sed -e '/: warning:/d' | \
		texi2index >ld-index.ms

######################################################################

mkscript: $(srcdir)/mkscript.c
	$(CC) $(CFLAGS) $(LDFLAGS) -o mkscript $(srcdir)/mkscript.c $(LOADLIBES)

ldlex.c: ldlex.l ldgram.h
ldlex.o: ldlex.c ldgram.h
ldgram.o: ldgram.c
ldgram.c:ldgram.y

ldgld68k.x :ldgld68k.sc 
ldgld68kUr.x :ldgld68kUr.sc 
ldgld68kr.x :ldgld68kr.sc 
h8300hds.x:h8300hds.sc
ldgld.x :ldgld.sc 
ldgldUr.x :ldgldUr.sc 
ldgldr.x :ldgldr.sc 
ldlnk960.x :ldlnk960.sc 
ldlnk960r.x :ldlnk960r.sc 
ldgld960.x :ldgld960.sc 
ldgldm88k.x :ldgldm88k.sc 
ldm88kUr.x :ldm88kUr.sc 
ldm88kr.x:ldm88kr.sc
ldgld68k.x:ldgld68k.sc
ldglda29k.x :ldglda29k.sc 
ldglda29kr.x :ldglda29kr.sc 
ldglda29kUr.x :ldglda29kUr.sc 

ebmon29k.x :ebmon29k.sc 
ebmon29kr.x :ebmon29kr.sc 
ebmon29kUr.x :ebmon29kUr.sc 

stage1:	force
	- mkdir stage1
	- mv -f $(STAGESTUFF) stage1
	- (cd stage1 ; ln -s $(LD_PROG) ld)

stage2:	force
	- mkdir stage2
	- mv -f $(STAGESTUFF) stage2
	- (cd stage2 ; ln -s $(LD_PROG) ld)

stage3:	force
	- mkdir stage3
	- mv -f $(STAGESTUFF) stage3
	- (cd stage3 ; ln -s $(LD_PROG) ld)

against=stage2

comparison: force
	for i in $(STAGESTUFF) ; do cmp $$i $(against)/$$i ; done

de-stage1: force
	- (cd stage1 ; mv -f * ..)
	- rm ld
	- rmdir stage1

de-stage2: force
	- (cd stage2 ; mv -f * ..)
	- rm ld
	- rmdir stage2

de-stage3: force
	- (cd stage3 ; mv -f * ..)
	- rm ld
	- rmdir stage3

clean:
	- rm -f TAGS $(OFILES) $(GENERATED_SOURCES) $(GENERATED_HEADERS)
	- rm -f *.x *.x[ru] *.sc[ur]
	- rm -f ld.?? ld.??? 
	- rm -f ld ld1 ld2 ld3 ld.new mkscript *.o y.output

lintlog:$(SOURCES) Makefile
	$(LINT) -abhxzn  $(LINTFLAGS)  $(LINTSOURCES) \
| grep -v "pointer casts may be troublesome" \
| grep -v "possible pointer alignment problem" \
| grep -v "ignore" \
| grep -v "conversion from long may lose accuracy" \
| grep -v "warning: constant argument to NOT" \
| grep -v "enumeration type clash, operator CAST" \
| grep -v "warning: constant in conditional context"\
| grep -v "archive\.c"


tags TAGS:$(SOURCES) $(HEADERS)
	etags -t $?

release:
	(cd /4/steve/ld; tar cf -  $(LDSOURCES) $(HEADERS) $(MANSOURCES)) | tar xf - 

objdump:objdump.c 

install: $(LD_PROG)
#	$(INSTALL_PROGRAM) ld.new $(libsubdir)/ld
	cp $(LD_PROG) $(bindir)/ld.new
	mv -f $(bindir)/ld.new $(bindir)/ld

#-----------------------------------------------------------------------------
#		'STANDARD' GNU/960 TARGETS BELOW THIS POINT
#
# 'VERSION' file must be present and contain a string of the form "x.y"
#-----------------------------------------------------------------------------

ver960.c: FORCE
	rm -f ver960.c
	echo "char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > ver960.c


# This target should be invoked before building a new release.
# 'VERSION' file must be present and contain a string of the form "x.y"
#
roll:
	@V=`cat VERSION`		; \
	MAJ=`sed 's/\..*//' VERSION`	; \
	MIN=`sed 's/.*\.//' VERSION`	; \
	V=$$MAJ.`expr $$MIN + 1`	; \
	rm -f VERSION			; \
	echo $$V >VERSION		; \
	echo Version $$V


dep: $(LDSOURCES)
	mkdep $(CFLAGS) $?

# Dummy target to force execution of dependent targets.
#
force:

# Target to uncomment host-specific lines in this makefile.  Such lines must
# have the following string beginning in column 1: #__<hostname>__#
# Original Makefile is backed up as 'Makefile.old'.
#
# Invoke with:  make make HOST=xxx
#
make:
	-@if test $(HOST)x = x ; then \
		echo 'Specify "make make HOST=???"'; \
		exit 1; \
	fi ; \
	grep -s "^#The next line was generated by 'make make'" Makefile; \
	if test $$? = 0 ; then	\
		echo "Makefile has already been processed with 'make make'";\
		exit 1; \
	fi ; \
	mv -f Makefile Makefile.old; \
	echo "#The next line was generated by 'make make'"	 >Makefile ; \
	echo "HOST=$(HOST)"					>>Makefile ; \
	echo							>>Makefile ; \
	sed "s/^#__$(HOST)__#//" < Makefile.old			>>Makefile

#

Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)
	$(SHELL) ./config.status

### Local Variables: ***
### mode:fundamental ***
### page-delimiter: "^#" ***
### End: ***
### end of file


# IF YOU PUT ANYTHING HERE IT WILL GO AWAY