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 |
Jiri Denemark | 76dc3cf | 2011-08-10 12:04:34 +0200 | [diff] [blame] | 18 | $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," CC $(TARGET_DIR)$@") |
aliguori | 1775918 | 2009-01-21 18:12:52 +0000 | [diff] [blame] | 19 | |
Alon Levy | 44dc0ca | 2011-05-15 11:51:28 +0300 | [diff] [blame] | 20 | ifeq ($(LIBTOOL),) |
| 21 | %.lo: %.c |
| 22 | @echo "missing libtool. please install and rerun configure"; exit 1 |
| 23 | else |
| 24 | %.lo: %.c |
Brad | 3f53458 | 2011-08-13 20:30:14 -0400 | [diff] [blame] | 25 | $(call quiet-command,$(LIBTOOL) --mode=compile --quiet --tag=CC $(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," lt CC $@") |
Alon Levy | 44dc0ca | 2011-05-15 11:51:28 +0300 | [diff] [blame] | 26 | endif |
| 27 | |
aliguori | 1775918 | 2009-01-21 18:12:52 +0000 | [diff] [blame] | 28 | %.o: %.S |
Jiri Denemark | 76dc3cf | 2011-08-10 12:04:34 +0200 | [diff] [blame] | 29 | $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," AS $(TARGET_DIR)$@") |
aliguori | 1775918 | 2009-01-21 18:12:52 +0000 | [diff] [blame] | 30 | |
| 31 | %.o: %.m |
Jiri Denemark | 76dc3cf | 2011-08-10 12:04:34 +0200 | [diff] [blame] | 32 | $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," OBJC $(TARGET_DIR)$@") |
aliguori | 1775918 | 2009-01-21 18:12:52 +0000 | [diff] [blame] | 33 | |
Stefan Hajnoczi | e2a99ad | 2011-08-25 09:18:52 +0100 | [diff] [blame] | 34 | LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(sort $(1)) $(LIBS)," LINK $(TARGET_DIR)$@") |
aliguori | 3aa892d | 2009-01-21 18:13:02 +0000 | [diff] [blame] | 35 | |
| 36 | %$(EXESUF): %.o |
Anthony Liguori | 0bfe3ca | 2009-05-14 19:29:53 +0100 | [diff] [blame] | 37 | $(call LINK,$^) |
aliguori | 4f188f8 | 2009-01-21 18:13:09 +0000 | [diff] [blame] | 38 | |
aliguori | 93a0dba | 2009-01-21 18:13:16 +0000 | [diff] [blame] | 39 | %.a: |
aliguori | 28c699a | 2009-01-26 17:07:46 +0000 | [diff] [blame] | 40 | $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^," AR $(TARGET_DIR)$@") |
aliguori | 93a0dba | 2009-01-21 18:13:16 +0000 | [diff] [blame] | 41 | |
aliguori | 28c699a | 2009-01-26 17:07:46 +0000 | [diff] [blame] | 42 | quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1)) |
Juan Quintela | 70071e1 | 2009-07-21 14:11:18 +0200 | [diff] [blame] | 43 | |
| 44 | # cc-option |
Juan Quintela | 8a2e6ab | 2009-08-31 00:48:45 +0200 | [diff] [blame] | 45 | # Usage: CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0) |
Juan Quintela | 70071e1 | 2009-07-21 14:11:18 +0200 | [diff] [blame] | 46 | |
Thomas Monjalon | fc3baad | 2009-09-11 18:45:40 +0200 | [diff] [blame] | 47 | cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \ |
| 48 | >/dev/null 2>&1 && echo OK), $2, $3) |
Juan Quintela | 1215c6e | 2009-10-07 02:40:58 +0200 | [diff] [blame] | 49 | |
Paolo Bonzini | b93b63f | 2012-03-28 15:42:01 +0200 | [diff] [blame] | 50 | VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.texi %.sh |
Nathan Froyd | 288e7bc | 2010-04-26 14:52:23 -0700 | [diff] [blame] | 51 | set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1))) |
Paolo Bonzini | 076d247 | 2009-12-21 10:06:55 +0100 | [diff] [blame] | 52 | |
Paolo Bonzini | 2b2e59e | 2010-10-21 10:18:40 +0200 | [diff] [blame] | 53 | # 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. |
| 58 | find-in-path = $(if $(find-string /, $1), \ |
| 59 | $(wildcard $1), \ |
| 60 | $(wildcard $(patsubst %, %/$1, $(subst :, ,$(PATH))))) |
| 61 | |
Juan Quintela | 1215c6e | 2009-10-07 02:40:58 +0200 | [diff] [blame] | 62 | # Generate timestamp files for .h include files |
| 63 | |
| 64 | %.h: %.h-timestamp |
| 65 | @test -f $@ || cp $< $@ |
| 66 | |
| 67 | %.h-timestamp: %.mak |
Blue Swirl | 4c3b5a4 | 2011-01-20 20:54:21 +0000 | [diff] [blame] | 68 | $(call quiet-command, sh $(SRC_PATH)/scripts/create_config < $< > $@, " GEN $*.h") |
Juan Quintela | 1215c6e | 2009-10-07 02:40:58 +0200 | [diff] [blame] | 69 | @cmp $@ $*.h >/dev/null 2>&1 || cp $@ $*.h |
Michael S. Tsirkin | 7dbbbb0 | 2009-12-07 21:04:52 +0200 | [diff] [blame] | 70 | |
| 71 | # will delete the target of a rule if commands exit with a nonzero exit status |
| 72 | .DELETE_ON_ERROR: |