Makefile.unix 3.12 KB
Newer Older
Jean-Marc Valin's avatar
Jean-Marc Valin committed
1
2
#################### COMPILE OPTIONS #######################

3
# Uncomment this for fixed-point build
Jean-Marc Valin's avatar
Jean-Marc Valin committed
4
5
#FIXED_POINT=1

6
7
8
9
# It is strongly recommended to uncomment one of these
# VAR_ARRAYS: Use C99 variable-length arrays for stack allocation
# USE_ALLOCA: Use alloca() for stack allocation
# If none is defined, then the fallback is a non-threadsafe global array
10
11
CFLAGS := -DUSE_ALLOCA $(CFLAGS)
#CFLAGS := -DVAR_ARRAYS $(CFLAGS)
Jean-Marc Valin's avatar
Jean-Marc Valin committed
12

13
14
# These options affect performance
# HAVE_LRINTF: Use C99 intrinsics to speed up float-to-int conversion
15
#CFLAGS := -DHAVE_LRINTF $(CFLAGS)
16

Jean-Marc Valin's avatar
Jean-Marc Valin committed
17
###################### END OF OPTIONS ######################
18

Ron's avatar
Ron committed
19
20
-include package_version

21
22
23
24
include silk_sources.mk
include celt_sources.mk
include opus_sources.mk

Jean-Marc Valin's avatar
Jean-Marc Valin committed
25
26
27
28
ifdef FIXED_POINT
SILK_SOURCES += $(SILK_SOURCES_FIXED)
else
SILK_SOURCES += $(SILK_SOURCES_FLOAT)
Jean-Marc Valin's avatar
Jean-Marc Valin committed
29
OPUS_SOURCES += $(OPUS_SOURCES_FLOAT)
Jean-Marc Valin's avatar
Jean-Marc Valin committed
30
31
endif

32
33
34
35
36
EXESUFFIX =
LIBPREFIX = lib
LIBSUFFIX = .a
OBJSUFFIX = .o

37
CC     = $(TOOLCHAIN_PREFIX)cc$(TOOLCHAIN_SUFFIX)
38
39
40
41
42
43
44
AR     = $(TOOLCHAIN_PREFIX)ar
RANLIB = $(TOOLCHAIN_PREFIX)ranlib
CP     = $(TOOLCHAIN_PREFIX)cp

cppflags-from-defines   = $(addprefix -D,$(1))
cppflags-from-includes  = $(addprefix -I,$(1))
ldflags-from-ldlibdirs  = $(addprefix -L,$(1))
Ron's avatar
Ron committed
45
ldlibs-from-libs        = $(addprefix -l,$(1))
46

47
WARNINGS = -Wall -W -Wstrict-prototypes -Wextra -Wcast-align -Wnested-externs -Wshadow
Jean-Marc Valin's avatar
Jean-Marc Valin committed
48
CFLAGS  += -O2 -g $(WARNINGS) -DOPUS_BUILD
Ron's avatar
Ron committed
49
50
CINCLUDES = include silk celt

51
ifdef FIXED_POINT
Jean-Marc Valin's avatar
Jean-Marc Valin committed
52
CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API
Ron's avatar
Ron committed
53
54
55
CINCLUDES += silk/fixed
else
CINCLUDES += silk/float
56
endif
57

58
59
60
61
62

LIBS = m

LDLIBDIRS = ./

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
CFLAGS  += $(call cppflags-from-defines,$(CDEFINES))
CFLAGS  += $(call cppflags-from-includes,$(CINCLUDES))
LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS))
LDLIBS  += $(call ldlibs-from-libs,$(LIBS))

COMPILE.c.cmdline   = $(CC) -c $(CFLAGS) -o $@ $<
LINK.o              = $(CC) $(LDPREFLAGS) $(LDFLAGS)
LINK.o.cmdline      = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX)

ARCHIVE.cmdline     = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@

%$(OBJSUFFIX):%.c
	$(COMPILE.c.cmdline)

%$(OBJSUFFIX):%.cpp
	$(COMPILE.cpp.cmdline)

# Directives


# Variable definitions
84
LIB_NAME = opus
85
86
87
88
89
90
TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX)

SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES)

OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C))

91
92
OPUSDEMO_SRCS_C = src/opus_demo.c
OPUSDEMO_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSDEMO_SRCS_C))
93

94
95
96
OPUSCOMPARE_SRCS_C = src/opus_compare.c
OPUSCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSCOMPARE_SRCS_C))

97
# Rules
Ron's avatar
Ron committed
98
all: lib opus_demo opus_compare
99
100
101
102
103
104

lib: $(TARGET)

$(TARGET): $(OBJS)
	$(ARCHIVE.cmdline)

105
opus_demo$(EXESUFFIX): $(OPUSDEMO_OBJS) $(TARGET)
106
	$(LINK.o.cmdline)
Ralph Giles's avatar
Ralph Giles committed
107

108
109
opus_compare$(EXESUFFIX): $(OPUSCOMPARE_OBJS)
	$(LINK.o.cmdline)
110

Ron's avatar
Ron committed
111
112
113
114
celt/celt.o: CFLAGS += -DPACKAGE_VERSION='$(PACKAGE_VERSION)'
celt/celt.o: package_version

package_version: force
115
116
117
118
119
	@if [ -x ./update_version ]; then \
		./update_version || true; \
	elif [ ! -e ./package_version ]; then \
		echo 'PACKAGE_VERSION="unknown"' > ./package_version; \
	fi
Ron's avatar
Ron committed
120
121
122

force:

Jean-Marc Valin's avatar
Jean-Marc Valin committed
123
clean:
124
125
	rm -f opus_demo$(EXESUFFIX) opus_compare$(EXESUFFIX) $(TARGET) \
		$(OBJS) $(OPUSDEMO_OBJS) $(OPUSCOMPARE_OBJS)
Ron's avatar
Ron committed
126
127

.PHONY: all lib clean