-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild_rules.mk
More file actions
69 lines (59 loc) · 2.51 KB
/
Copy pathbuild_rules.mk
File metadata and controls
69 lines (59 loc) · 2.51 KB
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
# Check for linux vs macOS and account for clang/ld path
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
CC := clang
CXX := clang++
LD := ld.lld
AR := llvm-ar
CDIR := linux
endif
ifeq ($(UNAME_S),Darwin)
CC := /usr/local/opt/llvm/bin/clang
CXX := /usr/local/opt/llvm/bin/clang++
LD := /usr/local/opt/llvm/bin/ld.lld
AR := /usr/local/opt/llvm/bin/llvm-ar
CDIR := macos
endif
# Allow for 'make VERBOSE=1' to see the recepie executions
ifndef VERBOSE
VERB := @
endif
#---------------------------------------------------------------------------------
%.a:
#---------------------------------------------------------------------------------
$(VERB) echo $(notdir $@)
$(VERB) rm -f $@
$(VERB) $(AR) -rc $@ $^
#---------------------------------------------------------------------------------
%.elf: $(OFILES)
$(VERB) echo linking ... $(notdir $@)
$(VERB) $(LD) $^ $(LDFLAGS) $(LIBPATHS) $(LIBS) -o $@
#---------------------------------------------------------------------------------
%.o: %.cpp
$(VERB) echo $(notdir $<)
$(VERB) $(CXX) $(DEPSOPT) $(CXXFLAGS) -o $@ $< $(ERROR_FILTER)
#---------------------------------------------------------------------------------
%.o: %.c
$(VERB) echo $(notdir $<)
$(VERB) $(CC) $(DEPSOPT) $(CFLAGS) -o $@ $< $(ERROR_FILTER)
#---------------------------------------------------------------------------------
%.o: %.m
$(VERB) echo $(notdir $<)
$(VERB) $(CC) $(DEPSOPT) $(OBJCFLAGS) -o $@ $< $(ERROR_FILTER)
#---------------------------------------------------------------------------------
%.o: %.s
$(VERB) echo $(notdir $<)
$(VERB) $(CC) $(DEPSOPT) -x assembler-with-cpp $(ASFLAGS) -o $@ $< $(ERROR_FILTER)
#---------------------------------------------------------------------------------
%.o: %.S
$(VERB) echo $(notdir $<)
$(VERB) $(CC) $(DEPSOPT) -x assembler-with-cpp $(ASFLAGS) -o $@ $< $(ERROR_FILTER)
#---------------------------------------------------------------------------------
# canned command sequence for binary data
#---------------------------------------------------------------------------------
define bin2o
$(VERB) bin2s -a 64 $< | $(AS) -o $(@)
$(VERB) echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(<F) | tr . _)`.h
$(VERB) echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(<F) | tr . _)`.h
$(VERB) echo "extern const u32" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(<F) | tr . _)`.h
endef