1 2 # Don't use implicit rules or variables 3 # we have explicit rules for everything 4 MAKEFLAGS += -rR 5 6 # Files with this suffixes are final, don't try to generate them 7 # using implicit rules 8 %.d: 9 %.h: 10 %.c: 11 %.m: 12 %.mak: 13 14 # Flags for dependency generation 15 QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d 16 17 %.o: %.c 18 $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," CC $(TARGET_DIR)$@") 19 20 %.o: %.S 21 $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," AS $(TARGET_DIR)$@") 22 23 %.o: %.m 24 $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," OBJC $(TARGET_DIR)$@") 25 26 LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(LIBS)," LINK $(TARGET_DIR)$@") 27 28 CTFMERGE = $(call quiet-command, $$(which ctfmerge) -L VERSION -o $@ $(1)," CTFMERGE $(TARGET_DIR)$@") 29 30 ifeq ($(TRACE_BACKEND),dtrace) 31 ifneq ($(strip $(CONFIG_SOLARIS)),) 32 %$(EXESUF): %.o 33 $(call quiet-command, dtrace $(CONFIG_DTRACE_FLAGS) -o trace-dtrace.o -s trace-dtrace.dtrace -G $^," LINK $(TARGET_DIR)$@.dtrace") 34 $(call LINK,$^ trace-dtrace.o) 35 else 36 %$(EXESUF): %.o 37 $(call LINK,$^) 38 endif 39 else 40 %$(EXESUF): %.o 41 $(call LINK,$^) 42 endif 43 44 %.a: 45 $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^," AR $(TARGET_DIR)$@") 46 47 quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1)) 48 49 # cc-option 50 # Usage: CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0) 51 52 cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \ 53 >/dev/null 2>&1 && echo OK), $2, $3) 54 55 VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.texi 56 set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1))) 57 58 # find-in-path 59 # Usage: $(call find-in-path, prog) 60 # Looks in the PATH if the argument contains no slash, else only considers one 61 # specific directory. Returns an # empty string if the program doesn't exist 62 # there. 63 find-in-path = $(if $(find-string /, $1), \ 64 $(wildcard $1), \ 65 $(wildcard $(patsubst %, %/$1, $(subst :, ,$(PATH))))) 66 67 # Generate timestamp files for .h include files 68 69 %.h: %.h-timestamp 70 @test -f $@ || cp $< $@ 71 72 %.h-timestamp: %.mak 73 $(call quiet-command, sh $(SRC_PATH)/scripts/create_config < $< > $@, " GEN $*.h") 74 @cmp $@ $*.h >/dev/null 2>&1 || cp $@ $*.h 75 76 # will delete the target of a rule if commands exit with a nonzero exit status 77 .DELETE_ON_ERROR: