blob: 6bf149e36c26e9766d454d052e9210329da41d09 [file] [log] [blame]
Josh Coalson6b05bc52001-06-08 00:13:21 +00001# FLAC - Free Lossless Audio Codec
Erik de Castro Lopob1982fb2013-05-25 17:11:19 +10002# Copyright (C) 2001-2009 Josh Coalson
Erik de Castro Lopo14373912014-11-24 22:07:15 +11003# Copyright (C) 2011-2014 Xiph.Org Foundation
Josh Coalson6b05bc52001-06-08 00:13:21 +00004#
Josh Coalsone8a76012003-02-07 00:14:32 +00005# This file is part the FLAC project. FLAC is comprised of several
Ulrich Klauercd4ddab2013-05-26 22:53:43 +02006# components distributed under different licenses. The codec libraries
Josh Coalsone8a76012003-02-07 00:14:32 +00007# 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 Coalson6b05bc52001-06-08 00:13:21 +000013#
Josh Coalsone8a76012003-02-07 00:14:32 +000014# 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 Coalson6b05bc52001-06-08 00:13:21 +000018
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000019#
20# GNU makefile fragment for building an executable
21#
22
Josh Coalsonb74fc982002-11-20 06:40:08 +000023include $(topdir)/build/config.mk
24
Josh Coalsonc10f9782008-09-14 19:59:52 +000025ifeq ($(OS),Darwin)
Hendricks26696d081c2012-12-29 04:22:59 -060026 CC = cc
27 CCC = c++
Josh Coalson6e144902001-12-07 19:28:25 +000028else
Hendricks26696d081c2012-12-29 04:22:59 -060029 CC = gcc
30 CCC = g++
Josh Coalson6e144902001-12-07 19:28:25 +000031endif
Josh Coalson955a7672001-05-03 02:24:39 +000032NASM = nasm
Josh Coalson6e144902001-12-07 19:28:25 +000033LINK = $(CC) $(LINKAGE)
Erik de Castro Lopo85d5c532013-01-02 22:37:42 +110034OBJPATH = $(topdir)/objs
Josh Coalsonb74fc982002-11-20 06:40:08 +000035BINPATH = $(OBJPATH)/$(BUILD)/bin
36LIBPATH = $(OBJPATH)/$(BUILD)/lib
37DEBUG_BINPATH = $(OBJPATH)/debug/bin
38DEBUG_LIBPATH = $(OBJPATH)/debug/lib
39RELEASE_BINPATH = $(OBJPATH)/release/bin
40RELEASE_LIBPATH = $(OBJPATH)/release/lib
41PROGRAM = $(BINPATH)/$(PROGRAM_NAME)
42DEBUG_PROGRAM = $(DEBUG_BINPATH)/$(PROGRAM_NAME)
43RELEASE_PROGRAM = $(RELEASE_BINPATH)/$(PROGRAM_NAME)
Josh Coalson6ca4b1b2001-06-29 02:54:59 +000044
Evan Ramos9df67362014-06-23 16:24:49 -050045debug : CFLAGS = -g -O0 -DDEBUG $(CONFIG_CFLAGS) $(DEBUG_CFLAGS) -W -Wall -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
46valgrind: CFLAGS = -g -O0 -DDEBUG $(CONFIG_CFLAGS) $(DEBUG_CFLAGS) -DFLAC__VALGRIND_TESTING -W -Wall -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
47release : CFLAGS = -O3 -fomit-frame-pointer -funroll-loops -finline-functions -DNDEBUG $(CONFIG_CFLAGS) $(RELEASE_CFLAGS) -W -Wall -Winline -DFLaC__INLINE=__inline__ -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000048
Evan Ramos9df67362014-06-23 16:24:49 -050049CFLAGS = $(CFLAGS) -Wmissing-prototypes -Wstrict-prototypes
50CXXFLAGS = $(CFLAGS)
51
52LFLAGS = -L$(LIBPATH)
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000053
Erik de Castro Lopob60f16b2014-07-13 21:19:48 +100054DEBUG_OBJS = $(SRCS_C:%.c=%.debug.o) $(SRCS_CC:%.cc=%.debug.o) $(SRCS_CPP:%.cpp=%.debug.o) $(SRCS_NASM:%.nasm=%.debug.o)
55RELEASE_OBJS = $(SRCS_C:%.c=%.release.o) $(SRCS_CC:%.cc=%.release.o) $(SRCS_CPP:%.cpp=%.release.o) $(SRCS_NASM:%.nasm=%.release.o)
Josh Coalsonc10f9782008-09-14 19:59:52 +000056ifeq ($(PROC),x86_64)
Erik de Castro Lopob60f16b2014-07-13 21:19:48 +100057DEBUG_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)
58RELEASE_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 Coalsonc10f9782008-09-14 19:59:52 +000059endif
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000060
Josh Coalsonf8ecdde2004-12-30 03:56:08 +000061debug : $(DEBUG_PROGRAM)
62valgrind: $(DEBUG_PROGRAM)
63release : $(RELEASE_PROGRAM)
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000064
Josh Coalson2757af62004-10-30 00:03:21 +000065# by default on OS X we link with static libs as much as possible
66
Josh Coalsonc10f9782008-09-14 19:59:52 +000067$(DEBUG_PROGRAM) : $(DEBUG_OBJS) $(DEBUG_PIC_OBJS)
68ifeq ($(OS),Darwin)
Josh Coalson2757af62004-10-30 00:03:21 +000069 $(LINK) -o $@ $(DEBUG_OBJS) $(EXPLICIT_LIBS)
70else
Josh Coalsonb74fc982002-11-20 06:40:08 +000071 $(LINK) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS)
Josh Coalson2757af62004-10-30 00:03:21 +000072endif
Josh Coalsonb74fc982002-11-20 06:40:08 +000073
Josh Coalsonc10f9782008-09-14 19:59:52 +000074$(RELEASE_PROGRAM) : $(RELEASE_OBJS) $(RELEASE_PIC_OBJS)
75ifeq ($(OS),Darwin)
Josh Coalson2757af62004-10-30 00:03:21 +000076 $(LINK) -o $@ $(RELEASE_OBJS) $(EXPLICIT_LIBS)
77else
Josh Coalsonb74fc982002-11-20 06:40:08 +000078 $(LINK) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS)
Josh Coalson2757af62004-10-30 00:03:21 +000079endif
Josh Coalsonb74fc982002-11-20 06:40:08 +000080
Josh Coalsonc10f9782008-09-14 19:59:52 +000081include $(topdir)/build/compile.mk
Josh Coalson955a7672001-05-03 02:24:39 +000082
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000083.PHONY : clean
84clean :
Josh Coalsonc10f9782008-09-14 19:59:52 +000085 -rm -f $(DEBUG_OBJS) $(RELEASE_OBJS) $(DEBUG_PIC_OBJS) $(RELEASE_PIC_OBJS) $(OBJPATH)/*/bin/$(PROGRAM_NAME)
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000086
87.PHONY : depend
88depend:
Josh Coalson5601bca2002-10-16 22:33:56 +000089 makedepend -fMakefile.lite -- $(CFLAGS) $(INCLUDES) -- *.c *.cc *.cpp