blob: 99af7d577765dee648503064fb2ccf6eb72b2ca9 [file] [log] [blame]
Josh Coalson6b05bc52001-06-08 00:13:21 +00001# FLAC - Free Lossless Audio Codec
Josh Coalson1152f9f2002-01-26 18:05:12 +00002# Copyright (C) 2001,2002 Josh Coalson
Josh Coalson6b05bc52001-06-08 00:13:21 +00003#
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
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000018#
19# GNU makefile fragment for building an executable
20#
21
Josh Coalsonb74fc982002-11-20 06:40:08 +000022include $(topdir)/build/config.mk
23
Josh Coalson6e144902001-12-07 19:28:25 +000024ifeq ($(DARWIN_BUILD),yes)
25CC = cc
Josh Coalsonb7557fd2002-05-17 06:08:44 +000026CCC = c++
Josh Coalson6e144902001-12-07 19:28:25 +000027else
Josh Coalson955a7672001-05-03 02:24:39 +000028CC = gcc
Josh Coalsonb7557fd2002-05-17 06:08:44 +000029CCC = g++
Josh Coalson6e144902001-12-07 19:28:25 +000030endif
Josh Coalson955a7672001-05-03 02:24:39 +000031NASM = nasm
Josh Coalson6e144902001-12-07 19:28:25 +000032# LINKAGE can be forced to -static or -dynamic from invocation if desired, but it defaults to -static except on OSX
33ifeq ($(DARWIN_BUILD),yes)
34LINKAGE = -dynamic
35else
Josh Coalson955a7672001-05-03 02:24:39 +000036LINKAGE = -static
Josh Coalson6e144902001-12-07 19:28:25 +000037endif
38LINK = $(CC) $(LINKAGE)
Josh Coalsonb74fc982002-11-20 06:40:08 +000039OBJPATH = $(topdir)/obj
40BINPATH = $(OBJPATH)/$(BUILD)/bin
41LIBPATH = $(OBJPATH)/$(BUILD)/lib
42DEBUG_BINPATH = $(OBJPATH)/debug/bin
43DEBUG_LIBPATH = $(OBJPATH)/debug/lib
44RELEASE_BINPATH = $(OBJPATH)/release/bin
45RELEASE_LIBPATH = $(OBJPATH)/release/lib
46PROGRAM = $(BINPATH)/$(PROGRAM_NAME)
47DEBUG_PROGRAM = $(DEBUG_BINPATH)/$(PROGRAM_NAME)
48RELEASE_PROGRAM = $(RELEASE_BINPATH)/$(PROGRAM_NAME)
Josh Coalson6ca4b1b2001-06-29 02:54:59 +000049
50debug : CFLAGS = -g -O0 -DDEBUG $(DEBUG_CFLAGS) -Wall -W -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
Josh Coalson9bab0412001-07-20 23:44:35 +000051release : CFLAGS = -O3 -fomit-frame-pointer -funroll-loops -finline-functions -DNDEBUG $(RELEASE_CFLAGS) -Wall -W -Winline -DFLaC__INLINE=__inline__ -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000052
53LFLAGS = -L$(LIBPATH)
54
Josh Coalsonb74fc982002-11-20 06:40:08 +000055#@@@ 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)
57DEBUG_OBJS = $(SRCS_C:%.c=%.debug.o) $(SRCS_CC:%.cc=%.debug.o) $(SRCS_CPP:%.cpp=%.debug.o) $(SRCS_NASM:%.nasm=%.debug.o)
58RELEASE_OBJS = $(SRCS_C:%.c=%.release.o) $(SRCS_CC:%.cc=%.release.o) $(SRCS_CPP:%.cpp=%.release.o) $(SRCS_NASM:%.nasm=%.release.o)
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000059
Josh Coalsonb74fc982002-11-20 06:40:08 +000060debug : $(ORDINALS_H) $(DEBUG_PROGRAM)
61release : $(ORDINALS_H) $(RELEASE_PROGRAM)
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000062
Josh Coalsonb74fc982002-11-20 06:40:08 +000063$(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
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000070 $(CC) $(CFLAGS) -c $< -o $@
Josh Coalsonb74fc982002-11-20 06:40:08 +000071%.debug.o %.release.o : %.cc
Josh Coalsonb7557fd2002-05-17 06:08:44 +000072 $(CCC) $(CFLAGS) -c $< -o $@
Josh Coalsonb74fc982002-11-20 06:40:08 +000073%.debug.o %.release.o : %.cpp
Josh Coalson5601bca2002-10-16 22:33:56 +000074 $(CCC) $(CFLAGS) -c $< -o $@
Josh Coalsonb74fc982002-11-20 06:40:08 +000075%.debug.i %.release.i : %.c
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000076 $(CC) $(CFLAGS) -E $< -o $@
Josh Coalsonb74fc982002-11-20 06:40:08 +000077%.debug.i %.release.i : %.cc
Josh Coalsonb7557fd2002-05-17 06:08:44 +000078 $(CCC) $(CFLAGS) -E $< -o $@
Josh Coalsonb74fc982002-11-20 06:40:08 +000079%.debug.i %.release.i : %.cpp
Josh Coalson5601bca2002-10-16 22:33:56 +000080 $(CCC) $(CFLAGS) -E $< -o $@
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000081
Josh Coalsonb74fc982002-11-20 06:40:08 +000082%.debug.o %.release.o : %.nasm
Josh Coalson1162f182001-06-19 06:48:21 +000083 $(NASM) -f elf -d OBJ_FORMAT_elf -i ia32/ $< -o $@
Josh Coalson955a7672001-05-03 02:24:39 +000084
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000085.PHONY : clean
86clean :
Josh Coalsonb74fc982002-11-20 06:40:08 +000087 -rm -f *.o $(OBJPATH)/*/bin/$(PROGRAM_NAME)
Josh Coalsonbb7f6b92000-12-10 04:09:52 +000088
89.PHONY : depend
90depend:
Josh Coalson5601bca2002-10-16 22:33:56 +000091 makedepend -fMakefile.lite -- $(CFLAGS) $(INCLUDES) -- *.c *.cc *.cpp