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