From 6e144900303a46e1323e84c05e69df13eed3cdb8 Mon Sep 17 00:00:00 2001 From: Josh Coalson Date: Fri, 7 Dec 2001 19:28:25 +0000 Subject: [PATCH] add support for Darwin builds --- build/exe.mk | 12 ++++++++++-- build/lib.mk | 20 +++++++++++++++++++- src/flac/Makefile.lite | 8 ++++++-- src/libFLAC/Makefile.lite | 19 ++++++++++++++----- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/build/exe.mk b/build/exe.mk index ce36e931..507d3b17 100644 --- a/build/exe.mk +++ b/build/exe.mk @@ -19,11 +19,19 @@ # GNU makefile fragment for building an executable # +ifeq ($(DARWIN_BUILD),yes) +CC = cc +else CC = gcc +endif NASM = nasm -# LINKAGE can be forced to -static or -dynamic from invocation if desired, but it defaults to -static +# LINKAGE can be forced to -static or -dynamic from invocation if desired, but it defaults to -static except on OSX +ifeq ($(DARWIN_BUILD),yes) +LINKAGE = -dynamic +else LINKAGE = -static -LINK = gcc $(LINKAGE) +endif +LINK = $(CC) $(LINKAGE) BINPATH = ../../obj/bin LIBPATH = ../../obj/lib PROGRAM = $(BINPATH)/$(PROGRAM_NAME) diff --git a/build/lib.mk b/build/lib.mk index bc9ecfb1..9a723351 100644 --- a/build/lib.mk +++ b/build/lib.mk @@ -19,13 +19,27 @@ # GNU makefile fragment for building a library # +ifeq ($(DARWIN_BUILD),yes) +CC = cc +else CC = gcc +endif NASM = nasm LINK = ar cru +ifeq ($(DARWIN_BUILD),yes) +LINKD = $(CC) -dynamiclib -flat_namespace -undefined suppress -install_name ../../obj/lib/libFLAC.dylib +#LINKD = $(CC) -dynamiclib -flat_namespace -undefined suppress -install_name ../../obj/lib/libFLAC.1.dylib -compatibility_version 3 -current_version 3.1 +else LINKD = ld -G +endif LIBPATH = ../../obj/lib STATIC_LIB = $(LIBPATH)/$(LIB_NAME).a +ifeq ($(DARWIN_BUILD),yes) +DYNAMIC_LIB = $(LIBPATH)/$(LIB_NAME).dylib +#DYNAMIC_LIB = $(LIBPATH)/$(LIB_NAME).1.1.1.dylib +else DYNAMIC_LIB = $(LIBPATH)/$(LIB_NAME).so +endif all : release @@ -40,10 +54,14 @@ debug : $(ORDINALS_H) $(STATIC_LIB) $(DYNAMIC_LIB) release : $(ORDINALS_H) $(STATIC_LIB) $(DYNAMIC_LIB) $(STATIC_LIB) : $(OBJS) - $(LINK) $@ $(OBJS) + $(LINK) $@ $(OBJS) && ranlib $@ $(DYNAMIC_LIB) : $(OBJS) +ifeq ($(DARWIN_BUILD),yes) + $(LINKD) -o $@ $(OBJS) $(LFLAGS) $(LIBS) -lc +else $(LINKD) -o $@ $(OBJS) $(LFLAGS) $(LIBS) +endif %.o : %.c $(CC) $(CFLAGS) -c $< -o $@ diff --git a/src/flac/Makefile.lite b/src/flac/Makefile.lite index aab13cbe..e99cd769 100644 --- a/src/flac/Makefile.lite +++ b/src/flac/Makefile.lite @@ -20,10 +20,14 @@ # PROGRAM_NAME = flac -#@@@OGG +ifeq ($(DARWIN_BUILD),yes) +INCLUDES = -I./include -I../../include +LIBS = -lFLAC -lc -lm +else +#@@@ TODO: conditionalize ogg includes, defines, and -logg INCLUDES = -I./include -I../../include -I$(HOME)/local/include -DFLAC__HAS_OGG -#@@@OGG conditionalize -logg LIBS = -lFLAC -lm -L$(HOME)/local/lib -logg +endif OBJS = \ analyze.o \ diff --git a/src/libFLAC/Makefile.lite b/src/libFLAC/Makefile.lite index a684df6b..3de4cfa6 100644 --- a/src/libFLAC/Makefile.lite +++ b/src/libFLAC/Makefile.lite @@ -21,11 +21,23 @@ # LIB_NAME = libFLAC +ifeq ($(DARWIN_BUILD),yes) +DEFINES = -DFLAC__NO_NASM -DFLAC__ALIGN_MALLOC_DATA +else DEFINES = -DFLAC__CPU_IA32 -DFLAC__HAS_NASM -DFLAC__ALIGN_MALLOC_DATA +endif INCLUDES = -I./include -I../../include DEBUG_CFLAGS = -DFLAC__OVERFLOW_DETECT -OBJS = \ +ifeq ($(DARWIN_BUILD),yes) +else +ASM_OBJS = \ + ia32/cpu_asm.o \ + ia32/fixed_asm.o \ + ia32/lpc_asm.o +endif + +OBJS = $(ASM_OBJS) \ bitbuffer.o \ bitmath.o \ cpu.o \ @@ -41,10 +53,7 @@ OBJS = \ stream_decoder.o \ stream_encoder.o \ stream_encoder_framing.o \ - utility.o \ - ia32/cpu_asm.o \ - ia32/fixed_asm.o \ - ia32/lpc_asm.o + utility.o include ../../build/lib.mk