1 2ifeq ($(wildcard config.mak),) 3$(error run ./configure first. See ./configure -h) 4endif 5 6include config.mak 7 8DESTDIR := $(PREFIX)/share/qemu/tests 9 10.PHONY: arch_clean clean distclean cscope 11 12#make sure env CFLAGS variable is not used 13CFLAGS = 14 15libgcc := $(shell $(CC) --print-libgcc-file-name) 16 17libcflat := lib/libcflat.a 18cflatobjs := \ 19 lib/argv.o \ 20 lib/printf.o \ 21 lib/string.o \ 22 lib/abort.o \ 23 lib/report.o 24 25# libfdt paths 26LIBFDT_objdir = lib/libfdt 27LIBFDT_srcdir = lib/libfdt 28LIBFDT_archive = $(LIBFDT_objdir)/libfdt.a 29LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES)) 30LIBFDT_version = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_VERSION)) 31 32#include architecure specific make rules 33include config/config-$(ARCH).mak 34 35# cc-option 36# Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0) 37 38cc-option = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \ 39 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) 40 41CFLAGS += -g 42CFLAGS += $(autodepend-flags) -Wall 43CFLAGS += $(call cc-option, -fomit-frame-pointer, "") 44CFLAGS += $(call cc-option, -fno-stack-protector, "") 45CFLAGS += $(call cc-option, -fno-stack-protector-all, "") 46 47CXXFLAGS += $(CFLAGS) 48 49autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d 50 51LDFLAGS += $(CFLAGS) 52LDFLAGS += -pthread -lrt 53 54$(libcflat): $(cflatobjs) 55 $(AR) rcs $@ $^ 56 57include $(LIBFDT_srcdir)/Makefile.libfdt 58$(LIBFDT_archive): CFLAGS += -ffreestanding -I lib -I lib/libfdt -Wno-sign-compare 59$(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS)) 60 $(AR) rcs $@ $^ 61 62%.o: %.S 63 $(CC) $(CFLAGS) -c -nostdlib -o $@ $< 64 65-include */.*.d */*/.*.d 66 67install: 68 mkdir -p $(DESTDIR) 69 install $(tests_and_config) $(DESTDIR) 70 71clean: arch_clean 72 $(RM) lib/.*.d $(libcflat) $(cflatobjs) 73 74libfdt_clean: 75 $(RM) $(LIBFDT_archive) \ 76 $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS)) \ 77 $(LIBFDT_objdir)/.*.d 78 79distclean: clean libfdt_clean 80 $(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.* 81 82cscope: common_dirs = lib lib/libfdt lib/asm lib/asm-generic 83cscope: 84 $(RM) ./cscope.* 85 find -L $(TEST_DIR) lib/$(TEST_DIR) $(common_dirs) -maxdepth 1 \ 86 -name '*.[chsS]' -print | sed 's,^\./,,' > ./cscope.files 87 cscope -bk 88