inc=inc/ src=src/ obj=obj/ o=o DEBUG=-g -DDEBUG uname=$(strip $(shell uname -s)) ifeq ($(findstring MINGW32,$(uname)),MINGW32) WINDOWS=1 else WINDOWS=0 endif ifeq ($(findstring BSD,$(uname)),BSD) BSD=1 else BSD=0 endif # # OpenAL location # Required component!! This library must be installed! # http://www.openal.org/ # DYNAMIC_OPENAL=1 ifeq ($(WINDOWS),0) openalinc=-I/usr/include/AL/ openallib= else openal=c:/sdks/OpenAL openalinc=-I$(openal)/Include/ openallib=$(openal)/libs/ endif # # OggVorbis support # Requires the Ogg and Vorbis headers and libraries be present. # http://www.vorbis.com/ # # Setting this to 1 enables the OggVorbis file reader module in the compiled # executable, and with DYNAMIC_VORBIS also set to 1, the vorbisfile DLL will # be loaded at run-time and not bound to the executable. # # The vorbis variable indicates the path to the vorbis SDK. # WITH_VORBIS=1 DYNAMIC_VORBIS=1 ifeq ($(WINDOWS),0) vorbisinc=$(shell pkg-config --cflags vorbisfile) vorbislib=$(shell pkg-config --libs vorbisfile) else vorbis=c:/sdks/oggvorbis-gcc3 vorbisinc=-I$(vorbis)/include/ vorbislib=$(vorbis)/lib/ endif # # FLAC support # Requires the FLAC headers and libraries be present. # http://flac.sourceforge.net/ # WITH_FLAC=1 DYNAMIC_FLAC=1 ifeq ($(WINDOWS),0) flacinc=-I/usr/include/FLAC/ flaclib=-L/usr/lib/ else flac=c:/flac flacinc=-I$(flac)/include/FLAC/ flaclib=$(flac)/bin/ endif # # libMAD MPEG audio support # Requires libMAD be available. # http://www.underbit.com/products/mad/ # WITH_MPEG=1 DYNAMIC_MPEG=1 ifeq ($(WINDOWS),0) libmadinc=-I/usr/include libmadlib= else libmad=c:/sdks/mad libmadinc=-I$(libmad) libmadlib=-L$(libmad) endif # # libModPlug module support # Linux users require libmodplug be available. # Windows users use the included version. # http://modplug-xmms.sourceforge.net/ # WITH_MOD=1 # LEAVE THIS AT 0 FOR NOW. I'M SERIOUS! DYNAMIC_MOD=0 ifeq ($(WINDOWS),0) libmodpluglib=$(shell pkg-config --libs libmodplug) libmodpluginc=$(shell pkg-config --cflags libmodplug) else libmodpluginc=-Ilibmodplug/ libmodpluglib=libmodplug/libmodplug.a endif library=libjfaud.a ifeq ($(WINDOWS),0) dlname=jfaud.so else dlname=jfaud.dll endif libobjs=$(obj)buffer.$o $(obj)channel.$o $(obj)main.$o $(obj)soundfile.$o \ $(obj)alout.$o $(obj)fx.$o $(obj)fnhash.$o \ $(obj)wf_raw.$o $(obj)wf_riffwav.$o $(obj)wf_voc.$o $(obj)wf_au.$o \ $(obj)wf_vorbis.$o $(obj)wf_flac.$o $(obj)wf_mod2.$o $(obj)wf_mpeg.$o \ $(obj)mf_mid.$o $(obj)midiseq.$o CC=gcc CXX=g++ CFLAGS=$(DEBUG) -O2 -I$(src) -I$(inc) -W -Wall -Werror-implicit-function-declaration LIBS= ifeq ($(WINDOWS),1) libobjs+= $(obj)thread_win32.$o $(obj)midiout_win32.$o $(obj)cda_win32.$o LIBS+= -lwinmm else libobjs+= $(obj)thread_pthread.$o $(obj)midiout_null.$o $(obj)cda_null.$o ifeq ($(BSD),0) LIBS+= -ldl endif LIBS+= -lpthread endif ifeq ($(DYNAMIC_OPENAL),0) ifeq ($(WINDOWS),1) LIBS+= $(openallib)OpenAL32.lib else LIBS+= $(openallib) -lopenal endif endif OPENAL_CFLAGS= $(openalinc) -DDYNAMIC_OPENAL=$(DYNAMIC_OPENAL) VORBIS_CFLAGS= -DWITH_VORBIS=$(WITH_VORBIS) ifeq ($(WITH_VORBIS),1) ifeq ($(DYNAMIC_VORBIS),0) ifeq ($(WINDOWS),1) # This is if you want to link to the import library for vorbisfile.dll LIBS+= $(vorbislib)vorbisfile.lib # This probably won't work, but it tries static linking to the MSVC libraries #LIBS+= $(vorbislib)vorbis_static.lib $(vorbislib)vorbisfile_static.lib $(vorbislib)ogg_static.lib # I compiled myself a set of static libraries and link to those to build the DLL: # (for ogg) $ sh configure --prefix=/c/sdks/oggvorbis --enable-shared=no # (for vorbis) $ sh configure --prefix=/c/sdks/oggvorbis --enable-shared=no --with-ogg=/c/sdks/oggvorbis #LIBS+= $(vorbislib)libvorbisfile.a $(vorbislib)libvorbis.a $(vorbislib)libogg.a else LIBS+= $(vorbislib) -lvorbisfile endif endif VORBIS_CFLAGS+= $(vorbisinc) -DDYNAMIC_VORBIS=$(DYNAMIC_VORBIS) endif FLAC_CFLAGS= -DWITH_FLAC=$(WITH_FLAC) ifeq ($(WITH_FLAC),1) ifeq ($(DYNAMIC_FLAC),0) ifeq ($(WINDOWS),1) LIBS+= $(flaclib)libFLAC.dll #LIBS+= $(flaclib)libFLAC_static.lib else LIBS+= $(flaclib) -lFLAC endif endif FLAC_CFLAGS+= $(flacinc) -DDYNAMIC_FLAC=$(DYNAMIC_FLAC) endif MPEG_CFLAGS= -DWITH_MPEG=$(WITH_MPEG) ifeq ($(WITH_MPEG),1) ifeq ($(DYNAMIC_MPEG),0) LIBS+= $(libmadlib) ifeq ($(WINDOWS),1) LIBS+= -lmad else LIBS+= -lmad endif endif MPEG_CFLAGS+= $(libmadinc) -DDYNAMIC_MPEG=$(DYNAMIC_MPEG) endif MOD_CFLAGS= -DWITH_MOD=$(WITH_MOD) ifeq ($(WITH_MOD),1) ifeq ($(DYNAMIC_MOD),0) LIBS+= $(libmodpluglib) -lstdc++ endif MOD_CFLAGS+= $(libmodpluginc) -DDYNAMIC_MOD=$(DYNAMIC_MOD) endif CXXFLAGS=$(CFLAGS) AUD_COMPILE=$(CC) $(CFLAGS) AUD_COMPILEP=$(CXX) $(CFLAGS) AUD_FN=-c AUD_OUT=-o ifeq ($(WINDOWS),1) all: libmodplug $(dlname) $(library) test.exe $(dlname): $(library) $(obj)windll.$o dllwrap -mwindows --dllname $@ --implib jfaud.a --def $(src)windll.def $^ $(LIBS) .PHONY: libmodplug libmodplug: cd libmodplug && $(MAKE) else all: $(library) test.exe endif test.exe: $(obj)test.$o $(library) $(CC) $(CFLAGS) -o $@ $^ $(LIBS) -lm $(library): $(libobjs) ar rc $@ $^ ranlib $@ $(obj)%.$o: $(src)%.c $(AUD_COMPILE) -c $< -o $@ $(obj)%.$o: $(src)%.cpp $(CXX) $(CXXFLAGS) -c $< -o $@ strip: $(dlname) strip $(dlname) clean: -cd libmodplug && $(MAKE) $@ -rm -f $(libobjs) $(obj)windll.$o $(obj)test.$o $(library) $(dlname) include Makefile.deps