Statistics
| Branch: | Revision:

root / rules.mak @ 076d2471

History | View | Annotate | Download (1.5 kB)

1 17759187 aliguori
2 5ab28867 Juan Quintela
# Don't use implicit rules or variables
3 5ab28867 Juan Quintela
# we have explicit rules for everything
4 5ab28867 Juan Quintela
MAKEFLAGS += -rR
5 5ab28867 Juan Quintela
6 5ab28867 Juan Quintela
# Files with this suffixes are final, don't try to generate them
7 5ab28867 Juan Quintela
# using implicit rules
8 5ab28867 Juan Quintela
%.d:
9 5ab28867 Juan Quintela
%.h:
10 5ab28867 Juan Quintela
%.c:
11 5ab28867 Juan Quintela
%.m:
12 5ab28867 Juan Quintela
%.mak:
13 5ab28867 Juan Quintela
14 7ebf54bc Stefan Weil
# Flags for dependency generation
15 7ebf54bc Stefan Weil
QEMU_DGFLAGS += -MMD -MP -MT $@
16 02d5467e malc
17 0e8c9214 Andreas Färber
%.o: %.c
18 7ebf54bc Stefan Weil
	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
19 17759187 aliguori
20 17759187 aliguori
%.o: %.S
21 7ebf54bc Stefan Weil
	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  AS    $(TARGET_DIR)$@")
22 17759187 aliguori
23 17759187 aliguori
%.o: %.m
24 7ebf54bc Stefan Weil
	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
25 17759187 aliguori
26 0e8c9214 Andreas Färber
LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(LIBS),"  LINK  $(TARGET_DIR)$@")
27 3aa892d7 aliguori
28 3aa892d7 aliguori
%$(EXESUF): %.o
29 0bfe3ca5 Anthony Liguori
	$(call LINK,$^)
30 4f188f88 aliguori
31 93a0dba7 aliguori
%.a:
32 28c699a2 aliguori
	$(call quiet-command,rm -f $@ && $(AR) rcs $@ $^,"  AR    $(TARGET_DIR)$@")
33 93a0dba7 aliguori
34 28c699a2 aliguori
quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))
35 70071e17 Juan Quintela
36 70071e17 Juan Quintela
# cc-option
37 8a2e6ab5 Juan Quintela
# Usage: CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
38 70071e17 Juan Quintela
39 fc3baad7 Thomas Monjalon
cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \
40 fc3baad7 Thomas Monjalon
              >/dev/null 2>&1 && echo OK), $2, $3)
41 1215c6e7 Juan Quintela
42 076d2471 Paolo Bonzini
set-vpath = $(if $1,$(foreach PATTERN,%.c %.h %.S, $(eval vpath $(PATTERN) $1)))
43 076d2471 Paolo Bonzini
44 1215c6e7 Juan Quintela
# Generate timestamp files for .h include files
45 1215c6e7 Juan Quintela
46 1215c6e7 Juan Quintela
%.h: %.h-timestamp
47 1215c6e7 Juan Quintela
	@test -f $@ || cp $< $@
48 1215c6e7 Juan Quintela
49 1215c6e7 Juan Quintela
%.h-timestamp: %.mak
50 3e65aaf5 malc
	$(call quiet-command, sh $(SRC_PATH)/create_config < $< > $@, "  GEN   $*.h")
51 1215c6e7 Juan Quintela
	@cmp $@ $*.h >/dev/null 2>&1 || cp $@ $*.h
52 7dbbbb0c Michael S. Tsirkin
53 7dbbbb0c Michael S. Tsirkin
# will delete the target of a rule if commands exit with a nonzero exit status
54 7dbbbb0c Michael S. Tsirkin
.DELETE_ON_ERROR: