1## Process this file with automake to create Makefile.in
2## Configure input file for elfutils.
3##
4## Copyright (C) 1996-2002, 2003, 2004 Red Hat, Inc.
5##
6## This program is Open Source software; you can redistribute it and/or
7## modify it under the terms of the Open Software License version 1.0 as
8## published by the Open Source Initiative.
9##
10## You should have received a copy of the Open Software License along
11## with this program; if not, you may obtain a copy of the Open Software
12## License version 1.0 from http://www.opensource.org/licenses/osl.php or
13## by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
14## 3001 King Ranch Road, Ukiah, CA 95482.
15##
16DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H $(YYDEBUG) \
17       -DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\"
18if MUDFLAP
19AM_CFLAGS = -Wall -Wshadow -std=gnu99 \
20	    $(native_ld_cflags)
21else
22AM_CFLAGS = -Wall -Wshadow -std=gnu99 \
23	    $(if $($(*F)_no_Werror),,-Werror) $(native_ld_cflags)
24endif
25if MUDFLAP
26AM_LDFLAGS = -fmudflap
27endif
28INCLUDES = -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl -I$(srcdir)/../lib -I$(srcdir)/../libdw  -I..
29
30YACC = @YACC@ -d
31AM_YFLAGS = -pld
32AM_LFLAGS = -Pld -olex.yy.c
33## Uncomment to enable debugging of linker script parser
34##YYDEBUG = -DYYDEBUG=1
35
36native_ld = @native_ld@
37base_cpu = @base_cpu@
38
39bin_PROGRAMS = readelf nm size strip ld elflint
40
41
42ld_dsos = libld_elf_i386_pic.a
43if NATIVE_LD
44noinst_LIBRARIES = libld_elf.a
45native_ld_cflags = -DBASE_ELF_NAME=elf_$(base_cpu)
46else
47noinst_LIBRARIES = libld_elf.a $(ld_dsos)
48noinst_PROGRAMS = $(ld_dsos:_pic.a=.so)
49endif
50
51
52ld_SOURCES = ld.c ldgeneric.c ldlex.l ldscript.y symbolhash.c sectionhash.c \
53	     versionhash.c
54
55noinst_HEADERS = ld.h symbolhash.h sectionhash.h versionhash.h \
56		 ldscript.h xelf.h unaligned.h
57
58EXTRA_DIST = elf32-i386.script libld_elf_i386.map $(ld_modules)
59ld_modules = i386_ld.c
60
61if MUDFLAP
62libdw = ../libdw/libdw.a
63libelf = ../libelf/libelf.a
64else
65libdw = ../libdw/libdw.so
66libelf = ../libelf/libelf.so
67endif
68libebl = ../libebl/libebl.a
69libeu = ../lib/libeu.a
70
71readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) -ldl
72nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) -ldl
73size_LDADD = $(libelf) $(libeu)
74strip_LDADD = $(libebl) $(libelf) $(libeu) -ldl
75ld_LDADD = $(libebl) $(libelf) $(libeu) -ldl
76if NATIVE_LD
77ld_LDADD += libld_elf.a
78endif
79ld_LDFLAGS = -rdynamic
80elflint_LDADD  = $(libebl) $(libelf) $(libeu) -ldl
81
82ldlex.o: ldscript.c
83ldlex_no_Werror = yes
84ldscript.h: ldscript.c
85
86# Machine-specific linker code.
87libld_elf_a_SOURCES = $(base_cpu)_ld.c
88
89libld_elf_i386_pic_a_SOURCES =
90am_libld_elf_i386_pic_a_OBJECTS = i386_ld.os
91
92libld_elf_i386_so_SOURCES =
93libld_elf_i386.so: libld_elf_i386_pic.a libld_elf_i386.map
94	$(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
95	      $(libelf) $(libeu) \
96	      -Wl,--version-script,$(srcdir)/libld_elf_i386.map
97
98
99%.os: %.c %.o
100	if $(filter-out -fmudflap,$(COMPILE)) -c -o $@ -fpic -DPIC -DSHARED \
101	  -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
102	  `test -f '$<' || echo '$(srcdir)/'`$<; \
103	then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
104	     rm -f "$(DEPDIR)/$*.Tpo"; \
105	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
106	fi
107
108# Special rule to make it possible to define libld_elf_a_SOURCES as we do.
109# Otherwise make would complain.
110.deps/none_ld.Po: none_ld.os
111	-:
112
113
114installcheck-binPROGRAMS: $(bin_PROGRAMS)
115	bad=0; pid=$$$$; list="$(bin_PROGRAMS)"; for p in $$list; do \
116	  case ' $(AM_INSTALLCHECK_STD_OPTIONS_EXEMPT) ' in \
117	   *" $$p "* | *" $(srcdir)/$$p "*) continue;; \
118	  esac; \
119	  f=`echo "$$p" | \
120	     sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
121	  for opt in --help --version; do \
122	    if LD_LIBRARY_PATH=$(DESTDIR)$(libdir) \
123	       $(DESTDIR)$(bindir)/$$f $$opt > c$${pid}_.out 2> c$${pid}_.err \
124	         && test -n "`cat c$${pid}_.out`" \
125	         && test -z "`cat c$${pid}_.err`"; then :; \
126	    else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \
127	  done; \
128	done; rm -f c$${pid}_.???; exit $$bad
129
130CLEANFILES = none_ld.os $(ld_modules:.c=.os)
131