2013-04-29 Alexander Ivchenko <alexander.ivchenko@intel.com>
[external/binutils.git] / gold / Makefile.am
1 ## Process this file with automake to generate Makefile.in
2 #
3 #  Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
4 #  Free Software Foundation, Inc.
5 #
6 # This file 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 3 of the License, or
9 # (at your option) any later version.
10
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.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; see the file COPYING3.  If not see
18 # <http://www.gnu.org/licenses/>.
19 #
20
21 AUTOMAKE_OPTIONS = foreign
22
23 SUBDIRS = po testsuite
24
25 tooldir = $(exec_prefix)/$(target_alias)
26
27 ACLOCAL_AMFLAGS = -I ../bfd -I ../config
28
29 AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS) $(RANDOM_SEED_CFLAGS)
30 AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CFLAGS) $(RANDOM_SEED_CFLAGS)
31
32 AM_CPPFLAGS = \
33         -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../elfcpp \
34         -DLOCALEDIR="\"$(datadir)/locale\"" \
35         -DBINDIR="\"$(bindir)\"" -DTOOLBINDIR="\"$(tooldir)/bin\"" \
36         -DTOOLLIBDIR="\"$(tooldir)/lib\"" @INCINTL@
37
38 LIBIBERTY = ../libiberty/libiberty.a
39
40 if PLUGINS
41 LIBDL = @DLOPEN_LIBS@
42 endif
43
44 if THREADS
45 THREADSLIB = -lpthread
46 endif
47
48 AM_YFLAGS = -d
49
50 # Automake 1.10+ disables lex and yacc output file regeneration if
51 # maintainer mode is disabled.  Avoid this.
52 am__skiplex =
53 am__skipyacc =
54
55 bin_PROGRAMS = dwp
56
57 noinst_PROGRAMS = ld-new incremental-dump
58 noinst_LIBRARIES = libgold.a
59
60 CCFILES = \
61         archive.cc \
62         attributes.cc \
63         binary.cc \
64         common.cc \
65         compressed_output.cc \
66         copy-relocs.cc \
67         cref.cc \
68         defstd.cc \
69         descriptors.cc \
70         dirsearch.cc \
71         dynobj.cc \
72         dwarf_reader.cc \
73         ehframe.cc \
74         errors.cc \
75         expression.cc \
76         fileread.cc \
77         gc.cc \
78         gdb-index.cc \
79         gold.cc \
80         gold-threads.cc \
81         icf.cc \
82         incremental.cc \
83         int_encoding.cc \
84         layout.cc \
85         mapfile.cc \
86         merge.cc \
87         nacl.cc \
88         object.cc \
89         options.cc \
90         output.cc \
91         parameters.cc \
92         plugin.cc \
93         readsyms.cc \
94         reduced_debug_output.cc \
95         reloc.cc \
96         resolve.cc \
97         script-sections.cc \
98         script.cc \
99         stringpool.cc \
100         symtab.cc \
101         target.cc \
102         target-select.cc \
103         timer.cc \
104         version.cc \
105         workqueue.cc \
106         workqueue-threads.cc
107
108 HFILES = \
109         arm-reloc-property.h \
110         archive.h \
111         attributes.h \
112         binary.h \
113         common.h \
114         compressed_output.h \
115         copy-relocs.h \
116         cref.h \
117         defstd.h \
118         dirsearch.h \
119         descriptors.h \
120         dynobj.h \
121         dwarf_reader.h \
122         ehframe.h \
123         errors.h \
124         fileread.h \
125         freebsd.h \
126         gc.h \
127         gdb-index.h \
128         gold.h \
129         gold-threads.h \
130         icf.h \
131         int_encoding.h \
132         layout.h \
133         mapfile.h \
134         merge.h \
135         nacl.h \
136         object.h \
137         options.h \
138         output.h \
139         parameters.h \
140         plugin.h \
141         readsyms.h \
142         reduced_debug_output.h \
143         reloc.h \
144         reloc-types.h \
145         script-c.h \
146         script-sections.h \
147         script.h \
148         stringpool.h \
149         symtab.h \
150         target.h \
151         target-reloc.h \
152         target-select.h \
153         timer.h \
154         tls.h \
155         token.h \
156         workqueue.h \
157         workqueue-internal.h
158
159 YFILES = \
160         yyscript.y
161
162 DEFFILES = arm-reloc.def
163
164 EXTRA_DIST = yyscript.c yyscript.h
165
166 TARGETSOURCES = \
167         i386.cc x86_64.cc sparc.cc powerpc.cc arm.cc arm-reloc-property.cc tilegx.cc
168
169 ALL_TARGETOBJS = \
170         i386.$(OBJEXT) x86_64.$(OBJEXT) sparc.$(OBJEXT) powerpc.$(OBJEXT) \
171         arm.$(OBJEXT) arm-reloc-property.$(OBJEXT) tilegx.$(OBJEXT)
172
173 libgold_a_SOURCES = $(CCFILES) $(HFILES) $(YFILES) $(DEFFILES)
174 libgold_a_LIBADD = $(LIBOBJS)
175
176 sources_var = main.cc
177 deps_var = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL_DEP)
178 ldadd_var = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) \
179          $(THREADSLIB) $(LIBDL)
180 ldflags_var = $(GOLD_LDFLAGS)
181
182 ld_new_SOURCES = $(sources_var)
183 ld_new_DEPENDENCIES = $(deps_var)
184 ld_new_LDADD = $(ldadd_var)
185 ld_new_LDFLAGS = $(ldflags_var)
186
187 EXTRA_ld_new_SOURCES = $(TARGETSOURCES)
188
189 incremental_dump_SOURCES = incremental-dump.cc
190 incremental_dump_DEPENDENCIES = $(TARGETOBJS) libgold.a $(LIBIBERTY) \
191         $(LIBINTL_DEP)
192 incremental_dump_LDADD = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL) \
193          $(THREADSLIB) $(LIBDL)
194
195 dwp_SOURCES = dwp.cc
196 dwp_DEPENDENCIES = libgold.a $(LIBIBERTY) $(LIBINTL_DEP)
197 dwp_LDADD = libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) $(THREADSLIB) \
198         $(LIBDL)
199 dwp_LDFLAGS = $(GOLD_LDFLAGS)
200
201 # Use an explicit dependency for the bison generated header file.
202 expression.$(OBJEXT): yyscript.h
203 script-sections.$(OBJEXT): yyscript.h
204 script.$(OBJEXT): yyscript.h
205
206 # We have to build libgold.a before we run the tests.
207 check: libgold.a
208
209 .PHONY: install-exec-local
210
211 install-exec-local: ld-new$(EXEEXT)
212         $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(tooldir)/bin
213         n=`echo $(installed_linker) | sed '$(transform)'`; \
214         $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${n}$(EXEEXT); \
215         if test "$(bindir)" != "$(tooldir)/bin"; then \
216           rm -f $(DESTDIR)$(tooldir)/bin/$(installed_linker)$(EXEEXT); \
217           ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$(installed_linker)$(EXEEXT) >/dev/null 2>/dev/null \
218           || $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/$(installed_linker)$(EXEEXT); \
219         fi; \
220         if test "x$(install_as_default)" = "xyes"; then \
221           ld=`echo ld | sed '$(transform)'`; \
222           rm -f $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \
223           ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT) >/dev/null 2>/dev/null \
224           || $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(bindir)/$${ld}$(EXEEXT); \
225           if test "$(bindir)" != "$(tooldir)/bin"; then \
226             rm -f $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
227             ln $(DESTDIR)$(bindir)/$${n}$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT) >/dev/null 2>/dev/null \
228             || $(INSTALL_PROGRAM) ld-new$(EXEEXT) $(DESTDIR)$(tooldir)/bin/ld$(EXEEXT); \
229           fi; \
230         fi
231
232 # We want install to imply install-info as per GNU standards, despite
233 # the cygnus option.
234 install-data-local: install-info
235
236 POTFILES= $(CCFILES) $(HFILES) $(TARGETSOURCES)
237
238 po/POTFILES.in: @MAINT@ Makefile
239         for f in $(POTFILES); do echo $$f; done | LC_ALL=C sort > tmp \
240           && mv tmp $(srcdir)/po/POTFILES.in
241
242 # Bootstrap test support.  We use ld-new to build ld1, then use ld1 to
243 # build ld2.  ld1 and ld2 should be identical.  ld-new need not be
244 # identical to ld1, since it was linked with the host linker.
245
246 if GCC
247 if NATIVE_LINKER
248
249 gcctestdir1/ld: ld-new
250         test -d gcctestdir1 || mkdir -p gcctestdir1
251         rm -f gcctestdir1/ld
252         (cd gcctestdir1 && $(LN_S) ../ld-new ld)
253
254 ld1_SOURCES = $(sources_var)
255 ld1_DEPENDENCIES = $(deps_var) gcctestdir1/ld
256 ld1_LDADD = $(ldadd_var)
257 ld1_LDFLAGS = -Bgcctestdir1/
258
259 gcctestdir2/ld: ld1
260         test -d gcctestdir2 || mkdir -p gcctestdir2
261         rm -f gcctestdir2/ld
262         (cd gcctestdir2 && $(LN_S) ../ld1 ld)
263
264 ld2_SOURCES = $(sources_var)
265 ld2_DEPENDENCIES = $(deps_var) gcctestdir2/ld
266 ld2_LDADD = $(ldadd_var)
267 ld2_LDFLAGS = -Bgcctestdir2/
268
269 bootstrap-test: ld2
270         rm -f $@
271         echo "#!/bin/sh" > $@
272         echo "cmp ld1 ld2" >> $@
273         chmod +x $@
274
275 libgold-1-r.o: gcctestdir1/ld libgold.a
276         gcctestdir1/ld -o $@ -r --whole-archive libgold.a
277
278 ld1_r_SOURCES = $(sources_var)
279 ld1_r_DEPENDENCIES = libgold-1-r.o $(deps_var) gcctestdir1/ld
280 ld1_r_LDADD = libgold-1-r.o $(ldadd_var)
281 ld1_r_LDFLAGS = -Bgcctestdir1/
282
283 gcctestdir2-r/ld: ld1-r
284         test -d gcctestdir2-r || mkdir -p gcctestdir2-r
285         rm -f gcctestdir2-r/ld
286         (cd gcctestdir2-r && $(LN_S) ../ld1-r ld)
287
288 libgold-2-r.o: gcctestdir2-r/ld libgold.a
289         gcctestdir2-r/ld -o $@ -r --whole-archive libgold.a
290
291 ld2_r_SOURCES = $(sources_var)
292 ld2_r_DEPENDENCIES = libgold-2-r.o $(deps_var) gcctestdir2-r/ld
293 ld2_r_LDADD = libgold-2-r.o $(ldadd_var)
294 ld2_r_LDFLAGS = -Bgcctestdir2-r/
295
296 bootstrap-test-r: ld2-r
297         rm -f $@
298         echo "#!/bin/sh" > $@
299         echo "cmp ld1-r ld2-r" >> $@
300         chmod +x $@
301
302 check_PROGRAMS = ld1 ld2 ld1-r ld2-r
303 TESTS = bootstrap-test bootstrap-test-r
304
305 # Verify that changing the number of threads doesn't change the
306 # treehash computation, by building ld1 and ld3 the same way except
307 # for the number of threads.  However, the build ID should change if
308 # we change the chunk size for --build-id=tree, so ld4 should be
309 # different.  We run the latter test even if multithreading is unavailable,
310 # because the treehash can still operate in that mode.
311 check_PROGRAMS += ld4
312 TESTS += bootstrap-test-treehash-chunksize
313
314 gcctestdir3/ld: ld-new
315         test -d gcctestdir3 || mkdir -p gcctestdir3
316         rm -f gcctestdir3/ld
317         (cd gcctestdir3 && $(LN_S) ../ld-new ld)
318
319 ld3_SOURCES = $(sources_var)
320 ld3_DEPENDENCIES = $(deps_var) gcctestdir3/ld
321 ld3_LDADD = $(ldadd_var)
322 ld3_LDFLAGS = -Bgcctestdir3/
323
324 gcctestdir4/ld: ld-new
325         test -d gcctestdir4 || mkdir -p gcctestdir4
326         rm -f gcctestdir4/ld
327         (cd gcctestdir4 && $(LN_S) ../ld-new ld)
328
329 ld4_SOURCES = $(sources_var)
330 ld4_DEPENDENCIES = $(deps_var) gcctestdir4/ld
331 ld4_LDADD = $(ldadd_var)
332 ld4_LDFLAGS = -Bgcctestdir4/
333
334 ld1_LDFLAGS += -Wl,--build-id=tree -Wl,--build-id-chunk-size-for-treehash=12345 -Wl,--build-id-min-file-size-for-treehash=0
335 ld2_LDFLAGS += -Wl,--build-id=tree -Wl,--build-id-chunk-size-for-treehash=12345 -Wl,--build-id-min-file-size-for-treehash=0
336 ld3_LDFLAGS += -Wl,--build-id=tree -Wl,--build-id-chunk-size-for-treehash=12345 -Wl,--build-id-min-file-size-for-treehash=0
337 ld4_LDFLAGS += -Wl,--build-id=tree -Wl,--build-id-chunk-size-for-treehash=12346 -Wl,--build-id-min-file-size-for-treehash=0
338
339 if THREADS
340
341 ld1_LDFLAGS += -Wl,--thread-count=3
342 ld2_LDFLAGS += -Wl,--thread-count=3
343 ld3_LDFLAGS += -Wl,--thread-count=13
344 ld4_LDFLAGS += -Wl,--thread-count=3
345 check_PROGRAMS += ld3
346 TESTS += bootstrap-test-treehash-chunksize
347
348 bootstrap-test-treehash: ld1 ld3
349         rm -f $@
350         echo "#!/bin/sh" > $@
351         echo "cmp ld1 ld3" >> $@
352         chmod +x $@
353
354 endif
355
356 bootstrap-test-treehash-chunksize: ld1 ld4
357         rm -f $@
358         echo "#!/bin/sh" > $@
359         echo "cmp ld1 ld4 | grep ." >> $@
360         chmod +x $@
361
362 endif
363 endif