better clean target
[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 include $(topdir)/build/config.mk
23
24 ifeq ($(DARWIN_BUILD),yes)
25 CC          = cc
26 CCC         = c++
27 else
28 CC          = gcc
29 CCC         = g++
30 endif
31 NASM        = nasm
32 # LINKAGE can be forced to -static or -dynamic from invocation if desired, but it defaults to -static except on OSX
33 ifeq ($(DARWIN_BUILD),yes)
34 LINKAGE     = -dynamic
35 else
36 LINKAGE     = -static
37 endif
38 LINK        = $(CC) $(LINKAGE)
39 OBJPATH     = $(topdir)/obj
40 BINPATH     = $(OBJPATH)/$(BUILD)/bin
41 LIBPATH     = $(OBJPATH)/$(BUILD)/lib
42 DEBUG_BINPATH   = $(OBJPATH)/debug/bin
43 DEBUG_LIBPATH   = $(OBJPATH)/debug/lib
44 RELEASE_BINPATH = $(OBJPATH)/release/bin
45 RELEASE_LIBPATH = $(OBJPATH)/release/lib
46 PROGRAM         = $(BINPATH)/$(PROGRAM_NAME)
47 DEBUG_PROGRAM   = $(DEBUG_BINPATH)/$(PROGRAM_NAME)
48 RELEASE_PROGRAM = $(RELEASE_BINPATH)/$(PROGRAM_NAME)
49
50 debug   : CFLAGS = -g -O0 -DDEBUG $(DEBUG_CFLAGS) -Wall -W -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
51 release : CFLAGS = -O3 -fomit-frame-pointer -funroll-loops -finline-functions -DNDEBUG $(RELEASE_CFLAGS) -Wall -W -Winline -DFLaC__INLINE=__inline__ -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
52
53 LFLAGS  = -L$(LIBPATH)
54
55 #@@@ OBJS = $(SRCS_C:%.c=%.o) $(SRCS_CC:%.cc=%.o) $(SRCS_CPP:%.cpp=%.o) $(SRCS_NASM:%.nasm=%.o)
56 #@@@ OBJS = $(SRCS_C:%.c=%.$(BUILD).o) $(SRCS_CC:%.cc=%.$(BUILD).o) $(SRCS_CPP:%.cpp=%.$(BUILD).o) $(SRCS_NASM:%.nasm=%.$(BUILD).o)
57 DEBUG_OBJS = $(SRCS_C:%.c=%.debug.o) $(SRCS_CC:%.cc=%.debug.o) $(SRCS_CPP:%.cpp=%.debug.o) $(SRCS_NASM:%.nasm=%.debug.o)
58 RELEASE_OBJS = $(SRCS_C:%.c=%.release.o) $(SRCS_CC:%.cc=%.release.o) $(SRCS_CPP:%.cpp=%.release.o) $(SRCS_NASM:%.nasm=%.release.o)
59
60 debug   : $(ORDINALS_H) $(DEBUG_PROGRAM)
61 release : $(ORDINALS_H) $(RELEASE_PROGRAM)
62
63 $(DEBUG_PROGRAM) : $(DEBUG_OBJS)
64         $(LINK) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS)
65
66 $(RELEASE_PROGRAM) : $(RELEASE_OBJS)
67         $(LINK) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS)
68
69 %.debug.o %.release.o : %.c
70         $(CC) $(CFLAGS) -c $< -o $@
71 %.debug.o %.release.o : %.cc
72         $(CCC) $(CFLAGS) -c $< -o $@
73 %.debug.o %.release.o : %.cpp
74         $(CCC) $(CFLAGS) -c $< -o $@
75 %.debug.i %.release.i : %.c
76         $(CC) $(CFLAGS) -E $< -o $@
77 %.debug.i %.release.i : %.cc
78         $(CCC) $(CFLAGS) -E $< -o $@
79 %.debug.i %.release.i : %.cpp
80         $(CCC) $(CFLAGS) -E $< -o $@
81
82 %.debug.o %.release.o : %.nasm
83         $(NASM) -f elf -d OBJ_FORMAT_elf -i ia32/ $< -o $@
84
85 .PHONY : clean
86 clean :
87         -rm -f $(DEBUG_OBJS) $(RELEASE_OBJS) $(OBJPATH)/*/bin/$(PROGRAM_NAME)
88
89 .PHONY : depend
90 depend:
91         makedepend -fMakefile.lite -- $(CFLAGS) $(INCLUDES) -- *.c *.cc *.cpp