1# FLAC - Free Lossless Audio Codec 2# Copyright (C) 2001-2009 Josh Coalson 3# Copyright (C) 2011-2016 Xiph.Org Foundation 4# 5# This file is part the FLAC project. FLAC is comprised of several 6# components distributed under different licenses. The codec libraries 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. 13# 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. 18 19# 20# GNU makefile fragment for building an executable 21# 22 23include $(topdir)/build/config.mk 24 25ifeq ($(OS),Darwin) 26 CC = cc 27 CCC = c++ 28else 29ifeq ($(OS),FreeBSD) 30 CC = cc 31 CCC = c++ 32else 33 CC = gcc 34 CCC = g++ 35endif 36endif 37ifeq ($(CC),gcc) 38 GCC_INLINE = -finline-functions 39endif 40NASM = nasm 41LINK = $(CC) $(LINKAGE) 42OBJPATH = $(topdir)/objs 43BINPATH = $(OBJPATH)/$(BUILD)/bin 44LIBPATH = $(OBJPATH)/$(BUILD)/lib 45DEBUG_BINPATH = $(OBJPATH)/debug/bin 46DEBUG_LIBPATH = $(OBJPATH)/debug/lib 47RELEASE_BINPATH = $(OBJPATH)/release/bin 48RELEASE_LIBPATH = $(OBJPATH)/release/lib 49PROGRAM = $(BINPATH)/$(PROGRAM_NAME) 50DEBUG_PROGRAM = $(DEBUG_BINPATH)/$(PROGRAM_NAME) 51RELEASE_PROGRAM = $(RELEASE_BINPATH)/$(PROGRAM_NAME) 52 53BASE_CFLAGS = -Wall -Wextra $(CONFIG_CFLAGS) -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES) 54 55ifeq ($(DEFAULT_BUILD),debug) 56CFLAGS := -g -O0 -DDEBUG $(CFLAGS) $(BASE_CFLAGS) -Wmissing-prototypes -Wstrict-prototypes 57CXXFLAGS := -g -O0 -DDEBUG $(CXXFLAGS) $(BASE_CFLAGS) 58endif 59 60ifeq ($(DEFAULT_BUILD),valgrind) 61CFLAGS := -g -O0 -DDEBUG -DDEBUG -DFLAC__VALGRIND_TESTING $(CFLAGS) $(BASE_CFLAGS) -Wmissing-prototypes -Wstrict-prototypes 62CXXFLAGS := -g -O0 -DDEBUG -DDEBUG -DFLAC__VALGRIND_TESTING $(CXXFLAGS) $(BASE_CFLAGS) 63endif 64 65ifeq ($(DEFAULT_BUILD),release) 66CFLAGS := -O3 -fomit-frame-pointer -funroll-loops $(GCC_INLINE) -DFLaC__INLINE=__inline__ -DNDEBUG $(CFLAGS) $(BASE_CFLAGS) -Wmissing-prototypes -Wstrict-prototypes 67CXXFLAGS := -O3 -fomit-frame-pointer -funroll-loops $(GCC_INLINE) -DFLaC__INLINE=__inline__ -DNDEBUG $(CXXFLAGS) $(BASE_CFLAGS) 68endif 69 70LFLAGS = -L$(LIBPATH) 71 72DEBUG_OBJS = $(SRCS_C:%.c=%.debug.o) $(SRCS_CC:%.cc=%.debug.o) $(SRCS_CPP:%.cpp=%.debug.o) $(SRCS_NASM:%.nasm=%.debug.o) 73RELEASE_OBJS = $(SRCS_C:%.c=%.release.o) $(SRCS_CC:%.cc=%.release.o) $(SRCS_CPP:%.cpp=%.release.o) $(SRCS_NASM:%.nasm=%.release.o) 74ifeq ($(PROC),x86_64) 75DEBUG_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) 76RELEASE_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) 77endif 78 79debug : $(DEBUG_PROGRAM) 80valgrind: $(DEBUG_PROGRAM) 81release : $(RELEASE_PROGRAM) 82 83# by default on OS X we link with static libs as much as possible 84 85$(DEBUG_PROGRAM) : $(DEBUG_OBJS) $(DEBUG_PIC_OBJS) 86ifeq ($(OS),Darwin) 87 $(LINK) -o $@ $(DEBUG_OBJS) $(EXPLICIT_LIBS) 88else 89 $(LINK) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS) 90endif 91 92$(RELEASE_PROGRAM) : $(RELEASE_OBJS) $(RELEASE_PIC_OBJS) 93ifeq ($(OS),Darwin) 94 $(LINK) -o $@ $(RELEASE_OBJS) $(EXPLICIT_LIBS) 95else 96 $(LINK) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS) 97endif 98 99include $(topdir)/build/compile.mk 100 101.PHONY : clean 102clean : 103 -rm -f $(DEBUG_OBJS) $(RELEASE_OBJS) $(DEBUG_PIC_OBJS) $(RELEASE_PIC_OBJS) $(OBJPATH)/*/bin/$(PROGRAM_NAME) 104 105.PHONY : depend 106depend: 107 makedepend -fMakefile.lite -- $(CFLAGS) $(INCLUDES) -- *.c *.cc *.cpp 108