1e9886aceSAndy Lutomirskiall:
2e9886aceSAndy Lutomirski
3e9886aceSAndy Lutomirskiinclude ../lib.mk
4e9886aceSAndy Lutomirski
5e9886aceSAndy Lutomirski.PHONY: all all_32 all_64 warn_32bit_failure clean
63f705dfdSAndy Lutomirski
70a15584dSAndy LutomirskiTARGETS_C_BOTHBITS := sigreturn single_step_syscall
83f705dfdSAndy Lutomirski
93f705dfdSAndy LutomirskiBINARIES_32 := $(TARGETS_C_BOTHBITS:%=%_32)
103f705dfdSAndy LutomirskiBINARIES_64 := $(TARGETS_C_BOTHBITS:%=%_64)
113f705dfdSAndy Lutomirski
123f705dfdSAndy LutomirskiCFLAGS := -O2 -g -std=gnu99 -pthread -Wall
133f705dfdSAndy Lutomirski
14f9ea4a33STyler BakerUNAME_M := $(shell uname -m)
15e9886aceSAndy LutomirskiCAN_BUILD_I386 := $(shell ./check_cc.sh $(CC) trivial_32bit_program.c -m32)
16e9886aceSAndy LutomirskiCAN_BUILD_X86_64 := $(shell ./check_cc.sh $(CC) trivial_64bit_program.c)
173f705dfdSAndy Lutomirski
18e9886aceSAndy Lutomirskiifeq ($(CAN_BUILD_I386),1)
193f705dfdSAndy Lutomirskiall: all_32
20c1e6e5cbSAndy LutomirskiTEST_PROGS += $(BINARIES_32)
21e9886aceSAndy Lutomirskiendif
22e9886aceSAndy Lutomirski
23e9886aceSAndy Lutomirskiifeq ($(CAN_BUILD_X86_64),1)
243f705dfdSAndy Lutomirskiall: all_64
2507620abeSTyler BakerTEST_PROGS += $(BINARIES_64)
263f705dfdSAndy Lutomirskiendif
273f705dfdSAndy Lutomirski
28e9886aceSAndy Lutomirskiall_32: $(BINARIES_32)
293f705dfdSAndy Lutomirski
303f705dfdSAndy Lutomirskiall_64: $(BINARIES_64)
313f705dfdSAndy Lutomirski
323f705dfdSAndy Lutomirskiclean:
333f705dfdSAndy Lutomirski	$(RM) $(BINARIES_32) $(BINARIES_64)
343f705dfdSAndy Lutomirski
353f705dfdSAndy Lutomirski$(TARGETS_C_BOTHBITS:%=%_32): %_32: %.c
363f705dfdSAndy Lutomirski	$(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl
373f705dfdSAndy Lutomirski
383f705dfdSAndy Lutomirski$(TARGETS_C_BOTHBITS:%=%_64): %_64: %.c
393f705dfdSAndy Lutomirski	$(CC) -m64 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl
403f705dfdSAndy Lutomirski
41e9886aceSAndy Lutomirski# x86_64 users should be encouraged to install 32-bit libraries
42e9886aceSAndy Lutomirskiifeq ($(CAN_BUILD_I386)$(CAN_BUILD_X86_64),01)
43e9886aceSAndy Lutomirskiall: warn_32bit_failure
44e9886aceSAndy Lutomirski
45e9886aceSAndy Lutomirskiwarn_32bit_failure:
46e9886aceSAndy Lutomirski	@echo "Warning: you seem to have a broken 32-bit build" 2>&1; 	\
47e9886aceSAndy Lutomirski	echo "environment.  This will reduce test coverage of 64-bit" 2>&1; \
48e9886aceSAndy Lutomirski	echo "kernels.  If you are using a Debian-like distribution," 2>&1; \
49e9886aceSAndy Lutomirski	echo "try:"; 2>&1; \
503f705dfdSAndy Lutomirski	echo "";							\
513f705dfdSAndy Lutomirski	echo "  apt-get install gcc-multilib libc6-i386 libc6-dev-i386"; \
523f705dfdSAndy Lutomirski	echo "";							\
533f705dfdSAndy Lutomirski	echo "If you are using a Fedora-like distribution, try:";	\
543f705dfdSAndy Lutomirski	echo "";							\
553f705dfdSAndy Lutomirski	echo "  yum install glibc-devel.*i686";				\
56e9886aceSAndy Lutomirski	exit 0;
57e9886aceSAndy Lutomirskiendif
58