lib.mk 4.03 KB
Newer Older
1
#  FLAC - Free Lossless Audio Codec
Josh Coalson's avatar
Josh Coalson committed
2
#  Copyright (C) 2001,2002,2003,2004  Josh Coalson
3
#
Josh Coalson's avatar
Josh Coalson committed
4
5
6
7
8
9
10
11
#  This file is part the FLAC project.  FLAC is comprised of several
#  components distributed under difference licenses.  The codec libraries
#  are distributed under Xiph.Org's BSD-like license (see the file
#  COPYING.Xiph in this distribution).  All other programs, libraries, and
#  plugins are distributed under the GPL (see COPYING.GPL).  The documentation
#  is distributed under the Gnu FDL (see COPYING.FDL).  Each file in the
#  FLAC distribution contains at the top the terms under which it may be
#  distributed.
12
#
Josh Coalson's avatar
Josh Coalson committed
13
14
15
16
#  Since this particular file is relevant to all components of FLAC,
#  it may be distributed under the Xiph.Org license, which is the least
#  restrictive of those mentioned above.  See the file COPYING.Xiph in this
#  distribution.
17

Josh Coalson's avatar
Josh Coalson committed
18
19
20
21
#
# GNU makefile fragment for building a library
#

22
23
include $(topdir)/build/config.mk

Josh Coalson's avatar
Josh Coalson committed
24
25
ifeq ($(DARWIN_BUILD),yes)
CC          = cc
26
CCC         = c++
Josh Coalson's avatar
Josh Coalson committed
27
else
Josh Coalson's avatar
Josh Coalson committed
28
CC          = gcc
29
CCC         = g++
Josh Coalson's avatar
Josh Coalson committed
30
endif
Josh Coalson's avatar
Josh Coalson committed
31
NASM        = nasm
Josh Coalson's avatar
Josh Coalson committed
32
LINK        = ar cru
33
34
35
36
OBJPATH     = $(topdir)/obj
LIBPATH     = $(OBJPATH)/$(BUILD)/lib
DEBUG_LIBPATH     = $(OBJPATH)/debug/lib
RELEASE_LIBPATH   = $(OBJPATH)/release/lib
Josh Coalson's avatar
Josh Coalson committed
37
ifeq ($(DARWIN_BUILD),yes)
38
39
STATIC_LIB_SUFFIX = a
DYNAMIC_LIB_SUFFIX = dylib
Josh Coalson's avatar
Josh Coalson committed
40
else
41
42
STATIC_LIB_SUFFIX = a
DYNAMIC_LIB_SUFFIX = so
Josh Coalson's avatar
Josh Coalson committed
43
endif
44
45
46
47
48
49
50
51
STATIC_LIB_NAME     = $(LIB_NAME).$(STATIC_LIB_SUFFIX)
DYNAMIC_LIB_NAME    = $(LIB_NAME).$(DYNAMIC_LIB_SUFFIX)
STATIC_LIB          = $(LIBPATH)/$(STATIC_LIB_NAME)
DYNAMIC_LIB         = $(LIBPATH)/$(DYNAMIC_LIB_NAME)
DEBUG_STATIC_LIB    = $(DEBUG_LIBPATH)/$(STATIC_LIB_NAME)
DEBUG_DYNAMIC_LIB   = $(DEBUG_LIBPATH)/$(DYNAMIC_LIB_NAME)
RELEASE_STATIC_LIB  = $(RELEASE_LIBPATH)/$(STATIC_LIB_NAME)
RELEASE_DYNAMIC_LIB = $(RELEASE_LIBPATH)/$(DYNAMIC_LIB_NAME)
Josh Coalson's avatar
Josh Coalson committed
52
ifeq ($(DARWIN_BUILD),yes)
53
LINKD       = $(CC) -dynamiclib -flat_namespace -undefined suppress -install_name $(DYNAMIC_LIB)
Josh Coalson's avatar
Josh Coalson committed
54
else
Josh Coalson's avatar
Josh Coalson committed
55
LINKD       = $(CC) -shared
Josh Coalson's avatar
Josh Coalson committed
56
endif
Josh Coalson's avatar
Josh Coalson committed
57

58
59
60
debug   : CFLAGS = -g -O0 -DDEBUG $(CONFIG_CFLAGS) $(DEBUG_CFLAGS) -Wall -W -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
valgrind: CFLAGS = -g -O0 -DDEBUG $(CONFIG_CFLAGS) -DFLAC__VALGRIND_TESTING -Wall -W -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
release : CFLAGS = -O3 -fomit-frame-pointer -funroll-loops -finline-functions -DNDEBUG $(CONFIG_CFLAGS) $(RELEASE_CFLAGS) -Wall -W -Winline -DFLaC__INLINE=__inline__ -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
Josh Coalson's avatar
Josh Coalson committed
61
62
63

LFLAGS  = -L$(LIBPATH)

64
65
66
67
DEBUG_OBJS = $(SRCS_C:%.c=%.debug.o) $(SRCS_CC:%.cc=%.debug.o) $(SRCS_CPP:%.cpp=%.debug.o) $(SRCS_NASM:%.nasm=%.debug.o)
RELEASE_OBJS = $(SRCS_C:%.c=%.release.o) $(SRCS_CC:%.cc=%.release.o) $(SRCS_CPP:%.cpp=%.release.o) $(SRCS_NASM:%.nasm=%.release.o)

debug   : $(ORDINALS_H) $(DEBUG_STATIC_LIB) $(DEBUG_DYNAMIC_LIB)
Josh Coalson's avatar
Josh Coalson committed
68
valgrind: $(ORDINALS_H) $(DEBUG_STATIC_LIB) $(DEBUG_DYNAMIC_LIB)
69
release : $(ORDINALS_H) $(RELEASE_STATIC_LIB) $(RELEASE_DYNAMIC_LIB)
Josh Coalson's avatar
Josh Coalson committed
70

71
72
73
74
75
76
77
78
79
80
81
82
$(DEBUG_STATIC_LIB): $(DEBUG_OBJS)
	$(LINK) $@ $(DEBUG_OBJS) && ranlib $@

$(RELEASE_STATIC_LIB): $(RELEASE_OBJS)
	$(LINK) $@ $(RELEASE_OBJS) && ranlib $@

$(DEBUG_DYNAMIC_LIB) : $(DEBUG_OBJS)
ifeq ($(DARWIN_BUILD),yes)
	$(LINKD) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS) -lc
else
	$(LINKD) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS)
endif
Josh Coalson's avatar
Josh Coalson committed
83

84
$(RELEASE_DYNAMIC_LIB) : $(RELEASE_OBJS)
Josh Coalson's avatar
Josh Coalson committed
85
ifeq ($(DARWIN_BUILD),yes)
86
	$(LINKD) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS) -lc
Josh Coalson's avatar
Josh Coalson committed
87
else
88
	$(LINKD) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS)
Josh Coalson's avatar
Josh Coalson committed
89
endif
Josh Coalson's avatar
Josh Coalson committed
90

91
%.debug.o %.release.o : %.c
Josh Coalson's avatar
Josh Coalson committed
92
	$(CC) $(CFLAGS) -c $< -o $@
93
%.debug.o %.release.o : %.cc
94
	$(CCC) $(CFLAGS) -c $< -o $@
95
%.debug.o %.release.o : %.cpp
Josh Coalson's avatar
Josh Coalson committed
96
	$(CCC) $(CFLAGS) -c $< -o $@
97
%.debug.i %.release.i : %.c
Josh Coalson's avatar
Josh Coalson committed
98
	$(CC) $(CFLAGS) -E $< -o $@
99
%.debug.i %.release.i : %.cc
100
	$(CCC) $(CFLAGS) -E $< -o $@
101
%.debug.i %.release.i : %.cpp
Josh Coalson's avatar
Josh Coalson committed
102
	$(CCC) $(CFLAGS) -E $< -o $@
Josh Coalson's avatar
Josh Coalson committed
103

104
%.debug.o %.release.o : %.nasm
Josh Coalson's avatar
Josh Coalson committed
105
	$(NASM) -f elf -d OBJ_FORMAT_elf -i ia32/ $< -o $@
Josh Coalson's avatar
Josh Coalson committed
106

Josh Coalson's avatar
Josh Coalson committed
107
108
.PHONY : clean
clean :
Josh Coalson's avatar
Josh Coalson committed
109
	-rm -f $(DEBUG_OBJS) $(RELEASE_OBJS) $(OBJPATH)/*/lib/$(STATIC_LIB_NAME) $(OBJPATH)/*/lib/$(DYNAMIC_LIB_NAME) $(ORDINALS_H)
Josh Coalson's avatar
Josh Coalson committed
110
111
112

.PHONY : depend
depend:
Josh Coalson's avatar
Josh Coalson committed
113
	makedepend -fMakefile.lite -- $(CFLAGS) $(INCLUDES) -- *.c *.cc *.cpp