cf4875ef06d246c275a57ec6a448e6cf987aa3dc
[platform/upstream/elfutils.git] / src / Makefile.am
1 ## Process this file with automake to create Makefile.in
2 ##
3 ## Copyright (C) 1996-2012 Red Hat, Inc.
4 ## This file is part of elfutils.
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 ## elfutils is distributed in the hope that it will be useful, but
12 ## 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.  If not, see <http://www.gnu.org/licenses/>.
18 ##
19 include $(top_srcdir)/config/eu.am
20 DEFS += $(YYDEBUG) -DDEBUGPRED=@DEBUGPRED@ \
21         -DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\"
22 INCLUDES += -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
23             -I$(srcdir)/../libdw -I$(srcdir)/../libdwfl \
24             -I$(srcdir)/../libasm
25
26 AM_LDFLAGS = -Wl,-rpath-link,../libelf:../libdw
27
28 no_mudflap.os = -fmudflap
29
30 YACC = @YACC@ -d
31 AM_YFLAGS = -pld
32 AM_LFLAGS = -Pld -olex.yy.c
33 ## Uncomment to enable debugging of linker script parser
34 ##YYDEBUG = -DYYDEBUG=1
35
36 native_ld = @native_ld@
37 base_cpu = @base_cpu@
38
39 bin_PROGRAMS = readelf nm size strip ld elflint findtextrel addr2line \
40                elfcmp objdump ranlib strings ar unstrip
41
42
43 ld_dsos = libld_elf_i386_pic.a
44 if NATIVE_LD
45 noinst_LIBRARIES = libld_elf.a libar.a
46 native_ld_cflags = -DBASE_ELF_NAME=elf_$(base_cpu)
47 else
48 noinst_LIBRARIES = libld_elf.a libar.a $(ld_dsos)
49 noinst_PROGRAMS = $(ld_dsos:_pic.a=.so)
50 endif
51 if NEVER
52 # We never build this library but we need to get the dependency files
53 # of all the linker backends that might be used in a non-generic linker.
54 noinst_LIBRARIES += libdummy.a
55 libdummy_a_SOURCES = i386_ld.c
56 endif
57
58
59 ld_SOURCES = ld.c ldgeneric.c ldlex.l ldscript.y symbolhash.c sectionhash.c \
60              versionhash.c
61
62 libar_a_SOURCES = arlib.c arlib2.c arlib-argp.c
63
64 noinst_HEADERS = ld.h symbolhash.h sectionhash.h versionhash.h \
65                  ldscript.h xelf.h unaligned.h
66
67 EXTRA_DIST = elf32-i386.script libld_elf_i386.map $(ld_modules) arlib.h \
68              debugpred.h
69 ld_modules = i386_ld.c
70
71 bin_SCRIPTS = make-debug-archive
72 EXTRA_DIST += make-debug-archive.in
73 CLEANFILES += make-debug-archive
74
75 if BUILD_STATIC
76 libasm = ../libasm/libasm.a
77 libdw = ../libdw/libdw.a $(zip_LIBS) $(libelf) $(libebl) -ldl
78 libelf = ../libelf/libelf.a
79 else
80 libasm = ../libasm/libasm.so
81 libdw = ../libdw/libdw.so
82 libelf = ../libelf/libelf.so
83 endif
84 libebl = ../libebl/libebl.a
85 libeu = ../lib/libeu.a
86
87 if DEMANGLE
88 demanglelib = -lstdc++
89 endif
90
91 nm_no_Wformat = yes
92 size_no_Wformat = yes
93 strings_no_Wformat = yes
94 addr2line_no_Wformat = yes
95 # XXX While the file is not finished, don't warn about this
96 ldgeneric_no_Wunused = yes
97
98 readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
99 nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl \
100            $(demanglelib)
101 size_LDADD = $(libelf) $(libeu) $(libmudflap)
102 strip_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
103 ld_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
104 if NATIVE_LD
105 # -ldl is always needed for libebl.
106 ld_LDADD += libld_elf.a
107 endif
108 ld_LDFLAGS = -rdynamic
109 elflint_LDADD  = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
110 findtextrel_LDADD = $(libdw) $(libelf) $(libmudflap)
111 addr2line_LDADD = $(libdw) $(libelf) $(libmudflap)
112 elfcmp_LDADD = $(libebl) $(libelf) $(libmudflap) -ldl
113 objdump_LDADD  = $(libasm) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
114 ranlib_LDADD = libar.a $(libelf) $(libeu) $(libmudflap)
115 strings_LDADD = $(libelf) $(libeu) $(libmudflap)
116 ar_LDADD = libar.a $(libelf) $(libeu) $(libmudflap)
117 unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(libmudflap) -ldl
118
119 ldlex.o: ldscript.c
120 ldlex_no_Werror = yes
121 ldscript.h: ldscript.c
122
123 if NATIVE_LD
124 # Machine-specific linker code.
125 libld_elf_a_SOURCES := $(base_cpu)_ld.c
126 else
127 libld_elf_i386_pic_a_SOURCES =
128 am_libld_elf_i386_pic_a_OBJECTS = i386_ld.os
129
130 libld_elf_i386_so_SOURCES =
131 libld_elf_i386.so: libld_elf_i386_pic.a libld_elf_i386.map
132         $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
133                 $(libelf) $(libeu) \
134                 -Wl,--version-script,$(srcdir)/libld_elf_i386.map
135         $(textrel_check)
136 endif
137
138 # Special rule to make it possible to define libld_elf_a_SOURCES as we do.
139 # Otherwise make would complain.
140 .deps/none_ld.Po: none_ld.os
141         -:
142
143
144 installcheck-binPROGRAMS: $(bin_PROGRAMS)
145         bad=0; pid=$$$$; list="$(bin_PROGRAMS)"; for p in $$list; do \
146           case ' $(AM_INSTALLCHECK_STD_OPTIONS_EXEMPT) ' in \
147            *" $$p "* | *" $(srcdir)/$$p "*) continue;; \
148           esac; \
149           f=`echo "$$p" | \
150              sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
151           for opt in --help --version; do \
152             if LD_LIBRARY_PATH=$(DESTDIR)$(libdir) \
153                $(DESTDIR)$(bindir)/$$f $$opt > c$${pid}_.out 2> c$${pid}_.err \
154                  && test -n "`cat c$${pid}_.out`" \
155                  && test -z "`cat c$${pid}_.err`"; then :; \
156             else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \
157           done; \
158         done; rm -f c$${pid}_.???; exit $$bad
159
160 CLEANFILES += none_ld.os $(ld_modules:.c=.os) *.gconv
161
162 MAINTAINERCLEANFILES = ldlex.c ldscript.c ldscript.h
163
164
165 make-debug-archive: $(srcdir)/make-debug-archive.in
166         UNSTRIP=$(bindir)/`echo unstrip | sed '$(transform)'`; \
167         AR=$(bindir)/`echo ar | sed '$(transform)'`; \
168         sed -e "s,@UNSTRIP@,$$UNSTRIP,g" -e "s,@AR@,$$AR,g" \
169             -e "s%[@]PACKAGE_NAME[@]%$(PACKAGE_NAME)%g" \
170             -e "s%[@]PACKAGE_VERSION[@]%$(PACKAGE_VERSION)%g" \
171             $(srcdir)/make-debug-archive.in > $@.new
172         chmod +x $@.new
173         mv -f $@.new $@