blob: c30093c116067457d9063fc8bfc1f09594cd1156 [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
Jiri Denemark76dc3cf2011-08-10 12:04:34 +020018 $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," CC $(TARGET_DIR)$@")
aliguori17759182009-01-21 18:12:52 +000019
Alon Levy44dc0ca2011-05-15 11:51:28 +030020ifeq ($(LIBTOOL),)
21%.lo: %.c
22 @echo "missing libtool. please install and rerun configure"; exit 1
23else
24%.lo: %.c
Brad3f534582011-08-13 20:30:14 -040025 $(call quiet-command,$(LIBTOOL) --mode=compile --quiet --tag=CC $(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," lt CC $@")
Alon Levy44dc0ca2011-05-15 11:51:28 +030026endif
27
aliguori17759182009-01-21 18:12:52 +000028%.o: %.S
Jiri Denemark76dc3cf2011-08-10 12:04:34 +020029 $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," AS $(TARGET_DIR)$@")
aliguori17759182009-01-21 18:12:52 +000030
31%.o: %.m
Jiri Denemark76dc3cf2011-08-10 12:04:34 +020032 $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," OBJC $(TARGET_DIR)$@")
aliguori17759182009-01-21 18:12:52 +000033
Stefan Hajnoczie2a99ad2011-08-25 09:18:52 +010034LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(sort $(1)) $(LIBS)," LINK $(TARGET_DIR)$@")
aliguori3aa892d2009-01-21 18:13:02 +000035
36%$(EXESUF): %.o
Anthony Liguori0bfe3ca2009-05-14 19:29:53 +010037 $(call LINK,$^)
aliguori4f188f82009-01-21 18:13:09 +000038
aliguori93a0dba2009-01-21 18:13:16 +000039%.a:
aliguori28c699a2009-01-26 17:07:46 +000040 $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^," AR $(TARGET_DIR)$@")
aliguori93a0dba2009-01-21 18:13:16 +000041
aliguori28c699a2009-01-26 17:07:46 +000042quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))
Juan Quintela70071e12009-07-21 14:11:18 +020043
44# cc-option
Juan Quintela8a2e6ab2009-08-31 00:48:45 +020045# Usage: CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
Juan Quintela70071e12009-07-21 14:11:18 +020046
Thomas Monjalonfc3baad2009-09-11 18:45:40 +020047cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \
48 >/dev/null 2>&1 && echo OK), $2, $3)
Juan Quintela1215c6e2009-10-07 02:40:58 +020049
Paolo Bonzinib93b63f2012-03-28 15:42:01 +020050VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.texi %.sh
Nathan Froyd288e7bc2010-04-26 14:52:23 -070051set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1)))
Paolo Bonzini076d2472009-12-21 10:06:55 +010052
Paolo Bonzini2b2e59e2010-10-21 10:18:40 +020053# find-in-path
54# Usage: $(call find-in-path, prog)
55# Looks in the PATH if the argument contains no slash, else only considers one
56# specific directory. Returns an # empty string if the program doesn't exist
57# there.
58find-in-path = $(if $(find-string /, $1), \
59 $(wildcard $1), \
60 $(wildcard $(patsubst %, %/$1, $(subst :, ,$(PATH)))))
61
Juan Quintela1215c6e2009-10-07 02:40:58 +020062# Generate timestamp files for .h include files
63
64%.h: %.h-timestamp
65 @test -f $@ || cp $< $@
66
67%.h-timestamp: %.mak
Blue Swirl4c3b5a42011-01-20 20:54:21 +000068 $(call quiet-command, sh $(SRC_PATH)/scripts/create_config < $< > $@, " GEN $*.h")
Juan Quintela1215c6e2009-10-07 02:40:58 +020069 @cmp $@ $*.h >/dev/null 2>&1 || cp $@ $*.h
Michael S. Tsirkin7dbbbb02009-12-07 21:04:52 +020070
71# will delete the target of a rule if commands exit with a nonzero exit status
72.DELETE_ON_ERROR: