blob: 45d4f237eb63eb23e8ae65ccdf244520c19c5b3a [file] [log] [blame]
Josh Coalson6b05bc52001-06-08 00:13:21 +00001# FLAC - Free Lossless Audio Codec
Josh Coalson1152f9f2002-01-26 18:05:12 +00002# Copyright (C) 2001,2002 Josh Coalson
Josh Coalson6b05bc52001-06-08 00:13:21 +00003#
4# This program is part of FLAC; you can redistribute it and/or
5# modify it under the terms of the GNU General Public License
6# as published by the Free Software Foundation; either version 2
7# of the License, or (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000018#
19# GNU makefile fragment for building a library
20#
21
Josh Coalson6e144902001-12-07 19:28:25 +000022ifeq ($(DARWIN_BUILD),yes)
23CC = cc
Josh Coalsonb7557fd2002-05-17 06:08:44 +000024CCC = c++
Josh Coalson6e144902001-12-07 19:28:25 +000025else
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000026CC = gcc
Josh Coalsonb7557fd2002-05-17 06:08:44 +000027CCC = g++
Josh Coalson6e144902001-12-07 19:28:25 +000028endif
Josh Coalson955a7672001-05-03 02:24:39 +000029NASM = nasm
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000030LINK = ar cru
Josh Coalson1ce20ee2002-08-14 00:50:48 +000031LIBPATH = ../../obj/lib
Josh Coalson6e144902001-12-07 19:28:25 +000032ifeq ($(DARWIN_BUILD),yes)
Josh Coalson1ce20ee2002-08-14 00:50:48 +000033STATIC_LIB_SUFFIX = a
34DYNAMIC_LIB_SUFFIX = dylib
35else
36STATIC_LIB_SUFFIX = a
37DYNAMIC_LIB_SUFFIX = so
38endif
39STATIC_LIB = $(LIBPATH)/$(LIB_NAME).$(STATIC_LIB_SUFFIX)
40DYNAMIC_LIB = $(LIBPATH)/$(LIB_NAME).$(DYNAMIC_LIB_SUFFIX)
41ifeq ($(DARWIN_BUILD),yes)
42LINKD = $(CC) -dynamiclib -flat_namespace -undefined suppress -install_name $(DYNAMIC_LIB)
Josh Coalson6e144902001-12-07 19:28:25 +000043else
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000044LINKD = ld -G
Josh Coalson6e144902001-12-07 19:28:25 +000045endif
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000046
47all : release
48
Josh Coalson6ca4b1b2001-06-29 02:54:59 +000049include ../../build/config.mk
50
51debug : CFLAGS = -g -O0 -DDEBUG $(DEBUG_CFLAGS) -Wall -W -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
Josh Coalson9bab0412001-07-20 23:44:35 +000052release : CFLAGS = -O3 -fomit-frame-pointer -funroll-loops -finline-functions -DNDEBUG $(RELEASE_CFLAGS) -Wall -W -Winline -DFLaC__INLINE=__inline__ -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000053
54LFLAGS = -L$(LIBPATH)
55
Josh Coalson6ca4b1b2001-06-29 02:54:59 +000056debug : $(ORDINALS_H) $(STATIC_LIB) $(DYNAMIC_LIB)
57release : $(ORDINALS_H) $(STATIC_LIB) $(DYNAMIC_LIB)
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000058
59$(STATIC_LIB) : $(OBJS)
Josh Coalson6e144902001-12-07 19:28:25 +000060 $(LINK) $@ $(OBJS) && ranlib $@
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000061
62$(DYNAMIC_LIB) : $(OBJS)
Josh Coalson6e144902001-12-07 19:28:25 +000063ifeq ($(DARWIN_BUILD),yes)
64 $(LINKD) -o $@ $(OBJS) $(LFLAGS) $(LIBS) -lc
65else
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000066 $(LINKD) -o $@ $(OBJS) $(LFLAGS) $(LIBS)
Josh Coalson6e144902001-12-07 19:28:25 +000067endif
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000068
69%.o : %.c
70 $(CC) $(CFLAGS) -c $< -o $@
Josh Coalsonb7557fd2002-05-17 06:08:44 +000071%.o : %.cc
72 $(CCC) $(CFLAGS) -c $< -o $@
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000073%.i : %.c
74 $(CC) $(CFLAGS) -E $< -o $@
Josh Coalsonb7557fd2002-05-17 06:08:44 +000075%.i : %.cc
76 $(CCC) $(CFLAGS) -E $< -o $@
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000077
Josh Coalson22558482001-06-13 18:04:47 +000078%.o : %.nasm
Josh Coalson1162f182001-06-19 06:48:21 +000079 $(NASM) -f elf -d OBJ_FORMAT_elf -i ia32/ $< -o $@
Josh Coalson955a7672001-05-03 02:24:39 +000080
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000081.PHONY : clean
82clean :
Josh Coalson6ca4b1b2001-06-29 02:54:59 +000083 -rm -f $(OBJS) $(STATIC_LIB) $(DYNAMIC_LIB) $(ORDINALS_H)
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000084
85.PHONY : depend
86depend:
Josh Coalson087a5d22002-07-18 05:33:06 +000087 makedepend -fMakefile.lite -- $(CFLAGS) $(INCLUDES) -- *.c *.cc