Josh Coalson | 6b05bc5 | 2001-06-08 00:13:21 +0000 | [diff] [blame] | 1 | # FLAC - Free Lossless Audio Codec |
Erik de Castro Lopo | b1982fb | 2013-05-25 17:11:19 +1000 | [diff] [blame] | 2 | # Copyright (C) 2001-2009 Josh Coalson |
Erik de Castro Lopo | 6a5fe43 | 2016-12-05 06:35:39 +1100 | [diff] [blame] | 3 | # Copyright (C) 2011-2016 Xiph.Org Foundation |
Josh Coalson | 6b05bc5 | 2001-06-08 00:13:21 +0000 | [diff] [blame] | 4 | # |
Josh Coalson | e8a7601 | 2003-02-07 00:14:32 +0000 | [diff] [blame] | 5 | # This file is part the FLAC project. FLAC is comprised of several |
Ulrich Klauer | cd4ddab | 2013-05-26 22:53:43 +0200 | [diff] [blame] | 6 | # components distributed under different licenses. The codec libraries |
Josh Coalson | e8a7601 | 2003-02-07 00:14:32 +0000 | [diff] [blame] | 7 | # are distributed under Xiph.Org's BSD-like license (see the file |
| 8 | # COPYING.Xiph in this distribution). All other programs, libraries, and |
| 9 | # plugins are distributed under the GPL (see COPYING.GPL). The documentation |
| 10 | # is distributed under the Gnu FDL (see COPYING.FDL). Each file in the |
| 11 | # FLAC distribution contains at the top the terms under which it may be |
| 12 | # distributed. |
Josh Coalson | 6b05bc5 | 2001-06-08 00:13:21 +0000 | [diff] [blame] | 13 | # |
Josh Coalson | e8a7601 | 2003-02-07 00:14:32 +0000 | [diff] [blame] | 14 | # Since this particular file is relevant to all components of FLAC, |
| 15 | # it may be distributed under the Xiph.Org license, which is the least |
| 16 | # restrictive of those mentioned above. See the file COPYING.Xiph in this |
| 17 | # distribution. |
Josh Coalson | 6b05bc5 | 2001-06-08 00:13:21 +0000 | [diff] [blame] | 18 | |
Josh Coalson | bb7f6b9 | 2000-12-10 04:09:52 +0000 | [diff] [blame] | 19 | # |
| 20 | # GNU makefile fragment for building a library |
| 21 | # |
| 22 | |
Josh Coalson | b74fc98 | 2002-11-20 06:40:08 +0000 | [diff] [blame] | 23 | include $(topdir)/build/config.mk |
| 24 | |
Josh Coalson | c10f978 | 2008-09-14 19:59:52 +0000 | [diff] [blame] | 25 | ifeq ($(OS),Darwin) |
Hendricks266 | 96d081c | 2012-12-29 04:22:59 -0600 | [diff] [blame] | 26 | CC = cc |
| 27 | CCC = c++ |
Josh Coalson | 6e14490 | 2001-12-07 19:28:25 +0000 | [diff] [blame] | 28 | else |
Thomas Zander | d20a79a | 2015-10-11 17:56:13 +0200 | [diff] [blame] | 29 | ifeq ($(OS),FreeBSD) |
| 30 | CC = cc |
| 31 | CCC = c++ |
| 32 | else |
Hendricks266 | 96d081c | 2012-12-29 04:22:59 -0600 | [diff] [blame] | 33 | CC = gcc |
| 34 | CCC = g++ |
Josh Coalson | 6e14490 | 2001-12-07 19:28:25 +0000 | [diff] [blame] | 35 | endif |
Thomas Zander | d20a79a | 2015-10-11 17:56:13 +0200 | [diff] [blame] | 36 | endif |
Thomas Zander | 8f4dffe | 2017-06-22 19:12:25 +0200 | [diff] [blame] | 37 | ifeq ($(CC),gcc) |
| 38 | GCC_INLINE = -finline-functions |
| 39 | endif |
Josh Coalson | 955a767 | 2001-05-03 02:24:39 +0000 | [diff] [blame] | 40 | NASM = nasm |
NotTsunami | 1640e10 | 2019-11-19 15:49:40 -0500 | [diff] [blame] | 41 | LINK = ar cr |
Erik de Castro Lopo | 85d5c53 | 2013-01-02 22:37:42 +1100 | [diff] [blame] | 42 | OBJPATH = $(topdir)/objs |
Josh Coalson | b74fc98 | 2002-11-20 06:40:08 +0000 | [diff] [blame] | 43 | LIBPATH = $(OBJPATH)/$(BUILD)/lib |
| 44 | DEBUG_LIBPATH = $(OBJPATH)/debug/lib |
| 45 | RELEASE_LIBPATH = $(OBJPATH)/release/lib |
Josh Coalson | c10f978 | 2008-09-14 19:59:52 +0000 | [diff] [blame] | 46 | ifeq ($(OS),Darwin) |
Hendricks266 | 96d081c | 2012-12-29 04:22:59 -0600 | [diff] [blame] | 47 | STATIC_LIB_SUFFIX = a |
| 48 | DYNAMIC_LIB_SUFFIX = dylib |
Evan Ramos | f658ea5 | 2014-06-26 17:25:48 -0500 | [diff] [blame] | 49 | else |
| 50 | ifeq ($(findstring Windows,$(OS)),Windows) |
Hendricks266 | 96d081c | 2012-12-29 04:22:59 -0600 | [diff] [blame] | 51 | STATIC_LIB_SUFFIX = a |
| 52 | DYNAMIC_LIB_SUFFIX = dll |
Josh Coalson | 1ce20ee | 2002-08-14 00:50:48 +0000 | [diff] [blame] | 53 | else |
Hendricks266 | 96d081c | 2012-12-29 04:22:59 -0600 | [diff] [blame] | 54 | STATIC_LIB_SUFFIX = a |
| 55 | DYNAMIC_LIB_SUFFIX = so |
Josh Coalson | 1ce20ee | 2002-08-14 00:50:48 +0000 | [diff] [blame] | 56 | endif |
Evan Ramos | f658ea5 | 2014-06-26 17:25:48 -0500 | [diff] [blame] | 57 | endif |
Josh Coalson | b74fc98 | 2002-11-20 06:40:08 +0000 | [diff] [blame] | 58 | STATIC_LIB_NAME = $(LIB_NAME).$(STATIC_LIB_SUFFIX) |
| 59 | DYNAMIC_LIB_NAME = $(LIB_NAME).$(DYNAMIC_LIB_SUFFIX) |
| 60 | STATIC_LIB = $(LIBPATH)/$(STATIC_LIB_NAME) |
| 61 | DYNAMIC_LIB = $(LIBPATH)/$(DYNAMIC_LIB_NAME) |
| 62 | DEBUG_STATIC_LIB = $(DEBUG_LIBPATH)/$(STATIC_LIB_NAME) |
| 63 | DEBUG_DYNAMIC_LIB = $(DEBUG_LIBPATH)/$(DYNAMIC_LIB_NAME) |
| 64 | RELEASE_STATIC_LIB = $(RELEASE_LIBPATH)/$(STATIC_LIB_NAME) |
| 65 | RELEASE_DYNAMIC_LIB = $(RELEASE_LIBPATH)/$(DYNAMIC_LIB_NAME) |
Josh Coalson | c10f978 | 2008-09-14 19:59:52 +0000 | [diff] [blame] | 66 | ifeq ($(OS),Darwin) |
Hendricks266 | 96d081c | 2012-12-29 04:22:59 -0600 | [diff] [blame] | 67 | LINKD = $(CC) -dynamiclib -flat_namespace -undefined suppress -install_name $(DYNAMIC_LIB) |
Josh Coalson | 6e14490 | 2001-12-07 19:28:25 +0000 | [diff] [blame] | 68 | else |
Hendricks266 | 96d081c | 2012-12-29 04:22:59 -0600 | [diff] [blame] | 69 | LINKD = $(CC) -shared |
Josh Coalson | 6e14490 | 2001-12-07 19:28:25 +0000 | [diff] [blame] | 70 | endif |
Josh Coalson | bb7f6b9 | 2000-12-10 04:09:52 +0000 | [diff] [blame] | 71 | |
Erik de Castro Lopo | 9e5dd48 | 2016-12-11 20:17:49 +1100 | [diff] [blame] | 72 | BASE_CFLAGS = -Wall -Wextra $(CONFIG_CFLAGS) -DVERSION=$(VERSION) -DPACKAGE_VERSION=$(VERSION) $(DEFINES) $(INCLUDES) |
Erik de Castro Lopo | 089caea | 2016-05-12 06:33:22 +1000 | [diff] [blame] | 73 | |
| 74 | ifeq ($(DEFAULT_BUILD),debug) |
| 75 | CFLAGS := -g -O0 -DDEBUG $(CFLAGS) $(BASE_CFLAGS) -Wmissing-prototypes -Wstrict-prototypes |
| 76 | CXXFLAGS := -g -O0 -DDEBUG $(CFLAGS) $(BASE_CFLAGS) |
| 77 | endif |
| 78 | |
| 79 | ifeq ($(DEFAULT_BUILD),valgrind) |
| 80 | CFLAGS := -g -O0 -DDEBUG -DDEBUG -DFLAC__VALGRIND_TESTING $(CFLAGS) $(BASE_CFLAGS) -Wmissing-prototypes -Wstrict-prototypes |
| 81 | CXXFLAGS := -g -O0 -DDEBUG -DDEBUG -DFLAC__VALGRIND_TESTING $(CFLAGS) $(BASE_CFLAGS) |
| 82 | endif |
| 83 | |
| 84 | ifeq ($(DEFAULT_BUILD),release) |
Thomas Zander | 8f4dffe | 2017-06-22 19:12:25 +0200 | [diff] [blame] | 85 | CFLAGS := -O3 -fomit-frame-pointer -funroll-loops $(GCC_INLINE) -DFLaC__INLINE=__inline__ -DNDEBUG $(CFLAGS) $(BASE_CFLAGS) -Wmissing-prototypes -Wstrict-prototypes |
| 86 | CXXFLAGS := -O3 -fomit-frame-pointer -funroll-loops $(GCC_INLINE) -DFLaC__INLINE=__inline__ -DNDEBUG $(CFLAGS) $(BASE_CFLAGS) |
Erik de Castro Lopo | 089caea | 2016-05-12 06:33:22 +1000 | [diff] [blame] | 87 | endif |
Evan Ramos | 9df6736 | 2014-06-23 16:24:49 -0500 | [diff] [blame] | 88 | |
| 89 | LFLAGS = -L$(LIBPATH) |
Josh Coalson | bb7f6b9 | 2000-12-10 04:09:52 +0000 | [diff] [blame] | 90 | |
Erik de Castro Lopo | b60f16b | 2014-07-13 21:19:48 +1000 | [diff] [blame] | 91 | DEBUG_OBJS = $(SRCS_C:%.c=%.debug.o) $(SRCS_CC:%.cc=%.debug.o) $(SRCS_CPP:%.cpp=%.debug.o) $(SRCS_NASM:%.nasm=%.debug.o) |
| 92 | RELEASE_OBJS = $(SRCS_C:%.c=%.release.o) $(SRCS_CC:%.cc=%.release.o) $(SRCS_CPP:%.cpp=%.release.o) $(SRCS_NASM:%.nasm=%.release.o) |
Josh Coalson | c10f978 | 2008-09-14 19:59:52 +0000 | [diff] [blame] | 93 | ifeq ($(PROC),x86_64) |
Erik de Castro Lopo | b60f16b | 2014-07-13 21:19:48 +1000 | [diff] [blame] | 94 | DEBUG_PIC_OBJS = $(SRCS_C:%.c=%.debug.pic.o) $(SRCS_CC:%.cc=%.debug.pic.o) $(SRCS_CPP:%.cpp=%.debug.pic.o) $(SRCS_NASM:%.nasm=%.debug.pic.o) |
| 95 | RELEASE_PIC_OBJS = $(SRCS_C:%.c=%.release.pic.o) $(SRCS_CC:%.cc=%.release.pic.o) $(SRCS_CPP:%.cpp=%.release.pic.o) $(SRCS_NASM:%.nasm=%.release.pic.o) |
Josh Coalson | c10f978 | 2008-09-14 19:59:52 +0000 | [diff] [blame] | 96 | endif |
Josh Coalson | bb7f6b9 | 2000-12-10 04:09:52 +0000 | [diff] [blame] | 97 | |
Josh Coalson | f8ecdde | 2004-12-30 03:56:08 +0000 | [diff] [blame] | 98 | debug : $(DEBUG_STATIC_LIB) $(DEBUG_DYNAMIC_LIB) |
| 99 | valgrind: $(DEBUG_STATIC_LIB) $(DEBUG_DYNAMIC_LIB) |
| 100 | release : $(RELEASE_STATIC_LIB) $(RELEASE_DYNAMIC_LIB) |
Josh Coalson | bb7f6b9 | 2000-12-10 04:09:52 +0000 | [diff] [blame] | 101 | |
Josh Coalson | b74fc98 | 2002-11-20 06:40:08 +0000 | [diff] [blame] | 102 | $(DEBUG_STATIC_LIB): $(DEBUG_OBJS) |
| 103 | $(LINK) $@ $(DEBUG_OBJS) && ranlib $@ |
| 104 | |
| 105 | $(RELEASE_STATIC_LIB): $(RELEASE_OBJS) |
| 106 | $(LINK) $@ $(RELEASE_OBJS) && ranlib $@ |
| 107 | |
Josh Coalson | c10f978 | 2008-09-14 19:59:52 +0000 | [diff] [blame] | 108 | $(DEBUG_DYNAMIC_LIB) : $(DEBUG_OBJS) $(DEBUG_PIC_OBJS) |
| 109 | ifeq ($(OS),Darwin) |
Josh Coalson | 2757af6 | 2004-10-30 00:03:21 +0000 | [diff] [blame] | 110 | echo Not building dynamic lib, command is: $(LINKD) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS) -lc |
Josh Coalson | 6e14490 | 2001-12-07 19:28:25 +0000 | [diff] [blame] | 111 | else |
Josh Coalson | c10f978 | 2008-09-14 19:59:52 +0000 | [diff] [blame] | 112 | ifeq ($(PROC),x86_64) |
| 113 | $(LINKD) -o $@ $(DEBUG_PIC_OBJS) $(LFLAGS) $(LIBS) |
| 114 | else |
Josh Coalson | b74fc98 | 2002-11-20 06:40:08 +0000 | [diff] [blame] | 115 | $(LINKD) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS) |
Josh Coalson | 6e14490 | 2001-12-07 19:28:25 +0000 | [diff] [blame] | 116 | endif |
Josh Coalson | c10f978 | 2008-09-14 19:59:52 +0000 | [diff] [blame] | 117 | endif |
Josh Coalson | bb7f6b9 | 2000-12-10 04:09:52 +0000 | [diff] [blame] | 118 | |
Josh Coalson | c10f978 | 2008-09-14 19:59:52 +0000 | [diff] [blame] | 119 | $(RELEASE_DYNAMIC_LIB) : $(RELEASE_OBJS) $(RELEASE_PIC_OBJS) |
| 120 | ifeq ($(OS),Darwin) |
Josh Coalson | 28306cc | 2004-12-30 03:48:25 +0000 | [diff] [blame] | 121 | echo Not building dynamic lib, command is: $(LINKD) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS) -lc |
Josh Coalson | b74fc98 | 2002-11-20 06:40:08 +0000 | [diff] [blame] | 122 | else |
Josh Coalson | c10f978 | 2008-09-14 19:59:52 +0000 | [diff] [blame] | 123 | ifeq ($(PROC),x86_64) |
| 124 | $(LINKD) -o $@ $(RELEASE_PIC_OBJS) $(LFLAGS) $(LIBS) |
| 125 | else |
Josh Coalson | b74fc98 | 2002-11-20 06:40:08 +0000 | [diff] [blame] | 126 | $(LINKD) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS) |
| 127 | endif |
Josh Coalson | 2757af6 | 2004-10-30 00:03:21 +0000 | [diff] [blame] | 128 | endif |
| 129 | |
Josh Coalson | c10f978 | 2008-09-14 19:59:52 +0000 | [diff] [blame] | 130 | include $(topdir)/build/compile.mk |
Josh Coalson | 955a767 | 2001-05-03 02:24:39 +0000 | [diff] [blame] | 131 | |
Josh Coalson | bb7f6b9 | 2000-12-10 04:09:52 +0000 | [diff] [blame] | 132 | .PHONY : clean |
| 133 | clean : |
Josh Coalson | c10f978 | 2008-09-14 19:59:52 +0000 | [diff] [blame] | 134 | -rm -f $(DEBUG_OBJS) $(RELEASE_OBJS) $(DEBUG_PIC_OBJS) $(RELEASE_PIC_OBJS) $(OBJPATH)/*/lib/$(STATIC_LIB_NAME) $(OBJPATH)/*/lib/$(DYNAMIC_LIB_NAME) |
Josh Coalson | bb7f6b9 | 2000-12-10 04:09:52 +0000 | [diff] [blame] | 135 | |
| 136 | .PHONY : depend |
| 137 | depend: |
Josh Coalson | 5601bca | 2002-10-16 22:33:56 +0000 | [diff] [blame] | 138 | makedepend -fMakefile.lite -- $(CFLAGS) $(INCLUDES) -- *.c *.cc *.cpp |