-
Notifications
You must be signed in to change notification settings - Fork 14
/
common_head.mk
67 lines (52 loc) · 1.6 KB
/
common_head.mk
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
ifdef VERBOSE
Q =
endif
Q ?= @
all: $(PROJ)
.PHONY: all
# Detect the native OS
UNAME_OS=$(shell uname -s)
# What's the extension on C++ files? .cc is the Google default, but
# lots of people use .cpp instead.
CXX_EXT ?= cc
C_SRC = $(filter %.c,$(SRC))
CXX_SRC = $(filter %.$(CXX_EXT),$(SRC))
CUSTOM_C_SRC = $(filter %.c,$(CUSTOM_SRC))
CUSTOM_CXX_SRC = $(filter %.$(CXX_EXT),$(CUSTOM_SRC))
C_HDR = $(filter %.h,$(SRC))
CXX_HDR = $(filter %.hh,$(SRC))
_TARGET_STEM ?= $(shell $(CC) -dumpmachine | perl -pe "s/(\w+)-.*/\1/")
_TARGET_NAMES ?= 1
ifneq (0, $(_TARGET_NAMES))
OBJECT_FILE_SUFFIX ?= o.$(_TARGET_STEM)
ASMNAME ?= lst.$(_TARGET_STEM)
else
OBJECT_FILE_SUFFIX ?= o
ASMNAME ?= lst
endif
C_ASM ?= $(C_SRC:%.c=%.$(ASMNAME))
C_OBJ ?= $(C_SRC:%.c=%.$(OBJECT_FILE_SUFFIX))
CUSTOM_C_OBJ ?= $(CUSTOM_C_SRC:%.c=%.$(OBJECT_FILE_SUFFIX))
C_DEPS ?= $(C_SRC:%.c=%.d)
CXX_ASM ?= $(CXX_SRC:%.$(CXX_EXT)=%.$(ASMNAME))
CXX_OBJ ?= $(CXX_SRC:%.$(CXX_EXT)=%.$(OBJECT_FILE_SUFFIX))
CUSTOM_CXX_OBJ ?= $(CUSTOM_CXX_SRC:%.c=%.$(OBJECT_FILE_SUFFIX))
CXX_DEPS ?= $(CXX_SRC:%.$(CXX_EXT)=%.d)
ASM ?= $(C_ASM) $(CXX_ASM)
OBJ ?= $(C_OBJ) $(CXX_OBJ)
DEPS ?= $(C_DEPS) $(CXX_DEPS)
ifeq ("$(UNAME_OS)","Darwin")
CLANGIN = 22
endif
ifneq (,$(findstring clang,$(CC)))
CLANGIN = 222
endif
# Here we remove all paths from the given object and source file
# names; you can echo these in commands and get slightly tidier output.
SRC_SHORT = $(notdir $(SRC))
ASM_SHORT = $(notdir $(ASM))
OBJ_SHORT = $(notdir $(OBJ))
# So make recognizes dependency files
SUFFIXES += .d
# Generate sweet mixed assembly/C listing files
ASMFLAGS ?= -fverbose-asm -Wa,-L,-alchsdn=