-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile.alt
95 lines (76 loc) · 1.89 KB
/
Makefile.alt
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
.NOTPARALLEL:
SRCDIR = src
LIBDIR = lib
BUILDDIR = obj
SRC = $(wildcard $(SRCDIR)/*.c)
INCLUDES += -I$(SRCDIR) -Iext
CFLAGS += -std=c11 $(INCLUDES)
ARCH := $(shell getconf LONG_BIT)
ifndef platform
platform=x86_$(ARCH)
endif
ifndef config
ifeq ($(findstring x86, $(platform)), x86)
config=release-sse
else
config=release
endif
endif
ifeq ($(findstring -sse, $(config)),-sse)
CFLAGS += -msse -msse2 -msse3 -msse4.1 -msse4.2
DEFINES += -DCT_FEATURE_SSE
endif
ifeq ($(findstring release, $(config)),release)
CFLAGS += -O3
DEFINES += -DNDEBUG
else
CFLAGS += -g
DEFINES += -DDEBUG -DCT_FEATURE_CHECKS -DCT_FEATURE_CHECK_MEM -DCT_FEATURE_LOG
endif
OBJDIR = $(BUILDDIR)/$(platform)/$(config)
OBJECTS = $(subst $(SRCDIR)/, $(OBJDIR)/, $(SRC:.c=.o))
DEPS = $(OBJECTS:.o=.d)
ifeq ($(findstring stm32,$(platform)),stm32)
TARGETDIR = $(LIBDIR)
TARGET = $(TARGETDIR)/libctss-$(platform)-$(config).a
CC = arm-none-eabi-gcc
AR = arm-none-eabi-ar
ifeq ($(platform),stm32f4)
CFLAGS += -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -ffast-math
endif
ifeq ($(platform),stm32f7)
CFLAGS += -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -ffast-math
endif
else
TARGETDIR = $(LIBDIR)
TARGET = $(TARGETDIR)/libctss-$(platform)-$(config).a
endif
LINKCMD = $(AR) -rcs "$@" $(OBJECTS)
all: $(TARGETDIR) $(OBJDIR) $(TARGET)
@:
.PHONY: trace clean
trace:
@echo $(CC)
@echo $(AR)
@echo $(CFLAGS)
@echo $(TARGET)
@echo $(SRC)
@echo $(OBJECTS)
@echo $(DEPS)
clean:
@echo Cleaning...
rm -rf $(TARGETDIR)
rm -rf $(OBJDIR)
$(TARGET): $(OBJECTS) $(LDDEPS) $(RESOURCES)
@echo Linking $(TARGET)
$(LINKCMD)
$(TARGETDIR):
@echo Creating $(TARGETDIR)
mkdir -p $(TARGETDIR)
$(OBJDIR):
@echo Creating $(OBJDIR)
mkdir -p $(OBJDIR)
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(TARGETDIR)
@echo $(notdir $<)
$(CC) $(DEFINES) $(CFLAGS) -o "$@" -MMD -MP -MF "$(@:%.o=%.d)" -c "$<"
-include $(DEPS)