1 # FLAC - Free Lossless Audio Codec
2 # Copyright (C) 2001,2002,2003 Josh Coalson
4 # This file is part the FLAC project. FLAC is comprised of several
5 # components distributed under difference licenses. The codec libraries
6 # are distributed under Xiph.Org's BSD-like license (see the file
7 # COPYING.Xiph in this distribution). All other programs, libraries, and
8 # plugins are distributed under the GPL (see COPYING.GPL). The documentation
9 # is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
10 # FLAC distribution contains at the top the terms under which it may be
13 # Since this particular file is relevant to all components of FLAC,
14 # it may be distributed under the Xiph.Org license, which is the least
15 # restrictive of those mentioned above. See the file COPYING.Xiph in this
19 # GNU makefile fragment for building a library
22 include $(topdir)/build/config.mk
24 ifeq ($(DARWIN_BUILD),yes)
33 OBJPATH = $(topdir)/obj
34 LIBPATH = $(OBJPATH)/$(BUILD)/lib
35 DEBUG_LIBPATH = $(OBJPATH)/debug/lib
36 RELEASE_LIBPATH = $(OBJPATH)/release/lib
37 ifeq ($(DARWIN_BUILD),yes)
39 DYNAMIC_LIB_SUFFIX = dylib
42 DYNAMIC_LIB_SUFFIX = so
44 STATIC_LIB_NAME = $(LIB_NAME).$(STATIC_LIB_SUFFIX)
45 DYNAMIC_LIB_NAME = $(LIB_NAME).$(DYNAMIC_LIB_SUFFIX)
46 STATIC_LIB = $(LIBPATH)/$(STATIC_LIB_NAME)
47 DYNAMIC_LIB = $(LIBPATH)/$(DYNAMIC_LIB_NAME)
48 DEBUG_STATIC_LIB = $(DEBUG_LIBPATH)/$(STATIC_LIB_NAME)
49 DEBUG_DYNAMIC_LIB = $(DEBUG_LIBPATH)/$(DYNAMIC_LIB_NAME)
50 RELEASE_STATIC_LIB = $(RELEASE_LIBPATH)/$(STATIC_LIB_NAME)
51 RELEASE_DYNAMIC_LIB = $(RELEASE_LIBPATH)/$(DYNAMIC_LIB_NAME)
52 ifeq ($(DARWIN_BUILD),yes)
53 LINKD = $(CC) -dynamiclib -flat_namespace -undefined suppress -install_name $(DYNAMIC_LIB)
58 debug : CFLAGS = -g -O0 -DDEBUG $(DEBUG_CFLAGS) -Wall -W -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
59 valgrind: CFLAGS = -g -O0 -DDEBUG $(DEBUG_CFLAGS) -DFLAC__VALGRIND_TESTING -Wall -W -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
60 release : CFLAGS = -O3 -fomit-frame-pointer -funroll-loops -finline-functions -DNDEBUG $(RELEASE_CFLAGS) -Wall -W -Winline -DFLaC__INLINE=__inline__ -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
64 DEBUG_OBJS = $(SRCS_C:%.c=%.debug.o) $(SRCS_CC:%.cc=%.debug.o) $(SRCS_CPP:%.cpp=%.debug.o) $(SRCS_NASM:%.nasm=%.debug.o)
65 RELEASE_OBJS = $(SRCS_C:%.c=%.release.o) $(SRCS_CC:%.cc=%.release.o) $(SRCS_CPP:%.cpp=%.release.o) $(SRCS_NASM:%.nasm=%.release.o)
67 debug : $(ORDINALS_H) $(DEBUG_STATIC_LIB) $(DEBUG_DYNAMIC_LIB)
68 valgrind: $(ORDINALS_H) $(DEBUG_STATIC_LIB) $(DEBUG_DYNAMIC_LIB)
69 release : $(ORDINALS_H) $(RELEASE_STATIC_LIB) $(RELEASE_DYNAMIC_LIB)
71 $(DEBUG_STATIC_LIB): $(DEBUG_OBJS)
72 $(LINK) $@ $(DEBUG_OBJS) && ranlib $@
74 $(RELEASE_STATIC_LIB): $(RELEASE_OBJS)
75 $(LINK) $@ $(RELEASE_OBJS) && ranlib $@
77 $(DEBUG_DYNAMIC_LIB) : $(DEBUG_OBJS)
78 ifeq ($(DARWIN_BUILD),yes)
79 $(LINKD) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS) -lc
81 $(LINKD) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS)
84 $(RELEASE_DYNAMIC_LIB) : $(RELEASE_OBJS)
85 ifeq ($(DARWIN_BUILD),yes)
86 $(LINKD) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS) -lc
88 $(LINKD) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS)
91 %.debug.o %.release.o : %.c
92 $(CC) $(CFLAGS) -c $< -o $@
93 %.debug.o %.release.o : %.cc
94 $(CCC) $(CFLAGS) -c $< -o $@
95 %.debug.o %.release.o : %.cpp
96 $(CCC) $(CFLAGS) -c $< -o $@
97 %.debug.i %.release.i : %.c
98 $(CC) $(CFLAGS) -E $< -o $@
99 %.debug.i %.release.i : %.cc
100 $(CCC) $(CFLAGS) -E $< -o $@
101 %.debug.i %.release.i : %.cpp
102 $(CCC) $(CFLAGS) -E $< -o $@
104 %.debug.o %.release.o : %.nasm
105 $(NASM) -f elf -d OBJ_FORMAT_elf -i ia32/ $< -o $@
109 -rm -f $(DEBUG_OBJS) $(RELEASE_OBJS) $(OBJPATH)/*/lib/$(STATIC_LIB_NAME) $(OBJPATH)/*/lib/$(DYNAMIC_LIB_NAME) $(ORDINALS_H)
113 makedepend -fMakefile.lite -- $(CFLAGS) $(INCLUDES) -- *.c *.cc *.cpp