blob: 6dac7773d5de6aa8337061d7f874a83cae37cce1 [file] [log] [blame]
aliguori17759182009-01-21 18:12:52 +00001
Juan Quintela5ab28862009-10-06 21:11:14 +02002# Don't use implicit rules or variables
3# we have explicit rules for everything
4MAKEFLAGS += -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
Stefan Weil7ebf54b2009-11-19 20:07:52 +010014# Flags for dependency generation
Jan Kiszkaa71cd2a2010-05-15 13:03:28 +020015QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
malc02d54672009-10-11 17:08:57 +040016
Andreas Färber0e8c9212010-01-06 20:24:05 +010017%.o: %.c
Stefan Weil7ebf54b2009-11-19 20:07:52 +010018 $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," CC $(TARGET_DIR)$@")
aliguori17759182009-01-21 18:12:52 +000019
20%.o: %.S
Stefan Weil7ebf54b2009-11-19 20:07:52 +010021 $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," AS $(TARGET_DIR)$@")
aliguori17759182009-01-21 18:12:52 +000022
23%.o: %.m
Stefan Weil7ebf54b2009-11-19 20:07:52 +010024 $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," OBJC $(TARGET_DIR)$@")
aliguori17759182009-01-21 18:12:52 +000025
Andreas Färber0e8c9212010-01-06 20:24:05 +010026LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(LIBS)," LINK $(TARGET_DIR)$@")
aliguori3aa892d2009-01-21 18:13:02 +000027
28%$(EXESUF): %.o
Anthony Liguori0bfe3ca2009-05-14 19:29:53 +010029 $(call LINK,$^)
aliguori4f188f82009-01-21 18:13:09 +000030
aliguori93a0dba2009-01-21 18:13:16 +000031%.a:
aliguori28c699a2009-01-26 17:07:46 +000032 $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^," AR $(TARGET_DIR)$@")
aliguori93a0dba2009-01-21 18:13:16 +000033
aliguori28c699a2009-01-26 17:07:46 +000034quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))
Juan Quintela70071e12009-07-21 14:11:18 +020035
36# cc-option
Juan Quintela8a2e6ab2009-08-31 00:48:45 +020037# Usage: CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
Juan Quintela70071e12009-07-21 14:11:18 +020038
Thomas Monjalonfc3baad2009-09-11 18:45:40 +020039cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \
40 >/dev/null 2>&1 && echo OK), $2, $3)
Juan Quintela1215c6e2009-10-07 02:40:58 +020041
Paolo Bonzini59bc10e2010-01-04 11:02:28 +010042VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.texi
Nathan Froyd288e7bc2010-04-26 14:52:23 -070043set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1)))
Paolo Bonzini076d2472009-12-21 10:06:55 +010044
Paolo Bonzini2b2e59e2010-10-21 10:18:40 +020045# find-in-path
46# Usage: $(call find-in-path, prog)
47# Looks in the PATH if the argument contains no slash, else only considers one
48# specific directory. Returns an # empty string if the program doesn't exist
49# there.
50find-in-path = $(if $(find-string /, $1), \
51 $(wildcard $1), \
52 $(wildcard $(patsubst %, %/$1, $(subst :, ,$(PATH)))))
53
Juan Quintela1215c6e2009-10-07 02:40:58 +020054# Generate timestamp files for .h include files
55
56%.h: %.h-timestamp
57 @test -f $@ || cp $< $@
58
59%.h-timestamp: %.mak
malc3e65aaf2009-11-14 23:32:10 +030060 $(call quiet-command, sh $(SRC_PATH)/create_config < $< > $@, " GEN $*.h")
Juan Quintela1215c6e2009-10-07 02:40:58 +020061 @cmp $@ $*.h >/dev/null 2>&1 || cp $@ $*.h
Michael S. Tsirkin7dbbbb02009-12-07 21:04:52 +020062
63# will delete the target of a rule if commands exit with a nonzero exit status
64.DELETE_ON_ERROR: