annotate src/opus-1.3/Makefile.unix @ 69:7aeed7906520

Add Opus sources and macOS builds
author Chris Cannam
date Wed, 23 Jan 2019 13:48:08 +0000
parents
children
rev   line source
Chris@69 1 #################### COMPILE OPTIONS #######################
Chris@69 2
Chris@69 3 # Uncomment this for fixed-point build
Chris@69 4 #FIXED_POINT=1
Chris@69 5
Chris@69 6 # It is strongly recommended to uncomment one of these
Chris@69 7 # VAR_ARRAYS: Use C99 variable-length arrays for stack allocation
Chris@69 8 # USE_ALLOCA: Use alloca() for stack allocation
Chris@69 9 # If none is defined, then the fallback is a non-threadsafe global array
Chris@69 10 CFLAGS := -DUSE_ALLOCA $(CFLAGS)
Chris@69 11 #CFLAGS := -DVAR_ARRAYS $(CFLAGS)
Chris@69 12
Chris@69 13 # These options affect performance
Chris@69 14 # HAVE_LRINTF: Use C99 intrinsics to speed up float-to-int conversion
Chris@69 15 #CFLAGS := -DHAVE_LRINTF $(CFLAGS)
Chris@69 16
Chris@69 17 ###################### END OF OPTIONS ######################
Chris@69 18
Chris@69 19 -include package_version
Chris@69 20
Chris@69 21 include silk_sources.mk
Chris@69 22 include celt_sources.mk
Chris@69 23 include opus_sources.mk
Chris@69 24
Chris@69 25 ifdef FIXED_POINT
Chris@69 26 SILK_SOURCES += $(SILK_SOURCES_FIXED)
Chris@69 27 else
Chris@69 28 SILK_SOURCES += $(SILK_SOURCES_FLOAT)
Chris@69 29 OPUS_SOURCES += $(OPUS_SOURCES_FLOAT)
Chris@69 30 endif
Chris@69 31
Chris@69 32 EXESUFFIX =
Chris@69 33 LIBPREFIX = lib
Chris@69 34 LIBSUFFIX = .a
Chris@69 35 OBJSUFFIX = .o
Chris@69 36
Chris@69 37 CC = $(TOOLCHAIN_PREFIX)cc$(TOOLCHAIN_SUFFIX)
Chris@69 38 AR = $(TOOLCHAIN_PREFIX)ar
Chris@69 39 RANLIB = $(TOOLCHAIN_PREFIX)ranlib
Chris@69 40 CP = $(TOOLCHAIN_PREFIX)cp
Chris@69 41
Chris@69 42 cppflags-from-defines = $(addprefix -D,$(1))
Chris@69 43 cppflags-from-includes = $(addprefix -I,$(1))
Chris@69 44 ldflags-from-ldlibdirs = $(addprefix -L,$(1))
Chris@69 45 ldlibs-from-libs = $(addprefix -l,$(1))
Chris@69 46
Chris@69 47 WARNINGS = -Wall -W -Wstrict-prototypes -Wextra -Wcast-align -Wnested-externs -Wshadow
Chris@69 48 CFLAGS += -O2 -g $(WARNINGS) -DOPUS_BUILD
Chris@69 49 CINCLUDES = include silk celt
Chris@69 50
Chris@69 51 ifdef FIXED_POINT
Chris@69 52 CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API
Chris@69 53 CINCLUDES += silk/fixed
Chris@69 54 else
Chris@69 55 CINCLUDES += silk/float
Chris@69 56 endif
Chris@69 57
Chris@69 58
Chris@69 59 LIBS = m
Chris@69 60
Chris@69 61 LDLIBDIRS = ./
Chris@69 62
Chris@69 63 CFLAGS += $(call cppflags-from-defines,$(CDEFINES))
Chris@69 64 CFLAGS += $(call cppflags-from-includes,$(CINCLUDES))
Chris@69 65 LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS))
Chris@69 66 LDLIBS += $(call ldlibs-from-libs,$(LIBS))
Chris@69 67
Chris@69 68 COMPILE.c.cmdline = $(CC) -c $(CFLAGS) -o $@ $<
Chris@69 69 LINK.o = $(CC) $(LDPREFLAGS) $(LDFLAGS)
Chris@69 70 LINK.o.cmdline = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX)
Chris@69 71
Chris@69 72 ARCHIVE.cmdline = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@
Chris@69 73
Chris@69 74 %$(OBJSUFFIX):%.c
Chris@69 75 $(COMPILE.c.cmdline)
Chris@69 76
Chris@69 77 %$(OBJSUFFIX):%.cpp
Chris@69 78 $(COMPILE.cpp.cmdline)
Chris@69 79
Chris@69 80 # Directives
Chris@69 81
Chris@69 82
Chris@69 83 # Variable definitions
Chris@69 84 LIB_NAME = opus
Chris@69 85 TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX)
Chris@69 86
Chris@69 87 SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES)
Chris@69 88
Chris@69 89 OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C))
Chris@69 90
Chris@69 91 OPUSDEMO_SRCS_C = src/opus_demo.c
Chris@69 92 OPUSDEMO_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSDEMO_SRCS_C))
Chris@69 93
Chris@69 94 TESTOPUSAPI_SRCS_C = tests/test_opus_api.c
Chris@69 95 TESTOPUSAPI_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSAPI_SRCS_C))
Chris@69 96
Chris@69 97 TESTOPUSDECODE_SRCS_C = tests/test_opus_decode.c
Chris@69 98 TESTOPUSDECODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSDECODE_SRCS_C))
Chris@69 99
Chris@69 100 TESTOPUSENCODE_SRCS_C = tests/test_opus_encode.c tests/opus_encode_regressions.c
Chris@69 101 TESTOPUSENCODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSENCODE_SRCS_C))
Chris@69 102
Chris@69 103 TESTOPUSPADDING_SRCS_C = tests/test_opus_padding.c
Chris@69 104 TESTOPUSPADDING_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSPADDING_SRCS_C))
Chris@69 105
Chris@69 106 OPUSCOMPARE_SRCS_C = src/opus_compare.c
Chris@69 107 OPUSCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSCOMPARE_SRCS_C))
Chris@69 108
Chris@69 109 TESTS := test_opus_api test_opus_decode test_opus_encode test_opus_padding
Chris@69 110
Chris@69 111 # Rules
Chris@69 112 all: lib opus_demo opus_compare $(TESTS)
Chris@69 113
Chris@69 114 lib: $(TARGET)
Chris@69 115
Chris@69 116 check: all
Chris@69 117 for test in $(TESTS); do ./$$test; done
Chris@69 118
Chris@69 119 $(TARGET): $(OBJS)
Chris@69 120 $(ARCHIVE.cmdline)
Chris@69 121
Chris@69 122 opus_demo$(EXESUFFIX): $(OPUSDEMO_OBJS) $(TARGET)
Chris@69 123 $(LINK.o.cmdline)
Chris@69 124
Chris@69 125 test_opus_api$(EXESUFFIX): $(TESTOPUSAPI_OBJS) $(TARGET)
Chris@69 126 $(LINK.o.cmdline)
Chris@69 127
Chris@69 128 test_opus_decode$(EXESUFFIX): $(TESTOPUSDECODE_OBJS) $(TARGET)
Chris@69 129 $(LINK.o.cmdline)
Chris@69 130
Chris@69 131 test_opus_encode$(EXESUFFIX): $(TESTOPUSENCODE_OBJS) $(TARGET)
Chris@69 132 $(LINK.o.cmdline)
Chris@69 133
Chris@69 134 test_opus_padding$(EXESUFFIX): $(TESTOPUSPADDING_OBJS) $(TARGET)
Chris@69 135 $(LINK.o.cmdline)
Chris@69 136
Chris@69 137 opus_compare$(EXESUFFIX): $(OPUSCOMPARE_OBJS)
Chris@69 138 $(LINK.o.cmdline)
Chris@69 139
Chris@69 140 celt/celt.o: CFLAGS += -DPACKAGE_VERSION='$(PACKAGE_VERSION)'
Chris@69 141 celt/celt.o: package_version
Chris@69 142
Chris@69 143 package_version: force
Chris@69 144 @if [ -x ./update_version ]; then \
Chris@69 145 ./update_version || true; \
Chris@69 146 elif [ ! -e ./package_version ]; then \
Chris@69 147 echo 'PACKAGE_VERSION="unknown"' > ./package_version; \
Chris@69 148 fi
Chris@69 149
Chris@69 150 force:
Chris@69 151
Chris@69 152 clean:
Chris@69 153 rm -f opus_demo$(EXESUFFIX) opus_compare$(EXESUFFIX) $(TARGET) \
Chris@69 154 test_opus_api$(EXESUFFIX) test_opus_decode$(EXESUFFIX) \
Chris@69 155 test_opus_encode$(EXESUFFIX) test_opus_padding$(EXESUFFIX) \
Chris@69 156 $(OBJS) $(OPUSDEMO_OBJS) $(OPUSCOMPARE_OBJS) $(TESTOPUSAPI_OBJS) \
Chris@69 157 $(TESTOPUSDECODE_OBJS) $(TESTOPUSENCODE_OBJS) $(TESTOPUSPADDING_OBJS)
Chris@69 158
Chris@69 159 .PHONY: all lib clean force check