aliguori | 1775918 | 2009-01-21 18:12:52 +0000 | [diff] [blame] | 1 | |
Juan Quintela | 5ab2886 | 2009-10-06 21:11:14 +0200 | [diff] [blame] | 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 | |
Stefan Weil | 7ebf54b | 2009-11-19 20:07:52 +0100 | [diff] [blame] | 14 | # Flags for dependency generation |
Jan Kiszka | a71cd2a | 2010-05-15 13:03:28 +0200 | [diff] [blame] | 15 | QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d |
malc | 02d5467 | 2009-10-11 17:08:57 +0400 | [diff] [blame] | 16 | |
Andreas Färber | 0e8c921 | 2010-01-06 20:24:05 +0100 | [diff] [blame] | 17 | %.o: %.c |
Stefan Weil | 7ebf54b | 2009-11-19 20:07:52 +0100 | [diff] [blame] | 18 | $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," CC $(TARGET_DIR)$@") |
aliguori | 1775918 | 2009-01-21 18:12:52 +0000 | [diff] [blame] | 19 | |
| 20 | %.o: %.S |
Stefan Weil | 7ebf54b | 2009-11-19 20:07:52 +0100 | [diff] [blame] | 21 | $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," AS $(TARGET_DIR)$@") |
aliguori | 1775918 | 2009-01-21 18:12:52 +0000 | [diff] [blame] | 22 | |
| 23 | %.o: %.m |
Stefan Weil | 7ebf54b | 2009-11-19 20:07:52 +0100 | [diff] [blame] | 24 | $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," OBJC $(TARGET_DIR)$@") |
aliguori | 1775918 | 2009-01-21 18:12:52 +0000 | [diff] [blame] | 25 | |
Andreas Färber | 0e8c921 | 2010-01-06 20:24:05 +0100 | [diff] [blame] | 26 | LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(LIBS)," LINK $(TARGET_DIR)$@") |
aliguori | 3aa892d | 2009-01-21 18:13:02 +0000 | [diff] [blame] | 27 | |
| 28 | %$(EXESUF): %.o |
Anthony Liguori | 0bfe3ca | 2009-05-14 19:29:53 +0100 | [diff] [blame] | 29 | $(call LINK,$^) |
aliguori | 4f188f8 | 2009-01-21 18:13:09 +0000 | [diff] [blame] | 30 | |
aliguori | 93a0dba | 2009-01-21 18:13:16 +0000 | [diff] [blame] | 31 | %.a: |
aliguori | 28c699a | 2009-01-26 17:07:46 +0000 | [diff] [blame] | 32 | $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^," AR $(TARGET_DIR)$@") |
aliguori | 93a0dba | 2009-01-21 18:13:16 +0000 | [diff] [blame] | 33 | |
aliguori | 28c699a | 2009-01-26 17:07:46 +0000 | [diff] [blame] | 34 | quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1)) |
Juan Quintela | 70071e1 | 2009-07-21 14:11:18 +0200 | [diff] [blame] | 35 | |
| 36 | # cc-option |
Juan Quintela | 8a2e6ab | 2009-08-31 00:48:45 +0200 | [diff] [blame] | 37 | # Usage: CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0) |
Juan Quintela | 70071e1 | 2009-07-21 14:11:18 +0200 | [diff] [blame] | 38 | |
Thomas Monjalon | fc3baad | 2009-09-11 18:45:40 +0200 | [diff] [blame] | 39 | cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \ |
| 40 | >/dev/null 2>&1 && echo OK), $2, $3) |
Juan Quintela | 1215c6e | 2009-10-07 02:40:58 +0200 | [diff] [blame] | 41 | |
Paolo Bonzini | 59bc10e | 2010-01-04 11:02:28 +0100 | [diff] [blame] | 42 | VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.texi |
Nathan Froyd | 288e7bc | 2010-04-26 14:52:23 -0700 | [diff] [blame] | 43 | set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1))) |
Paolo Bonzini | 076d247 | 2009-12-21 10:06:55 +0100 | [diff] [blame] | 44 | |
Paolo Bonzini | 2b2e59e | 2010-10-21 10:18:40 +0200 | [diff] [blame] | 45 | # 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. |
| 50 | find-in-path = $(if $(find-string /, $1), \ |
| 51 | $(wildcard $1), \ |
| 52 | $(wildcard $(patsubst %, %/$1, $(subst :, ,$(PATH))))) |
| 53 | |
Juan Quintela | 1215c6e | 2009-10-07 02:40:58 +0200 | [diff] [blame] | 54 | # Generate timestamp files for .h include files |
| 55 | |
| 56 | %.h: %.h-timestamp |
| 57 | @test -f $@ || cp $< $@ |
| 58 | |
| 59 | %.h-timestamp: %.mak |
malc | 3e65aaf | 2009-11-14 23:32:10 +0300 | [diff] [blame] | 60 | $(call quiet-command, sh $(SRC_PATH)/create_config < $< > $@, " GEN $*.h") |
Juan Quintela | 1215c6e | 2009-10-07 02:40:58 +0200 | [diff] [blame] | 61 | @cmp $@ $*.h >/dev/null 2>&1 || cp $@ $*.h |
Michael S. Tsirkin | 7dbbbb0 | 2009-12-07 21:04:52 +0200 | [diff] [blame] | 62 | |
| 63 | # will delete the target of a rule if commands exit with a nonzero exit status |
| 64 | .DELETE_ON_ERROR: |