d536a353ae4dc7cfe7b8b142edeac98a4d8745c5
[platform/upstream/flac.git] / build / exe.mk
1 #  FLAC - Free Lossless Audio Codec
2 #  Copyright (C) 2001,2002  Josh Coalson
3 #
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
18 #
19 # GNU makefile fragment for building an executable
20 #
21
22 ifeq ($(DARWIN_BUILD),yes)
23 CC          = cc
24 CCC         = c++
25 else
26 CC          = gcc
27 CCC         = g++
28 endif
29 NASM        = nasm
30 # LINKAGE can be forced to -static or -dynamic from invocation if desired, but it defaults to -static except on OSX
31 ifeq ($(DARWIN_BUILD),yes)
32 LINKAGE     = -dynamic
33 else
34 LINKAGE     = -static
35 endif
36 LINK        = $(CC) $(LINKAGE)
37 BINPATH     = ../../obj/bin
38 LIBPATH     = ../../obj/lib
39 PROGRAM     = $(BINPATH)/$(PROGRAM_NAME)
40
41 all : release
42
43 include ../../build/config.mk
44
45 debug   : CFLAGS = -g -O0 -DDEBUG $(DEBUG_CFLAGS) -Wall -W -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
46 release : CFLAGS = -O3 -fomit-frame-pointer -funroll-loops -finline-functions -DNDEBUG $(RELEASE_CFLAGS) -Wall -W -Winline -DFLaC__INLINE=__inline__ -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
47
48 LFLAGS  = -L$(LIBPATH)
49
50 debug   : $(ORDINALS_H) $(PROGRAM)
51 release : $(ORDINALS_H) $(PROGRAM)
52
53 $(PROGRAM) : $(OBJS)
54         $(LINK) -o $@ $(OBJS) $(LFLAGS) $(LIBS)
55
56 %.o : %.c
57         $(CC) $(CFLAGS) -c $< -o $@
58 %.o : %.cc
59         $(CCC) $(CFLAGS) -c $< -o $@
60 %.i : %.c
61         $(CC) $(CFLAGS) -E $< -o $@
62 %.i : %.cc
63         $(CCC) $(CFLAGS) -E $< -o $@
64
65 %.o : %.nasm
66         $(NASM) -f elf -d OBJ_FORMAT_elf -i ia32/ $< -o $@
67
68 .PHONY : clean
69 clean :
70         -rm -f $(OBJS) $(PROGRAM)
71
72 .PHONY : depend
73 depend:
74         makedepend -- $(CFLAGS) $(INCLUDES) -- *.c