]>
Commit | Line | Data |
---|---|---|
eb02fd64 RP |
1 | # |
2 | # Makefile for ld version 2 | |
3 | # | |
4 | # $Id$ | |
5 | # | |
6 | ||
7 | srcdir = . | |
8 | ||
8c32cf6e RP |
9 | destdir = /usr/local |
10 | ||
e45bef1e | 11 | version=`$(unsubdir)/../gcc$(subdir)/gcc -dumpversion` |
8c32cf6e RP |
12 | prefix = $(destdir) |
13 | bindir = $(prefix)/bin | |
14 | libdir = $(prefix)/lib | |
15 | libsubdir = $(libdir)/gcc/$(target)/$(version) | |
16 | ||
17 | INSTALL = install -c | |
18 | INSTALL_PROGRAM = $(INSTALL) | |
19 | INSTALL_FILE = $(INSTALL) | |
20 | ||
2ee11735 | 21 | BASEDIR = ../.. |
d6e467b4 | 22 | INCLUDE = $(srcdir)/../include |
2ee11735 | 23 | INCLUDES = -I. -I$(srcdir) -I$(INCLUDE) |
eb02fd64 | 24 | DEBUG = -g |
2ee11735 | 25 | |
e46cdcdd RP |
26 | BISON = bison |
27 | BISONFLAGS = -v | |
28 | ||
e1e5fbfc PB |
29 | SCRIPTS = ldgld68k.sc ldgld.sc \ |
30 | ldlnk960.sc ldlnk960r.sc ldgld960.sc \ | |
58b8383a | 31 | ldm88k.sc ldglda29k.sc news.sc h8300hds.sc |
2ee11735 RP |
32 | |
33 | #### target and host dependent Makefile fragments come in here. | |
34 | ### | |
35 | ||
a37cc0c0 | 36 | CFLAGS = $(INCLUDES) $(DEBUG) $(HDEFINES) $(TDEFINES) $(CDEFINES) |
2ee11735 RP |
37 | LINTFLAGS = $(INCLUDES) $(EXTRA_DEF) |
38 | ||
e1e5fbfc | 39 | .SUFFIXES: .y .x .xr .xu .sc .scu .scr $(SUFFIXES) |
2ee11735 | 40 | |
eb02fd64 RP |
41 | # go directly to ld.new in case this ld isn't capable of |
42 | # linking native object on this host. It can be renamed on | |
43 | # install. | |
e7921bd4 | 44 | LD_PROG = ld.new |
f78e2569 | 45 | |
e1e5fbfc PB |
46 | # A .sc script file is needed for each emulation mode. |
47 | # sed is used to transform this script into two variant forms: | |
48 | # A .scr script is for linking without relocation (-r flag). | |
49 | # A .scu script is like .scr, but *do* create constructors. | |
50 | ||
51 | # A sed pattern to translate .sc to .scu: | |
52 | SED_MAKE_RELOC_WITH_CONSTRUCTORS=\ | |
53 | -e "/If relocating/,/End if relocating/d" \ | |
54 | -e "/=/s/[_a-z.]* *= .*//g" \ | |
55 | -e '/>/s/} *> *[a-z]*/}/' \ | |
56 | -e "/text/s/[.]text .*:/.text :/" \ | |
57 | -e "/data/s/[.]data .*:/.data :/" | |
58 | # A sed pattern to translate .scu to .scr: | |
59 | SED_REMOVE_CONSTRUCTORS= -e /CONSTRUCTORS/d | |
60 | ||
61 | .sc.scu: | |
62 | sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) $< >$*.scu | |
63 | .scu.scr: | |
64 | sed $(SED_REMOVE_CONSTRUCTORS) < $< >$*.scr | |
65 | ||
66 | # Each .sc .scr or .scu script is filtered by mkscript | |
67 | # into a string literal that can be included in a .c program. | |
30104b16 | 68 | .sc.x: |
e1e5fbfc PB |
69 | ./mkscript < $< >$*.x |
70 | .scu.xu: | |
71 | ./mkscript < $< >$*.xu | |
72 | .scr.xr: | |
73 | ./mkscript < $< >$*.xr | |
74 | .sc.xu: | |
75 | sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) < $< | ./mkscript >$*.xu | |
76 | .sc.xr: | |
77 | sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) $(SED_REMOVE_CONSTRUCTORS) \ | |
78 | < $< | ./mkscript >$*.xr | |
eb02fd64 RP |
79 | |
80 | # for self hosting | |
e45bef1e RP |
81 | BFDLIB=$(unsubdir)/../bfd$(subdir)/libbfd.a |
82 | LIBIBERTY=$(unsubdir)/../libiberty$(subdir)/libiberty.a | |
eb02fd64 | 83 | |
c252bac8 | 84 | OFILES= ldgram.o ldlex.o ldlang.o ldmain.o ldwarn.o ldwrite.o ldexp.o ldlnk960.o ldgld68k.o ldindr.o \ |
58b8383a | 85 | ldm88k.o ldglda29k.o news.o h8300hds.o \ |
239d28f3 | 86 | ldgld.o ldgld960.o ldemul.o ldver.o ldmisc.o ldsym.o ldvanilla.o ldfile.o |
eb02fd64 | 87 | |
c252bac8 | 88 | HEADERS=config.h ldmain.h ldmain.h ldwarn.h ldmisc.h ldindr.h ldsym.h ldlang.h ldexp.h \ |
239d28f3 | 89 | ldlex.h ldwrite.h ldver.h ldemul.h ldfile.h ldgram.h ld.h |
eb02fd64 RP |
90 | |
91 | MANSOURCES=ld.tex | |
92 | ||
c252bac8 | 93 | LDCSOURCES=ldlang.c ldindr.c ldmain.c ldwrite.c ldwarn.c ldlnk960.c ldgld.c ldgld68k.c \ |
1baac72e | 94 | ldm88k.c ldgld29k.c \ |
239d28f3 | 95 | ldgld960.c ldemul.c ldver.c ldmisc.c ldexp.c ldsym.c ldfile.c ldvanilla.c |
eb02fd64 | 96 | |
cc964c6f SC |
97 | GENERATED_SOURCES=ldgram.c ldlex.c ldgram.h |
98 | GENERATED_HEADERS=ldgram.h | |
eb02fd64 | 99 | |
cc964c6f | 100 | LDSOURCES=$(LDCSOURCES) ldgram.y ldlex.l ldgram.h |
eb02fd64 | 101 | |
2ee11735 | 102 | BFDSOURCES=../../bfd/common/*.c |
eb02fd64 RP |
103 | |
104 | SOURCES= $(LDSOURCES) $(BFDSOURCES) | |
105 | LINTSOURCES= $(LDCSOURCES) $(BFDSOURCES) $(GENERATED_SOURCES) | |
106 | ||
e1e5fbfc | 107 | STAGESTUFF = *.x *.x[ru] *.sc[ru] $(GENERATED_SOURCES) $(GENERATED_HEADERS) $(OFILES) $(LD_PROG) mkscript |
2ee11735 | 108 | |
e1e5fbfc | 109 | all: Makefile $(LD_PROG) |
2ee11735 | 110 | |
4976e6ab | 111 | ldgram.h ldgram.c: ldgram.y |
e46cdcdd | 112 | $(BISON) $(BISONFLAGS) -d $(VPATH)/ldgram.y -o ldgram.c |
3e0f5f4f PB |
113 | # These are in case BISON is really yacc (which ignores -o). |
114 | if [ -f y.tab.c -a ! -f ldgram.c ]; then mv y.tab.c ldgram.c; fi | |
115 | if [ -f y.tab.h -a ! -f ldgram.h ]; then mv y.tab.h ldgram.h; fi | |
cc964c6f | 116 | |
4976e6ab | 117 | ldlex.c: ldlex.l |
cc964c6f SC |
118 | lex -t $(VPATH)/ldlex.l >ldlex.c |
119 | ||
19b03b7a | 120 | |
e1e5fbfc PB |
121 | ldgld.c: ldtemplate |
122 | sed -e s/"<ldtarget>"/ldgld/g -e s/"<arch>"/m68k/g \ | |
5784123f | 123 | -e s/"<target>"//g -e s/"<TARGET>"//g < ldtemplate > ldgld.c |
e1e5fbfc PB |
124 | news.c: ldtemplate |
125 | sed -e s/"<ldtarget>"/news/g -e s/"<arch>"/m68k/g \ | |
5784123f | 126 | -e s/"<target>"/news/g -e s/"<TARGET>"/NEWS/g < ldtemplate > news.c |
e1e5fbfc PB |
127 | ldgld68k.c: ldtemplate |
128 | sed -e s/"<ldtarget>"/ldgld68k/g -e s/"<arch>"/m68k/g \ | |
5784123f | 129 | -e s/"<target>"/68k/g -e s/"<TARGET>"/68K/g < ldtemplate > ldgld68k.c |
e1e5fbfc PB |
130 | ldglda29k.c: ldtemplate |
131 | sed -e s/"<ldtarget>"/ldglda29k/g -e s/"<arch>"/a29k/g \ | |
5784123f | 132 | -e s/"<target>"/29k/g -e s/"<TARGET>"/29K/g < ldtemplate > ldglda29k.c |
e1e5fbfc PB |
133 | ldm88k.c: ldtemplate |
134 | sed -e s/"<ldtarget>"/ldm88k/g -e s/"<arch>"/m88k/g \ | |
5784123f | 135 | -e s/"<target>"/m88kbcs/g -e s/"<TARGET>"/M88KBCS/g < ldtemplate > ldm88k.c |
e1e5fbfc PB |
136 | |
137 | # The .c files for these are generated from ldtemplete. | |
138 | ldgld.o: ./mkscript ldgld.x ldgld.xr ldgld.xu | |
139 | news.o: ./mkscript news.x news.xr news.xu | |
140 | ldgld68k.o: ./mkscript ldgld68k.x ldgld68k.xr ldgld68k.xu | |
141 | ldglda29k.o: ./mkscript ldglda29k.x ldglda29k.xr ldglda29k.xu | |
142 | ldm88k.o: ./mkscript ldm88k.x ldm88k.xr ldm88k.xu | |
143 | ||
144 | # The .c files for these are (for now) specially written (not ldtemplete). | |
145 | ldgld960.o: ./mkscript ldgld960.x | |
146 | ldlnk960.o: ./mkscript ldlnk960.x ldlnk960.xr | |
147 | ||
2ee11735 RP |
148 | |
149 | #$(BFDLIB): $(BFDSOURCES) | |
150 | # (cd ../bfd; make) | |
eb02fd64 | 151 | |
e77463a1 | 152 | $(LD_PROG): $(OFILES) $(BFDLIB) $(LIBIBERTY) |
fe9c20e2 | 153 | $(CC) $(CFLAGS) $(LDFLAGS) -o $(LD_PROG) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(LOADLIBES) |
e7921bd4 | 154 | |
eb02fd64 | 155 | # (cd ../bfd; make) |
239d28f3 | 156 | # 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 |
e77463a1 JG |
157 | # gld -o ld /lib/crt0.o $(OFILES) $(BFDLIB) $(LIBIBERTY) -lc /usr/local/lib/gcc/sparc/1.91/gnulib |
158 | # $(CC) -Bstatic -o ld.new $(OFILES) $(BFDLIB) $(LIBIBERTY) | |
eb02fd64 RP |
159 | |
160 | ||
f78e2569 | 161 | ld1: ld.new |
e77463a1 | 162 | $(HOSTING_EMU); ./ld.new -o ld1 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) |
eb02fd64 RP |
163 | |
164 | ld2: ld1 | |
e77463a1 | 165 | $(HOSTING_EMU); ./ld1 -o ld2 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) |
eb02fd64 RP |
166 | |
167 | ld3: ld2 | |
e77463a1 | 168 | $(HOSTING_EMU); ./ld2 -o ld3 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) |
eb02fd64 RP |
169 | |
170 | ld.dvi:ld.tex | |
171 | tex ld.tex | |
172 | ||
e0220a5b | 173 | mkscript: $(srcdir)/mkscript.c |
30104b16 | 174 | $(CC) $(CFLAGS) $(LDFLAGS) -o mkscript $(srcdir)/mkscript.c $(LOADLIBES) |
f78e2569 | 175 | |
cc964c6f SC |
176 | ldlex.c: ldlex.l ldgram.h |
177 | ldlex.o: ldlex.c ldgram.h | |
178 | ldgram.o: ldgram.c | |
179 | ldgram.c:ldgram.y | |
eb02fd64 | 180 | |
30104b16 SC |
181 | ldgld68k.x :ldgld68k.sc |
182 | ldgld68kUr.x :ldgld68kUr.sc | |
183 | ldgld68kr.x :ldgld68kr.sc | |
184 | ldgld.x :ldgld.sc | |
185 | ldgldUr.x :ldgldUr.sc | |
186 | ldgldr.x :ldgldr.sc | |
187 | ldlnk960.x :ldlnk960.sc | |
188 | ldlnk960r.x :ldlnk960r.sc | |
189 | ldgld960.x :ldgld960.sc | |
1e332873 SC |
190 | ldgldm88k.x :ldgldm88k.sc |
191 | ldm88kUr.x :ldm88kUr.sc | |
192 | ldm88kr.x:ldm88kr.sc | |
30104b16 SC |
193 | ldgld68k.x:ldgld68k.sc |
194 | ldglda29k.x :ldglda29k.sc | |
195 | ldglda29kr.x :ldglda29kr.sc | |
196 | ldglda29kUr.x :ldglda29kUr.sc | |
eb02fd64 | 197 | |
e7921bd4 RP |
198 | stage1: force |
199 | - mkdir stage1 | |
200 | - mv -f $(STAGESTUFF) stage1 | |
201 | - (cd stage1 ; ln -s $(LD_PROG) ld) | |
f78e2569 | 202 | |
e7921bd4 RP |
203 | stage2: force |
204 | - mkdir stage2 | |
205 | - mv -f $(STAGESTUFF) stage2 | |
206 | - (cd stage2 ; ln -s $(LD_PROG) ld) | |
f78e2569 | 207 | |
e7921bd4 RP |
208 | stage3: force |
209 | - mkdir stage3 | |
210 | - mv -f $(STAGESTUFF) stage3 | |
211 | - (cd stage3 ; ln -s $(LD_PROG) ld) | |
eb02fd64 | 212 | |
e46cdcdd RP |
213 | against=stage2 |
214 | ||
215 | comparison: force | |
216 | for i in $(STAGESTUFF) ; do cmp $$i $(against)/$$i ; done | |
217 | ||
e7921bd4 RP |
218 | de-stage1: force |
219 | - (cd stage1 ; mv -f * ..) | |
220 | - rm ld | |
221 | - rmdir stage1 | |
222 | ||
223 | de-stage2: force | |
224 | - (cd stage2 ; mv -f * ..) | |
225 | - rm ld | |
226 | - rmdir stage2 | |
227 | ||
228 | de-stage3: force | |
229 | - (cd stage3 ; mv -f * ..) | |
230 | - rm ld | |
231 | - rmdir stage3 | |
232 | ||
233 | clean: | |
234 | - rm -f TAGS $(OFILES) $(GENERATED_SOURCES) $(GENERATED_HEADERS) | |
e1e5fbfc | 235 | - rm -f *.x *.x[ru] *.sc[ur] |
e7921bd4 | 236 | - rm -f ld ld1 ld2 ld3 ld.new mkscript *.o y.output |
eb02fd64 RP |
237 | |
238 | lintlog:$(SOURCES) Makefile | |
2ee11735 | 239 | $(LINT) -abhxzn $(LINTFLAGS) $(LINTSOURCES) \ |
eb02fd64 RP |
240 | | grep -v "pointer casts may be troublesome" \ |
241 | | grep -v "possible pointer alignment problem" \ | |
242 | | grep -v "ignore" \ | |
243 | | grep -v "conversion from long may lose accuracy" \ | |
244 | | grep -v "warning: constant argument to NOT" \ | |
245 | | grep -v "enumeration type clash, operator CAST" \ | |
246 | | grep -v "warning: constant in conditional context"\ | |
247 | | grep -v "archive\.c" | |
248 | ||
249 | ||
250 | tags TAGS:$(SOURCES) $(HEADERS) | |
19b03b7a | 251 | etags -t $? |
eb02fd64 RP |
252 | |
253 | release: | |
254 | (cd /4/steve/ld; tar cf - $(LDSOURCES) $(HEADERS) $(MANSOURCES)) | tar xf - | |
255 | ||
256 | objdump:objdump.c | |
257 | ||
e7921bd4 | 258 | install: $(LD_PROG) |
8c32cf6e | 259 | $(INSTALL_PROGRAM) ld.new $(libsubdir)/ld |
eb02fd64 RP |
260 | |
261 | #----------------------------------------------------------------------------- | |
262 | # 'STANDARD' GNU/960 TARGETS BELOW THIS POINT | |
263 | # | |
264 | # 'VERSION' file must be present and contain a string of the form "x.y" | |
265 | #----------------------------------------------------------------------------- | |
266 | ||
267 | ver960.c: FORCE | |
268 | rm -f ver960.c | |
269 | echo "char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > ver960.c | |
270 | ||
271 | ||
272 | # This target should be invoked before building a new release. | |
273 | # 'VERSION' file must be present and contain a string of the form "x.y" | |
274 | # | |
275 | roll: | |
276 | @V=`cat VERSION` ; \ | |
277 | MAJ=`sed 's/\..*//' VERSION` ; \ | |
278 | MIN=`sed 's/.*\.//' VERSION` ; \ | |
279 | V=$$MAJ.`expr $$MIN + 1` ; \ | |
280 | rm -f VERSION ; \ | |
281 | echo $$V >VERSION ; \ | |
282 | echo Version $$V | |
283 | ||
239d28f3 | 284 | |
e1e5fbfc | 285 | dep: $(LDSOURCES) |
239d28f3 SC |
286 | mkdep $(CFLAGS) $? |
287 | ||
eb02fd64 RP |
288 | # Dummy target to force execution of dependent targets. |
289 | # | |
e7921bd4 | 290 | force: |
eb02fd64 RP |
291 | |
292 | # Target to uncomment host-specific lines in this makefile. Such lines must | |
293 | # have the following string beginning in column 1: #__<hostname>__# | |
294 | # Original Makefile is backed up as 'Makefile.old'. | |
295 | # | |
296 | # Invoke with: make make HOST=xxx | |
297 | # | |
298 | make: | |
299 | -@if test $(HOST)x = x ; then \ | |
300 | echo '\aSpecify "make make HOST=???"'; \ | |
301 | exit 1; \ | |
302 | fi ; \ | |
303 | grep -s "^#The next line was generated by 'make make'" Makefile; \ | |
304 | if test $$? = 0 ; then \ | |
305 | echo "\aMakefile has already been processed with 'make make'";\ | |
306 | exit 1; \ | |
307 | fi ; \ | |
308 | mv -f Makefile Makefile.old; \ | |
309 | echo "#The next line was generated by 'make make'" >Makefile ; \ | |
310 | echo "HOST=$(HOST)" >>Makefile ; \ | |
311 | echo >>Makefile ; \ | |
312 | sed "s/^#__$(HOST)__#//" < Makefile.old >>Makefile | |
313 | ||
314 | #\f | |
315 | ||
f1eb48b6 | 316 | Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) |
a26878d1 | 317 | $(SHELL) ./config.status |
eb02fd64 RP |
318 | |
319 | ### Local Variables: *** | |
320 | ### mode:fundamental *** | |
321 | ### page-delimiter: "^#\f" *** | |
322 | ### End: *** | |
323 | ### end of file | |
239d28f3 SC |
324 | |
325 | ||
326 | # IF YOU PUT ANYTHING HERE IT WILL GO AWAY |