blob: dcf13fa192e733e960af74b04ef8fadc4d2dbdee [file] [log] [blame]
nethercote4388a402004-09-01 23:20:49 +00001include $(top_srcdir)/Makefile.all.am
2include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
njn25e49d8e72002-09-23 09:36:25 +00003
tom5598ef92005-08-20 16:26:04 +00004.PHONY: @VEX_DIR@/libvex.a
5
njn2521d322005-05-08 14:45:13 +00006MODULES = \
njn2521d322005-05-08 14:45:13 +00007 m_aspacemgr \
njnea27e462005-05-31 02:38:09 +00008 m_debuginfo \
njn36b66df2005-05-12 05:13:04 +00009 m_demangle \
10 m_dispatch \
njn717cde52005-05-10 02:47:21 +000011 m_replacemalloc \
njn278b3d62005-05-30 23:20:51 +000012 m_scheduler \
njn2521d322005-05-08 14:45:13 +000013 m_sigframe \
njn8a4eeaf2005-06-17 22:27:21 +000014 m_syswrap
njn2521d322005-05-08 14:45:13 +000015
njna5f1bcd2004-11-27 16:47:42 +000016## When building, we are only interested in the current arch/OS/platform.
17## But when doing 'make dist', we are interested in every arch/OS/platform.
18## That's what DIST_SUBDIRS specifies.
njn68980862005-06-18 18:31:26 +000019SUBDIRS = $(MODULES) .
sewardj985fabb2005-04-24 14:18:14 +000020
njn68980862005-06-18 18:31:26 +000021DIST_SUBDIRS = $(MODULES) .
sewardjde4a1d02002-03-22 01:27:54 +000022
njn44e13682005-05-10 04:56:56 +000023AM_CPPFLAGS += -DVG_LIBDIR="\"$(valdir)"\" \
sewardjbc7df202005-05-02 10:25:34 +000024 -DKICKSTART_BASE=@KICKSTART_BASE@
25
gobry3b777892002-04-04 09:18:39 +000026default.supp: $(SUPP_FILES)
sewardjde4a1d02002-03-22 01:27:54 +000027
fitzhardinge98abfc72003-12-16 02:05:15 +000028bin_PROGRAMS = \
29 valgrind
30
njn25e49d8e72002-09-23 09:36:25 +000031val_PROGRAMS = \
nethercote5f2ad772004-09-01 11:33:35 +000032 stage2 \
njn16eeb4e2005-06-16 03:56:58 +000033 vg_preload_core.so
njn25cac76cb2002-09-23 11:21:57 +000034
nethercote799fb802004-10-20 18:40:40 +000035noinst_HEADERS = \
njn12771092005-06-18 02:18:04 +000036 coregrind.h \
njn2521d322005-05-08 14:45:13 +000037 pub_core_aspacemgr.h \
njnc7561b92005-06-19 01:24:32 +000038 pub_core_basics.h \
njn68980862005-06-18 18:31:26 +000039 pub_core_cpuid.h \
njnea27e462005-05-31 02:38:09 +000040 pub_core_debuginfo.h \
njn75b65aa2005-06-19 19:25:44 +000041 pub_core_debugger.h \
njn2521d322005-05-08 14:45:13 +000042 pub_core_debuglog.h \
njn44e13682005-05-10 04:56:56 +000043 pub_core_demangle.h \
njn36b66df2005-05-12 05:13:04 +000044 pub_core_dispatch.h \
njna733b5f2005-05-12 13:15:38 +000045 pub_core_dispatch_asm.h \
njnd2b17112005-04-19 04:10:25 +000046 pub_core_errormgr.h \
njnd01fef72005-03-25 23:35:48 +000047 pub_core_execontext.h \
njn81c00df2005-05-14 21:28:43 +000048 pub_core_hashtable.h \
njn97405b22005-06-02 03:39:33 +000049 pub_core_libcbase.h \
njn132bfcc2005-06-04 19:16:06 +000050 pub_core_libcassert.h \
njneb8896b2005-06-04 20:03:55 +000051 pub_core_libcfile.h \
njne9befc62005-06-11 15:51:30 +000052 pub_core_libcmman.h \
njn36a20fa2005-06-03 03:08:39 +000053 pub_core_libcprint.h \
njnf39e9a32005-06-12 02:43:17 +000054 pub_core_libcproc.h \
njnde62cbf2005-06-10 22:08:14 +000055 pub_core_libcsignal.h \
njnf536bbb2005-06-13 04:21:38 +000056 pub_core_machine.h \
njn04e16982005-05-31 00:23:43 +000057 pub_core_main.h \
njn717cde52005-05-10 02:47:21 +000058 pub_core_mallocfree.h \
njn20242342005-05-16 23:31:24 +000059 pub_core_options.h \
njne1b2b962005-08-14 22:13:00 +000060 pub_core_oset.h \
njn31513b42005-06-01 03:09:59 +000061 pub_core_profile.h \
njn984a6362005-06-11 01:07:00 +000062 pub_core_pthreadmodel.h \
njnd1af0032005-05-29 17:01:48 +000063 pub_core_redir.h \
njn717cde52005-05-10 02:47:21 +000064 pub_core_replacemalloc.h\
njn278b3d62005-05-30 23:20:51 +000065 pub_core_scheduler.h \
sewardj1cf558c2005-04-25 01:36:56 +000066 pub_core_sigframe.h \
njn0c246472005-05-31 01:00:08 +000067 pub_core_signals.h \
njn641d5cc2005-05-12 04:37:27 +000068 pub_core_skiplist.h \
njn945ed2e2005-06-24 03:28:30 +000069 pub_core_stacks.h \
njn2521d322005-05-08 14:45:13 +000070 pub_core_stacktrace.h \
njnc7e10712005-06-24 13:45:56 +000071 pub_core_syscall.h \
njnc1b01812005-06-17 22:19:06 +000072 pub_core_syswrap.h \
njn984a6362005-06-11 01:07:00 +000073 pub_core_threadmodel.h \
njnc7561b92005-06-19 01:24:32 +000074 pub_core_threadstate.h \
njn43b9a8a2005-05-10 04:37:01 +000075 pub_core_tooliface.h \
njna7598f62005-06-18 03:27:58 +000076 pub_core_trampoline.h \
njncf443512005-05-13 23:14:40 +000077 pub_core_translate.h \
njn8bddf582005-05-13 23:40:55 +000078 pub_core_transtab.h \
njn2e8f4ef2005-05-14 21:44:20 +000079 pub_core_transtab_asm.h \
njn08a2e172005-06-21 22:47:54 +000080 pub_core_ume.h \
njn31ebb9a2005-05-29 23:30:48 +000081 vki_unistd.h \
82 vki_unistd-amd64-linux.h\
cerion85665ca2005-06-20 15:51:07 +000083 vki_unistd-ppc32-linux.h\
njn31ebb9a2005-05-29 23:30:48 +000084 vki_unistd-x86-linux.h
nethercote799fb802004-10-20 18:40:40 +000085
njn4986dbf2005-06-18 16:41:30 +000086BUILT_SOURCES = stage2.lds
87CLEANFILES = stage2.lds
sewardj85a9dca2005-07-26 10:42:57 +000088
fitzhardinge98abfc72003-12-16 02:05:15 +000089valgrind_SOURCES = \
nethercote107e1c02004-10-13 17:55:31 +000090 stage1.c \
njn08a2e172005-06-21 22:47:54 +000091 m_debuglog.c \
92 m_ume.c
fitzhardinge98abfc72003-12-16 02:05:15 +000093valgrind_DEPENDENCIES =
nethercotec25c4492004-10-18 11:52:17 +000094valgrind_LDFLAGS=-static -g
fitzhardinge98abfc72003-12-16 02:05:15 +000095valgrind_LDADD=
sewardjde4a1d02002-03-22 01:27:54 +000096
fitzhardinge98abfc72003-12-16 02:05:15 +000097stage2_SOURCES = \
njn68980862005-06-18 18:31:26 +000098 m_cpuid.S \
njn75b65aa2005-06-19 19:25:44 +000099 m_debugger.c \
njn43b9a8a2005-05-10 04:37:01 +0000100 m_debuglog.c \
sewardj267100d2005-04-24 12:33:12 +0000101 m_errormgr.c \
102 m_execontext.c \
njn81c00df2005-05-14 21:28:43 +0000103 m_hashtable.c \
njn97405b22005-06-02 03:39:33 +0000104 m_libcbase.c \
njn132bfcc2005-06-04 19:16:06 +0000105 m_libcassert.c \
njneb8896b2005-06-04 20:03:55 +0000106 m_libcfile.c \
njne9befc62005-06-11 15:51:30 +0000107 m_libcmman.c \
njn36a20fa2005-06-03 03:08:39 +0000108 m_libcprint.c \
njnf39e9a32005-06-12 02:43:17 +0000109 m_libcproc.c \
njnde62cbf2005-06-10 22:08:14 +0000110 m_libcsignal.c \
njnf536bbb2005-06-13 04:21:38 +0000111 m_machine.c \
njn04e16982005-05-31 00:23:43 +0000112 m_main.c \
njn717cde52005-05-10 02:47:21 +0000113 m_mallocfree.c \
njn20242342005-05-16 23:31:24 +0000114 m_options.c \
njne1b2b962005-08-14 22:13:00 +0000115 m_oset.c \
njn31513b42005-06-01 03:09:59 +0000116 m_profile.c \
njn984a6362005-06-11 01:07:00 +0000117 m_pthreadmodel.c \
njnd1af0032005-05-29 17:01:48 +0000118 m_redir.c \
njn0c246472005-05-31 01:00:08 +0000119 m_signals.c \
njn641d5cc2005-05-12 04:37:27 +0000120 m_skiplist.c \
njn945ed2e2005-06-24 03:28:30 +0000121 m_stacks.c \
sewardj267100d2005-04-24 12:33:12 +0000122 m_stacktrace.c \
njn9abd6082005-06-17 21:31:45 +0000123 m_syscall.c \
njn984a6362005-06-11 01:07:00 +0000124 m_threadmodel.c \
njnc7561b92005-06-19 01:24:32 +0000125 m_threadstate.c \
njn43b9a8a2005-05-10 04:37:01 +0000126 m_tooliface.c \
njna7598f62005-06-18 03:27:58 +0000127 m_trampoline.S \
njn3cbfbc12005-05-13 23:11:40 +0000128 m_translate.c \
njn8bddf582005-05-13 23:40:55 +0000129 m_transtab.c \
njn08a2e172005-06-21 22:47:54 +0000130 m_ume.c
nethercoteb77dee62004-11-16 17:13:24 +0000131
njn278b3d62005-05-30 23:20:51 +0000132## Nb: libscheduler.a must precede libdispatch.a in this list.
nethercoteb77dee62004-11-16 17:13:24 +0000133stage2_extra= \
njnea27e462005-05-31 02:38:09 +0000134 m_debuginfo/libdebuginfo.a \
135 m_demangle/libdemangle.a \
njn278b3d62005-05-30 23:20:51 +0000136 m_scheduler/libscheduler.a \
njn36b66df2005-05-12 05:13:04 +0000137 m_dispatch/libdispatch.a \
sewardj55f9d1a2005-04-25 11:11:44 +0000138 m_aspacemgr/libaspacemgr.a \
njn2521d322005-05-08 14:45:13 +0000139 m_sigframe/libsigframe.a \
njn8a4eeaf2005-06-17 22:27:21 +0000140 m_syswrap/libsyswrap.a \
sewardj8b635a42004-11-22 19:01:47 +0000141 @VEX_DIR@/libvex.a
nethercoteb77dee62004-11-16 17:13:24 +0000142
njn717cde52005-05-10 02:47:21 +0000143## These ones must be linked in with the --whole-archive flag, because they
njndddc8282005-07-19 00:40:16 +0000144## wouldn't get pulled into stage2 otherwise (because they contain symbols
njn717cde52005-05-10 02:47:21 +0000145## only referred to by tool shared objects).
146stage2_extra2 = \
147 m_replacemalloc/libreplacemalloc_core.a
tom78604412005-05-17 16:11:40 +0000148
njn717cde52005-05-10 02:47:21 +0000149## Nb: older versions of automake don't seem to like having += within an
150## if-then-else, so we have to use these variables for the common parts.
151st2_DEPS_common = \
njn717cde52005-05-10 02:47:21 +0000152 $(stage2_extra) \
153 $(stage2_extra2)
154
155st2_LDFLAGS_common = \
njndddc8282005-07-19 00:40:16 +0000156 -Wl,--export-dynamic -g \
157 -Wl,--whole-archive $(stage2_extra2) -Wl,--no-whole-archive
njn717cde52005-05-10 02:47:21 +0000158
nethercotef8fbaaa2004-10-25 17:59:43 +0000159if USE_PIE
njn717cde52005-05-10 02:47:21 +0000160stage2_DEPENDENCIES = $(st2_DEPS_common)
161stage2_LDFLAGS = \
162 $(st2_LDFLAGS_common) \
nethercotec69863e2004-10-25 19:13:41 +0000163 -pie
nethercote7f390022004-10-25 17:18:24 +0000164else
njn4986dbf2005-06-18 16:41:30 +0000165stage2_DEPENDENCIES = $(st2_DEPS_common) stage2.lds
njn717cde52005-05-10 02:47:21 +0000166stage2_LDFLAGS = \
167 $(st2_LDFLAGS_common) \
njn4986dbf2005-06-18 16:41:30 +0000168 -Wl,-defsym,kickstart_base=@KICKSTART_BASE@ -Wl,-T,stage2.lds
nethercote7f390022004-10-25 17:18:24 +0000169endif
nethercotec69863e2004-10-25 19:13:41 +0000170
njn717cde52005-05-10 02:47:21 +0000171stage2_LDADD= $(stage2_extra) \
172 -ldl
sewardjde4a1d02002-03-22 01:27:54 +0000173
njn16eeb4e2005-06-16 03:56:58 +0000174vg_preload_core_so_SOURCES = vg_preloaded.c
175vg_preload_core_so_CFLAGS = $(AM_CFLAGS) -fpic
176vg_preload_core_so_LDADD = -ldl
177vg_preload_core_so_LDFLAGS = \
fitzhardinge98abfc72003-12-16 02:05:15 +0000178 -shared \
njn16eeb4e2005-06-16 03:56:58 +0000179 -Wl,--soname,vg_preload_core.so \
fitzhardinge98abfc72003-12-16 02:05:15 +0000180 -Wl,-z,initfirst
njn3e884182003-04-15 13:03:23 +0000181
njn4986dbf2005-06-18 16:41:30 +0000182# Extract ld's default linker script and hack it to our needs.
njneb0daa32005-06-21 03:30:51 +0000183# First we cut everything above and below the "=====..." lines at the top
184# and bottom.
185# Then we have to replace the load address with "kickstart_base".
186# The line to replace in has one of the following two forms:
187#
188# . = 0x08048000 + SIZEOF_HEADERS;
189#
190# or
191# PROVIDE (__executable_start = 0x08048000); . = 0x08048000 + SIZEOF_HEADERS;
192#
193# So we search for the line with a hex value "+ SIZEOF_HEADERS", and replace
194# all the hex values in that line with "kickstart_base".
njn4986dbf2005-06-18 16:41:30 +0000195stage2.lds: Makefile
tom5496c302005-08-17 08:50:51 +0000196 $(CC) $(AM_CFLAGS) -Wl,--verbose -nostdlib 2>&1 | sed \
njn4986dbf2005-06-18 16:41:30 +0000197 -e '1,/^=====\+$$/d' \
198 -e '/^=====\+$$/d' \
njneb0daa32005-06-21 03:30:51 +0000199 -e '/\. = 0x[0-9A-Fa-f]\+ + SIZEOF_HEADERS/s/0x[0-9A-Fa-f]\+/kickstart_base/g' > $@ \
njn4986dbf2005-06-18 16:41:30 +0000200 || rm -f $@
201
sewardj85a9dca2005-07-26 10:42:57 +0000202@VEX_DIR@/libvex.a: @VEX_DIR@/priv/main/vex_svnversion.h
tom5496c302005-08-17 08:50:51 +0000203 $(MAKE) -C @VEX_DIR@ libvex.a EXTRA_CFLAGS="@ARCH_CORE_AM_CFLAGS@ @PIE_AM_CFLAGS@"
sewardj85a9dca2005-07-26 10:42:57 +0000204
tom5598ef92005-08-20 16:26:04 +0000205@VEX_DIR@/priv/main/vex_svnversion.h: $(wildcard @VEX_DIR@/.svn/entries)
sewardj85a9dca2005-07-26 10:42:57 +0000206 $(MAKE) -C @VEX_DIR@ version
207
208clean-local:
209 $(MAKE) -C @VEX_DIR@ clean
210
sewardjb5f6f512005-03-10 23:59:00 +0000211MANUAL_DEPS = $(noinst_HEADERS) $(include_HEADERS)
sewardj71889e62002-05-10 03:03:57 +0000212
daywalker781132b2003-06-01 20:05:08 +0000213all-local:
fitzhardinge98abfc72003-12-16 02:05:15 +0000214 mkdir -p $(inplacedir)
215 for i in $(val_PROGRAMS); do \
sewardjb5f6f512005-03-10 23:59:00 +0000216 to=$(inplacedir)/$$i; \
fitzhardinge98abfc72003-12-16 02:05:15 +0000217 rm -f $$$to; \
nethercote03b19482004-08-25 11:57:21 +0000218 ln -sf ../$(subdir)/$$i $$to; \
fitzhardinge98abfc72003-12-16 02:05:15 +0000219 done
220