Ensure AM_LDFLAGS is used consistently
[platform/upstream/flac.git] / build / exe.mk
1 #  FLAC - Free Lossless Audio Codec
2 #  Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009  Josh Coalson
3 #
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
11 #  distributed.
12 #
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
16 #  distribution.
17
18 #
19 # GNU makefile fragment for building an executable
20 #
21
22 include $(topdir)/build/config.mk
23
24 ifeq ($(OS),Darwin)
25     CC          = cc
26     CCC         = c++
27 else
28     CC          = gcc
29     CCC         = g++
30 endif
31 NASM        = nasm
32 LINK        = $(CC) $(LINKAGE)
33 OBJPATH     = $(topdir)/objs
34 BINPATH     = $(OBJPATH)/$(BUILD)/bin
35 LIBPATH     = $(OBJPATH)/$(BUILD)/lib
36 DEBUG_BINPATH   = $(OBJPATH)/debug/bin
37 DEBUG_LIBPATH   = $(OBJPATH)/debug/lib
38 RELEASE_BINPATH = $(OBJPATH)/release/bin
39 RELEASE_LIBPATH = $(OBJPATH)/release/lib
40 PROGRAM         = $(BINPATH)/$(PROGRAM_NAME)
41 DEBUG_PROGRAM   = $(DEBUG_BINPATH)/$(PROGRAM_NAME)
42 RELEASE_PROGRAM = $(RELEASE_BINPATH)/$(PROGRAM_NAME)
43
44 debug   : CFLAGS = -g -O0 -DDEBUG $(CONFIG_CFLAGS) $(DEBUG_CFLAGS) -W -Wall -Wmissing-prototypes -Wstrict-prototypes -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
45 valgrind: CFLAGS = -g -O0 -DDEBUG $(CONFIG_CFLAGS) $(DEBUG_CFLAGS) -DFLAC__VALGRIND_TESTING -W -Wall -Wmissing-prototypes -Wstrict-prototypes -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
46 release : CFLAGS = -O3 -fomit-frame-pointer -funroll-loops -finline-functions -DNDEBUG $(CONFIG_CFLAGS) $(RELEASE_CFLAGS) -W -Wall -Wmissing-prototypes -Wstrict-prototypes -Winline -DFLaC__INLINE=__inline__ -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
47
48 LFLAGS  = -L$(LIBPATH)
49
50 DEBUG_OBJS = $(SRCS_C:%.c=%.debug.o) $(SRCS_CC:%.cc=%.debug.o) $(SRCS_CPP:%.cpp=%.debug.o) $(SRCS_NASM:%.nasm=%.debug.o) $(SRCS_S:%.s=%.debug.o)
51 RELEASE_OBJS = $(SRCS_C:%.c=%.release.o) $(SRCS_CC:%.cc=%.release.o) $(SRCS_CPP:%.cpp=%.release.o) $(SRCS_NASM:%.nasm=%.release.o) $(SRCS_S:%.s=%.release.o)
52 ifeq ($(PROC),x86_64)
53 DEBUG_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) $(SRCS_S:%.s=%.debug.pic.o)
54 RELEASE_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) $(SRCS_S:%.s=%.release.pic.o)
55 endif
56
57 debug   : $(DEBUG_PROGRAM)
58 valgrind: $(DEBUG_PROGRAM)
59 release : $(RELEASE_PROGRAM)
60
61 # by default on OS X we link with static libs as much as possible
62
63 $(DEBUG_PROGRAM) : $(DEBUG_OBJS) $(DEBUG_PIC_OBJS)
64 ifeq ($(OS),Darwin)
65         $(LINK) -o $@ $(DEBUG_OBJS) $(EXPLICIT_LIBS)
66 else
67         $(LINK) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS)
68 endif
69
70 $(RELEASE_PROGRAM) : $(RELEASE_OBJS) $(RELEASE_PIC_OBJS)
71 ifeq ($(OS),Darwin)
72         $(LINK) -o $@ $(RELEASE_OBJS) $(EXPLICIT_LIBS)
73 else
74         $(LINK) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS)
75 endif
76
77 include $(topdir)/build/compile.mk
78
79 .PHONY : clean
80 clean :
81         -rm -f $(DEBUG_OBJS) $(RELEASE_OBJS) $(DEBUG_PIC_OBJS) $(RELEASE_PIC_OBJS) $(OBJPATH)/*/bin/$(PROGRAM_NAME)
82
83 .PHONY : depend
84 depend:
85         makedepend -fMakefile.lite -- $(CFLAGS) $(INCLUDES) -- *.c *.cc *.cpp