summaryrefslogtreecommitdiffstats
path: root/Makefile.rules
blob: 80121c33109442269e56d2ded979e0266e16228d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#
# These allow for the build to be less verbose
#

ifdef V
  VERBOSE:= $(V)
else
  VERBOSE:= 0
endif

ifeq ($(VERBOSE),1)
define Q
  $(2)
endef
else
ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
define Q
  @$(2)
endef
else
define Q
  @echo "	[$1] $(3)"
  @$(2)
endef
endif
endif

define QTEST
	$(call Q,$1, ./test/run.sh $2, $3)
endef

define cook_aflags
       $(filter-out $(AFLAGS_SKIP_$(1)), $(CPPFLAGS) $(AFLAGS)) $(AFLAGS_$(1))
endef

define cook_cflags
       $(filter-out $(CFLAGS_SKIP_$(1)), $(CPPFLAGS) $(CFLAGS)) $(CFLAGS_$(1))
endef

ifeq ($(C),1)
  ifeq ($(VERBOSE),1)
	cmd_check = $(CHECK) $(CHECKFLAGS) $(filter-out $(CHECK_CFLAGS_SKIP),$(call cook_cflags,$@)) $<
  else
	cmd_check = @$(CHECK) $(CHECKFLAGS) $(filter-out $(CHECK_CFLAGS_SKIP),$(call cook_cflags,$@)) $<
  endif
endif


%.o : %.S include/asm-offsets.h
	$(call Q,AS, $(CC) $(call cook_aflags,$@) -c $< -o $@, $@)

%.s : %.S include/asm-offsets.h
	$(call Q,CC, $(CC) $(call cook_aflags,$@) -E -c $< -o $@, $@)

%.o : %.c
	$(call cmd_check)
	$(call Q,CC, $(CC) $(call cook_cflags,$@) -c $< -o $@, $@)

# Force the use of the C compiler, not C++ for the .C files in libpore
%.o : %.C
	$(call cmd_check)
	$(call Q,CC, $(CC) $(call cook_cflags,$@) -x c -c $< -o $@, $@)

%.s : %.c
	$(call Q,CC, $(CC) $(call cook_cflags,$@) -S -c $< -o $@, $@)

%.i : %.c
	$(call Q,CC, $(CC) $(call cook_cflags,$@) -E -c $< -o $@, $@)

%built-in.o :
	$(call Q,LD, $(LD) $(LDRFLAGS) -r $^ -o $@, $@)

%.lds : %.lds.S
	$(call Q,CC, $(CC) $(CPPFLAGS) -P -E $< -o $@, $@)

%.map: %.elf
	$(call Q,NM, $(NM) --synthetic -n $< | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)' > $@, $@)
OpenPOWER on IntegriCloud