-
Notifications
You must be signed in to change notification settings - Fork 25
/
GNUmakefile
107 lines (82 loc) · 2.11 KB
/
GNUmakefile
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
96
97
98
99
100
101
102
103
104
105
106
ifeq ($(platform),)
platform = unix
ifeq ($(shell uname -a),)
platform = win
else ifneq ($(findstring MINGW,$(shell uname -a)),)
platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
platform = osx
else ifneq ($(findstring win,$(shell uname -a)),)
platform = win
endif
endif
ifeq ($(platform),win)
CC = gcc
EXE_SUFFIX := .exe
else
FPIC := -fPIC
endif
CFLAGS += -std=c99 -Wall -Wextra -pedantic $(FPIC) -Iinclude
LDFLAGS += -lm
FMSYNTH_STATIC_LIB := libfmsynth.a
OBJDIR := obj
FMSYNTH_C_SOURCES := src/fmsynth.c
FMSYNTH_TEST_SOURCES := src/fmsynth_test.c
FMSYNTH_TEST_OBJECTS := $(addprefix $(OBJDIR)/,$(FMSYNTH_TEST_SOURCES:.c=.o))
FMSYNTH_TEST := fmsynth_test$(EXE_SUFFIX)
SIMD = 1
PREFIX = /usr/local
ifeq ($(ARCH),)
ARCH := $(shell uname -m)
endif
ifneq ($(findstring armv7,$(ARCH)),)
CFLAGS += -march=armv7-a -mfpu=neon -marm
ASFLAGS += -mfpu=neon
FMSYNTH_ASM_SOURCES += src/arm/fmsynth_neon.S
endif
ifneq ($(TOOLCHAIN_PREFIX),)
CC = $(TOOLCHAIN_PREFIX)gcc
AS = $(TOOLCHAIN_PREFIX)gcc
AR = $(TOOLCHAIN_PREFIX)ar
endif
FMSYNTH_OBJECTS := \
$(addprefix $(OBJDIR)/,$(FMSYNTH_C_SOURCES:.c=.o)) \
$(addprefix $(OBJDIR)/,$(FMSYNTH_ASM_SOURCES:.S=.o))
DEPS := $(FMSYNTH_TEST_OBJECTS:.o=.d) $(FMSYNTH_OBJECTS:.o=.d)
ifneq ($(TUNE),)
CFLAGS += -mtune=$(TUNE)
else
CFLAGS += -march=native
endif
ifeq ($(SIMD), 1)
CFLAGS += -DFMSYNTH_SIMD
endif
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g
else
CFLAGS += -Ofast
endif
all: $(FMSYNTH_STATIC_LIB)
test: $(FMSYNTH_TEST)
-include $(DEPS)
$(FMSYNTH_STATIC_LIB): $(FMSYNTH_OBJECTS)
$(AR) rcs $@ $^
$(FMSYNTH_TEST): $(FMSYNTH_TEST_OBJECTS) $(FMSYNTH_STATIC_LIB)
$(CC) -o $@ $^ $(LDFLAGS)
$(OBJDIR)/%.o: %.c
@mkdir -p $(dir $@)
$(CC) -c -o $@ $< $(CFLAGS) -MMD
$(OBJDIR)/%.o: %.S
@mkdir -p $(dir $@)
$(CC) -c -o $@ $< $(ASFLAGS)
clean:
rm -f $(FMSYNTH_TEST) $(FMSYNTH_STATIC_LIB)
rm -rf $(OBJDIR)
install:
@mkdir -p $(PREFIX)/lib
@mkdir -p $(PREFIX)/include
install -m644 $(FMSYNTH_STATIC_LIB) $(PREFIX)/lib/
install -m644 fmsynth.h $(PREFIX)/include/
docs:
doxygen
.PHONY: clean install docs