diff --git a/Android.mk b/Android.mk index 9ceb328..eaaf6f6 100644 --- a/Android.mk +++ b/Android.mk @@ -1,10 +1,12 @@ # Save the local path SDL_MIXER_LOCAL_PATH := $(call my-dir) +# Enable this if you want to support loading WAV music +SUPPORT_WAV ?= true # Enable this if you want to support loading FLAC music with libFLAC SUPPORT_FLAC ?= true -FLAC_LIBRARY_PATH := external/flac-1.3.2 +FLAC_LIBRARY_PATH := external/flac-1.3.3 # Enable this if you want to support loading OGG Vorbis music via Tremor SUPPORT_OGG ?= true @@ -13,7 +15,7 @@ # Enable this if you want to support loading MP3 music via MPG123 SUPPORT_MP3_MPG123 ?= true -MPG123_LIBRARY_PATH := external/mpg123-1.25.6 +MPG123_LIBRARY_PATH := external/mpg123-1.25.13 # Enable this if you want to support loading MOD music via modplug SUPPORT_MOD_MODPLUG ?= true @@ -21,7 +23,7 @@ # Enable this if you want to support TiMidity SUPPORT_MID_TIMIDITY ?= true -TIMIDITY_LIBRARY_PATH := timidity +TIMIDITY_LIBRARY_PATH := src/codecs/timidity # Build the library @@ -58,12 +60,26 @@ LOCAL_MODULE := SDL2_mixer -LOCAL_SRC_FILES := $(notdir $(filter-out %/playmus.c %/playwave.c, $(wildcard $(LOCAL_PATH)/*.c))) \ +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/include \ + $(LOCAL_PATH)/src/ \ + $(LOCAL_PATH)/src/codecs \ + + +LOCAL_SRC_FILES := \ + $(subst $(LOCAL_PATH)/,, \ + $(wildcard $(LOCAL_PATH)/src/*.c) \ + $(wildcard $(LOCAL_PATH)/src/codecs/*.c) \ + ) LOCAL_CFLAGS := LOCAL_LDLIBS := LOCAL_STATIC_LIBRARIES := LOCAL_SHARED_LIBRARIES := SDL2 + +ifeq ($(SUPPORT_WAV),true) + LOCAL_CFLAGS += -DMUSIC_WAV +endif ifeq ($(SUPPORT_FLAC),true) LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(FLAC_LIBRARY_PATH)/include @@ -98,6 +114,22 @@ LOCAL_STATIC_LIBRARIES += timidity endif -LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH) +LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/include include $(BUILD_SHARED_LIBRARY) + +########################### +# +# SDL2_mixer static library +# +########################### + +LOCAL_MODULE := SDL2_mixer_static + +LOCAL_MODULE_FILENAME := libSDL2_mixer + +LOCAL_LDLIBS := +LOCAL_EXPORT_LDLIBS := + +include $(BUILD_STATIC_LIBRARY) + diff --git a/CHANGES.txt b/CHANGES.txt index 58ffd27..5b458bf 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,59 @@ +2.0.5: +Ozkan Sezer - Sun Feb 07 03:10:10 2021 + * fixed distorted MIDI playback with FluidSynth if the sample rate + is out of library's limits +Ozkan Sezer - Fri Feb 05 14:33:50 2021 + * Added Mix_ModMusicJumpToOrder for mod music formats +Ozkan Sezer - Sun Jan 31 10:03:10 2021 + * Added libxmp support for mod music playback, partially based on + work by Vitaly Novichkov +Ozkan Sezer - Sun Jan 31 00:33:00 2021 + * Fixed mikmod player reader issue with umx files + * Enabled module internal loops in modplug player +Ozkan Sezer - Thu Jan 28 17:02:25 2021 + * Respect original mp3 file offset +Sam Lantinga - Wed Jan 20 10:17:10 2021 + * Fixed a used-after-free issue in fluidsynth player +michaeljosephmaltese - Tue Nov 24 22:07:14 2020 + * Support setting soundfont via SDL_SOUNDFONTS in OSX native midi +David Gow - Fri Oct 23 23:01:00 2020 + * Fixed mp3 file detection. +Ozkan Sezer - Sat Jun 27 00:50:04 2020 + * Fixed divide by zero crash in voc_get_block(). +Matthias Gatto - Tue Dec 17 21:55:00 2019 + * Add Mix_MusicDuration() to return music duration in seconds. +Vitaly Novichkov - Tue Dec 17 15:50:02 2019 + * Fixed music_mpg123 seek bug when sample rate of the file and + the stream don't match +Ozkan Sezer - Tue Dec 17 14:56:04 2019 + * Timidity improvements. New Mix_SetTimidityCfg() public api. +Ozkan Sezer - Sun Dec 08 10:20:40 2019 + * Improved mp3 tag detection/skipping +Ozkan Sezer - Thu Dec 05 01:41:50 2019 + * Updated external libraries with multiple bug/security fixes +Vitaly Novichkov - Wed Dec 04 18:50:02 2019 + * Extended support for WAV files +Vitaly Novichkov - Tue Nov 26 15:55:50 2019 + * Added looping support for Opus files +Vitaly Novichkov - Tue, 26 Nov 2019 15:02:51 + * Allow rmid files be opened by native midi +Vitaly Novichkov - Tue Nov 26 14:37:25 2019 + * Fixed possible crash in win32 native midi +Vitaly Novichkov - Mon Nov 18 17:10:20 2019 + * Prevent clipping due to volume settings in modplug music +Michael Day - Mon Nov 18 07:43:52 2019 + * Fixed FLAC initial stutter +Michael Day - Sat Nov 16 22:11:29 PST 2019 + * Added looping support for FLAC files +Michael Day - Fri Nov 01 10:38:35 2019 + * Improved OGG looping support +Sam Lantinga - Fri Oct 04 18:00:42 2019 + * Fixed loading Opus audio as audio chunks +Sylvain Becker - Wed Aug 21 09:30:22 2019 + * Fixed Mix_FadeOutChannel() never setting fade_volume_reset +Ioan Chera - Sat Mar 30 14:07:03 2019 + * Fixed memory leak in macOS native midi code + 2.0.4: Ozkan Sezer - Wed, 10 Oct 2018 14:56:10 * Removed smpeg support for mp3 music, now that it's replaced by libmpg123 diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..8c5490b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,96 @@ +cmake_minimum_required(VERSION 3.1.0) +project(SDL2_mixer C) + +# FIXME: CMAKE SUPPORT IN SDL2_mixer IS VERY INCOMPLETE YET !!! +# +# FIXME: make it able build against system codec libraries, too. +# FIXME: handle library versioning. +# FIXME: test accross different target platforms. +# +# FIXME: missing CMakeLists.txt for MPG123 +set(SUPPORT_MP3_MPG123 OFF CACHE BOOL "" FORCE) + +option(SUPPORT_WAV "Support loading WAVE music" ON) +option(SUPPORT_FLAC "Support loading FLAC music with libFLAC" OFF) +option(SUPPORT_OGG "Support loading OGG Vorbis music via Tremor" OFF) +option(SUPPORT_MP3_MPG123 "Support loading MP3 music via MPG123" OFF) +option(SUPPORT_MOD_MODPLUG "Support loading MOD music via modplug" OFF) +option(SUPPORT_MID_TIMIDITY "Support loading MIDI music via TiMidity" OFF) + +option(BUILD_SHARED_LIBS "Enable shared library" ON) + +if (NOT ANDROID AND NOT (TARGET SDL2 OR TARGET SDL2-static)) + find_package(SDL2 REQUIRED) + + if(NOT TARGET SDL2::SDL2) + # SDL < 2.0.12 + add_library(SDL2::SDL2 INTERFACE IMPORTED) + set_target_properties(SDL2::SDL2 PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIRS} ${SDL2_INCLUDE_DIR} + INTERFACE_LINK_LIBRARIES ${SDL2_LIBRARIES} ${SDL2_LIBRARY} + ) + endif() +endif() + +include_directories(include src src/codecs) + +add_library(SDL2_mixer) +add_library(SDL2::mixer ALIAS SDL2_mixer) + +target_sources(SDL2_mixer PRIVATE + src/effect_position.c src/effects_internal.c src/effect_stereoreverse.c + src/mixer.c src/music.c src/utils.c + src/codecs/load_aiff.c src/codecs/load_voc.c + src/codecs/music_cmd.c + src/codecs/music_wav.c src/codecs/music_flac.c + src/codecs/music_mad.c src/codecs/music_mpg123.c + src/codecs/music_ogg.c src/codecs/music_opus.c + src/codecs/music_mikmod.c src/codecs/music_modplug.c + src/codecs/music_xmp.c + src/codecs/music_fluidsynth.c src/codecs/music_timidity.c + src/codecs/music_nativemidi.c) + +if (SUPPORT_WAV) + target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_WAV) +endif() + +if (SUPPORT_FLAC) + target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_FLAC) + add_subdirectory(external/flac-1.3.3) + target_include_directories(SDL2_mixer PRIVATE external/flac-1.3.3/include) + target_link_libraries(SDL2_mixer PRIVATE FLAC) +endif() + +if (SUPPORT_OGG) + target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_OGG -DOGG_USE_TREMOR -DOGG_HEADER=) + add_subdirectory(external/libogg-1.3.2) + add_subdirectory(external/libvorbisidec-1.2.1) + target_include_directories(SDL2_mixer PRIVATE external/libvorbisidec-1.2.1) + target_link_libraries(SDL2_mixer PRIVATE vorbisidec ogg) +endif() + +if (SUPPORT_MP3_MPG123) + target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_MP3_MPG123) + add_subdirectory(external/mpg123-1.25.13) + target_link_libraries(SDL2_mixer PRIVATE mpg123) +endif() + +if (SUPPORT_MOD_MODPLUG) + target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_MOD_MODPLUG -DMODPLUG_HEADER=) + add_subdirectory(external/libmodplug-0.8.9.0) + target_include_directories(SDL2_mixer PRIVATE external/libmodplug-0.8.9.0/src) + target_link_libraries(SDL2_mixer PRIVATE modplug) +endif() + +if (SUPPORT_MID_TIMIDITY) + target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_MID_TIMIDITY) + add_subdirectory(src/codecs/timidity) + target_link_libraries(SDL2_mixer PRIVATE timidity) +endif() + +if(WIN32 AND BUILD_SHARED_LIBS) + target_compile_definitions(SDL2_mixer PRIVATE -DDLL_EXPORT) +endif() + +target_include_directories(SDL2_mixer PUBLIC include) +target_link_libraries(SDL2_mixer PRIVATE SDL2::SDL2) diff --git a/COPYING.txt b/COPYING.txt deleted file mode 100644 index c59f77f..0000000 --- a/COPYING.txt +++ /dev/null @@ -1,20 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..3c82ac8 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,17 @@ +Copyright (C) 1997-2021 Sam Lantinga + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. diff --git a/Makefile.in b/Makefile.in index 2ff24b2..5c7abfc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -28,7 +28,7 @@ INSTALL = @INSTALL@ AR = @AR@ RANLIB = @RANLIB@ -WINDRES = @WINDRES@ +RC = @RC@ SDL_CFLAGS = @SDL_CFLAGS@ SDL_LIBS = @SDL_LIBS@ @@ -38,26 +38,27 @@ PLAYWAVE_OBJECTS = @PLAYWAVE_OBJECTS@ PLAYMUS_OBJECTS = @PLAYMUS_OBJECTS@ -DIST = *.txt Android.mk Makefile.in SDL2_mixer.pc.in SDL2_mixer.spec.in SDL_mixer.h VisualC VisualC-WinRT Xcode Xcode-iOS acinclude aclocal.m4 autogen.sh build-scripts configure configure.in debian effect_position.c effect_stereoreverse.c effects_internal.c effects_internal.h external gcc-fat.sh load_aiff.c load_aiff.h load_voc.c load_voc.h mixer.c mixer.h music.c music.h music_cmd.c music_cmd.h music_flac.c music_flac.h music_fluidsynth.c music_fluidsynth.h music_mad.c music_mad.h music_mikmod.c music_mikmod.h music_modplug.c music_modplug.h music_mpg123.c music_mpg123.h music_nativemidi.c music_nativemidi.h music_ogg.c music_ogg.h music_opus.c music_opus.h music_timidity.c music_timidity.h music_wav.c music_wav.h native_midi playmus.c playwave.c timidity version.rc +SRC_DIST = *.txt Android.mk Makefile.in Makefile.os2 SDL2_mixer.pc.in SDL2_mixer.spec.in include/SDL_mixer.h VisualC VisualC-WinRT Xcode Xcode-iOS acinclude autogen.sh build-scripts configure configure.ac debian external gcc-fat.sh src/utils.c src/utils.h src/effect_position.c src/effect_stereoreverse.c src/effects_internal.c src/effects_internal.h src/codecs/load_aiff.c src/codecs/load_aiff.h src/codecs/load_voc.c src/codecs/load_voc.h src/codecs/mp3utils.c src/codecs/mp3utils.h src/mixer.c src/mixer.h src/music.c src/music.h src/codecs/music_cmd.c src/codecs/music_cmd.h src/codecs/music_flac.c src/codecs/music_flac.h src/codecs/music_fluidsynth.c src/codecs/music_fluidsynth.h src/codecs/music_mad.c src/codecs/music_mad.h src/codecs/music_mikmod.c src/codecs/music_mikmod.h src/codecs/music_modplug.c src/codecs/music_modplug.h src/codecs/music_xmp.c src/codecs/music_xmp.h src/codecs/music_mpg123.c src/codecs/music_mpg123.h src/codecs/music_nativemidi.c src/codecs/music_nativemidi.h src/codecs/music_ogg.c src/codecs/music_ogg.h src/codecs/music_opus.c src/codecs/music_opus.h src/codecs/music_timidity.c src/codecs/music_timidity.h src/codecs/music_wav.c src/codecs/music_wav.h src/codecs/native_midi playmus.c playwave.c src/codecs/timidity version.rc +GEN_DIST = SDL2_mixer.spec LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ LT_RELEASE = @LT_RELEASE@ LT_REVISION = @LT_REVISION@ -LT_LDFLAGS = -no-undefined -rpath $(libdir) -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) +LT_EXTRA = @LT_EXTRA@ +LT_LDFLAGS = -no-undefined -rpath $(libdir) -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) $(LT_EXTRA) -all: $(srcdir)/configure Makefile $(objects) $(objects)/$(TARGET) $(objects)/playwave$(EXE) $(objects)/playmus$(EXE) +all: $(srcdir)/configure Makefile $(objects)/$(TARGET) $(objects)/playwave$(EXE) $(objects)/playmus$(EXE) -$(srcdir)/configure: $(srcdir)/configure.in - @echo "Warning, configure.in is out of date" - #(cd $(srcdir) && sh autogen.sh && sh configure) - @sleep 3 +$(srcdir)/configure: $(srcdir)/configure.ac + @echo "Warning, configure is out of date, please re-run autogen.sh" Makefile: $(srcdir)/Makefile.in $(SHELL) config.status $@ -$(objects): - $(SHELL) $(auxdir)/mkinstalldirs $@ +$(objects)/.created: + $(SHELL) $(auxdir)/mkinstalldirs $(objects) + touch $@ .PHONY: all install install-hdrs install-lib install-bin uninstall uninstall-hdrs uninstall-lib uninstall-bin clean distclean dist @@ -73,7 +74,7 @@ install: all install-hdrs install-lib #install-bin install-hdrs: $(SHELL) $(auxdir)/mkinstalldirs $(includedir)/SDL2 - for src in $(srcdir)/SDL_mixer.h; do \ + for src in $(srcdir)/include/SDL_mixer.h; do \ file=`echo $$src | sed -e 's|^.*/||'`; \ $(INSTALL) -m 644 $$src $(includedir)/SDL2/$$file; \ done @@ -89,7 +90,7 @@ uninstall: uninstall-hdrs uninstall-lib uninstall-bin uninstall-hdrs: - for src in $(srcdir)/SDL_mixer.h; do \ + for src in $(srcdir)/include/SDL_mixer.h; do \ file=`echo $$src | sed -e 's|^.*/||'`; \ rm -f $(includedir)/SDL2/$$file; \ done @@ -121,7 +122,8 @@ dist $(distfile): $(SHELL) $(auxdir)/mkinstalldirs $(distdir) - (cd $(srcdir); tar cf - $(DIST)) | (cd $(distdir); tar xf -) + (cd $(srcdir); tar cf - $(SRC_DIST)) | (cd $(distdir); tar xf -) + tar cf - $(GEN_DIST) | (cd $(distdir); tar xf -) rm -rf `find $(distdir) -name .svn` rm -f `find $(distdir) -name '.#*'` tar cvf - $(distdir) | gzip --best >$(distfile) diff --git a/Makefile.os2 b/Makefile.os2 new file mode 100644 index 0000000..1e50ce9 --- /dev/null +++ b/Makefile.os2 @@ -0,0 +1,192 @@ +# Open Watcom makefile to build SDL2mix.dll for OS/2 +# wmake -f Makefile.os2 +# +# Remember to edit DEPS_INC and DEPS_LIB below to meet +# your own environment!. + +LIBNAME = SDL2mix +VERSION = 2.0.4 + +TITLENAME = $(LIBNAME) $(VERSION) + +# change DEPS_INC in order to point to the dependency headers. +DEPS_INC=-IC:\SDL2DEV\h\SDL2 -IC:\SDL2DEV\h +# change DEPS_LIB in order to point to the dependency libraries. +DEPS_LIB=C:\SDL2DEV\lib + +# wav music support +USE_WAV=yes +# ogg/vorbis music support +USE_OGG=yes +# use integer-only Tremor (libvorbisidec) instead of libvorbis? +USE_TREMOR=no +# flac music support +USE_FLAC=yes +# opus music support +USE_OPUS=yes +# mp3 music support (using libmad) +USE_LIBMAD=no +# mp3 music support (using mpg123) +USE_MPG123=yes +# midi music support (using timidity) +USE_TIMIDITY=yes +# midi music support (using fluidsynth) +USE_FLUIDSYNTH=no +# tracker music support (using libmikmod) +USE_MIKMOD=no +# tracker music support (using libxmp) +USE_XMP=yes +# tracker music support (using libmodplug) +USE_MODPLUG=no + +LIBFILE = $(LIBNAME).lib +DLLFILE = $(LIBNAME).dll +LNKFILE = $(LIBNAME).lnk +TIMILIB = timidity.lib + +SRCS = utils.c effect_position.c effects_internal.c effect_stereoreverse.c mixer.c music.c +# codec sources: +SRCS+= load_aiff.c load_voc.c music_wav.c & + mp3utils.c music_mad.c music_mpg123.c & + music_ogg.c music_opus.c music_flac.c & + music_xmp.c music_mikmod.c music_modplug.c & + music_fluidsynth.c music_timidity.c +# timidity sources: +TIMISRCS = common.c instrum.c mix.c output.c playmidi.c readmidi.c resample.c tables.c timidity.c + +OBJS = $(SRCS:.c=.obj) +TIMIOBJS = $(TIMISRCS:.c=.obj) + +LIBS = SDL2.lib + +CFLAGS_BASE = -bt=os2 -d0 -q -bm -5s -fp5 -fpi87 -sg -oteanbmier -ei -j +# warnings: +CFLAGS_BASE+= -wx +# include paths: +CFLAGS_BASE+= -Iinclude -Isrc -I"src/codecs" -I"src/codecs/timidity" $(DEPS_INC) +CFLAGS_BASE+= -I"$(%WATCOM)/h/os2" -I"$(%WATCOM)/h" +CFLAGS = $(CFLAGS_BASE) +# to build a dll: +CFLAGS+= -bd +# for DECLSPEC: +CFLAGS+= -DBUILD_SDL + +!ifeq USE_TIMIDITY yes +CFLAGS+= -DMUSIC_MID_TIMIDITY +LIBS+= $(TIMILIB) +!endif +!ifeq USE_FLUIDSYNTH yes +CFLAGS+= -DMUSIC_MID_FLUIDSYNTH +LIBS+= fluidsyn.lib +!endif + +!ifeq USE_WAV yes +CFLAGS+= -DMUSIC_WAV +!endif + +!ifeq USE_TREMOR yes +VORBIS_LIBS=vorbisidec.lib +!else +VORBIS_LIBS=vorbisfile.lib vorbis.lib +!endif +!ifeq USE_OGG yes +CFLAGS+= -DMUSIC_OGG +!ifeq USE_TREMOR yes +CFLAGS+= -DOGG_USE_TREMOR +!endif +LIBS+= $(VORBIS_LIBS) +LIBS+= ogg.lib +!endif + +!ifeq USE_FLAC yes +CFLAGS+= -DMUSIC_FLAC +LIBS+= FLAC.lib +!endif + +!ifeq USE_OPUS yes +CFLAGS+= -DMUSIC_OPUS +LIBS+= opusfile.lib opus.lib +!ifneq USE_OGG yes +LIBS+= ogg.lib +!endif +!endif + +!ifeq USE_LIBMAD yes +CFLAGS+= -DMUSIC_MP3_MAD +LIBS+= mad.lib +!endif +!ifeq USE_MPG123 yes +CFLAGS+= -DMUSIC_MP3_MPG123 +LIBS+= mpg123.lib +!endif + +!ifeq USE_XMP yes +CFLAGS+= -DMUSIC_MOD_XMP +LIBS+= libxmp.lib +!endif +!ifeq USE_MIKMOD yes +CFLAGS+= -DMUSIC_MOD_MIKMOD +LIBS+= mikmod.lib +!endif +!ifeq USE_MODPLUG yes +CFLAGS+= -DMUSIC_MOD_MODPLUG +LIBS+= modplug.lib +!endif + +all: $(DLLFILE) playwave.exe playmus.exe + +$(LIBFILE): $(DLLFILE) + @echo * Create library: $@... + wlib -b -n -q -c -pa -s -t -zld -ii -io $@ $(DLLFILE) + +$(DLLFILE): $(OBJS) $(TIMILIB) $(LNKFILE) + @echo * Link: $@ + wlink @$(LNKFILE) + +$(LNKFILE): + @%create $@ + @%append $@ SYSTEM os2v2_dll INITINSTANCE TERMINSTANCE + @%append $@ NAME $(LIBNAME) + @for %i in ($(OBJS)) do @%append $@ FILE %i + @%append $@ OPTION QUIET + @%append $@ OPTION DESCRIPTION '@$#libsdl org:$(VERSION)$#@Simple DirectMedia Layer Mixer' + @%append $@ LIBPATH $(DEPS_LIB) + @for %i in ($(LIBS)) do @%append $@ LIB %i + @%append $@ OPTION MAP=$* + @%append $@ OPTION ELIMINATE + @%append $@ OPTION MANYAUTODATA + @%append $@ OPTION OSNAME='OS/2 and eComStation' + @%append $@ OPTION SHOWDEAD + +.c: ./src;./src/codecs; + +.c.obj: + wcc386 $(CFLAGS) -fo=$^@ $< + +playmus.obj: playmus.c + wcc386 $(CFLAGS_BASE) -fo=$^@ $< + +playwave.obj: playwave.c + wcc386 $(CFLAGS_BASE) -fo=$^@ $< + +playmus.exe: $(LIBFILE) playmus.obj + wlink SYS os2v2 OP q LIBPATH $(DEPS_LIB) LIBR {$(LIBFILE) SDL2.lib} F {playmus.obj} N playmus.exe + +playwave.exe: $(LIBFILE) playwave.obj + wlink SYS os2v2 OP q LIBPATH $(DEPS_LIB) LIBR {$(LIBFILE) SDL2.lib} F {playwave.obj} N playwave.exe + +.c: ./src/codecs/timidity; +timidity.lib: $(TIMIOBJS) + wlib -b -n -q -c -pa -s -t -zld -ii -io $@ $(TIMIOBJS) + +clean: .SYMBOLIC + @echo * Clean: $(TITLENAME) + @if exist *.obj rm *.obj + @if exist *.err rm *.err + @if exist $(TIMILIB) rm $(TIMILIB) + @if exist $(LNKFILE) rm $(LNKFILE) +distclean: .SYMBOLIC clean + @if exist $(DLLFILE) rm $(DLLFILE) + @if exist $(LIBFILE) rm $(LIBFILE) + @if exist *.map rm *.map + @if exist *.exe rm *.exe diff --git a/README.txt b/README.txt index 3f7330f..d1dbee8 100644 --- a/README.txt +++ b/README.txt @@ -50,5 +50,5 @@ and SDL_mixer directories to your "Header Search Paths" setting, then add the libSDL2.a and libSDL2_mixer.a to your "Link Binary with Libraries" setting. -This library is under the zlib license, see the file "COPYING.txt" for details. +This library is under the zlib license, see the file "LICENSE.txt" for details. diff --git a/SDL2_mixer.spec b/SDL2_mixer.spec new file mode 100644 index 0000000..69d29cb --- /dev/null +++ b/SDL2_mixer.spec @@ -0,0 +1,64 @@ +%define name SDL2_mixer +%define version 2.0.4 +%define release 1 + +Summary: Simple DirectMedia Layer - Sample Mixer Library +Name: %{name} +Version: %{version} +Release: %{release} +Source0: %{name}-%{version}.tar.gz +License: LGPL +Group: System Environment/Libraries +BuildRoot: /var/tmp/%{name}-buildroot +Prefix: %{_prefix} + +%description +Due to popular demand, here is a simple multi-channel audio mixer. +It supports 4 channels of 16 bit stereo audio, plus a single channel +of music, mixed by the popular MikMod MOD, Timidity MIDI, Ogg Vorbis, +Tremor, libmpg123 and libmad MP3 libraries. + +%package devel +Summary: Libraries, includes and more to develop SDL applications. +Group: Development/Libraries +Requires: %{name} + +%description devel +Due to popular demand, here is a simple multi-channel audio mixer. +It supports 4 channels of 16 bit stereo audio, plus a single channel +of music, mixed by the popular MikMod MOD, Timidity MIDI, Ogg Vorbis, +Tremor, libmpg123 and libmad MP3 libraries. + +%prep +%setup + +%build +CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{prefix} +make + +%install +rm -rf $RPM_BUILD_ROOT +make install prefix=$RPM_BUILD_ROOT/%{prefix} + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%defattr(-,root,root) +%doc README.txt CHANGES.txt LICENSE.txt +%{prefix}/lib/lib*.so.* + +%files devel +%defattr(-,root,root) +%{prefix}/lib/lib*.a +%{prefix}/lib/lib*.la +%{prefix}/lib/lib*.so +%{prefix}/include/*/ +%{prefix}/lib/pkgconfig/*.pc + +%changelog +* Wed Jan 19 2000 Sam Lantinga +- converted to get package information from configure +* Sun Jan 16 2000 Hakan Tandogan +- initial spec file + diff --git a/SDL2_mixer.spec.in b/SDL2_mixer.spec.in index bccf2bd..1929e08 100644 --- a/SDL2_mixer.spec.in +++ b/SDL2_mixer.spec.in @@ -30,7 +30,7 @@ Tremor, libmpg123 and libmad MP3 libraries. %prep -%setup +%setup %build CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{prefix} @@ -45,7 +45,7 @@ %files %defattr(-,root,root) -%doc README.txt CHANGES.txt COPYING.txt +%doc README.txt CHANGES.txt LICENSE.txt %{prefix}/lib/lib*.so.* %files devel @@ -57,7 +57,7 @@ %{prefix}/lib/pkgconfig/*.pc %changelog -* Wed Jan 19 2000 Sam Lantinga +* Wed Jan 19 2000 Sam Lantinga - converted to get package information from configure * Sun Jan 16 2000 Hakan Tandogan - initial spec file diff --git a/SDL_mixer.h b/SDL_mixer.h deleted file mode 100644 index 009d8a2..0000000 --- a/SDL_mixer.h +++ /dev/null @@ -1,651 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SDL_MIXER_H_ -#define SDL_MIXER_H_ - -#include "SDL_stdinc.h" -#include "SDL_rwops.h" -#include "SDL_audio.h" -#include "SDL_endian.h" -#include "SDL_version.h" -#include "begin_code.h" - -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL -*/ -#define SDL_MIXER_MAJOR_VERSION 2 -#define SDL_MIXER_MINOR_VERSION 0 -#define SDL_MIXER_PATCHLEVEL 4 - -/* This macro can be used to fill a version structure with the compile-time - * version of the SDL_mixer library. - */ -#define SDL_MIXER_VERSION(X) \ -{ \ - (X)->major = SDL_MIXER_MAJOR_VERSION; \ - (X)->minor = SDL_MIXER_MINOR_VERSION; \ - (X)->patch = SDL_MIXER_PATCHLEVEL; \ -} - -/* Backwards compatibility */ -#define MIX_MAJOR_VERSION SDL_MIXER_MAJOR_VERSION -#define MIX_MINOR_VERSION SDL_MIXER_MINOR_VERSION -#define MIX_PATCHLEVEL SDL_MIXER_PATCHLEVEL -#define MIX_VERSION(X) SDL_MIXER_VERSION(X) - -/** - * This is the version number macro for the current SDL_mixer version. - */ -#define SDL_MIXER_COMPILEDVERSION \ - SDL_VERSIONNUM(SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL) - -/** - * This macro will evaluate to true if compiled with SDL_mixer at least X.Y.Z. - */ -#define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \ - (SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) - -/* This function gets the version of the dynamically linked SDL_mixer library. - it should NOT be used to fill a version structure, instead you should - use the SDL_MIXER_VERSION() macro. - */ -extern DECLSPEC const SDL_version * SDLCALL Mix_Linked_Version(void); - -typedef enum -{ - MIX_INIT_FLAC = 0x00000001, - MIX_INIT_MOD = 0x00000002, - MIX_INIT_MP3 = 0x00000008, - MIX_INIT_OGG = 0x00000010, - MIX_INIT_MID = 0x00000020, - MIX_INIT_OPUS = 0x00000040 -} MIX_InitFlags; - -/* Loads dynamic libraries and prepares them for use. Flags should be - one or more flags from MIX_InitFlags OR'd together. - It returns the flags successfully initialized, or 0 on failure. - */ -extern DECLSPEC int SDLCALL Mix_Init(int flags); - -/* Unloads libraries loaded with Mix_Init */ -extern DECLSPEC void SDLCALL Mix_Quit(void); - - -/* The default mixer has 8 simultaneous mixing channels */ -#ifndef MIX_CHANNELS -#define MIX_CHANNELS 8 -#endif - -/* Good default values for a PC soundcard */ -#define MIX_DEFAULT_FREQUENCY 22050 -#if SDL_BYTEORDER == SDL_LIL_ENDIAN -#define MIX_DEFAULT_FORMAT AUDIO_S16LSB -#else -#define MIX_DEFAULT_FORMAT AUDIO_S16MSB -#endif -#define MIX_DEFAULT_CHANNELS 2 -#define MIX_MAX_VOLUME SDL_MIX_MAXVOLUME /* Volume of a chunk */ - -/* The internal format for an audio chunk */ -typedef struct Mix_Chunk { - int allocated; - Uint8 *abuf; - Uint32 alen; - Uint8 volume; /* Per-sample volume, 0-128 */ -} Mix_Chunk; - -/* The different fading types supported */ -typedef enum { - MIX_NO_FADING, - MIX_FADING_OUT, - MIX_FADING_IN -} Mix_Fading; - -/* These are types of music files (not libraries used to load them) */ -typedef enum { - MUS_NONE, - MUS_CMD, - MUS_WAV, - MUS_MOD, - MUS_MID, - MUS_OGG, - MUS_MP3, - MUS_MP3_MAD_UNUSED, - MUS_FLAC, - MUS_MODPLUG_UNUSED, - MUS_OPUS -} Mix_MusicType; - -/* The internal format for a music chunk interpreted via mikmod */ -typedef struct _Mix_Music Mix_Music; - -/* Open the mixer with a certain audio format */ -extern DECLSPEC int SDLCALL Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize); - -/* Open the mixer with specific device and certain audio format */ -extern DECLSPEC int SDLCALL Mix_OpenAudioDevice(int frequency, Uint16 format, int channels, int chunksize, const char* device, int allowed_changes); - -/* Dynamically change the number of channels managed by the mixer. - If decreasing the number of channels, the upper channels are - stopped. - This function returns the new number of allocated channels. - */ -extern DECLSPEC int SDLCALL Mix_AllocateChannels(int numchans); - -/* Find out what the actual audio device parameters are. - This function returns 1 if the audio has been opened, 0 otherwise. - */ -extern DECLSPEC int SDLCALL Mix_QuerySpec(int *frequency,Uint16 *format,int *channels); - -/* Load a wave file or a music (.mod .s3m .it .xm) file */ -extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV_RW(SDL_RWops *src, int freesrc); -#define Mix_LoadWAV(file) Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1) -extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file); - -/* Load a music file from an SDL_RWop object (Ogg and MikMod specific currently) - Matt Campbell (matt@campbellhome.dhs.org) April 2000 */ -extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *src, int freesrc); - -/* Load a music file from an SDL_RWop object assuming a specific format */ -extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc); - -/* Load a wave file of the mixer format from a memory buffer */ -extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_WAV(Uint8 *mem); - -/* Load raw audio data of the mixer format from a memory buffer */ -extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len); - -/* Free an audio chunk previously loaded */ -extern DECLSPEC void SDLCALL Mix_FreeChunk(Mix_Chunk *chunk); -extern DECLSPEC void SDLCALL Mix_FreeMusic(Mix_Music *music); - -/* Get a list of chunk/music decoders that this build of SDL_mixer provides. - This list can change between builds AND runs of the program, if external - libraries that add functionality become available. - You must successfully call Mix_OpenAudio() before calling these functions. - This API is only available in SDL_mixer 1.2.9 and later. - - // usage... - int i; - const int total = Mix_GetNumChunkDecoders(); - for (i = 0; i < total; i++) - printf("Supported chunk decoder: [%s]\n", Mix_GetChunkDecoder(i)); - - Appearing in this list doesn't promise your specific audio file will - decode...but it's handy to know if you have, say, a functioning Timidity - install. - - These return values are static, read-only data; do not modify or free it. - The pointers remain valid until you call Mix_CloseAudio(). -*/ -extern DECLSPEC int SDLCALL Mix_GetNumChunkDecoders(void); -extern DECLSPEC const char * SDLCALL Mix_GetChunkDecoder(int index); -extern DECLSPEC SDL_bool SDLCALL Mix_HasChunkDecoder(const char *name); -extern DECLSPEC int SDLCALL Mix_GetNumMusicDecoders(void); -extern DECLSPEC const char * SDLCALL Mix_GetMusicDecoder(int index); -extern DECLSPEC SDL_bool SDLCALL Mix_HasMusicDecoder(const char *name); - -/* Find out the music format of a mixer music, or the currently playing - music, if 'music' is NULL. -*/ -extern DECLSPEC Mix_MusicType SDLCALL Mix_GetMusicType(const Mix_Music *music); - -/* Set a function that is called after all mixing is performed. - This can be used to provide real-time visual display of the audio stream - or add a custom mixer filter for the stream data. -*/ -extern DECLSPEC void SDLCALL Mix_SetPostMix(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg); - -/* Add your own music player or additional mixer function. - If 'mix_func' is NULL, the default music player is re-enabled. - */ -extern DECLSPEC void SDLCALL Mix_HookMusic(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg); - -/* Add your own callback for when the music has finished playing or when it is - * stopped from a call to Mix_HaltMusic. - */ -extern DECLSPEC void SDLCALL Mix_HookMusicFinished(void (SDLCALL *music_finished)(void)); - -/* Get a pointer to the user data for the current music hook */ -extern DECLSPEC void * SDLCALL Mix_GetMusicHookData(void); - -/* - * Add your own callback when a channel has finished playing. NULL - * to disable callback. The callback may be called from the mixer's audio - * callback or it could be called as a result of Mix_HaltChannel(), etc. - * do not call SDL_LockAudio() from this callback; you will either be - * inside the audio callback, or SDL_mixer will explicitly lock the audio - * before calling your callback. - */ -extern DECLSPEC void SDLCALL Mix_ChannelFinished(void (SDLCALL *channel_finished)(int channel)); - - -/* Special Effects API by ryan c. gordon. (icculus@icculus.org) */ - -#define MIX_CHANNEL_POST -2 - -/* This is the format of a special effect callback: - * - * myeffect(int chan, void *stream, int len, void *udata); - * - * (chan) is the channel number that your effect is affecting. (stream) is - * the buffer of data to work upon. (len) is the size of (stream), and - * (udata) is a user-defined bit of data, which you pass as the last arg of - * Mix_RegisterEffect(), and is passed back unmolested to your callback. - * Your effect changes the contents of (stream) based on whatever parameters - * are significant, or just leaves it be, if you prefer. You can do whatever - * you like to the buffer, though, and it will continue in its changed state - * down the mixing pipeline, through any other effect functions, then finally - * to be mixed with the rest of the channels and music for the final output - * stream. - * - * DO NOT EVER call SDL_LockAudio() from your callback function! - */ -typedef void (SDLCALL *Mix_EffectFunc_t)(int chan, void *stream, int len, void *udata); - -/* - * This is a callback that signifies that a channel has finished all its - * loops and has completed playback. This gets called if the buffer - * plays out normally, or if you call Mix_HaltChannel(), implicitly stop - * a channel via Mix_AllocateChannels(), or unregister a callback while - * it's still playing. - * - * DO NOT EVER call SDL_LockAudio() from your callback function! - */ -typedef void (SDLCALL *Mix_EffectDone_t)(int chan, void *udata); - - -/* Register a special effect function. At mixing time, the channel data is - * copied into a buffer and passed through each registered effect function. - * After it passes through all the functions, it is mixed into the final - * output stream. The copy to buffer is performed once, then each effect - * function performs on the output of the previous effect. Understand that - * this extra copy to a buffer is not performed if there are no effects - * registered for a given chunk, which saves CPU cycles, and any given - * effect will be extra cycles, too, so it is crucial that your code run - * fast. Also note that the data that your function is given is in the - * format of the sound device, and not the format you gave to Mix_OpenAudio(), - * although they may in reality be the same. This is an unfortunate but - * necessary speed concern. Use Mix_QuerySpec() to determine if you can - * handle the data before you register your effect, and take appropriate - * actions. - * You may also specify a callback (Mix_EffectDone_t) that is called when - * the channel finishes playing. This gives you a more fine-grained control - * than Mix_ChannelFinished(), in case you need to free effect-specific - * resources, etc. If you don't need this, you can specify NULL. - * You may set the callbacks before or after calling Mix_PlayChannel(). - * Things like Mix_SetPanning() are just internal special effect functions, - * so if you are using that, you've already incurred the overhead of a copy - * to a separate buffer, and that these effects will be in the queue with - * any functions you've registered. The list of registered effects for a - * channel is reset when a chunk finishes playing, so you need to explicitly - * set them with each call to Mix_PlayChannel*(). - * You may also register a special effect function that is to be run after - * final mixing occurs. The rules for these callbacks are identical to those - * in Mix_RegisterEffect, but they are run after all the channels and the - * music have been mixed into a single stream, whereas channel-specific - * effects run on a given channel before any other mixing occurs. These - * global effect callbacks are call "posteffects". Posteffects only have - * their Mix_EffectDone_t function called when they are unregistered (since - * the main output stream is never "done" in the same sense as a channel). - * You must unregister them manually when you've had enough. Your callback - * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the - * processing is considered a posteffect. - * - * After all these effects have finished processing, the callback registered - * through Mix_SetPostMix() runs, and then the stream goes to the audio - * device. - * - * DO NOT EVER call SDL_LockAudio() from your callback function! - * - * returns zero if error (no such channel), nonzero if added. - * Error messages can be retrieved from Mix_GetError(). - */ -extern DECLSPEC int SDLCALL Mix_RegisterEffect(int chan, Mix_EffectFunc_t f, Mix_EffectDone_t d, void *arg); - - -/* You may not need to call this explicitly, unless you need to stop an - * effect from processing in the middle of a chunk's playback. - * Posteffects are never implicitly unregistered as they are for channels, - * but they may be explicitly unregistered through this function by - * specifying MIX_CHANNEL_POST for a channel. - * returns zero if error (no such channel or effect), nonzero if removed. - * Error messages can be retrieved from Mix_GetError(). - */ -extern DECLSPEC int SDLCALL Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f); - - -/* You may not need to call this explicitly, unless you need to stop all - * effects from processing in the middle of a chunk's playback. Note that - * this will also shut off some internal effect processing, since - * Mix_SetPanning() and others may use this API under the hood. This is - * called internally when a channel completes playback. - * Posteffects are never implicitly unregistered as they are for channels, - * but they may be explicitly unregistered through this function by - * specifying MIX_CHANNEL_POST for a channel. - * returns zero if error (no such channel), nonzero if all effects removed. - * Error messages can be retrieved from Mix_GetError(). - */ -extern DECLSPEC int SDLCALL Mix_UnregisterAllEffects(int channel); - - -#define MIX_EFFECTSMAXSPEED "MIX_EFFECTSMAXSPEED" - -/* - * These are the internally-defined mixing effects. They use the same API that - * effects defined in the application use, but are provided here as a - * convenience. Some effects can reduce their quality or use more memory in - * the name of speed; to enable this, make sure the environment variable - * MIX_EFFECTSMAXSPEED (see above) is defined before you call - * Mix_OpenAudio(). - */ - - -/* Set the panning of a channel. The left and right channels are specified - * as integers between 0 and 255, quietest to loudest, respectively. - * - * Technically, this is just individual volume control for a sample with - * two (stereo) channels, so it can be used for more than just panning. - * If you want real panning, call it like this: - * - * Mix_SetPanning(channel, left, 255 - left); - * - * ...which isn't so hard. - * - * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and - * the panning will be done to the final mixed stream before passing it on - * to the audio device. - * - * This uses the Mix_RegisterEffect() API internally, and returns without - * registering the effect function if the audio device is not configured - * for stereo output. Setting both (left) and (right) to 255 causes this - * effect to be unregistered, since that is the data's normal state. - * - * returns zero if error (no such channel or Mix_RegisterEffect() fails), - * nonzero if panning effect enabled. Note that an audio device in mono - * mode is a no-op, but this call will return successful in that case. - * Error messages can be retrieved from Mix_GetError(). - */ -extern DECLSPEC int SDLCALL Mix_SetPanning(int channel, Uint8 left, Uint8 right); - - -/* Set the position of a channel. (angle) is an integer from 0 to 360, that - * specifies the location of the sound in relation to the listener. (angle) - * will be reduced as neccesary (540 becomes 180 degrees, -100 becomes 260). - * Angle 0 is due north, and rotates clockwise as the value increases. - * For efficiency, the precision of this effect may be limited (angles 1 - * through 7 might all produce the same effect, 8 through 15 are equal, etc). - * (distance) is an integer between 0 and 255 that specifies the space - * between the sound and the listener. The larger the number, the further - * away the sound is. Using 255 does not guarantee that the channel will be - * culled from the mixing process or be completely silent. For efficiency, - * the precision of this effect may be limited (distance 0 through 5 might - * all produce the same effect, 6 through 10 are equal, etc). Setting (angle) - * and (distance) to 0 unregisters this effect, since the data would be - * unchanged. - * - * If you need more precise positional audio, consider using OpenAL for - * spatialized effects instead of SDL_mixer. This is only meant to be a - * basic effect for simple "3D" games. - * - * If the audio device is configured for mono output, then you won't get - * any effectiveness from the angle; however, distance attenuation on the - * channel will still occur. While this effect will function with stereo - * voices, it makes more sense to use voices with only one channel of sound, - * so when they are mixed through this effect, the positioning will sound - * correct. You can convert them to mono through SDL before giving them to - * the mixer in the first place if you like. - * - * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and - * the positioning will be done to the final mixed stream before passing it - * on to the audio device. - * - * This is a convenience wrapper over Mix_SetDistance() and Mix_SetPanning(). - * - * returns zero if error (no such channel or Mix_RegisterEffect() fails), - * nonzero if position effect is enabled. - * Error messages can be retrieved from Mix_GetError(). - */ -extern DECLSPEC int SDLCALL Mix_SetPosition(int channel, Sint16 angle, Uint8 distance); - - -/* Set the "distance" of a channel. (distance) is an integer from 0 to 255 - * that specifies the location of the sound in relation to the listener. - * Distance 0 is overlapping the listener, and 255 is as far away as possible - * A distance of 255 does not guarantee silence; in such a case, you might - * want to try changing the chunk's volume, or just cull the sample from the - * mixing process with Mix_HaltChannel(). - * For efficiency, the precision of this effect may be limited (distances 1 - * through 7 might all produce the same effect, 8 through 15 are equal, etc). - * (distance) is an integer between 0 and 255 that specifies the space - * between the sound and the listener. The larger the number, the further - * away the sound is. - * Setting (distance) to 0 unregisters this effect, since the data would be - * unchanged. - * If you need more precise positional audio, consider using OpenAL for - * spatialized effects instead of SDL_mixer. This is only meant to be a - * basic effect for simple "3D" games. - * - * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and - * the distance attenuation will be done to the final mixed stream before - * passing it on to the audio device. - * - * This uses the Mix_RegisterEffect() API internally. - * - * returns zero if error (no such channel or Mix_RegisterEffect() fails), - * nonzero if position effect is enabled. - * Error messages can be retrieved from Mix_GetError(). - */ -extern DECLSPEC int SDLCALL Mix_SetDistance(int channel, Uint8 distance); - - -/* - * !!! FIXME : Haven't implemented, since the effect goes past the - * end of the sound buffer. Will have to think about this. - * --ryan. - */ -#if 0 -/* Causes an echo effect to be mixed into a sound. (echo) is the amount - * of echo to mix. 0 is no echo, 255 is infinite (and probably not - * what you want). - * - * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and - * the reverbing will be done to the final mixed stream before passing it on - * to the audio device. - * - * This uses the Mix_RegisterEffect() API internally. If you specify an echo - * of zero, the effect is unregistered, as the data is already in that state. - * - * returns zero if error (no such channel or Mix_RegisterEffect() fails), - * nonzero if reversing effect is enabled. - * Error messages can be retrieved from Mix_GetError(). - */ -extern no_parse_DECLSPEC int SDLCALL Mix_SetReverb(int channel, Uint8 echo); -#endif - -/* Causes a channel to reverse its stereo. This is handy if the user has his - * speakers hooked up backwards, or you would like to have a minor bit of - * psychedelia in your sound code. :) Calling this function with (flip) - * set to non-zero reverses the chunks's usual channels. If (flip) is zero, - * the effect is unregistered. - * - * This uses the Mix_RegisterEffect() API internally, and thus is probably - * more CPU intensive than having the user just plug in his speakers - * correctly. Mix_SetReverseStereo() returns without registering the effect - * function if the audio device is not configured for stereo output. - * - * If you specify MIX_CHANNEL_POST for (channel), then this the effect is used - * on the final mixed stream before sending it on to the audio device (a - * posteffect). - * - * returns zero if error (no such channel or Mix_RegisterEffect() fails), - * nonzero if reversing effect is enabled. Note that an audio device in mono - * mode is a no-op, but this call will return successful in that case. - * Error messages can be retrieved from Mix_GetError(). - */ -extern DECLSPEC int SDLCALL Mix_SetReverseStereo(int channel, int flip); - -/* end of effects API. --ryan. */ - - -/* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate - them dynamically to the next sample if requested with a -1 value below. - Returns the number of reserved channels. - */ -extern DECLSPEC int SDLCALL Mix_ReserveChannels(int num); - -/* Channel grouping functions */ - -/* Attach a tag to a channel. A tag can be assigned to several mixer - channels, to form groups of channels. - If 'tag' is -1, the tag is removed (actually -1 is the tag used to - represent the group of all the channels). - Returns true if everything was OK. - */ -extern DECLSPEC int SDLCALL Mix_GroupChannel(int which, int tag); -/* Assign several consecutive channels to a group */ -extern DECLSPEC int SDLCALL Mix_GroupChannels(int from, int to, int tag); -/* Finds the first available channel in a group of channels, - returning -1 if none are available. - */ -extern DECLSPEC int SDLCALL Mix_GroupAvailable(int tag); -/* Returns the number of channels in a group. This is also a subtle - way to get the total number of channels when 'tag' is -1 - */ -extern DECLSPEC int SDLCALL Mix_GroupCount(int tag); -/* Finds the "oldest" sample playing in a group of channels */ -extern DECLSPEC int SDLCALL Mix_GroupOldest(int tag); -/* Finds the "most recent" (i.e. last) sample playing in a group of channels */ -extern DECLSPEC int SDLCALL Mix_GroupNewer(int tag); - -/* Play an audio chunk on a specific channel. - If the specified channel is -1, play on the first free channel. - If 'loops' is greater than zero, loop the sound that many times. - If 'loops' is -1, loop inifinitely (~65000 times). - Returns which channel was used to play the sound. -*/ -#define Mix_PlayChannel(channel,chunk,loops) Mix_PlayChannelTimed(channel,chunk,loops,-1) -/* The same as above, but the sound is played at most 'ticks' milliseconds */ -extern DECLSPEC int SDLCALL Mix_PlayChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ticks); -extern DECLSPEC int SDLCALL Mix_PlayMusic(Mix_Music *music, int loops); - -/* Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions */ -extern DECLSPEC int SDLCALL Mix_FadeInMusic(Mix_Music *music, int loops, int ms); -extern DECLSPEC int SDLCALL Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position); -#define Mix_FadeInChannel(channel,chunk,loops,ms) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1) -extern DECLSPEC int SDLCALL Mix_FadeInChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ms, int ticks); - -/* Set the volume in the range of 0-128 of a specific channel or chunk. - If the specified channel is -1, set volume for all channels. - Returns the original volume. - If the specified volume is -1, just return the current volume. -*/ -extern DECLSPEC int SDLCALL Mix_Volume(int channel, int volume); -extern DECLSPEC int SDLCALL Mix_VolumeChunk(Mix_Chunk *chunk, int volume); -extern DECLSPEC int SDLCALL Mix_VolumeMusic(int volume); - -/* Halt playing of a particular channel */ -extern DECLSPEC int SDLCALL Mix_HaltChannel(int channel); -extern DECLSPEC int SDLCALL Mix_HaltGroup(int tag); -extern DECLSPEC int SDLCALL Mix_HaltMusic(void); - -/* Change the expiration delay for a particular channel. - The sample will stop playing after the 'ticks' milliseconds have elapsed, - or remove the expiration if 'ticks' is -1 -*/ -extern DECLSPEC int SDLCALL Mix_ExpireChannel(int channel, int ticks); - -/* Halt a channel, fading it out progressively till it's silent - The ms parameter indicates the number of milliseconds the fading - will take. - */ -extern DECLSPEC int SDLCALL Mix_FadeOutChannel(int which, int ms); -extern DECLSPEC int SDLCALL Mix_FadeOutGroup(int tag, int ms); -extern DECLSPEC int SDLCALL Mix_FadeOutMusic(int ms); - -/* Query the fading status of a channel */ -extern DECLSPEC Mix_Fading SDLCALL Mix_FadingMusic(void); -extern DECLSPEC Mix_Fading SDLCALL Mix_FadingChannel(int which); - -/* Pause/Resume a particular channel */ -extern DECLSPEC void SDLCALL Mix_Pause(int channel); -extern DECLSPEC void SDLCALL Mix_Resume(int channel); -extern DECLSPEC int SDLCALL Mix_Paused(int channel); - -/* Pause/Resume the music stream */ -extern DECLSPEC void SDLCALL Mix_PauseMusic(void); -extern DECLSPEC void SDLCALL Mix_ResumeMusic(void); -extern DECLSPEC void SDLCALL Mix_RewindMusic(void); -extern DECLSPEC int SDLCALL Mix_PausedMusic(void); - -/* Set the current position in the music stream. - This returns 0 if successful, or -1 if it failed or isn't implemented. - This function is only implemented for MOD music formats (set pattern - order number) and for OGG, FLAC, MP3_MAD, MP3_MPG and MODPLUG music - (set position in seconds), at the moment. -*/ -extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position); - -/* Check the status of a specific channel. - If the specified channel is -1, check all channels. -*/ -extern DECLSPEC int SDLCALL Mix_Playing(int channel); -extern DECLSPEC int SDLCALL Mix_PlayingMusic(void); - -/* Stop music and set external music playback command */ -extern DECLSPEC int SDLCALL Mix_SetMusicCMD(const char *command); - -/* Synchro value is set by MikMod from modules while playing */ -extern DECLSPEC int SDLCALL Mix_SetSynchroValue(int value); -extern DECLSPEC int SDLCALL Mix_GetSynchroValue(void); - -/* Set/Get/Iterate SoundFonts paths to use by supported MIDI backends */ -extern DECLSPEC int SDLCALL Mix_SetSoundFonts(const char *paths); -extern DECLSPEC const char* SDLCALL Mix_GetSoundFonts(void); -extern DECLSPEC int SDLCALL Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data); - -/* Get the Mix_Chunk currently associated with a mixer channel - Returns NULL if it's an invalid channel, or there's no chunk associated. -*/ -extern DECLSPEC Mix_Chunk * SDLCALL Mix_GetChunk(int channel); - -/* Close the mixer, halting all playing audio */ -extern DECLSPEC void SDLCALL Mix_CloseAudio(void); - -/* We'll use SDL for reporting errors */ -#define Mix_SetError SDL_SetError -#define Mix_GetError SDL_GetError -#define Mix_ClearError SDL_ClearError - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_MIXER_H_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/acinclude/libtool.m4 b/acinclude/libtool.m4 deleted file mode 100644 index 03771a7..0000000 --- a/acinclude/libtool.m4 +++ /dev/null @@ -1,7373 +0,0 @@ -############################################################################## -# Based on libtool-2.2.6a -# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008 Free Software Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -m4_define([_LT_COPYING], [dnl -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008 Free Software Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is part of GNU Libtool. -# -# GNU Libtool is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, or -# obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -]) - -# serial 56 LT_INIT - - -# LT_PREREQ(VERSION) -# ------------------ -# Complain and exit if this libtool version is less that VERSION. -m4_defun([LT_PREREQ], -[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, - [m4_default([$3], - [m4_fatal([Libtool version $1 or higher is required], - 63)])], - [$2])]) - - -# _LT_CHECK_BUILDDIR -# ------------------ -# Complain if the absolute build directory name contains unusual characters -m4_defun([_LT_CHECK_BUILDDIR], -[case `pwd` in - *\ * | *\ *) - AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; -esac -]) - - -# LT_INIT([OPTIONS]) -# ------------------ -AC_DEFUN([LT_INIT], -[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT -AC_BEFORE([$0], [LT_LANG])dnl -AC_BEFORE([$0], [LT_OUTPUT])dnl -AC_BEFORE([$0], [LTDL_INIT])dnl -m4_require([_LT_CHECK_BUILDDIR])dnl - -dnl Autoconf doesn't catch unexpanded LT_ macros by default: -m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl -m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl -dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 -dnl unless we require an AC_DEFUNed macro: -AC_REQUIRE([LTOPTIONS_VERSION])dnl -AC_REQUIRE([LTSUGAR_VERSION])dnl -AC_REQUIRE([LTVERSION_VERSION])dnl -AC_REQUIRE([LTOBSOLETE_VERSION])dnl -m4_require([_LT_PROG_LTMAIN])dnl - -dnl Parse OPTIONS -_LT_SET_OPTIONS([$0], [$1]) - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ltmain" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' -AC_SUBST(LIBTOOL)dnl - -_LT_SETUP - -# Only expand once: -m4_define([LT_INIT]) -])# LT_INIT - -# Old names: -AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) -AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_PROG_LIBTOOL], []) -dnl AC_DEFUN([AM_PROG_LIBTOOL], []) - - -# _LT_CC_BASENAME(CC) -# ------------------- -# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. -m4_defun([_LT_CC_BASENAME], -[for cc_temp in $1""; do - case $cc_temp in - compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; - distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` -]) - - -# _LT_FILEUTILS_DEFAULTS -# ---------------------- -# It is okay to use these file commands and assume they have been set -# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. -m4_defun([_LT_FILEUTILS_DEFAULTS], -[: ${CP="cp -f"} -: ${MV="mv -f"} -: ${RM="rm -f"} -])# _LT_FILEUTILS_DEFAULTS - - -# _LT_SETUP -# --------- -m4_defun([_LT_SETUP], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -_LT_DECL([], [host_alias], [0], [The host system])dnl -_LT_DECL([], [host], [0])dnl -_LT_DECL([], [host_os], [0])dnl -dnl -_LT_DECL([], [build_alias], [0], [The build system])dnl -_LT_DECL([], [build], [0])dnl -_LT_DECL([], [build_os], [0])dnl -dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([LT_PATH_LD])dnl -AC_REQUIRE([LT_PATH_NM])dnl -dnl -AC_REQUIRE([AC_PROG_LN_S])dnl -test -z "$LN_S" && LN_S="ln -s" -_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl -dnl -AC_REQUIRE([LT_CMD_MAX_LEN])dnl -_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl -_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl -dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_CHECK_SHELL_FEATURES])dnl -m4_require([_LT_CMD_RELOAD])dnl -m4_require([_LT_CHECK_MAGIC_METHOD])dnl -m4_require([_LT_CMD_OLD_ARCHIVE])dnl -m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl - -_LT_CONFIG_LIBTOOL_INIT([ -# See if we are running on zsh, and set the options which allow our -# commands through without removal of \ escapes INIT. -if test -n "\${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi -]) -if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi - -_LT_CHECK_OBJDIR - -m4_require([_LT_TAG_COMPILER])dnl -_LT_PROG_ECHO_BACKSLASH - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\([["`\\]]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to delay expansion of an escaped single quote. -delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - -# Global variables: -ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a - -with_gnu_ld="$lt_cv_prog_gnu_ld" - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS -test -z "$LD" && LD=ld -test -z "$ac_objext" && ac_objext=o - -_LT_CC_BASENAME([$compiler]) - -# Only perform the check for file, if the check method requires it -test -z "$MAGIC_CMD" && MAGIC_CMD=file -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - _LT_PATH_MAGIC - fi - ;; -esac - -# Use C for the default configuration in the libtool script -LT_SUPPORTED_TAG([CC]) -_LT_LANG_C_CONFIG -_LT_LANG_DEFAULT_CONFIG -_LT_CONFIG_COMMANDS -])# _LT_SETUP - - -# _LT_PROG_LTMAIN -# --------------- -# Note that this code is called both from `configure', and `config.status' -# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, -# `config.status' has no value for ac_aux_dir unless we are using Automake, -# so we pass a copy along to make sure it has a sensible value anyway. -m4_defun([_LT_PROG_LTMAIN], -[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl -_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) -ltmain="$ac_aux_dir/ltmain.sh" -])# _LT_PROG_LTMAIN - - -## ------------------------------------- ## -## Accumulate code for creating libtool. ## -## ------------------------------------- ## - -# So that we can recreate a full libtool script including additional -# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS -# in macros and then make a single call at the end using the `libtool' -# label. - - -# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) -# ---------------------------------------- -# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. -m4_define([_LT_CONFIG_LIBTOOL_INIT], -[m4_ifval([$1], - [m4_append([_LT_OUTPUT_LIBTOOL_INIT], - [$1 -])])]) - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_INIT]) - - -# _LT_CONFIG_LIBTOOL([COMMANDS]) -# ------------------------------ -# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. -m4_define([_LT_CONFIG_LIBTOOL], -[m4_ifval([$1], - [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], - [$1 -])])]) - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) - - -# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) -# ----------------------------------------------------- -m4_defun([_LT_CONFIG_SAVE_COMMANDS], -[_LT_CONFIG_LIBTOOL([$1]) -_LT_CONFIG_LIBTOOL_INIT([$2]) -]) - - -# _LT_FORMAT_COMMENT([COMMENT]) -# ----------------------------- -# Add leading comment marks to the start of each line, and a trailing -# full-stop to the whole comment if one is not present already. -m4_define([_LT_FORMAT_COMMENT], -[m4_ifval([$1], [ -m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], - [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) -)]) - - - -## ------------------------ ## -## FIXME: Eliminate VARNAME ## -## ------------------------ ## - - -# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) -# ------------------------------------------------------------------- -# CONFIGNAME is the name given to the value in the libtool script. -# VARNAME is the (base) name used in the configure script. -# VALUE may be 0, 1 or 2 for a computed quote escaped value based on -# VARNAME. Any other value will be used directly. -m4_define([_LT_DECL], -[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], - [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], - [m4_ifval([$1], [$1], [$2])]) - lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) - m4_ifval([$4], - [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) - lt_dict_add_subkey([lt_decl_dict], [$2], - [tagged?], [m4_ifval([$5], [yes], [no])])]) -]) - - -# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) -# -------------------------------------------------------- -m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) - - -# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) -# ------------------------------------------------ -m4_define([lt_decl_tag_varnames], -[_lt_decl_filter([tagged?], [yes], $@)]) - - -# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) -# --------------------------------------------------------- -m4_define([_lt_decl_filter], -[m4_case([$#], - [0], [m4_fatal([$0: too few arguments: $#])], - [1], [m4_fatal([$0: too few arguments: $#: $1])], - [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], - [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], - [lt_dict_filter([lt_decl_dict], $@)])[]dnl -]) - - -# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) -# -------------------------------------------------- -m4_define([lt_decl_quote_varnames], -[_lt_decl_filter([value], [1], $@)]) - - -# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) -# --------------------------------------------------- -m4_define([lt_decl_dquote_varnames], -[_lt_decl_filter([value], [2], $@)]) - - -# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) -# --------------------------------------------------- -m4_define([lt_decl_varnames_tagged], -[m4_assert([$# <= 2])dnl -_$0(m4_quote(m4_default([$1], [[, ]])), - m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), - m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) -m4_define([_lt_decl_varnames_tagged], -[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) - - -# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) -# ------------------------------------------------ -m4_define([lt_decl_all_varnames], -[_$0(m4_quote(m4_default([$1], [[, ]])), - m4_if([$2], [], - m4_quote(lt_decl_varnames), - m4_quote(m4_shift($@))))[]dnl -]) -m4_define([_lt_decl_all_varnames], -[lt_join($@, lt_decl_varnames_tagged([$1], - lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl -]) - - -# _LT_CONFIG_STATUS_DECLARE([VARNAME]) -# ------------------------------------ -# Quote a variable value, and forward it to `config.status' so that its -# declaration there will have the same value as in `configure'. VARNAME -# must have a single quote delimited value for this to work. -m4_define([_LT_CONFIG_STATUS_DECLARE], -[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`']) - - -# _LT_CONFIG_STATUS_DECLARATIONS -# ------------------------------ -# We delimit libtool config variables with single quotes, so when -# we write them to config.status, we have to be sure to quote all -# embedded single quotes properly. In configure, this macro expands -# each variable declared with _LT_DECL (and _LT_TAGDECL) into: -# -# ='`$ECHO "X$" | $Xsed -e "$delay_single_quote_subst"`' -m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], -[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), - [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) - - -# _LT_LIBTOOL_TAGS -# ---------------- -# Output comment and list of tags supported by the script -m4_defun([_LT_LIBTOOL_TAGS], -[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl -available_tags="_LT_TAGS"dnl -]) - - -# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) -# ----------------------------------- -# Extract the dictionary values for VARNAME (optionally with TAG) and -# expand to a commented shell variable setting: -# -# # Some comment about what VAR is for. -# visible_name=$lt_internal_name -m4_define([_LT_LIBTOOL_DECLARE], -[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], - [description])))[]dnl -m4_pushdef([_libtool_name], - m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl -m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), - [0], [_libtool_name=[$]$1], - [1], [_libtool_name=$lt_[]$1], - [2], [_libtool_name=$lt_[]$1], - [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl -m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl -]) - - -# _LT_LIBTOOL_CONFIG_VARS -# ----------------------- -# Produce commented declarations of non-tagged libtool config variables -# suitable for insertion in the LIBTOOL CONFIG section of the `libtool' -# script. Tagged libtool config variables (even for the LIBTOOL CONFIG -# section) are produced by _LT_LIBTOOL_TAG_VARS. -m4_defun([_LT_LIBTOOL_CONFIG_VARS], -[m4_foreach([_lt_var], - m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), - [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) - - -# _LT_LIBTOOL_TAG_VARS(TAG) -# ------------------------- -m4_define([_LT_LIBTOOL_TAG_VARS], -[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), - [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) - - -# _LT_TAGVAR(VARNAME, [TAGNAME]) -# ------------------------------ -m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) - - -# _LT_CONFIG_COMMANDS -# ------------------- -# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of -# variables for single and double quote escaping we saved from calls -# to _LT_DECL, we can put quote escaped variables declarations -# into `config.status', and then the shell code to quote escape them in -# for loops in `config.status'. Finally, any additional code accumulated -# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. -m4_defun([_LT_CONFIG_COMMANDS], -[AC_PROVIDE_IFELSE([LT_OUTPUT], - dnl If the libtool generation code has been placed in $CONFIG_LT, - dnl instead of duplicating it all over again into config.status, - dnl then we will have config.status run $CONFIG_LT later, so it - dnl needs to know what name is stored there: - [AC_CONFIG_COMMANDS([libtool], - [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], - dnl If the libtool generation code is destined for config.status, - dnl expand the accumulated commands and init code now: - [AC_CONFIG_COMMANDS([libtool], - [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) -])#_LT_CONFIG_COMMANDS - - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], -[ - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -sed_quote_subst='$sed_quote_subst' -double_quote_subst='$double_quote_subst' -delay_variable_subst='$delay_variable_subst' -_LT_CONFIG_STATUS_DECLARATIONS -LTCC='$LTCC' -LTCFLAGS='$LTCFLAGS' -compiler='$compiler_DEFAULT' - -# Quote evaled strings. -for var in lt_decl_all_varnames([[ \ -]], lt_decl_quote_varnames); do - case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in - *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Double-quote double-evaled strings. -for var in lt_decl_all_varnames([[ \ -]], lt_decl_dquote_varnames); do - case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in - *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Fix-up fallback echo if it was mangled by the above quoting rules. -case \$lt_ECHO in -*'\\\[$]0 --fallback-echo"')dnl " - lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\` - ;; -esac - -_LT_OUTPUT_LIBTOOL_INIT -]) - - -# LT_OUTPUT -# --------- -# This macro allows early generation of the libtool script (before -# AC_OUTPUT is called), incase it is used in configure for compilation -# tests. -AC_DEFUN([LT_OUTPUT], -[: ${CONFIG_LT=./config.lt} -AC_MSG_NOTICE([creating $CONFIG_LT]) -cat >"$CONFIG_LT" <<_LTEOF -#! $SHELL -# Generated by $as_me. -# Run this file to recreate a libtool stub with the current configuration. - -lt_cl_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_LTEOF - -cat >>"$CONFIG_LT" <<\_LTEOF -AS_SHELL_SANITIZE -_AS_PREPARE - -exec AS_MESSAGE_FD>&1 -exec AS_MESSAGE_LOG_FD>>config.log -{ - echo - AS_BOX([Running $as_me.]) -} >&AS_MESSAGE_LOG_FD - -lt_cl_help="\ -\`$as_me' creates a local libtool stub from the current configuration, -for use in further configure time tests before the real libtool is -generated. - -Usage: $[0] [[OPTIONS]] - - -h, --help print this help, then exit - -V, --version print version number, then exit - -q, --quiet do not print progress messages - -d, --debug don't remove temporary files - -Report bugs to ." - -lt_cl_version="\ -m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl -m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) -configured by $[0], generated by m4_PACKAGE_STRING. - -Copyright (C) 2008 Free Software Foundation, Inc. -This config.lt script is free software; the Free Software Foundation -gives unlimited permision to copy, distribute and modify it." - -while test $[#] != 0 -do - case $[1] in - --version | --v* | -V ) - echo "$lt_cl_version"; exit 0 ;; - --help | --h* | -h ) - echo "$lt_cl_help"; exit 0 ;; - --debug | --d* | -d ) - debug=: ;; - --quiet | --q* | --silent | --s* | -q ) - lt_cl_silent=: ;; - - -*) AC_MSG_ERROR([unrecognized option: $[1] -Try \`$[0] --help' for more information.]) ;; - - *) AC_MSG_ERROR([unrecognized argument: $[1] -Try \`$[0] --help' for more information.]) ;; - esac - shift -done - -if $lt_cl_silent; then - exec AS_MESSAGE_FD>/dev/null -fi -_LTEOF - -cat >>"$CONFIG_LT" <<_LTEOF -_LT_OUTPUT_LIBTOOL_COMMANDS_INIT -_LTEOF - -cat >>"$CONFIG_LT" <<\_LTEOF -AC_MSG_NOTICE([creating $ofile]) -_LT_OUTPUT_LIBTOOL_COMMANDS -AS_EXIT(0) -_LTEOF -chmod +x "$CONFIG_LT" - -# configure is writing to config.log, but config.lt does its own redirection, -# appending to config.log, which fails on DOS, as config.log is still kept -# open by configure. Here we exec the FD to /dev/null, effectively closing -# config.log, so it can be properly (re)opened and appended to by config.lt. -if test "$no_create" != yes; then - lt_cl_success=: - test "$silent" = yes && - lt_config_lt_args="$lt_config_lt_args --quiet" - exec AS_MESSAGE_LOG_FD>/dev/null - $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false - exec AS_MESSAGE_LOG_FD>>config.log - $lt_cl_success || AS_EXIT(1) -fi -])# LT_OUTPUT - - -# _LT_CONFIG(TAG) -# --------------- -# If TAG is the built-in tag, create an initial libtool script with a -# default configuration from the untagged config vars. Otherwise add code -# to config.status for appending the configuration named by TAG from the -# matching tagged config vars. -m4_defun([_LT_CONFIG], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -_LT_CONFIG_SAVE_COMMANDS([ - m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl - m4_if(_LT_TAG, [C], [ - # See if we are running on zsh, and set the options which allow our - # commands through without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST - fi - - cfgfile="${ofile}T" - trap "$RM \"$cfgfile\"; exit 1" 1 2 15 - $RM "$cfgfile" - - cat <<_LT_EOF >> "$cfgfile" -#! $SHELL - -# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -_LT_COPYING -_LT_LIBTOOL_TAGS - -# ### BEGIN LIBTOOL CONFIG -_LT_LIBTOOL_CONFIG_VARS -_LT_LIBTOOL_TAG_VARS -# ### END LIBTOOL CONFIG - -_LT_EOF - - case $host_os in - aix3*) - cat <<\_LT_EOF >> "$cfgfile" -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES -fi -_LT_EOF - ;; - esac - - _LT_PROG_LTMAIN - - # We use sed instead of cat because bash on DJGPP gets confused if - # if finds mixed CR/LF and LF-only lines. Since sed operates in - # text mode, it properly converts lines to CR/LF. This bash problem - # is reportedly fixed, but why not run on old versions too? - sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - _LT_PROG_XSI_SHELLFNS - - sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - mv -f "$cfgfile" "$ofile" || - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" -], -[cat <<_LT_EOF >> "$ofile" - -dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded -dnl in a comment (ie after a #). -# ### BEGIN LIBTOOL TAG CONFIG: $1 -_LT_LIBTOOL_TAG_VARS(_LT_TAG) -# ### END LIBTOOL TAG CONFIG: $1 -_LT_EOF -])dnl /m4_if -], -[m4_if([$1], [], [ - PACKAGE='$PACKAGE' - VERSION='$VERSION' - TIMESTAMP='$TIMESTAMP' - RM='$RM' - ofile='$ofile'], []) -])dnl /_LT_CONFIG_SAVE_COMMANDS -])# _LT_CONFIG - - -# LT_SUPPORTED_TAG(TAG) -# --------------------- -# Trace this macro to discover what tags are supported by the libtool -# --tag option, using: -# autoconf --trace 'LT_SUPPORTED_TAG:$1' -AC_DEFUN([LT_SUPPORTED_TAG], []) - - -# C support is built-in for now -m4_define([_LT_LANG_C_enabled], []) -m4_define([_LT_TAGS], []) - - -# LT_LANG(LANG) -# ------------- -# Enable libtool support for the given language if not already enabled. -AC_DEFUN([LT_LANG], -[AC_BEFORE([$0], [LT_OUTPUT])dnl -m4_case([$1], - [C], [_LT_LANG(C)], - [C++], [_LT_LANG(CXX)], - [Java], [_LT_LANG(GCJ)], - [Fortran 77], [_LT_LANG(F77)], - [Fortran], [_LT_LANG(FC)], - [Windows Resource], [_LT_LANG(RC)], - [m4_ifdef([_LT_LANG_]$1[_CONFIG], - [_LT_LANG($1)], - [m4_fatal([$0: unsupported language: "$1"])])])dnl -])# LT_LANG - - -# _LT_LANG(LANGNAME) -# ------------------ -m4_defun([_LT_LANG], -[m4_ifdef([_LT_LANG_]$1[_enabled], [], - [LT_SUPPORTED_TAG([$1])dnl - m4_append([_LT_TAGS], [$1 ])dnl - m4_define([_LT_LANG_]$1[_enabled], [])dnl - _LT_LANG_$1_CONFIG($1)])dnl -])# _LT_LANG - - -# _LT_LANG_DEFAULT_CONFIG -# ----------------------- -m4_defun([_LT_LANG_DEFAULT_CONFIG], -[AC_PROVIDE_IFELSE([AC_PROG_CXX], - [LT_LANG(CXX)], - [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) - -AC_PROVIDE_IFELSE([AC_PROG_F77], - [LT_LANG(F77)], - [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) - -AC_PROVIDE_IFELSE([AC_PROG_FC], - [LT_LANG(FC)], - [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) - -dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal -dnl pulling things in needlessly. -AC_PROVIDE_IFELSE([AC_PROG_GCJ], - [LT_LANG(GCJ)], - [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], - [LT_LANG(GCJ)], - [AC_PROVIDE_IFELSE([LT_PROG_GCJ], - [LT_LANG(GCJ)], - [m4_ifdef([AC_PROG_GCJ], - [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) - m4_ifdef([A][M_PROG_GCJ], - [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) - m4_ifdef([LT_PROG_GCJ], - [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) - -AC_PROVIDE_IFELSE([LT_PROG_RC], - [LT_LANG(RC)], - [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) -])# _LT_LANG_DEFAULT_CONFIG - -# Obsolete macros: -AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) -AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) -AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) -AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_CXX], []) -dnl AC_DEFUN([AC_LIBTOOL_F77], []) -dnl AC_DEFUN([AC_LIBTOOL_FC], []) -dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) - - -# _LT_TAG_COMPILER -# ---------------- -m4_defun([_LT_TAG_COMPILER], -[AC_REQUIRE([AC_PROG_CC])dnl - -_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl -_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl -_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl -_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC -])# _LT_TAG_COMPILER - - -# _LT_COMPILER_BOILERPLATE -# ------------------------ -# Check for compiler boilerplate output or warnings with -# the simple compiler test code. -m4_defun([_LT_COMPILER_BOILERPLATE], -[m4_require([_LT_DECL_SED])dnl -ac_outfile=conftest.$ac_objext -echo "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$RM conftest* -])# _LT_COMPILER_BOILERPLATE - - -# _LT_LINKER_BOILERPLATE -# ---------------------- -# Check for linker boilerplate output or warnings with -# the simple link test code. -m4_defun([_LT_LINKER_BOILERPLATE], -[m4_require([_LT_DECL_SED])dnl -ac_outfile=conftest.$ac_objext -echo "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$RM -r conftest* -])# _LT_LINKER_BOILERPLATE - -# _LT_REQUIRED_DARWIN_CHECKS -# ------------------------- -m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ - case $host_os in - rhapsody* | darwin*) - AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) - AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) - AC_CHECK_TOOL([LIPO], [lipo], [:]) - AC_CHECK_TOOL([OTOOL], [otool], [:]) - AC_CHECK_TOOL([OTOOL64], [otool64], [:]) - _LT_DECL([], [DSYMUTIL], [1], - [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) - _LT_DECL([], [NMEDIT], [1], - [Tool to change global to local symbols on Mac OS X]) - _LT_DECL([], [LIPO], [1], - [Tool to manipulate fat objects and archives on Mac OS X]) - _LT_DECL([], [OTOOL], [1], - [ldd/readelf like tool for Mach-O binaries on Mac OS X]) - _LT_DECL([], [OTOOL64], [1], - [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) - - AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], - [lt_cv_apple_cc_single_mod=no - if test -z "${LT_MULTI_MODULE}"; then - # By default we will add the -single_module flag. You can override - # by either setting the environment variable LT_MULTI_MODULE - # non-empty at configure time, or by adding -multi_module to the - # link flags. - rm -rf libconftest.dylib* - echo "int foo(void){return 1;}" > conftest.c - echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ --dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD - $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ - -dynamiclib -Wl,-single_module conftest.c 2>conftest.err - _lt_result=$? - if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then - lt_cv_apple_cc_single_mod=yes - else - cat conftest.err >&AS_MESSAGE_LOG_FD - fi - rm -rf libconftest.dylib* - rm -f conftest.* - fi]) - AC_CACHE_CHECK([for -exported_symbols_list linker flag], - [lt_cv_ld_exported_symbols_list], - [lt_cv_ld_exported_symbols_list=no - save_LDFLAGS=$LDFLAGS - echo "_main" > conftest.sym - LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], - [lt_cv_ld_exported_symbols_list=yes], - [lt_cv_ld_exported_symbols_list=no]) - LDFLAGS="$save_LDFLAGS" - ]) - case $host_os in - rhapsody* | darwin1.[[012]]) - _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; - darwin1.*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - darwin*) # darwin 5.x on - # if running on 10.5 or later, the deployment target defaults - # to the OS version, if on x86, and 10.4, the deployment - # target defaults to 10.4. Don't you love it? - case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - 10.[[012]]*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - 10.*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - esac - ;; - esac - if test "$lt_cv_apple_cc_single_mod" = "yes"; then - _lt_dar_single_mod='$single_module' - fi - if test "$lt_cv_ld_exported_symbols_list" = "yes"; then - _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' - else - _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - if test "$DSYMUTIL" != ":"; then - _lt_dsymutil='~$DSYMUTIL $lib || :' - else - _lt_dsymutil= - fi - ;; - esac -]) - - -# _LT_DARWIN_LINKER_FEATURES -# -------------------------- -# Checks for linker and compiler features on darwin -m4_defun([_LT_DARWIN_LINKER_FEATURES], -[ - m4_require([_LT_REQUIRED_DARWIN_CHECKS]) - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_automatic, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_TAGVAR(whole_archive_flag_spec, $1)='' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" - case $cc_basename in - ifort*) _lt_dar_can_shared=yes ;; - *) _lt_dar_can_shared=$GCC ;; - esac - if test "$_lt_dar_can_shared" = "yes"; then - output_verbose_link_cmd=echo - _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" - m4_if([$1], [CXX], -[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then - _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" - fi -],[]) - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi -]) - -# _LT_SYS_MODULE_PATH_AIX -# ----------------------- -# Links a minimal program and checks the executable -# for the system default hardcoded library path. In most cases, -# this is /usr/lib:/lib, but when the MPI compilers are used -# the location of the communication and MPI libs are included too. -# If we don't find anything, use the default library path according -# to the aix ld manual. -m4_defun([_LT_SYS_MODULE_PATH_AIX], -[m4_require([_LT_DECL_SED])dnl -AC_LINK_IFELSE(AC_LANG_PROGRAM,[ -lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\(.*\)$/\1/ - p - } - }' -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then - aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -fi],[]) -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -])# _LT_SYS_MODULE_PATH_AIX - - -# _LT_SHELL_INIT(ARG) -# ------------------- -m4_define([_LT_SHELL_INIT], -[ifdef([AC_DIVERSION_NOTICE], - [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], - [AC_DIVERT_PUSH(NOTICE)]) -$1 -AC_DIVERT_POP -])# _LT_SHELL_INIT - - -# _LT_PROG_ECHO_BACKSLASH -# ----------------------- -# Add some code to the start of the generated configure script which -# will find an echo command which doesn't interpret backslashes. -m4_defun([_LT_PROG_ECHO_BACKSLASH], -[_LT_SHELL_INIT([ -# Check that we are running under the correct shell. -SHELL=${CONFIG_SHELL-/bin/sh} - -case X$lt_ECHO in -X*--fallback-echo) - # Remove one level of quotation (which was required for Make). - ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` - ;; -esac - -ECHO=${lt_ECHO-echo} -if test "X[$]1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X[$]1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then - # Yippee, $ECHO works! - : -else - # Restart under the correct shell. - exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} -fi - -if test "X[$]1" = X--fallback-echo; then - # used as fallback echo - shift - cat <<_LT_EOF -[$]* -_LT_EOF - exit 0 -fi - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -if test -z "$lt_ECHO"; then - if test "X${echo_test_string+set}" != Xset; then - # find a string as large as possible, as long as the shell can cope with it - for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do - # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... - if { echo_test_string=`eval $cmd`; } 2>/dev/null && - { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null - then - break - fi - done - fi - - if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - : - else - # The Solaris, AIX, and Digital Unix default echo programs unquote - # backslashes. This makes it impossible to quote backslashes using - # echo "$something" | sed 's/\\/\\\\/g' - # - # So, first we look for a working echo in the user's PATH. - - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for dir in $PATH /usr/ucb; do - IFS="$lt_save_ifs" - if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && - test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - ECHO="$dir/echo" - break - fi - done - IFS="$lt_save_ifs" - - if test "X$ECHO" = Xecho; then - # We didn't find a better echo, so look for alternatives. - if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # This shell has a builtin print -r that does the trick. - ECHO='print -r' - elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && - test "X$CONFIG_SHELL" != X/bin/ksh; then - # If we have ksh, try running configure again with it. - ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} - export ORIGINAL_CONFIG_SHELL - CONFIG_SHELL=/bin/ksh - export CONFIG_SHELL - exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} - else - # Try using printf. - ECHO='printf %s\n' - if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # Cool, printf works - : - elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL - export CONFIG_SHELL - SHELL="$CONFIG_SHELL" - export SHELL - ECHO="$CONFIG_SHELL [$]0 --fallback-echo" - elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - ECHO="$CONFIG_SHELL [$]0 --fallback-echo" - else - # maybe with a smaller string... - prev=: - - for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do - if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null - then - break - fi - prev="$cmd" - done - - if test "$prev" != 'sed 50q "[$]0"'; then - echo_test_string=`eval $prev` - export echo_test_string - exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} - else - # Oops. We lost completely, so just stick with echo. - ECHO=echo - fi - fi - fi - fi - fi -fi - -# Copy echo and quote the copy suitably for passing to libtool from -# the Makefile, instead of quoting the original, which is used later. -lt_ECHO=$ECHO -if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then - lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" -fi - -AC_SUBST(lt_ECHO) -]) -_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) -_LT_DECL([], [ECHO], [1], - [An echo program that does not interpret backslashes]) -])# _LT_PROG_ECHO_BACKSLASH - - -# _LT_ENABLE_LOCK -# --------------- -m4_defun([_LT_ENABLE_LOCK], -[AC_ARG_ENABLE([libtool-lock], - [AS_HELP_STRING([--disable-libtool-lock], - [avoid locking (might break parallel builds)])]) -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -ia64-*-hpux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.$ac_objext` in - *ELF-32*) - HPUX_IA64_MODE="32" - ;; - *ELF-64*) - HPUX_IA64_MODE="64" - ;; - esac - fi - rm -rf conftest* - ;; -*-*-irix6*) - # Find out which ABI we are using. - echo '[#]line __oline__ "configure"' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - if test "$lt_cv_prog_gnu_ld" = yes; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -melf32bsmip" - ;; - *N32*) - LD="${LD-ld} -melf32bmipn32" - ;; - *64-bit*) - LD="${LD-ld} -melf64bmip" - ;; - esac - else - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - fi - rm -rf conftest* - ;; - -x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ -s390*-*linux*|s390*-*tpf*|sparc*-*linux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *32-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_i386_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_i386" - ;; - ppc64-*linux*|powerpc64-*linux*) - LD="${LD-ld} -m elf32ppclinux" - ;; - s390x-*linux*) - LD="${LD-ld} -m elf_s390" - ;; - sparc64-*linux*) - LD="${LD-ld} -m elf32_sparc" - ;; - esac - ;; - *64-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_x86_64_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - powerpc64le-*linux*) - LD="${LD-ld} -m elf64lppc" - ;; - powerpc64-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*|s390*-*tpf*) - LD="${LD-ld} -m elf64_s390" - ;; - sparc*-*linux*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, - [AC_LANG_PUSH(C) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) - AC_LANG_POP]) - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; -sparc*-*solaris*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *64-bit*) - case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; - *) - if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then - LD="${LD-ld} -64" - fi - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; -esac - -need_locks="$enable_libtool_lock" -])# _LT_ENABLE_LOCK - - -# _LT_CMD_OLD_ARCHIVE -# ------------------- -m4_defun([_LT_CMD_OLD_ARCHIVE], -[AC_CHECK_TOOL(AR, ar, false) -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru -_LT_DECL([], [AR], [1], [The archiver]) -_LT_DECL([], [AR_FLAGS], [1]) - -AC_CHECK_TOOL(STRIP, strip, :) -test -z "$STRIP" && STRIP=: -_LT_DECL([], [STRIP], [1], [A symbol stripping program]) - -AC_CHECK_TOOL(RANLIB, ranlib, :) -test -z "$RANLIB" && RANLIB=: -_LT_DECL([], [RANLIB], [1], - [Commands used to install an old-style archive]) - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" -fi -_LT_DECL([], [old_postinstall_cmds], [2]) -_LT_DECL([], [old_postuninstall_cmds], [2]) -_LT_TAGDECL([], [old_archive_cmds], [2], - [Commands used to build an old-style archive]) -])# _LT_CMD_OLD_ARCHIVE - - -# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------------------- -# Check whether the given compiler option works -AC_DEFUN([_LT_COMPILER_OPTION], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_SED])dnl -AC_CACHE_CHECK([$1], [$2], - [$2=no - m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$3" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - fi - $RM conftest* -]) - -if test x"[$]$2" = xyes; then - m4_if([$5], , :, [$5]) -else - m4_if([$6], , :, [$6]) -fi -])# _LT_COMPILER_OPTION - -# Old name: -AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) - - -# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------- -# Check whether the given linker option works -AC_DEFUN([_LT_LINKER_OPTION], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_SED])dnl -AC_CACHE_CHECK([$1], [$2], - [$2=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $3" - echo "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&AS_MESSAGE_LOG_FD - $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - else - $2=yes - fi - fi - $RM -r conftest* - LDFLAGS="$save_LDFLAGS" -]) - -if test x"[$]$2" = xyes; then - m4_if([$4], , :, [$4]) -else - m4_if([$5], , :, [$5]) -fi -])# _LT_LINKER_OPTION - -# Old name: -AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) - - -# LT_CMD_MAX_LEN -#--------------- -AC_DEFUN([LT_CMD_MAX_LEN], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -# find the maximum length of command line arguments -AC_MSG_CHECKING([the maximum length of command line arguments]) -AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl - i=0 - teststring="ABCD" - - case $build_os in - msdosdjgpp*) - # On DJGPP, this test can blow up pretty badly due to problems in libc - # (any single argument exceeding 2000 bytes causes a buffer overrun - # during glob expansion). Even if it were fixed, the result of this - # check would be larger than it should be. - lt_cv_sys_max_cmd_len=12288; # 12K is about right - ;; - - gnu*) - # Under GNU Hurd, this test is not required because there is - # no limit to the length of command line arguments. - # Libtool will interpret -1 as no limit whatsoever - lt_cv_sys_max_cmd_len=-1; - ;; - - cygwin* | mingw* | cegcc*) - # On Win9x/ME, this test blows up -- it succeeds, but takes - # about 5 minutes as the teststring grows exponentially. - # Worse, since 9x/ME are not pre-emptively multitasking, - # you end up with a "frozen" computer, even though with patience - # the test eventually succeeds (with a max line length of 256k). - # Instead, let's just punt: use the minimum linelength reported by - # all of the supported platforms: 8192 (on NT/2K/XP). - lt_cv_sys_max_cmd_len=8192; - ;; - - beos*) - # On BeOS, this test takes a really really long time. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - amigaos*) - # On AmigaOS with pdksh, this test takes hours, literally. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) - # This has been around since 386BSD, at least. Likely further. - if test -x /sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` - elif test -x /usr/sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` - else - lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs - fi - # And add a safety zone - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - ;; - - interix*) - # We know the value 262144 and hardcode it with a safety zone (like BSD) - lt_cv_sys_max_cmd_len=196608 - ;; - - osf*) - # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure - # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not - # nice to cause kernel panics so lets avoid the loop below. - # First set a reasonable default. - lt_cv_sys_max_cmd_len=16384 - # - if test -x /sbin/sysconfig; then - case `/sbin/sysconfig -q proc exec_disable_arg_limit` in - *1*) lt_cv_sys_max_cmd_len=-1 ;; - esac - fi - ;; - sco3.2v5*) - lt_cv_sys_max_cmd_len=102400 - ;; - sysv5* | sco5v6* | sysv4.2uw2*) - kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` - if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` - else - lt_cv_sys_max_cmd_len=32768 - fi - ;; - *) - lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len"; then - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - else - # Make teststring a little bigger before we do anything with it. - # a 1K string should be a reasonable start. - for i in 1 2 3 4 5 6 7 8 ; do - teststring=$teststring$teststring - done - SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} - # If test is not a shell built-in, we'll probably end up computing a - # maximum length that is only half of the actual maximum length, but - # we can't tell. - while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ - = "XX$teststring$teststring"; } >/dev/null 2>&1 && - test $i != 17 # 1/2 MB should be enough - do - i=`expr $i + 1` - teststring=$teststring$teststring - done - # Only check the string length outside the loop. - lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` - teststring= - # Add a significant safety factor because C++ compilers can tack on - # massive amounts of additional arguments before passing them to the - # linker. It appears as though 1/2 is a usable value. - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` - fi - ;; - esac -]) -if test -n $lt_cv_sys_max_cmd_len ; then - AC_MSG_RESULT($lt_cv_sys_max_cmd_len) -else - AC_MSG_RESULT(none) -fi -max_cmd_len=$lt_cv_sys_max_cmd_len -_LT_DECL([], [max_cmd_len], [0], - [What is the maximum length of a command?]) -])# LT_CMD_MAX_LEN - -# Old name: -AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) - - -# _LT_HEADER_DLFCN -# ---------------- -m4_defun([_LT_HEADER_DLFCN], -[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl -])# _LT_HEADER_DLFCN - - -# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, -# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) -# ---------------------------------------------------------------- -m4_defun([_LT_TRY_DLOPEN_SELF], -[m4_require([_LT_HEADER_DLFCN])dnl -if test "$cross_compiling" = yes; then : - [$4] -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF -[#line __oline__ "configure" -#include "confdefs.h" - -#if HAVE_DLFCN_H -#include -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -void fnord() { int i=42;} -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - /* dlclose (self); */ - } - else - puts (dlerror ()); - - return status; -}] -_LT_EOF - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) $1 ;; - x$lt_dlneed_uscore) $2 ;; - x$lt_dlunknown|x*) $3 ;; - esac - else : - # compilation failed - $3 - fi -fi -rm -fr conftest* -])# _LT_TRY_DLOPEN_SELF - - -# LT_SYS_DLOPEN_SELF -# ------------------ -AC_DEFUN([LT_SYS_DLOPEN_SELF], -[m4_require([_LT_HEADER_DLFCN])dnl -if test "x$enable_dlopen" != xyes; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen="load_add_on" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - mingw* | pw32* | cegcc*) - lt_cv_dlopen="LoadLibrary" - lt_cv_dlopen_libs= - ;; - - cygwin*) - lt_cv_dlopen="dlopen" - lt_cv_dlopen_libs= - ;; - - darwin*) - # if libdl is installed we need to link against it - AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ]) - ;; - - *) - AC_CHECK_FUNC([shl_load], - [lt_cv_dlopen="shl_load"], - [AC_CHECK_LIB([dld], [shl_load], - [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], - [AC_CHECK_FUNC([dlopen], - [lt_cv_dlopen="dlopen"], - [AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], - [AC_CHECK_LIB([svld], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], - [AC_CHECK_LIB([dld], [dld_link], - [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) - ]) - ]) - ]) - ]) - ]) - ;; - esac - - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else - enable_dlopen=no - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS="$LDFLAGS" - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - AC_CACHE_CHECK([whether a program can dlopen itself], - lt_cv_dlopen_self, [dnl - _LT_TRY_DLOPEN_SELF( - lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, - lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) - ]) - - if test "x$lt_cv_dlopen_self" = xyes; then - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" - AC_CACHE_CHECK([whether a statically linked program can dlopen itself], - lt_cv_dlopen_self_static, [dnl - _LT_TRY_DLOPEN_SELF( - lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, - lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) - ]) - fi - - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi -_LT_DECL([dlopen_support], [enable_dlopen], [0], - [Whether dlopen is supported]) -_LT_DECL([dlopen_self], [enable_dlopen_self], [0], - [Whether dlopen of programs is supported]) -_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], - [Whether dlopen of statically linked programs is supported]) -])# LT_SYS_DLOPEN_SELF - -# Old name: -AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) - - -# _LT_COMPILER_C_O([TAGNAME]) -# --------------------------- -# Check to see if options -c and -o are simultaneously supported by compiler. -# This macro does not hard code the compiler like AC_PROG_CC_C_O. -m4_defun([_LT_COMPILER_C_O], -[m4_require([_LT_DECL_SED])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_TAG_COMPILER])dnl -AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], - [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], - [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - fi - fi - chmod u+w . 2>&AS_MESSAGE_LOG_FD - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* -]) -_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], - [Does compiler simultaneously support -c and -o options?]) -])# _LT_COMPILER_C_O - - -# _LT_COMPILER_FILE_LOCKS([TAGNAME]) -# ---------------------------------- -# Check to see if we can do hard links to lock some files if needed -m4_defun([_LT_COMPILER_FILE_LOCKS], -[m4_require([_LT_ENABLE_LOCK])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -_LT_COMPILER_C_O([$1]) - -hard_links="nottested" -if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - AC_MSG_CHECKING([if we can lock with hard links]) - hard_links=yes - $RM conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - AC_MSG_RESULT([$hard_links]) - if test "$hard_links" = no; then - AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) - need_locks=warn - fi -else - need_locks=no -fi -_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) -])# _LT_COMPILER_FILE_LOCKS - - -# _LT_CHECK_OBJDIR -# ---------------- -m4_defun([_LT_CHECK_OBJDIR], -[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], -[rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - lt_cv_objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - lt_cv_objdir=_libs -fi -rmdir .libs 2>/dev/null]) -objdir=$lt_cv_objdir -_LT_DECL([], [objdir], [0], - [The name of the directory that contains temporary libtool files])dnl -m4_pattern_allow([LT_OBJDIR])dnl -AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", - [Define to the sub-directory in which libtool stores uninstalled libraries.]) -])# _LT_CHECK_OBJDIR - - -# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) -# -------------------------------------- -# Check hardcoding attributes. -m4_defun([_LT_LINKER_HARDCODE_LIBPATH], -[AC_MSG_CHECKING([how to hardcode library paths into programs]) -_LT_TAGVAR(hardcode_action, $1)= -if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || - test -n "$_LT_TAGVAR(runpath_var, $1)" || - test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then - - # We can hardcode non-existent directories. - if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && - test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then - # Linking always hardcodes the temporary library directory. - _LT_TAGVAR(hardcode_action, $1)=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - _LT_TAGVAR(hardcode_action, $1)=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - _LT_TAGVAR(hardcode_action, $1)=unsupported -fi -AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) - -if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || - test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi -_LT_TAGDECL([], [hardcode_action], [0], - [How to hardcode a shared library path into an executable]) -])# _LT_LINKER_HARDCODE_LIBPATH - - -# _LT_CMD_STRIPLIB -# ---------------- -m4_defun([_LT_CMD_STRIPLIB], -[m4_require([_LT_DECL_EGREP]) -striplib= -old_striplib= -AC_MSG_CHECKING([whether stripping libraries is possible]) -if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - AC_MSG_RESULT([yes]) -else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP" ; then - striplib="$STRIP -x" - old_striplib="$STRIP -S" - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - fi - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac -fi -_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) -_LT_DECL([], [striplib], [1]) -])# _LT_CMD_STRIPLIB - - -# _LT_SYS_DYNAMIC_LINKER([TAG]) -# ----------------------------- -# PORTME Fill in your ld.so characteristics -m4_defun([_LT_SYS_DYNAMIC_LINKER], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_OBJDUMP])dnl -m4_require([_LT_DECL_SED])dnl -AC_MSG_CHECKING([dynamic linker characteristics]) -m4_if([$1], - [], [ -if test "$GCC" = yes; then - case $host_os in - darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; - *) lt_awk_arg="/^libraries:/" ;; - esac - lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` - else - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - # Ok, now we have the path, separated by spaces, we can step through it - # and add multilib dir if necessary. - lt_tmp_lt_search_path_spec= - lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` - for lt_sys_path in $lt_search_path_spec; do - if test -d "$lt_sys_path/$lt_multi_os_dir"; then - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" - else - test -d "$lt_sys_path" && \ - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" - fi - done - lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' -BEGIN {RS=" "; FS="/|\n";} { - lt_foo=""; - lt_count=0; - for (lt_i = NF; lt_i > 0; lt_i--) { - if ($lt_i != "" && $lt_i != ".") { - if ($lt_i == "..") { - lt_count++; - } else { - if (lt_count == 0) { - lt_foo="/" $lt_i lt_foo; - } else { - lt_count--; - } - } - } - } - if (lt_foo != "") { lt_freq[[lt_foo]]++; } - if (lt_freq[[lt_foo]] == 1) { print lt_foo; } -}'` - sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi]) -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix[[4-9]]*) - version_type=linux - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[[01]] | aix4.[[01]].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - case $host_cpu in - powerpc) - # Since July 2007 AmigaOS4 officially supports .so libraries. - # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - ;; - m68k) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - esac - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[[45]]*) - version_type=linux - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32* | cegcc*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname~ - if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then - eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; - fi' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - #soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - soname_spec='`echo ${libname} | sed -e 's/^lib//'`${shared_ext}' - sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" - ;; - mingw* | cegcc*) - # MinGW DLLs use traditional 'lib' prefix - #soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - soname_spec='`echo ${libname} | $SED -e 's/^lib//'`${shared_ext}' - sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then - # It is most probably a Windows format PATH printed by - # mingw gcc, but we are running on Cygwin. Gcc prints its search - # path with ; separators, and with drive letters. We can handle the - # drive letters (cygwin fileutils understands them), so leave them, - # especially as we might pass files found there to a mingw objdump, - # which wouldn't understand a cygwinified path. Ahh. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - ;; - esac - ;; - - *) - library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' - ;; - esac - dynamic_linker='Win32 ld.exe' - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' -m4_if([$1], [],[ - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd1*) - dynamic_linker=no - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[[123]]*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[[01]]* | freebsdelf3.[[01]]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ - freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - *) # from 4.6 on, and DragonFly - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' - ;; - -interix[[3-9]]*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be Linux ELF. -linux* | k*bsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - # Some binutils ld are patched to set DT_RUNPATH - save_LDFLAGS=$LDFLAGS - save_libdir=$libdir - eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ - LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], - [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], - [shlibpath_overrides_runpath=yes])]) - LDFLAGS=$save_LDFLAGS - libdir=$save_libdir - - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -*nto* | *qnx*) - version_type=qnx - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='ldqnx.so' - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[[89]] | openbsd2.[[89]].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -rdos*) - dynamic_linker=no - ;; - -solaris*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -tpf*) - # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -uts4*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -AC_MSG_RESULT([$dynamic_linker]) -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then - sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" -fi -if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then - sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" -fi - -_LT_DECL([], [variables_saved_for_relink], [1], - [Variables whose values should be saved in libtool wrapper scripts and - restored at link time]) -_LT_DECL([], [need_lib_prefix], [0], - [Do we need the "lib" prefix for modules?]) -_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) -_LT_DECL([], [version_type], [0], [Library versioning type]) -_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) -_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) -_LT_DECL([], [shlibpath_overrides_runpath], [0], - [Is shlibpath searched before the hard-coded library search path?]) -_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) -_LT_DECL([], [library_names_spec], [1], - [[List of archive names. First name is the real one, the rest are links. - The last name is the one that the linker finds with -lNAME]]) -_LT_DECL([], [soname_spec], [1], - [[The coded name of the library, if different from the real name]]) -_LT_DECL([], [postinstall_cmds], [2], - [Command to use after installation of a shared archive]) -_LT_DECL([], [postuninstall_cmds], [2], - [Command to use after uninstallation of a shared archive]) -_LT_DECL([], [finish_cmds], [2], - [Commands used to finish a libtool library installation in a directory]) -_LT_DECL([], [finish_eval], [1], - [[As "finish_cmds", except a single script fragment to be evaled but - not shown]]) -_LT_DECL([], [hardcode_into_libs], [0], - [Whether we should hardcode library paths into libraries]) -_LT_DECL([], [sys_lib_search_path_spec], [2], - [Compile-time system search path for libraries]) -_LT_DECL([], [sys_lib_dlsearch_path_spec], [2], - [Run-time system search path for libraries]) -])# _LT_SYS_DYNAMIC_LINKER - - -# _LT_PATH_TOOL_PREFIX(TOOL) -# -------------------------- -# find a file program which can recognize shared library -AC_DEFUN([_LT_PATH_TOOL_PREFIX], -[m4_require([_LT_DECL_EGREP])dnl -AC_MSG_CHECKING([for $1]) -AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, -[case $MAGIC_CMD in -[[\\/*] | ?:[\\/]*]) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -dnl $ac_dummy forces splitting on constant user-supplied paths. -dnl POSIX.2 word splitting is done only on the output of word expansions, -dnl not every word. This closes a longstanding sh security hole. - ac_dummy="m4_if([$2], , $PATH, [$2])" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$1; then - lt_cv_path_MAGIC_CMD="$ac_dir/$1" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <<_LT_EOF 1>&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -_LT_EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac]) -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - AC_MSG_RESULT($MAGIC_CMD) -else - AC_MSG_RESULT(no) -fi -_LT_DECL([], [MAGIC_CMD], [0], - [Used to examine libraries when file_magic_cmd begins with "file"])dnl -])# _LT_PATH_TOOL_PREFIX - -# Old name: -AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) - - -# _LT_PATH_MAGIC -# -------------- -# find a file program which can recognize a shared library -m4_defun([_LT_PATH_MAGIC], -[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) -if test -z "$lt_cv_path_MAGIC_CMD"; then - if test -n "$ac_tool_prefix"; then - _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) - else - MAGIC_CMD=: - fi -fi -])# _LT_PATH_MAGIC - - -# LT_PATH_LD -# ---------- -# find the pathname to the GNU or non-GNU linker -AC_DEFUN([LT_PATH_LD], -[AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_DECL_EGREP])dnl - -AC_ARG_WITH([gnu-ld], - [AS_HELP_STRING([--with-gnu-ld], - [assume the C compiler uses GNU ld @<:@default=no@:>@])], - [test "$withval" = no || with_gnu_ld=yes], - [with_gnu_ld=no])dnl - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - AC_MSG_CHECKING([for ld used by $CC]) - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [[\\/]]* | ?:[[\\/]]*) - re_direlt='/[[^/]][[^/]]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` - while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do - ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - AC_MSG_CHECKING([for GNU ld]) -else - AC_MSG_CHECKING([for non-GNU ld]) -fi -AC_CACHE_VAL(lt_cv_path_LD, -[if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_file_magic_cmd='func_win32_libid' - else - lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' - lt_cv_file_magic_cmd='$OBJDUMP -f' - fi - lt_cv_deplibs_check_method=pass_all - ;; - -cegcc) - # use the weaker test based on 'objdump'. See mingw*. - lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - ;; - -darwin* | rhapsody*) - lt_cv_deplibs_check_method=pass_all - ;; - -freebsd* | dragonfly*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - case $host_cpu in - i*86 ) - # Not sure whether the presence of OpenBSD here was a mistake. - # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - ;; - esac - else - lt_cv_deplibs_check_method=pass_all - fi - ;; - -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file - case $host_cpu in - ia64*) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' - lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so - ;; - hppa*64*) - [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] - lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl - ;; - *) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' - lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - esac - ;; - -interix[[3-9]]*) - # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' - ;; - -irix5* | irix6* | nonstopux*) - case $LD in - *-32|*"-32 ") libmagic=32-bit;; - *-n32|*"-n32 ") libmagic=N32;; - *-64|*"-64 ") libmagic=64-bit;; - *) libmagic=never-match;; - esac - lt_cv_deplibs_check_method=pass_all - ;; - -# This must be Linux ELF. -linux* | k*bsd*-gnu) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' - fi - ;; - -newos6*) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libnls.so - ;; - -*nto* | *qnx*) - lt_cv_deplibs_check_method=pass_all - ;; - -openbsd*) - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - fi - ;; - -osf3* | osf4* | osf5*) - lt_cv_deplibs_check_method=pass_all - ;; - -rdos*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.3*) - case $host_vendor in - motorola) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` - ;; - ncr) - lt_cv_deplibs_check_method=pass_all - ;; - sequent) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' - ;; - sni) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" - lt_cv_file_magic_test_file=/lib/libc.so - ;; - siemens) - lt_cv_deplibs_check_method=pass_all - ;; - pc) - lt_cv_deplibs_check_method=pass_all - ;; - esac - ;; - -tpf*) - lt_cv_deplibs_check_method=pass_all - ;; -esac -]) -file_magic_cmd=$lt_cv_file_magic_cmd -deplibs_check_method=$lt_cv_deplibs_check_method -test -z "$deplibs_check_method" && deplibs_check_method=unknown - -_LT_DECL([], [deplibs_check_method], [1], - [Method to check whether dependent libraries are shared objects]) -_LT_DECL([], [file_magic_cmd], [1], - [Command to use when deplibs_check_method == "file_magic"]) -])# _LT_CHECK_MAGIC_METHOD - - -# LT_PATH_NM -# ---------- -# find the pathname to a BSD- or MS-compatible name lister -AC_DEFUN([LT_PATH_NM], -[AC_REQUIRE([AC_PROG_CC])dnl -AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, -[if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM="$NM" -else - lt_nm_to_check="${ac_tool_prefix}nm" - if test -n "$ac_tool_prefix" && test "$build" = "$host"; then - lt_nm_to_check="$lt_nm_to_check nm" - fi - for lt_tmp_nm in $lt_nm_to_check; do - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/$lt_tmp_nm" - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in - */dev/null* | *'Invalid file or object type'*) - lt_cv_path_NM="$tmp_nm -B" - break - ;; - *) - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in - */dev/null*) - lt_cv_path_NM="$tmp_nm -p" - break - ;; - *) - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but - continue # so that we can try to find one that supports BSD flags - ;; - esac - ;; - esac - fi - done - IFS="$lt_save_ifs" - done - : ${lt_cv_path_NM=no} -fi]) -if test "$lt_cv_path_NM" != "no"; then - NM="$lt_cv_path_NM" -else - # Didn't find any BSD compatible name lister, look for dumpbin. - AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :) - AC_SUBST([DUMPBIN]) - if test "$DUMPBIN" != ":"; then - NM="$DUMPBIN" - fi -fi -test -z "$NM" && NM=nm -AC_SUBST([NM]) -_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl - -AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], - [lt_cv_nm_interface="BSD nm" - echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$ac_compile" 2>conftest.err) - cat conftest.err >&AS_MESSAGE_LOG_FD - (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) - (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) - cat conftest.err >&AS_MESSAGE_LOG_FD - (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD) - cat conftest.out >&AS_MESSAGE_LOG_FD - if $GREP 'External.*some_variable' conftest.out > /dev/null; then - lt_cv_nm_interface="MS dumpbin" - fi - rm -f conftest*]) -])# LT_PATH_NM - -# Old names: -AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) -AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_PROG_NM], []) -dnl AC_DEFUN([AC_PROG_NM], []) - - -# LT_LIB_M -# -------- -# check for math library -AC_DEFUN([LT_LIB_M], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -LIBM= -case $host in -*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) - # These system don't have libm, or don't need it - ;; -*-ncr-sysv4.3*) - AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") - AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") - ;; -*) - AC_CHECK_LIB(m, cos, LIBM="-lm") - ;; -esac -AC_SUBST([LIBM]) -])# LT_LIB_M - -# Old name: -AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_CHECK_LIBM], []) - - -# _LT_COMPILER_NO_RTTI([TAGNAME]) -# ------------------------------- -m4_defun([_LT_COMPILER_NO_RTTI], -[m4_require([_LT_TAG_COMPILER])dnl - -_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= - -if test "$GCC" = yes; then - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' - - _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], - lt_cv_prog_compiler_rtti_exceptions, - [-fno-rtti -fno-exceptions], [], - [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) -fi -_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], - [Compiler flag to turn off builtin functions]) -])# _LT_COMPILER_NO_RTTI - - -# _LT_CMD_GLOBAL_SYMBOLS -# ---------------------- -m4_defun([_LT_CMD_GLOBAL_SYMBOLS], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([LT_PATH_NM])dnl -AC_REQUIRE([LT_PATH_LD])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_TAG_COMPILER])dnl - -# Check for command to grab the raw symbol name followed by C symbol from nm. -AC_MSG_CHECKING([command to parse $NM output from $compiler object]) -AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], -[ -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[[BCDEGRST]]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[[BCDT]]' - ;; -cygwin* | mingw* | pw32* | cegcc*) - symcode='[[ABCDGISTW]]' - ;; -hpux*) - if test "$host_cpu" = ia64; then - symcode='[[ABCDEGRST]]' - fi - ;; -irix* | nonstopux*) - symcode='[[BCDEGRST]]' - ;; -osf*) - symcode='[[BCDEGQRST]]' - ;; -solaris*) - symcode='[[BDRT]]' - ;; -sco3.2v5*) - symcode='[[DT]]' - ;; -sysv4.2uw2*) - symcode='[[DT]]' - ;; -sysv5* | sco5v6* | unixware* | OpenUNIX*) - symcode='[[ABDT]]' - ;; -sysv4) - symcode='[[DFNSTU]]' - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -case `$NM -V 2>&1` in -*GNU* | *'with BFD'*) - symcode='[[ABCDGIRSTW]]' ;; -esac - -# Transform an extracted symbol line into a proper C declaration. -# Some systems (esp. on ia64) link data and code symbols differently, -# so use this general approach. -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - -# Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" - -# Handle CRLF in mingw tool chain -opt_cr= -case $build_os in -mingw*) - opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp - ;; -esac - -# Try without a prefix underscore, then with it. -for ac_symprfx in "" "_"; do - - # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. - symxfrm="\\1 $ac_symprfx\\2 \\2" - - # Write the raw and C identifiers. - if test "$lt_cv_nm_interface" = "MS dumpbin"; then - # Fake it for dumpbin and say T for any non-static function - # and D for any global variable. - # Also find C++ and __fastcall symbols from MSVC++, - # which start with @ or ?. - lt_cv_sys_global_symbol_pipe="$AWK ['"\ -" {last_section=section; section=\$ 3};"\ -" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ -" \$ 0!~/External *\|/{next};"\ -" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ -" {if(hide[section]) next};"\ -" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ -" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ -" s[1]~/^[@?]/{print s[1], s[1]; next};"\ -" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ -" ' prfx=^$ac_symprfx]" - else - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" - fi - - # Check to see that the pipe works correctly. - pipe_works=no - - rm -f conftest* - cat > conftest.$ac_ext <<_LT_EOF -#ifdef __cplusplus -extern "C" { -#endif -char nm_test_var; -void nm_test_func(void); -void nm_test_func(void){} -#ifdef __cplusplus -} -#endif -int main(){nm_test_var='a';nm_test_func();return(0);} -_LT_EOF - - if AC_TRY_EVAL(ac_compile); then - # Now try to grab the symbols. - nlist=conftest.nm - if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - else - rm -f "$nlist"T - fi - - # Make sure that we snagged all the symbols we need. - if $GREP ' nm_test_var$' "$nlist" >/dev/null; then - if $GREP ' nm_test_func$' "$nlist" >/dev/null; then - cat <<_LT_EOF > conftest.$ac_ext -#ifdef __cplusplus -extern "C" { -#endif - -_LT_EOF - # Now generate the symbol file. - eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' - - cat <<_LT_EOF >> conftest.$ac_ext - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - void *address; -} -lt__PROGRAM__LTX_preloaded_symbols[[]] = -{ - { "@PROGRAM@", (void *) 0 }, -_LT_EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext - cat <<\_LT_EOF >> conftest.$ac_ext - {0, (void *) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt__PROGRAM__LTX_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif -_LT_EOF - # Now try linking the two files. - mv conftest.$ac_objext conftstm.$ac_objext - lt_save_LIBS="$LIBS" - lt_save_CFLAGS="$CFLAGS" - LIBS="conftstm.$ac_objext" - CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then - pipe_works=yes - fi - LIBS="$lt_save_LIBS" - CFLAGS="$lt_save_CFLAGS" - else - echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD - fi - else - echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD - cat conftest.$ac_ext >&5 - fi - rm -rf conftest* conftst* - - # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then - break - else - lt_cv_sys_global_symbol_pipe= - fi -done -]) -if test -z "$lt_cv_sys_global_symbol_pipe"; then - lt_cv_sys_global_symbol_to_cdecl= -fi -if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then - AC_MSG_RESULT(failed) -else - AC_MSG_RESULT(ok) -fi - -_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], - [Take the output of nm and produce a listing of raw symbols and C names]) -_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], - [Transform the output of nm in a proper C declaration]) -_LT_DECL([global_symbol_to_c_name_address], - [lt_cv_sys_global_symbol_to_c_name_address], [1], - [Transform the output of nm in a C name address pair]) -_LT_DECL([global_symbol_to_c_name_address_lib_prefix], - [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], - [Transform the output of nm in a C name address pair when lib prefix is needed]) -]) # _LT_CMD_GLOBAL_SYMBOLS - - -# _LT_COMPILER_PIC([TAGNAME]) -# --------------------------- -m4_defun([_LT_COMPILER_PIC], -[m4_require([_LT_TAG_COMPILER])dnl -_LT_TAGVAR(lt_prog_compiler_wl, $1)= -_LT_TAGVAR(lt_prog_compiler_pic, $1)= -_LT_TAGVAR(lt_prog_compiler_static, $1)= - -AC_MSG_CHECKING([for $compiler option to produce PIC]) -m4_if([$1], [CXX], [ - # C++ specific cases for pic, static, wl, etc. - if test "$GXX" = yes; then - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - *djgpp*) - # DJGPP does not support shared libraries at all - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - interix[[3-9]]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - else - case $host_os in - aix[[4-9]]*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - chorus*) - case $cc_basename in - cxch68*) - # Green Hills C++ Compiler - # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" - ;; - esac - ;; - dgux*) - case $cc_basename in - ec++*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - ghcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - freebsd* | dragonfly*) - # FreeBSD uses GNU C++ - ;; - hpux9* | hpux10* | hpux11*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - if test "$host_cpu" != ia64; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - fi - ;; - aCC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - ;; - *) - ;; - esac - ;; - interix*) - # This is c89, which is MS Visual C++ (no shared libs) - # Anyone wants to do a port? - ;; - irix5* | irix6* | nonstopux*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - # CC pic flag -KPIC is the default. - ;; - *) - ;; - esac - ;; - linux* | k*bsd*-gnu) - case $cc_basename in - KCC*) - # KAI C++ Compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - ecpc* ) - # old Intel C++ for x86_64 which still supported -KPIC. - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - icpc* ) - # Intel C++, used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - cxx*) - # Compaq C++ - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - xlc* | xlC*) - # IBM XL 8.0 on PPC - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - esac - ;; - esac - ;; - lynxos*) - ;; - m88k*) - ;; - mvs*) - case $cc_basename in - cxx*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' - ;; - *) - ;; - esac - ;; - netbsd*) - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - ;; - RCC*) - # Rational C++ 2.4.1 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - cxx*) - # Digital/Compaq C++ - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - *) - ;; - esac - ;; - psos*) - ;; - solaris*) - case $cc_basename in - CC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - ;; - *) - ;; - esac - ;; - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - lcc*) - # Lucid - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - esac - ;; - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - *) - ;; - esac - ;; - vxworks*) - ;; - *) - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -], -[ - if test "$GCC" = yes; then - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - - interix[[3-9]]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - enable_shared=no - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - - hpux9* | hpux10* | hpux11*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC (with -KPIC) is the default. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - linux* | k*bsd*-gnu) - case $cc_basename in - # old Intel for x86_64 which still supported -KPIC. - ecc*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - # icc used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - icc* | ifort*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - # Lahey Fortran 8.1. - lf95*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' - _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' - ;; - pgcc* | pgf77* | pgf90* | pgf95*) - # Portland Group compilers (*not* the Pentium gcc compiler, - # which looks to be a dead project) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - ccc*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All Alpha code is PIC. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - xl*) - # IBM XL C 8.0/Fortran 10.1 on PPC - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C 5.9 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - ;; - *Sun\ F*) - # Sun Fortran 8.3 passes all unrecognized flags to the linker - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='' - ;; - esac - ;; - esac - ;; - - newsos6) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - - osf3* | osf4* | osf5*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All OSF/1 code is PIC. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - rdos*) - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - solaris*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - case $cc_basename in - f77* | f90* | f95*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; - *) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; - esac - ;; - - sunos4*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - unicos*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - - uts4*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - *) - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -]) -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" - ;; -esac -AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) -_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], - [How to pass a linker flag through the compiler]) - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then - _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], - [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], - [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], - [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in - "" | " "*) ;; - *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; - esac], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) -fi -_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], - [Additional compiler flags for building library objects]) - -# -# Check to make sure the static flag actually works. -# -wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" -_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], - _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), - $lt_tmp_static_flag, - [], - [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) -_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], - [Compiler flag to prevent dynamic linking]) -])# _LT_COMPILER_PIC - - -# _LT_LINKER_SHLIBS([TAGNAME]) -# ---------------------------- -# See if the linker supports building shared libraries. -m4_defun([_LT_LINKER_SHLIBS], -[AC_REQUIRE([LT_PATH_LD])dnl -AC_REQUIRE([LT_PATH_NM])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl -m4_require([_LT_TAG_COMPILER])dnl -AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) -m4_if([$1], [CXX], [ - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - case $host_os in - aix[[4-9]]*) - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - ;; - pw32*) - _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" - ;; - cygwin* | mingw* | cegcc*) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' - ;; - *) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - ;; - esac - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] -], [ - runpath_var= - _LT_TAGVAR(allow_undefined_flag, $1)= - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(archive_cmds, $1)= - _LT_TAGVAR(archive_expsym_cmds, $1)= - _LT_TAGVAR(compiler_needs_object, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - _LT_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(hardcode_automatic, $1)=no - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= - _LT_TAGVAR(hardcode_libdir_separator, $1)= - _LT_TAGVAR(hardcode_minus_L, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_TAGVAR(inherit_rpath, $1)=no - _LT_TAGVAR(link_all_deplibs, $1)=unknown - _LT_TAGVAR(module_cmds, $1)= - _LT_TAGVAR(module_expsym_cmds, $1)= - _LT_TAGVAR(old_archive_from_new_cmds, $1)= - _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= - _LT_TAGVAR(thread_safe_flag_spec, $1)= - _LT_TAGVAR(whole_archive_flag_spec, $1)= - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - _LT_TAGVAR(include_expsyms, $1)= - # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] - # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out - # platforms (ab)use it in PIC code, but their linkers get confused if - # the symbol is explicitly referenced. Since portable code cannot - # rely on this symbol name, it's probably fine to never include it in - # preloaded symbol tables. - # Exclude shared library initialization/finalization symbols. -dnl Note also adjust exclude_expsyms for C++ above. - extract_expsyms_cmds= - - case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; - esac - - _LT_TAGVAR(ld_shlibs, $1)=yes - if test "$with_gnu_ld" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - runpath_var=LD_RUN_PATH - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - supports_anon_versioning=no - case `$LD -v 2>&1` in - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 - *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... - *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... - *\ 2.11.*) ;; # other 2.11 versions - *) supports_anon_versioning=yes ;; - esac - - # See if GNU ld supports shared libraries. - case $host_os in - aix[[3-9]]*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: the GNU linker, at least up to release 2.9.1, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to modify your PATH -*** so that a non-GNU linker is found, and then restart. - -_LT_EOF - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='' - ;; - m68k) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - interix[[3-9]]*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - - gnu* | linux* | tpf* | k*bsd*-gnu) - tmp_diet=no - if test "$host_os" = linux-dietlibc; then - case $cc_basename in - diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) - esac - fi - if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ - && test "$tmp_diet" = no - then - tmp_addflag= - tmp_sharedflag='-shared' - case $cc_basename,$host_cpu in - pgcc*) # Portland Group C compiler - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag -Mnomain' ;; - ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 - tmp_addflag=' -i_dynamic' ;; - efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 - tmp_addflag=' -i_dynamic -nofor_main' ;; - ifc* | ifort*) # Intel Fortran compiler - tmp_addflag=' -nofor_main' ;; - lf95*) # Lahey Fortran 8.1 - _LT_TAGVAR(whole_archive_flag_spec, $1)= - tmp_sharedflag='--shared' ;; - xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) - tmp_sharedflag='-qmkshrobj' - tmp_addflag= ;; - esac - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) # Sun C 5.9 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - tmp_sharedflag='-G' ;; - *Sun\ F*) # Sun Fortran 8.3 - tmp_sharedflag='-G' ;; - esac - _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - - case $cc_basename in - xlf*) - # IBM XL Fortran 10.1 on PPC cannot create shared libs itself - _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' - _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' - fi - ;; - esac - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris*) - if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not -*** reliably create shared libraries on SCO systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.16.91.0.3 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - ;; - *) - # For security reasons, it is highly recommended that you always - # use absolute paths for naming shared libraries, and exclude the - # DT_RUNPATH tag from executables and libraries. But doing so - # requires that you compile everything twice, which is a pain. - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - sunos4*) - _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - - if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then - runpath_var= - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=yes - _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - _LT_TAGVAR(hardcode_direct, $1)=unsupported - fi - ;; - - aix[[4-9]]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_TAGVAR(archive_cmds, $1)='' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' - - if test "$GCC" = yes; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - _LT_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - _LT_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared libraries. - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='' - ;; - m68k) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - ;; - - bsdi[[45]]*) - _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - # FIXME: Should let the user specify the lib program. - _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' - _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - ;; - - darwin* | rhapsody*) - _LT_DARWIN_LINKER_FEATURES($1) - ;; - - dgux*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - freebsd1*) - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - hpux9*) - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_direct, $1)=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - - hpux10*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - fi - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - fi - ;; - - hpux11*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - else - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - fi - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - # Try to use the -exported_symbol ld option, if it does not - # work, assume that -exports_file does not work either and - # implicitly export all symbols. - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" - AC_LINK_IFELSE(int foo(void) {}, - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - ) - LDFLAGS="$save_LDFLAGS" - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(inherit_rpath, $1)=yes - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - newsos6) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *nto* | *qnx*) - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - else - case $host_os in - openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - ;; - esac - fi - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - os2*) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - else - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ - $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' - - # Both c and cxx compiler support -rpath directly - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - solaris*) - _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' - if test "$GCC" = yes; then - wlarc='${wl}' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - else - case `$CC -V 2>&1` in - *"Compilers 5.0"*) - wlarc='' - _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' - ;; - *) - wlarc='${wl}' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - ;; - esac - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. GCC discards it without `$wl', - # but is careful enough not to reorder. - # Supported since Solaris 2.6 (maybe 2.5.1?) - if test "$GCC" = yes; then - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' - fi - ;; - esac - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4) - case $host_vendor in - sni) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' - _LT_TAGVAR(hardcode_direct, $1)=no - ;; - motorola) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4.3*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - _LT_TAGVAR(ld_shlibs, $1)=yes - fi - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - uts4*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - - if test x$host_vendor = xsni; then - case $host in - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' - ;; - esac - fi - fi -]) -AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) -test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no - -_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld - -_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl -_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl -_LT_DECL([], [extract_expsyms_cmds], [2], - [The commands to extract the exported symbol list from a shared archive]) - -# -# Do we need to explicitly link libc? -# -case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in -x|xyes) - # Assume -lc should be added - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $_LT_TAGVAR(archive_cmds, $1) in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - AC_MSG_CHECKING([whether -lc should be explicitly linked in]) - $RM conftest* - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - if AC_TRY_EVAL(ac_compile) 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) - pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) - _LT_TAGVAR(allow_undefined_flag, $1)= - if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) - then - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - else - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - fi - _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $RM conftest* - AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)]) - ;; - esac - fi - ;; -esac - -_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], - [Whether or not to add -lc for building shared libraries]) -_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], - [enable_shared_with_static_runtimes], [0], - [Whether or not to disallow shared libs when runtime libs are static]) -_LT_TAGDECL([], [export_dynamic_flag_spec], [1], - [Compiler flag to allow reflexive dlopens]) -_LT_TAGDECL([], [whole_archive_flag_spec], [1], - [Compiler flag to generate shared objects directly from archives]) -_LT_TAGDECL([], [compiler_needs_object], [1], - [Whether the compiler copes with passing no objects directly]) -_LT_TAGDECL([], [old_archive_from_new_cmds], [2], - [Create an old-style archive from a shared archive]) -_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], - [Create a temporary old-style archive to link instead of a shared archive]) -_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) -_LT_TAGDECL([], [archive_expsym_cmds], [2]) -_LT_TAGDECL([], [module_cmds], [2], - [Commands used to build a loadable module if different from building - a shared archive.]) -_LT_TAGDECL([], [module_expsym_cmds], [2]) -_LT_TAGDECL([], [with_gnu_ld], [1], - [Whether we are building with GNU ld or not]) -_LT_TAGDECL([], [allow_undefined_flag], [1], - [Flag that allows shared libraries with undefined symbols to be built]) -_LT_TAGDECL([], [no_undefined_flag], [1], - [Flag that enforces no undefined symbols]) -_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], - [Flag to hardcode $libdir into a binary during linking. - This must work even if $libdir does not exist]) -_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], - [[If ld is used when linking, flag to hardcode $libdir into a binary - during linking. This must work even if $libdir does not exist]]) -_LT_TAGDECL([], [hardcode_libdir_separator], [1], - [Whether we need a single "-rpath" flag with a separated argument]) -_LT_TAGDECL([], [hardcode_direct], [0], - [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes - DIR into the resulting binary]) -_LT_TAGDECL([], [hardcode_direct_absolute], [0], - [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes - DIR into the resulting binary and the resulting library dependency is - "absolute", i.e impossible to change by setting ${shlibpath_var} if the - library is relocated]) -_LT_TAGDECL([], [hardcode_minus_L], [0], - [Set to "yes" if using the -LDIR flag during linking hardcodes DIR - into the resulting binary]) -_LT_TAGDECL([], [hardcode_shlibpath_var], [0], - [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR - into the resulting binary]) -_LT_TAGDECL([], [hardcode_automatic], [0], - [Set to "yes" if building a shared library automatically hardcodes DIR - into the library and all subsequent libraries and executables linked - against it]) -_LT_TAGDECL([], [inherit_rpath], [0], - [Set to yes if linker adds runtime paths of dependent libraries - to runtime path list]) -_LT_TAGDECL([], [link_all_deplibs], [0], - [Whether libtool must link a program against all its dependency libraries]) -_LT_TAGDECL([], [fix_srcfile_path], [1], - [Fix the shell variable $srcfile for the compiler]) -_LT_TAGDECL([], [always_export_symbols], [0], - [Set to "yes" if exported symbols are required]) -_LT_TAGDECL([], [export_symbols_cmds], [2], - [The commands to list exported symbols]) -_LT_TAGDECL([], [exclude_expsyms], [1], - [Symbols that should not be listed in the preloaded symbols]) -_LT_TAGDECL([], [include_expsyms], [1], - [Symbols that must always be exported]) -_LT_TAGDECL([], [prelink_cmds], [2], - [Commands necessary for linking programs (against libraries) with templates]) -_LT_TAGDECL([], [file_list_spec], [1], - [Specify filename containing input files]) -dnl FIXME: Not yet implemented -dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], -dnl [Compiler flag to generate thread safe objects]) -])# _LT_LINKER_SHLIBS - - -# _LT_LANG_C_CONFIG([TAG]) -# ------------------------ -# Ensure that the configuration variables for a C compiler are suitably -# defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to `libtool'. -m4_defun([_LT_LANG_C_CONFIG], -[m4_require([_LT_DECL_EGREP])dnl -lt_save_CC="$CC" -AC_LANG_PUSH(C) - -# Source file extension for C test sources. -ac_ext=c - -# Object file extension for compiled C test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}' - -_LT_TAG_COMPILER -# Save the default compiler, since it gets overwritten when the other -# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. -compiler_DEFAULT=$CC - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -## CAVEAT EMPTOR: -## There is no encapsulation within the following macros, do not change -## the running order or otherwise move them around unless you know exactly -## what you are doing... -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - LT_SYS_DLOPEN_SELF - _LT_CMD_STRIPLIB - - # Report which library types will actually be built - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_CONFIG($1) -fi -AC_LANG_POP -CC="$lt_save_CC" -])# _LT_LANG_C_CONFIG - - -# _LT_PROG_CXX -# ------------ -# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++ -# compiler, we have our own version here. -m4_defun([_LT_PROG_CXX], -[ -pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes]) -AC_PROG_CXX -if test -n "$CXX" && ( test "X$CXX" != "Xno" && - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || - (test "X$CXX" != "Xg++"))) ; then - AC_PROG_CXXCPP -else - _lt_caught_CXX_error=yes -fi -popdef([AC_MSG_ERROR]) -])# _LT_PROG_CXX - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([_LT_PROG_CXX], []) - - -# _LT_LANG_CXX_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for a C++ compiler are suitably -# defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to `libtool'. -m4_defun([_LT_LANG_CXX_CONFIG], -[AC_REQUIRE([_LT_PROG_CXX])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_EGREP])dnl - -AC_LANG_PUSH(C++) -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(compiler_needs_object, $1)=no -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for C++ test sources. -ac_ext=cpp - -# Object file extension for compiled C++ test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the CXX compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_caught_CXX_error" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="int some_variable = 0;" - - # Code to be used in simple link tests - lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC=$CC - lt_save_LD=$LD - lt_save_GCC=$GCC - GCC=$GXX - lt_save_with_gnu_ld=$with_gnu_ld - lt_save_path_LD=$lt_cv_path_LD - if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then - lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx - else - $as_unset lt_cv_prog_gnu_ld - fi - if test -n "${lt_cv_path_LDCXX+set}"; then - lt_cv_path_LD=$lt_cv_path_LDCXX - else - $as_unset lt_cv_path_LD - fi - test -z "${LDCXX+set}" || LD=$LDCXX - CC=${CXX-"c++"} - compiler=$CC - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - - if test -n "$compiler"; then - # We don't want -fno-exception when compiling C++ code, so set the - # no_builtin_flag separately - if test "$GXX" = yes; then - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' - else - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= - fi - - if test "$GXX" = yes; then - # Set up default GNU C++ configuration - - LT_PATH_LD - - # Check if GNU C++ uses GNU ld as the underlying linker, since the - # archiving commands below assume that GNU ld is being used. - if test "$with_gnu_ld" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - - # If archive_cmds runs LD, not CC, wlarc should be empty - # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to - # investigate it a little bit more. (MM) - wlarc='${wl}' - - # ancient GNU ld didn't support --whole-archive et. al. - if eval "`$CC -print-prog-name=ld` --help 2>&1" | - $GREP 'no-whole-archive' > /dev/null; then - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - with_gnu_ld=no - wlarc= - - # A generic and very simple default shared library creation - # command for GNU C++ for the case where it uses the native - # linker, instead of GNU ld. If possible, this setting should - # overridden to take advantage of the native linker features on - # the platform it is being used on. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - fi - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' - - else - GXX=no - with_gnu_ld=no - wlarc= - fi - - # PORTME: fill in a description of your system's C++ link characteristics - AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) - _LT_TAGVAR(ld_shlibs, $1)=yes - case $host_os in - aix3*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aix[[4-9]]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) - for ld_flag in $LDFLAGS; do - case $ld_flag in - *-brtl*) - aix_use_runtimelinking=yes - break - ;; - esac - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_TAGVAR(archive_cmds, $1)='' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' - - if test "$GXX" = yes; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - _LT_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)= - fi - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to - # export. - _LT_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an empty - # executable. - _LT_SYS_MODULE_PATH_AIX - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared - # libraries. - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - chorus*) - case $cc_basename in - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - darwin* | rhapsody*) - _LT_DARWIN_LINKER_FEATURES($1) - ;; - - dgux*) - case $cc_basename in - ec++*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - ghcx*) - # Green Hills C++ Compiler - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - freebsd[[12]]*) - # C++ shared libraries reported to be fairly broken before - # switch to ELF - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - freebsd-elf*) - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - ;; - - freebsd* | dragonfly*) - # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF - # conventions - _LT_TAGVAR(ld_shlibs, $1)=yes - ;; - - gnu*) - ;; - - hpux9*) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - ;; - *) - if test "$GXX" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - hpux10*|hpux11*) - if test $with_gnu_ld = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - ;; - *) - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - esac - fi - case $host_cpu in - hppa*64*|ia64*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - ;; - esac - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - ;; - *) - if test "$GXX" = yes; then - if test $with_gnu_ld = no; then - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - fi - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - interix[[3-9]]*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - irix5* | irix6*) - case $cc_basename in - CC*) - # SGI C++ - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - - # Archives containing C++ object files must be created using - # "CC -ar", where "CC" is the IRIX C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' - ;; - *) - if test "$GXX" = yes; then - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib' - fi - fi - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - esac - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(inherit_rpath, $1)=yes - ;; - - linux* | k*bsd*-gnu) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' - ;; - icpc* | ecpc* ) - # Intel C++ - with_gnu_ld=yes - # version 8.0 and above of icpc choke on multiply defined symbols - # if we add $predep_objects and $postdep_objects, however 7.1 and - # earlier do not add the objects themselves. - case `$CC -V 2>&1` in - *"Version 7."*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - *) # Version 8.0 or newer - tmp_idyn= - case $host_cpu in - ia64*) tmp_idyn=' -i_dynamic';; - esac - _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - esac - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - case `$CC -V` in - *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*) - _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ - compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"' - _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ - $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~ - $RANLIB $oldlib' - _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - ;; - *) # Version 6 will use weak symbols - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - ;; - cxx*) - # Compaq C++ - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' - - runpath_var=LD_RUN_PATH - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - ;; - xl*) - # IBM XL 8.0 on PPC, with GNU ld - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - - # Not sure whether something based on - # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 - # would be better. - output_verbose_link_cmd='echo' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' - ;; - esac - ;; - esac - ;; - - lynxos*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - m88k*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - mvs*) - case $cc_basename in - cxx*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' - wlarc= - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - fi - # Workaround some broken pre-1.5 toolchains - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' - ;; - - *nto* | *qnx*) - _LT_TAGVAR(ld_shlibs, $1)=yes - ;; - - openbsd2*) - # C++ shared libraries are fairly broken - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - fi - output_verbose_link_cmd=echo - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Archives containing C++ object files must be created using - # the KAI C++ compiler. - case $host in - osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; - *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; - esac - ;; - RCC*) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - cxx*) - case $host in - osf3*) - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - ;; - *) - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ - echo "-hidden">> $lib.exp~ - $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~ - $RM $lib.exp' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - case $host in - osf3*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' - - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - psos*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - lcc*) - # Lucid - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - solaris*) - case $cc_basename in - CC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_TAGVAR(archive_cmds_need_lc,$1)=yes - _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. - # Supported since Solaris 2.6 (maybe 2.5.1?) - _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' - ;; - esac - _LT_TAGVAR(link_all_deplibs, $1)=yes - - output_verbose_link_cmd='echo' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - - # The C++ compiler must be used to create the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' - ;; - *) - # GNU C++ compiler with Solaris linker - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' - if $CC --version | $GREP -v '^2\.7' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' - else - # g++ 2.7 appears to require `-G' NOT `-shared' on this - # platform. - _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' - fi - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - ;; - esac - fi - ;; - esac - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - vxworks*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - - AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) - test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no - - _LT_TAGVAR(GCC, $1)="$GXX" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_SYS_HIDDEN_LIBDEPS($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - CC=$lt_save_CC - LDCXX=$LD - LD=$lt_save_LD - GCC=$lt_save_GCC - with_gnu_ld=$lt_save_with_gnu_ld - lt_cv_path_LDCXX=$lt_cv_path_LD - lt_cv_path_LD=$lt_save_path_LD - lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld - lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld -fi # test "$_lt_caught_CXX_error" != yes - -AC_LANG_POP -])# _LT_LANG_CXX_CONFIG - - -# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) -# --------------------------------- -# Figure out "hidden" library dependencies from verbose -# compiler output when linking a shared library. -# Parse the compiler output and extract the necessary -# objects, libraries and library flags. -m4_defun([_LT_SYS_HIDDEN_LIBDEPS], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -# Dependencies to place before and after the object being linked: -_LT_TAGVAR(predep_objects, $1)= -_LT_TAGVAR(postdep_objects, $1)= -_LT_TAGVAR(predeps, $1)= -_LT_TAGVAR(postdeps, $1)= -_LT_TAGVAR(compiler_lib_search_path, $1)= - -dnl we can't use the lt_simple_compile_test_code here, -dnl because it contains code intended for an executable, -dnl not a library. It's possible we should let each -dnl tag define a new lt_????_link_test_code variable, -dnl but it's only used here... -m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF -int a; -void foo (void) { a = 0; } -_LT_EOF -], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF -class Foo -{ -public: - Foo (void) { a = 0; } -private: - int a; -}; -_LT_EOF -], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF - subroutine foo - implicit none - integer*4 a - a=0 - return - end -_LT_EOF -], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF - subroutine foo - implicit none - integer a - a=0 - return - end -_LT_EOF -], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF -public class foo { - private int a; - public void bar (void) { - a = 0; - } -}; -_LT_EOF -]) -dnl Parse the compiler output and extract the necessary -dnl objects, libraries and library flags. -if AC_TRY_EVAL(ac_compile); then - # Parse the compiler output and extract the necessary - # objects, libraries and library flags. - - # Sentinel used to keep track of whether or not we are before - # the conftest object file. - pre_test_object_deps_done=no - - for p in `eval "$output_verbose_link_cmd"`; do - case $p in - - -L* | -R* | -l*) - # Some compilers place space between "-{L,R}" and the path. - # Remove the space. - if test $p = "-L" || - test $p = "-R"; then - prev=$p - continue - else - prev= - fi - - if test "$pre_test_object_deps_done" = no; then - case $p in - -L* | -R*) - # Internal compiler library paths should come after those - # provided the user. The postdeps already come after the - # user supplied libs so there is no need to process them. - if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then - _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" - else - _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" - fi - ;; - # The "-l" case would never come before the object being - # linked, so don't bother handling this case. - esac - else - if test -z "$_LT_TAGVAR(postdeps, $1)"; then - _LT_TAGVAR(postdeps, $1)="${prev}${p}" - else - _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" - fi - fi - ;; - - *.$objext) - # This assumes that the test object file only shows up - # once in the compiler output. - if test "$p" = "conftest.$objext"; then - pre_test_object_deps_done=yes - continue - fi - - if test "$pre_test_object_deps_done" = no; then - if test -z "$_LT_TAGVAR(predep_objects, $1)"; then - _LT_TAGVAR(predep_objects, $1)="$p" - else - _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" - fi - else - if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then - _LT_TAGVAR(postdep_objects, $1)="$p" - else - _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" - fi - fi - ;; - - *) ;; # Ignore the rest. - - esac - done - - # Clean up. - rm -f a.out a.exe -else - echo "libtool.m4: error: problem compiling $1 test program" -fi - -$RM -f confest.$objext - -# PORTME: override above test on systems where it is broken -m4_if([$1], [CXX], -[case $host_os in -interix[[3-9]]*) - # Interix 3.5 installs completely hosed .la files for C++, so rather than - # hack all around it, let's just trust "g++" to DTRT. - _LT_TAGVAR(predep_objects,$1)= - _LT_TAGVAR(postdep_objects,$1)= - _LT_TAGVAR(postdeps,$1)= - ;; - -linux*) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - if test "$solaris_use_stlport4" != yes; then - _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' - fi - ;; - esac - ;; - -solaris*) - case $cc_basename in - CC*) - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - # Adding this requires a known-good setup of shared libraries for - # Sun compiler versions before 5.6, else PIC objects from an old - # archive will be linked into the output, leading to subtle bugs. - if test "$solaris_use_stlport4" != yes; then - _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' - fi - ;; - esac - ;; -esac -]) - -case " $_LT_TAGVAR(postdeps, $1) " in -*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; -esac - _LT_TAGVAR(compiler_lib_search_dirs, $1)= -if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then - _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` -fi -_LT_TAGDECL([], [compiler_lib_search_dirs], [1], - [The directories searched by this compiler when creating a shared library]) -_LT_TAGDECL([], [predep_objects], [1], - [Dependencies to place before and after the objects being linked to - create a shared library]) -_LT_TAGDECL([], [postdep_objects], [1]) -_LT_TAGDECL([], [predeps], [1]) -_LT_TAGDECL([], [postdeps], [1]) -_LT_TAGDECL([], [compiler_lib_search_path], [1], - [The library search path used internally by the compiler when linking - a shared library]) -])# _LT_SYS_HIDDEN_LIBDEPS - - -# _LT_PROG_F77 -# ------------ -# Since AC_PROG_F77 is broken, in that it returns the empty string -# if there is no fortran compiler, we have our own version here. -m4_defun([_LT_PROG_F77], -[ -pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes]) -AC_PROG_F77 -if test -z "$F77" || test "X$F77" = "Xno"; then - _lt_disable_F77=yes -fi -popdef([AC_MSG_ERROR]) -])# _LT_PROG_F77 - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([_LT_PROG_F77], []) - - -# _LT_LANG_F77_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for a Fortran 77 compiler are -# suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_F77_CONFIG], -[AC_REQUIRE([_LT_PROG_F77])dnl -AC_LANG_PUSH(Fortran 77) - -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for f77 test sources. -ac_ext=f - -# Object file extension for compiled f77 test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the F77 compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_disable_F77" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="\ - subroutine t - return - end -" - - # Code to be used in simple link tests - lt_simple_link_test_code="\ - program t - end -" - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC="$CC" - lt_save_GCC=$GCC - CC=${F77-"f77"} - compiler=$CC - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - GCC=$G77 - if test -n "$compiler"; then - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_TAGVAR(GCC, $1)="$G77" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - GCC=$lt_save_GCC - CC="$lt_save_CC" -fi # test "$_lt_disable_F77" != yes - -AC_LANG_POP -])# _LT_LANG_F77_CONFIG - - -# _LT_PROG_FC -# ----------- -# Since AC_PROG_FC is broken, in that it returns the empty string -# if there is no fortran compiler, we have our own version here. -m4_defun([_LT_PROG_FC], -[ -pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes]) -AC_PROG_FC -if test -z "$FC" || test "X$FC" = "Xno"; then - _lt_disable_FC=yes -fi -popdef([AC_MSG_ERROR]) -])# _LT_PROG_FC - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([_LT_PROG_FC], []) - - -# _LT_LANG_FC_CONFIG([TAG]) -# ------------------------- -# Ensure that the configuration variables for a Fortran compiler are -# suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_FC_CONFIG], -[AC_REQUIRE([_LT_PROG_FC])dnl -AC_LANG_PUSH(Fortran) - -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for fc test sources. -ac_ext=${ac_fc_srcext-f} - -# Object file extension for compiled fc test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the FC compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_disable_FC" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="\ - subroutine t - return - end -" - - # Code to be used in simple link tests - lt_simple_link_test_code="\ - program t - end -" - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC="$CC" - lt_save_GCC=$GCC - CC=${FC-"f95"} - compiler=$CC - GCC=$ac_cv_fc_compiler_gnu - - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - - if test -n "$compiler"; then - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_SYS_HIDDEN_LIBDEPS($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - GCC=$lt_save_GCC - CC="$lt_save_CC" -fi # test "$_lt_disable_FC" != yes - -AC_LANG_POP -])# _LT_LANG_FC_CONFIG - - -# _LT_LANG_GCJ_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for the GNU Java Compiler compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_GCJ_CONFIG], -[AC_REQUIRE([LT_PROG_GCJ])dnl -AC_LANG_SAVE - -# Source file extension for Java test sources. -ac_ext=java - -# Object file extension for compiled Java test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="class foo {}" - -# Code to be used in simple link tests -lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC="$CC" -lt_save_GCC=$GCC -GCC=yes -CC=${GCJ-"gcj"} -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_TAGVAR(LD, $1)="$LD" -_LT_CC_BASENAME([$compiler]) - -# GCJ did not exist at the time GCC didn't implicitly link libc in. -_LT_TAGVAR(archive_cmds_need_lc, $1)=no - -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds - -## CAVEAT EMPTOR: -## There is no encapsulation within the following macros, do not change -## the running order or otherwise move them around unless you know exactly -## what you are doing... -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) -fi - -AC_LANG_RESTORE - -GCC=$lt_save_GCC -CC="$lt_save_CC" -])# _LT_LANG_GCJ_CONFIG - - -# _LT_LANG_RC_CONFIG([TAG]) -# ------------------------- -# Ensure that the configuration variables for the Windows resource compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_RC_CONFIG], -[AC_REQUIRE([LT_PROG_RC])dnl -AC_LANG_SAVE - -# Source file extension for RC test sources. -ac_ext=rc - -# Object file extension for compiled RC test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' - -# Code to be used in simple link tests -lt_simple_link_test_code="$lt_simple_compile_test_code" - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC="$CC" -lt_save_GCC=$GCC -GCC= -CC=${RC-"windres"} -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_CC_BASENAME([$compiler]) -_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - -if test -n "$compiler"; then - : - _LT_CONFIG($1) -fi - -GCC=$lt_save_GCC -AC_LANG_RESTORE -CC="$lt_save_CC" -])# _LT_LANG_RC_CONFIG - - -# LT_PROG_GCJ -# ----------- -AC_DEFUN([LT_PROG_GCJ], -[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], - [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], - [AC_CHECK_TOOL(GCJ, gcj,) - test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" - AC_SUBST(GCJFLAGS)])])[]dnl -]) - -# Old name: -AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_GCJ], []) - - -# LT_PROG_RC -# ---------- -AC_DEFUN([LT_PROG_RC], -[AC_CHECK_TOOL(RC, windres,) -]) - -# Old name: -AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_RC], []) - - -# _LT_DECL_EGREP -# -------------- -# If we don't have a new enough Autoconf to choose the best grep -# available, choose the one first in the user's PATH. -m4_defun([_LT_DECL_EGREP], -[AC_REQUIRE([AC_PROG_EGREP])dnl -AC_REQUIRE([AC_PROG_FGREP])dnl -test -z "$GREP" && GREP=grep -_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) -_LT_DECL([], [EGREP], [1], [An ERE matcher]) -_LT_DECL([], [FGREP], [1], [A literal string matcher]) -dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too -AC_SUBST([GREP]) -]) - - -# _LT_DECL_OBJDUMP -# -------------- -# If we don't have a new enough Autoconf to choose the best objdump -# available, choose the one first in the user's PATH. -m4_defun([_LT_DECL_OBJDUMP], -[AC_CHECK_TOOL(OBJDUMP, objdump, false) -test -z "$OBJDUMP" && OBJDUMP=objdump -_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) -AC_SUBST([OBJDUMP]) -]) - - -# _LT_DECL_SED -# ------------ -# Check for a fully-functional sed program, that truncates -# as few characters as possible. Prefer GNU sed if found. -m4_defun([_LT_DECL_SED], -[AC_PROG_SED -test -z "$SED" && SED=sed -Xsed="$SED -e 1s/^X//" -_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) -_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], - [Sed that helps us avoid accidentally triggering echo(1) options like -n]) -])# _LT_DECL_SED - -m4_ifndef([AC_PROG_SED], [ -############################################################ -# NOTE: This macro has been submitted for inclusion into # -# GNU Autoconf as AC_PROG_SED. When it is available in # -# a released version of Autoconf we should remove this # -# macro and use it instead. # -############################################################ - -m4_defun([AC_PROG_SED], -[AC_MSG_CHECKING([for a sed that does not truncate output]) -AC_CACHE_VAL(lt_cv_path_SED, -[# Loop through the user's path and test for sed and gsed. -# Then use that list of sed's as ones to test for truncation. -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for lt_ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then - lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" - fi - done - done -done -IFS=$as_save_IFS -lt_ac_max=0 -lt_ac_count=0 -# Add /usr/xpg4/bin/sed as it is typically found on Solaris -# along with /bin/sed that truncates output. -for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do - test ! -f $lt_ac_sed && continue - cat /dev/null > conftest.in - lt_ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >conftest.in - # Check for GNU sed and select it if it is found. - if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then - lt_cv_path_SED=$lt_ac_sed - break - fi - while true; do - cat conftest.in conftest.in >conftest.tmp - mv conftest.tmp conftest.in - cp conftest.in conftest.nl - echo >>conftest.nl - $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break - cmp -s conftest.out conftest.nl || break - # 10000 chars as input seems more than enough - test $lt_ac_count -gt 10 && break - lt_ac_count=`expr $lt_ac_count + 1` - if test $lt_ac_count -gt $lt_ac_max; then - lt_ac_max=$lt_ac_count - lt_cv_path_SED=$lt_ac_sed - fi - done -done -]) -SED=$lt_cv_path_SED -AC_SUBST([SED]) -AC_MSG_RESULT([$SED]) -])#AC_PROG_SED -])#m4_ifndef - -# Old name: -AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_SED], []) - - -# _LT_CHECK_SHELL_FEATURES -# ------------------------ -# Find out whether the shell is Bourne or XSI compatible, -# or has some other useful features. -m4_defun([_LT_CHECK_SHELL_FEATURES], -[AC_MSG_CHECKING([whether the shell understands some XSI constructs]) -# Try some XSI features -xsi_shell=no -( _lt_dummy="a/b/c" - test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ - = c,a/b,, \ - && eval 'test $(( 1 + 1 )) -eq 2 \ - && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ - && xsi_shell=yes -AC_MSG_RESULT([$xsi_shell]) -_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) - -AC_MSG_CHECKING([whether the shell understands "+="]) -lt_shell_append=no -( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ - >/dev/null 2>&1 \ - && lt_shell_append=yes -AC_MSG_RESULT([$lt_shell_append]) -_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) - -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - lt_unset=unset -else - lt_unset=false -fi -_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl - -# test EBCDIC or ASCII -case `echo X|tr X '\101'` in - A) # ASCII based system - # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr - lt_SP2NL='tr \040 \012' - lt_NL2SP='tr \015\012 \040\040' - ;; - *) # EBCDIC based system - lt_SP2NL='tr \100 \n' - lt_NL2SP='tr \r\n \100\100' - ;; -esac -_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl -_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl -])# _LT_CHECK_SHELL_FEATURES - - -# _LT_PROG_XSI_SHELLFNS -# --------------------- -# Bourne and XSI compatible variants of some useful shell functions. -m4_defun([_LT_PROG_XSI_SHELLFNS], -[case $xsi_shell in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac -} - -# func_basename file -func_basename () -{ - func_basename_result="${1##*/}" -} - -# func_dirname_and_basename file append nondir_replacement -# perform func_basename and func_dirname in a single function -# call: -# dirname: Compute the dirname of FILE. If nonempty, -# add APPEND to the result, otherwise set result -# to NONDIR_REPLACEMENT. -# value returned in "$func_dirname_result" -# basename: Compute filename of FILE. -# value retuned in "$func_basename_result" -# Implementation must be kept synchronized with func_dirname -# and func_basename. For efficiency, we do not delegate to -# those functions but instead duplicate the functionality here. -func_dirname_and_basename () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac - func_basename_result="${1##*/}" -} - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -func_stripname () -{ - # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are - # positional parameters, so assign one to ordinary parameter first. - func_stripname_result=${3} - func_stripname_result=${func_stripname_result#"${1}"} - func_stripname_result=${func_stripname_result%"${2}"} -} - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=${1%%=*} - func_opt_split_arg=${1#*=} -} - -# func_lo2o object -func_lo2o () -{ - case ${1} in - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; - *) func_lo2o_result=${1} ;; - esac -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=${1%.*}.lo -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=$(( $[*] )) -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=${#1} -} - -_LT_EOF - ;; - *) # Bourne compatible functions. - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi -} - -# func_basename file -func_basename () -{ - func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` -} - -dnl func_dirname_and_basename -dnl A portable version of this function is already defined in general.m4sh -dnl so there is no need for it here. - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# func_strip_suffix prefix name -func_stripname () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "X${3}" \ - | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "X${3}" \ - | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; - esac -} - -# sed scripts: -my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q' -my_sed_long_arg='1s/^-[[^=]]*=//' - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` - func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` -} - -# func_lo2o object -func_lo2o () -{ - func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'` -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=`expr "$[@]"` -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len` -} - -_LT_EOF -esac - -case $lt_shell_append in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$[1]+=\$[2]" -} -_LT_EOF - ;; - *) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$[1]=\$$[1]\$[2]" -} - -_LT_EOF - ;; - esac -]) - diff --git a/acinclude/ltoptions.m4 b/acinclude/ltoptions.m4 deleted file mode 100644 index d4df679..0000000 --- a/acinclude/ltoptions.m4 +++ /dev/null @@ -1,370 +0,0 @@ -############################################################################## -# Helper functions for option handling. -*- Autoconf -*- -# -# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. -# Written by Gary V. Vaughan, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 6 ltoptions.m4 - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) - - -# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) -# ------------------------------------------ -m4_define([_LT_MANGLE_OPTION], -[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) - - -# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) -# --------------------------------------- -# Set option OPTION-NAME for macro MACRO-NAME, and if there is a -# matching handler defined, dispatch to it. Other OPTION-NAMEs are -# saved as a flag. -m4_define([_LT_SET_OPTION], -[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl -m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), - _LT_MANGLE_DEFUN([$1], [$2]), - [m4_warning([Unknown $1 option `$2'])])[]dnl -]) - - -# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) -# ------------------------------------------------------------ -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -m4_define([_LT_IF_OPTION], -[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) - - -# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) -# ------------------------------------------------------- -# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME -# are set. -m4_define([_LT_UNLESS_OPTIONS], -[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), - [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), - [m4_define([$0_found])])])[]dnl -m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 -])[]dnl -]) - - -# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) -# ---------------------------------------- -# OPTION-LIST is a space-separated list of Libtool options associated -# with MACRO-NAME. If any OPTION has a matching handler declared with -# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about -# the unknown option and exit. -m4_defun([_LT_SET_OPTIONS], -[# Set options -m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), - [_LT_SET_OPTION([$1], _LT_Option)]) - -m4_if([$1],[LT_INIT],[ - dnl - dnl Simply set some default values (i.e off) if boolean options were not - dnl specified: - _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no - ]) - _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no - ]) - dnl - dnl If no reference was made to various pairs of opposing options, then - dnl we run the default mode handler for the pair. For example, if neither - dnl `shared' nor `disable-shared' was passed, we enable building of shared - dnl archives by default: - _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) - _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) - _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) - _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], - [_LT_ENABLE_FAST_INSTALL]) - ]) -])# _LT_SET_OPTIONS - - -## --------------------------------- ## -## Macros to handle LT_INIT options. ## -## --------------------------------- ## - -# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) -# ----------------------------------------- -m4_define([_LT_MANGLE_DEFUN], -[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) - - -# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) -# ----------------------------------------------- -m4_define([LT_OPTION_DEFINE], -[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl -])# LT_OPTION_DEFINE - - -# dlopen -# ------ -LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes -]) - -AU_DEFUN([AC_LIBTOOL_DLOPEN], -[_LT_SET_OPTION([LT_INIT], [dlopen]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `dlopen' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) - - -# win32-dll -# --------- -# Declare package support for building win32 dll's. -LT_OPTION_DEFINE([LT_INIT], [win32-dll], -[enable_win32_dll=yes - -case $host in -*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*) - AC_CHECK_TOOL(AS, as, false) - AC_CHECK_TOOL(DLLTOOL, dlltool, false) - AC_CHECK_TOOL(OBJDUMP, objdump, false) - ;; -esac - -test -z "$AS" && AS=as -_LT_DECL([], [AS], [0], [Assembler program])dnl - -test -z "$DLLTOOL" && DLLTOOL=dlltool -_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl - -test -z "$OBJDUMP" && OBJDUMP=objdump -_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl -])# win32-dll - -AU_DEFUN([AC_LIBTOOL_WIN32_DLL], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -_LT_SET_OPTION([LT_INIT], [win32-dll]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `win32-dll' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) - - -# _LT_ENABLE_SHARED([DEFAULT]) -# ---------------------------- -# implement the --enable-shared flag, and supports the `shared' and -# `disable-shared' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -m4_define([_LT_ENABLE_SHARED], -[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([shared], - [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], - [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_shared=yes ;; - no) enable_shared=no ;; - *) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_shared=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) - - _LT_DECL([build_libtool_libs], [enable_shared], [0], - [Whether or not to build shared libraries]) -])# _LT_ENABLE_SHARED - -LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) - -# Old names: -AC_DEFUN([AC_ENABLE_SHARED], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) -]) - -AC_DEFUN([AC_DISABLE_SHARED], -[_LT_SET_OPTION([LT_INIT], [disable-shared]) -]) - -AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) -AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_ENABLE_SHARED], []) -dnl AC_DEFUN([AM_DISABLE_SHARED], []) - - - -# _LT_ENABLE_STATIC([DEFAULT]) -# ---------------------------- -# implement the --enable-static flag, and support the `static' and -# `disable-static' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -m4_define([_LT_ENABLE_STATIC], -[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([static], - [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], - [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_static=yes ;; - no) enable_static=no ;; - *) - enable_static=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_static=]_LT_ENABLE_STATIC_DEFAULT) - - _LT_DECL([build_old_libs], [enable_static], [0], - [Whether or not to build static libraries]) -])# _LT_ENABLE_STATIC - -LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) - -# Old names: -AC_DEFUN([AC_ENABLE_STATIC], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) -]) - -AC_DEFUN([AC_DISABLE_STATIC], -[_LT_SET_OPTION([LT_INIT], [disable-static]) -]) - -AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) -AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_ENABLE_STATIC], []) -dnl AC_DEFUN([AM_DISABLE_STATIC], []) - - - -# _LT_ENABLE_FAST_INSTALL([DEFAULT]) -# ---------------------------------- -# implement the --enable-fast-install flag, and support the `fast-install' -# and `disable-fast-install' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -m4_define([_LT_ENABLE_FAST_INSTALL], -[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([fast-install], - [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], - [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_fast_install=yes ;; - no) enable_fast_install=no ;; - *) - enable_fast_install=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_fast_install=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) - -_LT_DECL([fast_install], [enable_fast_install], [0], - [Whether or not to optimize for fast installation])dnl -])# _LT_ENABLE_FAST_INSTALL - -LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) - -# Old names: -AU_DEFUN([AC_ENABLE_FAST_INSTALL], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you put -the `fast-install' option into LT_INIT's first parameter.]) -]) - -AU_DEFUN([AC_DISABLE_FAST_INSTALL], -[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you put -the `disable-fast-install' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) -dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) - - -# _LT_WITH_PIC([MODE]) -# -------------------- -# implement the --with-pic flag, and support the `pic-only' and `no-pic' -# LT_INIT options. -# MODE is either `yes' or `no'. If omitted, it defaults to `both'. -m4_define([_LT_WITH_PIC], -[AC_ARG_WITH([pic], - [AS_HELP_STRING([--with-pic], - [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], - [pic_mode="$withval"], - [pic_mode=default]) - -test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) - -_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl -])# _LT_WITH_PIC - -LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) -LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) - -# Old name: -AU_DEFUN([AC_LIBTOOL_PICMODE], -[_LT_SET_OPTION([LT_INIT], [pic-only]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `pic-only' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) - -## ----------------- ## -## LTDL_INIT Options ## -## ----------------- ## - -m4_define([_LTDL_MODE], []) -LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], - [m4_define([_LTDL_MODE], [nonrecursive])]) -LT_OPTION_DEFINE([LTDL_INIT], [recursive], - [m4_define([_LTDL_MODE], [recursive])]) -LT_OPTION_DEFINE([LTDL_INIT], [subproject], - [m4_define([_LTDL_MODE], [subproject])]) - -m4_define([_LTDL_TYPE], []) -LT_OPTION_DEFINE([LTDL_INIT], [installable], - [m4_define([_LTDL_TYPE], [installable])]) -LT_OPTION_DEFINE([LTDL_INIT], [convenience], - [m4_define([_LTDL_TYPE], [convenience])]) - diff --git a/acinclude/ltsugar.m4 b/acinclude/ltsugar.m4 deleted file mode 100644 index 02a939d..0000000 --- a/acinclude/ltsugar.m4 +++ /dev/null @@ -1,125 +0,0 @@ -############################################################################## -# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- -# -# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. -# Written by Gary V. Vaughan, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 6 ltsugar.m4 - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) - - -# lt_join(SEP, ARG1, [ARG2...]) -# ----------------------------- -# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their -# associated separator. -# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier -# versions in m4sugar had bugs. -m4_define([lt_join], -[m4_if([$#], [1], [], - [$#], [2], [[$2]], - [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) -m4_define([_lt_join], -[m4_if([$#$2], [2], [], - [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) - - -# lt_car(LIST) -# lt_cdr(LIST) -# ------------ -# Manipulate m4 lists. -# These macros are necessary as long as will still need to support -# Autoconf-2.59 which quotes differently. -m4_define([lt_car], [[$1]]) -m4_define([lt_cdr], -[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], - [$#], 1, [], - [m4_dquote(m4_shift($@))])]) -m4_define([lt_unquote], $1) - - -# lt_append(MACRO-NAME, STRING, [SEPARATOR]) -# ------------------------------------------ -# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. -# Note that neither SEPARATOR nor STRING are expanded; they are appended -# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). -# No SEPARATOR is output if MACRO-NAME was previously undefined (different -# than defined and empty). -# -# This macro is needed until we can rely on Autoconf 2.62, since earlier -# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. -m4_define([lt_append], -[m4_define([$1], - m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) - - - -# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) -# ---------------------------------------------------------- -# Produce a SEP delimited list of all paired combinations of elements of -# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list -# has the form PREFIXmINFIXSUFFIXn. -# Needed until we can rely on m4_combine added in Autoconf 2.62. -m4_define([lt_combine], -[m4_if(m4_eval([$# > 3]), [1], - [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl -[[m4_foreach([_Lt_prefix], [$2], - [m4_foreach([_Lt_suffix], - ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, - [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) - - -# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) -# ----------------------------------------------------------------------- -# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited -# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. -m4_define([lt_if_append_uniq], -[m4_ifdef([$1], - [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], - [lt_append([$1], [$2], [$3])$4], - [$5])], - [lt_append([$1], [$2], [$3])$4])]) - - -# lt_dict_add(DICT, KEY, VALUE) -# ----------------------------- -m4_define([lt_dict_add], -[m4_define([$1($2)], [$3])]) - - -# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) -# -------------------------------------------- -m4_define([lt_dict_add_subkey], -[m4_define([$1($2:$3)], [$4])]) - - -# lt_dict_fetch(DICT, KEY, [SUBKEY]) -# ---------------------------------- -m4_define([lt_dict_fetch], -[m4_ifval([$3], - m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), - m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) - - -# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) -# ----------------------------------------------------------------- -m4_define([lt_if_dict_fetch], -[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], - [$5], - [$6])]) - - -# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) -# -------------------------------------------------------------- -m4_define([lt_dict_filter], -[m4_if([$5], [], [], - [lt_join(m4_quote(m4_default([$4], [[, ]])), - lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), - [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl -]) - diff --git a/acinclude/ltversion.m4 b/acinclude/ltversion.m4 deleted file mode 100644 index 83a83f2..0000000 --- a/acinclude/ltversion.m4 +++ /dev/null @@ -1,25 +0,0 @@ -############################################################################## -# ltversion.m4 -- version numbers -*- Autoconf -*- -# -# Copyright (C) 2004 Free Software Foundation, Inc. -# Written by Scott James Remnant, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# Generated from ltversion.in. - -# serial 3012 ltversion.m4 -# This file is part of GNU Libtool - -m4_define([LT_PACKAGE_VERSION], [2.2.6]) -m4_define([LT_PACKAGE_REVISION], [1.3012]) - -AC_DEFUN([LTVERSION_VERSION], -[macro_version='2.2.6' -macro_revision='1.3012' -_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) -_LT_DECL(, macro_revision, 0) -]) - diff --git a/acinclude/lt~obsolete.m4 b/acinclude/lt~obsolete.m4 deleted file mode 100644 index 3b2acd4..0000000 --- a/acinclude/lt~obsolete.m4 +++ /dev/null @@ -1,93 +0,0 @@ -############################################################################## -# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- -# -# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. -# Written by Scott James Remnant, 2004. -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 4 lt~obsolete.m4 - -# These exist entirely to fool aclocal when bootstrapping libtool. -# -# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) -# which have later been changed to m4_define as they aren't part of the -# exported API, or moved to Autoconf or Automake where they belong. -# -# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN -# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us -# using a macro with the same name in our local m4/libtool.m4 it'll -# pull the old libtool.m4 in (it doesn't see our shiny new m4_define -# and doesn't know about Autoconf macros at all.) -# -# So we provide this file, which has a silly filename so it's always -# included after everything else. This provides aclocal with the -# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything -# because those macros already exist, or will be overwritten later. -# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. -# -# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. -# Yes, that means every name once taken will need to remain here until -# we give up compatibility with versions before 1.7, at which point -# we need to keep only those names which we still refer to. - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) - -m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) -m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) -m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) -m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) -m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) -m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) -m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) -m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) -m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) -m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) -m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) -m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) -m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) -m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) -m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) -m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) -m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) -m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) -m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) -m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) -m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) -m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) -m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) -m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) -m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) -m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) -m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) -m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) -m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) -m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) -m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) -m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) -m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) -m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) -m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) -m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) -m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) -m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) -m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) -m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) -m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) -m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) -m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])]) -m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) -m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) -m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) -m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) -m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) -m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) -m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) -m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) diff --git a/acinclude/pkg.m4 b/acinclude/pkg.m4 index 0048a3f..13a8890 100644 --- a/acinclude/pkg.m4 +++ b/acinclude/pkg.m4 @@ -1,32 +1,68 @@ -# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -# -# Copyright © 2004 Scott James Remnant . -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# PKG_PROG_PKG_CONFIG([MIN-VERSION]) -# ---------------------------------- +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 12 (pkg-config-0.29.2) + +dnl Copyright © 2004 Scott James Remnant . +dnl Copyright © 2012-2015 Dan Nicholson +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +dnl 02111-1307, USA. +dnl +dnl As a special exception to the GNU General Public License, if you +dnl distribute this file as part of a program that contains a +dnl configuration script generated by Autoconf, you may include it under +dnl the same distribution terms that you use for the rest of that +dnl program. + +dnl PKG_PREREQ(MIN-VERSION) +dnl ----------------------- +dnl Since: 0.29 +dnl +dnl Verify that the version of the pkg-config macros are at least +dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's +dnl installed version of pkg-config, this checks the developer's version +dnl of pkg.m4 when generating configure. +dnl +dnl To ensure that this macro is defined, also add: +dnl m4_ifndef([PKG_PREREQ], +dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) +dnl +dnl See the "Since" comment for each macro you use to see what version +dnl of the macros you require. +m4_defun([PKG_PREREQ], +[m4_define([PKG_MACROS_VERSION], [0.29.2]) +m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, + [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) +])dnl PKG_PREREQ + +dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) +dnl ---------------------------------- +dnl Since: 0.16 +dnl +dnl Search for the pkg-config tool and set the PKG_CONFIG variable to +dnl first found in the path. Checks that the version of pkg-config found +dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is +dnl used since that's the first version where most current features of +dnl pkg-config existed. AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) -m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) -AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl +m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) +m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) +AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) +AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) + if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi @@ -39,48 +75,49 @@ AC_MSG_RESULT([no]) PKG_CONFIG="" fi - -fi[]dnl -])# PKG_PROG_PKG_CONFIG - -# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# -# Check to see whether a particular set of modules exists. Similar -# to PKG_CHECK_MODULES(), but does not set variables or print errors. -# -# -# Similar to PKG_CHECK_MODULES, make sure that the first instance of -# this or PKG_CHECK_MODULES is called, or make sure to call -# PKG_CHECK_EXISTS manually -# -------------------------------------------------------------- +fi[]dnl +])dnl PKG_PROG_PKG_CONFIG + +dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------------------------------- +dnl Since: 0.18 +dnl +dnl Check to see whether a particular set of modules exists. Similar to +dnl PKG_CHECK_MODULES(), but does not set variables or print errors. +dnl +dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +dnl only at the first occurence in configure.ac, so if the first place +dnl it's called might be skipped (such as if it is within an "if", you +dnl have to call PKG_CHECK_EXISTS manually AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then - m4_ifval([$2], [$2], [:]) + m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) - -# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) -# --------------------------------------------- +dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +dnl --------------------------------------------- +dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting +dnl pkg_failed based on the result. m4_define([_PKG_CONFIG], -[if test -n "$PKG_CONFIG"; then - if test -n "$$1"; then - pkg_cv_[]$1="$$1" - else - PKG_CHECK_EXISTS([$3], - [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], - [pkg_failed=yes]) - fi -else - pkg_failed=untried -fi[]dnl -])# _PKG_CONFIG - -# _PKG_SHORT_ERRORS_SUPPORTED -# ----------------------------- +[if test -n "$$1"; then + pkg_cv_[]$1="$$1" + elif test -n "$PKG_CONFIG"; then + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes ], + [pkg_failed=yes]) + else + pkg_failed=untried +fi[]dnl +])dnl _PKG_CONFIG + +dnl _PKG_SHORT_ERRORS_SUPPORTED +dnl --------------------------- +dnl Internal check to see if pkg-config supports short errors. AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -88,26 +125,24 @@ else _pkg_short_errors_supported=no fi[]dnl -])# _PKG_SHORT_ERRORS_SUPPORTED - - -# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], -# [ACTION-IF-NOT-FOUND]) -# -# -# Note that if there is a possibility the first call to -# PKG_CHECK_MODULES might not happen, you should be sure to include an -# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac -# -# -# -------------------------------------------------------------- +])dnl _PKG_SHORT_ERRORS_SUPPORTED + + +dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl -------------------------------------------------------------- +dnl Since: 0.4.0 +dnl +dnl Note that if there is a possibility the first call to +dnl PKG_CHECK_MODULES might not happen, you should be sure to include an +dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no -AC_MSG_CHECKING([for $1]) +AC_MSG_CHECKING([for $2]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) @@ -117,16 +152,17 @@ See the pkg-config man page for more details.]) if test $pkg_failed = yes; then + AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then - $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` - else - $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD - ifelse([$4], , [AC_MSG_ERROR(dnl + m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS @@ -134,24 +170,106 @@ Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. -_PKG_TEXT -])], - [AC_MSG_RESULT([no]) - $4]) +_PKG_TEXT])[]dnl + ]) elif test $pkg_failed = untried; then - ifelse([$4], , [AC_MSG_FAILURE(dnl + AC_MSG_RESULT([no]) + m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT -To get pkg-config, see .])], - [$4]) +To get pkg-config, see .])[]dnl + ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) - ifelse([$3], , :, [$3]) -fi[]dnl -])# PKG_CHECK_MODULES + $3 +fi[]dnl +])dnl PKG_CHECK_MODULES + + +dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl --------------------------------------------------------------------- +dnl Since: 0.29 +dnl +dnl Checks for existence of MODULES and gathers its build flags with +dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags +dnl and VARIABLE-PREFIX_LIBS from --libs. +dnl +dnl Note that if there is a possibility the first call to +dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to +dnl include an explicit call to PKG_PROG_PKG_CONFIG in your +dnl configure.ac. +AC_DEFUN([PKG_CHECK_MODULES_STATIC], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +_save_PKG_CONFIG=$PKG_CONFIG +PKG_CONFIG="$PKG_CONFIG --static" +PKG_CHECK_MODULES($@) +PKG_CONFIG=$_save_PKG_CONFIG[]dnl +])dnl PKG_CHECK_MODULES_STATIC + + +dnl PKG_INSTALLDIR([DIRECTORY]) +dnl ------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable pkgconfigdir as the location where a module +dnl should install pkg-config .pc files. By default the directory is +dnl $libdir/pkgconfig, but the default can be changed by passing +dnl DIRECTORY. The user can override through the --with-pkgconfigdir +dnl parameter. +AC_DEFUN([PKG_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([pkgconfigdir], + [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, + [with_pkgconfigdir=]pkg_default) +AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +])dnl PKG_INSTALLDIR + + +dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) +dnl -------------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable noarch_pkgconfigdir as the location where a +dnl module should install arch-independent pkg-config .pc files. By +dnl default the directory is $datadir/pkgconfig, but the default can be +dnl changed by passing DIRECTORY. The user can override through the +dnl --with-noarch-pkgconfigdir parameter. +AC_DEFUN([PKG_NOARCH_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([noarch-pkgconfigdir], + [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, + [with_noarch_pkgconfigdir=]pkg_default) +AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +])dnl PKG_NOARCH_INSTALLDIR + + +dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------- +dnl Since: 0.28 +dnl +dnl Retrieves the value of the pkg-config variable for the given module. +AC_DEFUN([PKG_CHECK_VAR], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl + +_PKG_CONFIG([$1], [variable="][$3]["], [$2]) +AS_VAR_COPY([$1], [pkg_cv_][$1]) + +AS_VAR_IF([$1], [""], [$5], [$4])dnl +])dnl PKG_CHECK_VAR diff --git a/acinclude/sdl2.m4 b/acinclude/sdl2.m4 index a03b2d2..af101a8 100644 --- a/acinclude/sdl2.m4 +++ b/acinclude/sdl2.m4 @@ -5,13 +5,13 @@ # stolen from Manish Singh # Shamelessly stolen from Owen Taylor -# serial 1 +# serial 2 dnl AM_PATH_SDL2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS dnl AC_DEFUN([AM_PATH_SDL2], -[dnl +[dnl dnl Get the cflags and libraries from the sdl2-config script dnl AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], @@ -80,41 +80,19 @@ dnl checks the results of sdl2-config to some extent dnl rm -f conf.sdltest - AC_TRY_RUN([ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include -#include #include "SDL.h" - -char* -my_strdup (char *str) -{ - char *new_str; - - if (str) - { - new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); - strcpy (new_str, str); - } - else - new_str = NULL; - - return new_str; -} int main (int argc, char *argv[]) { int major, minor, micro; - char *tmp_version; + FILE *fp = fopen("conf.sdltest", "w"); - /* This hangs on some systems (?) - system ("touch conf.sdltest"); - */ - { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } + if (fp) fclose(fp); - /* HP/UX 9 (%@#!) writes to sscanf strings */ - tmp_version = my_strdup("$min_sdl_version"); - if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + if (sscanf("$min_sdl_version", "%d.%d.%d", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_sdl_version"); exit(1); } @@ -137,7 +115,7 @@ } } -],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) +]])], [], [no_sdl=yes], [echo $ac_n "cross compiling; assumed OK... $ac_c"]) CFLAGS="$ac_save_CFLAGS" CXXFLAGS="$ac_save_CXXFLAGS" LIBS="$ac_save_LIBS" @@ -165,7 +143,7 @@ CFLAGS="$CFLAGS $SDL_CFLAGS" CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" LIBS="$LIBS $SDL_LIBS" - AC_TRY_LINK([ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include #include "SDL.h" @@ -173,7 +151,7 @@ { return 0; } #undef main #define main K_and_R_C_main -], [ return 0; ], +]], [[ return 0; ]])], [ echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding SDL or finding the wrong" echo "*** version of SDL. If it is not finding SDL, you'll need to set your" diff --git a/aclocal.m4 b/aclocal.m4 deleted file mode 100644 index 2189f73..0000000 --- a/aclocal.m4 +++ /dev/null @@ -1,8345 +0,0 @@ -############################################################################## -# Based on libtool-2.2.6a -# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008 Free Software Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -m4_define([_LT_COPYING], [dnl -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008 Free Software Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is part of GNU Libtool. -# -# GNU Libtool is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, or -# obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -]) - -# serial 56 LT_INIT - - -# LT_PREREQ(VERSION) -# ------------------ -# Complain and exit if this libtool version is less that VERSION. -m4_defun([LT_PREREQ], -[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, - [m4_default([$3], - [m4_fatal([Libtool version $1 or higher is required], - 63)])], - [$2])]) - - -# _LT_CHECK_BUILDDIR -# ------------------ -# Complain if the absolute build directory name contains unusual characters -m4_defun([_LT_CHECK_BUILDDIR], -[case `pwd` in - *\ * | *\ *) - AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; -esac -]) - - -# LT_INIT([OPTIONS]) -# ------------------ -AC_DEFUN([LT_INIT], -[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT -AC_BEFORE([$0], [LT_LANG])dnl -AC_BEFORE([$0], [LT_OUTPUT])dnl -AC_BEFORE([$0], [LTDL_INIT])dnl -m4_require([_LT_CHECK_BUILDDIR])dnl - -dnl Autoconf doesn't catch unexpanded LT_ macros by default: -m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl -m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl -dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 -dnl unless we require an AC_DEFUNed macro: -AC_REQUIRE([LTOPTIONS_VERSION])dnl -AC_REQUIRE([LTSUGAR_VERSION])dnl -AC_REQUIRE([LTVERSION_VERSION])dnl -AC_REQUIRE([LTOBSOLETE_VERSION])dnl -m4_require([_LT_PROG_LTMAIN])dnl - -dnl Parse OPTIONS -_LT_SET_OPTIONS([$0], [$1]) - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ltmain" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' -AC_SUBST(LIBTOOL)dnl - -_LT_SETUP - -# Only expand once: -m4_define([LT_INIT]) -])# LT_INIT - -# Old names: -AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) -AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_PROG_LIBTOOL], []) -dnl AC_DEFUN([AM_PROG_LIBTOOL], []) - - -# _LT_CC_BASENAME(CC) -# ------------------- -# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. -m4_defun([_LT_CC_BASENAME], -[for cc_temp in $1""; do - case $cc_temp in - compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; - distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` -]) - - -# _LT_FILEUTILS_DEFAULTS -# ---------------------- -# It is okay to use these file commands and assume they have been set -# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. -m4_defun([_LT_FILEUTILS_DEFAULTS], -[: ${CP="cp -f"} -: ${MV="mv -f"} -: ${RM="rm -f"} -])# _LT_FILEUTILS_DEFAULTS - - -# _LT_SETUP -# --------- -m4_defun([_LT_SETUP], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -_LT_DECL([], [host_alias], [0], [The host system])dnl -_LT_DECL([], [host], [0])dnl -_LT_DECL([], [host_os], [0])dnl -dnl -_LT_DECL([], [build_alias], [0], [The build system])dnl -_LT_DECL([], [build], [0])dnl -_LT_DECL([], [build_os], [0])dnl -dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([LT_PATH_LD])dnl -AC_REQUIRE([LT_PATH_NM])dnl -dnl -AC_REQUIRE([AC_PROG_LN_S])dnl -test -z "$LN_S" && LN_S="ln -s" -_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl -dnl -AC_REQUIRE([LT_CMD_MAX_LEN])dnl -_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl -_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl -dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_CHECK_SHELL_FEATURES])dnl -m4_require([_LT_CMD_RELOAD])dnl -m4_require([_LT_CHECK_MAGIC_METHOD])dnl -m4_require([_LT_CMD_OLD_ARCHIVE])dnl -m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl - -_LT_CONFIG_LIBTOOL_INIT([ -# See if we are running on zsh, and set the options which allow our -# commands through without removal of \ escapes INIT. -if test -n "\${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi -]) -if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi - -_LT_CHECK_OBJDIR - -m4_require([_LT_TAG_COMPILER])dnl -_LT_PROG_ECHO_BACKSLASH - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\([["`\\]]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to delay expansion of an escaped single quote. -delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - -# Global variables: -ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a - -with_gnu_ld="$lt_cv_prog_gnu_ld" - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS -test -z "$LD" && LD=ld -test -z "$ac_objext" && ac_objext=o - -_LT_CC_BASENAME([$compiler]) - -# Only perform the check for file, if the check method requires it -test -z "$MAGIC_CMD" && MAGIC_CMD=file -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - _LT_PATH_MAGIC - fi - ;; -esac - -# Use C for the default configuration in the libtool script -LT_SUPPORTED_TAG([CC]) -_LT_LANG_C_CONFIG -_LT_LANG_DEFAULT_CONFIG -_LT_CONFIG_COMMANDS -])# _LT_SETUP - - -# _LT_PROG_LTMAIN -# --------------- -# Note that this code is called both from `configure', and `config.status' -# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, -# `config.status' has no value for ac_aux_dir unless we are using Automake, -# so we pass a copy along to make sure it has a sensible value anyway. -m4_defun([_LT_PROG_LTMAIN], -[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl -_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) -ltmain="$ac_aux_dir/ltmain.sh" -])# _LT_PROG_LTMAIN - - -## ------------------------------------- ## -## Accumulate code for creating libtool. ## -## ------------------------------------- ## - -# So that we can recreate a full libtool script including additional -# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS -# in macros and then make a single call at the end using the `libtool' -# label. - - -# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) -# ---------------------------------------- -# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. -m4_define([_LT_CONFIG_LIBTOOL_INIT], -[m4_ifval([$1], - [m4_append([_LT_OUTPUT_LIBTOOL_INIT], - [$1 -])])]) - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_INIT]) - - -# _LT_CONFIG_LIBTOOL([COMMANDS]) -# ------------------------------ -# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. -m4_define([_LT_CONFIG_LIBTOOL], -[m4_ifval([$1], - [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], - [$1 -])])]) - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) - - -# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) -# ----------------------------------------------------- -m4_defun([_LT_CONFIG_SAVE_COMMANDS], -[_LT_CONFIG_LIBTOOL([$1]) -_LT_CONFIG_LIBTOOL_INIT([$2]) -]) - - -# _LT_FORMAT_COMMENT([COMMENT]) -# ----------------------------- -# Add leading comment marks to the start of each line, and a trailing -# full-stop to the whole comment if one is not present already. -m4_define([_LT_FORMAT_COMMENT], -[m4_ifval([$1], [ -m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], - [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) -)]) - - - -## ------------------------ ## -## FIXME: Eliminate VARNAME ## -## ------------------------ ## - - -# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) -# ------------------------------------------------------------------- -# CONFIGNAME is the name given to the value in the libtool script. -# VARNAME is the (base) name used in the configure script. -# VALUE may be 0, 1 or 2 for a computed quote escaped value based on -# VARNAME. Any other value will be used directly. -m4_define([_LT_DECL], -[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], - [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], - [m4_ifval([$1], [$1], [$2])]) - lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) - m4_ifval([$4], - [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) - lt_dict_add_subkey([lt_decl_dict], [$2], - [tagged?], [m4_ifval([$5], [yes], [no])])]) -]) - - -# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) -# -------------------------------------------------------- -m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) - - -# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) -# ------------------------------------------------ -m4_define([lt_decl_tag_varnames], -[_lt_decl_filter([tagged?], [yes], $@)]) - - -# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) -# --------------------------------------------------------- -m4_define([_lt_decl_filter], -[m4_case([$#], - [0], [m4_fatal([$0: too few arguments: $#])], - [1], [m4_fatal([$0: too few arguments: $#: $1])], - [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], - [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], - [lt_dict_filter([lt_decl_dict], $@)])[]dnl -]) - - -# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) -# -------------------------------------------------- -m4_define([lt_decl_quote_varnames], -[_lt_decl_filter([value], [1], $@)]) - - -# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) -# --------------------------------------------------- -m4_define([lt_decl_dquote_varnames], -[_lt_decl_filter([value], [2], $@)]) - - -# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) -# --------------------------------------------------- -m4_define([lt_decl_varnames_tagged], -[m4_assert([$# <= 2])dnl -_$0(m4_quote(m4_default([$1], [[, ]])), - m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), - m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) -m4_define([_lt_decl_varnames_tagged], -[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) - - -# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) -# ------------------------------------------------ -m4_define([lt_decl_all_varnames], -[_$0(m4_quote(m4_default([$1], [[, ]])), - m4_if([$2], [], - m4_quote(lt_decl_varnames), - m4_quote(m4_shift($@))))[]dnl -]) -m4_define([_lt_decl_all_varnames], -[lt_join($@, lt_decl_varnames_tagged([$1], - lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl -]) - - -# _LT_CONFIG_STATUS_DECLARE([VARNAME]) -# ------------------------------------ -# Quote a variable value, and forward it to `config.status' so that its -# declaration there will have the same value as in `configure'. VARNAME -# must have a single quote delimited value for this to work. -m4_define([_LT_CONFIG_STATUS_DECLARE], -[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`']) - - -# _LT_CONFIG_STATUS_DECLARATIONS -# ------------------------------ -# We delimit libtool config variables with single quotes, so when -# we write them to config.status, we have to be sure to quote all -# embedded single quotes properly. In configure, this macro expands -# each variable declared with _LT_DECL (and _LT_TAGDECL) into: -# -# ='`$ECHO "X$" | $Xsed -e "$delay_single_quote_subst"`' -m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], -[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), - [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) - - -# _LT_LIBTOOL_TAGS -# ---------------- -# Output comment and list of tags supported by the script -m4_defun([_LT_LIBTOOL_TAGS], -[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl -available_tags="_LT_TAGS"dnl -]) - - -# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) -# ----------------------------------- -# Extract the dictionary values for VARNAME (optionally with TAG) and -# expand to a commented shell variable setting: -# -# # Some comment about what VAR is for. -# visible_name=$lt_internal_name -m4_define([_LT_LIBTOOL_DECLARE], -[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], - [description])))[]dnl -m4_pushdef([_libtool_name], - m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl -m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), - [0], [_libtool_name=[$]$1], - [1], [_libtool_name=$lt_[]$1], - [2], [_libtool_name=$lt_[]$1], - [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl -m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl -]) - - -# _LT_LIBTOOL_CONFIG_VARS -# ----------------------- -# Produce commented declarations of non-tagged libtool config variables -# suitable for insertion in the LIBTOOL CONFIG section of the `libtool' -# script. Tagged libtool config variables (even for the LIBTOOL CONFIG -# section) are produced by _LT_LIBTOOL_TAG_VARS. -m4_defun([_LT_LIBTOOL_CONFIG_VARS], -[m4_foreach([_lt_var], - m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), - [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) - - -# _LT_LIBTOOL_TAG_VARS(TAG) -# ------------------------- -m4_define([_LT_LIBTOOL_TAG_VARS], -[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), - [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) - - -# _LT_TAGVAR(VARNAME, [TAGNAME]) -# ------------------------------ -m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) - - -# _LT_CONFIG_COMMANDS -# ------------------- -# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of -# variables for single and double quote escaping we saved from calls -# to _LT_DECL, we can put quote escaped variables declarations -# into `config.status', and then the shell code to quote escape them in -# for loops in `config.status'. Finally, any additional code accumulated -# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. -m4_defun([_LT_CONFIG_COMMANDS], -[AC_PROVIDE_IFELSE([LT_OUTPUT], - dnl If the libtool generation code has been placed in $CONFIG_LT, - dnl instead of duplicating it all over again into config.status, - dnl then we will have config.status run $CONFIG_LT later, so it - dnl needs to know what name is stored there: - [AC_CONFIG_COMMANDS([libtool], - [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], - dnl If the libtool generation code is destined for config.status, - dnl expand the accumulated commands and init code now: - [AC_CONFIG_COMMANDS([libtool], - [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) -])#_LT_CONFIG_COMMANDS - - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], -[ - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -sed_quote_subst='$sed_quote_subst' -double_quote_subst='$double_quote_subst' -delay_variable_subst='$delay_variable_subst' -_LT_CONFIG_STATUS_DECLARATIONS -LTCC='$LTCC' -LTCFLAGS='$LTCFLAGS' -compiler='$compiler_DEFAULT' - -# Quote evaled strings. -for var in lt_decl_all_varnames([[ \ -]], lt_decl_quote_varnames); do - case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in - *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Double-quote double-evaled strings. -for var in lt_decl_all_varnames([[ \ -]], lt_decl_dquote_varnames); do - case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in - *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Fix-up fallback echo if it was mangled by the above quoting rules. -case \$lt_ECHO in -*'\\\[$]0 --fallback-echo"')dnl " - lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\` - ;; -esac - -_LT_OUTPUT_LIBTOOL_INIT -]) - - -# LT_OUTPUT -# --------- -# This macro allows early generation of the libtool script (before -# AC_OUTPUT is called), incase it is used in configure for compilation -# tests. -AC_DEFUN([LT_OUTPUT], -[: ${CONFIG_LT=./config.lt} -AC_MSG_NOTICE([creating $CONFIG_LT]) -cat >"$CONFIG_LT" <<_LTEOF -#! $SHELL -# Generated by $as_me. -# Run this file to recreate a libtool stub with the current configuration. - -lt_cl_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_LTEOF - -cat >>"$CONFIG_LT" <<\_LTEOF -AS_SHELL_SANITIZE -_AS_PREPARE - -exec AS_MESSAGE_FD>&1 -exec AS_MESSAGE_LOG_FD>>config.log -{ - echo - AS_BOX([Running $as_me.]) -} >&AS_MESSAGE_LOG_FD - -lt_cl_help="\ -\`$as_me' creates a local libtool stub from the current configuration, -for use in further configure time tests before the real libtool is -generated. - -Usage: $[0] [[OPTIONS]] - - -h, --help print this help, then exit - -V, --version print version number, then exit - -q, --quiet do not print progress messages - -d, --debug don't remove temporary files - -Report bugs to ." - -lt_cl_version="\ -m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl -m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) -configured by $[0], generated by m4_PACKAGE_STRING. - -Copyright (C) 2008 Free Software Foundation, Inc. -This config.lt script is free software; the Free Software Foundation -gives unlimited permision to copy, distribute and modify it." - -while test $[#] != 0 -do - case $[1] in - --version | --v* | -V ) - echo "$lt_cl_version"; exit 0 ;; - --help | --h* | -h ) - echo "$lt_cl_help"; exit 0 ;; - --debug | --d* | -d ) - debug=: ;; - --quiet | --q* | --silent | --s* | -q ) - lt_cl_silent=: ;; - - -*) AC_MSG_ERROR([unrecognized option: $[1] -Try \`$[0] --help' for more information.]) ;; - - *) AC_MSG_ERROR([unrecognized argument: $[1] -Try \`$[0] --help' for more information.]) ;; - esac - shift -done - -if $lt_cl_silent; then - exec AS_MESSAGE_FD>/dev/null -fi -_LTEOF - -cat >>"$CONFIG_LT" <<_LTEOF -_LT_OUTPUT_LIBTOOL_COMMANDS_INIT -_LTEOF - -cat >>"$CONFIG_LT" <<\_LTEOF -AC_MSG_NOTICE([creating $ofile]) -_LT_OUTPUT_LIBTOOL_COMMANDS -AS_EXIT(0) -_LTEOF -chmod +x "$CONFIG_LT" - -# configure is writing to config.log, but config.lt does its own redirection, -# appending to config.log, which fails on DOS, as config.log is still kept -# open by configure. Here we exec the FD to /dev/null, effectively closing -# config.log, so it can be properly (re)opened and appended to by config.lt. -if test "$no_create" != yes; then - lt_cl_success=: - test "$silent" = yes && - lt_config_lt_args="$lt_config_lt_args --quiet" - exec AS_MESSAGE_LOG_FD>/dev/null - $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false - exec AS_MESSAGE_LOG_FD>>config.log - $lt_cl_success || AS_EXIT(1) -fi -])# LT_OUTPUT - - -# _LT_CONFIG(TAG) -# --------------- -# If TAG is the built-in tag, create an initial libtool script with a -# default configuration from the untagged config vars. Otherwise add code -# to config.status for appending the configuration named by TAG from the -# matching tagged config vars. -m4_defun([_LT_CONFIG], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -_LT_CONFIG_SAVE_COMMANDS([ - m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl - m4_if(_LT_TAG, [C], [ - # See if we are running on zsh, and set the options which allow our - # commands through without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST - fi - - cfgfile="${ofile}T" - trap "$RM \"$cfgfile\"; exit 1" 1 2 15 - $RM "$cfgfile" - - cat <<_LT_EOF >> "$cfgfile" -#! $SHELL - -# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -_LT_COPYING -_LT_LIBTOOL_TAGS - -# ### BEGIN LIBTOOL CONFIG -_LT_LIBTOOL_CONFIG_VARS -_LT_LIBTOOL_TAG_VARS -# ### END LIBTOOL CONFIG - -_LT_EOF - - case $host_os in - aix3*) - cat <<\_LT_EOF >> "$cfgfile" -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES -fi -_LT_EOF - ;; - esac - - _LT_PROG_LTMAIN - - # We use sed instead of cat because bash on DJGPP gets confused if - # if finds mixed CR/LF and LF-only lines. Since sed operates in - # text mode, it properly converts lines to CR/LF. This bash problem - # is reportedly fixed, but why not run on old versions too? - sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - _LT_PROG_XSI_SHELLFNS - - sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - mv -f "$cfgfile" "$ofile" || - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" -], -[cat <<_LT_EOF >> "$ofile" - -dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded -dnl in a comment (ie after a #). -# ### BEGIN LIBTOOL TAG CONFIG: $1 -_LT_LIBTOOL_TAG_VARS(_LT_TAG) -# ### END LIBTOOL TAG CONFIG: $1 -_LT_EOF -])dnl /m4_if -], -[m4_if([$1], [], [ - PACKAGE='$PACKAGE' - VERSION='$VERSION' - TIMESTAMP='$TIMESTAMP' - RM='$RM' - ofile='$ofile'], []) -])dnl /_LT_CONFIG_SAVE_COMMANDS -])# _LT_CONFIG - - -# LT_SUPPORTED_TAG(TAG) -# --------------------- -# Trace this macro to discover what tags are supported by the libtool -# --tag option, using: -# autoconf --trace 'LT_SUPPORTED_TAG:$1' -AC_DEFUN([LT_SUPPORTED_TAG], []) - - -# C support is built-in for now -m4_define([_LT_LANG_C_enabled], []) -m4_define([_LT_TAGS], []) - - -# LT_LANG(LANG) -# ------------- -# Enable libtool support for the given language if not already enabled. -AC_DEFUN([LT_LANG], -[AC_BEFORE([$0], [LT_OUTPUT])dnl -m4_case([$1], - [C], [_LT_LANG(C)], - [C++], [_LT_LANG(CXX)], - [Java], [_LT_LANG(GCJ)], - [Fortran 77], [_LT_LANG(F77)], - [Fortran], [_LT_LANG(FC)], - [Windows Resource], [_LT_LANG(RC)], - [m4_ifdef([_LT_LANG_]$1[_CONFIG], - [_LT_LANG($1)], - [m4_fatal([$0: unsupported language: "$1"])])])dnl -])# LT_LANG - - -# _LT_LANG(LANGNAME) -# ------------------ -m4_defun([_LT_LANG], -[m4_ifdef([_LT_LANG_]$1[_enabled], [], - [LT_SUPPORTED_TAG([$1])dnl - m4_append([_LT_TAGS], [$1 ])dnl - m4_define([_LT_LANG_]$1[_enabled], [])dnl - _LT_LANG_$1_CONFIG($1)])dnl -])# _LT_LANG - - -# _LT_LANG_DEFAULT_CONFIG -# ----------------------- -m4_defun([_LT_LANG_DEFAULT_CONFIG], -[AC_PROVIDE_IFELSE([AC_PROG_CXX], - [LT_LANG(CXX)], - [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) - -AC_PROVIDE_IFELSE([AC_PROG_F77], - [LT_LANG(F77)], - [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) - -AC_PROVIDE_IFELSE([AC_PROG_FC], - [LT_LANG(FC)], - [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) - -dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal -dnl pulling things in needlessly. -AC_PROVIDE_IFELSE([AC_PROG_GCJ], - [LT_LANG(GCJ)], - [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], - [LT_LANG(GCJ)], - [AC_PROVIDE_IFELSE([LT_PROG_GCJ], - [LT_LANG(GCJ)], - [m4_ifdef([AC_PROG_GCJ], - [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) - m4_ifdef([A][M_PROG_GCJ], - [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) - m4_ifdef([LT_PROG_GCJ], - [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) - -AC_PROVIDE_IFELSE([LT_PROG_RC], - [LT_LANG(RC)], - [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) -])# _LT_LANG_DEFAULT_CONFIG - -# Obsolete macros: -AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) -AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) -AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) -AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_CXX], []) -dnl AC_DEFUN([AC_LIBTOOL_F77], []) -dnl AC_DEFUN([AC_LIBTOOL_FC], []) -dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) - - -# _LT_TAG_COMPILER -# ---------------- -m4_defun([_LT_TAG_COMPILER], -[AC_REQUIRE([AC_PROG_CC])dnl - -_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl -_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl -_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl -_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC -])# _LT_TAG_COMPILER - - -# _LT_COMPILER_BOILERPLATE -# ------------------------ -# Check for compiler boilerplate output or warnings with -# the simple compiler test code. -m4_defun([_LT_COMPILER_BOILERPLATE], -[m4_require([_LT_DECL_SED])dnl -ac_outfile=conftest.$ac_objext -echo "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$RM conftest* -])# _LT_COMPILER_BOILERPLATE - - -# _LT_LINKER_BOILERPLATE -# ---------------------- -# Check for linker boilerplate output or warnings with -# the simple link test code. -m4_defun([_LT_LINKER_BOILERPLATE], -[m4_require([_LT_DECL_SED])dnl -ac_outfile=conftest.$ac_objext -echo "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$RM -r conftest* -])# _LT_LINKER_BOILERPLATE - -# _LT_REQUIRED_DARWIN_CHECKS -# ------------------------- -m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ - case $host_os in - rhapsody* | darwin*) - AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) - AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) - AC_CHECK_TOOL([LIPO], [lipo], [:]) - AC_CHECK_TOOL([OTOOL], [otool], [:]) - AC_CHECK_TOOL([OTOOL64], [otool64], [:]) - _LT_DECL([], [DSYMUTIL], [1], - [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) - _LT_DECL([], [NMEDIT], [1], - [Tool to change global to local symbols on Mac OS X]) - _LT_DECL([], [LIPO], [1], - [Tool to manipulate fat objects and archives on Mac OS X]) - _LT_DECL([], [OTOOL], [1], - [ldd/readelf like tool for Mach-O binaries on Mac OS X]) - _LT_DECL([], [OTOOL64], [1], - [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) - - AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], - [lt_cv_apple_cc_single_mod=no - if test -z "${LT_MULTI_MODULE}"; then - # By default we will add the -single_module flag. You can override - # by either setting the environment variable LT_MULTI_MODULE - # non-empty at configure time, or by adding -multi_module to the - # link flags. - rm -rf libconftest.dylib* - echo "int foo(void){return 1;}" > conftest.c - echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ --dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD - $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ - -dynamiclib -Wl,-single_module conftest.c 2>conftest.err - _lt_result=$? - if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then - lt_cv_apple_cc_single_mod=yes - else - cat conftest.err >&AS_MESSAGE_LOG_FD - fi - rm -rf libconftest.dylib* - rm -f conftest.* - fi]) - AC_CACHE_CHECK([for -exported_symbols_list linker flag], - [lt_cv_ld_exported_symbols_list], - [lt_cv_ld_exported_symbols_list=no - save_LDFLAGS=$LDFLAGS - echo "_main" > conftest.sym - LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], - [lt_cv_ld_exported_symbols_list=yes], - [lt_cv_ld_exported_symbols_list=no]) - LDFLAGS="$save_LDFLAGS" - ]) - case $host_os in - rhapsody* | darwin1.[[012]]) - _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; - darwin1.*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - darwin*) # darwin 5.x on - # if running on 10.5 or later, the deployment target defaults - # to the OS version, if on x86, and 10.4, the deployment - # target defaults to 10.4. Don't you love it? - case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - 10.[[012]]*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - 10.*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - esac - ;; - esac - if test "$lt_cv_apple_cc_single_mod" = "yes"; then - _lt_dar_single_mod='$single_module' - fi - if test "$lt_cv_ld_exported_symbols_list" = "yes"; then - _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' - else - _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - if test "$DSYMUTIL" != ":"; then - _lt_dsymutil='~$DSYMUTIL $lib || :' - else - _lt_dsymutil= - fi - ;; - esac -]) - - -# _LT_DARWIN_LINKER_FEATURES -# -------------------------- -# Checks for linker and compiler features on darwin -m4_defun([_LT_DARWIN_LINKER_FEATURES], -[ - m4_require([_LT_REQUIRED_DARWIN_CHECKS]) - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_automatic, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_TAGVAR(whole_archive_flag_spec, $1)='' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" - case $cc_basename in - ifort*) _lt_dar_can_shared=yes ;; - *) _lt_dar_can_shared=$GCC ;; - esac - if test "$_lt_dar_can_shared" = "yes"; then - output_verbose_link_cmd=echo - _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" - m4_if([$1], [CXX], -[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then - _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" - fi -],[]) - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi -]) - -# _LT_SYS_MODULE_PATH_AIX -# ----------------------- -# Links a minimal program and checks the executable -# for the system default hardcoded library path. In most cases, -# this is /usr/lib:/lib, but when the MPI compilers are used -# the location of the communication and MPI libs are included too. -# If we don't find anything, use the default library path according -# to the aix ld manual. -m4_defun([_LT_SYS_MODULE_PATH_AIX], -[m4_require([_LT_DECL_SED])dnl -AC_LINK_IFELSE(AC_LANG_PROGRAM,[ -lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\(.*\)$/\1/ - p - } - }' -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then - aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -fi],[]) -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -])# _LT_SYS_MODULE_PATH_AIX - - -# _LT_SHELL_INIT(ARG) -# ------------------- -m4_define([_LT_SHELL_INIT], -[ifdef([AC_DIVERSION_NOTICE], - [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], - [AC_DIVERT_PUSH(NOTICE)]) -$1 -AC_DIVERT_POP -])# _LT_SHELL_INIT - - -# _LT_PROG_ECHO_BACKSLASH -# ----------------------- -# Add some code to the start of the generated configure script which -# will find an echo command which doesn't interpret backslashes. -m4_defun([_LT_PROG_ECHO_BACKSLASH], -[_LT_SHELL_INIT([ -# Check that we are running under the correct shell. -SHELL=${CONFIG_SHELL-/bin/sh} - -case X$lt_ECHO in -X*--fallback-echo) - # Remove one level of quotation (which was required for Make). - ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` - ;; -esac - -ECHO=${lt_ECHO-echo} -if test "X[$]1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X[$]1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then - # Yippee, $ECHO works! - : -else - # Restart under the correct shell. - exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} -fi - -if test "X[$]1" = X--fallback-echo; then - # used as fallback echo - shift - cat <<_LT_EOF -[$]* -_LT_EOF - exit 0 -fi - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -if test -z "$lt_ECHO"; then - if test "X${echo_test_string+set}" != Xset; then - # find a string as large as possible, as long as the shell can cope with it - for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do - # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... - if { echo_test_string=`eval $cmd`; } 2>/dev/null && - { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null - then - break - fi - done - fi - - if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - : - else - # The Solaris, AIX, and Digital Unix default echo programs unquote - # backslashes. This makes it impossible to quote backslashes using - # echo "$something" | sed 's/\\/\\\\/g' - # - # So, first we look for a working echo in the user's PATH. - - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for dir in $PATH /usr/ucb; do - IFS="$lt_save_ifs" - if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && - test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - ECHO="$dir/echo" - break - fi - done - IFS="$lt_save_ifs" - - if test "X$ECHO" = Xecho; then - # We didn't find a better echo, so look for alternatives. - if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # This shell has a builtin print -r that does the trick. - ECHO='print -r' - elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && - test "X$CONFIG_SHELL" != X/bin/ksh; then - # If we have ksh, try running configure again with it. - ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} - export ORIGINAL_CONFIG_SHELL - CONFIG_SHELL=/bin/ksh - export CONFIG_SHELL - exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} - else - # Try using printf. - ECHO='printf %s\n' - if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # Cool, printf works - : - elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL - export CONFIG_SHELL - SHELL="$CONFIG_SHELL" - export SHELL - ECHO="$CONFIG_SHELL [$]0 --fallback-echo" - elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - ECHO="$CONFIG_SHELL [$]0 --fallback-echo" - else - # maybe with a smaller string... - prev=: - - for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do - if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null - then - break - fi - prev="$cmd" - done - - if test "$prev" != 'sed 50q "[$]0"'; then - echo_test_string=`eval $prev` - export echo_test_string - exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} - else - # Oops. We lost completely, so just stick with echo. - ECHO=echo - fi - fi - fi - fi - fi -fi - -# Copy echo and quote the copy suitably for passing to libtool from -# the Makefile, instead of quoting the original, which is used later. -lt_ECHO=$ECHO -if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then - lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" -fi - -AC_SUBST(lt_ECHO) -]) -_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) -_LT_DECL([], [ECHO], [1], - [An echo program that does not interpret backslashes]) -])# _LT_PROG_ECHO_BACKSLASH - - -# _LT_ENABLE_LOCK -# --------------- -m4_defun([_LT_ENABLE_LOCK], -[AC_ARG_ENABLE([libtool-lock], - [AS_HELP_STRING([--disable-libtool-lock], - [avoid locking (might break parallel builds)])]) -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -ia64-*-hpux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.$ac_objext` in - *ELF-32*) - HPUX_IA64_MODE="32" - ;; - *ELF-64*) - HPUX_IA64_MODE="64" - ;; - esac - fi - rm -rf conftest* - ;; -*-*-irix6*) - # Find out which ABI we are using. - echo '[#]line __oline__ "configure"' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - if test "$lt_cv_prog_gnu_ld" = yes; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -melf32bsmip" - ;; - *N32*) - LD="${LD-ld} -melf32bmipn32" - ;; - *64-bit*) - LD="${LD-ld} -melf64bmip" - ;; - esac - else - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - fi - rm -rf conftest* - ;; - -x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ -s390*-*linux*|s390*-*tpf*|sparc*-*linux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *32-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_i386_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_i386" - ;; - ppc64-*linux*|powerpc64-*linux*) - LD="${LD-ld} -m elf32ppclinux" - ;; - s390x-*linux*) - LD="${LD-ld} -m elf_s390" - ;; - sparc64-*linux*) - LD="${LD-ld} -m elf32_sparc" - ;; - esac - ;; - *64-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_x86_64_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - powerpc64le-*linux*) - LD="${LD-ld} -m elf64lppc" - ;; - powerpc64-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*|s390*-*tpf*) - LD="${LD-ld} -m elf64_s390" - ;; - sparc*-*linux*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, - [AC_LANG_PUSH(C) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) - AC_LANG_POP]) - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; -sparc*-*solaris*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *64-bit*) - case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; - *) - if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then - LD="${LD-ld} -64" - fi - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; -esac - -need_locks="$enable_libtool_lock" -])# _LT_ENABLE_LOCK - - -# _LT_CMD_OLD_ARCHIVE -# ------------------- -m4_defun([_LT_CMD_OLD_ARCHIVE], -[AC_CHECK_TOOL(AR, ar, false) -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru -_LT_DECL([], [AR], [1], [The archiver]) -_LT_DECL([], [AR_FLAGS], [1]) - -AC_CHECK_TOOL(STRIP, strip, :) -test -z "$STRIP" && STRIP=: -_LT_DECL([], [STRIP], [1], [A symbol stripping program]) - -AC_CHECK_TOOL(RANLIB, ranlib, :) -test -z "$RANLIB" && RANLIB=: -_LT_DECL([], [RANLIB], [1], - [Commands used to install an old-style archive]) - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" -fi -_LT_DECL([], [old_postinstall_cmds], [2]) -_LT_DECL([], [old_postuninstall_cmds], [2]) -_LT_TAGDECL([], [old_archive_cmds], [2], - [Commands used to build an old-style archive]) -])# _LT_CMD_OLD_ARCHIVE - - -# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------------------- -# Check whether the given compiler option works -AC_DEFUN([_LT_COMPILER_OPTION], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_SED])dnl -AC_CACHE_CHECK([$1], [$2], - [$2=no - m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$3" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - fi - $RM conftest* -]) - -if test x"[$]$2" = xyes; then - m4_if([$5], , :, [$5]) -else - m4_if([$6], , :, [$6]) -fi -])# _LT_COMPILER_OPTION - -# Old name: -AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) - - -# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------- -# Check whether the given linker option works -AC_DEFUN([_LT_LINKER_OPTION], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_SED])dnl -AC_CACHE_CHECK([$1], [$2], - [$2=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $3" - echo "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&AS_MESSAGE_LOG_FD - $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - else - $2=yes - fi - fi - $RM -r conftest* - LDFLAGS="$save_LDFLAGS" -]) - -if test x"[$]$2" = xyes; then - m4_if([$4], , :, [$4]) -else - m4_if([$5], , :, [$5]) -fi -])# _LT_LINKER_OPTION - -# Old name: -AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) - - -# LT_CMD_MAX_LEN -#--------------- -AC_DEFUN([LT_CMD_MAX_LEN], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -# find the maximum length of command line arguments -AC_MSG_CHECKING([the maximum length of command line arguments]) -AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl - i=0 - teststring="ABCD" - - case $build_os in - msdosdjgpp*) - # On DJGPP, this test can blow up pretty badly due to problems in libc - # (any single argument exceeding 2000 bytes causes a buffer overrun - # during glob expansion). Even if it were fixed, the result of this - # check would be larger than it should be. - lt_cv_sys_max_cmd_len=12288; # 12K is about right - ;; - - gnu*) - # Under GNU Hurd, this test is not required because there is - # no limit to the length of command line arguments. - # Libtool will interpret -1 as no limit whatsoever - lt_cv_sys_max_cmd_len=-1; - ;; - - cygwin* | mingw* | cegcc*) - # On Win9x/ME, this test blows up -- it succeeds, but takes - # about 5 minutes as the teststring grows exponentially. - # Worse, since 9x/ME are not pre-emptively multitasking, - # you end up with a "frozen" computer, even though with patience - # the test eventually succeeds (with a max line length of 256k). - # Instead, let's just punt: use the minimum linelength reported by - # all of the supported platforms: 8192 (on NT/2K/XP). - lt_cv_sys_max_cmd_len=8192; - ;; - - beos*) - # On BeOS, this test takes a really really long time. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - amigaos*) - # On AmigaOS with pdksh, this test takes hours, literally. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) - # This has been around since 386BSD, at least. Likely further. - if test -x /sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` - elif test -x /usr/sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` - else - lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs - fi - # And add a safety zone - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - ;; - - interix*) - # We know the value 262144 and hardcode it with a safety zone (like BSD) - lt_cv_sys_max_cmd_len=196608 - ;; - - osf*) - # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure - # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not - # nice to cause kernel panics so lets avoid the loop below. - # First set a reasonable default. - lt_cv_sys_max_cmd_len=16384 - # - if test -x /sbin/sysconfig; then - case `/sbin/sysconfig -q proc exec_disable_arg_limit` in - *1*) lt_cv_sys_max_cmd_len=-1 ;; - esac - fi - ;; - sco3.2v5*) - lt_cv_sys_max_cmd_len=102400 - ;; - sysv5* | sco5v6* | sysv4.2uw2*) - kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` - if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` - else - lt_cv_sys_max_cmd_len=32768 - fi - ;; - *) - lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len"; then - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - else - # Make teststring a little bigger before we do anything with it. - # a 1K string should be a reasonable start. - for i in 1 2 3 4 5 6 7 8 ; do - teststring=$teststring$teststring - done - SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} - # If test is not a shell built-in, we'll probably end up computing a - # maximum length that is only half of the actual maximum length, but - # we can't tell. - while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ - = "XX$teststring$teststring"; } >/dev/null 2>&1 && - test $i != 17 # 1/2 MB should be enough - do - i=`expr $i + 1` - teststring=$teststring$teststring - done - # Only check the string length outside the loop. - lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` - teststring= - # Add a significant safety factor because C++ compilers can tack on - # massive amounts of additional arguments before passing them to the - # linker. It appears as though 1/2 is a usable value. - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` - fi - ;; - esac -]) -if test -n $lt_cv_sys_max_cmd_len ; then - AC_MSG_RESULT($lt_cv_sys_max_cmd_len) -else - AC_MSG_RESULT(none) -fi -max_cmd_len=$lt_cv_sys_max_cmd_len -_LT_DECL([], [max_cmd_len], [0], - [What is the maximum length of a command?]) -])# LT_CMD_MAX_LEN - -# Old name: -AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) - - -# _LT_HEADER_DLFCN -# ---------------- -m4_defun([_LT_HEADER_DLFCN], -[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl -])# _LT_HEADER_DLFCN - - -# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, -# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) -# ---------------------------------------------------------------- -m4_defun([_LT_TRY_DLOPEN_SELF], -[m4_require([_LT_HEADER_DLFCN])dnl -if test "$cross_compiling" = yes; then : - [$4] -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF -[#line __oline__ "configure" -#include "confdefs.h" - -#if HAVE_DLFCN_H -#include -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -void fnord() { int i=42;} -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - /* dlclose (self); */ - } - else - puts (dlerror ()); - - return status; -}] -_LT_EOF - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) $1 ;; - x$lt_dlneed_uscore) $2 ;; - x$lt_dlunknown|x*) $3 ;; - esac - else : - # compilation failed - $3 - fi -fi -rm -fr conftest* -])# _LT_TRY_DLOPEN_SELF - - -# LT_SYS_DLOPEN_SELF -# ------------------ -AC_DEFUN([LT_SYS_DLOPEN_SELF], -[m4_require([_LT_HEADER_DLFCN])dnl -if test "x$enable_dlopen" != xyes; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen="load_add_on" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - mingw* | pw32* | cegcc*) - lt_cv_dlopen="LoadLibrary" - lt_cv_dlopen_libs= - ;; - - cygwin*) - lt_cv_dlopen="dlopen" - lt_cv_dlopen_libs= - ;; - - darwin*) - # if libdl is installed we need to link against it - AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ]) - ;; - - *) - AC_CHECK_FUNC([shl_load], - [lt_cv_dlopen="shl_load"], - [AC_CHECK_LIB([dld], [shl_load], - [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], - [AC_CHECK_FUNC([dlopen], - [lt_cv_dlopen="dlopen"], - [AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], - [AC_CHECK_LIB([svld], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], - [AC_CHECK_LIB([dld], [dld_link], - [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) - ]) - ]) - ]) - ]) - ]) - ;; - esac - - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else - enable_dlopen=no - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS="$LDFLAGS" - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - AC_CACHE_CHECK([whether a program can dlopen itself], - lt_cv_dlopen_self, [dnl - _LT_TRY_DLOPEN_SELF( - lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, - lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) - ]) - - if test "x$lt_cv_dlopen_self" = xyes; then - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" - AC_CACHE_CHECK([whether a statically linked program can dlopen itself], - lt_cv_dlopen_self_static, [dnl - _LT_TRY_DLOPEN_SELF( - lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, - lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) - ]) - fi - - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi -_LT_DECL([dlopen_support], [enable_dlopen], [0], - [Whether dlopen is supported]) -_LT_DECL([dlopen_self], [enable_dlopen_self], [0], - [Whether dlopen of programs is supported]) -_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], - [Whether dlopen of statically linked programs is supported]) -])# LT_SYS_DLOPEN_SELF - -# Old name: -AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) - - -# _LT_COMPILER_C_O([TAGNAME]) -# --------------------------- -# Check to see if options -c and -o are simultaneously supported by compiler. -# This macro does not hard code the compiler like AC_PROG_CC_C_O. -m4_defun([_LT_COMPILER_C_O], -[m4_require([_LT_DECL_SED])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_TAG_COMPILER])dnl -AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], - [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], - [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - fi - fi - chmod u+w . 2>&AS_MESSAGE_LOG_FD - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* -]) -_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], - [Does compiler simultaneously support -c and -o options?]) -])# _LT_COMPILER_C_O - - -# _LT_COMPILER_FILE_LOCKS([TAGNAME]) -# ---------------------------------- -# Check to see if we can do hard links to lock some files if needed -m4_defun([_LT_COMPILER_FILE_LOCKS], -[m4_require([_LT_ENABLE_LOCK])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -_LT_COMPILER_C_O([$1]) - -hard_links="nottested" -if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - AC_MSG_CHECKING([if we can lock with hard links]) - hard_links=yes - $RM conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - AC_MSG_RESULT([$hard_links]) - if test "$hard_links" = no; then - AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) - need_locks=warn - fi -else - need_locks=no -fi -_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) -])# _LT_COMPILER_FILE_LOCKS - - -# _LT_CHECK_OBJDIR -# ---------------- -m4_defun([_LT_CHECK_OBJDIR], -[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], -[rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - lt_cv_objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - lt_cv_objdir=_libs -fi -rmdir .libs 2>/dev/null]) -objdir=$lt_cv_objdir -_LT_DECL([], [objdir], [0], - [The name of the directory that contains temporary libtool files])dnl -m4_pattern_allow([LT_OBJDIR])dnl -AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", - [Define to the sub-directory in which libtool stores uninstalled libraries.]) -])# _LT_CHECK_OBJDIR - - -# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) -# -------------------------------------- -# Check hardcoding attributes. -m4_defun([_LT_LINKER_HARDCODE_LIBPATH], -[AC_MSG_CHECKING([how to hardcode library paths into programs]) -_LT_TAGVAR(hardcode_action, $1)= -if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || - test -n "$_LT_TAGVAR(runpath_var, $1)" || - test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then - - # We can hardcode non-existent directories. - if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && - test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then - # Linking always hardcodes the temporary library directory. - _LT_TAGVAR(hardcode_action, $1)=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - _LT_TAGVAR(hardcode_action, $1)=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - _LT_TAGVAR(hardcode_action, $1)=unsupported -fi -AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) - -if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || - test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi -_LT_TAGDECL([], [hardcode_action], [0], - [How to hardcode a shared library path into an executable]) -])# _LT_LINKER_HARDCODE_LIBPATH - - -# _LT_CMD_STRIPLIB -# ---------------- -m4_defun([_LT_CMD_STRIPLIB], -[m4_require([_LT_DECL_EGREP]) -striplib= -old_striplib= -AC_MSG_CHECKING([whether stripping libraries is possible]) -if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - AC_MSG_RESULT([yes]) -else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP" ; then - striplib="$STRIP -x" - old_striplib="$STRIP -S" - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - fi - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac -fi -_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) -_LT_DECL([], [striplib], [1]) -])# _LT_CMD_STRIPLIB - - -# _LT_SYS_DYNAMIC_LINKER([TAG]) -# ----------------------------- -# PORTME Fill in your ld.so characteristics -m4_defun([_LT_SYS_DYNAMIC_LINKER], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_OBJDUMP])dnl -m4_require([_LT_DECL_SED])dnl -AC_MSG_CHECKING([dynamic linker characteristics]) -m4_if([$1], - [], [ -if test "$GCC" = yes; then - case $host_os in - darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; - *) lt_awk_arg="/^libraries:/" ;; - esac - lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` - else - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - # Ok, now we have the path, separated by spaces, we can step through it - # and add multilib dir if necessary. - lt_tmp_lt_search_path_spec= - lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` - for lt_sys_path in $lt_search_path_spec; do - if test -d "$lt_sys_path/$lt_multi_os_dir"; then - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" - else - test -d "$lt_sys_path" && \ - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" - fi - done - lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' -BEGIN {RS=" "; FS="/|\n";} { - lt_foo=""; - lt_count=0; - for (lt_i = NF; lt_i > 0; lt_i--) { - if ($lt_i != "" && $lt_i != ".") { - if ($lt_i == "..") { - lt_count++; - } else { - if (lt_count == 0) { - lt_foo="/" $lt_i lt_foo; - } else { - lt_count--; - } - } - } - } - if (lt_foo != "") { lt_freq[[lt_foo]]++; } - if (lt_freq[[lt_foo]] == 1) { print lt_foo; } -}'` - sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi]) -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix[[4-9]]*) - version_type=linux - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[[01]] | aix4.[[01]].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - case $host_cpu in - powerpc) - # Since July 2007 AmigaOS4 officially supports .so libraries. - # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - ;; - m68k) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - esac - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[[45]]*) - version_type=linux - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32* | cegcc*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname~ - if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then - eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; - fi' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - #soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - soname_spec='`echo ${libname} | sed -e 's/^lib//'`${shared_ext}' - sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" - ;; - mingw* | cegcc*) - # MinGW DLLs use traditional 'lib' prefix - #soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - soname_spec='`echo ${libname} | $SED -e 's/^lib//'`${shared_ext}' - sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then - # It is most probably a Windows format PATH printed by - # mingw gcc, but we are running on Cygwin. Gcc prints its search - # path with ; separators, and with drive letters. We can handle the - # drive letters (cygwin fileutils understands them), so leave them, - # especially as we might pass files found there to a mingw objdump, - # which wouldn't understand a cygwinified path. Ahh. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - ;; - esac - ;; - - *) - library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' - ;; - esac - dynamic_linker='Win32 ld.exe' - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' -m4_if([$1], [],[ - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd1*) - dynamic_linker=no - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[[123]]*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[[01]]* | freebsdelf3.[[01]]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ - freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - *) # from 4.6 on, and DragonFly - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' - ;; - -interix[[3-9]]*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be Linux ELF. -linux* | k*bsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - # Some binutils ld are patched to set DT_RUNPATH - save_LDFLAGS=$LDFLAGS - save_libdir=$libdir - eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ - LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], - [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], - [shlibpath_overrides_runpath=yes])]) - LDFLAGS=$save_LDFLAGS - libdir=$save_libdir - - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -*nto* | *qnx*) - version_type=qnx - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='ldqnx.so' - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[[89]] | openbsd2.[[89]].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -rdos*) - dynamic_linker=no - ;; - -solaris*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -tpf*) - # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -uts4*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -AC_MSG_RESULT([$dynamic_linker]) -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then - sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" -fi -if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then - sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" -fi - -_LT_DECL([], [variables_saved_for_relink], [1], - [Variables whose values should be saved in libtool wrapper scripts and - restored at link time]) -_LT_DECL([], [need_lib_prefix], [0], - [Do we need the "lib" prefix for modules?]) -_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) -_LT_DECL([], [version_type], [0], [Library versioning type]) -_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) -_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) -_LT_DECL([], [shlibpath_overrides_runpath], [0], - [Is shlibpath searched before the hard-coded library search path?]) -_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) -_LT_DECL([], [library_names_spec], [1], - [[List of archive names. First name is the real one, the rest are links. - The last name is the one that the linker finds with -lNAME]]) -_LT_DECL([], [soname_spec], [1], - [[The coded name of the library, if different from the real name]]) -_LT_DECL([], [postinstall_cmds], [2], - [Command to use after installation of a shared archive]) -_LT_DECL([], [postuninstall_cmds], [2], - [Command to use after uninstallation of a shared archive]) -_LT_DECL([], [finish_cmds], [2], - [Commands used to finish a libtool library installation in a directory]) -_LT_DECL([], [finish_eval], [1], - [[As "finish_cmds", except a single script fragment to be evaled but - not shown]]) -_LT_DECL([], [hardcode_into_libs], [0], - [Whether we should hardcode library paths into libraries]) -_LT_DECL([], [sys_lib_search_path_spec], [2], - [Compile-time system search path for libraries]) -_LT_DECL([], [sys_lib_dlsearch_path_spec], [2], - [Run-time system search path for libraries]) -])# _LT_SYS_DYNAMIC_LINKER - - -# _LT_PATH_TOOL_PREFIX(TOOL) -# -------------------------- -# find a file program which can recognize shared library -AC_DEFUN([_LT_PATH_TOOL_PREFIX], -[m4_require([_LT_DECL_EGREP])dnl -AC_MSG_CHECKING([for $1]) -AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, -[case $MAGIC_CMD in -[[\\/*] | ?:[\\/]*]) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -dnl $ac_dummy forces splitting on constant user-supplied paths. -dnl POSIX.2 word splitting is done only on the output of word expansions, -dnl not every word. This closes a longstanding sh security hole. - ac_dummy="m4_if([$2], , $PATH, [$2])" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$1; then - lt_cv_path_MAGIC_CMD="$ac_dir/$1" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <<_LT_EOF 1>&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -_LT_EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac]) -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - AC_MSG_RESULT($MAGIC_CMD) -else - AC_MSG_RESULT(no) -fi -_LT_DECL([], [MAGIC_CMD], [0], - [Used to examine libraries when file_magic_cmd begins with "file"])dnl -])# _LT_PATH_TOOL_PREFIX - -# Old name: -AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) - - -# _LT_PATH_MAGIC -# -------------- -# find a file program which can recognize a shared library -m4_defun([_LT_PATH_MAGIC], -[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) -if test -z "$lt_cv_path_MAGIC_CMD"; then - if test -n "$ac_tool_prefix"; then - _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) - else - MAGIC_CMD=: - fi -fi -])# _LT_PATH_MAGIC - - -# LT_PATH_LD -# ---------- -# find the pathname to the GNU or non-GNU linker -AC_DEFUN([LT_PATH_LD], -[AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_DECL_EGREP])dnl - -AC_ARG_WITH([gnu-ld], - [AS_HELP_STRING([--with-gnu-ld], - [assume the C compiler uses GNU ld @<:@default=no@:>@])], - [test "$withval" = no || with_gnu_ld=yes], - [with_gnu_ld=no])dnl - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - AC_MSG_CHECKING([for ld used by $CC]) - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [[\\/]]* | ?:[[\\/]]*) - re_direlt='/[[^/]][[^/]]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` - while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do - ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - AC_MSG_CHECKING([for GNU ld]) -else - AC_MSG_CHECKING([for non-GNU ld]) -fi -AC_CACHE_VAL(lt_cv_path_LD, -[if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_file_magic_cmd='func_win32_libid' - else - lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' - lt_cv_file_magic_cmd='$OBJDUMP -f' - fi - lt_cv_deplibs_check_method=pass_all - ;; - -cegcc) - # use the weaker test based on 'objdump'. See mingw*. - lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - ;; - -darwin* | rhapsody*) - lt_cv_deplibs_check_method=pass_all - ;; - -freebsd* | dragonfly*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - case $host_cpu in - i*86 ) - # Not sure whether the presence of OpenBSD here was a mistake. - # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - ;; - esac - else - lt_cv_deplibs_check_method=pass_all - fi - ;; - -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file - case $host_cpu in - ia64*) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' - lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so - ;; - hppa*64*) - [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] - lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl - ;; - *) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' - lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - esac - ;; - -interix[[3-9]]*) - # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' - ;; - -irix5* | irix6* | nonstopux*) - case $LD in - *-32|*"-32 ") libmagic=32-bit;; - *-n32|*"-n32 ") libmagic=N32;; - *-64|*"-64 ") libmagic=64-bit;; - *) libmagic=never-match;; - esac - lt_cv_deplibs_check_method=pass_all - ;; - -# This must be Linux ELF. -linux* | k*bsd*-gnu) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' - fi - ;; - -newos6*) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libnls.so - ;; - -*nto* | *qnx*) - lt_cv_deplibs_check_method=pass_all - ;; - -openbsd*) - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - fi - ;; - -osf3* | osf4* | osf5*) - lt_cv_deplibs_check_method=pass_all - ;; - -rdos*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.3*) - case $host_vendor in - motorola) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` - ;; - ncr) - lt_cv_deplibs_check_method=pass_all - ;; - sequent) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' - ;; - sni) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" - lt_cv_file_magic_test_file=/lib/libc.so - ;; - siemens) - lt_cv_deplibs_check_method=pass_all - ;; - pc) - lt_cv_deplibs_check_method=pass_all - ;; - esac - ;; - -tpf*) - lt_cv_deplibs_check_method=pass_all - ;; -esac -]) -file_magic_cmd=$lt_cv_file_magic_cmd -deplibs_check_method=$lt_cv_deplibs_check_method -test -z "$deplibs_check_method" && deplibs_check_method=unknown - -_LT_DECL([], [deplibs_check_method], [1], - [Method to check whether dependent libraries are shared objects]) -_LT_DECL([], [file_magic_cmd], [1], - [Command to use when deplibs_check_method == "file_magic"]) -])# _LT_CHECK_MAGIC_METHOD - - -# LT_PATH_NM -# ---------- -# find the pathname to a BSD- or MS-compatible name lister -AC_DEFUN([LT_PATH_NM], -[AC_REQUIRE([AC_PROG_CC])dnl -AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, -[if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM="$NM" -else - lt_nm_to_check="${ac_tool_prefix}nm" - if test -n "$ac_tool_prefix" && test "$build" = "$host"; then - lt_nm_to_check="$lt_nm_to_check nm" - fi - for lt_tmp_nm in $lt_nm_to_check; do - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/$lt_tmp_nm" - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in - */dev/null* | *'Invalid file or object type'*) - lt_cv_path_NM="$tmp_nm -B" - break - ;; - *) - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in - */dev/null*) - lt_cv_path_NM="$tmp_nm -p" - break - ;; - *) - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but - continue # so that we can try to find one that supports BSD flags - ;; - esac - ;; - esac - fi - done - IFS="$lt_save_ifs" - done - : ${lt_cv_path_NM=no} -fi]) -if test "$lt_cv_path_NM" != "no"; then - NM="$lt_cv_path_NM" -else - # Didn't find any BSD compatible name lister, look for dumpbin. - AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :) - AC_SUBST([DUMPBIN]) - if test "$DUMPBIN" != ":"; then - NM="$DUMPBIN" - fi -fi -test -z "$NM" && NM=nm -AC_SUBST([NM]) -_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl - -AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], - [lt_cv_nm_interface="BSD nm" - echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$ac_compile" 2>conftest.err) - cat conftest.err >&AS_MESSAGE_LOG_FD - (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) - (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) - cat conftest.err >&AS_MESSAGE_LOG_FD - (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD) - cat conftest.out >&AS_MESSAGE_LOG_FD - if $GREP 'External.*some_variable' conftest.out > /dev/null; then - lt_cv_nm_interface="MS dumpbin" - fi - rm -f conftest*]) -])# LT_PATH_NM - -# Old names: -AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) -AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_PROG_NM], []) -dnl AC_DEFUN([AC_PROG_NM], []) - - -# LT_LIB_M -# -------- -# check for math library -AC_DEFUN([LT_LIB_M], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -LIBM= -case $host in -*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) - # These system don't have libm, or don't need it - ;; -*-ncr-sysv4.3*) - AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") - AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") - ;; -*) - AC_CHECK_LIB(m, cos, LIBM="-lm") - ;; -esac -AC_SUBST([LIBM]) -])# LT_LIB_M - -# Old name: -AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_CHECK_LIBM], []) - - -# _LT_COMPILER_NO_RTTI([TAGNAME]) -# ------------------------------- -m4_defun([_LT_COMPILER_NO_RTTI], -[m4_require([_LT_TAG_COMPILER])dnl - -_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= - -if test "$GCC" = yes; then - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' - - _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], - lt_cv_prog_compiler_rtti_exceptions, - [-fno-rtti -fno-exceptions], [], - [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) -fi -_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], - [Compiler flag to turn off builtin functions]) -])# _LT_COMPILER_NO_RTTI - - -# _LT_CMD_GLOBAL_SYMBOLS -# ---------------------- -m4_defun([_LT_CMD_GLOBAL_SYMBOLS], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([LT_PATH_NM])dnl -AC_REQUIRE([LT_PATH_LD])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_TAG_COMPILER])dnl - -# Check for command to grab the raw symbol name followed by C symbol from nm. -AC_MSG_CHECKING([command to parse $NM output from $compiler object]) -AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], -[ -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[[BCDEGRST]]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[[BCDT]]' - ;; -cygwin* | mingw* | pw32* | cegcc*) - symcode='[[ABCDGISTW]]' - ;; -hpux*) - if test "$host_cpu" = ia64; then - symcode='[[ABCDEGRST]]' - fi - ;; -irix* | nonstopux*) - symcode='[[BCDEGRST]]' - ;; -osf*) - symcode='[[BCDEGQRST]]' - ;; -solaris*) - symcode='[[BDRT]]' - ;; -sco3.2v5*) - symcode='[[DT]]' - ;; -sysv4.2uw2*) - symcode='[[DT]]' - ;; -sysv5* | sco5v6* | unixware* | OpenUNIX*) - symcode='[[ABDT]]' - ;; -sysv4) - symcode='[[DFNSTU]]' - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -case `$NM -V 2>&1` in -*GNU* | *'with BFD'*) - symcode='[[ABCDGIRSTW]]' ;; -esac - -# Transform an extracted symbol line into a proper C declaration. -# Some systems (esp. on ia64) link data and code symbols differently, -# so use this general approach. -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - -# Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" - -# Handle CRLF in mingw tool chain -opt_cr= -case $build_os in -mingw*) - opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp - ;; -esac - -# Try without a prefix underscore, then with it. -for ac_symprfx in "" "_"; do - - # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. - symxfrm="\\1 $ac_symprfx\\2 \\2" - - # Write the raw and C identifiers. - if test "$lt_cv_nm_interface" = "MS dumpbin"; then - # Fake it for dumpbin and say T for any non-static function - # and D for any global variable. - # Also find C++ and __fastcall symbols from MSVC++, - # which start with @ or ?. - lt_cv_sys_global_symbol_pipe="$AWK ['"\ -" {last_section=section; section=\$ 3};"\ -" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ -" \$ 0!~/External *\|/{next};"\ -" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ -" {if(hide[section]) next};"\ -" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ -" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ -" s[1]~/^[@?]/{print s[1], s[1]; next};"\ -" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ -" ' prfx=^$ac_symprfx]" - else - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" - fi - - # Check to see that the pipe works correctly. - pipe_works=no - - rm -f conftest* - cat > conftest.$ac_ext <<_LT_EOF -#ifdef __cplusplus -extern "C" { -#endif -char nm_test_var; -void nm_test_func(void); -void nm_test_func(void){} -#ifdef __cplusplus -} -#endif -int main(){nm_test_var='a';nm_test_func();return(0);} -_LT_EOF - - if AC_TRY_EVAL(ac_compile); then - # Now try to grab the symbols. - nlist=conftest.nm - if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - else - rm -f "$nlist"T - fi - - # Make sure that we snagged all the symbols we need. - if $GREP ' nm_test_var$' "$nlist" >/dev/null; then - if $GREP ' nm_test_func$' "$nlist" >/dev/null; then - cat <<_LT_EOF > conftest.$ac_ext -#ifdef __cplusplus -extern "C" { -#endif - -_LT_EOF - # Now generate the symbol file. - eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' - - cat <<_LT_EOF >> conftest.$ac_ext - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - void *address; -} -lt__PROGRAM__LTX_preloaded_symbols[[]] = -{ - { "@PROGRAM@", (void *) 0 }, -_LT_EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext - cat <<\_LT_EOF >> conftest.$ac_ext - {0, (void *) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt__PROGRAM__LTX_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif -_LT_EOF - # Now try linking the two files. - mv conftest.$ac_objext conftstm.$ac_objext - lt_save_LIBS="$LIBS" - lt_save_CFLAGS="$CFLAGS" - LIBS="conftstm.$ac_objext" - CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then - pipe_works=yes - fi - LIBS="$lt_save_LIBS" - CFLAGS="$lt_save_CFLAGS" - else - echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD - fi - else - echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD - cat conftest.$ac_ext >&5 - fi - rm -rf conftest* conftst* - - # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then - break - else - lt_cv_sys_global_symbol_pipe= - fi -done -]) -if test -z "$lt_cv_sys_global_symbol_pipe"; then - lt_cv_sys_global_symbol_to_cdecl= -fi -if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then - AC_MSG_RESULT(failed) -else - AC_MSG_RESULT(ok) -fi - -_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], - [Take the output of nm and produce a listing of raw symbols and C names]) -_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], - [Transform the output of nm in a proper C declaration]) -_LT_DECL([global_symbol_to_c_name_address], - [lt_cv_sys_global_symbol_to_c_name_address], [1], - [Transform the output of nm in a C name address pair]) -_LT_DECL([global_symbol_to_c_name_address_lib_prefix], - [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], - [Transform the output of nm in a C name address pair when lib prefix is needed]) -]) # _LT_CMD_GLOBAL_SYMBOLS - - -# _LT_COMPILER_PIC([TAGNAME]) -# --------------------------- -m4_defun([_LT_COMPILER_PIC], -[m4_require([_LT_TAG_COMPILER])dnl -_LT_TAGVAR(lt_prog_compiler_wl, $1)= -_LT_TAGVAR(lt_prog_compiler_pic, $1)= -_LT_TAGVAR(lt_prog_compiler_static, $1)= - -AC_MSG_CHECKING([for $compiler option to produce PIC]) -m4_if([$1], [CXX], [ - # C++ specific cases for pic, static, wl, etc. - if test "$GXX" = yes; then - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - *djgpp*) - # DJGPP does not support shared libraries at all - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - interix[[3-9]]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - else - case $host_os in - aix[[4-9]]*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - chorus*) - case $cc_basename in - cxch68*) - # Green Hills C++ Compiler - # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" - ;; - esac - ;; - dgux*) - case $cc_basename in - ec++*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - ghcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - freebsd* | dragonfly*) - # FreeBSD uses GNU C++ - ;; - hpux9* | hpux10* | hpux11*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - if test "$host_cpu" != ia64; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - fi - ;; - aCC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - ;; - *) - ;; - esac - ;; - interix*) - # This is c89, which is MS Visual C++ (no shared libs) - # Anyone wants to do a port? - ;; - irix5* | irix6* | nonstopux*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - # CC pic flag -KPIC is the default. - ;; - *) - ;; - esac - ;; - linux* | k*bsd*-gnu) - case $cc_basename in - KCC*) - # KAI C++ Compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - ecpc* ) - # old Intel C++ for x86_64 which still supported -KPIC. - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - icpc* ) - # Intel C++, used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - cxx*) - # Compaq C++ - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - xlc* | xlC*) - # IBM XL 8.0 on PPC - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - esac - ;; - esac - ;; - lynxos*) - ;; - m88k*) - ;; - mvs*) - case $cc_basename in - cxx*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' - ;; - *) - ;; - esac - ;; - netbsd*) - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - ;; - RCC*) - # Rational C++ 2.4.1 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - cxx*) - # Digital/Compaq C++ - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - *) - ;; - esac - ;; - psos*) - ;; - solaris*) - case $cc_basename in - CC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - ;; - *) - ;; - esac - ;; - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - lcc*) - # Lucid - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - esac - ;; - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - *) - ;; - esac - ;; - vxworks*) - ;; - *) - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -], -[ - if test "$GCC" = yes; then - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - - interix[[3-9]]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - enable_shared=no - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - - hpux9* | hpux10* | hpux11*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC (with -KPIC) is the default. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - linux* | k*bsd*-gnu) - case $cc_basename in - # old Intel for x86_64 which still supported -KPIC. - ecc*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - # icc used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - icc* | ifort*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - # Lahey Fortran 8.1. - lf95*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' - _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' - ;; - pgcc* | pgf77* | pgf90* | pgf95*) - # Portland Group compilers (*not* the Pentium gcc compiler, - # which looks to be a dead project) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - ccc*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All Alpha code is PIC. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - xl*) - # IBM XL C 8.0/Fortran 10.1 on PPC - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C 5.9 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - ;; - *Sun\ F*) - # Sun Fortran 8.3 passes all unrecognized flags to the linker - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='' - ;; - esac - ;; - esac - ;; - - newsos6) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - - osf3* | osf4* | osf5*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All OSF/1 code is PIC. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - rdos*) - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - solaris*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - case $cc_basename in - f77* | f90* | f95*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; - *) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; - esac - ;; - - sunos4*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - unicos*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - - uts4*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - *) - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -]) -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" - ;; -esac -AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) -_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], - [How to pass a linker flag through the compiler]) - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then - _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], - [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], - [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], - [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in - "" | " "*) ;; - *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; - esac], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) -fi -_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], - [Additional compiler flags for building library objects]) - -# -# Check to make sure the static flag actually works. -# -wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" -_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], - _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), - $lt_tmp_static_flag, - [], - [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) -_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], - [Compiler flag to prevent dynamic linking]) -])# _LT_COMPILER_PIC - - -# _LT_LINKER_SHLIBS([TAGNAME]) -# ---------------------------- -# See if the linker supports building shared libraries. -m4_defun([_LT_LINKER_SHLIBS], -[AC_REQUIRE([LT_PATH_LD])dnl -AC_REQUIRE([LT_PATH_NM])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl -m4_require([_LT_TAG_COMPILER])dnl -AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) -m4_if([$1], [CXX], [ - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - case $host_os in - aix[[4-9]]*) - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - ;; - pw32*) - _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" - ;; - cygwin* | mingw* | cegcc*) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' - ;; - *) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - ;; - esac - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] -], [ - runpath_var= - _LT_TAGVAR(allow_undefined_flag, $1)= - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(archive_cmds, $1)= - _LT_TAGVAR(archive_expsym_cmds, $1)= - _LT_TAGVAR(compiler_needs_object, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - _LT_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(hardcode_automatic, $1)=no - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= - _LT_TAGVAR(hardcode_libdir_separator, $1)= - _LT_TAGVAR(hardcode_minus_L, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_TAGVAR(inherit_rpath, $1)=no - _LT_TAGVAR(link_all_deplibs, $1)=unknown - _LT_TAGVAR(module_cmds, $1)= - _LT_TAGVAR(module_expsym_cmds, $1)= - _LT_TAGVAR(old_archive_from_new_cmds, $1)= - _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= - _LT_TAGVAR(thread_safe_flag_spec, $1)= - _LT_TAGVAR(whole_archive_flag_spec, $1)= - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - _LT_TAGVAR(include_expsyms, $1)= - # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] - # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out - # platforms (ab)use it in PIC code, but their linkers get confused if - # the symbol is explicitly referenced. Since portable code cannot - # rely on this symbol name, it's probably fine to never include it in - # preloaded symbol tables. - # Exclude shared library initialization/finalization symbols. -dnl Note also adjust exclude_expsyms for C++ above. - extract_expsyms_cmds= - - case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; - esac - - _LT_TAGVAR(ld_shlibs, $1)=yes - if test "$with_gnu_ld" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - runpath_var=LD_RUN_PATH - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - supports_anon_versioning=no - case `$LD -v 2>&1` in - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 - *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... - *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... - *\ 2.11.*) ;; # other 2.11 versions - *) supports_anon_versioning=yes ;; - esac - - # See if GNU ld supports shared libraries. - case $host_os in - aix[[3-9]]*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: the GNU linker, at least up to release 2.9.1, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to modify your PATH -*** so that a non-GNU linker is found, and then restart. - -_LT_EOF - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='' - ;; - m68k) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - interix[[3-9]]*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - - gnu* | linux* | tpf* | k*bsd*-gnu) - tmp_diet=no - if test "$host_os" = linux-dietlibc; then - case $cc_basename in - diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) - esac - fi - if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ - && test "$tmp_diet" = no - then - tmp_addflag= - tmp_sharedflag='-shared' - case $cc_basename,$host_cpu in - pgcc*) # Portland Group C compiler - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag -Mnomain' ;; - ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 - tmp_addflag=' -i_dynamic' ;; - efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 - tmp_addflag=' -i_dynamic -nofor_main' ;; - ifc* | ifort*) # Intel Fortran compiler - tmp_addflag=' -nofor_main' ;; - lf95*) # Lahey Fortran 8.1 - _LT_TAGVAR(whole_archive_flag_spec, $1)= - tmp_sharedflag='--shared' ;; - xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) - tmp_sharedflag='-qmkshrobj' - tmp_addflag= ;; - esac - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) # Sun C 5.9 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - tmp_sharedflag='-G' ;; - *Sun\ F*) # Sun Fortran 8.3 - tmp_sharedflag='-G' ;; - esac - _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - - case $cc_basename in - xlf*) - # IBM XL Fortran 10.1 on PPC cannot create shared libs itself - _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' - _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' - fi - ;; - esac - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris*) - if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not -*** reliably create shared libraries on SCO systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.16.91.0.3 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - ;; - *) - # For security reasons, it is highly recommended that you always - # use absolute paths for naming shared libraries, and exclude the - # DT_RUNPATH tag from executables and libraries. But doing so - # requires that you compile everything twice, which is a pain. - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - sunos4*) - _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - - if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then - runpath_var= - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=yes - _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - _LT_TAGVAR(hardcode_direct, $1)=unsupported - fi - ;; - - aix[[4-9]]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_TAGVAR(archive_cmds, $1)='' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' - - if test "$GCC" = yes; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - _LT_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - _LT_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared libraries. - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='' - ;; - m68k) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - ;; - - bsdi[[45]]*) - _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - # FIXME: Should let the user specify the lib program. - _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' - _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - ;; - - darwin* | rhapsody*) - _LT_DARWIN_LINKER_FEATURES($1) - ;; - - dgux*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - freebsd1*) - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - hpux9*) - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_direct, $1)=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - - hpux10*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - fi - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - fi - ;; - - hpux11*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - else - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - fi - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - # Try to use the -exported_symbol ld option, if it does not - # work, assume that -exports_file does not work either and - # implicitly export all symbols. - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" - AC_LINK_IFELSE(int foo(void) {}, - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - ) - LDFLAGS="$save_LDFLAGS" - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(inherit_rpath, $1)=yes - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - newsos6) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *nto* | *qnx*) - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - else - case $host_os in - openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - ;; - esac - fi - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - os2*) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - else - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ - $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' - - # Both c and cxx compiler support -rpath directly - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - solaris*) - _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' - if test "$GCC" = yes; then - wlarc='${wl}' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - else - case `$CC -V 2>&1` in - *"Compilers 5.0"*) - wlarc='' - _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' - ;; - *) - wlarc='${wl}' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - ;; - esac - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. GCC discards it without `$wl', - # but is careful enough not to reorder. - # Supported since Solaris 2.6 (maybe 2.5.1?) - if test "$GCC" = yes; then - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' - fi - ;; - esac - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4) - case $host_vendor in - sni) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' - _LT_TAGVAR(hardcode_direct, $1)=no - ;; - motorola) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4.3*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - _LT_TAGVAR(ld_shlibs, $1)=yes - fi - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - uts4*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - - if test x$host_vendor = xsni; then - case $host in - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' - ;; - esac - fi - fi -]) -AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) -test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no - -_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld - -_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl -_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl -_LT_DECL([], [extract_expsyms_cmds], [2], - [The commands to extract the exported symbol list from a shared archive]) - -# -# Do we need to explicitly link libc? -# -case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in -x|xyes) - # Assume -lc should be added - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $_LT_TAGVAR(archive_cmds, $1) in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - AC_MSG_CHECKING([whether -lc should be explicitly linked in]) - $RM conftest* - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - if AC_TRY_EVAL(ac_compile) 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) - pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) - _LT_TAGVAR(allow_undefined_flag, $1)= - if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) - then - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - else - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - fi - _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $RM conftest* - AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)]) - ;; - esac - fi - ;; -esac - -_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], - [Whether or not to add -lc for building shared libraries]) -_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], - [enable_shared_with_static_runtimes], [0], - [Whether or not to disallow shared libs when runtime libs are static]) -_LT_TAGDECL([], [export_dynamic_flag_spec], [1], - [Compiler flag to allow reflexive dlopens]) -_LT_TAGDECL([], [whole_archive_flag_spec], [1], - [Compiler flag to generate shared objects directly from archives]) -_LT_TAGDECL([], [compiler_needs_object], [1], - [Whether the compiler copes with passing no objects directly]) -_LT_TAGDECL([], [old_archive_from_new_cmds], [2], - [Create an old-style archive from a shared archive]) -_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], - [Create a temporary old-style archive to link instead of a shared archive]) -_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) -_LT_TAGDECL([], [archive_expsym_cmds], [2]) -_LT_TAGDECL([], [module_cmds], [2], - [Commands used to build a loadable module if different from building - a shared archive.]) -_LT_TAGDECL([], [module_expsym_cmds], [2]) -_LT_TAGDECL([], [with_gnu_ld], [1], - [Whether we are building with GNU ld or not]) -_LT_TAGDECL([], [allow_undefined_flag], [1], - [Flag that allows shared libraries with undefined symbols to be built]) -_LT_TAGDECL([], [no_undefined_flag], [1], - [Flag that enforces no undefined symbols]) -_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], - [Flag to hardcode $libdir into a binary during linking. - This must work even if $libdir does not exist]) -_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], - [[If ld is used when linking, flag to hardcode $libdir into a binary - during linking. This must work even if $libdir does not exist]]) -_LT_TAGDECL([], [hardcode_libdir_separator], [1], - [Whether we need a single "-rpath" flag with a separated argument]) -_LT_TAGDECL([], [hardcode_direct], [0], - [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes - DIR into the resulting binary]) -_LT_TAGDECL([], [hardcode_direct_absolute], [0], - [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes - DIR into the resulting binary and the resulting library dependency is - "absolute", i.e impossible to change by setting ${shlibpath_var} if the - library is relocated]) -_LT_TAGDECL([], [hardcode_minus_L], [0], - [Set to "yes" if using the -LDIR flag during linking hardcodes DIR - into the resulting binary]) -_LT_TAGDECL([], [hardcode_shlibpath_var], [0], - [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR - into the resulting binary]) -_LT_TAGDECL([], [hardcode_automatic], [0], - [Set to "yes" if building a shared library automatically hardcodes DIR - into the library and all subsequent libraries and executables linked - against it]) -_LT_TAGDECL([], [inherit_rpath], [0], - [Set to yes if linker adds runtime paths of dependent libraries - to runtime path list]) -_LT_TAGDECL([], [link_all_deplibs], [0], - [Whether libtool must link a program against all its dependency libraries]) -_LT_TAGDECL([], [fix_srcfile_path], [1], - [Fix the shell variable $srcfile for the compiler]) -_LT_TAGDECL([], [always_export_symbols], [0], - [Set to "yes" if exported symbols are required]) -_LT_TAGDECL([], [export_symbols_cmds], [2], - [The commands to list exported symbols]) -_LT_TAGDECL([], [exclude_expsyms], [1], - [Symbols that should not be listed in the preloaded symbols]) -_LT_TAGDECL([], [include_expsyms], [1], - [Symbols that must always be exported]) -_LT_TAGDECL([], [prelink_cmds], [2], - [Commands necessary for linking programs (against libraries) with templates]) -_LT_TAGDECL([], [file_list_spec], [1], - [Specify filename containing input files]) -dnl FIXME: Not yet implemented -dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], -dnl [Compiler flag to generate thread safe objects]) -])# _LT_LINKER_SHLIBS - - -# _LT_LANG_C_CONFIG([TAG]) -# ------------------------ -# Ensure that the configuration variables for a C compiler are suitably -# defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to `libtool'. -m4_defun([_LT_LANG_C_CONFIG], -[m4_require([_LT_DECL_EGREP])dnl -lt_save_CC="$CC" -AC_LANG_PUSH(C) - -# Source file extension for C test sources. -ac_ext=c - -# Object file extension for compiled C test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}' - -_LT_TAG_COMPILER -# Save the default compiler, since it gets overwritten when the other -# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. -compiler_DEFAULT=$CC - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -## CAVEAT EMPTOR: -## There is no encapsulation within the following macros, do not change -## the running order or otherwise move them around unless you know exactly -## what you are doing... -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - LT_SYS_DLOPEN_SELF - _LT_CMD_STRIPLIB - - # Report which library types will actually be built - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_CONFIG($1) -fi -AC_LANG_POP -CC="$lt_save_CC" -])# _LT_LANG_C_CONFIG - - -# _LT_PROG_CXX -# ------------ -# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++ -# compiler, we have our own version here. -m4_defun([_LT_PROG_CXX], -[ -pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes]) -AC_PROG_CXX -if test -n "$CXX" && ( test "X$CXX" != "Xno" && - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || - (test "X$CXX" != "Xg++"))) ; then - AC_PROG_CXXCPP -else - _lt_caught_CXX_error=yes -fi -popdef([AC_MSG_ERROR]) -])# _LT_PROG_CXX - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([_LT_PROG_CXX], []) - - -# _LT_LANG_CXX_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for a C++ compiler are suitably -# defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to `libtool'. -m4_defun([_LT_LANG_CXX_CONFIG], -[AC_REQUIRE([_LT_PROG_CXX])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_EGREP])dnl - -AC_LANG_PUSH(C++) -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(compiler_needs_object, $1)=no -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for C++ test sources. -ac_ext=cpp - -# Object file extension for compiled C++ test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the CXX compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_caught_CXX_error" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="int some_variable = 0;" - - # Code to be used in simple link tests - lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC=$CC - lt_save_LD=$LD - lt_save_GCC=$GCC - GCC=$GXX - lt_save_with_gnu_ld=$with_gnu_ld - lt_save_path_LD=$lt_cv_path_LD - if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then - lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx - else - $as_unset lt_cv_prog_gnu_ld - fi - if test -n "${lt_cv_path_LDCXX+set}"; then - lt_cv_path_LD=$lt_cv_path_LDCXX - else - $as_unset lt_cv_path_LD - fi - test -z "${LDCXX+set}" || LD=$LDCXX - CC=${CXX-"c++"} - compiler=$CC - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - - if test -n "$compiler"; then - # We don't want -fno-exception when compiling C++ code, so set the - # no_builtin_flag separately - if test "$GXX" = yes; then - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' - else - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= - fi - - if test "$GXX" = yes; then - # Set up default GNU C++ configuration - - LT_PATH_LD - - # Check if GNU C++ uses GNU ld as the underlying linker, since the - # archiving commands below assume that GNU ld is being used. - if test "$with_gnu_ld" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - - # If archive_cmds runs LD, not CC, wlarc should be empty - # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to - # investigate it a little bit more. (MM) - wlarc='${wl}' - - # ancient GNU ld didn't support --whole-archive et. al. - if eval "`$CC -print-prog-name=ld` --help 2>&1" | - $GREP 'no-whole-archive' > /dev/null; then - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - with_gnu_ld=no - wlarc= - - # A generic and very simple default shared library creation - # command for GNU C++ for the case where it uses the native - # linker, instead of GNU ld. If possible, this setting should - # overridden to take advantage of the native linker features on - # the platform it is being used on. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - fi - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' - - else - GXX=no - with_gnu_ld=no - wlarc= - fi - - # PORTME: fill in a description of your system's C++ link characteristics - AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) - _LT_TAGVAR(ld_shlibs, $1)=yes - case $host_os in - aix3*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aix[[4-9]]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) - for ld_flag in $LDFLAGS; do - case $ld_flag in - *-brtl*) - aix_use_runtimelinking=yes - break - ;; - esac - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_TAGVAR(archive_cmds, $1)='' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' - - if test "$GXX" = yes; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - _LT_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)= - fi - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to - # export. - _LT_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an empty - # executable. - _LT_SYS_MODULE_PATH_AIX - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared - # libraries. - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - chorus*) - case $cc_basename in - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - darwin* | rhapsody*) - _LT_DARWIN_LINKER_FEATURES($1) - ;; - - dgux*) - case $cc_basename in - ec++*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - ghcx*) - # Green Hills C++ Compiler - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - freebsd[[12]]*) - # C++ shared libraries reported to be fairly broken before - # switch to ELF - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - freebsd-elf*) - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - ;; - - freebsd* | dragonfly*) - # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF - # conventions - _LT_TAGVAR(ld_shlibs, $1)=yes - ;; - - gnu*) - ;; - - hpux9*) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - ;; - *) - if test "$GXX" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - hpux10*|hpux11*) - if test $with_gnu_ld = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - ;; - *) - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - esac - fi - case $host_cpu in - hppa*64*|ia64*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - ;; - esac - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - ;; - *) - if test "$GXX" = yes; then - if test $with_gnu_ld = no; then - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - fi - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - interix[[3-9]]*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - irix5* | irix6*) - case $cc_basename in - CC*) - # SGI C++ - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - - # Archives containing C++ object files must be created using - # "CC -ar", where "CC" is the IRIX C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' - ;; - *) - if test "$GXX" = yes; then - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib' - fi - fi - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - esac - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(inherit_rpath, $1)=yes - ;; - - linux* | k*bsd*-gnu) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' - ;; - icpc* | ecpc* ) - # Intel C++ - with_gnu_ld=yes - # version 8.0 and above of icpc choke on multiply defined symbols - # if we add $predep_objects and $postdep_objects, however 7.1 and - # earlier do not add the objects themselves. - case `$CC -V 2>&1` in - *"Version 7."*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - *) # Version 8.0 or newer - tmp_idyn= - case $host_cpu in - ia64*) tmp_idyn=' -i_dynamic';; - esac - _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - esac - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - case `$CC -V` in - *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*) - _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ - compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"' - _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ - $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~ - $RANLIB $oldlib' - _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - ;; - *) # Version 6 will use weak symbols - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - ;; - cxx*) - # Compaq C++ - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' - - runpath_var=LD_RUN_PATH - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - ;; - xl*) - # IBM XL 8.0 on PPC, with GNU ld - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - - # Not sure whether something based on - # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 - # would be better. - output_verbose_link_cmd='echo' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' - ;; - esac - ;; - esac - ;; - - lynxos*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - m88k*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - mvs*) - case $cc_basename in - cxx*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' - wlarc= - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - fi - # Workaround some broken pre-1.5 toolchains - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' - ;; - - *nto* | *qnx*) - _LT_TAGVAR(ld_shlibs, $1)=yes - ;; - - openbsd2*) - # C++ shared libraries are fairly broken - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - fi - output_verbose_link_cmd=echo - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Archives containing C++ object files must be created using - # the KAI C++ compiler. - case $host in - osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; - *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; - esac - ;; - RCC*) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - cxx*) - case $host in - osf3*) - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - ;; - *) - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ - echo "-hidden">> $lib.exp~ - $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~ - $RM $lib.exp' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - case $host in - osf3*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' - - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - psos*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - lcc*) - # Lucid - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - solaris*) - case $cc_basename in - CC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_TAGVAR(archive_cmds_need_lc,$1)=yes - _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. - # Supported since Solaris 2.6 (maybe 2.5.1?) - _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' - ;; - esac - _LT_TAGVAR(link_all_deplibs, $1)=yes - - output_verbose_link_cmd='echo' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - - # The C++ compiler must be used to create the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' - ;; - *) - # GNU C++ compiler with Solaris linker - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' - if $CC --version | $GREP -v '^2\.7' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' - else - # g++ 2.7 appears to require `-G' NOT `-shared' on this - # platform. - _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' - fi - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - ;; - esac - fi - ;; - esac - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - vxworks*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - - AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) - test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no - - _LT_TAGVAR(GCC, $1)="$GXX" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_SYS_HIDDEN_LIBDEPS($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - CC=$lt_save_CC - LDCXX=$LD - LD=$lt_save_LD - GCC=$lt_save_GCC - with_gnu_ld=$lt_save_with_gnu_ld - lt_cv_path_LDCXX=$lt_cv_path_LD - lt_cv_path_LD=$lt_save_path_LD - lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld - lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld -fi # test "$_lt_caught_CXX_error" != yes - -AC_LANG_POP -])# _LT_LANG_CXX_CONFIG - - -# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) -# --------------------------------- -# Figure out "hidden" library dependencies from verbose -# compiler output when linking a shared library. -# Parse the compiler output and extract the necessary -# objects, libraries and library flags. -m4_defun([_LT_SYS_HIDDEN_LIBDEPS], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -# Dependencies to place before and after the object being linked: -_LT_TAGVAR(predep_objects, $1)= -_LT_TAGVAR(postdep_objects, $1)= -_LT_TAGVAR(predeps, $1)= -_LT_TAGVAR(postdeps, $1)= -_LT_TAGVAR(compiler_lib_search_path, $1)= - -dnl we can't use the lt_simple_compile_test_code here, -dnl because it contains code intended for an executable, -dnl not a library. It's possible we should let each -dnl tag define a new lt_????_link_test_code variable, -dnl but it's only used here... -m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF -int a; -void foo (void) { a = 0; } -_LT_EOF -], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF -class Foo -{ -public: - Foo (void) { a = 0; } -private: - int a; -}; -_LT_EOF -], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF - subroutine foo - implicit none - integer*4 a - a=0 - return - end -_LT_EOF -], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF - subroutine foo - implicit none - integer a - a=0 - return - end -_LT_EOF -], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF -public class foo { - private int a; - public void bar (void) { - a = 0; - } -}; -_LT_EOF -]) -dnl Parse the compiler output and extract the necessary -dnl objects, libraries and library flags. -if AC_TRY_EVAL(ac_compile); then - # Parse the compiler output and extract the necessary - # objects, libraries and library flags. - - # Sentinel used to keep track of whether or not we are before - # the conftest object file. - pre_test_object_deps_done=no - - for p in `eval "$output_verbose_link_cmd"`; do - case $p in - - -L* | -R* | -l*) - # Some compilers place space between "-{L,R}" and the path. - # Remove the space. - if test $p = "-L" || - test $p = "-R"; then - prev=$p - continue - else - prev= - fi - - if test "$pre_test_object_deps_done" = no; then - case $p in - -L* | -R*) - # Internal compiler library paths should come after those - # provided the user. The postdeps already come after the - # user supplied libs so there is no need to process them. - if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then - _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" - else - _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" - fi - ;; - # The "-l" case would never come before the object being - # linked, so don't bother handling this case. - esac - else - if test -z "$_LT_TAGVAR(postdeps, $1)"; then - _LT_TAGVAR(postdeps, $1)="${prev}${p}" - else - _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" - fi - fi - ;; - - *.$objext) - # This assumes that the test object file only shows up - # once in the compiler output. - if test "$p" = "conftest.$objext"; then - pre_test_object_deps_done=yes - continue - fi - - if test "$pre_test_object_deps_done" = no; then - if test -z "$_LT_TAGVAR(predep_objects, $1)"; then - _LT_TAGVAR(predep_objects, $1)="$p" - else - _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" - fi - else - if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then - _LT_TAGVAR(postdep_objects, $1)="$p" - else - _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" - fi - fi - ;; - - *) ;; # Ignore the rest. - - esac - done - - # Clean up. - rm -f a.out a.exe -else - echo "libtool.m4: error: problem compiling $1 test program" -fi - -$RM -f confest.$objext - -# PORTME: override above test on systems where it is broken -m4_if([$1], [CXX], -[case $host_os in -interix[[3-9]]*) - # Interix 3.5 installs completely hosed .la files for C++, so rather than - # hack all around it, let's just trust "g++" to DTRT. - _LT_TAGVAR(predep_objects,$1)= - _LT_TAGVAR(postdep_objects,$1)= - _LT_TAGVAR(postdeps,$1)= - ;; - -linux*) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - if test "$solaris_use_stlport4" != yes; then - _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' - fi - ;; - esac - ;; - -solaris*) - case $cc_basename in - CC*) - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - # Adding this requires a known-good setup of shared libraries for - # Sun compiler versions before 5.6, else PIC objects from an old - # archive will be linked into the output, leading to subtle bugs. - if test "$solaris_use_stlport4" != yes; then - _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' - fi - ;; - esac - ;; -esac -]) - -case " $_LT_TAGVAR(postdeps, $1) " in -*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; -esac - _LT_TAGVAR(compiler_lib_search_dirs, $1)= -if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then - _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` -fi -_LT_TAGDECL([], [compiler_lib_search_dirs], [1], - [The directories searched by this compiler when creating a shared library]) -_LT_TAGDECL([], [predep_objects], [1], - [Dependencies to place before and after the objects being linked to - create a shared library]) -_LT_TAGDECL([], [postdep_objects], [1]) -_LT_TAGDECL([], [predeps], [1]) -_LT_TAGDECL([], [postdeps], [1]) -_LT_TAGDECL([], [compiler_lib_search_path], [1], - [The library search path used internally by the compiler when linking - a shared library]) -])# _LT_SYS_HIDDEN_LIBDEPS - - -# _LT_PROG_F77 -# ------------ -# Since AC_PROG_F77 is broken, in that it returns the empty string -# if there is no fortran compiler, we have our own version here. -m4_defun([_LT_PROG_F77], -[ -pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes]) -AC_PROG_F77 -if test -z "$F77" || test "X$F77" = "Xno"; then - _lt_disable_F77=yes -fi -popdef([AC_MSG_ERROR]) -])# _LT_PROG_F77 - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([_LT_PROG_F77], []) - - -# _LT_LANG_F77_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for a Fortran 77 compiler are -# suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_F77_CONFIG], -[AC_REQUIRE([_LT_PROG_F77])dnl -AC_LANG_PUSH(Fortran 77) - -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for f77 test sources. -ac_ext=f - -# Object file extension for compiled f77 test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the F77 compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_disable_F77" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="\ - subroutine t - return - end -" - - # Code to be used in simple link tests - lt_simple_link_test_code="\ - program t - end -" - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC="$CC" - lt_save_GCC=$GCC - CC=${F77-"f77"} - compiler=$CC - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - GCC=$G77 - if test -n "$compiler"; then - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_TAGVAR(GCC, $1)="$G77" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - GCC=$lt_save_GCC - CC="$lt_save_CC" -fi # test "$_lt_disable_F77" != yes - -AC_LANG_POP -])# _LT_LANG_F77_CONFIG - - -# _LT_PROG_FC -# ----------- -# Since AC_PROG_FC is broken, in that it returns the empty string -# if there is no fortran compiler, we have our own version here. -m4_defun([_LT_PROG_FC], -[ -pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes]) -AC_PROG_FC -if test -z "$FC" || test "X$FC" = "Xno"; then - _lt_disable_FC=yes -fi -popdef([AC_MSG_ERROR]) -])# _LT_PROG_FC - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([_LT_PROG_FC], []) - - -# _LT_LANG_FC_CONFIG([TAG]) -# ------------------------- -# Ensure that the configuration variables for a Fortran compiler are -# suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_FC_CONFIG], -[AC_REQUIRE([_LT_PROG_FC])dnl -AC_LANG_PUSH(Fortran) - -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for fc test sources. -ac_ext=${ac_fc_srcext-f} - -# Object file extension for compiled fc test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the FC compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_disable_FC" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="\ - subroutine t - return - end -" - - # Code to be used in simple link tests - lt_simple_link_test_code="\ - program t - end -" - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC="$CC" - lt_save_GCC=$GCC - CC=${FC-"f95"} - compiler=$CC - GCC=$ac_cv_fc_compiler_gnu - - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - - if test -n "$compiler"; then - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_SYS_HIDDEN_LIBDEPS($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - GCC=$lt_save_GCC - CC="$lt_save_CC" -fi # test "$_lt_disable_FC" != yes - -AC_LANG_POP -])# _LT_LANG_FC_CONFIG - - -# _LT_LANG_GCJ_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for the GNU Java Compiler compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_GCJ_CONFIG], -[AC_REQUIRE([LT_PROG_GCJ])dnl -AC_LANG_SAVE - -# Source file extension for Java test sources. -ac_ext=java - -# Object file extension for compiled Java test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="class foo {}" - -# Code to be used in simple link tests -lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC="$CC" -lt_save_GCC=$GCC -GCC=yes -CC=${GCJ-"gcj"} -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_TAGVAR(LD, $1)="$LD" -_LT_CC_BASENAME([$compiler]) - -# GCJ did not exist at the time GCC didn't implicitly link libc in. -_LT_TAGVAR(archive_cmds_need_lc, $1)=no - -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds - -## CAVEAT EMPTOR: -## There is no encapsulation within the following macros, do not change -## the running order or otherwise move them around unless you know exactly -## what you are doing... -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) -fi - -AC_LANG_RESTORE - -GCC=$lt_save_GCC -CC="$lt_save_CC" -])# _LT_LANG_GCJ_CONFIG - - -# _LT_LANG_RC_CONFIG([TAG]) -# ------------------------- -# Ensure that the configuration variables for the Windows resource compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_RC_CONFIG], -[AC_REQUIRE([LT_PROG_RC])dnl -AC_LANG_SAVE - -# Source file extension for RC test sources. -ac_ext=rc - -# Object file extension for compiled RC test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' - -# Code to be used in simple link tests -lt_simple_link_test_code="$lt_simple_compile_test_code" - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC="$CC" -lt_save_GCC=$GCC -GCC= -CC=${RC-"windres"} -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_CC_BASENAME([$compiler]) -_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - -if test -n "$compiler"; then - : - _LT_CONFIG($1) -fi - -GCC=$lt_save_GCC -AC_LANG_RESTORE -CC="$lt_save_CC" -])# _LT_LANG_RC_CONFIG - - -# LT_PROG_GCJ -# ----------- -AC_DEFUN([LT_PROG_GCJ], -[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], - [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], - [AC_CHECK_TOOL(GCJ, gcj,) - test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" - AC_SUBST(GCJFLAGS)])])[]dnl -]) - -# Old name: -AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_GCJ], []) - - -# LT_PROG_RC -# ---------- -AC_DEFUN([LT_PROG_RC], -[AC_CHECK_TOOL(RC, windres,) -]) - -# Old name: -AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_RC], []) - - -# _LT_DECL_EGREP -# -------------- -# If we don't have a new enough Autoconf to choose the best grep -# available, choose the one first in the user's PATH. -m4_defun([_LT_DECL_EGREP], -[AC_REQUIRE([AC_PROG_EGREP])dnl -AC_REQUIRE([AC_PROG_FGREP])dnl -test -z "$GREP" && GREP=grep -_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) -_LT_DECL([], [EGREP], [1], [An ERE matcher]) -_LT_DECL([], [FGREP], [1], [A literal string matcher]) -dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too -AC_SUBST([GREP]) -]) - - -# _LT_DECL_OBJDUMP -# -------------- -# If we don't have a new enough Autoconf to choose the best objdump -# available, choose the one first in the user's PATH. -m4_defun([_LT_DECL_OBJDUMP], -[AC_CHECK_TOOL(OBJDUMP, objdump, false) -test -z "$OBJDUMP" && OBJDUMP=objdump -_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) -AC_SUBST([OBJDUMP]) -]) - - -# _LT_DECL_SED -# ------------ -# Check for a fully-functional sed program, that truncates -# as few characters as possible. Prefer GNU sed if found. -m4_defun([_LT_DECL_SED], -[AC_PROG_SED -test -z "$SED" && SED=sed -Xsed="$SED -e 1s/^X//" -_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) -_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], - [Sed that helps us avoid accidentally triggering echo(1) options like -n]) -])# _LT_DECL_SED - -m4_ifndef([AC_PROG_SED], [ -############################################################ -# NOTE: This macro has been submitted for inclusion into # -# GNU Autoconf as AC_PROG_SED. When it is available in # -# a released version of Autoconf we should remove this # -# macro and use it instead. # -############################################################ - -m4_defun([AC_PROG_SED], -[AC_MSG_CHECKING([for a sed that does not truncate output]) -AC_CACHE_VAL(lt_cv_path_SED, -[# Loop through the user's path and test for sed and gsed. -# Then use that list of sed's as ones to test for truncation. -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for lt_ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then - lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" - fi - done - done -done -IFS=$as_save_IFS -lt_ac_max=0 -lt_ac_count=0 -# Add /usr/xpg4/bin/sed as it is typically found on Solaris -# along with /bin/sed that truncates output. -for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do - test ! -f $lt_ac_sed && continue - cat /dev/null > conftest.in - lt_ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >conftest.in - # Check for GNU sed and select it if it is found. - if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then - lt_cv_path_SED=$lt_ac_sed - break - fi - while true; do - cat conftest.in conftest.in >conftest.tmp - mv conftest.tmp conftest.in - cp conftest.in conftest.nl - echo >>conftest.nl - $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break - cmp -s conftest.out conftest.nl || break - # 10000 chars as input seems more than enough - test $lt_ac_count -gt 10 && break - lt_ac_count=`expr $lt_ac_count + 1` - if test $lt_ac_count -gt $lt_ac_max; then - lt_ac_max=$lt_ac_count - lt_cv_path_SED=$lt_ac_sed - fi - done -done -]) -SED=$lt_cv_path_SED -AC_SUBST([SED]) -AC_MSG_RESULT([$SED]) -])#AC_PROG_SED -])#m4_ifndef - -# Old name: -AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_SED], []) - - -# _LT_CHECK_SHELL_FEATURES -# ------------------------ -# Find out whether the shell is Bourne or XSI compatible, -# or has some other useful features. -m4_defun([_LT_CHECK_SHELL_FEATURES], -[AC_MSG_CHECKING([whether the shell understands some XSI constructs]) -# Try some XSI features -xsi_shell=no -( _lt_dummy="a/b/c" - test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ - = c,a/b,, \ - && eval 'test $(( 1 + 1 )) -eq 2 \ - && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ - && xsi_shell=yes -AC_MSG_RESULT([$xsi_shell]) -_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) - -AC_MSG_CHECKING([whether the shell understands "+="]) -lt_shell_append=no -( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ - >/dev/null 2>&1 \ - && lt_shell_append=yes -AC_MSG_RESULT([$lt_shell_append]) -_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) - -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - lt_unset=unset -else - lt_unset=false -fi -_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl - -# test EBCDIC or ASCII -case `echo X|tr X '\101'` in - A) # ASCII based system - # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr - lt_SP2NL='tr \040 \012' - lt_NL2SP='tr \015\012 \040\040' - ;; - *) # EBCDIC based system - lt_SP2NL='tr \100 \n' - lt_NL2SP='tr \r\n \100\100' - ;; -esac -_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl -_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl -])# _LT_CHECK_SHELL_FEATURES - - -# _LT_PROG_XSI_SHELLFNS -# --------------------- -# Bourne and XSI compatible variants of some useful shell functions. -m4_defun([_LT_PROG_XSI_SHELLFNS], -[case $xsi_shell in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac -} - -# func_basename file -func_basename () -{ - func_basename_result="${1##*/}" -} - -# func_dirname_and_basename file append nondir_replacement -# perform func_basename and func_dirname in a single function -# call: -# dirname: Compute the dirname of FILE. If nonempty, -# add APPEND to the result, otherwise set result -# to NONDIR_REPLACEMENT. -# value returned in "$func_dirname_result" -# basename: Compute filename of FILE. -# value retuned in "$func_basename_result" -# Implementation must be kept synchronized with func_dirname -# and func_basename. For efficiency, we do not delegate to -# those functions but instead duplicate the functionality here. -func_dirname_and_basename () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac - func_basename_result="${1##*/}" -} - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -func_stripname () -{ - # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are - # positional parameters, so assign one to ordinary parameter first. - func_stripname_result=${3} - func_stripname_result=${func_stripname_result#"${1}"} - func_stripname_result=${func_stripname_result%"${2}"} -} - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=${1%%=*} - func_opt_split_arg=${1#*=} -} - -# func_lo2o object -func_lo2o () -{ - case ${1} in - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; - *) func_lo2o_result=${1} ;; - esac -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=${1%.*}.lo -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=$(( $[*] )) -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=${#1} -} - -_LT_EOF - ;; - *) # Bourne compatible functions. - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi -} - -# func_basename file -func_basename () -{ - func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` -} - -dnl func_dirname_and_basename -dnl A portable version of this function is already defined in general.m4sh -dnl so there is no need for it here. - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# func_strip_suffix prefix name -func_stripname () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "X${3}" \ - | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "X${3}" \ - | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; - esac -} - -# sed scripts: -my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q' -my_sed_long_arg='1s/^-[[^=]]*=//' - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` - func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` -} - -# func_lo2o object -func_lo2o () -{ - func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'` -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=`expr "$[@]"` -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len` -} - -_LT_EOF -esac - -case $lt_shell_append in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$[1]+=\$[2]" -} -_LT_EOF - ;; - *) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$[1]=\$$[1]\$[2]" -} - -_LT_EOF - ;; - esac -]) - -############################################################################## -# Helper functions for option handling. -*- Autoconf -*- -# -# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. -# Written by Gary V. Vaughan, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 6 ltoptions.m4 - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) - - -# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) -# ------------------------------------------ -m4_define([_LT_MANGLE_OPTION], -[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) - - -# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) -# --------------------------------------- -# Set option OPTION-NAME for macro MACRO-NAME, and if there is a -# matching handler defined, dispatch to it. Other OPTION-NAMEs are -# saved as a flag. -m4_define([_LT_SET_OPTION], -[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl -m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), - _LT_MANGLE_DEFUN([$1], [$2]), - [m4_warning([Unknown $1 option `$2'])])[]dnl -]) - - -# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) -# ------------------------------------------------------------ -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -m4_define([_LT_IF_OPTION], -[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) - - -# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) -# ------------------------------------------------------- -# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME -# are set. -m4_define([_LT_UNLESS_OPTIONS], -[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), - [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), - [m4_define([$0_found])])])[]dnl -m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 -])[]dnl -]) - - -# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) -# ---------------------------------------- -# OPTION-LIST is a space-separated list of Libtool options associated -# with MACRO-NAME. If any OPTION has a matching handler declared with -# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about -# the unknown option and exit. -m4_defun([_LT_SET_OPTIONS], -[# Set options -m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), - [_LT_SET_OPTION([$1], _LT_Option)]) - -m4_if([$1],[LT_INIT],[ - dnl - dnl Simply set some default values (i.e off) if boolean options were not - dnl specified: - _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no - ]) - _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no - ]) - dnl - dnl If no reference was made to various pairs of opposing options, then - dnl we run the default mode handler for the pair. For example, if neither - dnl `shared' nor `disable-shared' was passed, we enable building of shared - dnl archives by default: - _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) - _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) - _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) - _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], - [_LT_ENABLE_FAST_INSTALL]) - ]) -])# _LT_SET_OPTIONS - - -## --------------------------------- ## -## Macros to handle LT_INIT options. ## -## --------------------------------- ## - -# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) -# ----------------------------------------- -m4_define([_LT_MANGLE_DEFUN], -[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) - - -# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) -# ----------------------------------------------- -m4_define([LT_OPTION_DEFINE], -[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl -])# LT_OPTION_DEFINE - - -# dlopen -# ------ -LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes -]) - -AU_DEFUN([AC_LIBTOOL_DLOPEN], -[_LT_SET_OPTION([LT_INIT], [dlopen]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `dlopen' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) - - -# win32-dll -# --------- -# Declare package support for building win32 dll's. -LT_OPTION_DEFINE([LT_INIT], [win32-dll], -[enable_win32_dll=yes - -case $host in -*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*) - AC_CHECK_TOOL(AS, as, false) - AC_CHECK_TOOL(DLLTOOL, dlltool, false) - AC_CHECK_TOOL(OBJDUMP, objdump, false) - ;; -esac - -test -z "$AS" && AS=as -_LT_DECL([], [AS], [0], [Assembler program])dnl - -test -z "$DLLTOOL" && DLLTOOL=dlltool -_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl - -test -z "$OBJDUMP" && OBJDUMP=objdump -_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl -])# win32-dll - -AU_DEFUN([AC_LIBTOOL_WIN32_DLL], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -_LT_SET_OPTION([LT_INIT], [win32-dll]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `win32-dll' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) - - -# _LT_ENABLE_SHARED([DEFAULT]) -# ---------------------------- -# implement the --enable-shared flag, and supports the `shared' and -# `disable-shared' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -m4_define([_LT_ENABLE_SHARED], -[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([shared], - [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], - [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_shared=yes ;; - no) enable_shared=no ;; - *) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_shared=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) - - _LT_DECL([build_libtool_libs], [enable_shared], [0], - [Whether or not to build shared libraries]) -])# _LT_ENABLE_SHARED - -LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) - -# Old names: -AC_DEFUN([AC_ENABLE_SHARED], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) -]) - -AC_DEFUN([AC_DISABLE_SHARED], -[_LT_SET_OPTION([LT_INIT], [disable-shared]) -]) - -AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) -AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_ENABLE_SHARED], []) -dnl AC_DEFUN([AM_DISABLE_SHARED], []) - - - -# _LT_ENABLE_STATIC([DEFAULT]) -# ---------------------------- -# implement the --enable-static flag, and support the `static' and -# `disable-static' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -m4_define([_LT_ENABLE_STATIC], -[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([static], - [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], - [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_static=yes ;; - no) enable_static=no ;; - *) - enable_static=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_static=]_LT_ENABLE_STATIC_DEFAULT) - - _LT_DECL([build_old_libs], [enable_static], [0], - [Whether or not to build static libraries]) -])# _LT_ENABLE_STATIC - -LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) - -# Old names: -AC_DEFUN([AC_ENABLE_STATIC], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) -]) - -AC_DEFUN([AC_DISABLE_STATIC], -[_LT_SET_OPTION([LT_INIT], [disable-static]) -]) - -AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) -AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_ENABLE_STATIC], []) -dnl AC_DEFUN([AM_DISABLE_STATIC], []) - - - -# _LT_ENABLE_FAST_INSTALL([DEFAULT]) -# ---------------------------------- -# implement the --enable-fast-install flag, and support the `fast-install' -# and `disable-fast-install' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -m4_define([_LT_ENABLE_FAST_INSTALL], -[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([fast-install], - [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], - [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_fast_install=yes ;; - no) enable_fast_install=no ;; - *) - enable_fast_install=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_fast_install=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) - -_LT_DECL([fast_install], [enable_fast_install], [0], - [Whether or not to optimize for fast installation])dnl -])# _LT_ENABLE_FAST_INSTALL - -LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) - -# Old names: -AU_DEFUN([AC_ENABLE_FAST_INSTALL], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you put -the `fast-install' option into LT_INIT's first parameter.]) -]) - -AU_DEFUN([AC_DISABLE_FAST_INSTALL], -[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you put -the `disable-fast-install' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) -dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) - - -# _LT_WITH_PIC([MODE]) -# -------------------- -# implement the --with-pic flag, and support the `pic-only' and `no-pic' -# LT_INIT options. -# MODE is either `yes' or `no'. If omitted, it defaults to `both'. -m4_define([_LT_WITH_PIC], -[AC_ARG_WITH([pic], - [AS_HELP_STRING([--with-pic], - [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], - [pic_mode="$withval"], - [pic_mode=default]) - -test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) - -_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl -])# _LT_WITH_PIC - -LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) -LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) - -# Old name: -AU_DEFUN([AC_LIBTOOL_PICMODE], -[_LT_SET_OPTION([LT_INIT], [pic-only]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `pic-only' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) - -## ----------------- ## -## LTDL_INIT Options ## -## ----------------- ## - -m4_define([_LTDL_MODE], []) -LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], - [m4_define([_LTDL_MODE], [nonrecursive])]) -LT_OPTION_DEFINE([LTDL_INIT], [recursive], - [m4_define([_LTDL_MODE], [recursive])]) -LT_OPTION_DEFINE([LTDL_INIT], [subproject], - [m4_define([_LTDL_MODE], [subproject])]) - -m4_define([_LTDL_TYPE], []) -LT_OPTION_DEFINE([LTDL_INIT], [installable], - [m4_define([_LTDL_TYPE], [installable])]) -LT_OPTION_DEFINE([LTDL_INIT], [convenience], - [m4_define([_LTDL_TYPE], [convenience])]) - -############################################################################## -# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- -# -# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. -# Written by Gary V. Vaughan, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 6 ltsugar.m4 - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) - - -# lt_join(SEP, ARG1, [ARG2...]) -# ----------------------------- -# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their -# associated separator. -# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier -# versions in m4sugar had bugs. -m4_define([lt_join], -[m4_if([$#], [1], [], - [$#], [2], [[$2]], - [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) -m4_define([_lt_join], -[m4_if([$#$2], [2], [], - [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) - - -# lt_car(LIST) -# lt_cdr(LIST) -# ------------ -# Manipulate m4 lists. -# These macros are necessary as long as will still need to support -# Autoconf-2.59 which quotes differently. -m4_define([lt_car], [[$1]]) -m4_define([lt_cdr], -[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], - [$#], 1, [], - [m4_dquote(m4_shift($@))])]) -m4_define([lt_unquote], $1) - - -# lt_append(MACRO-NAME, STRING, [SEPARATOR]) -# ------------------------------------------ -# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. -# Note that neither SEPARATOR nor STRING are expanded; they are appended -# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). -# No SEPARATOR is output if MACRO-NAME was previously undefined (different -# than defined and empty). -# -# This macro is needed until we can rely on Autoconf 2.62, since earlier -# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. -m4_define([lt_append], -[m4_define([$1], - m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) - - - -# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) -# ---------------------------------------------------------- -# Produce a SEP delimited list of all paired combinations of elements of -# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list -# has the form PREFIXmINFIXSUFFIXn. -# Needed until we can rely on m4_combine added in Autoconf 2.62. -m4_define([lt_combine], -[m4_if(m4_eval([$# > 3]), [1], - [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl -[[m4_foreach([_Lt_prefix], [$2], - [m4_foreach([_Lt_suffix], - ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, - [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) - - -# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) -# ----------------------------------------------------------------------- -# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited -# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. -m4_define([lt_if_append_uniq], -[m4_ifdef([$1], - [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], - [lt_append([$1], [$2], [$3])$4], - [$5])], - [lt_append([$1], [$2], [$3])$4])]) - - -# lt_dict_add(DICT, KEY, VALUE) -# ----------------------------- -m4_define([lt_dict_add], -[m4_define([$1($2)], [$3])]) - - -# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) -# -------------------------------------------- -m4_define([lt_dict_add_subkey], -[m4_define([$1($2:$3)], [$4])]) - - -# lt_dict_fetch(DICT, KEY, [SUBKEY]) -# ---------------------------------- -m4_define([lt_dict_fetch], -[m4_ifval([$3], - m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), - m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) - - -# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) -# ----------------------------------------------------------------- -m4_define([lt_if_dict_fetch], -[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], - [$5], - [$6])]) - - -# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) -# -------------------------------------------------------------- -m4_define([lt_dict_filter], -[m4_if([$5], [], [], - [lt_join(m4_quote(m4_default([$4], [[, ]])), - lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), - [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl -]) - -############################################################################## -# ltversion.m4 -- version numbers -*- Autoconf -*- -# -# Copyright (C) 2004 Free Software Foundation, Inc. -# Written by Scott James Remnant, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# Generated from ltversion.in. - -# serial 3012 ltversion.m4 -# This file is part of GNU Libtool - -m4_define([LT_PACKAGE_VERSION], [2.2.6]) -m4_define([LT_PACKAGE_REVISION], [1.3012]) - -AC_DEFUN([LTVERSION_VERSION], -[macro_version='2.2.6' -macro_revision='1.3012' -_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) -_LT_DECL(, macro_revision, 0) -]) - -############################################################################## -# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- -# -# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. -# Written by Scott James Remnant, 2004. -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 4 lt~obsolete.m4 - -# These exist entirely to fool aclocal when bootstrapping libtool. -# -# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) -# which have later been changed to m4_define as they aren't part of the -# exported API, or moved to Autoconf or Automake where they belong. -# -# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN -# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us -# using a macro with the same name in our local m4/libtool.m4 it'll -# pull the old libtool.m4 in (it doesn't see our shiny new m4_define -# and doesn't know about Autoconf macros at all.) -# -# So we provide this file, which has a silly filename so it's always -# included after everything else. This provides aclocal with the -# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything -# because those macros already exist, or will be overwritten later. -# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. -# -# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. -# Yes, that means every name once taken will need to remain here until -# we give up compatibility with versions before 1.7, at which point -# we need to keep only those names which we still refer to. - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) - -m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) -m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) -m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) -m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) -m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) -m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) -m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) -m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) -m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) -m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) -m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) -m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) -m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) -m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) -m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) -m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) -m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) -m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) -m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) -m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) -m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) -m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) -m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) -m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) -m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) -m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) -m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) -m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) -m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) -m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) -m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) -m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) -m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) -m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) -m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) -m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) -m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) -m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) -m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) -m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) -m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) -m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) -m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])]) -m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) -m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) -m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) -m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) -m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) -m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) -m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) -m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) -# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -# -# Copyright © 2004 Scott James Remnant . -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# PKG_PROG_PKG_CONFIG([MIN-VERSION]) -# ---------------------------------- -AC_DEFUN([PKG_PROG_PKG_CONFIG], -[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) -m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) -AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl -if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then - AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) -fi -if test -n "$PKG_CONFIG"; then - _pkg_min_version=m4_default([$1], [0.9.0]) - AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) - if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - PKG_CONFIG="" - fi - -fi[]dnl -])# PKG_PROG_PKG_CONFIG - -# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# -# Check to see whether a particular set of modules exists. Similar -# to PKG_CHECK_MODULES(), but does not set variables or print errors. -# -# -# Similar to PKG_CHECK_MODULES, make sure that the first instance of -# this or PKG_CHECK_MODULES is called, or make sure to call -# PKG_CHECK_EXISTS manually -# -------------------------------------------------------------- -AC_DEFUN([PKG_CHECK_EXISTS], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -if test -n "$PKG_CONFIG" && \ - AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then - m4_ifval([$2], [$2], [:]) -m4_ifvaln([$3], [else - $3])dnl -fi]) - - -# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) -# --------------------------------------------- -m4_define([_PKG_CONFIG], -[if test -n "$PKG_CONFIG"; then - if test -n "$$1"; then - pkg_cv_[]$1="$$1" - else - PKG_CHECK_EXISTS([$3], - [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], - [pkg_failed=yes]) - fi -else - pkg_failed=untried -fi[]dnl -])# _PKG_CONFIG - -# _PKG_SHORT_ERRORS_SUPPORTED -# ----------------------------- -AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi[]dnl -])# _PKG_SHORT_ERRORS_SUPPORTED - - -# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], -# [ACTION-IF-NOT-FOUND]) -# -# -# Note that if there is a possibility the first call to -# PKG_CHECK_MODULES might not happen, you should be sure to include an -# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac -# -# -# -------------------------------------------------------------- -AC_DEFUN([PKG_CHECK_MODULES], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl -AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl - -pkg_failed=no -AC_MSG_CHECKING([for $1]) - -_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) -_PKG_CONFIG([$1][_LIBS], [libs], [$2]) - -m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS -and $1[]_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details.]) - -if test $pkg_failed = yes; then - _PKG_SHORT_ERRORS_SUPPORTED - if test $_pkg_short_errors_supported = yes; then - $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` - else - $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` - fi - # Put the nasty error message in config.log where it belongs - echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD - - ifelse([$4], , [AC_MSG_ERROR(dnl -[Package requirements ($2) were not met: - -$$1_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -_PKG_TEXT -])], - [AC_MSG_RESULT([no]) - $4]) -elif test $pkg_failed = untried; then - ifelse([$4], , [AC_MSG_FAILURE(dnl -[The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -_PKG_TEXT - -To get pkg-config, see .])], - [$4]) -else - $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS - $1[]_LIBS=$pkg_cv_[]$1[]_LIBS - AC_MSG_RESULT([yes]) - ifelse([$3], , :, [$3]) -fi[]dnl -])# PKG_CHECK_MODULES -# Configure paths for SDL -# Sam Lantinga 9/21/99 -# stolen from Manish Singh -# stolen back from Frank Belew -# stolen from Manish Singh -# Shamelessly stolen from Owen Taylor - -# serial 1 - -dnl AM_PATH_SDL2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) -dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS -dnl -AC_DEFUN([AM_PATH_SDL2], -[dnl -dnl Get the cflags and libraries from the sdl2-config script -dnl -AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], - sdl_prefix="$withval", sdl_prefix="") -AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], - sdl_exec_prefix="$withval", sdl_exec_prefix="") -AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], - , enable_sdltest=yes) - - min_sdl_version=ifelse([$1], ,2.0.0,$1) - - if test "x$sdl_prefix$sdl_exec_prefix" = x ; then - PKG_CHECK_MODULES([SDL], [sdl2 >= $min_sdl_version], - [sdl_pc=yes], - [sdl_pc=no]) - else - sdl_pc=no - if test x$sdl_exec_prefix != x ; then - sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix" - if test x${SDL2_CONFIG+set} != xset ; then - SDL2_CONFIG=$sdl_exec_prefix/bin/sdl2-config - fi - fi - if test x$sdl_prefix != x ; then - sdl_config_args="$sdl_config_args --prefix=$sdl_prefix" - if test x${SDL2_CONFIG+set} != xset ; then - SDL2_CONFIG=$sdl_prefix/bin/sdl2-config - fi - fi - fi - - if test "x$sdl_pc" = xyes ; then - no_sdl="" - SDL2_CONFIG="pkg-config sdl2" - else - as_save_PATH="$PATH" - if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then - PATH="$prefix/bin:$prefix/usr/bin:$PATH" - fi - AC_PATH_PROG(SDL2_CONFIG, sdl2-config, no, [$PATH]) - PATH="$as_save_PATH" - AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) - no_sdl="" - - if test "$SDL2_CONFIG" = "no" ; then - no_sdl=yes - else - SDL_CFLAGS=`$SDL2_CONFIG $sdl_config_args --cflags` - SDL_LIBS=`$SDL2_CONFIG $sdl_config_args --libs` - - sdl_major_version=`$SDL2_CONFIG $sdl_config_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` - sdl_minor_version=`$SDL2_CONFIG $sdl_config_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` - sdl_micro_version=`$SDL2_CONFIG $sdl_config_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` - if test "x$enable_sdltest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_CXXFLAGS="$CXXFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $SDL_CFLAGS" - CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" - LIBS="$LIBS $SDL_LIBS" -dnl -dnl Now check if the installed SDL is sufficiently new. (Also sanity -dnl checks the results of sdl2-config to some extent -dnl - rm -f conf.sdltest - AC_TRY_RUN([ -#include -#include -#include -#include "SDL.h" - -char* -my_strdup (char *str) -{ - char *new_str; - - if (str) - { - new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); - strcpy (new_str, str); - } - else - new_str = NULL; - - return new_str; -} - -int main (int argc, char *argv[]) -{ - int major, minor, micro; - char *tmp_version; - - /* This hangs on some systems (?) - system ("touch conf.sdltest"); - */ - { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } - - /* HP/UX 9 (%@#!) writes to sscanf strings */ - tmp_version = my_strdup("$min_sdl_version"); - if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { - printf("%s, bad version string\n", "$min_sdl_version"); - exit(1); - } - - if (($sdl_major_version > major) || - (($sdl_major_version == major) && ($sdl_minor_version > minor)) || - (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) - { - return 0; - } - else - { - printf("\n*** 'sdl2-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); - printf("*** of SDL required is %d.%d.%d. If sdl2-config is correct, then it is\n", major, minor, micro); - printf("*** best to upgrade to the required version.\n"); - printf("*** If sdl2-config was wrong, set the environment variable SDL2_CONFIG\n"); - printf("*** to point to the correct copy of sdl2-config, and remove the file\n"); - printf("*** config.cache before re-running configure\n"); - return 1; - } -} - -],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) - CFLAGS="$ac_save_CFLAGS" - CXXFLAGS="$ac_save_CXXFLAGS" - LIBS="$ac_save_LIBS" - fi - fi - if test "x$no_sdl" = x ; then - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - fi - fi - if test "x$no_sdl" = x ; then - ifelse([$2], , :, [$2]) - else - if test "$SDL2_CONFIG" = "no" ; then - echo "*** The sdl2-config script installed by SDL could not be found" - echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" - echo "*** your path, or set the SDL2_CONFIG environment variable to the" - echo "*** full path to sdl2-config." - else - if test -f conf.sdltest ; then - : - else - echo "*** Could not run SDL test program, checking why..." - CFLAGS="$CFLAGS $SDL_CFLAGS" - CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" - LIBS="$LIBS $SDL_LIBS" - AC_TRY_LINK([ -#include -#include "SDL.h" - -int main(int argc, char *argv[]) -{ return 0; } -#undef main -#define main K_and_R_C_main -], [ return 0; ], - [ echo "*** The test program compiled, but did not run. This usually means" - echo "*** that the run-time linker is not finding SDL or finding the wrong" - echo "*** version of SDL. If it is not finding SDL, you'll need to set your" - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" - echo "*** to the installed location Also, make sure you have run ldconfig if that" - echo "*** is required on your system" - echo "***" - echo "*** If you have an old version installed, it is best to remove it, although" - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], - [ echo "*** The test program failed to compile or link. See the file config.log for the" - echo "*** exact error that occured. This usually means SDL was incorrectly installed" - echo "*** or that you have moved SDL since it was installed. In the latter case, you" - echo "*** may want to edit the sdl2-config script: $SDL2_CONFIG" ]) - CFLAGS="$ac_save_CFLAGS" - CXXFLAGS="$ac_save_CXXFLAGS" - LIBS="$ac_save_LIBS" - fi - fi - SDL_CFLAGS="" - SDL_LIBS="" - ifelse([$3], , :, [$3]) - fi - AC_SUBST(SDL_CFLAGS) - AC_SUBST(SDL_LIBS) - rm -f conf.sdltest -]) diff --git a/build-scripts/config.guess b/build-scripts/config.guess deleted file mode 100644 index a744844..0000000 --- a/build-scripts/config.guess +++ /dev/null @@ -1,1476 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright 1992-2017 Free Software Foundation, Inc. - -timestamp='2017-08-08' - -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). -# -# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. -# -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess -# -# Please send patches to . - - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright 1992-2017 Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - -trap 'exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. Note that the use of a -# compiler to aid in system detection is discouraged as it requires -# temporary files to be created and, as you can see below, it is a -# headache to deal with in a portable fashion. - -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -# Portable tmp directory creation inspired by the Autoconf team. - -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -case "${UNAME_SYSTEM}" in -Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu - - eval $set_cc_for_build - cat <<-EOF > $dummy.c - #include - #if defined(__UCLIBC__) - LIBC=uclibc - #elif defined(__dietlibc__) - LIBC=dietlibc - #else - LIBC=gnu - #endif - EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` - ;; -esac - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ - /sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || \ - echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - sh5el) machine=sh5le-unknown ;; - earmv*) - arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` - endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` - machine=${arch}${endian}-unknown - ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently (or will in the future) and ABI. - case "${UNAME_MACHINE_ARCH}" in - earm*) - os=netbsdelf - ;; - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ELF__ - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # Determine ABI tags. - case "${UNAME_MACHINE_ARCH}" in - earm*) - expr='s/^earmv[0-9]/-eabi/;s/eb$//' - abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` - ;; - esac - # The OS release - # Debian GNU/NetBSD machines have a different userland, and - # thus, need a distinct triplet. However, they do not need - # kernel version information, so it can be replaced with a - # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in - Debian*) - release='-gnu' - ;; - *) - release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` - ;; - esac - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}${abi}" - exit ;; - *:Bitrig:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} - exit ;; - *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; - *:LibertyBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE} - exit ;; - *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; - *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} - exit ;; - macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} - exit ;; - *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; - *:Sortix:*:*) - echo ${UNAME_MACHINE}-unknown-sortix - exit ;; - *:Redox:*:*) - echo ${UNAME_MACHINE}-unknown-redox - exit ;; - alpha:OSF1:*:*) - case $UNAME_RELEASE in - *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - ;; - *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` - ;; - esac - # According to Compaq, /usr/sbin/psrinfo has been available on - # OSF/1 and Tru64 systems produced since 1995. I hope that - # covers most systems running today. This code pipes the CPU - # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in - "EV4 (21064)") - UNAME_MACHINE=alpha ;; - "EV4.5 (21064)") - UNAME_MACHINE=alpha ;; - "LCA4 (21066/21068)") - UNAME_MACHINE=alpha ;; - "EV5 (21164)") - UNAME_MACHINE=alphaev5 ;; - "EV5.6 (21164A)") - UNAME_MACHINE=alphaev56 ;; - "EV5.6 (21164PC)") - UNAME_MACHINE=alphapca56 ;; - "EV5.7 (21164PC)") - UNAME_MACHINE=alphapca57 ;; - "EV6 (21264)") - UNAME_MACHINE=alphaev6 ;; - "EV6.7 (21264A)") - UNAME_MACHINE=alphaev67 ;; - "EV6.8CB (21264C)") - UNAME_MACHINE=alphaev68 ;; - "EV6.8AL (21264B)") - UNAME_MACHINE=alphaev68 ;; - "EV6.8CX (21264D)") - UNAME_MACHINE=alphaev68 ;; - "EV6.9A (21264/EV69A)") - UNAME_MACHINE=alphaev69 ;; - "EV7 (21364)") - UNAME_MACHINE=alphaev7 ;; - "EV7.9 (21364A)") - UNAME_MACHINE=alphaev79 ;; - esac - # A Pn.n version is a patched version. - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; - *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; - *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; - arm*:riscos:*:*|arm*:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; - DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; - DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; - s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} - exit ;; - i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH=i386 - # If there is a compiler, see if it is configured for 64-bit objects. - # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. - # This test works for both compilers. - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then - if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - SUN_ARCH=x86_64 - fi - fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; - m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && - { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; - Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` - then - echo "$SYSTEM_NAME" - else - echo rs6000-ibm-aix3.2.5 - fi - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit ;; - *:AIX:*:[4567]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/lslpp ] ; then - IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | - awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 - 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH=hppa2.0n ;; - 64) HP_ARCH=hppa2.0w ;; - '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` - test -z "$HP_ARCH" && HP_ARCH=hppa - fi ;; - esac - if [ ${HP_ARCH} = hppa2.0w ] - then - eval $set_cc_for_build - - # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating - # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler - # generating 64-bit code. GNU and HP use different nomenclature: - # - # $ CC_FOR_BUILD=cc ./config.guess - # => hppa2.0w-hp-hpux11.23 - # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess - # => hppa64-hp-hpux11.23 - - if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | - grep -q __LP64__ - then - HP_ARCH=hppa2.0w - else - HP_ARCH=hppa64 - fi - fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` - FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; - *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in - amd64) - UNAME_PROCESSOR=x86_64 ;; - i386) - UNAME_PROCESSOR=i586 ;; - esac - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; - *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 - exit ;; - *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; - *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; - *:Interix*:*) - case ${UNAME_MACHINE} in - x86) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; - authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} - exit ;; - IA64) - echo ia64-unknown-interix${UNAME_RELEASE} - exit ;; - esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; - amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; - *:GNU:*:*) - # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; - *:GNU/*:*:*) - # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; - aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - aarch64_be:Linux:*:*) - UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC=gnulibc1 ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - arm*:Linux:*:*) - eval $set_cc_for_build - if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_EABI__ - then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - else - if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_PCS_VFP - then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi - else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf - fi - fi - exit ;; - avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; - crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; - e2k:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - k1om:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } - ;; - mips64el:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - openrisc*:Linux:*:*) - echo or1k-unknown-linux-${LIBC} - exit ;; - or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} - exit ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; - esac - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} - exit ;; - ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} - exit ;; - ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} - exit ;; - riscv32:Linux:*:* | riscv64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} - exit ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} - exit ;; - x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; - xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit ;; - i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit ;; - i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` - (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. - # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configure will decide that - # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit ;; - mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; - M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; - M68*:*:R3V[5678]*:*) - test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; - NCR*:*:4.2:* | MPRAS*:*:4.2:*) - OS_REL='.3' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } - /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; - i*86:VOS:*:*) - # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; - BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; - x86_64:Haiku:*:*) - echo x86_64-unknown-haiku - exit ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; - SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; - SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} - exit ;; - SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} - exit ;; - SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} - exit ;; - SX-ACE:SUPER-UX:*:*) - echo sxace-nec-superux${UNAME_RELEASE} - exit ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; - *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc - fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi - # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc - if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_PPC >/dev/null - then - UNAME_PROCESSOR=powerpc - fi - fi - elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 - fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = x86; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NEO-*:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} - exit ;; - NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-*:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; - NSX-*:NONSTOP_KERNEL:*:*) - echo nsx-tandem-nsk${UNAME_RELEASE} - exit ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = 386; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit ;; - SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; - *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; - *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; - esac ;; - *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; - i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` - exit ;; - i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos - exit ;; - i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros - exit ;; - x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx - exit ;; - amd64:Isilon\ OneFS:*:*) - echo x86_64-unknown-onefs - exit ;; -esac - -cat >&2 </dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/build-scripts/config.sub b/build-scripts/config.sub deleted file mode 100644 index dcf4133..0000000 --- a/build-scripts/config.sub +++ /dev/null @@ -1,1868 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright 1992-2017 Free Software Foundation, Inc. - -timestamp='2017-04-02' - -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). - - -# Please send patches to . -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright 1992-2017 Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit ;; - --version | -v ) - echo "$version" ; exit ;; - --help | --h* | -h ) - echo "$usage"; exit ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit ;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | cloudabi*-eabi* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze*) - os= - basic_machine=$1 - ;; - -bluegene*) - os=-cnk - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | ba \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | e2k | epiphany \ - | fido | fr30 | frv | ft32 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia16 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pru \ - | pyramid \ - | riscv32 | riscv64 \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | visium \ - | wasm32 \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - leon|leon[3-9]) - basic_machine=sparc-$basic_machine - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - ms1) - basic_machine=mt-unknown - ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown - ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none - ;; - xscaleeb) - basic_machine=armeb-unknown - ;; - - xscaleel) - basic_machine=armel-unknown - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - nacl64*) - basic_machine=x86_64-pc - os=-nacl - ;; - nacl*) - basic_machine=i686-pc - os=-nacl - ;; - pnacl*) - # le32-unknown-pnacl comes from http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi - basic_machine=le32-unknown - os=-pnacl - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | ba-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | e2k-* | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | or1k*-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pru-* \ - | pyramid-* \ - | riscv32-* | riscv64-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | visium-* \ - | wasm32-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - asmjs) - basic_machine=asmjs-unknown - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - e500v[12]) - basic_machine=powerpc-unknown - os=$os"spe" - ;; - e500v[12]-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - os=$os"spe" - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - leon-*|leon[3-9]-*) - basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - pnacl) - basic_machine=le32-unknown - os=-pnacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - nsx-tandem) - basic_machine=nsx-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sde) - basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh5el) - basic_machine=sh5le-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tile*) - basic_machine=$basic_machine-unknown - os=-linux-gnu - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - wasm32) - basic_machine=wasm32-unknown - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - mmix) - basic_machine=mmix-knuth - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux - ;; - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* | -plan9* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* | -cloudabi* | -sortix* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-musl* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ - | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nacl*) - os=-nacl - ;; - -pnacl*) - os=-pnacl - ;; - -nto-qnx*) - ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -os400*) - os=-os400 - ;; - -cegcc*) - os=-cegcc - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -syllable*) - os=-syllable - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -tpf*) - os=-tpf - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -aros*) - os=-aros - ;; - -zvmoe) - os=-zvmoe - ;; - -dicos*) - os=-dicos - ;; - -nacl*) - os=-nacl - ;; - -pnacl*) - os=-pnacl - ;; - -ios) - ;; - -emscripten*) - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - score-*) - os=-elf - ;; - spu-*) - os=-elf - ;; - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - c4x-* | tic4x-*) - os=-coff - ;; - c8051-*) - os=-elf - ;; - hexagon-*) - os=-elf - ;; - tic54x-*) - os=-coff - ;; - tic55x-*) - os=-coff - ;; - tic6x-*) - os=-coff - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - ;; - m68*-cisco) - os=-aout - ;; - mep-*) - os=-elf - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - pru-*) - os=-elf - ;; - *-be) - os=-beos - ;; - *-haiku) - os=-haiku - ;; - *-ibm) - os=-aix - ;; - *-knuth) - os=-mmixware - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -cnk*|-aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -os400*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -tpf*) - vendor=ibm - ;; - -vxsim* | -vxworks* | -windiss*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/build-scripts/install-sh b/build-scripts/install-sh deleted file mode 100755 index 377bb86..0000000 --- a/build-scripts/install-sh +++ /dev/null @@ -1,527 +0,0 @@ -#!/bin/sh -# install - install a program, script, or datafile - -scriptversion=2011-11-20.07; # UTC - -# This originates from X11R5 (mit/util/scripts/install.sh), which was -# later released in X11R6 (xc/config/util/install.sh) with the -# following copyright and license. -# -# Copyright (C) 1994 X Consortium -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- -# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# Except as contained in this notice, the name of the X Consortium shall not -# be used in advertising or otherwise to promote the sale, use or other deal- -# ings in this Software without prior written authorization from the X Consor- -# tium. -# -# -# FSF changes to this file are in the public domain. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# 'make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. - -nl=' -' -IFS=" "" $nl" - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit=${DOITPROG-} -if test -z "$doit"; then - doit_exec=exec -else - doit_exec=$doit -fi - -# Put in absolute file names if you don't have them in your path; -# or use environment vars. - -chgrpprog=${CHGRPPROG-chgrp} -chmodprog=${CHMODPROG-chmod} -chownprog=${CHOWNPROG-chown} -cmpprog=${CMPPROG-cmp} -cpprog=${CPPROG-cp} -mkdirprog=${MKDIRPROG-mkdir} -mvprog=${MVPROG-mv} -rmprog=${RMPROG-rm} -stripprog=${STRIPPROG-strip} - -posix_glob='?' -initialize_posix_glob=' - test "$posix_glob" != "?" || { - if (set -f) 2>/dev/null; then - posix_glob= - else - posix_glob=: - fi - } -' - -posix_mkdir= - -# Desired mode of installed file. -mode=0755 - -chgrpcmd= -chmodcmd=$chmodprog -chowncmd= -mvcmd=$mvprog -rmcmd="$rmprog -f" -stripcmd= - -src= -dst= -dir_arg= -dst_arg= - -copy_on_change=false -no_target_directory= - -usage="\ -Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE - or: $0 [OPTION]... SRCFILES... DIRECTORY - or: $0 [OPTION]... -t DIRECTORY SRCFILES... - or: $0 [OPTION]... -d DIRECTORIES... - -In the 1st form, copy SRCFILE to DSTFILE. -In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. -In the 4th, create DIRECTORIES. - -Options: - --help display this help and exit. - --version display version info and exit. - - -c (ignored) - -C install only if different (preserve the last data modification time) - -d create directories instead of installing files. - -g GROUP $chgrpprog installed files to GROUP. - -m MODE $chmodprog installed files to MODE. - -o USER $chownprog installed files to USER. - -s $stripprog installed files. - -t DIRECTORY install into DIRECTORY. - -T report an error if DSTFILE is a directory. - -Environment variables override the default commands: - CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG - RMPROG STRIPPROG -" - -while test $# -ne 0; do - case $1 in - -c) ;; - - -C) copy_on_change=true;; - - -d) dir_arg=true;; - - -g) chgrpcmd="$chgrpprog $2" - shift;; - - --help) echo "$usage"; exit $?;; - - -m) mode=$2 - case $mode in - *' '* | *' '* | *' -'* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; - - -o) chowncmd="$chownprog $2" - shift;; - - -s) stripcmd=$stripprog;; - - -t) dst_arg=$2 - # Protect names problematic for 'test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - shift;; - - -T) no_target_directory=true;; - - --version) echo "$0 $scriptversion"; exit $?;; - - --) shift - break;; - - -*) echo "$0: invalid option: $1" >&2 - exit 1;; - - *) break;; - esac - shift -done - -if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then - # When -d is used, all remaining arguments are directories to create. - # When -t is used, the destination is already specified. - # Otherwise, the last argument is the destination. Remove it from $@. - for arg - do - if test -n "$dst_arg"; then - # $@ is not empty: it contains at least $arg. - set fnord "$@" "$dst_arg" - shift # fnord - fi - shift # arg - dst_arg=$arg - # Protect names problematic for 'test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - done -fi - -if test $# -eq 0; then - if test -z "$dir_arg"; then - echo "$0: no input file specified." >&2 - exit 1 - fi - # It's OK to call 'install-sh -d' without argument. - # This can happen when creating conditional directories. - exit 0 -fi - -if test -z "$dir_arg"; then - do_exit='(exit $ret); exit $ret' - trap "ret=129; $do_exit" 1 - trap "ret=130; $do_exit" 2 - trap "ret=141; $do_exit" 13 - trap "ret=143; $do_exit" 15 - - # Set umask so as not to create temps with too-generous modes. - # However, 'strip' requires both read and write access to temps. - case $mode in - # Optimize common cases. - *644) cp_umask=133;; - *755) cp_umask=22;; - - *[0-7]) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw='% 200' - fi - cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; - *) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw=,u+rw - fi - cp_umask=$mode$u_plus_rw;; - esac -fi - -for src -do - # Protect names problematic for 'test' and other utilities. - case $src in - -* | [=\(\)!]) src=./$src;; - esac - - if test -n "$dir_arg"; then - dst=$src - dstdir=$dst - test -d "$dstdir" - dstdir_status=$? - else - - # Waiting for this to be detected by the "$cpprog $src $dsttmp" command - # might cause directories to be created, which would be especially bad - # if $src (and thus $dsttmp) contains '*'. - if test ! -f "$src" && test ! -d "$src"; then - echo "$0: $src does not exist." >&2 - exit 1 - fi - - if test -z "$dst_arg"; then - echo "$0: no destination specified." >&2 - exit 1 - fi - dst=$dst_arg - - # If destination is a directory, append the input filename; won't work - # if double slashes aren't ignored. - if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dst_arg: Is a directory" >&2 - exit 1 - fi - dstdir=$dst - dst=$dstdir/`basename "$src"` - dstdir_status=0 - else - # Prefer dirname, but fall back on a substitute if dirname fails. - dstdir=` - (dirname "$dst") 2>/dev/null || - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$dst" : 'X\(//\)[^/]' \| \ - X"$dst" : 'X\(//\)$' \| \ - X"$dst" : 'X\(/\)' \| . 2>/dev/null || - echo X"$dst" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q' - ` - - test -d "$dstdir" - dstdir_status=$? - fi - fi - - obsolete_mkdir_used=false - - if test $dstdir_status != 0; then - case $posix_mkdir in - '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac - - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode - else - mkdir_mode= - fi - - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; - esac - - if - $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" - ) - then : - else - - # The umask is ridiculous, or mkdir does not conform to POSIX, - # or it failed possibly due to a race condition. Create the - # directory the slow way, step by step, checking for races as we go. - - case $dstdir in - /*) prefix='/';; - [-=\(\)!]*) prefix='./';; - *) prefix='';; - esac - - eval "$initialize_posix_glob" - - oIFS=$IFS - IFS=/ - $posix_glob set -f - set fnord $dstdir - shift - $posix_glob set +f - IFS=$oIFS - - prefixes= - - for d - do - test X"$d" = X && continue - - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ - done - - if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true - fi - fi - fi - - if test -n "$dir_arg"; then - { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && - { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || - test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 - else - - # Make a couple of temp file names in the proper directory. - dsttmp=$dstdir/_inst.$$_ - rmtmp=$dstdir/_rm.$$_ - - # Trap to clean up those temp files at exit. - trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 - - # Copy the file name to the temp name. - (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && - - # and set any options; do chmod last to preserve setuid bits. - # - # If any of these fail, we abort the whole thing. If we want to - # ignore errors from any of these, just make sure not to ignore - # errors from the above "$doit $cpprog $src $dsttmp" command. - # - { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && - { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && - { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && - - # If -C, don't bother to copy if it wouldn't change the file. - if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - - eval "$initialize_posix_glob" && - $posix_glob set -f && - set X $old && old=:$2:$4:$5:$6 && - set X $new && new=:$2:$4:$5:$6 && - $posix_glob set +f && - - test "$old" = "$new" && - $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 - then - rm -f "$dsttmp" - else - # Rename the file to the real destination. - $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || - - # The rename failed, perhaps because mv can't rename something else - # to itself, or perhaps because mv is so ancient that it does not - # support -f. - { - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" - } - fi || exit 1 - - trap '' 0 - fi -done - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/build-scripts/ltmain.sh b/build-scripts/ltmain.sh deleted file mode 100644 index 5e04f08..0000000 --- a/build-scripts/ltmain.sh +++ /dev/null @@ -1,8407 +0,0 @@ -# Generated from ltmain.m4sh. - -# ltmain.sh (GNU libtool) 2.2.6 -# Written by Gordon Matzigkeit , 1996 - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc. -# This is free software; see the source for copying conditions. There is NO -# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -# GNU Libtool is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, -# or obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -# Usage: $progname [OPTION]... [MODE-ARG]... -# -# Provide generalized library-building support services. -# -# --config show all configuration variables -# --debug enable verbose shell tracing -# -n, --dry-run display commands without modifying any files -# --features display basic configuration information and exit -# --mode=MODE use operation mode MODE -# --preserve-dup-deps don't remove duplicate dependency libraries -# --quiet, --silent don't print informational messages -# --tag=TAG use configuration variables from tag TAG -# -v, --verbose print informational messages (default) -# --version print version information -# -h, --help print short or long help message -# -# MODE must be one of the following: -# -# clean remove files from the build directory -# compile compile a source file into a libtool object -# execute automatically set library path, then run a program -# finish complete the installation of libtool libraries -# install install libraries or executables -# link create a library or an executable -# uninstall remove libraries from an installed directory -# -# MODE-ARGS vary depending on the MODE. -# Try `$progname --help --mode=MODE' for a more detailed description of MODE. -# -# When reporting a bug, please describe a test case to reproduce it and -# include the following information: -# -# host-triplet: $host -# shell: $SHELL -# compiler: $LTCC -# compiler flags: $LTCFLAGS -# linker: $LD (gnu? $with_gnu_ld) -# $progname: (GNU libtool) 2.2.6 -# automake: $automake_version -# autoconf: $autoconf_version -# -# Report bugs to . - -PROGRAM=ltmain.sh -PACKAGE=libtool -VERSION=2.2.6 -TIMESTAMP="" -package_revision=1.3012 - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac -fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh - -# NLS nuisances: We save the old values to restore during execute mode. -# Only set LANG and LC_ALL to C if already set. -# These must not be set unconditionally because not all systems understand -# e.g. LANG=C (notably SCO). -lt_user_locale= -lt_safe_locale= -for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES -do - eval "if test \"\${$lt_var+set}\" = set; then - save_$lt_var=\$$lt_var - $lt_var=C - export $lt_var - lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" - lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" - fi" -done - -$lt_unset CDPATH - - - - - -: ${CP="cp -f"} -: ${ECHO="echo"} -: ${EGREP="/usr/bin/grep -E"} -: ${FGREP="/usr/bin/grep -F"} -: ${GREP="/usr/bin/grep"} -: ${LN_S="ln -s"} -: ${MAKE="make"} -: ${MKDIR="mkdir"} -: ${MV="mv -f"} -: ${RM="rm -f"} -: ${SED="/opt/local/bin/gsed"} -: ${SHELL="${CONFIG_SHELL-/bin/sh}"} -: ${Xsed="$SED -e 1s/^X//"} - -# Global variables: -EXIT_SUCCESS=0 -EXIT_FAILURE=1 -EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. -EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. - -exit_status=$EXIT_SUCCESS - -# Make sure IFS has a sensible default -lt_nl=' -' -IFS=" $lt_nl" - -dirname="s,/[^/]*$,," -basename="s,^.*/,," - -# func_dirname_and_basename file append nondir_replacement -# perform func_basename and func_dirname in a single function -# call: -# dirname: Compute the dirname of FILE. If nonempty, -# add APPEND to the result, otherwise set result -# to NONDIR_REPLACEMENT. -# value returned in "$func_dirname_result" -# basename: Compute filename of FILE. -# value retuned in "$func_basename_result" -# Implementation must be kept synchronized with func_dirname -# and func_basename. For efficiency, we do not delegate to -# those functions but instead duplicate the functionality here. -func_dirname_and_basename () -{ - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi - func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` -} - -# Generated shell functions inserted here. - -# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh -# is ksh but when the shell is invoked as "sh" and the current value of -# the _XPG environment variable is not equal to 1 (one), the special -# positional parameter $0, within a function call, is the name of the -# function. -progpath="$0" - -# The name of this program: -# In the unlikely event $progname began with a '-', it would play havoc with -# func_echo (imagine progname=-n), so we prepend ./ in that case: -func_dirname_and_basename "$progpath" -progname=$func_basename_result -case $progname in - -*) progname=./$progname ;; -esac - -# Make sure we have an absolute path for reexecution: -case $progpath in - [\\/]*|[A-Za-z]:\\*) ;; - *[\\/]*) - progdir=$func_dirname_result - progdir=`cd "$progdir" && pwd` - progpath="$progdir/$progname" - ;; - *) - save_IFS="$IFS" - IFS=: - for progdir in $PATH; do - IFS="$save_IFS" - test -x "$progdir/$progname" && break - done - IFS="$save_IFS" - test -n "$progdir" || progdir=`pwd` - progpath="$progdir/$progname" - ;; -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed="${SED}"' -e 1s/^X//' -sed_quote_subst='s/\([`"$\\]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\(["`\\]\)/\\\1/g' - -# Re-`\' parameter expansions in output of double_quote_subst that were -# `\'-ed in input to the same. If an odd number of `\' preceded a '$' -# in input to double_quote_subst, that '$' was protected from expansion. -# Since each input `\' is now two `\'s, look for any number of runs of -# four `\'s followed by two `\'s and then a '$'. `\' that '$'. -bs='\\' -bs2='\\\\' -bs4='\\\\\\\\' -dollar='\$' -sed_double_backslash="\ - s/$bs4/&\\ -/g - s/^$bs2$dollar/$bs&/ - s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g - s/\n//g" - -# Standard options: -opt_dry_run=false -opt_help=false -opt_quiet=false -opt_verbose=false -opt_warning=: - -# func_echo arg... -# Echo program name prefixed message, along with the current mode -# name if it has been set yet. -func_echo () -{ - $ECHO "$progname${mode+: }$mode: $*" -} - -# func_verbose arg... -# Echo program name prefixed message in verbose mode only. -func_verbose () -{ - $opt_verbose && func_echo ${1+"$@"} - - # A bug in bash halts the script if the last line of a function - # fails when set -e is in force, so we need another command to - # work around that: - : -} - -# func_error arg... -# Echo program name prefixed message to standard error. -func_error () -{ - $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2 -} - -# func_warning arg... -# Echo program name prefixed warning message to standard error. -func_warning () -{ - $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2 - - # bash bug again: - : -} - -# func_fatal_error arg... -# Echo program name prefixed message to standard error, and exit. -func_fatal_error () -{ - func_error ${1+"$@"} - exit $EXIT_FAILURE -} - -# func_fatal_help arg... -# Echo program name prefixed message to standard error, followed by -# a help hint, and exit. -func_fatal_help () -{ - func_error ${1+"$@"} - func_fatal_error "$help" -} -help="Try \`$progname --help' for more information." ## default - - -# func_grep expression filename -# Check whether EXPRESSION matches any line of FILENAME, without output. -func_grep () -{ - $GREP "$1" "$2" >/dev/null 2>&1 -} - - -# func_mkdir_p directory-path -# Make sure the entire path to DIRECTORY-PATH is available. -func_mkdir_p () -{ - my_directory_path="$1" - my_dir_list= - - if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then - - # Protect directory names starting with `-' - case $my_directory_path in - -*) my_directory_path="./$my_directory_path" ;; - esac - - # While some portion of DIR does not yet exist... - while test ! -d "$my_directory_path"; do - # ...make a list in topmost first order. Use a colon delimited - # list incase some portion of path contains whitespace. - my_dir_list="$my_directory_path:$my_dir_list" - - # If the last portion added has no slash in it, the list is done - case $my_directory_path in */*) ;; *) break ;; esac - - # ...otherwise throw away the child directory and loop - my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"` - done - my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'` - - save_mkdir_p_IFS="$IFS"; IFS=':' - for my_dir in $my_dir_list; do - IFS="$save_mkdir_p_IFS" - # mkdir can fail with a `File exist' error if two processes - # try to create one of the directories concurrently. Don't - # stop in that case! - $MKDIR "$my_dir" 2>/dev/null || : - done - IFS="$save_mkdir_p_IFS" - - # Bail out if we (or some other process) failed to create a directory. - test -d "$my_directory_path" || \ - func_fatal_error "Failed to create \`$1'" - fi -} - - -# func_mktempdir [string] -# Make a temporary directory that won't clash with other running -# libtool processes, and avoids race conditions if possible. If -# given, STRING is the basename for that directory. -func_mktempdir () -{ - my_template="${TMPDIR-/tmp}/${1-$progname}" - - if test "$opt_dry_run" = ":"; then - # Return a directory name, but don't create it in dry-run mode - my_tmpdir="${my_template}-$$" - else - - # If mktemp works, use that first and foremost - my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` - - if test ! -d "$my_tmpdir"; then - # Failing that, at least try and use $RANDOM to avoid a race - my_tmpdir="${my_template}-${RANDOM-0}$$" - - save_mktempdir_umask=`umask` - umask 0077 - $MKDIR "$my_tmpdir" - umask $save_mktempdir_umask - fi - - # If we're not in dry-run mode, bomb out on failure - test -d "$my_tmpdir" || \ - func_fatal_error "cannot create temporary directory \`$my_tmpdir'" - fi - - $ECHO "X$my_tmpdir" | $Xsed -} - - -# func_quote_for_eval arg -# Aesthetically quote ARG to be evaled later. -# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT -# is double-quoted, suitable for a subsequent eval, whereas -# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters -# which are still active within double quotes backslashified. -func_quote_for_eval () -{ - case $1 in - *[\\\`\"\$]*) - func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;; - *) - func_quote_for_eval_unquoted_result="$1" ;; - esac - - case $func_quote_for_eval_unquoted_result in - # Double-quote args containing shell metacharacters to delay - # word splitting, command substitution and and variable - # expansion for a subsequent eval. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" - ;; - *) - func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" - esac -} - - -# func_quote_for_expand arg -# Aesthetically quote ARG to be evaled later; same as above, -# but do not quote variable references. -func_quote_for_expand () -{ - case $1 in - *[\\\`\"]*) - my_arg=`$ECHO "X$1" | $Xsed \ - -e "$double_quote_subst" -e "$sed_double_backslash"` ;; - *) - my_arg="$1" ;; - esac - - case $my_arg in - # Double-quote args containing shell metacharacters to delay - # word splitting and command substitution for a subsequent eval. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - my_arg="\"$my_arg\"" - ;; - esac - - func_quote_for_expand_result="$my_arg" -} - - -# func_show_eval cmd [fail_exp] -# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is -# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP -# is given, then evaluate it. -func_show_eval () -{ - my_cmd="$1" - my_fail_exp="${2-:}" - - ${opt_silent-false} || { - func_quote_for_expand "$my_cmd" - eval "func_echo $func_quote_for_expand_result" - } - - if ${opt_dry_run-false}; then :; else - eval "$my_cmd" - my_status=$? - if test "$my_status" -eq 0; then :; else - eval "(exit $my_status); $my_fail_exp" - fi - fi -} - - -# func_show_eval_locale cmd [fail_exp] -# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is -# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP -# is given, then evaluate it. Use the saved locale for evaluation. -func_show_eval_locale () -{ - my_cmd="$1" - my_fail_exp="${2-:}" - - ${opt_silent-false} || { - func_quote_for_expand "$my_cmd" - eval "func_echo $func_quote_for_expand_result" - } - - if ${opt_dry_run-false}; then :; else - eval "$lt_user_locale - $my_cmd" - my_status=$? - eval "$lt_safe_locale" - if test "$my_status" -eq 0; then :; else - eval "(exit $my_status); $my_fail_exp" - fi - fi -} - - - - - -# func_version -# Echo version message to standard output and exit. -func_version () -{ - $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / { - s/^# // - s/^# *$// - s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ - p - }' < "$progpath" - exit $? -} - -# func_usage -# Echo short help message to standard output and exit. -func_usage () -{ - $SED -n '/^# Usage:/,/# -h/ { - s/^# // - s/^# *$// - s/\$progname/'$progname'/ - p - }' < "$progpath" - $ECHO - $ECHO "run \`$progname --help | more' for full usage" - exit $? -} - -# func_help -# Echo long help message to standard output and exit. -func_help () -{ - $SED -n '/^# Usage:/,/# Report bugs to/ { - s/^# // - s/^# *$// - s*\$progname*'$progname'* - s*\$host*'"$host"'* - s*\$SHELL*'"$SHELL"'* - s*\$LTCC*'"$LTCC"'* - s*\$LTCFLAGS*'"$LTCFLAGS"'* - s*\$LD*'"$LD"'* - s/\$with_gnu_ld/'"$with_gnu_ld"'/ - s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ - s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ - p - }' < "$progpath" - exit $? -} - -# func_missing_arg argname -# Echo program name prefixed message to standard error and set global -# exit_cmd. -func_missing_arg () -{ - func_error "missing argument for $1" - exit_cmd=exit -} - -exit_cmd=: - - - - - -# Check that we have a working $ECHO. -if test "X$1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X$1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then - # Yippee, $ECHO works! - : -else - # Restart under the correct shell, and then maybe $ECHO will work. - exec $SHELL "$progpath" --no-reexec ${1+"$@"} -fi - -if test "X$1" = X--fallback-echo; then - # used as fallback echo - shift - cat </dev/null 2>&1; then - taglist="$taglist $tagname" - - # Evaluate the configuration. Be careful to quote the path - # and the sed script, to avoid splitting on whitespace, but - # also don't use non-portable quotes within backquotes within - # quotes we have to do it in 2 steps: - extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` - eval "$extractedcf" - else - func_error "ignoring unknown tag $tagname" - fi - ;; - esac -} - -# Parse options once, thoroughly. This comes as soon as possible in -# the script to make things like `libtool --version' happen quickly. -{ - - # Shorthand for --mode=foo, only valid as the first argument - case $1 in - clean|clea|cle|cl) - shift; set dummy --mode clean ${1+"$@"}; shift - ;; - compile|compil|compi|comp|com|co|c) - shift; set dummy --mode compile ${1+"$@"}; shift - ;; - execute|execut|execu|exec|exe|ex|e) - shift; set dummy --mode execute ${1+"$@"}; shift - ;; - finish|finis|fini|fin|fi|f) - shift; set dummy --mode finish ${1+"$@"}; shift - ;; - install|instal|insta|inst|ins|in|i) - shift; set dummy --mode install ${1+"$@"}; shift - ;; - link|lin|li|l) - shift; set dummy --mode link ${1+"$@"}; shift - ;; - uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) - shift; set dummy --mode uninstall ${1+"$@"}; shift - ;; - esac - - # Parse non-mode specific arguments: - while test "$#" -gt 0; do - opt="$1" - shift - - case $opt in - --config) func_config ;; - - --debug) preserve_args="$preserve_args $opt" - func_echo "enabling shell trace mode" - opt_debug='set -x' - $opt_debug - ;; - - -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break - execute_dlfiles="$execute_dlfiles $1" - shift - ;; - - --dry-run | -n) opt_dry_run=: ;; - --features) func_features ;; - --finish) mode="finish" ;; - - --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break - case $1 in - # Valid mode arguments: - clean) ;; - compile) ;; - execute) ;; - finish) ;; - install) ;; - link) ;; - relink) ;; - uninstall) ;; - - # Catch anything else as an error - *) func_error "invalid argument for $opt" - exit_cmd=exit - break - ;; - esac - - mode="$1" - shift - ;; - - --preserve-dup-deps) - opt_duplicate_deps=: ;; - - --quiet|--silent) preserve_args="$preserve_args $opt" - opt_silent=: - ;; - - --verbose| -v) preserve_args="$preserve_args $opt" - opt_silent=false - ;; - - --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break - preserve_args="$preserve_args $opt $1" - func_enable_tag "$1" # tagname is set here - shift - ;; - - # Separate optargs to long options: - -dlopen=*|--mode=*|--tag=*) - func_opt_split "$opt" - set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"} - shift - ;; - - -\?|-h) func_usage ;; - --help) opt_help=: ;; - --version) func_version ;; - - -*) func_fatal_help "unrecognized option \`$opt'" ;; - - *) nonopt="$opt" - break - ;; - esac - done - - - case $host in - *cygwin* | *mingw* | *pw32* | *cegcc*) - # don't eliminate duplications in $postdeps and $predeps - opt_duplicate_compiler_generated_deps=: - ;; - *) - opt_duplicate_compiler_generated_deps=$opt_duplicate_deps - ;; - esac - - # Having warned about all mis-specified options, bail out if - # anything was wrong. - $exit_cmd $EXIT_FAILURE -} - -# func_check_version_match -# Ensure that we are using m4 macros, and libtool script from the same -# release of libtool. -func_check_version_match () -{ - if test "$package_revision" != "$macro_revision"; then - if test "$VERSION" != "$macro_version"; then - if test -z "$macro_version"; then - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, but the -$progname: definition of this LT_INIT comes from an older release. -$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION -$progname: and run autoconf again. -_LT_EOF - else - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, but the -$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. -$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION -$progname: and run autoconf again. -_LT_EOF - fi - else - cat >&2 <<_LT_EOF -$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, -$progname: but the definition of this LT_INIT comes from revision $macro_revision. -$progname: You should recreate aclocal.m4 with macros from revision $package_revision -$progname: of $PACKAGE $VERSION and run autoconf again. -_LT_EOF - fi - - exit $EXIT_MISMATCH - fi -} - - -## ----------- ## -## Main. ## -## ----------- ## - -$opt_help || { - # Sanity checks first: - func_check_version_match - - if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then - func_fatal_configuration "not configured to build any kind of library" - fi - - test -z "$mode" && func_fatal_error "error: you must specify a MODE." - - - # Darwin sucks - eval std_shrext=\"$shrext_cmds\" - - - # Only execute mode is allowed to have -dlopen flags. - if test -n "$execute_dlfiles" && test "$mode" != execute; then - func_error "unrecognized option \`-dlopen'" - $ECHO "$help" 1>&2 - exit $EXIT_FAILURE - fi - - # Change the help message to a mode-specific one. - generic_help="$help" - help="Try \`$progname --help --mode=$mode' for more information." -} - - -# func_lalib_p file -# True iff FILE is a libtool `.la' library or `.lo' object file. -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_lalib_p () -{ - test -f "$1" && - $SED -e 4q "$1" 2>/dev/null \ - | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 -} - -# func_lalib_unsafe_p file -# True iff FILE is a libtool `.la' library or `.lo' object file. -# This function implements the same check as func_lalib_p without -# resorting to external programs. To this end, it redirects stdin and -# closes it afterwards, without saving the original file descriptor. -# As a safety measure, use it only where a negative result would be -# fatal anyway. Works if `file' does not exist. -func_lalib_unsafe_p () -{ - lalib_p=no - if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then - for lalib_p_l in 1 2 3 4 - do - read lalib_p_line - case "$lalib_p_line" in - \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; - esac - done - exec 0<&5 5<&- - fi - test "$lalib_p" = yes -} - -# func_ltwrapper_script_p file -# True iff FILE is a libtool wrapper script -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_ltwrapper_script_p () -{ - func_lalib_p "$1" -} - -# func_ltwrapper_executable_p file -# True iff FILE is a libtool wrapper executable -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_ltwrapper_executable_p () -{ - func_ltwrapper_exec_suffix= - case $1 in - *.exe) ;; - *) func_ltwrapper_exec_suffix=.exe ;; - esac - $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 -} - -# func_ltwrapper_scriptname file -# Assumes file is an ltwrapper_executable -# uses $file to determine the appropriate filename for a -# temporary ltwrapper_script. -func_ltwrapper_scriptname () -{ - func_ltwrapper_scriptname_result="" - if func_ltwrapper_executable_p "$1"; then - func_dirname_and_basename "$1" "" "." - func_stripname '' '.exe' "$func_basename_result" - func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" - fi -} - -# func_ltwrapper_p file -# True iff FILE is a libtool wrapper script or wrapper executable -# This function is only a basic sanity check; it will hardly flush out -# determined imposters. -func_ltwrapper_p () -{ - func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" -} - - -# func_execute_cmds commands fail_cmd -# Execute tilde-delimited COMMANDS. -# If FAIL_CMD is given, eval that upon failure. -# FAIL_CMD may read-access the current command in variable CMD! -func_execute_cmds () -{ - $opt_debug - save_ifs=$IFS; IFS='~' - for cmd in $1; do - IFS=$save_ifs - eval cmd=\"$cmd\" - func_show_eval "$cmd" "${2-:}" - done - IFS=$save_ifs -} - - -# func_source file -# Source FILE, adding directory component if necessary. -# Note that it is not necessary on cygwin/mingw to append a dot to -# FILE even if both FILE and FILE.exe exist: automatic-append-.exe -# behavior happens only for exec(3), not for open(2)! Also, sourcing -# `FILE.' does not work on cygwin managed mounts. -func_source () -{ - $opt_debug - case $1 in - */* | *\\*) . "$1" ;; - *) . "./$1" ;; - esac -} - - -# func_infer_tag arg -# Infer tagged configuration to use if any are available and -# if one wasn't chosen via the "--tag" command line option. -# Only attempt this if the compiler in the base compile -# command doesn't match the default compiler. -# arg is usually of the form 'gcc ...' -func_infer_tag () -{ - $opt_debug - if test -n "$available_tags" && test -z "$tagname"; then - CC_quoted= - for arg in $CC; do - func_quote_for_eval "$arg" - CC_quoted="$CC_quoted $func_quote_for_eval_result" - done - case $@ in - # Blanks in the command may have been stripped by the calling shell, - # but not from the CC environment variable when configure was run. - " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;; - # Blanks at the start of $base_compile will cause this to fail - # if we don't check for them as well. - *) - for z in $available_tags; do - if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then - # Evaluate the configuration. - eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" - CC_quoted= - for arg in $CC; do - # Double-quote args containing other shell metacharacters. - func_quote_for_eval "$arg" - CC_quoted="$CC_quoted $func_quote_for_eval_result" - done - case "$@ " in - " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) - # The compiler in the base compile command matches - # the one in the tagged configuration. - # Assume this is the tagged configuration we want. - tagname=$z - break - ;; - esac - fi - done - # If $tagname still isn't set, then no tagged configuration - # was found and let the user know that the "--tag" command - # line option must be used. - if test -z "$tagname"; then - func_echo "unable to infer tagged configuration" - func_fatal_error "specify a tag with \`--tag'" -# else -# func_verbose "using $tagname tagged configuration" - fi - ;; - esac - fi -} - - - -# func_write_libtool_object output_name pic_name nonpic_name -# Create a libtool object file (analogous to a ".la" file), -# but don't create it if we're doing a dry run. -func_write_libtool_object () -{ - write_libobj=${1} - if test "$build_libtool_libs" = yes; then - write_lobj=\'${2}\' - else - write_lobj=none - fi - - if test "$build_old_libs" = yes; then - write_oldobj=\'${3}\' - else - write_oldobj=none - fi - - $opt_dry_run || { - cat >${write_libobj}T <?"'"'"' &()|`$[]' \ - && func_warning "libobj name \`$libobj' may not contain shell special characters." - func_dirname_and_basename "$obj" "/" "" - objname="$func_basename_result" - xdir="$func_dirname_result" - lobj=${xdir}$objdir/$objname - - test -z "$base_compile" && \ - func_fatal_help "you must specify a compilation command" - - # Delete any leftover library objects. - if test "$build_old_libs" = yes; then - removelist="$obj $lobj $libobj ${libobj}T" - else - removelist="$lobj $libobj ${libobj}T" - fi - - # On Cygwin there's no "real" PIC flag so we must build both object types - case $host_os in - cygwin* | mingw* | pw32* | os2* | cegcc*) - pic_mode=default - ;; - esac - if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then - # non-PIC code in shared libraries is not supported - pic_mode=default - fi - - # Calculate the filename of the output object if compiler does - # not support -o with -c - if test "$compiler_c_o" = no; then - output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} - lockfile="$output_obj.lock" - else - output_obj= - need_locks=no - lockfile= - fi - - # Lock this critical section if it is needed - # We use this script file to make the link, it avoids creating a new file - if test "$need_locks" = yes; then - until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do - func_echo "Waiting for $lockfile to be removed" - sleep 2 - done - elif test "$need_locks" = warn; then - if test -f "$lockfile"; then - $ECHO "\ -*** ERROR, $lockfile exists and contains: -`cat $lockfile 2>/dev/null` - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $opt_dry_run || $RM $removelist - exit $EXIT_FAILURE - fi - removelist="$removelist $output_obj" - $ECHO "$srcfile" > "$lockfile" - fi - - $opt_dry_run || $RM $removelist - removelist="$removelist $lockfile" - trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 - - if test -n "$fix_srcfile_path"; then - eval srcfile=\"$fix_srcfile_path\" - fi - func_quote_for_eval "$srcfile" - qsrcfile=$func_quote_for_eval_result - - # Only build a PIC object if we are building libtool libraries. - if test "$build_libtool_libs" = yes; then - # Without this assignment, base_compile gets emptied. - fbsd_hideous_sh_bug=$base_compile - - if test "$pic_mode" != no; then - command="$base_compile $qsrcfile $pic_flag" - else - # Don't build PIC code - command="$base_compile $qsrcfile" - fi - - func_mkdir_p "$xdir$objdir" - - if test -z "$output_obj"; then - # Place PIC objects in $objdir - command="$command -o $lobj" - fi - - func_show_eval_locale "$command" \ - 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' - - if test "$need_locks" = warn && - test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then - $ECHO "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $opt_dry_run || $RM $removelist - exit $EXIT_FAILURE - fi - - # Just move the object if needed, then go on to compile the next one - if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then - func_show_eval '$MV "$output_obj" "$lobj"' \ - 'error=$?; $opt_dry_run || $RM $removelist; exit $error' - fi - - # Allow error messages only from the first compilation. - if test "$suppress_opt" = yes; then - suppress_output=' >/dev/null 2>&1' - fi - fi - - # Only build a position-dependent object if we build old libraries. - if test "$build_old_libs" = yes; then - if test "$pic_mode" != yes; then - # Don't build PIC code - command="$base_compile $qsrcfile$pie_flag" - else - command="$base_compile $qsrcfile $pic_flag" - fi - if test "$compiler_c_o" = yes; then - command="$command -o $obj" - fi - - # Suppress compiler output if we already did a PIC compilation. - command="$command$suppress_output" - func_show_eval_locale "$command" \ - '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' - - if test "$need_locks" = warn && - test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then - $ECHO "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $opt_dry_run || $RM $removelist - exit $EXIT_FAILURE - fi - - # Just move the object if needed - if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then - func_show_eval '$MV "$output_obj" "$obj"' \ - 'error=$?; $opt_dry_run || $RM $removelist; exit $error' - fi - fi - - $opt_dry_run || { - func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" - - # Unlock the critical section if it was locked - if test "$need_locks" != no; then - removelist=$lockfile - $RM "$lockfile" - fi - } - - exit $EXIT_SUCCESS -} - -$opt_help || { -test "$mode" = compile && func_mode_compile ${1+"$@"} -} - -func_mode_help () -{ - # We need to display help for each of the modes. - case $mode in - "") - # Generic help is extracted from the usage comments - # at the start of this file. - func_help - ;; - - clean) - $ECHO \ -"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... - -Remove files from the build directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, object or program, all the files associated -with it are deleted. Otherwise, only FILE itself is deleted using RM." - ;; - - compile) - $ECHO \ -"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE - -Compile a source file into a libtool library object. - -This mode accepts the following additional options: - - -o OUTPUT-FILE set the output file name to OUTPUT-FILE - -no-suppress do not suppress compiler output for multiple passes - -prefer-pic try to building PIC objects only - -prefer-non-pic try to building non-PIC objects only - -shared do not build a \`.o' file suitable for static linking - -static only build a \`.o' file suitable for static linking - -COMPILE-COMMAND is a command to be used in creating a \`standard' object file -from the given SOURCEFILE. - -The output file name is determined by removing the directory component from -SOURCEFILE, then substituting the C source code suffix \`.c' with the -library object suffix, \`.lo'." - ;; - - execute) - $ECHO \ -"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... - -Automatically set library path, then run a program. - -This mode accepts the following additional options: - - -dlopen FILE add the directory containing FILE to the library path - -This mode sets the library path environment variable according to \`-dlopen' -flags. - -If any of the ARGS are libtool executable wrappers, then they are translated -into their corresponding uninstalled binary, and any of their required library -directories are added to the library path. - -Then, COMMAND is executed, with ARGS as arguments." - ;; - - finish) - $ECHO \ -"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... - -Complete the installation of libtool libraries. - -Each LIBDIR is a directory that contains libtool libraries. - -The commands that this mode executes may require superuser privileges. Use -the \`--dry-run' option if you just want to see what would be executed." - ;; - - install) - $ECHO \ -"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... - -Install executables or libraries. - -INSTALL-COMMAND is the installation command. The first component should be -either the \`install' or \`cp' program. - -The following components of INSTALL-COMMAND are treated specially: - - -inst-prefix PREFIX-DIR Use PREFIX-DIR as a staging area for installation - -The rest of the components are interpreted as arguments to that command (only -BSD-compatible install options are recognized)." - ;; - - link) - $ECHO \ -"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... - -Link object files or libraries together to form another library, or to -create an executable program. - -LINK-COMMAND is a command using the C compiler that you would use to create -a program from several object files. - -The following components of LINK-COMMAND are treated specially: - - -all-static do not do any dynamic linking at all - -avoid-version do not add a version suffix if possible - -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime - -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols - -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) - -export-symbols SYMFILE - try to export only the symbols listed in SYMFILE - -export-symbols-regex REGEX - try to export only the symbols matching REGEX - -LLIBDIR search LIBDIR for required installed libraries - -lNAME OUTPUT-FILE requires the installed library libNAME - -module build a library that can dlopened - -no-fast-install disable the fast-install mode - -no-install link a not-installable executable - -no-undefined declare that a library does not refer to external symbols - -o OUTPUT-FILE create OUTPUT-FILE from the specified objects - -objectlist FILE Use a list of object files found in FILE to specify objects - -precious-files-regex REGEX - don't remove output files matching REGEX - -release RELEASE specify package release information - -rpath LIBDIR the created library will eventually be installed in LIBDIR - -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries - -shared only do dynamic linking of libtool libraries - -shrext SUFFIX override the standard shared library file extension - -static do not do any dynamic linking of uninstalled libtool libraries - -static-libtool-libs - do not do any dynamic linking of libtool libraries - -version-info CURRENT[:REVISION[:AGE]] - specify library version info [each variable defaults to 0] - -weak LIBNAME declare that the target provides the LIBNAME interface - -All other options (arguments beginning with \`-') are ignored. - -Every other argument is treated as a filename. Files ending in \`.la' are -treated as uninstalled libtool libraries, other files are standard or library -object files. - -If the OUTPUT-FILE ends in \`.la', then a libtool library is created, -only library objects (\`.lo' files) may be specified, and \`-rpath' is -required, except when creating a convenience library. - -If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created -using \`ar' and \`ranlib', or on Windows using \`lib'. - -If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file -is created, otherwise an executable program is created." - ;; - - uninstall) - $ECHO \ -"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... - -Remove libraries from an installation directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, all the files associated with it are deleted. -Otherwise, only FILE itself is deleted using RM." - ;; - - *) - func_fatal_help "invalid operation mode \`$mode'" - ;; - esac - - $ECHO - $ECHO "Try \`$progname --help' for more information about other modes." - - exit $? -} - - # Now that we've collected a possible --mode arg, show help if necessary - $opt_help && func_mode_help - - -# func_mode_execute arg... -func_mode_execute () -{ - $opt_debug - # The first argument is the command name. - cmd="$nonopt" - test -z "$cmd" && \ - func_fatal_help "you must specify a COMMAND" - - # Handle -dlopen flags immediately. - for file in $execute_dlfiles; do - test -f "$file" \ - || func_fatal_help "\`$file' is not a file" - - dir= - case $file in - *.la) - # Check to see that this really is a libtool archive. - func_lalib_unsafe_p "$file" \ - || func_fatal_help "\`$lib' is not a valid libtool archive" - - # Read the libtool library. - dlname= - library_names= - func_source "$file" - - # Skip this library if it cannot be dlopened. - if test -z "$dlname"; then - # Warn if it was a shared library. - test -n "$library_names" && \ - func_warning "\`$file' was not linked with \`-export-dynamic'" - continue - fi - - func_dirname "$file" "" "." - dir="$func_dirname_result" - - if test -f "$dir/$objdir/$dlname"; then - dir="$dir/$objdir" - else - if test ! -f "$dir/$dlname"; then - func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" - fi - fi - ;; - - *.lo) - # Just add the directory containing the .lo file. - func_dirname "$file" "" "." - dir="$func_dirname_result" - ;; - - *) - func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" - continue - ;; - esac - - # Get the absolute pathname. - absdir=`cd "$dir" && pwd` - test -n "$absdir" && dir="$absdir" - - # Now add the directory to shlibpath_var. - if eval "test -z \"\$$shlibpath_var\""; then - eval "$shlibpath_var=\"\$dir\"" - else - eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" - fi - done - - # This variable tells wrapper scripts just to set shlibpath_var - # rather than running their programs. - libtool_execute_magic="$magic" - - # Check if any of the arguments is a wrapper script. - args= - for file - do - case $file in - -*) ;; - *) - # Do a test to see if this is really a libtool program. - if func_ltwrapper_script_p "$file"; then - func_source "$file" - # Transform arg to wrapped name. - file="$progdir/$program" - elif func_ltwrapper_executable_p "$file"; then - func_ltwrapper_scriptname "$file" - func_source "$func_ltwrapper_scriptname_result" - # Transform arg to wrapped name. - file="$progdir/$program" - fi - ;; - esac - # Quote arguments (to preserve shell metacharacters). - func_quote_for_eval "$file" - args="$args $func_quote_for_eval_result" - done - - if test "X$opt_dry_run" = Xfalse; then - if test -n "$shlibpath_var"; then - # Export the shlibpath_var. - eval "export $shlibpath_var" - fi - - # Restore saved environment variables - for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES - do - eval "if test \"\${save_$lt_var+set}\" = set; then - $lt_var=\$save_$lt_var; export $lt_var - else - $lt_unset $lt_var - fi" - done - - # Now prepare to actually exec the command. - exec_cmd="\$cmd$args" - else - # Display what would be done. - if test -n "$shlibpath_var"; then - eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" - $ECHO "export $shlibpath_var" - fi - $ECHO "$cmd$args" - exit $EXIT_SUCCESS - fi -} - -test "$mode" = execute && func_mode_execute ${1+"$@"} - - -# func_mode_finish arg... -func_mode_finish () -{ - $opt_debug - libdirs="$nonopt" - admincmds= - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - for dir - do - libdirs="$libdirs $dir" - done - - for libdir in $libdirs; do - if test -n "$finish_cmds"; then - # Do each command in the finish commands. - func_execute_cmds "$finish_cmds" 'admincmds="$admincmds -'"$cmd"'"' - fi - if test -n "$finish_eval"; then - # Do the single finish_eval. - eval cmds=\"$finish_eval\" - $opt_dry_run || eval "$cmds" || admincmds="$admincmds - $cmds" - fi - done - fi - - # Exit here if they wanted silent mode. - $opt_silent && exit $EXIT_SUCCESS - - $ECHO "X----------------------------------------------------------------------" | $Xsed - $ECHO "Libraries have been installed in:" - for libdir in $libdirs; do - $ECHO " $libdir" - done - $ECHO - $ECHO "If you ever happen to want to link against installed libraries" - $ECHO "in a given directory, LIBDIR, you must either use libtool, and" - $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'" - $ECHO "flag during linking and do at least one of the following:" - if test -n "$shlibpath_var"; then - $ECHO " - add LIBDIR to the \`$shlibpath_var' environment variable" - $ECHO " during execution" - fi - if test -n "$runpath_var"; then - $ECHO " - add LIBDIR to the \`$runpath_var' environment variable" - $ECHO " during linking" - fi - if test -n "$hardcode_libdir_flag_spec"; then - libdir=LIBDIR - eval flag=\"$hardcode_libdir_flag_spec\" - - $ECHO " - use the \`$flag' linker flag" - fi - if test -n "$admincmds"; then - $ECHO " - have your system administrator run these commands:$admincmds" - fi - if test -f /etc/ld.so.conf; then - $ECHO " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" - fi - $ECHO - - $ECHO "See any operating system documentation about shared libraries for" - case $host in - solaris2.[6789]|solaris2.1[0-9]) - $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual" - $ECHO "pages." - ;; - *) - $ECHO "more information, such as the ld(1) and ld.so(8) manual pages." - ;; - esac - $ECHO "X----------------------------------------------------------------------" | $Xsed - exit $EXIT_SUCCESS -} - -test "$mode" = finish && func_mode_finish ${1+"$@"} - - -# func_mode_install arg... -func_mode_install () -{ - $opt_debug - # There may be an optional sh(1) argument at the beginning of - # install_prog (especially on Windows NT). - if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || - # Allow the use of GNU shtool's install command. - $ECHO "X$nonopt" | $GREP shtool >/dev/null; then - # Aesthetically quote it. - func_quote_for_eval "$nonopt" - install_prog="$func_quote_for_eval_result " - arg=$1 - shift - else - install_prog= - arg=$nonopt - fi - - # The real first argument should be the name of the installation program. - # Aesthetically quote it. - func_quote_for_eval "$arg" - install_prog="$install_prog$func_quote_for_eval_result" - - # We need to accept at least all the BSD install flags. - dest= - files= - opts= - prev= - install_type= - isdir=no - stripme= - for arg - do - if test -n "$dest"; then - files="$files $dest" - dest=$arg - continue - fi - - case $arg in - -d) isdir=yes ;; - -f) - case " $install_prog " in - *[\\\ /]cp\ *) ;; - *) prev=$arg ;; - esac - ;; - -g | -m | -o) - prev=$arg - ;; - -s) - stripme=" -s" - continue - ;; - -*) - ;; - *) - # If the previous option needed an argument, then skip it. - if test -n "$prev"; then - prev= - else - dest=$arg - continue - fi - ;; - esac - - # Aesthetically quote the argument. - func_quote_for_eval "$arg" - install_prog="$install_prog $func_quote_for_eval_result" - done - - test -z "$install_prog" && \ - func_fatal_help "you must specify an install program" - - test -n "$prev" && \ - func_fatal_help "the \`$prev' option requires an argument" - - if test -z "$files"; then - if test -z "$dest"; then - func_fatal_help "no file or destination specified" - else - func_fatal_help "you must specify a destination" - fi - fi - - # Strip any trailing slash from the destination. - func_stripname '' '/' "$dest" - dest=$func_stripname_result - - # Check to see that the destination is a directory. - test -d "$dest" && isdir=yes - if test "$isdir" = yes; then - destdir="$dest" - destname= - else - func_dirname_and_basename "$dest" "" "." - destdir="$func_dirname_result" - destname="$func_basename_result" - - # Not a directory, so check to see that there is only one file specified. - set dummy $files; shift - test "$#" -gt 1 && \ - func_fatal_help "\`$dest' is not a directory" - fi - case $destdir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - for file in $files; do - case $file in - *.lo) ;; - *) - func_fatal_help "\`$destdir' must be an absolute directory name" - ;; - esac - done - ;; - esac - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - staticlibs= - future_libdirs= - current_libdirs= - for file in $files; do - - # Do each installation. - case $file in - *.$libext) - # Do the static libraries later. - staticlibs="$staticlibs $file" - ;; - - *.la) - # Check to see that this really is a libtool archive. - func_lalib_unsafe_p "$file" \ - || func_fatal_help "\`$file' is not a valid libtool archive" - - library_names= - old_library= - relink_command= - func_source "$file" - - # Add the libdir to current_libdirs if it is the destination. - if test "X$destdir" = "X$libdir"; then - case "$current_libdirs " in - *" $libdir "*) ;; - *) current_libdirs="$current_libdirs $libdir" ;; - esac - else - # Note the libdir as a future libdir. - case "$future_libdirs " in - *" $libdir "*) ;; - *) future_libdirs="$future_libdirs $libdir" ;; - esac - fi - - func_dirname "$file" "/" "" - dir="$func_dirname_result" - dir="$dir$objdir" - - if test -n "$relink_command"; then - # Determine the prefix the user has applied to our future dir. - inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"` - - # Don't allow the user to place us outside of our expected - # location b/c this prevents finding dependent libraries that - # are installed to the same prefix. - # At present, this check doesn't affect windows .dll's that - # are installed into $libdir/../bin (currently, that works fine) - # but it's something to keep an eye on. - test "$inst_prefix_dir" = "$destdir" && \ - func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" - - if test -n "$inst_prefix_dir"; then - # Stick the inst_prefix_dir data into the link command. - relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` - else - relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"` - fi - - func_warning "relinking \`$file'" - func_show_eval "$relink_command" \ - 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' - fi - - # See the names of the shared library. - set dummy $library_names; shift - if test -n "$1"; then - realname="$1" - shift - - srcname="$realname" - test -n "$relink_command" && srcname="$realname"T - - # Install the shared library and build the symlinks. - func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \ - 'exit $?' - tstripme="$stripme" - case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - case $realname in - *.dll.a) - tstripme="" - ;; - esac - ;; - esac - if test -n "$tstripme" && test -n "$striplib"; then - func_show_eval "$striplib $destdir/$realname" 'exit $?' - fi - - if test "$#" -gt 0; then - # Delete the old symlinks, and create new ones. - # Try `ln -sf' first, because the `ln' binary might depend on - # the symlink we replace! Solaris /bin/ln does not understand -f, - # so we also need to try rm && ln -s. - for linkname - do - test "$linkname" != "$realname" \ - && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" - done - fi - - # Do each command in the postinstall commands. - lib="$destdir/$realname" - func_execute_cmds "$postinstall_cmds" 'exit $?' - fi - - # Install the pseudo-library for information purposes. - func_basename "$file" - name="$func_basename_result" - instname="$dir/$name"i - func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' - - # Maybe install the static library, too. - test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" - ;; - - *.lo) - # Install (i.e. copy) a libtool object. - - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - func_basename "$file" - destfile="$func_basename_result" - destfile="$destdir/$destfile" - fi - - # Deduce the name of the destination old-style object file. - case $destfile in - *.lo) - func_lo2o "$destfile" - staticdest=$func_lo2o_result - ;; - *.$objext) - staticdest="$destfile" - destfile= - ;; - *) - func_fatal_help "cannot copy a libtool object to \`$destfile'" - ;; - esac - - # Install the libtool object if requested. - test -n "$destfile" && \ - func_show_eval "$install_prog $file $destfile" 'exit $?' - - # Install the old object if enabled. - if test "$build_old_libs" = yes; then - # Deduce the name of the old-style object file. - func_lo2o "$file" - staticobj=$func_lo2o_result - func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' - fi - exit $EXIT_SUCCESS - ;; - - *) - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - func_basename "$file" - destfile="$func_basename_result" - destfile="$destdir/$destfile" - fi - - # If the file is missing, and there is a .exe on the end, strip it - # because it is most likely a libtool script we actually want to - # install - stripped_ext="" - case $file in - *.exe) - if test ! -f "$file"; then - func_stripname '' '.exe' "$file" - file=$func_stripname_result - stripped_ext=".exe" - fi - ;; - esac - - # Do a test to see if this is really a libtool program. - case $host in - *cygwin* | *mingw*) - if func_ltwrapper_executable_p "$file"; then - func_ltwrapper_scriptname "$file" - wrapper=$func_ltwrapper_scriptname_result - else - func_stripname '' '.exe' "$file" - wrapper=$func_stripname_result - fi - ;; - *) - wrapper=$file - ;; - esac - if func_ltwrapper_script_p "$wrapper"; then - notinst_deplibs= - relink_command= - - func_source "$wrapper" - - # Check the variables that should have been set. - test -z "$generated_by_libtool_version" && \ - func_fatal_error "invalid libtool wrapper script \`$wrapper'" - - finalize=yes - for lib in $notinst_deplibs; do - # Check to see that each library is installed. - libdir= - if test -f "$lib"; then - func_source "$lib" - fi - libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test - if test -n "$libdir" && test ! -f "$libfile"; then - func_warning "\`$lib' has not been installed in \`$libdir'" - finalize=no - fi - done - - relink_command= - func_source "$wrapper" - - outputname= - if test "$fast_install" = no && test -n "$relink_command"; then - $opt_dry_run || { - if test "$finalize" = yes; then - tmpdir=`func_mktempdir` - func_basename "$file$stripped_ext" - file="$func_basename_result" - outputname="$tmpdir/$file" - # Replace the output file specification. - relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` - - $opt_silent || { - func_quote_for_expand "$relink_command" - eval "func_echo $func_quote_for_expand_result" - } - if eval "$relink_command"; then : - else - func_error "error: relink \`$file' with the above command before installing it" - $opt_dry_run || ${RM}r "$tmpdir" - continue - fi - file="$outputname" - else - func_warning "cannot relink \`$file'" - fi - } - else - # Install the binary that we compiled earlier. - file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` - fi - fi - - # remove .exe since cygwin /usr/bin/install will append another - # one anyway - case $install_prog,$host in - */usr/bin/install*,*cygwin*) - case $file:$destfile in - *.exe:*.exe) - # this is ok - ;; - *.exe:*) - destfile=$destfile.exe - ;; - *:*.exe) - func_stripname '' '.exe' "$destfile" - destfile=$func_stripname_result - ;; - esac - ;; - esac - func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' - $opt_dry_run || if test -n "$outputname"; then - ${RM}r "$tmpdir" - fi - ;; - esac - done - - for file in $staticlibs; do - func_basename "$file" - name="$func_basename_result" - - # Set up the ranlib parameters. - oldlib="$destdir/$name" - - func_show_eval "$install_prog \$file \$oldlib" 'exit $?' - - if test -n "$stripme" && test -n "$old_striplib"; then - func_show_eval "$old_striplib $oldlib" 'exit $?' - fi - - # Do each command in the postinstall commands. - func_execute_cmds "$old_postinstall_cmds" 'exit $?' - done - - test -n "$future_libdirs" && \ - func_warning "remember to run \`$progname --finish$future_libdirs'" - - if test -n "$current_libdirs"; then - # Maybe just do a dry run. - $opt_dry_run && current_libdirs=" -n$current_libdirs" - exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' - else - exit $EXIT_SUCCESS - fi -} - -test "$mode" = install && func_mode_install ${1+"$@"} - - -# func_generate_dlsyms outputname originator pic_p -# Extract symbols from dlprefiles and create ${outputname}S.o with -# a dlpreopen symbol table. -func_generate_dlsyms () -{ - $opt_debug - my_outputname="$1" - my_originator="$2" - my_pic_p="${3-no}" - my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` - my_dlsyms= - - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - if test -n "$NM" && test -n "$global_symbol_pipe"; then - my_dlsyms="${my_outputname}S.c" - else - func_error "not configured to extract global symbols from dlpreopened files" - fi - fi - - if test -n "$my_dlsyms"; then - case $my_dlsyms in - "") ;; - *.c) - # Discover the nlist of each of the dlfiles. - nlist="$output_objdir/${my_outputname}.nm" - - func_show_eval "$RM $nlist ${nlist}S ${nlist}T" - - # Parse the name list into a source file. - func_verbose "creating $output_objdir/$my_dlsyms" - - $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ -/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ -/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ - -#ifdef __cplusplus -extern \"C\" { -#endif - -/* External symbol declarations for the compiler. */\ -" - - if test "$dlself" = yes; then - func_verbose "generating symbol list for \`$output'" - - $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" - - # Add our own program objects to the symbol list. - progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - for progfile in $progfiles; do - func_verbose "extracting global C symbols from \`$progfile'" - $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'" - done - - if test -n "$exclude_expsyms"; then - $opt_dry_run || { - eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' - eval '$MV "$nlist"T "$nlist"' - } - fi - - if test -n "$export_symbols_regex"; then - $opt_dry_run || { - eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' - eval '$MV "$nlist"T "$nlist"' - } - fi - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - export_symbols="$output_objdir/$outputname.exp" - $opt_dry_run || { - $RM $export_symbols - eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' - case $host in - *cygwin* | *mingw* | *cegcc* ) - eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' - eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' - ;; - esac - } - else - $opt_dry_run || { - eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' - eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' - eval '$MV "$nlist"T "$nlist"' - case $host in - *cygwin | *mingw* | *cegcc* ) - eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' - eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' - ;; - esac - } - fi - fi - - for dlprefile in $dlprefiles; do - func_verbose "extracting global C symbols from \`$dlprefile'" - func_basename "$dlprefile" - name="$func_basename_result" - $opt_dry_run || { - eval '$ECHO ": $name " >> "$nlist"' - eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'" - } - done - - $opt_dry_run || { - # Make sure we have at least an empty file. - test -f "$nlist" || : > "$nlist" - - if test -n "$exclude_expsyms"; then - $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T - $MV "$nlist"T "$nlist" - fi - - # Try sorting and uniquifying the output. - if $GREP -v "^: " < "$nlist" | - if sort -k 3 /dev/null 2>&1; then - sort -k 3 - else - sort +2 - fi | - uniq > "$nlist"S; then - : - else - $GREP -v "^: " < "$nlist" > "$nlist"S - fi - - if test -f "$nlist"S; then - eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' - else - $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms" - fi - - $ECHO >> "$output_objdir/$my_dlsyms" "\ - -/* The mapping between symbol names and symbols. */ -typedef struct { - const char *name; - void *address; -} lt_dlsymlist; -" - case $host in - *cygwin* | *mingw* | *cegcc* ) - $ECHO >> "$output_objdir/$my_dlsyms" "\ -/* DATA imports from DLLs on WIN32 con't be const, because - runtime relocations are performed -- see ld's documentation - on pseudo-relocs. */" - lt_dlsym_const= ;; - *osf5*) - echo >> "$output_objdir/$my_dlsyms" "\ -/* This system does not cope well with relocations in const data */" - lt_dlsym_const= ;; - *) - lt_dlsym_const=const ;; - esac - - $ECHO >> "$output_objdir/$my_dlsyms" "\ -extern $lt_dlsym_const lt_dlsymlist -lt_${my_prefix}_LTX_preloaded_symbols[]; -$lt_dlsym_const lt_dlsymlist -lt_${my_prefix}_LTX_preloaded_symbols[] = -{\ - { \"$my_originator\", (void *) 0 }," - - case $need_lib_prefix in - no) - eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" - ;; - *) - eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" - ;; - esac - $ECHO >> "$output_objdir/$my_dlsyms" "\ - {0, (void *) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt_${my_prefix}_LTX_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif\ -" - } # !$opt_dry_run - - pic_flag_for_symtable= - case "$compile_command " in - *" -static "*) ;; - *) - case $host in - # compiling the symbol table file with pic_flag works around - # a FreeBSD bug that causes programs to crash when -lm is - # linked before any other PIC object. But we must not use - # pic_flag when linking with -static. The problem exists in - # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. - *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) - pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; - *-*-hpux*) - pic_flag_for_symtable=" $pic_flag" ;; - *) - if test "X$my_pic_p" != Xno; then - pic_flag_for_symtable=" $pic_flag" - fi - ;; - esac - ;; - esac - symtab_cflags= - for arg in $LTCFLAGS; do - case $arg in - -pie | -fpie | -fPIE) ;; - *) symtab_cflags="$symtab_cflags $arg" ;; - esac - done - - # Now compile the dynamic symbol file. - func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' - - # Clean up the generated files. - func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' - - # Transform the symbol file into the correct name. - symfileobj="$output_objdir/${my_outputname}S.$objext" - case $host in - *cygwin* | *mingw* | *cegcc* ) - if test -f "$output_objdir/$my_outputname.def"; then - compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` - finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` - else - compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` - finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` - fi - ;; - *) - compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` - finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` - ;; - esac - ;; - *) - func_fatal_error "unknown suffix for \`$my_dlsyms'" - ;; - esac - else - # We keep going just in case the user didn't refer to - # lt_preloaded_symbols. The linker will fail if global_symbol_pipe - # really was required. - - # Nullify the symbol file. - compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` - finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` - fi -} - -# func_win32_libid arg -# return the library type of file 'arg' -# -# Need a lot of goo to handle *both* DLLs and import libs -# Has to be a shell function in order to 'eat' the argument -# that is supplied when $file_magic_command is called. -func_win32_libid () -{ - $opt_debug - win32_libid_type="unknown" - win32_fileres=`file -L $1 2>/dev/null` - case $win32_fileres in - *ar\ archive\ import\ library*) # definitely import - win32_libid_type="x86 archive import" - ;; - *ar\ archive*) # could be an import, or static - if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | - $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null ; then - win32_nmres=`eval $NM -f posix -A $1 | - $SED -n -e ' - 1,100{ - / I /{ - s,.*,import, - p - q - } - }'` - case $win32_nmres in - import*) win32_libid_type="x86 archive import";; - *) win32_libid_type="x86 archive static";; - esac - fi - ;; - *DLL*) - win32_libid_type="x86 DLL" - ;; - *executable*) # but shell scripts are "executable" too... - case $win32_fileres in - *MS\ Windows\ PE\ Intel*) - win32_libid_type="x86 DLL" - ;; - esac - ;; - esac - $ECHO "$win32_libid_type" -} - - - -# func_extract_an_archive dir oldlib -func_extract_an_archive () -{ - $opt_debug - f_ex_an_ar_dir="$1"; shift - f_ex_an_ar_oldlib="$1" - func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?' - if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then - : - else - func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" - fi -} - - -# func_extract_archives gentop oldlib ... -func_extract_archives () -{ - $opt_debug - my_gentop="$1"; shift - my_oldlibs=${1+"$@"} - my_oldobjs="" - my_xlib="" - my_xabs="" - my_xdir="" - - for my_xlib in $my_oldlibs; do - # Extract the objects. - case $my_xlib in - [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; - *) my_xabs=`pwd`"/$my_xlib" ;; - esac - func_basename "$my_xlib" - my_xlib="$func_basename_result" - my_xlib_u=$my_xlib - while :; do - case " $extracted_archives " in - *" $my_xlib_u "*) - func_arith $extracted_serial + 1 - extracted_serial=$func_arith_result - my_xlib_u=lt$extracted_serial-$my_xlib ;; - *) break ;; - esac - done - extracted_archives="$extracted_archives $my_xlib_u" - my_xdir="$my_gentop/$my_xlib_u" - - func_mkdir_p "$my_xdir" - - case $host in - *-darwin*) - func_verbose "Extracting $my_xabs" - # Do not bother doing anything if just a dry run - $opt_dry_run || { - darwin_orig_dir=`pwd` - cd $my_xdir || exit $? - darwin_archive=$my_xabs - darwin_curdir=`pwd` - darwin_base_archive=`basename "$darwin_archive"` - darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` - if test -n "$darwin_arches"; then - darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` - darwin_arch= - func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" - for darwin_arch in $darwin_arches ; do - func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" - $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" - cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" - func_extract_an_archive "`pwd`" "${darwin_base_archive}" - cd "$darwin_curdir" - $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" - done # $darwin_arches - ## Okay now we've a bunch of thin objects, gotta fatten them up :) - darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` - darwin_file= - darwin_files= - for darwin_file in $darwin_filelist; do - darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` - $LIPO -create -output "$darwin_file" $darwin_files - done # $darwin_filelist - $RM -rf unfat-$$ - cd "$darwin_orig_dir" - else - cd $darwin_orig_dir - func_extract_an_archive "$my_xdir" "$my_xabs" - fi # $darwin_arches - } # !$opt_dry_run - ;; - *) - func_extract_an_archive "$my_xdir" "$my_xabs" - ;; - esac - my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` - done - - func_extract_archives_result="$my_oldobjs" -} - - - -# func_emit_wrapper_part1 [arg=no] -# -# Emit the first part of a libtool wrapper script on stdout. -# For more information, see the description associated with -# func_emit_wrapper(), below. -func_emit_wrapper_part1 () -{ - func_emit_wrapper_part1_arg1=no - if test -n "$1" ; then - func_emit_wrapper_part1_arg1=$1 - fi - - $ECHO "\ -#! $SHELL - -# $output - temporary wrapper script for $objdir/$outputname -# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION -# -# The $output program cannot be directly executed until all the libtool -# libraries that it depends on are installed. -# -# This wrapper script should never be moved out of the build directory. -# If it is, it will not operate correctly. - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='${SED} -e 1s/^X//' -sed_quote_subst='$sed_quote_subst' - -# Be Bourne compatible -if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac -fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -relink_command=\"$relink_command\" - -# This environment variable determines our operation mode. -if test \"\$libtool_install_magic\" = \"$magic\"; then - # install mode needs the following variables: - generated_by_libtool_version='$macro_version' - notinst_deplibs='$notinst_deplibs' -else - # When we are sourced in execute mode, \$file and \$ECHO are already set. - if test \"\$libtool_execute_magic\" != \"$magic\"; then - ECHO=\"$qecho\" - file=\"\$0\" - # Make sure echo works. - if test \"X\$1\" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift - elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then - # Yippee, \$ECHO works! - : - else - # Restart under the correct shell, and then maybe \$ECHO will work. - exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} - fi - fi\ -" - $ECHO "\ - - # Find the directory that this script lives in. - thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` - test \"x\$thisdir\" = \"x\$file\" && thisdir=. - - # Follow symbolic links until we get to the real thisdir. - file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` - while test -n \"\$file\"; do - destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` - - # If there was a directory component, then change thisdir. - if test \"x\$destdir\" != \"x\$file\"; then - case \"\$destdir\" in - [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; - *) thisdir=\"\$thisdir/\$destdir\" ;; - esac - fi - - file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` - done -" -} -# end: func_emit_wrapper_part1 - -# func_emit_wrapper_part2 [arg=no] -# -# Emit the second part of a libtool wrapper script on stdout. -# For more information, see the description associated with -# func_emit_wrapper(), below. -func_emit_wrapper_part2 () -{ - func_emit_wrapper_part2_arg1=no - if test -n "$1" ; then - func_emit_wrapper_part2_arg1=$1 - fi - - $ECHO "\ - - # Usually 'no', except on cygwin/mingw when embedded into - # the cwrapper. - WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1 - if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then - # special case for '.' - if test \"\$thisdir\" = \".\"; then - thisdir=\`pwd\` - fi - # remove .libs from thisdir - case \"\$thisdir\" in - *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;; - $objdir ) thisdir=. ;; - esac - fi - - # Try to get the absolute directory name. - absdir=\`cd \"\$thisdir\" && pwd\` - test -n \"\$absdir\" && thisdir=\"\$absdir\" -" - - if test "$fast_install" = yes; then - $ECHO "\ - program=lt-'$outputname'$exeext - progdir=\"\$thisdir/$objdir\" - - if test ! -f \"\$progdir/\$program\" || - { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ - test \"X\$file\" != \"X\$progdir/\$program\"; }; then - - file=\"\$\$-\$program\" - - if test ! -d \"\$progdir\"; then - $MKDIR \"\$progdir\" - else - $RM \"\$progdir/\$file\" - fi" - - $ECHO "\ - - # relink executable if necessary - if test -n \"\$relink_command\"; then - if relink_command_output=\`eval \$relink_command 2>&1\`; then : - else - $ECHO \"\$relink_command_output\" >&2 - $RM \"\$progdir/\$file\" - exit 1 - fi - fi - - $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || - { $RM \"\$progdir/\$program\"; - $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } - $RM \"\$progdir/\$file\" - fi" - else - $ECHO "\ - program='$outputname' - progdir=\"\$thisdir/$objdir\" -" - fi - - $ECHO "\ - - if test -f \"\$progdir/\$program\"; then" - - # Export our shlibpath_var if we have one. - if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then - $ECHO "\ - # Add our own library path to $shlibpath_var - $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" - - # Some systems cannot cope with colon-terminated $shlibpath_var - # The second colon is a workaround for a bug in BeOS R4 sed - $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` - - export $shlibpath_var -" - fi - - # fixup the dll searchpath if we need to. - if test -n "$dllsearchpath"; then - $ECHO "\ - # Add the dll search path components to the executable PATH - PATH=$dllsearchpath:\$PATH -" - fi - - $ECHO "\ - if test \"\$libtool_execute_magic\" != \"$magic\"; then - # Run the actual program with our arguments. -" - case $host in - # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2* | *-cegcc*) - $ECHO "\ - exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} -" - ;; - - *) - $ECHO "\ - exec \"\$progdir/\$program\" \${1+\"\$@\"} -" - ;; - esac - $ECHO "\ - \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 - exit 1 - fi - else - # The program doesn't exist. - \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 - \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 - $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 - exit 1 - fi -fi\ -" -} -# end: func_emit_wrapper_part2 - - -# func_emit_wrapper [arg=no] -# -# Emit a libtool wrapper script on stdout. -# Don't directly open a file because we may want to -# incorporate the script contents within a cygwin/mingw -# wrapper executable. Must ONLY be called from within -# func_mode_link because it depends on a number of variables -# set therein. -# -# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR -# variable will take. If 'yes', then the emitted script -# will assume that the directory in which it is stored is -# the $objdir directory. This is a cygwin/mingw-specific -# behavior. -func_emit_wrapper () -{ - func_emit_wrapper_arg1=no - if test -n "$1" ; then - func_emit_wrapper_arg1=$1 - fi - - # split this up so that func_emit_cwrapperexe_src - # can call each part independently. - func_emit_wrapper_part1 "${func_emit_wrapper_arg1}" - func_emit_wrapper_part2 "${func_emit_wrapper_arg1}" -} - - -# func_to_host_path arg -# -# Convert paths to host format when used with build tools. -# Intended for use with "native" mingw (where libtool itself -# is running under the msys shell), or in the following cross- -# build environments: -# $build $host -# mingw (msys) mingw [e.g. native] -# cygwin mingw -# *nix + wine mingw -# where wine is equipped with the `winepath' executable. -# In the native mingw case, the (msys) shell automatically -# converts paths for any non-msys applications it launches, -# but that facility isn't available from inside the cwrapper. -# Similar accommodations are necessary for $host mingw and -# $build cygwin. Calling this function does no harm for other -# $host/$build combinations not listed above. -# -# ARG is the path (on $build) that should be converted to -# the proper representation for $host. The result is stored -# in $func_to_host_path_result. -func_to_host_path () -{ - func_to_host_path_result="$1" - if test -n "$1" ; then - case $host in - *mingw* ) - lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' - case $build in - *mingw* ) # actually, msys - # awkward: cmd appends spaces to result - lt_sed_strip_trailing_spaces="s/[ ]*\$//" - func_to_host_path_tmp1=`( cmd //c echo "$1" |\ - $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""` - func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ - $SED -e "$lt_sed_naive_backslashify"` - ;; - *cygwin* ) - func_to_host_path_tmp1=`cygpath -w "$1"` - func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ - $SED -e "$lt_sed_naive_backslashify"` - ;; - * ) - # Unfortunately, winepath does not exit with a non-zero - # error code, so we are forced to check the contents of - # stdout. On the other hand, if the command is not - # found, the shell will set an exit code of 127 and print - # *an error message* to stdout. So we must check for both - # error code of zero AND non-empty stdout, which explains - # the odd construction: - func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null` - if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then - func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ - $SED -e "$lt_sed_naive_backslashify"` - else - # Allow warning below. - func_to_host_path_result="" - fi - ;; - esac - if test -z "$func_to_host_path_result" ; then - #func_error "Could not determine host path corresponding to" - #func_error " '$1'" - #func_error "Continuing, but uninstalled executables may not work." - # Fallback: - func_to_host_path_result="$1" - fi - ;; - esac - fi -} -# end: func_to_host_path - -# func_to_host_pathlist arg -# -# Convert pathlists to host format when used with build tools. -# See func_to_host_path(), above. This function supports the -# following $build/$host combinations (but does no harm for -# combinations not listed here): -# $build $host -# mingw (msys) mingw [e.g. native] -# cygwin mingw -# *nix + wine mingw -# -# Path separators are also converted from $build format to -# $host format. If ARG begins or ends with a path separator -# character, it is preserved (but converted to $host format) -# on output. -# -# ARG is a pathlist (on $build) that should be converted to -# the proper representation on $host. The result is stored -# in $func_to_host_pathlist_result. -func_to_host_pathlist () -{ - func_to_host_pathlist_result="$1" - if test -n "$1" ; then - case $host in - *mingw* ) - lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' - # Remove leading and trailing path separator characters from - # ARG. msys behavior is inconsistent here, cygpath turns them - # into '.;' and ';.', and winepath ignores them completely. - func_to_host_pathlist_tmp2="$1" - # Once set for this call, this variable should not be - # reassigned. It is used in tha fallback case. - func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\ - $SED -e 's|^:*||' -e 's|:*$||'` - case $build in - *mingw* ) # Actually, msys. - # Awkward: cmd appends spaces to result. - lt_sed_strip_trailing_spaces="s/[ ]*\$//" - func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\ - $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""` - func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\ - $SED -e "$lt_sed_naive_backslashify"` - ;; - *cygwin* ) - func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"` - func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\ - $SED -e "$lt_sed_naive_backslashify"` - ;; - * ) - # unfortunately, winepath doesn't convert pathlists - func_to_host_pathlist_result="" - func_to_host_pathlist_oldIFS=$IFS - IFS=: - for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do - IFS=$func_to_host_pathlist_oldIFS - if test -n "$func_to_host_pathlist_f" ; then - func_to_host_path "$func_to_host_pathlist_f" - if test -n "$func_to_host_path_result" ; then - if test -z "$func_to_host_pathlist_result" ; then - func_to_host_pathlist_result="$func_to_host_path_result" - else - func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result" - fi - fi - fi - IFS=: - done - IFS=$func_to_host_pathlist_oldIFS - ;; - esac - if test -z "$func_to_host_pathlist_result" ; then - func_error "Could not determine the host path(s) corresponding to" - func_error " '$1'" - func_error "Continuing, but uninstalled executables may not work." - # Fallback. This may break if $1 contains DOS-style drive - # specifications. The fix is not to complicate the expression - # below, but for the user to provide a working wine installation - # with winepath so that path translation in the cross-to-mingw - # case works properly. - lt_replace_pathsep_nix_to_dos="s|:|;|g" - func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\ - $SED -e "$lt_replace_pathsep_nix_to_dos"` - fi - # Now, add the leading and trailing path separators back - case "$1" in - :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result" - ;; - esac - case "$1" in - *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;" - ;; - esac - ;; - esac - fi -} -# end: func_to_host_pathlist - -# func_emit_cwrapperexe_src -# emit the source code for a wrapper executable on stdout -# Must ONLY be called from within func_mode_link because -# it depends on a number of variable set therein. -func_emit_cwrapperexe_src () -{ - cat < -#include -#ifdef _MSC_VER -# include -# include -# include -# define setmode _setmode -#else -# include -# include -# ifdef __CYGWIN__ -# include -# define HAVE_SETENV -# ifdef __STRICT_ANSI__ -char *realpath (const char *, char *); -int putenv (char *); -int setenv (const char *, const char *, int); -# endif -# endif -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(PATH_MAX) -# define LT_PATHMAX PATH_MAX -#elif defined(MAXPATHLEN) -# define LT_PATHMAX MAXPATHLEN -#else -# define LT_PATHMAX 1024 -#endif - -#ifndef S_IXOTH -# define S_IXOTH 0 -#endif -#ifndef S_IXGRP -# define S_IXGRP 0 -#endif - -#ifdef _MSC_VER -# define S_IXUSR _S_IEXEC -# define stat _stat -# ifndef _INTPTR_T_DEFINED -# define intptr_t int -# endif -#endif - -#ifndef DIR_SEPARATOR -# define DIR_SEPARATOR '/' -# define PATH_SEPARATOR ':' -#endif - -#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ - defined (__OS2__) -# define HAVE_DOS_BASED_FILE_SYSTEM -# define FOPEN_WB "wb" -# ifndef DIR_SEPARATOR_2 -# define DIR_SEPARATOR_2 '\\' -# endif -# ifndef PATH_SEPARATOR_2 -# define PATH_SEPARATOR_2 ';' -# endif -#endif - -#ifndef DIR_SEPARATOR_2 -# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) -#else /* DIR_SEPARATOR_2 */ -# define IS_DIR_SEPARATOR(ch) \ - (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) -#endif /* DIR_SEPARATOR_2 */ - -#ifndef PATH_SEPARATOR_2 -# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) -#else /* PATH_SEPARATOR_2 */ -# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) -#endif /* PATH_SEPARATOR_2 */ - -#ifdef __CYGWIN__ -# define FOPEN_WB "wb" -#endif - -#ifndef FOPEN_WB -# define FOPEN_WB "w" -#endif -#ifndef _O_BINARY -# define _O_BINARY 0 -#endif - -#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) -#define XFREE(stale) do { \ - if (stale) { free ((void *) stale); stale = 0; } \ -} while (0) - -#undef LTWRAPPER_DEBUGPRINTF -#if defined DEBUGWRAPPER -# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args -static void -ltwrapper_debugprintf (const char *fmt, ...) -{ - va_list args; - va_start (args, fmt); - (void) vfprintf (stderr, fmt, args); - va_end (args); -} -#else -# define LTWRAPPER_DEBUGPRINTF(args) -#endif - -const char *program_name = NULL; - -void *xmalloc (size_t num); -char *xstrdup (const char *string); -const char *base_name (const char *name); -char *find_executable (const char *wrapper); -char *chase_symlinks (const char *pathspec); -int make_executable (const char *path); -int check_executable (const char *path); -char *strendzap (char *str, const char *pat); -void lt_fatal (const char *message, ...); -void lt_setenv (const char *name, const char *value); -char *lt_extend_str (const char *orig_value, const char *add, int to_end); -void lt_opt_process_env_set (const char *arg); -void lt_opt_process_env_prepend (const char *arg); -void lt_opt_process_env_append (const char *arg); -int lt_split_name_value (const char *arg, char** name, char** value); -void lt_update_exe_path (const char *name, const char *value); -void lt_update_lib_path (const char *name, const char *value); - -static const char *script_text_part1 = -EOF - - func_emit_wrapper_part1 yes | - $SED -e 's/\([\\"]\)/\\\1/g' \ - -e 's/^/ "/' -e 's/$/\\n"/' - echo ";" - cat <"))); - for (i = 0; i < newargc; i++) - { - LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, (newargz[i] ? newargz[i] : ""))); - } - -EOF - - case $host_os in - mingw*) - cat <<"EOF" - /* execv doesn't actually work on mingw as expected on unix */ - rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); - if (rval == -1) - { - /* failed to start process */ - LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno)); - return 127; - } - return rval; -EOF - ;; - *) - cat <<"EOF" - execv (lt_argv_zero, newargz); - return rval; /* =127, but avoids unused variable warning */ -EOF - ;; - esac - - cat <<"EOF" -} - -void * -xmalloc (size_t num) -{ - void *p = (void *) malloc (num); - if (!p) - lt_fatal ("Memory exhausted"); - - return p; -} - -char * -xstrdup (const char *string) -{ - return string ? strcpy ((char *) xmalloc (strlen (string) + 1), - string) : NULL; -} - -const char * -base_name (const char *name) -{ - const char *base; - -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) - /* Skip over the disk name in MSDOS pathnames. */ - if (isalpha ((unsigned char) name[0]) && name[1] == ':') - name += 2; -#endif - - for (base = name; *name; name++) - if (IS_DIR_SEPARATOR (*name)) - base = name + 1; - return base; -} - -int -check_executable (const char *path) -{ - struct stat st; - - LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n", - path ? (*path ? path : "EMPTY!") : "NULL!")); - if ((!path) || (!*path)) - return 0; - - if ((stat (path, &st) >= 0) - && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) - return 1; - else - return 0; -} - -int -make_executable (const char *path) -{ - int rval = 0; - struct stat st; - - LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n", - path ? (*path ? path : "EMPTY!") : "NULL!")); - if ((!path) || (!*path)) - return 0; - - if (stat (path, &st) >= 0) - { - rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); - } - return rval; -} - -/* Searches for the full path of the wrapper. Returns - newly allocated full path name if found, NULL otherwise - Does not chase symlinks, even on platforms that support them. -*/ -char * -find_executable (const char *wrapper) -{ - int has_slash = 0; - const char *p; - const char *p_next; - /* static buffer for getcwd */ - char tmp[LT_PATHMAX + 1]; - int tmp_len; - char *concat_name; - - LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n", - wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!")); - - if ((wrapper == NULL) || (*wrapper == '\0')) - return NULL; - - /* Absolute path? */ -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) - if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') - { - concat_name = xstrdup (wrapper); - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - } - else - { -#endif - if (IS_DIR_SEPARATOR (wrapper[0])) - { - concat_name = xstrdup (wrapper); - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - } -#if defined (HAVE_DOS_BASED_FILE_SYSTEM) - } -#endif - - for (p = wrapper; *p; p++) - if (*p == '/') - { - has_slash = 1; - break; - } - if (!has_slash) - { - /* no slashes; search PATH */ - const char *path = getenv ("PATH"); - if (path != NULL) - { - for (p = path; *p; p = p_next) - { - const char *q; - size_t p_len; - for (q = p; *q; q++) - if (IS_PATH_SEPARATOR (*q)) - break; - p_len = q - p; - p_next = (*q == '\0' ? q : q + 1); - if (p_len == 0) - { - /* empty path: current directory */ - if (getcwd (tmp, LT_PATHMAX) == NULL) - lt_fatal ("getcwd failed"); - tmp_len = strlen (tmp); - concat_name = - XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); - memcpy (concat_name, tmp, tmp_len); - concat_name[tmp_len] = '/'; - strcpy (concat_name + tmp_len + 1, wrapper); - } - else - { - concat_name = - XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); - memcpy (concat_name, p, p_len); - concat_name[p_len] = '/'; - strcpy (concat_name + p_len + 1, wrapper); - } - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - } - } - /* not found in PATH; assume curdir */ - } - /* Relative path | not found in path: prepend cwd */ - if (getcwd (tmp, LT_PATHMAX) == NULL) - lt_fatal ("getcwd failed"); - tmp_len = strlen (tmp); - concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); - memcpy (concat_name, tmp, tmp_len); - concat_name[tmp_len] = '/'; - strcpy (concat_name + tmp_len + 1, wrapper); - - if (check_executable (concat_name)) - return concat_name; - XFREE (concat_name); - return NULL; -} - -char * -chase_symlinks (const char *pathspec) -{ -#ifndef S_ISLNK - return xstrdup (pathspec); -#else - char buf[LT_PATHMAX]; - struct stat s; - char *tmp_pathspec = xstrdup (pathspec); - char *p; - int has_symlinks = 0; - while (strlen (tmp_pathspec) && !has_symlinks) - { - LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n", - tmp_pathspec)); - if (lstat (tmp_pathspec, &s) == 0) - { - if (S_ISLNK (s.st_mode) != 0) - { - has_symlinks = 1; - break; - } - - /* search backwards for last DIR_SEPARATOR */ - p = tmp_pathspec + strlen (tmp_pathspec) - 1; - while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) - p--; - if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) - { - /* no more DIR_SEPARATORS left */ - break; - } - *p = '\0'; - } - else - { - char *errstr = strerror (errno); - lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr); - } - } - XFREE (tmp_pathspec); - - if (!has_symlinks) - { - return xstrdup (pathspec); - } - - tmp_pathspec = realpath (pathspec, buf); - if (tmp_pathspec == 0) - { - lt_fatal ("Could not follow symlinks for %s", pathspec); - } - return xstrdup (tmp_pathspec); -#endif -} - -char * -strendzap (char *str, const char *pat) -{ - size_t len, patlen; - - assert (str != NULL); - assert (pat != NULL); - - len = strlen (str); - patlen = strlen (pat); - - if (patlen <= len) - { - str += len - patlen; - if (strcmp (str, pat) == 0) - *str = '\0'; - } - return str; -} - -static void -lt_error_core (int exit_status, const char *mode, - const char *message, va_list ap) -{ - fprintf (stderr, "%s: %s: ", program_name, mode); - vfprintf (stderr, message, ap); - fprintf (stderr, ".\n"); - - if (exit_status >= 0) - exit (exit_status); -} - -void -lt_fatal (const char *message, ...) -{ - va_list ap; - va_start (ap, message); - lt_error_core (EXIT_FAILURE, "FATAL", message, ap); - va_end (ap); -} - -void -lt_setenv (const char *name, const char *value) -{ - LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n", - (name ? name : ""), - (value ? value : ""))); - { -#ifdef HAVE_SETENV - /* always make a copy, for consistency with !HAVE_SETENV */ - char *str = xstrdup (value); - setenv (name, str, 1); -#else - int len = strlen (name) + 1 + strlen (value) + 1; - char *str = XMALLOC (char, len); - sprintf (str, "%s=%s", name, value); - if (putenv (str) != EXIT_SUCCESS) - { - XFREE (str); - } -#endif - } -} - -char * -lt_extend_str (const char *orig_value, const char *add, int to_end) -{ - char *new_value; - if (orig_value && *orig_value) - { - int orig_value_len = strlen (orig_value); - int add_len = strlen (add); - new_value = XMALLOC (char, add_len + orig_value_len + 1); - if (to_end) - { - strcpy (new_value, orig_value); - strcpy (new_value + orig_value_len, add); - } - else - { - strcpy (new_value, add); - strcpy (new_value + add_len, orig_value); - } - } - else - { - new_value = xstrdup (add); - } - return new_value; -} - -int -lt_split_name_value (const char *arg, char** name, char** value) -{ - const char *p; - int len; - if (!arg || !*arg) - return 1; - - p = strchr (arg, (int)'='); - - if (!p) - return 1; - - *value = xstrdup (++p); - - len = strlen (arg) - strlen (*value); - *name = XMALLOC (char, len); - strncpy (*name, arg, len-1); - (*name)[len - 1] = '\0'; - - return 0; -} - -void -lt_opt_process_env_set (const char *arg) -{ - char *name = NULL; - char *value = NULL; - - if (lt_split_name_value (arg, &name, &value) != 0) - { - XFREE (name); - XFREE (value); - lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg); - } - - lt_setenv (name, value); - XFREE (name); - XFREE (value); -} - -void -lt_opt_process_env_prepend (const char *arg) -{ - char *name = NULL; - char *value = NULL; - char *new_value = NULL; - - if (lt_split_name_value (arg, &name, &value) != 0) - { - XFREE (name); - XFREE (value); - lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg); - } - - new_value = lt_extend_str (getenv (name), value, 0); - lt_setenv (name, new_value); - XFREE (new_value); - XFREE (name); - XFREE (value); -} - -void -lt_opt_process_env_append (const char *arg) -{ - char *name = NULL; - char *value = NULL; - char *new_value = NULL; - - if (lt_split_name_value (arg, &name, &value) != 0) - { - XFREE (name); - XFREE (value); - lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg); - } - - new_value = lt_extend_str (getenv (name), value, 1); - lt_setenv (name, new_value); - XFREE (new_value); - XFREE (name); - XFREE (value); -} - -void -lt_update_exe_path (const char *name, const char *value) -{ - LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n", - (name ? name : ""), - (value ? value : ""))); - - if (name && *name && value && *value) - { - char *new_value = lt_extend_str (getenv (name), value, 0); - /* some systems can't cope with a ':'-terminated path #' */ - int len = strlen (new_value); - while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) - { - new_value[len-1] = '\0'; - } - lt_setenv (name, new_value); - XFREE (new_value); - } -} - -void -lt_update_lib_path (const char *name, const char *value) -{ - LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n", - (name ? name : ""), - (value ? value : ""))); - - if (name && *name && value && *value) - { - char *new_value = lt_extend_str (getenv (name), value, 0); - lt_setenv (name, new_value); - XFREE (new_value); - } -} - - -EOF -} -# end: func_emit_cwrapperexe_src - -# func_mode_link arg... -func_mode_link () -{ - $opt_debug - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - # It is impossible to link a dll without this setting, and - # we shouldn't force the makefile maintainer to figure out - # which system we are compiling for in order to pass an extra - # flag for every libtool invocation. - # allow_undefined=no - - # FIXME: Unfortunately, there are problems with the above when trying - # to make a dll which has undefined symbols, in which case not - # even a static library is built. For now, we need to specify - # -no-undefined on the libtool link line when we can be certain - # that all symbols are satisfied, otherwise we get a static library. - allow_undefined=yes - ;; - *) - allow_undefined=yes - ;; - esac - libtool_args=$nonopt - base_compile="$nonopt $@" - compile_command=$nonopt - finalize_command=$nonopt - - compile_rpath= - finalize_rpath= - compile_shlibpath= - finalize_shlibpath= - convenience= - old_convenience= - deplibs= - old_deplibs= - compiler_flags= - linker_flags= - dllsearchpath= - lib_search_path=`pwd` - inst_prefix_dir= - new_inherited_linker_flags= - - avoid_version=no - dlfiles= - dlprefiles= - dlself=no - export_dynamic=no - export_symbols= - export_symbols_regex= - generated= - libobjs= - ltlibs= - module=no - no_install=no - objs= - non_pic_objects= - precious_files_regex= - prefer_static_libs=no - preload=no - prev= - prevarg= - release= - rpath= - xrpath= - perm_rpath= - temp_rpath= - thread_safe=no - vinfo= - vinfo_number=no - weak_libs= - single_module="${wl}-single_module" - func_infer_tag $base_compile - - # We need to know -static, to get the right output filenames. - for arg - do - case $arg in - -shared) - test "$build_libtool_libs" != yes && \ - func_fatal_configuration "can not build a shared library" - build_old_libs=no - break - ;; - -all-static | -static | -static-libtool-libs) - case $arg in - -all-static) - if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then - func_warning "complete static linking is impossible in this configuration" - fi - if test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - prefer_static_libs=yes - ;; - -static) - if test -z "$pic_flag" && test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - prefer_static_libs=built - ;; - -static-libtool-libs) - if test -z "$pic_flag" && test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - prefer_static_libs=yes - ;; - esac - build_libtool_libs=no - build_old_libs=yes - break - ;; - esac - done - - # See if our shared archives depend on static archives. - test -n "$old_archive_from_new_cmds" && build_old_libs=yes - - # Go through the arguments, transforming them on the way. - while test "$#" -gt 0; do - arg="$1" - shift - func_quote_for_eval "$arg" - qarg=$func_quote_for_eval_unquoted_result - func_append libtool_args " $func_quote_for_eval_result" - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case $prev in - output) - func_append compile_command " @OUTPUT@" - func_append finalize_command " @OUTPUT@" - ;; - esac - - case $prev in - dlfiles|dlprefiles) - if test "$preload" = no; then - # Add the symbol object into the linking commands. - func_append compile_command " @SYMFILE@" - func_append finalize_command " @SYMFILE@" - preload=yes - fi - case $arg in - *.la | *.lo) ;; # We handle these cases below. - force) - if test "$dlself" = no; then - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - self) - if test "$prev" = dlprefiles; then - dlself=yes - elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then - dlself=yes - else - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - *) - if test "$prev" = dlfiles; then - dlfiles="$dlfiles $arg" - else - dlprefiles="$dlprefiles $arg" - fi - prev= - continue - ;; - esac - ;; - expsyms) - export_symbols="$arg" - test -f "$arg" \ - || func_fatal_error "symbol file \`$arg' does not exist" - prev= - continue - ;; - expsyms_regex) - export_symbols_regex="$arg" - prev= - continue - ;; - framework) - case $host in - *-*-darwin*) - case "$deplibs " in - *" $qarg.ltframework "*) ;; - *) deplibs="$deplibs $qarg.ltframework" # this is fixed later - ;; - esac - ;; - esac - prev= - continue - ;; - inst_prefix) - inst_prefix_dir="$arg" - prev= - continue - ;; - objectlist) - if test -f "$arg"; then - save_arg=$arg - moreargs= - for fil in `cat "$save_arg"` - do -# moreargs="$moreargs $fil" - arg=$fil - # A libtool-controlled object. - - # Check to see that this really is a libtool object. - if func_lalib_unsafe_p "$arg"; then - pic_object= - non_pic_object= - - # Read the .lo file - func_source "$arg" - - if test -z "$pic_object" || - test -z "$non_pic_object" || - test "$pic_object" = none && - test "$non_pic_object" = none; then - func_fatal_error "cannot find name of object for \`$arg'" - fi - - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - if test "$pic_object" != none; then - # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" - - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - dlfiles="$dlfiles $pic_object" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then - # Preload the old-style object. - dlprefiles="$dlprefiles $pic_object" - prev= - fi - - # A PIC object. - func_append libobjs " $pic_object" - arg="$pic_object" - fi - - # Non-PIC object. - if test "$non_pic_object" != none; then - # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" - - # A standard non-PIC object - func_append non_pic_objects " $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" - fi - else - # If the PIC object exists, use it instead. - # $xdir was prepended to $pic_object above. - non_pic_object="$pic_object" - func_append non_pic_objects " $non_pic_object" - fi - else - # Only an error if not doing a dry-run. - if $opt_dry_run; then - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - func_lo2o "$arg" - pic_object=$xdir$objdir/$func_lo2o_result - non_pic_object=$xdir$func_lo2o_result - func_append libobjs " $pic_object" - func_append non_pic_objects " $non_pic_object" - else - func_fatal_error "\`$arg' is not a valid libtool object" - fi - fi - done - else - func_fatal_error "link input file \`$arg' does not exist" - fi - arg=$save_arg - prev= - continue - ;; - precious_regex) - precious_files_regex="$arg" - prev= - continue - ;; - release) - release="-$arg" - prev= - continue - ;; - rpath | xrpath) - # We need an absolute path. - case $arg in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - func_fatal_error "only absolute run-paths are allowed" - ;; - esac - if test "$prev" = rpath; then - case "$rpath " in - *" $arg "*) ;; - *) rpath="$rpath $arg" ;; - esac - else - case "$xrpath " in - *" $arg "*) ;; - *) xrpath="$xrpath $arg" ;; - esac - fi - prev= - continue - ;; - shrext) - shrext_cmds="$arg" - prev= - continue - ;; - weak) - weak_libs="$weak_libs $arg" - prev= - continue - ;; - xcclinker) - linker_flags="$linker_flags $qarg" - compiler_flags="$compiler_flags $qarg" - prev= - func_append compile_command " $qarg" - func_append finalize_command " $qarg" - continue - ;; - xcompiler) - compiler_flags="$compiler_flags $qarg" - prev= - func_append compile_command " $qarg" - func_append finalize_command " $qarg" - continue - ;; - xlinker) - linker_flags="$linker_flags $qarg" - compiler_flags="$compiler_flags $wl$qarg" - prev= - func_append compile_command " $wl$qarg" - func_append finalize_command " $wl$qarg" - continue - ;; - *) - eval "$prev=\"\$arg\"" - prev= - continue - ;; - esac - fi # test -n "$prev" - - prevarg="$arg" - - case $arg in - -all-static) - if test -n "$link_static_flag"; then - # See comment for -static flag below, for more details. - func_append compile_command " $link_static_flag" - func_append finalize_command " $link_static_flag" - fi - continue - ;; - - -allow-undefined) - # FIXME: remove this flag sometime in the future. - func_fatal_error "\`-allow-undefined' must not be used because it is the default" - ;; - - -avoid-version) - avoid_version=yes - continue - ;; - - -dlopen) - prev=dlfiles - continue - ;; - - -dlpreopen) - prev=dlprefiles - continue - ;; - - -export-dynamic) - export_dynamic=yes - continue - ;; - - -export-symbols | -export-symbols-regex) - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - func_fatal_error "more than one -exported-symbols argument is not allowed" - fi - if test "X$arg" = "X-export-symbols"; then - prev=expsyms - else - prev=expsyms_regex - fi - continue - ;; - - -framework) - prev=framework - continue - ;; - - -inst-prefix-dir) - prev=inst_prefix - continue - ;; - - # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* - # so, if we see these flags be careful not to treat them like -L - -L[A-Z][A-Z]*:*) - case $with_gcc/$host in - no/*-*-irix* | /*-*-irix*) - func_append compile_command " $arg" - func_append finalize_command " $arg" - ;; - esac - continue - ;; - - -L*) - func_stripname '-L' '' "$arg" - dir=$func_stripname_result - if test -z "$dir"; then - if test "$#" -gt 0; then - func_fatal_error "require no space between \`-L' and \`$1'" - else - func_fatal_error "need path for \`-L' option" - fi - fi - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - absdir=`cd "$dir" && pwd` - test -z "$absdir" && \ - func_fatal_error "cannot determine absolute directory name of \`$dir'" - dir="$absdir" - ;; - esac - case "$deplibs " in - *" -L$dir "*) ;; - *) - deplibs="$deplibs -L$dir" - lib_search_path="$lib_search_path $dir" - ;; - esac - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'` - case :$dllsearchpath: in - *":$dir:"*) ;; - ::) dllsearchpath=$dir;; - *) dllsearchpath="$dllsearchpath:$dir";; - esac - case :$dllsearchpath: in - *":$testbindir:"*) ;; - ::) dllsearchpath=$testbindir;; - *) dllsearchpath="$dllsearchpath:$testbindir";; - esac - ;; - esac - continue - ;; - - -l*) - if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*) - # These systems don't actually have a C or math library (as such) - continue - ;; - *-*-os2*) - # These systems don't actually have a C library (as such) - test "X$arg" = "X-lc" && continue - ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc due to us having libc/libc_r. - test "X$arg" = "X-lc" && continue - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C and math libraries are in the System framework - deplibs="$deplibs System.ltframework" - continue - ;; - *-*-sco3.2v5* | *-*-sco5v6*) - # Causes problems with __ctype - test "X$arg" = "X-lc" && continue - ;; - *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) - # Compiler inserts libc in the correct place for threads to work - test "X$arg" = "X-lc" && continue - ;; - esac - elif test "X$arg" = "X-lc_r"; then - case $host in - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc_r directly, use -pthread flag. - continue - ;; - esac - fi - deplibs="$deplibs $arg" - continue - ;; - - -module) - module=yes - continue - ;; - - # Tru64 UNIX uses -model [arg] to determine the layout of C++ - # classes, name mangling, and exception handling. - # Darwin uses the -arch flag to determine output architecture. - -model|-arch|-isysroot) - compiler_flags="$compiler_flags $arg" - func_append compile_command " $arg" - func_append finalize_command " $arg" - prev=xcompiler - continue - ;; - - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) - compiler_flags="$compiler_flags $arg" - func_append compile_command " $arg" - func_append finalize_command " $arg" - case "$new_inherited_linker_flags " in - *" $arg "*) ;; - * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;; - esac - continue - ;; - - -multi_module) - single_module="${wl}-multi_module" - continue - ;; - - -no-fast-install) - fast_install=no - continue - ;; - - -no-install) - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) - # The PATH hackery in wrapper scripts is required on Windows - # and Darwin in order for the loader to find any dlls it needs. - func_warning "\`-no-install' is ignored for $host" - func_warning "assuming \`-no-fast-install' instead" - fast_install=no - ;; - *) no_install=yes ;; - esac - continue - ;; - - -no-undefined) - allow_undefined=no - continue - ;; - - -objectlist) - prev=objectlist - continue - ;; - - -o) prev=output ;; - - -precious-files-regex) - prev=precious_regex - continue - ;; - - -release) - prev=release - continue - ;; - - -rpath) - prev=rpath - continue - ;; - - -R) - prev=xrpath - continue - ;; - - -R*) - func_stripname '-R' '' "$arg" - dir=$func_stripname_result - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - func_fatal_error "only absolute run-paths are allowed" - ;; - esac - case "$xrpath " in - *" $dir "*) ;; - *) xrpath="$xrpath $dir" ;; - esac - continue - ;; - - -shared) - # The effects of -shared are defined in a previous loop. - continue - ;; - - -shrext) - prev=shrext - continue - ;; - - -static | -static-libtool-libs) - # The effects of -static are defined in a previous loop. - # We used to do the same as -all-static on platforms that - # didn't have a PIC flag, but the assumption that the effects - # would be equivalent was wrong. It would break on at least - # Digital Unix and AIX. - continue - ;; - - -thread-safe) - thread_safe=yes - continue - ;; - - -version-info) - prev=vinfo - continue - ;; - - -version-number) - prev=vinfo - vinfo_number=yes - continue - ;; - - -weak) - prev=weak - continue - ;; - - -Wc,*) - func_stripname '-Wc,' '' "$arg" - args=$func_stripname_result - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - func_quote_for_eval "$flag" - arg="$arg $wl$func_quote_for_eval_result" - compiler_flags="$compiler_flags $func_quote_for_eval_result" - done - IFS="$save_ifs" - func_stripname ' ' '' "$arg" - arg=$func_stripname_result - ;; - - -Wl,*) - func_stripname '-Wl,' '' "$arg" - args=$func_stripname_result - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - func_quote_for_eval "$flag" - arg="$arg $wl$func_quote_for_eval_result" - compiler_flags="$compiler_flags $wl$func_quote_for_eval_result" - linker_flags="$linker_flags $func_quote_for_eval_result" - done - IFS="$save_ifs" - func_stripname ' ' '' "$arg" - arg=$func_stripname_result - ;; - - -Xcompiler) - prev=xcompiler - continue - ;; - - -Xlinker) - prev=xlinker - continue - ;; - - -XCClinker) - prev=xcclinker - continue - ;; - - # -msg_* for osf cc - -msg_*) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - ;; - - # -64, -mips[0-9] enable 64-bit mode on the SGI compiler - # -r[0-9][0-9]* specifies the processor on the SGI compiler - # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler - # +DA*, +DD* enable 64-bit mode on the HP compiler - # -q* pass through compiler args for the IBM compiler - # -m*, -t[45]*, -txscale* pass through architecture-specific - # compiler args for GCC - # -F/path gives path to uninstalled frameworks, gcc on darwin - # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC - # @file GCC response files - -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ - -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - func_append compile_command " $arg" - func_append finalize_command " $arg" - compiler_flags="$compiler_flags $arg" - continue - ;; - - # Some other compiler flag. - -* | +*) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - ;; - - *.$objext) - # A standard object. - objs="$objs $arg" - ;; - - *.lo) - # A libtool-controlled object. - - # Check to see that this really is a libtool object. - if func_lalib_unsafe_p "$arg"; then - pic_object= - non_pic_object= - - # Read the .lo file - func_source "$arg" - - if test -z "$pic_object" || - test -z "$non_pic_object" || - test "$pic_object" = none && - test "$non_pic_object" = none; then - func_fatal_error "cannot find name of object for \`$arg'" - fi - - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - if test "$pic_object" != none; then - # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" - - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - dlfiles="$dlfiles $pic_object" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then - # Preload the old-style object. - dlprefiles="$dlprefiles $pic_object" - prev= - fi - - # A PIC object. - func_append libobjs " $pic_object" - arg="$pic_object" - fi - - # Non-PIC object. - if test "$non_pic_object" != none; then - # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" - - # A standard non-PIC object - func_append non_pic_objects " $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" - fi - else - # If the PIC object exists, use it instead. - # $xdir was prepended to $pic_object above. - non_pic_object="$pic_object" - func_append non_pic_objects " $non_pic_object" - fi - else - # Only an error if not doing a dry-run. - if $opt_dry_run; then - # Extract subdirectory from the argument. - func_dirname "$arg" "/" "" - xdir="$func_dirname_result" - - func_lo2o "$arg" - pic_object=$xdir$objdir/$func_lo2o_result - non_pic_object=$xdir$func_lo2o_result - func_append libobjs " $pic_object" - func_append non_pic_objects " $non_pic_object" - else - func_fatal_error "\`$arg' is not a valid libtool object" - fi - fi - ;; - - *.$libext) - # An archive. - deplibs="$deplibs $arg" - old_deplibs="$old_deplibs $arg" - continue - ;; - - *.la) - # A libtool-controlled library. - - if test "$prev" = dlfiles; then - # This library was specified with -dlopen. - dlfiles="$dlfiles $arg" - prev= - elif test "$prev" = dlprefiles; then - # The library was specified with -dlpreopen. - dlprefiles="$dlprefiles $arg" - prev= - else - deplibs="$deplibs $arg" - fi - continue - ;; - - # Some other compiler argument. - *) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - ;; - esac # arg - - # Now actually substitute the argument into the commands. - if test -n "$arg"; then - func_append compile_command " $arg" - func_append finalize_command " $arg" - fi - done # argument parsing loop - - test -n "$prev" && \ - func_fatal_help "the \`$prevarg' option requires an argument" - - if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then - eval arg=\"$export_dynamic_flag_spec\" - func_append compile_command " $arg" - func_append finalize_command " $arg" - fi - - oldlibs= - # calculate the name of the file, without its directory - func_basename "$output" - outputname="$func_basename_result" - libobjs_save="$libobjs" - - if test -n "$shlibpath_var"; then - # get the directories listed in $shlibpath_var - eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` - else - shlib_search_path= - fi - eval sys_lib_search_path=\"$sys_lib_search_path_spec\" - eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" - - func_dirname "$output" "/" "" - output_objdir="$func_dirname_result$objdir" - # Create the object directory. - func_mkdir_p "$output_objdir" - - # Determine the type of output - case $output in - "") - func_fatal_help "you must specify an output file" - ;; - *.$libext) linkmode=oldlib ;; - *.lo | *.$objext) linkmode=obj ;; - *.la) linkmode=lib ;; - *) linkmode=prog ;; # Anything else should be a program. - esac - - specialdeplibs= - - libs= - # Find all interdependent deplibs by searching for libraries - # that are linked more than once (e.g. -la -lb -la) - for deplib in $deplibs; do - if $opt_duplicate_deps ; then - case "$libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - libs="$libs $deplib" - done - - if test "$linkmode" = lib; then - libs="$predeps $libs $compiler_lib_search_path $postdeps" - - # Compute libraries that are listed more than once in $predeps - # $postdeps and mark them as special (i.e., whose duplicates are - # not to be eliminated). - pre_post_deps= - if $opt_duplicate_compiler_generated_deps; then - for pre_post_dep in $predeps $postdeps; do - case "$pre_post_deps " in - *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; - esac - pre_post_deps="$pre_post_deps $pre_post_dep" - done - fi - pre_post_deps= - fi - - deplibs= - newdependency_libs= - newlib_search_path= - need_relink=no # whether we're linking any uninstalled libtool libraries - notinst_deplibs= # not-installed libtool libraries - notinst_path= # paths that contain not-installed libtool libraries - - case $linkmode in - lib) - passes="conv dlpreopen link" - for file in $dlfiles $dlprefiles; do - case $file in - *.la) ;; - *) - func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" - ;; - esac - done - ;; - prog) - compile_deplibs= - finalize_deplibs= - alldeplibs=no - newdlfiles= - newdlprefiles= - passes="conv scan dlopen dlpreopen link" - ;; - *) passes="conv" - ;; - esac - - for pass in $passes; do - # The preopen pass in lib mode reverses $deplibs; put it back here - # so that -L comes before libs that need it for instance... - if test "$linkmode,$pass" = "lib,link"; then - ## FIXME: Find the place where the list is rebuilt in the wrong - ## order, and fix it there properly - tmp_deplibs= - for deplib in $deplibs; do - tmp_deplibs="$deplib $tmp_deplibs" - done - deplibs="$tmp_deplibs" - fi - - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan"; then - libs="$deplibs" - deplibs= - fi - if test "$linkmode" = prog; then - case $pass in - dlopen) libs="$dlfiles" ;; - dlpreopen) libs="$dlprefiles" ;; - link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; - esac - fi - if test "$linkmode,$pass" = "lib,dlpreopen"; then - # Collect and forward deplibs of preopened libtool libs - for lib in $dlprefiles; do - # Ignore non-libtool-libs - dependency_libs= - case $lib in - *.la) func_source "$lib" ;; - esac - - # Collect preopened libtool deplibs, except any this library - # has declared as weak libs - for deplib in $dependency_libs; do - deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"` - case " $weak_libs " in - *" $deplib_base "*) ;; - *) deplibs="$deplibs $deplib" ;; - esac - done - done - libs="$dlprefiles" - fi - if test "$pass" = dlopen; then - # Collect dlpreopened libraries - save_deplibs="$deplibs" - deplibs= - fi - - for deplib in $libs; do - lib= - found=no - case $deplib in - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - compiler_flags="$compiler_flags $deplib" - if test "$linkmode" = lib ; then - case "$new_inherited_linker_flags " in - *" $deplib "*) ;; - * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; - esac - fi - fi - continue - ;; - -l*) - if test "$linkmode" != lib && test "$linkmode" != prog; then - func_warning "\`-l' is ignored for archives/objects" - continue - fi - func_stripname '-l' '' "$deplib" - name=$func_stripname_result - if test "$linkmode" = lib; then - searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" - else - searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" - fi - for searchdir in $searchdirs; do - for search_ext in .la $std_shrext .so .a; do - # Search the libtool library - lib="$searchdir/lib${name}${search_ext}" - if test -f "$lib"; then - if test "$search_ext" = ".la"; then - found=yes - else - found=no - fi - break 2 - fi - done - done - if test "$found" != yes; then - # deplib doesn't seem to be a libtool library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - else # deplib is a libtool library - # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, - # We need to do some special things here, and not later. - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - case " $predeps $postdeps " in - *" $deplib "*) - if func_lalib_p "$lib"; then - library_names= - old_library= - func_source "$lib" - for l in $old_library $library_names; do - ll="$l" - done - if test "X$ll" = "X$old_library" ; then # only static version available - found=no - func_dirname "$lib" "" "." - ladir="$func_dirname_result" - lib=$ladir/$old_library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - fi - fi - ;; - *) ;; - esac - fi - fi - ;; # -l - *.ltframework) - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - if test "$linkmode" = lib ; then - case "$new_inherited_linker_flags " in - *" $deplib "*) ;; - * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; - esac - fi - fi - continue - ;; - -L*) - case $linkmode in - lib) - deplibs="$deplib $deplibs" - test "$pass" = conv && continue - newdependency_libs="$deplib $newdependency_libs" - func_stripname '-L' '' "$deplib" - newlib_search_path="$newlib_search_path $func_stripname_result" - ;; - prog) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - if test "$pass" = scan; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - func_stripname '-L' '' "$deplib" - newlib_search_path="$newlib_search_path $func_stripname_result" - ;; - *) - func_warning "\`-L' is ignored for archives/objects" - ;; - esac # linkmode - continue - ;; # -L - -R*) - if test "$pass" = link; then - func_stripname '-R' '' "$deplib" - dir=$func_stripname_result - # Make sure the xrpath contains only unique directories. - case "$xrpath " in - *" $dir "*) ;; - *) xrpath="$xrpath $dir" ;; - esac - fi - deplibs="$deplib $deplibs" - continue - ;; - *.la) lib="$deplib" ;; - *.$libext) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - continue - fi - case $linkmode in - lib) - # Linking convenience modules into shared libraries is allowed, - # but linking other static libraries is non-portable. - case " $dlpreconveniencelibs " in - *" $deplib "*) ;; - *) - valid_a_lib=no - case $deplibs_check_method in - match_pattern*) - set dummy $deplibs_check_method; shift - match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` - if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \ - | $EGREP "$match_pattern_regex" > /dev/null; then - valid_a_lib=yes - fi - ;; - pass_all) - valid_a_lib=yes - ;; - esac - if test "$valid_a_lib" != yes; then - $ECHO - $ECHO "*** Warning: Trying to link with static lib archive $deplib." - $ECHO "*** I have the capability to make that library automatically link in when" - $ECHO "*** you link to this library. But I can only do this if you have a" - $ECHO "*** shared version of the library, which you do not appear to have" - $ECHO "*** because the file extensions .$libext of this argument makes me believe" - $ECHO "*** that it is just a static archive that I should not use here." - else - $ECHO - $ECHO "*** Warning: Linking the shared library $output against the" - $ECHO "*** static library $deplib is not portable!" - deplibs="$deplib $deplibs" - fi - ;; - esac - continue - ;; - prog) - if test "$pass" != link; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - continue - ;; - esac # linkmode - ;; # *.$libext - *.lo | *.$objext) - if test "$pass" = conv; then - deplibs="$deplib $deplibs" - elif test "$linkmode" = prog; then - if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then - # If there is no dlopen support or we're linking statically, - # we need to preload. - newdlprefiles="$newdlprefiles $deplib" - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - newdlfiles="$newdlfiles $deplib" - fi - fi - continue - ;; - %DEPLIBS%) - alldeplibs=yes - continue - ;; - esac # case $deplib - - if test "$found" = yes || test -f "$lib"; then : - else - func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" - fi - - # Check to see that this really is a libtool archive. - func_lalib_unsafe_p "$lib" \ - || func_fatal_error "\`$lib' is not a valid libtool archive" - - func_dirname "$lib" "" "." - ladir="$func_dirname_result" - - dlname= - dlopen= - dlpreopen= - libdir= - library_names= - old_library= - inherited_linker_flags= - # If the library was installed with an old release of libtool, - # it will not redefine variables installed, or shouldnotlink - installed=yes - shouldnotlink=no - avoidtemprpath= - - - # Read the .la file - func_source "$lib" - - # Convert "-framework foo" to "foo.ltframework" - if test -n "$inherited_linker_flags"; then - tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'` - for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do - case " $new_inherited_linker_flags " in - *" $tmp_inherited_linker_flag "*) ;; - *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";; - esac - done - fi - dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan" || - { test "$linkmode" != prog && test "$linkmode" != lib; }; then - test -n "$dlopen" && dlfiles="$dlfiles $dlopen" - test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" - fi - - if test "$pass" = conv; then - # Only check for convenience libraries - deplibs="$lib $deplibs" - if test -z "$libdir"; then - if test -z "$old_library"; then - func_fatal_error "cannot find name of link library for \`$lib'" - fi - # It is a libtool convenience library, so add in its objects. - convenience="$convenience $ladir/$objdir/$old_library" - old_convenience="$old_convenience $ladir/$objdir/$old_library" - elif test "$linkmode" != prog && test "$linkmode" != lib; then - func_fatal_error "\`$lib' is not a convenience library" - fi - tmp_libs= - for deplib in $dependency_libs; do - deplibs="$deplib $deplibs" - if $opt_duplicate_deps ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done - continue - fi # $pass = conv - - - # Get the name of the library we link against. - linklib= - for l in $old_library $library_names; do - linklib="$l" - done - if test -z "$linklib"; then - func_fatal_error "cannot find name of link library for \`$lib'" - fi - - # This library was specified with -dlopen. - if test "$pass" = dlopen; then - if test -z "$libdir"; then - func_fatal_error "cannot -dlopen a convenience library: \`$lib'" - fi - if test -z "$dlname" || - test "$dlopen_support" != yes || - test "$build_libtool_libs" = no; then - # If there is no dlname, no dlopen support or we're linking - # statically, we need to preload. We also need to preload any - # dependent libraries so libltdl's deplib preloader doesn't - # bomb out in the load deplibs phase. - dlprefiles="$dlprefiles $lib $dependency_libs" - else - newdlfiles="$newdlfiles $lib" - fi - continue - fi # $pass = dlopen - - # We need an absolute path. - case $ladir in - [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; - *) - abs_ladir=`cd "$ladir" && pwd` - if test -z "$abs_ladir"; then - func_warning "cannot determine absolute directory name of \`$ladir'" - func_warning "passing it literally to the linker, although it might fail" - abs_ladir="$ladir" - fi - ;; - esac - func_basename "$lib" - laname="$func_basename_result" - - # Find the relevant object directory and library name. - if test "X$installed" = Xyes; then - if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then - func_warning "library \`$lib' was moved." - dir="$ladir" - absdir="$abs_ladir" - libdir="$abs_ladir" - else - dir="$libdir" - absdir="$libdir" - fi - test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes - else - if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then - dir="$ladir" - absdir="$abs_ladir" - # Remove this search path later - notinst_path="$notinst_path $abs_ladir" - else - dir="$ladir/$objdir" - absdir="$abs_ladir/$objdir" - # Remove this search path later - notinst_path="$notinst_path $abs_ladir" - fi - fi # $installed = yes - func_stripname 'lib' '.la' "$laname" - name=$func_stripname_result - - # This library was specified with -dlpreopen. - if test "$pass" = dlpreopen; then - if test -z "$libdir" && test "$linkmode" = prog; then - func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" - fi - # Prefer using a static library (so that no silly _DYNAMIC symbols - # are required to link). - if test -n "$old_library"; then - newdlprefiles="$newdlprefiles $dir/$old_library" - # Keep a list of preopened convenience libraries to check - # that they are being used correctly in the link pass. - test -z "$libdir" && \ - dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library" - # Otherwise, use the dlname, so that lt_dlopen finds it. - elif test -n "$dlname"; then - newdlprefiles="$newdlprefiles $dir/$dlname" - else - newdlprefiles="$newdlprefiles $dir/$linklib" - fi - fi # $pass = dlpreopen - - if test -z "$libdir"; then - # Link the convenience library - if test "$linkmode" = lib; then - deplibs="$dir/$old_library $deplibs" - elif test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$dir/$old_library $compile_deplibs" - finalize_deplibs="$dir/$old_library $finalize_deplibs" - else - deplibs="$lib $deplibs" # used for prog,scan pass - fi - continue - fi - - - if test "$linkmode" = prog && test "$pass" != link; then - newlib_search_path="$newlib_search_path $ladir" - deplibs="$lib $deplibs" - - linkalldeplibs=no - if test "$link_all_deplibs" != no || test -z "$library_names" || - test "$build_libtool_libs" = no; then - linkalldeplibs=yes - fi - - tmp_libs= - for deplib in $dependency_libs; do - case $deplib in - -L*) func_stripname '-L' '' "$deplib" - newlib_search_path="$newlib_search_path $func_stripname_result" - ;; - esac - # Need to link against all dependency_libs? - if test "$linkalldeplibs" = yes; then - deplibs="$deplib $deplibs" - else - # Need to hardcode shared library paths - # or/and link against static libraries - newdependency_libs="$deplib $newdependency_libs" - fi - if $opt_duplicate_deps ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done # for deplib - continue - fi # $linkmode = prog... - - if test "$linkmode,$pass" = "prog,link"; then - if test -n "$library_names" && - { { test "$prefer_static_libs" = no || - test "$prefer_static_libs,$installed" = "built,yes"; } || - test -z "$old_library"; }; then - # We need to hardcode the library path - if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then - # Make sure the rpath contains only unique directories. - case "$temp_rpath:" in - *"$absdir:"*) ;; - *) temp_rpath="$temp_rpath$absdir:" ;; - esac - fi - - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) compile_rpath="$compile_rpath $absdir" - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" - esac - ;; - esac - fi # $linkmode,$pass = prog,link... - - if test "$alldeplibs" = yes && - { test "$deplibs_check_method" = pass_all || - { test "$build_libtool_libs" = yes && - test -n "$library_names"; }; }; then - # We only need to search for static libraries - continue - fi - fi - - link_static=no # Whether the deplib will be linked statically - use_static_libs=$prefer_static_libs - if test "$use_static_libs" = built && test "$installed" = yes; then - use_static_libs=no - fi - if test -n "$library_names" && - { test "$use_static_libs" = no || test -z "$old_library"; }; then - case $host in - *cygwin* | *mingw* | *cegcc*) - # No point in relinking DLLs because paths are not encoded - notinst_deplibs="$notinst_deplibs $lib" - need_relink=no - ;; - *) - if test "$installed" = no; then - notinst_deplibs="$notinst_deplibs $lib" - need_relink=yes - fi - ;; - esac - # This is a shared library - - # Warn about portability, can't link against -module's on some - # systems (darwin). Don't bleat about dlopened modules though! - dlopenmodule="" - for dlpremoduletest in $dlprefiles; do - if test "X$dlpremoduletest" = "X$lib"; then - dlopenmodule="$dlpremoduletest" - break - fi - done - if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then - $ECHO - if test "$linkmode" = prog; then - $ECHO "*** Warning: Linking the executable $output against the loadable module" - else - $ECHO "*** Warning: Linking the shared library $output against the loadable module" - fi - $ECHO "*** $linklib is not portable!" - fi - if test "$linkmode" = lib && - test "$hardcode_into_libs" = yes; then - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) compile_rpath="$compile_rpath $absdir" - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" - esac - ;; - esac - fi - - if test -n "$old_archive_from_expsyms_cmds"; then - # figure out the soname - set dummy $library_names - shift - realname="$1" - shift - libname=`eval "\\$ECHO \"$libname_spec\""` - # use dlname if we got it. it's perfectly good, no? - if test -n "$dlname"; then - soname="$dlname" - elif test -n "$soname_spec"; then - # bleh windows - case $host in - *cygwin* | mingw* | *cegcc*) - func_arith $current - $age - major=$func_arith_result - versuffix="-$major" - ;; - esac - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - - # Make a new name for the extract_expsyms_cmds to use - soroot="$soname" - func_basename "$soroot" - soname="$func_basename_result" - func_stripname 'lib' '.dll' "$soname" - newlib=libimp-$func_stripname_result.a - - # If the library has no export list, then create one now - if test -f "$output_objdir/$soname-def"; then : - else - func_verbose "extracting exported symbol list from \`$soname'" - func_execute_cmds "$extract_expsyms_cmds" 'exit $?' - fi - - # Create $newlib - if test -f "$output_objdir/$newlib"; then :; else - func_verbose "generating import library for \`$soname'" - func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' - fi - # make sure the library variables are pointing to the new library - dir=$output_objdir - linklib=$newlib - fi # test -n "$old_archive_from_expsyms_cmds" - - if test "$linkmode" = prog || test "$mode" != relink; then - add_shlibpath= - add_dir= - add= - lib_linked=yes - case $hardcode_action in - immediate | unsupported) - if test "$hardcode_direct" = no; then - add="$dir/$linklib" - case $host in - *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; - *-*-sysv4*uw2*) add_dir="-L$dir" ;; - *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ - *-*-unixware7*) add_dir="-L$dir" ;; - *-*-darwin* ) - # if the lib is a (non-dlopened) module then we can not - # link against it, someone is ignoring the earlier warnings - if /usr/bin/file -L $add 2> /dev/null | - $GREP ": [^:]* bundle" >/dev/null ; then - if test "X$dlopenmodule" != "X$lib"; then - $ECHO "*** Warning: lib $linklib is a module, not a shared library" - if test -z "$old_library" ; then - $ECHO - $ECHO "*** And there doesn't seem to be a static archive available" - $ECHO "*** The link will probably fail, sorry" - else - add="$dir/$old_library" - fi - elif test -n "$old_library"; then - add="$dir/$old_library" - fi - fi - esac - elif test "$hardcode_minus_L" = no; then - case $host in - *-*-sunos*) add_shlibpath="$dir" ;; - esac - add_dir="-L$dir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = no; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - relink) - if test "$hardcode_direct" = yes && - test "$hardcode_direct_absolute" = no; then - add="$dir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$dir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case $libdir in - [\\/]*) - add_dir="$add_dir -L$inst_prefix_dir$libdir" - ;; - esac - fi - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - *) lib_linked=no ;; - esac - - if test "$lib_linked" != yes; then - func_fatal_configuration "unsupported hardcode properties" - fi - - if test -n "$add_shlibpath"; then - case :$compile_shlibpath: in - *":$add_shlibpath:"*) ;; - *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; - esac - fi - if test "$linkmode" = prog; then - test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" - test -n "$add" && compile_deplibs="$add $compile_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - if test "$hardcode_direct" != yes && - test "$hardcode_minus_L" != yes && - test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; - esac - fi - fi - fi - - if test "$linkmode" = prog || test "$mode" = relink; then - add_shlibpath= - add_dir= - add= - # Finalize command for both is simple: just hardcode it. - if test "$hardcode_direct" = yes && - test "$hardcode_direct_absolute" = no; then - add="$libdir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$libdir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; - esac - add="-l$name" - elif test "$hardcode_automatic" = yes; then - if test -n "$inst_prefix_dir" && - test -f "$inst_prefix_dir$libdir/$linklib" ; then - add="$inst_prefix_dir$libdir/$linklib" - else - add="$libdir/$linklib" - fi - else - # We cannot seem to hardcode it, guess we'll fake it. - add_dir="-L$libdir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case $libdir in - [\\/]*) - add_dir="$add_dir -L$inst_prefix_dir$libdir" - ;; - esac - fi - add="-l$name" - fi - - if test "$linkmode" = prog; then - test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" - test -n "$add" && finalize_deplibs="$add $finalize_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - fi - fi - elif test "$linkmode" = prog; then - # Here we assume that one of hardcode_direct or hardcode_minus_L - # is not unsupported. This is valid on all known static and - # shared platforms. - if test "$hardcode_direct" != unsupported; then - test -n "$old_library" && linklib="$old_library" - compile_deplibs="$dir/$linklib $compile_deplibs" - finalize_deplibs="$dir/$linklib $finalize_deplibs" - else - compile_deplibs="-l$name -L$dir $compile_deplibs" - finalize_deplibs="-l$name -L$dir $finalize_deplibs" - fi - elif test "$build_libtool_libs" = yes; then - # Not a shared library - if test "$deplibs_check_method" != pass_all; then - # We're trying link a shared library against a static one - # but the system doesn't support it. - - # Just print a warning and add the library to dependency_libs so - # that the program can be linked against the static library. - $ECHO - $ECHO "*** Warning: This system can not link to static lib archive $lib." - $ECHO "*** I have the capability to make that library automatically link in when" - $ECHO "*** you link to this library. But I can only do this if you have a" - $ECHO "*** shared version of the library, which you do not appear to have." - if test "$module" = yes; then - $ECHO "*** But as you try to build a module library, libtool will still create " - $ECHO "*** a static module, that should work as long as the dlopening application" - $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime." - if test -z "$global_symbol_pipe"; then - $ECHO - $ECHO "*** However, this would only work if libtool was able to extract symbol" - $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could" - $ECHO "*** not find such a program. So, this module is probably useless." - $ECHO "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - else - deplibs="$dir/$old_library $deplibs" - link_static=yes - fi - fi # link shared/static library? - - if test "$linkmode" = lib; then - if test -n "$dependency_libs" && - { test "$hardcode_into_libs" != yes || - test "$build_old_libs" = yes || - test "$link_static" = yes; }; then - # Extract -R from dependency_libs - temp_deplibs= - for libdir in $dependency_libs; do - case $libdir in - -R*) func_stripname '-R' '' "$libdir" - temp_xrpath=$func_stripname_result - case " $xrpath " in - *" $temp_xrpath "*) ;; - *) xrpath="$xrpath $temp_xrpath";; - esac;; - *) temp_deplibs="$temp_deplibs $libdir";; - esac - done - dependency_libs="$temp_deplibs" - fi - - newlib_search_path="$newlib_search_path $absdir" - # Link against this library - test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" - # ... and its dependency_libs - tmp_libs= - for deplib in $dependency_libs; do - newdependency_libs="$deplib $newdependency_libs" - if $opt_duplicate_deps ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done - - if test "$link_all_deplibs" != no; then - # Add the search paths of all dependency libraries - for deplib in $dependency_libs; do - case $deplib in - -L*) path="$deplib" ;; - *.la) - func_dirname "$deplib" "" "." - dir="$func_dirname_result" - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - func_warning "cannot determine absolute directory name of \`$dir'" - absdir="$dir" - fi - ;; - esac - if $GREP "^installed=no" $deplib > /dev/null; then - case $host in - *-*-darwin*) - depdepl= - eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` - if test -n "$deplibrary_names" ; then - for tmp in $deplibrary_names ; do - depdepl=$tmp - done - if test -f "$absdir/$objdir/$depdepl" ; then - depdepl="$absdir/$objdir/$depdepl" - darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` - if test -z "$darwin_install_name"; then - darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` - fi - compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" - linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}" - path= - fi - fi - ;; - *) - path="-L$absdir/$objdir" - ;; - esac - else - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - test -z "$libdir" && \ - func_fatal_error "\`$deplib' is not a valid libtool archive" - test "$absdir" != "$libdir" && \ - func_warning "\`$deplib' seems to be moved" - - path="-L$absdir" - fi - ;; - esac - case " $deplibs " in - *" $path "*) ;; - *) deplibs="$path $deplibs" ;; - esac - done - fi # link_all_deplibs != no - fi # linkmode = lib - done # for deplib in $libs - if test "$pass" = link; then - if test "$linkmode" = "prog"; then - compile_deplibs="$new_inherited_linker_flags $compile_deplibs" - finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" - else - compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` - fi - fi - dependency_libs="$newdependency_libs" - if test "$pass" = dlpreopen; then - # Link the dlpreopened libraries before other libraries - for deplib in $save_deplibs; do - deplibs="$deplib $deplibs" - done - fi - if test "$pass" != dlopen; then - if test "$pass" != conv; then - # Make sure lib_search_path contains only unique directories. - lib_search_path= - for dir in $newlib_search_path; do - case "$lib_search_path " in - *" $dir "*) ;; - *) lib_search_path="$lib_search_path $dir" ;; - esac - done - newlib_search_path= - fi - - if test "$linkmode,$pass" != "prog,link"; then - vars="deplibs" - else - vars="compile_deplibs finalize_deplibs" - fi - for var in $vars dependency_libs; do - # Add libraries to $var in reverse order - eval tmp_libs=\"\$$var\" - new_libs= - for deplib in $tmp_libs; do - # FIXME: Pedantically, this is the right thing to do, so - # that some nasty dependency loop isn't accidentally - # broken: - #new_libs="$deplib $new_libs" - # Pragmatically, this seems to cause very few problems in - # practice: - case $deplib in - -L*) new_libs="$deplib $new_libs" ;; - -R*) ;; - *) - # And here is the reason: when a library appears more - # than once as an explicit dependence of a library, or - # is implicitly linked in more than once by the - # compiler, it is considered special, and multiple - # occurrences thereof are not removed. Compare this - # with having the same library being listed as a - # dependency of multiple other libraries: in this case, - # we know (pedantically, we assume) the library does not - # need to be listed more than once, so we keep only the - # last copy. This is not always right, but it is rare - # enough that we require users that really mean to play - # such unportable linking tricks to link the library - # using -Wl,-lname, so that libtool does not consider it - # for duplicate removal. - case " $specialdeplibs " in - *" $deplib "*) new_libs="$deplib $new_libs" ;; - *) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs="$deplib $new_libs" ;; - esac - ;; - esac - ;; - esac - done - tmp_libs= - for deplib in $new_libs; do - case $deplib in - -L*) - case " $tmp_libs " in - *" $deplib "*) ;; - *) tmp_libs="$tmp_libs $deplib" ;; - esac - ;; - *) tmp_libs="$tmp_libs $deplib" ;; - esac - done - eval $var=\"$tmp_libs\" - done # for var - fi - # Last step: remove runtime libs from dependency_libs - # (they stay in deplibs) - tmp_libs= - for i in $dependency_libs ; do - case " $predeps $postdeps $compiler_lib_search_path " in - *" $i "*) - i="" - ;; - esac - if test -n "$i" ; then - tmp_libs="$tmp_libs $i" - fi - done - dependency_libs=$tmp_libs - done # for pass - if test "$linkmode" = prog; then - dlfiles="$newdlfiles" - fi - if test "$linkmode" = prog || test "$linkmode" = lib; then - dlprefiles="$newdlprefiles" - fi - - case $linkmode in - oldlib) - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - func_warning "\`-dlopen' is ignored for archives" - fi - - case " $deplibs" in - *\ -l* | *\ -L*) - func_warning "\`-l' and \`-L' are ignored for archives" ;; - esac - - test -n "$rpath" && \ - func_warning "\`-rpath' is ignored for archives" - - test -n "$xrpath" && \ - func_warning "\`-R' is ignored for archives" - - test -n "$vinfo" && \ - func_warning "\`-version-info/-version-number' is ignored for archives" - - test -n "$release" && \ - func_warning "\`-release' is ignored for archives" - - test -n "$export_symbols$export_symbols_regex" && \ - func_warning "\`-export-symbols' is ignored for archives" - - # Now set the variables for building old libraries. - build_libtool_libs=no - oldlibs="$output" - objs="$objs$old_deplibs" - ;; - - lib) - # Make sure we only generate libraries of the form `libNAME.la'. - case $outputname in - lib*) - func_stripname 'lib' '.la' "$outputname" - name=$func_stripname_result - eval shared_ext=\"$shrext_cmds\" - eval libname=\"$libname_spec\" - ;; - *) - test "$module" = no && \ - func_fatal_help "libtool library \`$output' must begin with \`lib'" - - if test "$need_lib_prefix" != no; then - # Add the "lib" prefix for modules if required - func_stripname '' '.la' "$outputname" - name=$func_stripname_result - eval shared_ext=\"$shrext_cmds\" - eval libname=\"$libname_spec\" - else - func_stripname '' '.la' "$outputname" - libname=$func_stripname_result - fi - ;; - esac - - if test -n "$objs"; then - if test "$deplibs_check_method" != pass_all; then - func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" - else - $ECHO - $ECHO "*** Warning: Linking the shared library $output against the non-libtool" - $ECHO "*** objects $objs is not portable!" - libobjs="$libobjs $objs" - fi - fi - - test "$dlself" != no && \ - func_warning "\`-dlopen self' is ignored for libtool libraries" - - set dummy $rpath - shift - test "$#" -gt 1 && \ - func_warning "ignoring multiple \`-rpath's for a libtool library" - - install_libdir="$1" - - oldlibs= - if test -z "$rpath"; then - if test "$build_libtool_libs" = yes; then - # Building a libtool convenience library. - # Some compilers have problems with a `.al' extension so - # convenience libraries should have the same extension an - # archive normally would. - oldlibs="$output_objdir/$libname.$libext $oldlibs" - build_libtool_libs=convenience - build_old_libs=yes - fi - - test -n "$vinfo" && \ - func_warning "\`-version-info/-version-number' is ignored for convenience libraries" - - test -n "$release" && \ - func_warning "\`-release' is ignored for convenience libraries" - else - - # Parse the version information argument. - save_ifs="$IFS"; IFS=':' - set dummy $vinfo 0 0 0 - shift - IFS="$save_ifs" - - test -n "$7" && \ - func_fatal_help "too many parameters to \`-version-info'" - - # convert absolute version numbers to libtool ages - # this retains compatibility with .la files and attempts - # to make the code below a bit more comprehensible - - case $vinfo_number in - yes) - number_major="$1" - number_minor="$2" - number_revision="$3" - # - # There are really only two kinds -- those that - # use the current revision as the major version - # and those that subtract age and use age as - # a minor version. But, then there is irix - # which has an extra 1 added just for fun - # - case $version_type in - darwin|linux|osf|windows|none) - func_arith $number_major + $number_minor - current=$func_arith_result - age="$number_minor" - revision="$number_revision" - ;; - freebsd-aout|freebsd-elf|sunos) - current="$number_major" - revision="$number_minor" - age="0" - ;; - irix|nonstopux) - func_arith $number_major + $number_minor - current=$func_arith_result - age="$number_minor" - revision="$number_minor" - lt_irix_increment=no - ;; - esac - ;; - no) - current="$1" - revision="$2" - age="$3" - ;; - esac - - # Check that each of the things are valid numbers. - case $current in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - func_error "CURRENT \`$current' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" - ;; - esac - - case $revision in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - func_error "REVISION \`$revision' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" - ;; - esac - - case $age in - 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; - *) - func_error "AGE \`$age' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" - ;; - esac - - if test "$age" -gt "$current"; then - func_error "AGE \`$age' is greater than the current interface number \`$current'" - func_fatal_error "\`$vinfo' is not valid version information" - fi - - # Calculate the version variables. - major= - versuffix= - verstring= - case $version_type in - none) ;; - - darwin) - # Like Linux, but with the current version available in - # verstring for coding it into the library header - func_arith $current - $age - major=.$func_arith_result - versuffix="$major.$age.$revision" - # Darwin ld doesn't like 0 for these options... - func_arith $current + 1 - minor_current=$func_arith_result - xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" - verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" - ;; - - freebsd-aout) - major=".$current" - versuffix=".$current.$revision"; - ;; - - freebsd-elf) - major=".$current" - versuffix=".$current" - ;; - - irix | nonstopux) - if test "X$lt_irix_increment" = "Xno"; then - func_arith $current - $age - else - func_arith $current - $age + 1 - fi - major=$func_arith_result - - case $version_type in - nonstopux) verstring_prefix=nonstopux ;; - *) verstring_prefix=sgi ;; - esac - verstring="$verstring_prefix$major.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$revision - while test "$loop" -ne 0; do - func_arith $revision - $loop - iface=$func_arith_result - func_arith $loop - 1 - loop=$func_arith_result - verstring="$verstring_prefix$major.$iface:$verstring" - done - - # Before this point, $major must not contain `.'. - major=.$major - versuffix="$major.$revision" - ;; - - linux) - func_arith $current - $age - major=.$func_arith_result - versuffix="$major.$age.$revision" - ;; - - osf) - func_arith $current - $age - major=.$func_arith_result - versuffix=".$current.$age.$revision" - verstring="$current.$age.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$age - while test "$loop" -ne 0; do - func_arith $current - $loop - iface=$func_arith_result - func_arith $loop - 1 - loop=$func_arith_result - verstring="$verstring:${iface}.0" - done - - # Make executables depend on our current version. - verstring="$verstring:${current}.0" - ;; - - qnx) - major=".$current" - versuffix=".$current" - ;; - - sunos) - major=".$current" - versuffix=".$current.$revision" - ;; - - windows) - # Use '-' rather than '.', since we only want one - # extension on DOS 8.3 filesystems. - func_arith $current - $age - major=$func_arith_result - versuffix="-$major" - ;; - - *) - func_fatal_configuration "unknown library version type \`$version_type'" - ;; - esac - - # Clear the version info if we defaulted, and they specified a release. - if test -z "$vinfo" && test -n "$release"; then - major= - case $version_type in - darwin) - # we can't check for "0.0" in archive_cmds due to quoting - # problems, so we reset it completely - verstring= - ;; - *) - verstring="0.0" - ;; - esac - if test "$need_version" = no; then - versuffix= - else - versuffix=".0.0" - fi - fi - - # Remove version info from name if versioning should be avoided - if test "$avoid_version" = yes && test "$need_version" = no; then - major= - versuffix= - verstring="" - fi - - # Check to see if the archive will have undefined symbols. - if test "$allow_undefined" = yes; then - if test "$allow_undefined_flag" = unsupported; then - func_warning "undefined symbols not allowed in $host shared libraries" - build_libtool_libs=no - build_old_libs=yes - fi - else - # Don't allow undefined symbols. - allow_undefined_flag="$no_undefined_flag" - fi - - fi - - func_generate_dlsyms "$libname" "$libname" "yes" - libobjs="$libobjs $symfileobj" - test "X$libobjs" = "X " && libobjs= - - if test "$mode" != relink; then - # Remove our outputs, but don't remove object files since they - # may have been created when compiling PIC objects. - removelist= - tempremovelist=`$ECHO "$output_objdir/*"` - for p in $tempremovelist; do - case $p in - *.$objext | *.gcno) - ;; - $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) - if test "X$precious_files_regex" != "X"; then - if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 - then - continue - fi - fi - removelist="$removelist $p" - ;; - *) ;; - esac - done - test -n "$removelist" && \ - func_show_eval "${RM}r \$removelist" - fi - - # Now set the variables for building old libraries. - if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then - oldlibs="$oldlibs $output_objdir/$libname.$libext" - - # Transform .lo files to .o files. - oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` - fi - - # Eliminate all temporary directories. - #for path in $notinst_path; do - # lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"` - # deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"` - # dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"` - #done - - if test -n "$xrpath"; then - # If the user specified any rpath flags, then add them. - temp_xrpath= - for libdir in $xrpath; do - temp_xrpath="$temp_xrpath -R$libdir" - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" ;; - esac - done - if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then - dependency_libs="$temp_xrpath $dependency_libs" - fi - fi - - # Make sure dlfiles contains only unique files that won't be dlpreopened - old_dlfiles="$dlfiles" - dlfiles= - for lib in $old_dlfiles; do - case " $dlprefiles $dlfiles " in - *" $lib "*) ;; - *) dlfiles="$dlfiles $lib" ;; - esac - done - - # Make sure dlprefiles contains only unique files - old_dlprefiles="$dlprefiles" - dlprefiles= - for lib in $old_dlprefiles; do - case "$dlprefiles " in - *" $lib "*) ;; - *) dlprefiles="$dlprefiles $lib" ;; - esac - done - - if test "$build_libtool_libs" = yes; then - if test -n "$rpath"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*) - # these systems don't actually have a c library (as such)! - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C library is in the System framework - deplibs="$deplibs System.ltframework" - ;; - *-*-netbsd*) - # Don't link with libc until the a.out ld.so is fixed. - ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) - # Do not include libc due to us having libc/libc_r. - ;; - *-*-sco3.2v5* | *-*-sco5v6*) - # Causes problems with __ctype - ;; - *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) - # Compiler inserts libc in the correct place for threads to work - ;; - *) - # Add libc to deplibs on all other systems if necessary. - if test "$build_libtool_need_lc" = "yes"; then - deplibs="$deplibs -lc" - fi - ;; - esac - fi - - # Transform deplibs into only deplibs that can be linked in shared. - name_save=$name - libname_save=$libname - release_save=$release - versuffix_save=$versuffix - major_save=$major - # I'm not sure if I'm treating the release correctly. I think - # release should show up in the -l (ie -lgmp5) so we don't want to - # add it in twice. Is that correct? - release="" - versuffix="" - major="" - newdeplibs= - droppeddeps=no - case $deplibs_check_method in - pass_all) - # Don't check for shared/static. Everything works. - # This might be a little naive. We might want to check - # whether the library exists or not. But this is on - # osf3 & osf4 and I'm not really sure... Just - # implementing what was already the behavior. - newdeplibs=$deplibs - ;; - test_compile) - # This code stresses the "libraries are programs" paradigm to its - # limits. Maybe even breaks it. We compile a program, linking it - # against the deplibs as a proxy for the library. Then we can check - # whether they linked in statically or dynamically with ldd. - $opt_dry_run || $RM conftest.c - cat > conftest.c </dev/null` - for potent_lib in $potential_libs; do - # Follow soft links. - if ls -lLd "$potent_lib" 2>/dev/null | - $GREP " -> " >/dev/null; then - continue - fi - # The statement above tries to avoid entering an - # endless loop below, in case of cyclic links. - # We might still enter an endless loop, since a link - # loop can be closed while we follow links, - # but so what? - potlib="$potent_lib" - while test -h "$potlib" 2>/dev/null; do - potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` - case $potliblink in - [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; - *) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; - esac - done - if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | - $SED -e 10q | - $EGREP "$file_magic_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi - done - done - fi - if test -n "$a_deplib" ; then - droppeddeps=yes - $ECHO - $ECHO "*** Warning: linker path does not have real file for library $a_deplib." - $ECHO "*** I have the capability to make that library automatically link in when" - $ECHO "*** you link to this library. But I can only do this if you have a" - $ECHO "*** shared version of the library, which you do not appear to have" - $ECHO "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - $ECHO "*** with $libname but no candidates were found. (...for file magic test)" - else - $ECHO "*** with $libname and none of the candidates passed a file format test" - $ECHO "*** using a file magic. Last file checked: $potlib" - fi - fi - ;; - *) - # Add a -L argument. - newdeplibs="$newdeplibs $a_deplib" - ;; - esac - done # Gone through all deplibs. - ;; - match_pattern*) - set dummy $deplibs_check_method; shift - match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` - for a_deplib in $deplibs; do - case $a_deplib in - -l*) - func_stripname -l '' "$a_deplib" - name=$func_stripname_result - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - case " $predeps $postdeps " in - *" $a_deplib "*) - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - ;; - esac - fi - if test -n "$a_deplib" ; then - libname=`eval "\\$ECHO \"$libname_spec\""` - for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do - potential_libs=`ls $i/$libname[.-]* 2>/dev/null` - for potent_lib in $potential_libs; do - potlib="$potent_lib" # see symlink-check above in file_magic test - if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \ - $EGREP "$match_pattern_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi - done - done - fi - if test -n "$a_deplib" ; then - droppeddeps=yes - $ECHO - $ECHO "*** Warning: linker path does not have real file for library $a_deplib." - $ECHO "*** I have the capability to make that library automatically link in when" - $ECHO "*** you link to this library. But I can only do this if you have a" - $ECHO "*** shared version of the library, which you do not appear to have" - $ECHO "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" - else - $ECHO "*** with $libname and none of the candidates passed a file format test" - $ECHO "*** using a regex pattern. Last file checked: $potlib" - fi - fi - ;; - *) - # Add a -L argument. - newdeplibs="$newdeplibs $a_deplib" - ;; - esac - done # Gone through all deplibs. - ;; - none | unknown | *) - newdeplibs="" - tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \ - -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'` - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - for i in $predeps $postdeps ; do - # can't use Xsed below, because $i might contain '/' - tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"` - done - fi - if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' | - $GREP . >/dev/null; then - $ECHO - if test "X$deplibs_check_method" = "Xnone"; then - $ECHO "*** Warning: inter-library dependencies are not supported in this platform." - else - $ECHO "*** Warning: inter-library dependencies are not known to be supported." - fi - $ECHO "*** All declared inter-library dependencies are being dropped." - droppeddeps=yes - fi - ;; - esac - versuffix=$versuffix_save - major=$major_save - release=$release_save - libname=$libname_save - name=$name_save - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library with the System framework - newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'` - ;; - esac - - if test "$droppeddeps" = yes; then - if test "$module" = yes; then - $ECHO - $ECHO "*** Warning: libtool could not satisfy all declared inter-library" - $ECHO "*** dependencies of module $libname. Therefore, libtool will create" - $ECHO "*** a static module, that should work as long as the dlopening" - $ECHO "*** application is linked with the -dlopen flag." - if test -z "$global_symbol_pipe"; then - $ECHO - $ECHO "*** However, this would only work if libtool was able to extract symbol" - $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could" - $ECHO "*** not find such a program. So, this module is probably useless." - $ECHO "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - else - $ECHO "*** The inter-library dependencies that have been dropped here will be" - $ECHO "*** automatically added whenever a program is linked with this library" - $ECHO "*** or is declared to -dlopen it." - - if test "$allow_undefined" = no; then - $ECHO - $ECHO "*** Since this library must not contain undefined symbols," - $ECHO "*** because either the platform does not support them or" - $ECHO "*** it was explicitly requested with -no-undefined," - $ECHO "*** libtool will only create a static version of it." - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - fi - fi - # Done checking deplibs! - deplibs=$newdeplibs - fi - # Time to change all our "foo.ltframework" stuff back to "-framework foo" - case $host in - *-*-darwin*) - newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` - new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` - deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` - ;; - esac - - # move library search paths that coincide with paths to not yet - # installed libraries to the beginning of the library search list - new_libs= - for path in $notinst_path; do - case " $new_libs " in - *" -L$path/$objdir "*) ;; - *) - case " $deplibs " in - *" -L$path/$objdir "*) - new_libs="$new_libs -L$path/$objdir" ;; - esac - ;; - esac - done - for deplib in $deplibs; do - case $deplib in - -L*) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs="$new_libs $deplib" ;; - esac - ;; - *) new_libs="$new_libs $deplib" ;; - esac - done - deplibs="$new_libs" - - # All the library-specific variables (install_libdir is set above). - library_names= - old_library= - dlname= - - # Test again, we may have decided not to build it any more - if test "$build_libtool_libs" = yes; then - if test "$hardcode_into_libs" = yes; then - # Hardcode the library paths - hardcode_libdirs= - dep_rpath= - rpath="$finalize_rpath" - test "$mode" != relink && rpath="$compile_rpath$rpath" - for libdir in $rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - dep_rpath="$dep_rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - if test -n "$hardcode_libdir_flag_spec_ld"; then - eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" - else - eval dep_rpath=\"$hardcode_libdir_flag_spec\" - fi - fi - if test -n "$runpath_var" && test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath="$rpath$dir:" - done - eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" - fi - test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" - fi - - shlibpath="$finalize_shlibpath" - test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" - if test -n "$shlibpath"; then - eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" - fi - - # Get the real and link names of the library. - eval shared_ext=\"$shrext_cmds\" - eval library_names=\"$library_names_spec\" - set dummy $library_names - shift - realname="$1" - shift - - if test -n "$soname_spec"; then - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - if test -z "$dlname"; then - dlname=$soname - fi - - lib="$output_objdir/$realname" - linknames= - for link - do - linknames="$linknames $link" - done - - # Use standard objects if they are pic - test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - test "X$libobjs" = "X " && libobjs= - - delfiles= - if test -n "$export_symbols" && test -n "$include_expsyms"; then - $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" - export_symbols="$output_objdir/$libname.uexp" - delfiles="$delfiles $export_symbols" - fi - - orig_export_symbols= - case $host_os in - cygwin* | mingw* | cegcc*) - if test -n "$export_symbols" && test -z "$export_symbols_regex"; then - # exporting using user supplied symfile - if test "x`$SED 1q $export_symbols`" != xEXPORTS; then - # and it's NOT already a .def file. Must figure out - # which of the given symbols are data symbols and tag - # them as such. So, trigger use of export_symbols_cmds. - # export_symbols gets reassigned inside the "prepare - # the list of exported symbols" if statement, so the - # include_expsyms logic still works. - orig_export_symbols="$export_symbols" - export_symbols= - always_export_symbols=yes - fi - fi - ;; - esac - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then - func_verbose "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $opt_dry_run || $RM $export_symbols - cmds=$export_symbols_cmds - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - func_len " $cmd" - len=$func_len_result - if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then - func_show_eval "$cmd" 'exit $?' - skipped_export=false - else - # The command line is too long to execute in one step. - func_verbose "using reloadable object file for export list..." - skipped_export=: - # Break out early, otherwise skipped_export may be - # set to false by a later but shorter cmd. - break - fi - done - IFS="$save_ifs" - if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then - func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' - func_show_eval '$MV "${export_symbols}T" "$export_symbols"' - fi - fi - fi - - if test -n "$export_symbols" && test -n "$include_expsyms"; then - tmp_export_symbols="$export_symbols" - test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" - $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"' - fi - - if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then - # The given exports_symbols file has to be filtered, so filter it. - func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" - # FIXME: $output_objdir/$libname.filter potentially contains lots of - # 's' commands which not all seds can handle. GNU sed should be fine - # though. Also, the filter scales superlinearly with the number of - # global variables. join(1) would be nice here, but unfortunately - # isn't a blessed tool. - $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter - delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" - export_symbols=$output_objdir/$libname.def - $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols - fi - - tmp_deplibs= - for test_deplib in $deplibs; do - case " $convenience " in - *" $test_deplib "*) ;; - *) - tmp_deplibs="$tmp_deplibs $test_deplib" - ;; - esac - done - deplibs="$tmp_deplibs" - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec" && - test "$compiler_needs_object" = yes && - test -z "$libobjs"; then - # extract the archives, so we have objects to list. - # TODO: could optimize this to just extract one archive. - whole_archive_flag_spec= - fi - if test -n "$whole_archive_flag_spec"; then - save_libobjs=$libobjs - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - test "X$libobjs" = "X " && libobjs= - else - gentop="$output_objdir/${outputname}x" - generated="$generated $gentop" - - func_extract_archives $gentop $convenience - libobjs="$libobjs $func_extract_archives_result" - test "X$libobjs" = "X " && libobjs= - fi - fi - - if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then - eval flag=\"$thread_safe_flag_spec\" - linker_flags="$linker_flags $flag" - fi - - # Make a backup of the uninstalled library when relinking - if test "$mode" = relink; then - $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? - fi - - # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then - eval test_cmds=\"$module_expsym_cmds\" - cmds=$module_expsym_cmds - else - eval test_cmds=\"$module_cmds\" - cmds=$module_cmds - fi - else - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - eval test_cmds=\"$archive_expsym_cmds\" - cmds=$archive_expsym_cmds - else - eval test_cmds=\"$archive_cmds\" - cmds=$archive_cmds - fi - fi - - if test "X$skipped_export" != "X:" && - func_len " $test_cmds" && - len=$func_len_result && - test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then - : - else - # The command line is too long to link in one step, link piecewise - # or, if using GNU ld and skipped_export is not :, use a linker - # script. - - # Save the value of $output and $libobjs because we want to - # use them later. If we have whole_archive_flag_spec, we - # want to use save_libobjs as it was before - # whole_archive_flag_spec was expanded, because we can't - # assume the linker understands whole_archive_flag_spec. - # This may have to be revisited, in case too many - # convenience libraries get linked in and end up exceeding - # the spec. - if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then - save_libobjs=$libobjs - fi - save_output=$output - output_la=`$ECHO "X$output" | $Xsed -e "$basename"` - - # Clear the reloadable object creation command queue and - # initialize k to one. - test_cmds= - concat_cmds= - objlist= - last_robj= - k=1 - - if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then - output=${output_objdir}/${output_la}.lnkscript - func_verbose "creating GNU ld script: $output" - $ECHO 'INPUT (' > $output - for obj in $save_libobjs - do - $ECHO "$obj" >> $output - done - $ECHO ')' >> $output - delfiles="$delfiles $output" - elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then - output=${output_objdir}/${output_la}.lnk - func_verbose "creating linker input file list: $output" - : > $output - set x $save_libobjs - shift - firstobj= - if test "$compiler_needs_object" = yes; then - firstobj="$1 " - shift - fi - for obj - do - $ECHO "$obj" >> $output - done - delfiles="$delfiles $output" - output=$firstobj\"$file_list_spec$output\" - else - if test -n "$save_libobjs"; then - func_verbose "creating reloadable object files..." - output=$output_objdir/$output_la-${k}.$objext - eval test_cmds=\"$reload_cmds\" - func_len " $test_cmds" - len0=$func_len_result - len=$len0 - - # Loop over the list of objects to be linked. - for obj in $save_libobjs - do - func_len " $obj" - func_arith $len + $func_len_result - len=$func_arith_result - if test "X$objlist" = X || - test "$len" -lt "$max_cmd_len"; then - func_append objlist " $obj" - else - # The command $test_cmds is almost too long, add a - # command to the queue. - if test "$k" -eq 1 ; then - # The first file doesn't have a previous command to add. - eval concat_cmds=\"$reload_cmds $objlist $last_robj\" - else - # All subsequent reloadable object files will link in - # the last one created. - eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\" - fi - last_robj=$output_objdir/$output_la-${k}.$objext - func_arith $k + 1 - k=$func_arith_result - output=$output_objdir/$output_la-${k}.$objext - objlist=$obj - func_len " $last_robj" - func_arith $len0 + $func_len_result - len=$func_arith_result - fi - done - # Handle the remaining objects by creating one last - # reloadable object file. All subsequent reloadable object - # files will link in the last one created. - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" - if test -n "$last_robj"; then - eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" - fi - delfiles="$delfiles $output" - - else - output= - fi - - if ${skipped_export-false}; then - func_verbose "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $opt_dry_run || $RM $export_symbols - libobjs=$output - # Append the command to create the export file. - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" - if test -n "$last_robj"; then - eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" - fi - fi - - test -n "$save_libobjs" && - func_verbose "creating a temporary reloadable object file: $output" - - # Loop through the commands generated above and execute them. - save_ifs="$IFS"; IFS='~' - for cmd in $concat_cmds; do - IFS="$save_ifs" - $opt_silent || { - func_quote_for_expand "$cmd" - eval "func_echo $func_quote_for_expand_result" - } - $opt_dry_run || eval "$cmd" || { - lt_exit=$? - - # Restore the uninstalled library and exit - if test "$mode" = relink; then - ( cd "$output_objdir" && \ - $RM "${realname}T" && \ - $MV "${realname}U" "$realname" ) - fi - - exit $lt_exit - } - done - IFS="$save_ifs" - - if test -n "$export_symbols_regex" && ${skipped_export-false}; then - func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' - func_show_eval '$MV "${export_symbols}T" "$export_symbols"' - fi - fi - - if ${skipped_export-false}; then - if test -n "$export_symbols" && test -n "$include_expsyms"; then - tmp_export_symbols="$export_symbols" - test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" - $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"' - fi - - if test -n "$orig_export_symbols"; then - # The given exports_symbols file has to be filtered, so filter it. - func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" - # FIXME: $output_objdir/$libname.filter potentially contains lots of - # 's' commands which not all seds can handle. GNU sed should be fine - # though. Also, the filter scales superlinearly with the number of - # global variables. join(1) would be nice here, but unfortunately - # isn't a blessed tool. - $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter - delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" - export_symbols=$output_objdir/$libname.def - $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols - fi - fi - - libobjs=$output - # Restore the value of output. - output=$save_output - - if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - test "X$libobjs" = "X " && libobjs= - fi - # Expand the library linking commands again to reset the - # value of $libobjs for piecewise linking. - - # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then - if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then - cmds=$module_expsym_cmds - else - cmds=$module_cmds - fi - else - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - cmds=$archive_expsym_cmds - else - cmds=$archive_cmds - fi - fi - fi - - if test -n "$delfiles"; then - # Append the command to remove temporary files to $cmds. - eval cmds=\"\$cmds~\$RM $delfiles\" - fi - - # Add any objects from preloaded convenience libraries - if test -n "$dlprefiles"; then - gentop="$output_objdir/${outputname}x" - generated="$generated $gentop" - - func_extract_archives $gentop $dlprefiles - libobjs="$libobjs $func_extract_archives_result" - test "X$libobjs" = "X " && libobjs= - fi - - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - eval cmd=\"$cmd\" - $opt_silent || { - func_quote_for_expand "$cmd" - eval "func_echo $func_quote_for_expand_result" - } - $opt_dry_run || eval "$cmd" || { - lt_exit=$? - - # Restore the uninstalled library and exit - if test "$mode" = relink; then - ( cd "$output_objdir" && \ - $RM "${realname}T" && \ - $MV "${realname}U" "$realname" ) - fi - - exit $lt_exit - } - done - IFS="$save_ifs" - - # Restore the uninstalled library and exit - if test "$mode" = relink; then - $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? - - if test -n "$convenience"; then - if test -z "$whole_archive_flag_spec"; then - func_show_eval '${RM}r "$gentop"' - fi - fi - - exit $EXIT_SUCCESS - fi - - # Create links to the real library. - for linkname in $linknames; do - if test "$realname" != "$linkname"; then - func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' - fi - done - - # If -module or -export-dynamic was specified, set the dlname. - if test "$module" = yes || test "$export_dynamic" = yes; then - # On all known operating systems, these are identical. - dlname="$soname" - fi - fi - ;; - - obj) - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - func_warning "\`-dlopen' is ignored for objects" - fi - - case " $deplibs" in - *\ -l* | *\ -L*) - func_warning "\`-l' and \`-L' are ignored for objects" ;; - esac - - test -n "$rpath" && \ - func_warning "\`-rpath' is ignored for objects" - - test -n "$xrpath" && \ - func_warning "\`-R' is ignored for objects" - - test -n "$vinfo" && \ - func_warning "\`-version-info' is ignored for objects" - - test -n "$release" && \ - func_warning "\`-release' is ignored for objects" - - case $output in - *.lo) - test -n "$objs$old_deplibs" && \ - func_fatal_error "cannot build library object \`$output' from non-libtool objects" - - libobj=$output - func_lo2o "$libobj" - obj=$func_lo2o_result - ;; - *) - libobj= - obj="$output" - ;; - esac - - # Delete the old objects. - $opt_dry_run || $RM $obj $libobj - - # Objects from convenience libraries. This assumes - # single-version convenience libraries. Whenever we create - # different ones for PIC/non-PIC, this we'll have to duplicate - # the extraction. - reload_conv_objs= - gentop= - # reload_cmds runs $LD directly, so let us get rid of - # -Wl from whole_archive_flag_spec and hope we can get by with - # turning comma into space.. - wl= - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then - eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" - reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'` - else - gentop="$output_objdir/${obj}x" - generated="$generated $gentop" - - func_extract_archives $gentop $convenience - reload_conv_objs="$reload_objs $func_extract_archives_result" - fi - fi - - # Create the old-style object. - reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test - - output="$obj" - func_execute_cmds "$reload_cmds" 'exit $?' - - # Exit if we aren't doing a library object file. - if test -z "$libobj"; then - if test -n "$gentop"; then - func_show_eval '${RM}r "$gentop"' - fi - - exit $EXIT_SUCCESS - fi - - if test "$build_libtool_libs" != yes; then - if test -n "$gentop"; then - func_show_eval '${RM}r "$gentop"' - fi - - # Create an invalid libtool object if no PIC, so that we don't - # accidentally link it into a program. - # $show "echo timestamp > $libobj" - # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? - exit $EXIT_SUCCESS - fi - - if test -n "$pic_flag" || test "$pic_mode" != default; then - # Only do commands if we really have different PIC objects. - reload_objs="$libobjs $reload_conv_objs" - output="$libobj" - func_execute_cmds "$reload_cmds" 'exit $?' - fi - - if test -n "$gentop"; then - func_show_eval '${RM}r "$gentop"' - fi - - exit $EXIT_SUCCESS - ;; - - prog) - case $host in - *cygwin*) func_stripname '' '.exe' "$output" - output=$func_stripname_result.exe;; - esac - test -n "$vinfo" && \ - func_warning "\`-version-info' is ignored for programs" - - test -n "$release" && \ - func_warning "\`-release' is ignored for programs" - - test "$preload" = yes \ - && test "$dlopen_support" = unknown \ - && test "$dlopen_self" = unknown \ - && test "$dlopen_self_static" = unknown && \ - func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library is the System framework - compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'` - finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'` - ;; - esac - - case $host in - *-*-darwin*) - # Don't allow lazy linking, it breaks C++ global constructors - # But is supposedly fixed on 10.4 or later (yay!). - if test "$tagname" = CXX ; then - case ${MACOSX_DEPLOYMENT_TARGET-10.0} in - 10.[0123]) - compile_command="$compile_command ${wl}-bind_at_load" - finalize_command="$finalize_command ${wl}-bind_at_load" - ;; - esac - fi - # Time to change all our "foo.ltframework" stuff back to "-framework foo" - compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` - finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` - ;; - esac - - - # move library search paths that coincide with paths to not yet - # installed libraries to the beginning of the library search list - new_libs= - for path in $notinst_path; do - case " $new_libs " in - *" -L$path/$objdir "*) ;; - *) - case " $compile_deplibs " in - *" -L$path/$objdir "*) - new_libs="$new_libs -L$path/$objdir" ;; - esac - ;; - esac - done - for deplib in $compile_deplibs; do - case $deplib in - -L*) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs="$new_libs $deplib" ;; - esac - ;; - *) new_libs="$new_libs $deplib" ;; - esac - done - compile_deplibs="$new_libs" - - - compile_command="$compile_command $compile_deplibs" - finalize_command="$finalize_command $finalize_deplibs" - - if test -n "$rpath$xrpath"; then - # If the user specified any rpath flags, then add them. - for libdir in $rpath $xrpath; do - # This is the magic to use -rpath. - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" ;; - esac - done - fi - - # Now hardcode the library paths - rpath= - hardcode_libdirs= - for libdir in $compile_rpath $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath="$rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` - case :$dllsearchpath: in - *":$libdir:"*) ;; - ::) dllsearchpath=$libdir;; - *) dllsearchpath="$dllsearchpath:$libdir";; - esac - case :$dllsearchpath: in - *":$testbindir:"*) ;; - ::) dllsearchpath=$testbindir;; - *) dllsearchpath="$dllsearchpath:$testbindir";; - esac - ;; - esac - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - compile_rpath="$rpath" - - rpath= - hardcode_libdirs= - for libdir in $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath="$rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$finalize_perm_rpath " in - *" $libdir "*) ;; - *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - finalize_rpath="$rpath" - - if test -n "$libobjs" && test "$build_old_libs" = yes; then - # Transform all the library objects into standard objects. - compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - fi - - func_generate_dlsyms "$outputname" "@PROGRAM@" "no" - - # template prelinking step - if test -n "$prelink_cmds"; then - func_execute_cmds "$prelink_cmds" 'exit $?' - fi - - wrappers_required=yes - case $host in - *cygwin* | *mingw* ) - if test "$build_libtool_libs" != yes; then - wrappers_required=no - fi - ;; - *cegcc) - # Disable wrappers for cegcc, we are cross compiling anyway. - wrappers_required=no - ;; - *) - if test "$need_relink" = no || test "$build_libtool_libs" != yes; then - wrappers_required=no - fi - ;; - esac - if test "$wrappers_required" = no; then - # Replace the output file specification. - compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - link_command="$compile_command$compile_rpath" - - # We have no uninstalled library dependencies, so finalize right now. - exit_status=0 - func_show_eval "$link_command" 'exit_status=$?' - - # Delete the generated files. - if test -f "$output_objdir/${outputname}S.${objext}"; then - func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' - fi - - exit $exit_status - fi - - if test -n "$compile_shlibpath$finalize_shlibpath"; then - compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" - fi - if test -n "$finalize_shlibpath"; then - finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" - fi - - compile_var= - finalize_var= - if test -n "$runpath_var"; then - if test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath="$rpath$dir:" - done - compile_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - if test -n "$finalize_perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $finalize_perm_rpath; do - rpath="$rpath$dir:" - done - finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - fi - - if test "$no_install" = yes; then - # We don't need to create a wrapper script. - link_command="$compile_var$compile_command$compile_rpath" - # Replace the output file specification. - link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - # Delete the old output file. - $opt_dry_run || $RM $output - # Link the executable and exit - func_show_eval "$link_command" 'exit $?' - exit $EXIT_SUCCESS - fi - - if test "$hardcode_action" = relink; then - # Fast installation is not supported - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - - func_warning "this platform does not like uninstalled shared libraries" - func_warning "\`$output' will be relinked during installation" - else - if test "$fast_install" != no; then - link_command="$finalize_var$compile_command$finalize_rpath" - if test "$fast_install" = yes; then - relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` - else - # fast_install is set to needless - relink_command= - fi - else - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - fi - fi - - # Replace the output file specification. - link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` - - # Delete the old output files. - $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname - - func_show_eval "$link_command" 'exit $?' - - # Now create the wrapper script. - func_verbose "creating $output" - - # Quote the relink command for shipping. - if test -n "$relink_command"; then - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - func_quote_for_eval "$var_value" - relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" - fi - done - relink_command="(cd `pwd`; $relink_command)" - relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"` - fi - - # Quote $ECHO for shipping. - if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then - case $progpath in - [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; - *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; - esac - qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"` - else - qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"` - fi - - # Only actually do things if not in dry run mode. - $opt_dry_run || { - # win32 will think the script is a binary if it has - # a .exe suffix, so we strip it off here. - case $output in - *.exe) func_stripname '' '.exe' "$output" - output=$func_stripname_result ;; - esac - # test for cygwin because mv fails w/o .exe extensions - case $host in - *cygwin*) - exeext=.exe - func_stripname '' '.exe' "$outputname" - outputname=$func_stripname_result ;; - *) exeext= ;; - esac - case $host in - *cygwin* | *mingw* ) - func_dirname_and_basename "$output" "" "." - output_name=$func_basename_result - output_path=$func_dirname_result - cwrappersource="$output_path/$objdir/lt-$output_name.c" - cwrapper="$output_path/$output_name.exe" - $RM $cwrappersource $cwrapper - trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 - - func_emit_cwrapperexe_src > $cwrappersource - - # The wrapper executable is built using the $host compiler, - # because it contains $host paths and files. If cross- - # compiling, it, like the target executable, must be - # executed on the $host or under an emulation environment. - $opt_dry_run || { - $LTCC $LTCFLAGS -o $cwrapper $cwrappersource - $STRIP $cwrapper - } - - # Now, create the wrapper script for func_source use: - func_ltwrapper_scriptname $cwrapper - $RM $func_ltwrapper_scriptname_result - trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 - $opt_dry_run || { - # note: this script will not be executed, so do not chmod. - if test "x$build" = "x$host" ; then - $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result - else - func_emit_wrapper no > $func_ltwrapper_scriptname_result - fi - } - ;; - * ) - $RM $output - trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 - - func_emit_wrapper no > $output - chmod +x $output - ;; - esac - } - exit $EXIT_SUCCESS - ;; - esac - - # See if we need to build an old-fashioned archive. - for oldlib in $oldlibs; do - - if test "$build_libtool_libs" = convenience; then - oldobjs="$libobjs_save $symfileobj" - addlibs="$convenience" - build_libtool_libs=no - else - if test "$build_libtool_libs" = module; then - oldobjs="$libobjs_save" - build_libtool_libs=no - else - oldobjs="$old_deplibs $non_pic_objects" - if test "$preload" = yes && test -f "$symfileobj"; then - oldobjs="$oldobjs $symfileobj" - fi - fi - addlibs="$old_convenience" - fi - - if test -n "$addlibs"; then - gentop="$output_objdir/${outputname}x" - generated="$generated $gentop" - - func_extract_archives $gentop $addlibs - oldobjs="$oldobjs $func_extract_archives_result" - fi - - # Do each command in the archive commands. - if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then - cmds=$old_archive_from_new_cmds - else - - # Add any objects from preloaded convenience libraries - if test -n "$dlprefiles"; then - gentop="$output_objdir/${outputname}x" - generated="$generated $gentop" - - func_extract_archives $gentop $dlprefiles - oldobjs="$oldobjs $func_extract_archives_result" - fi - - # POSIX demands no paths to be encoded in archives. We have - # to avoid creating archives with duplicate basenames if we - # might have to extract them afterwards, e.g., when creating a - # static archive out of a convenience library, or when linking - # the entirety of a libtool archive into another (currently - # not supported by libtool). - if (for obj in $oldobjs - do - func_basename "$obj" - $ECHO "$func_basename_result" - done | sort | sort -uc >/dev/null 2>&1); then - : - else - $ECHO "copying selected object files to avoid basename conflicts..." - gentop="$output_objdir/${outputname}x" - generated="$generated $gentop" - func_mkdir_p "$gentop" - save_oldobjs=$oldobjs - oldobjs= - counter=1 - for obj in $save_oldobjs - do - func_basename "$obj" - objbase="$func_basename_result" - case " $oldobjs " in - " ") oldobjs=$obj ;; - *[\ /]"$objbase "*) - while :; do - # Make sure we don't pick an alternate name that also - # overlaps. - newobj=lt$counter-$objbase - func_arith $counter + 1 - counter=$func_arith_result - case " $oldobjs " in - *[\ /]"$newobj "*) ;; - *) if test ! -f "$gentop/$newobj"; then break; fi ;; - esac - done - func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" - oldobjs="$oldobjs $gentop/$newobj" - ;; - *) oldobjs="$oldobjs $obj" ;; - esac - done - fi - eval cmds=\"$old_archive_cmds\" - - func_len " $cmds" - len=$func_len_result - if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then - cmds=$old_archive_cmds - else - # the command line is too long to link in one step, link in parts - func_verbose "using piecewise archive linking..." - save_RANLIB=$RANLIB - RANLIB=: - objlist= - concat_cmds= - save_oldobjs=$oldobjs - oldobjs= - # Is there a better way of finding the last object in the list? - for obj in $save_oldobjs - do - last_oldobj=$obj - done - eval test_cmds=\"$old_archive_cmds\" - func_len " $test_cmds" - len0=$func_len_result - len=$len0 - for obj in $save_oldobjs - do - func_len " $obj" - func_arith $len + $func_len_result - len=$func_arith_result - func_append objlist " $obj" - if test "$len" -lt "$max_cmd_len"; then - : - else - # the above command should be used before it gets too long - oldobjs=$objlist - if test "$obj" = "$last_oldobj" ; then - RANLIB=$save_RANLIB - fi - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" - objlist= - len=$len0 - fi - done - RANLIB=$save_RANLIB - oldobjs=$objlist - if test "X$oldobjs" = "X" ; then - eval cmds=\"\$concat_cmds\" - else - eval cmds=\"\$concat_cmds~\$old_archive_cmds\" - fi - fi - fi - func_execute_cmds "$cmds" 'exit $?' - done - - test -n "$generated" && \ - func_show_eval "${RM}r$generated" - - # Now create the libtool archive. - case $output in - *.la) - old_library= - test "$build_old_libs" = yes && old_library="$libname.$libext" - func_verbose "creating $output" - - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - func_quote_for_eval "$var_value" - relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" - fi - done - # Quote the link command for shipping. - relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" - relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"` - if test "$hardcode_automatic" = yes ; then - relink_command= - fi - - # Only create the output if not a dry run. - $opt_dry_run || { - for installed in no yes; do - if test "$installed" = yes; then - if test -z "$install_libdir"; then - break - fi - output="$output_objdir/$outputname"i - # Replace all uninstalled libtool libraries with the installed ones - newdependency_libs= - for deplib in $dependency_libs; do - case $deplib in - *.la) - func_basename "$deplib" - name="$func_basename_result" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - test -z "$libdir" && \ - func_fatal_error "\`$deplib' is not a valid libtool archive" - newdependency_libs="$newdependency_libs $libdir/$name" - ;; - *) newdependency_libs="$newdependency_libs $deplib" ;; - esac - done - dependency_libs="$newdependency_libs" - newdlfiles= - - for lib in $dlfiles; do - case $lib in - *.la) - func_basename "$lib" - name="$func_basename_result" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - test -z "$libdir" && \ - func_fatal_error "\`$lib' is not a valid libtool archive" - newdlfiles="$newdlfiles $libdir/$name" - ;; - *) newdlfiles="$newdlfiles $lib" ;; - esac - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - case $lib in - *.la) - # Only pass preopened files to the pseudo-archive (for - # eventual linking with the app. that links it) if we - # didn't already link the preopened objects directly into - # the library: - func_basename "$lib" - name="$func_basename_result" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - test -z "$libdir" && \ - func_fatal_error "\`$lib' is not a valid libtool archive" - newdlprefiles="$newdlprefiles $libdir/$name" - ;; - esac - done - dlprefiles="$newdlprefiles" - else - newdlfiles= - for lib in $dlfiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - newdlfiles="$newdlfiles $abs" - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - newdlprefiles="$newdlprefiles $abs" - done - dlprefiles="$newdlprefiles" - fi - $RM $output - # place dlname in correct position for cygwin - tdlname=$dlname - case $host,$output,$installed,$module,$dlname in - *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; - esac - $ECHO > $output "\ -# $outputname - a libtool library file -# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='$tdlname' - -# Names of this library. -library_names='$library_names' - -# The name of the static archive. -old_library='$old_library' - -# Linker flags that can not go in dependency_libs. -inherited_linker_flags='$new_inherited_linker_flags' - -# Libraries that this one depends upon. -dependency_libs='$dependency_libs' - -# Names of additional weak libraries provided by this library -weak_library_names='$weak_libs' - -# Version information for $libname. -current=$current -age=$age -revision=$revision - -# Is this an already installed library? -installed=$installed - -# Should we warn about portability when linking against -modules? -shouldnotlink=$module - -# Files to dlopen/dlpreopen -dlopen='$dlfiles' -dlpreopen='$dlprefiles' - -# Directory that this library needs to be installed in: -libdir='$install_libdir'" - if test "$installed" = no && test "$need_relink" = yes; then - $ECHO >> $output "\ -relink_command=\"$relink_command\"" - fi - done - } - - # Do a symbolic link so that the libtool archive can be found in - # LD_LIBRARY_PATH before the program is installed. - func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' - ;; - esac - exit $EXIT_SUCCESS -} - -{ test "$mode" = link || test "$mode" = relink; } && - func_mode_link ${1+"$@"} - - -# func_mode_uninstall arg... -func_mode_uninstall () -{ - $opt_debug - RM="$nonopt" - files= - rmforce= - exit_status=0 - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - for arg - do - case $arg in - -f) RM="$RM $arg"; rmforce=yes ;; - -*) RM="$RM $arg" ;; - *) files="$files $arg" ;; - esac - done - - test -z "$RM" && \ - func_fatal_help "you must specify an RM program" - - rmdirs= - - origobjdir="$objdir" - for file in $files; do - func_dirname "$file" "" "." - dir="$func_dirname_result" - if test "X$dir" = X.; then - objdir="$origobjdir" - else - objdir="$dir/$origobjdir" - fi - func_basename "$file" - name="$func_basename_result" - test "$mode" = uninstall && objdir="$dir" - - # Remember objdir for removal later, being careful to avoid duplicates - if test "$mode" = clean; then - case " $rmdirs " in - *" $objdir "*) ;; - *) rmdirs="$rmdirs $objdir" ;; - esac - fi - - # Don't error if the file doesn't exist and rm -f was used. - if { test -L "$file"; } >/dev/null 2>&1 || - { test -h "$file"; } >/dev/null 2>&1 || - test -f "$file"; then - : - elif test -d "$file"; then - exit_status=1 - continue - elif test "$rmforce" = yes; then - continue - fi - - rmfiles="$file" - - case $name in - *.la) - # Possibly a libtool archive, so verify it. - if func_lalib_p "$file"; then - func_source $dir/$name - - # Delete the libtool libraries and symlinks. - for n in $library_names; do - rmfiles="$rmfiles $objdir/$n" - done - test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" - - case "$mode" in - clean) - case " $library_names " in - # " " in the beginning catches empty $dlname - *" $dlname "*) ;; - *) rmfiles="$rmfiles $objdir/$dlname" ;; - esac - test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" - ;; - uninstall) - if test -n "$library_names"; then - # Do each command in the postuninstall commands. - func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' - fi - - if test -n "$old_library"; then - # Do each command in the old_postuninstall commands. - func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' - fi - # FIXME: should reinstall the best remaining shared library. - ;; - esac - fi - ;; - - *.lo) - # Possibly a libtool object, so verify it. - if func_lalib_p "$file"; then - - # Read the .lo file - func_source $dir/$name - - # Add PIC object to the list of files to remove. - if test -n "$pic_object" && - test "$pic_object" != none; then - rmfiles="$rmfiles $dir/$pic_object" - fi - - # Add non-PIC object to the list of files to remove. - if test -n "$non_pic_object" && - test "$non_pic_object" != none; then - rmfiles="$rmfiles $dir/$non_pic_object" - fi - fi - ;; - - *) - if test "$mode" = clean ; then - noexename=$name - case $file in - *.exe) - func_stripname '' '.exe' "$file" - file=$func_stripname_result - func_stripname '' '.exe' "$name" - noexename=$func_stripname_result - # $file with .exe has already been added to rmfiles, - # add $file without .exe - rmfiles="$rmfiles $file" - ;; - esac - # Do a test to see if this is a libtool program. - if func_ltwrapper_p "$file"; then - if func_ltwrapper_executable_p "$file"; then - func_ltwrapper_scriptname "$file" - relink_command= - func_source $func_ltwrapper_scriptname_result - rmfiles="$rmfiles $func_ltwrapper_scriptname_result" - else - relink_command= - func_source $dir/$noexename - fi - - # note $name still contains .exe if it was in $file originally - # as does the version of $file that was added into $rmfiles - rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" - if test "$fast_install" = yes && test -n "$relink_command"; then - rmfiles="$rmfiles $objdir/lt-$name" - fi - if test "X$noexename" != "X$name" ; then - rmfiles="$rmfiles $objdir/lt-${noexename}.c" - fi - fi - fi - ;; - esac - func_show_eval "$RM $rmfiles" 'exit_status=1' - done - objdir="$origobjdir" - - # Try to remove the ${objdir}s in the directories where we deleted files - for dir in $rmdirs; do - if test -d "$dir"; then - func_show_eval "rmdir $dir >/dev/null 2>&1" - fi - done - - exit $exit_status -} - -{ test "$mode" = uninstall || test "$mode" = clean; } && - func_mode_uninstall ${1+"$@"} - -test -z "$mode" && { - help="$generic_help" - func_fatal_help "you must specify a MODE" -} - -test -z "$exec_cmd" && \ - func_fatal_help "invalid operation mode \`$mode'" - -if test -n "$exec_cmd"; then - eval exec "$exec_cmd" - exit $EXIT_FAILURE -fi - -exit $exit_status - - -# The TAGs below are defined such that we never get into a situation -# in which we disable both kinds of libraries. Given conflicting -# choices, we go for a static library, that is the most portable, -# since we can't tell whether shared libraries were disabled because -# the user asked for that or because the platform doesn't support -# them. This is particularly important on AIX, because we don't -# support having both static and shared libraries enabled at the same -# time on that platform, so we default to a shared-only configuration. -# If a disable-shared tag is given, we'll fallback to a static-only -# configuration. But we'll never go from static-only to shared-only. - -# ### BEGIN LIBTOOL TAG CONFIG: disable-shared -build_libtool_libs=no -build_old_libs=yes -# ### END LIBTOOL TAG CONFIG: disable-shared - -# ### BEGIN LIBTOOL TAG CONFIG: disable-static -build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` -# ### END LIBTOOL TAG CONFIG: disable-static - -# Local Variables: -# mode:shell-script -# sh-indentation:2 -# End: -# vi:sw=2 - diff --git a/build-scripts/mkinstalldirs b/build-scripts/mkinstalldirs deleted file mode 100755 index 55d537f..0000000 --- a/build-scripts/mkinstalldirs +++ /dev/null @@ -1,162 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy - -scriptversion=2009-04-28.21; # UTC - -# Original author: Noah Friedman -# Created: 1993-05-16 -# Public domain. -# -# This file is maintained in Automake, please report -# bugs to or send patches to -# . - -nl=' -' -IFS=" "" $nl" -errstatus=0 -dirmode= - -usage="\ -Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... - -Create each directory DIR (with mode MODE, if specified), including all -leading file name components. - -Report bugs to ." - -# process command line arguments -while test $# -gt 0 ; do - case $1 in - -h | --help | --h*) # -h for help - echo "$usage" - exit $? - ;; - -m) # -m PERM arg - shift - test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } - dirmode=$1 - shift - ;; - --version) - echo "$0 $scriptversion" - exit $? - ;; - --) # stop option processing - shift - break - ;; - -*) # unknown option - echo "$usage" 1>&2 - exit 1 - ;; - *) # first non-opt arg - break - ;; - esac -done - -for file -do - if test -d "$file"; then - shift - else - break - fi -done - -case $# in - 0) exit 0 ;; -esac - -# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and -# mkdir -p a/c at the same time, both will detect that a is missing, -# one will create a, then the other will try to create a and die with -# a "File exists" error. This is a problem when calling mkinstalldirs -# from a parallel make. We use --version in the probe to restrict -# ourselves to GNU mkdir, which is thread-safe. -case $dirmode in - '') - if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then - echo "mkdir -p -- $*" - exec mkdir -p -- "$@" - else - # On NextStep and OpenStep, the 'mkdir' command does not - # recognize any option. It will interpret all options as - # directories to create, and then abort because '.' already - # exists. - test -d ./-p && rmdir ./-p - test -d ./--version && rmdir ./--version - fi - ;; - *) - if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && - test ! -d ./--version; then - echo "mkdir -m $dirmode -p -- $*" - exec mkdir -m "$dirmode" -p -- "$@" - else - # Clean up after NextStep and OpenStep mkdir. - for d in ./-m ./-p ./--version "./$dirmode"; - do - test -d $d && rmdir $d - done - fi - ;; -esac - -for file -do - case $file in - /*) pathcomp=/ ;; - *) pathcomp= ;; - esac - oIFS=$IFS - IFS=/ - set fnord $file - shift - IFS=$oIFS - - for d - do - test "x$d" = x && continue - - pathcomp=$pathcomp$d - case $pathcomp in - -*) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - else - if test ! -z "$dirmode"; then - echo "chmod $dirmode $pathcomp" - lasterr= - chmod "$dirmode" "$pathcomp" || lasterr=$? - - if test ! -z "$lasterr"; then - errstatus=$lasterr - fi - fi - fi - fi - - pathcomp=$pathcomp/ - done -done - -exit $errstatus - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/configure b/configure deleted file mode 100755 index 4df0be5..0000000 --- a/configure +++ /dev/null @@ -1,17164 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69. -# -# -# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. -# -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -# Use a proper internal environment variable to ensure we don't fall - # into an infinite loop, continuously re-executing ourselves. - if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then - _as_can_reexec=no; export _as_can_reexec; - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -as_fn_exit 255 - fi - # We don't want this to propagate to other subprocesses. - { _as_can_reexec=; unset _as_can_reexec;} -if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi -" - as_required="as_fn_return () { (exit \$1); } -as_fn_success () { as_fn_return 0; } -as_fn_failure () { as_fn_return 1; } -as_fn_ret_success () { return 0; } -as_fn_ret_failure () { return 1; } - -exitcode=0 -as_fn_success || { exitcode=1; echo as_fn_success failed.; } -as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } -as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } -as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } -if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : - -else - exitcode=1; echo positional parameters were not saved. -fi -test x\$exitcode = x0 || exit 1 -test -x / || exit 1" - as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO - as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO - eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && - test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 -test \$(( 1 + 1 )) = 2 || exit 1" - if (eval "$as_required") 2>/dev/null; then : - as_have_required=yes -else - as_have_required=no -fi - if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : - -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_found=false -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - as_found=: - case $as_dir in #( - /*) - for as_base in sh bash ksh sh5; do - # Try only shells that exist, to save several forks. - as_shell=$as_dir/$as_base - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : - CONFIG_SHELL=$as_shell as_have_required=yes - if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : - break 2 -fi -fi - done;; - esac - as_found=false -done -$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : - CONFIG_SHELL=$SHELL as_have_required=yes -fi; } -IFS=$as_save_IFS - - - if test "x$CONFIG_SHELL" != x; then : - export CONFIG_SHELL - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -exit 255 -fi - - if test x$as_have_required = xno; then : - $as_echo "$0: This script requires a shell more modern than all" - $as_echo "$0: the shells that I found on your system." - if test x${ZSH_VERSION+set} = xset ; then - $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" - $as_echo "$0: be upgraded to zsh 4.3.4 or later." - else - $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, -$0: including any error possibly output before this -$0: message. Then install a modern shell, or manually run -$0: the script under such a shell if you do have one." - fi - exit 1 -fi -fi -fi -SHELL=${CONFIG_SHELL-/bin/sh} -export SHELL -# Unset more variables known to interfere with behavior of common tools. -CLICOLOR_FORCE= GREP_OPTIONS= -unset CLICOLOR_FORCE GREP_OPTIONS - -## --------------------- ## -## M4sh Shell Functions. ## -## --------------------- ## -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - - - as_lineno_1=$LINENO as_lineno_1a=$LINENO - as_lineno_2=$LINENO as_lineno_2a=$LINENO - eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && - test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { - # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - - # If we had to re-execute with $CONFIG_SHELL, we're ensured to have - # already done that, so ensure we don't try to do so again and fall - # in an infinite loop. This has already happened in practice. - _as_can_reexec=no; export _as_can_reexec - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - - -# Check that we are running under the correct shell. -SHELL=${CONFIG_SHELL-/bin/sh} - -case X$lt_ECHO in -X*--fallback-echo) - # Remove one level of quotation (which was required for Make). - ECHO=`echo "$lt_ECHO" | sed 's,\\\\\$\\$0,'$0','` - ;; -esac - -ECHO=${lt_ECHO-echo} -if test "X$1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X$1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then - # Yippee, $ECHO works! - : -else - # Restart under the correct shell. - exec $SHELL "$0" --no-reexec ${1+"$@"} -fi - -if test "X$1" = X--fallback-echo; then - # used as fallback echo - shift - cat <<_LT_EOF -$* -_LT_EOF - exit 0 -fi - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -if test -z "$lt_ECHO"; then - if test "X${echo_test_string+set}" != Xset; then - # find a string as large as possible, as long as the shell can cope with it - for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do - # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... - if { echo_test_string=`eval $cmd`; } 2>/dev/null && - { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null - then - break - fi - done - fi - - if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - : - else - # The Solaris, AIX, and Digital Unix default echo programs unquote - # backslashes. This makes it impossible to quote backslashes using - # echo "$something" | sed 's/\\/\\\\/g' - # - # So, first we look for a working echo in the user's PATH. - - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for dir in $PATH /usr/ucb; do - IFS="$lt_save_ifs" - if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && - test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - ECHO="$dir/echo" - break - fi - done - IFS="$lt_save_ifs" - - if test "X$ECHO" = Xecho; then - # We didn't find a better echo, so look for alternatives. - if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # This shell has a builtin print -r that does the trick. - ECHO='print -r' - elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && - test "X$CONFIG_SHELL" != X/bin/ksh; then - # If we have ksh, try running configure again with it. - ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} - export ORIGINAL_CONFIG_SHELL - CONFIG_SHELL=/bin/ksh - export CONFIG_SHELL - exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} - else - # Try using printf. - ECHO='printf %s\n' - if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # Cool, printf works - : - elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL - export CONFIG_SHELL - SHELL="$CONFIG_SHELL" - export SHELL - ECHO="$CONFIG_SHELL $0 --fallback-echo" - elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - ECHO="$CONFIG_SHELL $0 --fallback-echo" - else - # maybe with a smaller string... - prev=: - - for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do - if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null - then - break - fi - prev="$cmd" - done - - if test "$prev" != 'sed 50q "$0"'; then - echo_test_string=`eval $prev` - export echo_test_string - exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} - else - # Oops. We lost completely, so just stick with echo. - ECHO=echo - fi - fi - fi - fi - fi -fi - -# Copy echo and quote the copy suitably for passing to libtool from -# the Makefile, instead of quoting the original, which is used later. -lt_ECHO=$ECHO -if test "X$lt_ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then - lt_ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" -fi - - - - -test -n "$DJDIR" || exec 7<&0 &1 - -# Name of the host. -# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_clean_files= -ac_config_libobj_dir=. -LIBOBJS= -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= - -# Identity of this package. -PACKAGE_NAME= -PACKAGE_TARNAME= -PACKAGE_VERSION= -PACKAGE_STRING= -PACKAGE_BUGREPORT= -PACKAGE_URL= - -ac_unique_file="README.txt" -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef STDC_HEADERS -# include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined STDC_HEADERS && defined HAVE_MEMORY_H -# include -# endif -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_INTTYPES_H -# include -#endif -#ifdef HAVE_STDINT_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif" - -ac_subst_vars='LTLIBOBJS -LIBOBJS -SDL_VERSION -EXE -EXTRA_LDFLAGS -BUILD_LDFLAGS -EXTRA_CFLAGS -BUILD_CFLAGS -PLAYMUS_OBJECTS -PLAYWAVE_OBJECTS -VERSION_OBJECTS -OBJECTS -ac_aux_dir -OPUSFILE_LIBS -OPUSFILE_CFLAGS -LIBMIKMOD_CONFIG -MODPLUG_LIBS -MODPLUG_CFLAGS -SDL2_CONFIG -SDL_LIBS -SDL_CFLAGS -PKG_CONFIG -WINDRES -SET_MAKE -INSTALL_DATA -INSTALL_SCRIPT -INSTALL_PROGRAM -LT_AGE -LT_REVISION -LT_CURRENT -LT_RELEASE -CPP -OTOOL64 -OTOOL -LIPO -NMEDIT -DSYMUTIL -lt_ECHO -RANLIB -STRIP -AR -LN_S -NM -ac_ct_DUMPBIN -DUMPBIN -LD -FGREP -EGREP -GREP -SED -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC -host_os -host_vendor -host_cpu -host -build_os -build_vendor -build_cpu -build -LIBTOOL -OBJDUMP -DLLTOOL -AS -VERSION -BINARY_AGE -INTERFACE_AGE -MICRO_VERSION -MINOR_VERSION -MAJOR_VERSION -target_alias -host_alias -build_alias -LIBS -ECHO_T -ECHO_N -ECHO_C -DEFS -mandir -localedir -libdir -psdir -pdfdir -dvidir -htmldir -infodir -docdir -oldincludedir -includedir -localstatedir -sharedstatedir -sysconfdir -datadir -datarootdir -libexecdir -sbindir -bindir -program_transform_name -prefix -exec_prefix -PACKAGE_URL -PACKAGE_BUGREPORT -PACKAGE_STRING -PACKAGE_VERSION -PACKAGE_TARNAME -PACKAGE_NAME -PATH_SEPARATOR -SHELL' -ac_subst_files='' -ac_user_opts=' -enable_option_checking -enable_shared -enable_static -with_pic -enable_fast_install -with_gnu_ld -enable_libtool_lock -enable_dependency_tracking -with_sdl_prefix -with_sdl_exec_prefix -enable_sdltest -enable_music_cmd -enable_music_wave -enable_music_mod -enable_music_mod_modplug -enable_music_mod_modplug_shared -enable_music_mod_mikmod -enable_music_mod_mikmod_shared -enable_music_midi -enable_music_midi_timidity -enable_music_midi_native -enable_music_midi_fluidsynth -enable_music_midi_fluidsynth_shared -enable_music_ogg -enable_music_ogg_tremor -enable_music_ogg_shared -enable_music_flac -enable_music_flac_shared -enable_music_mp3 -enable_music_mp3_mad_gpl -enable_music_mp3_mad_gpl_dithering -enable_music_mp3_mpg123 -enable_music_mp3_mpg123_shared -enable_music_opus -enable_music_opus_shared -' - ac_precious_vars='build_alias -host_alias -target_alias -CC -CFLAGS -LDFLAGS -LIBS -CPPFLAGS -CPP -PKG_CONFIG -SDL_CFLAGS -SDL_LIBS -MODPLUG_CFLAGS -MODPLUG_LIBS -OPUSFILE_CFLAGS -OPUSFILE_LIBS' - - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -ac_unrecognized_opts= -ac_unrecognized_sep= -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -includedir='${prefix}/include' -oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' - -ac_prev= -ac_dashdash= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option - ac_prev= - continue - fi - - case $ac_option in - *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *=) ac_optarg= ;; - *) ac_optarg=yes ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) - datadir=$ac_optarg ;; - - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; - - -enable-* | --enable-*) - ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=\$ac_optarg ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=\$ac_optarg ;; - - -without-* | --without-*) - ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=no ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) as_fn_error $? "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information" - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - case $ac_envvar in #( - '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; - esac - eval $ac_envvar=\$ac_optarg - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error $? "missing argument to $ac_option" -fi - -if test -n "$ac_unrecognized_opts"; then - case $enable_option_checking in - no) ;; - fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; - *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; - esac -fi - -# Check all directory arguments for consistency. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir -do - eval ac_val=\$$ac_var - # Remove trailing slashes. - case $ac_val in - */ ) - ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` - eval $ac_var=\$ac_val;; - esac - # Be sure to have absolute directory names. - case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; - esac - as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error $? "working directory cannot be determined" -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error $? "pwd does not report name of working directory" - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$as_myself" || -$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_myself" : 'X\(//\)[^/]' \| \ - X"$as_myself" : 'X\(//\)$' \| \ - X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_myself" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures this package to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking ...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] -_ACEOF - - cat <<\_ACEOF - -System types: - --build=BUILD configure for building on BUILD [guessed] - --host=HOST cross-compile to build programs to run on HOST [BUILD] -_ACEOF -fi - -if test -n "$ac_init_help"; then - - cat <<\_ACEOF - -Optional Features: - --disable-option-checking ignore unrecognized --enable/--with options - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --enable-shared[=PKGS] build shared libraries [default=yes] - --enable-static[=PKGS] build static libraries [default=yes] - --enable-fast-install[=PKGS] - optimize for fast installation [default=yes] - --disable-libtool-lock avoid locking (might break parallel builds) - --enable-dependency-tracking - Use gcc -MMD -MT dependency tracking [[default=yes]] - --disable-sdltest Do not try to compile and run a test SDL program - --enable-music-cmd support an external music player [[default=yes]] - --enable-music-wave enable streaming WAVE music [[default=yes]] - --enable-music-mod enable MOD music [[default=yes]] - --enable-music-mod-modplug - enable MOD music via modplug [[default=yes]] - --enable-music-mod-modplug-shared - dynamically load modplug library [[default=yes]] - --enable-music-mod-mikmod - enable MOD music via mikmod [[default=no]] - --enable-music-mod-mikmod-shared - dynamically load mikmod library [[default=yes]] - --enable-music-midi enable MIDI music [[default=yes]] - --enable-music-midi-timidity - enable timidity MIDI output [[default=yes]] - --enable-music-midi-native - enable native MIDI music output [[default=yes]] - --enable-music-midi-fluidsynth - enable FluidSynth MIDI output [[default=yes]] - --enable-music-midi-fluidsynth-shared - dynamically load FluidSynth library [[default=yes]] - --enable-music-ogg enable Ogg Vorbis music [[default=yes]] - --enable-music-ogg-tremor - enable OGG Vorbis music via libtremor [[default=no]] - --enable-music-ogg-shared - dynamically load Ogg Vorbis library [[default=yes]] - --enable-music-flac enable FLAC music [[default=yes]] - --enable-music-flac-shared - dynamically load FLAC library [[default=yes]] - --enable-music-mp3 enable MP3 music [[default=yes]] - --enable-music-mp3-mad-gpl - enable MP3 music via libmad GPL code [[default=no]] - --enable-music-mp3-mad-gpl-dithering - enable MP3 music via libmad GPL code [[default=yes]] - --enable-music-mp3-mpg123 - enable MP3 music via libmpg123 [[default=yes]] - --enable-music-mp3-mpg123-shared - dynamically load libmpg123 library [[default=yes]] - --enable-music-opus enable Opus music [[default=yes]] - --enable-music-opus-shared - dynamically load opusfile library [[default=yes]] - -Optional Packages: - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-pic try to use only PIC/non-PIC objects [default=use - both] - --with-gnu-ld assume the C compiler uses GNU ld [default=no] - --with-sdl-prefix=PFX Prefix where SDL is installed (optional) - --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional) - -Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if - you have headers in a nonstandard directory - CPP C preprocessor - PKG_CONFIG path to pkg-config utility - SDL_CFLAGS C compiler flags for SDL, overriding pkg-config - SDL_LIBS linker flags for SDL, overriding pkg-config - MODPLUG_CFLAGS - C compiler flags for MODPLUG, overriding pkg-config - MODPLUG_LIBS - linker flags for MODPLUG, overriding pkg-config - OPUSFILE_CFLAGS - C compiler flags for OPUSFILE, overriding pkg-config - OPUSFILE_LIBS - linker flags for OPUSFILE, overriding pkg-config - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -Report bugs to the package provider. -_ACEOF -ac_status=$? -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || - { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || - continue - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive - else - $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } - done -fi - -test -n "$ac_init_help" && exit $ac_status -if $ac_init_version; then - cat <<\_ACEOF -configure -generated by GNU Autoconf 2.69 - -Copyright (C) 2012 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit -fi - -## ------------------------ ## -## Autoconf initialization. ## -## ------------------------ ## - -# ac_fn_c_try_compile LINENO -# -------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_compile - -# ac_fn_c_try_link LINENO -# ----------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - test -x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_link - -# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists and can be compiled using the include files in -# INCLUDES, setting the cache variable VAR accordingly. -ac_fn_c_check_header_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_header_compile - -# ac_fn_c_try_cpp LINENO -# ---------------------- -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp - -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - -# ac_fn_c_check_func LINENO FUNC VAR -# ---------------------------------- -# Tests whether FUNC exists, setting the cache variable VAR accordingly -ac_fn_c_check_func () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Define $2 to an innocuous variant, in case declares $2. - For example, HP-UX 11i declares gettimeofday. */ -#define $2 innocuous_$2 - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $2 - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $2 (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$2 || defined __stub___$2 -choke me -#endif - -int -main () -{ -return $2 (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_func - -# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists, giving a warning if it cannot be compiled using -# the include files in INCLUDES and setting the cache variable VAR -# accordingly. -ac_fn_c_check_header_mongrel () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval \${$3+:} false; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 -$as_echo_n "checking $2 usability... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_header_compiler=yes -else - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 -$as_echo_n "checking $2 presence... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <$2> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - ac_header_preproc=yes -else - ac_header_preproc=no -fi -rm -f conftest.err conftest.i conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( - yes:no: ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; - no:yes:* ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=\$ac_header_compiler" -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_header_mongrel -cat >config.log <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by $as_me, which was -generated by GNU Autoconf 2.69. Invocation command line was - - $ $0 $@ - -_ACEOF -exec 5>>config.log -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" - done -IFS=$as_save_IFS - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *\'*) - ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; - 2) - as_fn_append ac_configure_args1 " '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - as_fn_append ac_configure_args " '$ac_arg'" - ;; - esac - done -done -{ ac_configure_args0=; unset ac_configure_args0;} -{ ac_configure_args1=; unset ac_configure_args1;} - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - $as_echo "## ---------------- ## -## Cache variables. ## -## ---------------- ##" - echo - # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( - *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) - echo - - $as_echo "## ----------------- ## -## Output variables. ## -## ----------------- ##" - echo - for ac_var in $ac_subst_vars - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - - if test -n "$ac_subst_files"; then - $as_echo "## ------------------- ## -## File substitutions. ## -## ------------------- ##" - echo - for ac_var in $ac_subst_files - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - fi - - if test -s confdefs.h; then - $as_echo "## ----------- ## -## confdefs.h. ## -## ----------- ##" - echo - cat confdefs.h - echo - fi - test "$ac_signal" != 0 && - $as_echo "$as_me: caught signal $ac_signal" - $as_echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status -' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h - -$as_echo "/* confdefs.h */" > confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_URL "$PACKAGE_URL" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer an explicitly selected file to automatically selected ones. -ac_site_file1=NONE -ac_site_file2=NONE -if test -n "$CONFIG_SITE"; then - # We do not want a PATH search for config.site. - case $CONFIG_SITE in #(( - -*) ac_site_file1=./$CONFIG_SITE;; - */*) ac_site_file1=$CONFIG_SITE;; - *) ac_site_file1=./$CONFIG_SITE;; - esac -elif test "x$prefix" != xNONE; then - ac_site_file1=$prefix/share/config.site - ac_site_file2=$prefix/etc/config.site -else - ac_site_file1=$ac_default_prefix/share/config.site - ac_site_file2=$ac_default_prefix/etc/config.site -fi -for ac_site_file in "$ac_site_file1" "$ac_site_file2" -do - test "x$ac_site_file" = xNONE && continue - if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 -$as_echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" \ - || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5; } - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special files - # actually), so we avoid doing that. DJGPP emulates it as a regular file. - if test /dev/null != "$cache_file" && test -f "$cache_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 -$as_echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; - esac - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 -$as_echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value - case $ac_old_set,$ac_new_set in - set,) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - # differences in whitespace do not lead to failure. - ac_old_val_w=`echo x $ac_old_val` - ac_new_val_w=`echo x $ac_new_val` - if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 -$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - ac_cache_corrupted=: - else - { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} - eval $ac_var=\$ac_old_val - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 -$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 -$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) as_fn_append ac_configure_args " '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 -$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 -fi -## -------------------- ## -## Main body of script. ## -## -------------------- ## - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -ac_aux_dir= -for ac_dir in build-scripts "$srcdir"/build-scripts; do - if test -f "$ac_dir/install-sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f "$ac_dir/install.sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f "$ac_dir/shtool"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi -done -if test -z "$ac_aux_dir"; then - as_fn_error $? "cannot find install-sh, install.sh, or shtool in build-scripts \"$srcdir\"/build-scripts" "$LINENO" 5 -fi - -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. -ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. -ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - - - - -# Making releases: -# MICRO_VERSION += 1; -# INTERFACE_AGE += 1; -# BINARY_AGE += 1; -# if any functions have been added, set INTERFACE_AGE to 0. -# if backwards compatibility has been broken, -# set BINARY_AGE and INTERFACE_AGE to 0. -# -MAJOR_VERSION=2 -MINOR_VERSION=0 -MICRO_VERSION=4 -INTERFACE_AGE=2 -BINARY_AGE=4 -VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION - - - - - - - - -# libtool versioning -case `pwd` in - *\ * | *\ *) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 -$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; -esac - - - -macro_version='2.2.6' -macro_revision='1.3012' - - - - - - - - - - - - - -ltmain="$ac_aux_dir/ltmain.sh" - -# Make sure we can run config.sub. -$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 -$as_echo_n "checking build system type... " >&6; } -if ${ac_cv_build+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_build_alias=$build_alias -test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` -test "x$ac_build_alias" = x && - as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 -ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 -$as_echo "$ac_cv_build" >&6; } -case $ac_cv_build in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; -esac -build=$ac_cv_build -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_build -shift -build_cpu=$1 -build_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -build_os=$* -IFS=$ac_save_IFS -case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 -$as_echo_n "checking host system type... " >&6; } -if ${ac_cv_host+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "x$host_alias" = x; then - ac_cv_host=$ac_cv_build -else - ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 -$as_echo "$ac_cv_host" >&6; } -case $ac_cv_host in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; -esac -host=$ac_cv_host -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_host -shift -host_cpu=$1 -host_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -host_os=$* -IFS=$ac_save_IFS -case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - -# The possible output files: -ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" - -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { { ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext= - -else - ac_file='' -fi -if test -z "$ac_file"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -ac_exeext=$ac_cv_exeext - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } -if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest conftest$ac_cv_exeext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -ac_clean_files="$ac_clean_files conftest.out" -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } -if ${ac_cv_objext+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -struct stat; -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 -$as_echo_n "checking for a sed that does not truncate output... " >&6; } -if ${ac_cv_path_SED+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ - for ac_i in 1 2 3 4 5 6 7; do - ac_script="$ac_script$as_nl$ac_script" - done - echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed - { ac_script=; unset ac_script;} - if test -z "$SED"; then - ac_path_SED_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_SED" || continue -# Check for GNU ac_path_SED and select it if it is found. - # Check for GNU $ac_path_SED -case `"$ac_path_SED" --version 2>&1` in -*GNU*) - ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo '' >> "conftest.nl" - "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_SED_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_SED="$ac_path_SED" - ac_path_SED_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_SED_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_SED"; then - as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 - fi -else - ac_cv_path_SED=$SED -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 -$as_echo "$ac_cv_path_SED" >&6; } - SED="$ac_cv_path_SED" - rm -f conftest.sed - -test -z "$SED" && SED=sed -Xsed="$SED -e 1s/^X//" - - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_GREP" || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_EGREP" || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 -$as_echo_n "checking for fgrep... " >&6; } -if ${ac_cv_path_FGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 - then ac_cv_path_FGREP="$GREP -F" - else - if test -z "$FGREP"; then - ac_path_FGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in fgrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_FGREP" || continue -# Check for GNU ac_path_FGREP and select it if it is found. - # Check for GNU $ac_path_FGREP -case `"$ac_path_FGREP" --version 2>&1` in -*GNU*) - ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'FGREP' >> "conftest.nl" - "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_FGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_FGREP="$ac_path_FGREP" - ac_path_FGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_FGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_FGREP"; then - as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_FGREP=$FGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 -$as_echo "$ac_cv_path_FGREP" >&6; } - FGREP="$ac_cv_path_FGREP" - - -test -z "$GREP" && GREP=grep - - - - - - - - - - - - - - - - - - - -# Check whether --with-gnu-ld was given. -if test "${with_gnu_ld+set}" = set; then : - withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes -else - with_gnu_ld=no -fi - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 -$as_echo_n "checking for ld used by $CC... " >&6; } - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [\\/]* | ?:[\\/]*) - re_direlt='/[^/][^/]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` - while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do - ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 -$as_echo_n "checking for GNU ld... " >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 -$as_echo_n "checking for non-GNU ld... " >&6; } -fi -if ${lt_cv_path_LD+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$lt_cv_path_LD" -v 2>&1 &5 -$as_echo "$LD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi -test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 -$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } -if ${lt_cv_prog_gnu_ld+:} false; then : - $as_echo_n "(cached) " >&6 -else - # I'd rather use --version here, but apparently some GNU lds only accept -v. -case `$LD -v 2>&1 &5 -$as_echo "$lt_cv_prog_gnu_ld" >&6; } -with_gnu_ld=$lt_cv_prog_gnu_ld - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 -$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } -if ${lt_cv_path_NM+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM="$NM" -else - lt_nm_to_check="${ac_tool_prefix}nm" - if test -n "$ac_tool_prefix" && test "$build" = "$host"; then - lt_nm_to_check="$lt_nm_to_check nm" - fi - for lt_tmp_nm in $lt_nm_to_check; do - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/$lt_tmp_nm" - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in - */dev/null* | *'Invalid file or object type'*) - lt_cv_path_NM="$tmp_nm -B" - break - ;; - *) - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in - */dev/null*) - lt_cv_path_NM="$tmp_nm -p" - break - ;; - *) - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but - continue # so that we can try to find one that supports BSD flags - ;; - esac - ;; - esac - fi - done - IFS="$lt_save_ifs" - done - : ${lt_cv_path_NM=no} -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 -$as_echo "$lt_cv_path_NM" >&6; } -if test "$lt_cv_path_NM" != "no"; then - NM="$lt_cv_path_NM" -else - # Didn't find any BSD compatible name lister, look for dumpbin. - if test -n "$ac_tool_prefix"; then - for ac_prog in "dumpbin -symbols" "link -dump -symbols" - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DUMPBIN+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$DUMPBIN"; then - ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -DUMPBIN=$ac_cv_prog_DUMPBIN -if test -n "$DUMPBIN"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 -$as_echo "$DUMPBIN" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$DUMPBIN" && break - done -fi -if test -z "$DUMPBIN"; then - ac_ct_DUMPBIN=$DUMPBIN - for ac_prog in "dumpbin -symbols" "link -dump -symbols" -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_DUMPBIN"; then - ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN -if test -n "$ac_ct_DUMPBIN"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 -$as_echo "$ac_ct_DUMPBIN" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_DUMPBIN" && break -done - - if test "x$ac_ct_DUMPBIN" = x; then - DUMPBIN=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - DUMPBIN=$ac_ct_DUMPBIN - fi -fi - - - if test "$DUMPBIN" != ":"; then - NM="$DUMPBIN" - fi -fi -test -z "$NM" && NM=nm - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 -$as_echo_n "checking the name lister ($NM) interface... " >&6; } -if ${lt_cv_nm_interface+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_nm_interface="BSD nm" - echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3930: $ac_compile\"" >&5) - (eval "$ac_compile" 2>conftest.err) - cat conftest.err >&5 - (eval echo "\"\$as_me:3933: $NM \\\"conftest.$ac_objext\\\"\"" >&5) - (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) - cat conftest.err >&5 - (eval echo "\"\$as_me:3936: output\"" >&5) - cat conftest.out >&5 - if $GREP 'External.*some_variable' conftest.out > /dev/null; then - lt_cv_nm_interface="MS dumpbin" - fi - rm -f conftest* -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 -$as_echo "$lt_cv_nm_interface" >&6; } - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 -$as_echo_n "checking whether ln -s works... " >&6; } -LN_S=$as_ln_s -if test "$LN_S" = "ln -s"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 -$as_echo "no, using $LN_S" >&6; } -fi - -# find the maximum length of command line arguments -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 -$as_echo_n "checking the maximum length of command line arguments... " >&6; } -if ${lt_cv_sys_max_cmd_len+:} false; then : - $as_echo_n "(cached) " >&6 -else - i=0 - teststring="ABCD" - - case $build_os in - msdosdjgpp*) - # On DJGPP, this test can blow up pretty badly due to problems in libc - # (any single argument exceeding 2000 bytes causes a buffer overrun - # during glob expansion). Even if it were fixed, the result of this - # check would be larger than it should be. - lt_cv_sys_max_cmd_len=12288; # 12K is about right - ;; - - gnu*) - # Under GNU Hurd, this test is not required because there is - # no limit to the length of command line arguments. - # Libtool will interpret -1 as no limit whatsoever - lt_cv_sys_max_cmd_len=-1; - ;; - - cygwin* | mingw* | cegcc*) - # On Win9x/ME, this test blows up -- it succeeds, but takes - # about 5 minutes as the teststring grows exponentially. - # Worse, since 9x/ME are not pre-emptively multitasking, - # you end up with a "frozen" computer, even though with patience - # the test eventually succeeds (with a max line length of 256k). - # Instead, let's just punt: use the minimum linelength reported by - # all of the supported platforms: 8192 (on NT/2K/XP). - lt_cv_sys_max_cmd_len=8192; - ;; - - beos*) - # On BeOS, this test takes a really really long time. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - amigaos*) - # On AmigaOS with pdksh, this test takes hours, literally. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) - # This has been around since 386BSD, at least. Likely further. - if test -x /sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` - elif test -x /usr/sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` - else - lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs - fi - # And add a safety zone - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - ;; - - interix*) - # We know the value 262144 and hardcode it with a safety zone (like BSD) - lt_cv_sys_max_cmd_len=196608 - ;; - - osf*) - # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure - # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not - # nice to cause kernel panics so lets avoid the loop below. - # First set a reasonable default. - lt_cv_sys_max_cmd_len=16384 - # - if test -x /sbin/sysconfig; then - case `/sbin/sysconfig -q proc exec_disable_arg_limit` in - *1*) lt_cv_sys_max_cmd_len=-1 ;; - esac - fi - ;; - sco3.2v5*) - lt_cv_sys_max_cmd_len=102400 - ;; - sysv5* | sco5v6* | sysv4.2uw2*) - kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` - if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` - else - lt_cv_sys_max_cmd_len=32768 - fi - ;; - *) - lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len"; then - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - else - # Make teststring a little bigger before we do anything with it. - # a 1K string should be a reasonable start. - for i in 1 2 3 4 5 6 7 8 ; do - teststring=$teststring$teststring - done - SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} - # If test is not a shell built-in, we'll probably end up computing a - # maximum length that is only half of the actual maximum length, but - # we can't tell. - while { test "X"`$SHELL $0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ - = "XX$teststring$teststring"; } >/dev/null 2>&1 && - test $i != 17 # 1/2 MB should be enough - do - i=`expr $i + 1` - teststring=$teststring$teststring - done - # Only check the string length outside the loop. - lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` - teststring= - # Add a significant safety factor because C++ compilers can tack on - # massive amounts of additional arguments before passing them to the - # linker. It appears as though 1/2 is a usable value. - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` - fi - ;; - esac - -fi - -if test -n $lt_cv_sys_max_cmd_len ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 -$as_echo "$lt_cv_sys_max_cmd_len" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 -$as_echo "none" >&6; } -fi -max_cmd_len=$lt_cv_sys_max_cmd_len - - - - - - -: ${CP="cp -f"} -: ${MV="mv -f"} -: ${RM="rm -f"} - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 -$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } -# Try some XSI features -xsi_shell=no -( _lt_dummy="a/b/c" - test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ - = c,a/b,, \ - && eval 'test $(( 1 + 1 )) -eq 2 \ - && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ - && xsi_shell=yes -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 -$as_echo "$xsi_shell" >&6; } - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 -$as_echo_n "checking whether the shell understands \"+=\"... " >&6; } -lt_shell_append=no -( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ - >/dev/null 2>&1 \ - && lt_shell_append=yes -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 -$as_echo "$lt_shell_append" >&6; } - - -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - lt_unset=unset -else - lt_unset=false -fi - - - - - -# test EBCDIC or ASCII -case `echo X|tr X '\101'` in - A) # ASCII based system - # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr - lt_SP2NL='tr \040 \012' - lt_NL2SP='tr \015\012 \040\040' - ;; - *) # EBCDIC based system - lt_SP2NL='tr \100 \n' - lt_NL2SP='tr \r\n \100\100' - ;; -esac - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 -$as_echo_n "checking for $LD option to reload object files... " >&6; } -if ${lt_cv_ld_reload_flag+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_ld_reload_flag='-r' -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 -$as_echo "$lt_cv_ld_reload_flag" >&6; } -reload_flag=$lt_cv_ld_reload_flag -case $reload_flag in -"" | " "*) ;; -*) reload_flag=" $reload_flag" ;; -esac -reload_cmds='$LD$reload_flag -o $output$reload_objs' -case $host_os in - darwin*) - if test "$GCC" = yes; then - reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' - else - reload_cmds='$LD$reload_flag -o $output$reload_objs' - fi - ;; -esac - - - - - - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. -set dummy ${ac_tool_prefix}objdump; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJDUMP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OBJDUMP"; then - ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OBJDUMP=$ac_cv_prog_OBJDUMP -if test -n "$OBJDUMP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 -$as_echo "$OBJDUMP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OBJDUMP"; then - ac_ct_OBJDUMP=$OBJDUMP - # Extract the first word of "objdump", so it can be a program name with args. -set dummy objdump; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OBJDUMP"; then - ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OBJDUMP="objdump" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP -if test -n "$ac_ct_OBJDUMP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 -$as_echo "$ac_ct_OBJDUMP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OBJDUMP" = x; then - OBJDUMP="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OBJDUMP=$ac_ct_OBJDUMP - fi -else - OBJDUMP="$ac_cv_prog_OBJDUMP" -fi - -test -z "$OBJDUMP" && OBJDUMP=objdump - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 -$as_echo_n "checking how to recognize dependent libraries... " >&6; } -if ${lt_cv_deplibs_check_method+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_file_magic_cmd='$MAGIC_CMD' -lt_cv_file_magic_test_file= -lt_cv_deplibs_check_method='unknown' -# Need to set the preceding variable on all platforms that support -# interlibrary dependencies. -# 'none' -- dependencies not supported. -# `unknown' -- same as none, but documents that we really don't know. -# 'pass_all' -- all dependencies passed with no checks. -# 'test_compile' -- check by making test program. -# 'file_magic [[regex]]' -- check by looking for files in library path -# which responds to the $file_magic_cmd with a given extended regex. -# If you have `file' or equivalent on your system and you're not sure -# whether `pass_all' will *always* work, you probably want this one. - -case $host_os in -aix[4-9]*) - lt_cv_deplibs_check_method=pass_all - ;; - -beos*) - lt_cv_deplibs_check_method=pass_all - ;; - -bsdi[45]*) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' - lt_cv_file_magic_cmd='/usr/bin/file -L' - lt_cv_file_magic_test_file=/shlib/libc.so - ;; - -cygwin*) - # func_win32_libid is a shell function defined in ltmain.sh - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_deplibs_check_method=pass_all - lt_cv_file_magic_cmd='func_win32_libid' - ;; - -mingw* | pw32*) - # Base MSYS/MinGW do not provide the 'file' command needed by - # func_win32_libid shell function, so use a weaker test based on 'objdump', - # unless we find 'file', for example because we are cross-compiling. - if ( file / ) >/dev/null 2>&1; then - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_file_magic_cmd='func_win32_libid' - else - lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' - lt_cv_file_magic_cmd='$OBJDUMP -f' - fi - lt_cv_deplibs_check_method=pass_all - ;; - -cegcc) - # use the weaker test based on 'objdump'. See mingw*. - lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - ;; - -darwin* | rhapsody*) - lt_cv_deplibs_check_method=pass_all - ;; - -freebsd* | dragonfly*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - case $host_cpu in - i*86 ) - # Not sure whether the presence of OpenBSD here was a mistake. - # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - ;; - esac - else - lt_cv_deplibs_check_method=pass_all - fi - ;; - -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file - case $host_cpu in - ia64*) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' - lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so - ;; - hppa*64*) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]' - lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl - ;; - *) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' - lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - esac - ;; - -interix[3-9]*) - # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' - ;; - -irix5* | irix6* | nonstopux*) - case $LD in - *-32|*"-32 ") libmagic=32-bit;; - *-n32|*"-n32 ") libmagic=N32;; - *-64|*"-64 ") libmagic=64-bit;; - *) libmagic=never-match;; - esac - lt_cv_deplibs_check_method=pass_all - ;; - -# This must be Linux ELF. -linux* | k*bsd*-gnu) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' - fi - ;; - -newos6*) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libnls.so - ;; - -*nto* | *qnx*) - lt_cv_deplibs_check_method=pass_all - ;; - -openbsd*) - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' - fi - ;; - -osf3* | osf4* | osf5*) - lt_cv_deplibs_check_method=pass_all - ;; - -rdos*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.3*) - case $host_vendor in - motorola) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` - ;; - ncr) - lt_cv_deplibs_check_method=pass_all - ;; - sequent) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' - ;; - sni) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" - lt_cv_file_magic_test_file=/lib/libc.so - ;; - siemens) - lt_cv_deplibs_check_method=pass_all - ;; - pc) - lt_cv_deplibs_check_method=pass_all - ;; - esac - ;; - -tpf*) - lt_cv_deplibs_check_method=pass_all - ;; -esac - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 -$as_echo "$lt_cv_deplibs_check_method" >&6; } -file_magic_cmd=$lt_cv_file_magic_cmd -deplibs_check_method=$lt_cv_deplibs_check_method -test -z "$deplibs_check_method" && deplibs_check_method=unknown - - - - - - - - - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. -set dummy ${ac_tool_prefix}ar; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AR"; then - ac_cv_prog_AR="$AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AR="${ac_tool_prefix}ar" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AR=$ac_cv_prog_AR -if test -n "$AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 -$as_echo "$AR" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_AR"; then - ac_ct_AR=$AR - # Extract the first word of "ar", so it can be a program name with args. -set dummy ar; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_AR"; then - ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_AR="ar" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_AR=$ac_cv_prog_ac_ct_AR -if test -n "$ac_ct_AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 -$as_echo "$ac_ct_AR" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_AR" = x; then - AR="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - AR=$ac_ct_AR - fi -else - AR="$ac_cv_prog_AR" -fi - -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru - - - - - - - - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_STRIP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -STRIP=$ac_cv_prog_STRIP -if test -n "$STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 -$as_echo "$STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_STRIP"; then - ac_ct_STRIP=$STRIP - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_STRIP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_STRIP"; then - ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_STRIP="strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -if test -n "$ac_ct_STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 -$as_echo "$ac_ct_STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_STRIP" = x; then - STRIP=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - STRIP=$ac_ct_STRIP - fi -else - STRIP="$ac_cv_prog_STRIP" -fi - -test -z "$STRIP" && STRIP=: - - - - - - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_RANLIB+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -RANLIB=$ac_cv_prog_RANLIB -if test -n "$RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 -$as_echo "$RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_RANLIB"; then - ac_ct_RANLIB=$RANLIB - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_RANLIB"; then - ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_RANLIB="ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB -if test -n "$ac_ct_RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 -$as_echo "$ac_ct_RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_RANLIB" = x; then - RANLIB=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - RANLIB=$ac_ct_RANLIB - fi -else - RANLIB="$ac_cv_prog_RANLIB" -fi - -test -z "$RANLIB" && RANLIB=: - - - - - - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC - - -# Check for command to grab the raw symbol name followed by C symbol from nm. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 -$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } -if ${lt_cv_sys_global_symbol_pipe+:} false; then : - $as_echo_n "(cached) " >&6 -else - -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[BCDEGRST]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([_A-Za-z][_A-Za-z0-9]*\)' - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[BCDT]' - ;; -cygwin* | mingw* | pw32* | cegcc*) - symcode='[ABCDGISTW]' - ;; -hpux*) - if test "$host_cpu" = ia64; then - symcode='[ABCDEGRST]' - fi - ;; -irix* | nonstopux*) - symcode='[BCDEGRST]' - ;; -osf*) - symcode='[BCDEGQRST]' - ;; -solaris*) - symcode='[BDRT]' - ;; -sco3.2v5*) - symcode='[DT]' - ;; -sysv4.2uw2*) - symcode='[DT]' - ;; -sysv5* | sco5v6* | unixware* | OpenUNIX*) - symcode='[ABDT]' - ;; -sysv4) - symcode='[DFNSTU]' - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -case `$NM -V 2>&1` in -*GNU* | *'with BFD'*) - symcode='[ABCDGIRSTW]' ;; -esac - -# Transform an extracted symbol line into a proper C declaration. -# Some systems (esp. on ia64) link data and code symbols differently, -# so use this general approach. -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - -# Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" - -# Handle CRLF in mingw tool chain -opt_cr= -case $build_os in -mingw*) - opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp - ;; -esac - -# Try without a prefix underscore, then with it. -for ac_symprfx in "" "_"; do - - # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. - symxfrm="\\1 $ac_symprfx\\2 \\2" - - # Write the raw and C identifiers. - if test "$lt_cv_nm_interface" = "MS dumpbin"; then - # Fake it for dumpbin and say T for any non-static function - # and D for any global variable. - # Also find C++ and __fastcall symbols from MSVC++, - # which start with @ or ?. - lt_cv_sys_global_symbol_pipe="$AWK '"\ -" {last_section=section; section=\$ 3};"\ -" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ -" \$ 0!~/External *\|/{next};"\ -" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ -" {if(hide[section]) next};"\ -" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ -" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ -" s[1]~/^[@?]/{print s[1], s[1]; next};"\ -" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ -" ' prfx=^$ac_symprfx" - else - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" - fi - - # Check to see that the pipe works correctly. - pipe_works=no - - rm -f conftest* - cat > conftest.$ac_ext <<_LT_EOF -#ifdef __cplusplus -extern "C" { -#endif -char nm_test_var; -void nm_test_func(void); -void nm_test_func(void){} -#ifdef __cplusplus -} -#endif -int main(){nm_test_var='a';nm_test_func();return(0);} -_LT_EOF - - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - # Now try to grab the symbols. - nlist=conftest.nm - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\""; } >&5 - (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s "$nlist"; then - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - else - rm -f "$nlist"T - fi - - # Make sure that we snagged all the symbols we need. - if $GREP ' nm_test_var$' "$nlist" >/dev/null; then - if $GREP ' nm_test_func$' "$nlist" >/dev/null; then - cat <<_LT_EOF > conftest.$ac_ext -#ifdef __cplusplus -extern "C" { -#endif - -_LT_EOF - # Now generate the symbol file. - eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' - - cat <<_LT_EOF >> conftest.$ac_ext - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - void *address; -} -lt__PROGRAM__LTX_preloaded_symbols[] = -{ - { "@PROGRAM@", (void *) 0 }, -_LT_EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext - cat <<\_LT_EOF >> conftest.$ac_ext - {0, (void *) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt__PROGRAM__LTX_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif -_LT_EOF - # Now try linking the two files. - mv conftest.$ac_objext conftstm.$ac_objext - lt_save_LIBS="$LIBS" - lt_save_CFLAGS="$CFLAGS" - LIBS="conftstm.$ac_objext" - CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 - (eval $ac_link) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext}; then - pipe_works=yes - fi - LIBS="$lt_save_LIBS" - CFLAGS="$lt_save_CFLAGS" - else - echo "cannot find nm_test_func in $nlist" >&5 - fi - else - echo "cannot find nm_test_var in $nlist" >&5 - fi - else - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 - fi - else - echo "$progname: failed program was:" >&5 - cat conftest.$ac_ext >&5 - fi - rm -rf conftest* conftst* - - # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then - break - else - lt_cv_sys_global_symbol_pipe= - fi -done - -fi - -if test -z "$lt_cv_sys_global_symbol_pipe"; then - lt_cv_sys_global_symbol_to_cdecl= -fi -if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 -$as_echo "failed" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; } -fi - - - - - - - - - - - - - - - - - - - - - - - -# Check whether --enable-libtool-lock was given. -if test "${enable_libtool_lock+set}" = set; then : - enableval=$enable_libtool_lock; -fi - -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -ia64-*-hpux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - case `/usr/bin/file conftest.$ac_objext` in - *ELF-32*) - HPUX_IA64_MODE="32" - ;; - *ELF-64*) - HPUX_IA64_MODE="64" - ;; - esac - fi - rm -rf conftest* - ;; -*-*-irix6*) - # Find out which ABI we are using. - echo '#line 5147 "configure"' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - if test "$lt_cv_prog_gnu_ld" = yes; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -melf32bsmip" - ;; - *N32*) - LD="${LD-ld} -melf32bmipn32" - ;; - *64-bit*) - LD="${LD-ld} -melf64bmip" - ;; - esac - else - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - fi - rm -rf conftest* - ;; - -x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ -s390*-*linux*|s390*-*tpf*|sparc*-*linux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - case `/usr/bin/file conftest.o` in - *32-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_i386_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_i386" - ;; - ppc64-*linux*|powerpc64-*linux*) - LD="${LD-ld} -m elf32ppclinux" - ;; - s390x-*linux*) - LD="${LD-ld} -m elf_s390" - ;; - sparc64-*linux*) - LD="${LD-ld} -m elf32_sparc" - ;; - esac - ;; - *64-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_x86_64_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - powerpc64le-*linux*) - LD="${LD-ld} -m elf64lppc" - ;; - powerpc64-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*|s390*-*tpf*) - LD="${LD-ld} -m elf64_s390" - ;; - sparc*-*linux*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 -$as_echo_n "checking whether the C compiler needs -belf... " >&6; } -if ${lt_cv_cc_needs_belf+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - lt_cv_cc_needs_belf=yes -else - lt_cv_cc_needs_belf=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 -$as_echo "$lt_cv_cc_needs_belf" >&6; } - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; -sparc*-*solaris*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - case `/usr/bin/file conftest.o` in - *64-bit*) - case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; - *) - if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then - LD="${LD-ld} -64" - fi - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; -esac - -need_locks="$enable_libtool_lock" - - - case $host_os in - rhapsody* | darwin*) - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. -set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DSYMUTIL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$DSYMUTIL"; then - ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -DSYMUTIL=$ac_cv_prog_DSYMUTIL -if test -n "$DSYMUTIL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 -$as_echo "$DSYMUTIL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_DSYMUTIL"; then - ac_ct_DSYMUTIL=$DSYMUTIL - # Extract the first word of "dsymutil", so it can be a program name with args. -set dummy dsymutil; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_DSYMUTIL"; then - ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL -if test -n "$ac_ct_DSYMUTIL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 -$as_echo "$ac_ct_DSYMUTIL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_DSYMUTIL" = x; then - DSYMUTIL=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - DSYMUTIL=$ac_ct_DSYMUTIL - fi -else - DSYMUTIL="$ac_cv_prog_DSYMUTIL" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. -set dummy ${ac_tool_prefix}nmedit; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_NMEDIT+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$NMEDIT"; then - ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -NMEDIT=$ac_cv_prog_NMEDIT -if test -n "$NMEDIT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 -$as_echo "$NMEDIT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_NMEDIT"; then - ac_ct_NMEDIT=$NMEDIT - # Extract the first word of "nmedit", so it can be a program name with args. -set dummy nmedit; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_NMEDIT"; then - ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_NMEDIT="nmedit" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT -if test -n "$ac_ct_NMEDIT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 -$as_echo "$ac_ct_NMEDIT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_NMEDIT" = x; then - NMEDIT=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - NMEDIT=$ac_ct_NMEDIT - fi -else - NMEDIT="$ac_cv_prog_NMEDIT" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. -set dummy ${ac_tool_prefix}lipo; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_LIPO+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$LIPO"; then - ac_cv_prog_LIPO="$LIPO" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_LIPO="${ac_tool_prefix}lipo" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -LIPO=$ac_cv_prog_LIPO -if test -n "$LIPO"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 -$as_echo "$LIPO" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_LIPO"; then - ac_ct_LIPO=$LIPO - # Extract the first word of "lipo", so it can be a program name with args. -set dummy lipo; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_LIPO+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_LIPO"; then - ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_LIPO="lipo" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO -if test -n "$ac_ct_LIPO"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 -$as_echo "$ac_ct_LIPO" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_LIPO" = x; then - LIPO=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - LIPO=$ac_ct_LIPO - fi -else - LIPO="$ac_cv_prog_LIPO" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. -set dummy ${ac_tool_prefix}otool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OTOOL"; then - ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OTOOL="${ac_tool_prefix}otool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OTOOL=$ac_cv_prog_OTOOL -if test -n "$OTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 -$as_echo "$OTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OTOOL"; then - ac_ct_OTOOL=$OTOOL - # Extract the first word of "otool", so it can be a program name with args. -set dummy otool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OTOOL"; then - ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OTOOL="otool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL -if test -n "$ac_ct_OTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 -$as_echo "$ac_ct_OTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OTOOL" = x; then - OTOOL=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OTOOL=$ac_ct_OTOOL - fi -else - OTOOL="$ac_cv_prog_OTOOL" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. -set dummy ${ac_tool_prefix}otool64; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OTOOL64+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OTOOL64"; then - ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OTOOL64=$ac_cv_prog_OTOOL64 -if test -n "$OTOOL64"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 -$as_echo "$OTOOL64" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OTOOL64"; then - ac_ct_OTOOL64=$OTOOL64 - # Extract the first word of "otool64", so it can be a program name with args. -set dummy otool64; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OTOOL64"; then - ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OTOOL64="otool64" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 -if test -n "$ac_ct_OTOOL64"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 -$as_echo "$ac_ct_OTOOL64" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OTOOL64" = x; then - OTOOL64=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OTOOL64=$ac_ct_OTOOL64 - fi -else - OTOOL64="$ac_cv_prog_OTOOL64" -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 -$as_echo_n "checking for -single_module linker flag... " >&6; } -if ${lt_cv_apple_cc_single_mod+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_apple_cc_single_mod=no - if test -z "${LT_MULTI_MODULE}"; then - # By default we will add the -single_module flag. You can override - # by either setting the environment variable LT_MULTI_MODULE - # non-empty at configure time, or by adding -multi_module to the - # link flags. - rm -rf libconftest.dylib* - echo "int foo(void){return 1;}" > conftest.c - echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ --dynamiclib -Wl,-single_module conftest.c" >&5 - $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ - -dynamiclib -Wl,-single_module conftest.c 2>conftest.err - _lt_result=$? - if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then - lt_cv_apple_cc_single_mod=yes - else - cat conftest.err >&5 - fi - rm -rf libconftest.dylib* - rm -f conftest.* - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 -$as_echo "$lt_cv_apple_cc_single_mod" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 -$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } -if ${lt_cv_ld_exported_symbols_list+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_ld_exported_symbols_list=no - save_LDFLAGS=$LDFLAGS - echo "_main" > conftest.sym - LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - lt_cv_ld_exported_symbols_list=yes -else - lt_cv_ld_exported_symbols_list=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 -$as_echo "$lt_cv_ld_exported_symbols_list" >&6; } - case $host_os in - rhapsody* | darwin1.[012]) - _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; - darwin1.*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - darwin*) # darwin 5.x on - # if running on 10.5 or later, the deployment target defaults - # to the OS version, if on x86, and 10.4, the deployment - # target defaults to 10.4. Don't you love it? - case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[91]*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - 10.[012]*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - 10.*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - esac - ;; - esac - if test "$lt_cv_apple_cc_single_mod" = "yes"; then - _lt_dar_single_mod='$single_module' - fi - if test "$lt_cv_ld_exported_symbols_list" = "yes"; then - _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' - else - _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - if test "$DSYMUTIL" != ":"; then - _lt_dsymutil='~$DSYMUTIL $lib || :' - else - _lt_dsymutil= - fi - ;; - esac - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -for ac_header in dlfcn.h -do : - ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default -" -if test "x$ac_cv_header_dlfcn_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_DLFCN_H 1 -_ACEOF - -fi - -done - - - -# Set options -enable_win32_dll=yes - -case $host in -*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*) - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. -set dummy ${ac_tool_prefix}as; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AS+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AS"; then - ac_cv_prog_AS="$AS" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AS="${ac_tool_prefix}as" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AS=$ac_cv_prog_AS -if test -n "$AS"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 -$as_echo "$AS" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_AS"; then - ac_ct_AS=$AS - # Extract the first word of "as", so it can be a program name with args. -set dummy as; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_AS+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_AS"; then - ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_AS="as" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_AS=$ac_cv_prog_ac_ct_AS -if test -n "$ac_ct_AS"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5 -$as_echo "$ac_ct_AS" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_AS" = x; then - AS="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - AS=$ac_ct_AS - fi -else - AS="$ac_cv_prog_AS" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. -set dummy ${ac_tool_prefix}dlltool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DLLTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$DLLTOOL"; then - ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -DLLTOOL=$ac_cv_prog_DLLTOOL -if test -n "$DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 -$as_echo "$DLLTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_DLLTOOL"; then - ac_ct_DLLTOOL=$DLLTOOL - # Extract the first word of "dlltool", so it can be a program name with args. -set dummy dlltool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_DLLTOOL"; then - ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_DLLTOOL="dlltool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL -if test -n "$ac_ct_DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 -$as_echo "$ac_ct_DLLTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_DLLTOOL" = x; then - DLLTOOL="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - DLLTOOL=$ac_ct_DLLTOOL - fi -else - DLLTOOL="$ac_cv_prog_DLLTOOL" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. -set dummy ${ac_tool_prefix}objdump; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJDUMP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OBJDUMP"; then - ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OBJDUMP=$ac_cv_prog_OBJDUMP -if test -n "$OBJDUMP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 -$as_echo "$OBJDUMP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OBJDUMP"; then - ac_ct_OBJDUMP=$OBJDUMP - # Extract the first word of "objdump", so it can be a program name with args. -set dummy objdump; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OBJDUMP"; then - ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_OBJDUMP="objdump" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP -if test -n "$ac_ct_OBJDUMP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 -$as_echo "$ac_ct_OBJDUMP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OBJDUMP" = x; then - OBJDUMP="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OBJDUMP=$ac_ct_OBJDUMP - fi -else - OBJDUMP="$ac_cv_prog_OBJDUMP" -fi - - ;; -esac - -test -z "$AS" && AS=as - - - - - -test -z "$DLLTOOL" && DLLTOOL=dlltool - - - - - -test -z "$OBJDUMP" && OBJDUMP=objdump - - - - - - - - enable_dlopen=no - - - - # Check whether --enable-shared was given. -if test "${enable_shared+set}" = set; then : - enableval=$enable_shared; p=${PACKAGE-default} - case $enableval in - yes) enable_shared=yes ;; - no) enable_shared=no ;; - *) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_shared=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - enable_shared=yes -fi - - - - - - - - - - # Check whether --enable-static was given. -if test "${enable_static+set}" = set; then : - enableval=$enable_static; p=${PACKAGE-default} - case $enableval in - yes) enable_static=yes ;; - no) enable_static=no ;; - *) - enable_static=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - enable_static=yes -fi - - - - - - - - - - -# Check whether --with-pic was given. -if test "${with_pic+set}" = set; then : - withval=$with_pic; pic_mode="$withval" -else - pic_mode=default -fi - - -test -z "$pic_mode" && pic_mode=default - - - - - - - - # Check whether --enable-fast-install was given. -if test "${enable_fast_install+set}" = set; then : - enableval=$enable_fast_install; p=${PACKAGE-default} - case $enableval in - yes) enable_fast_install=yes ;; - no) enable_fast_install=no ;; - *) - enable_fast_install=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_fast_install=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - enable_fast_install=yes -fi - - - - - - - - - - - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ltmain" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' - - - - - - - - - - - - - - - - - - - - - - - - - -test -z "$LN_S" && LN_S="ln -s" - - - - - - - - - - - - - - -if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 -$as_echo_n "checking for objdir... " >&6; } -if ${lt_cv_objdir+:} false; then : - $as_echo_n "(cached) " >&6 -else - rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - lt_cv_objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - lt_cv_objdir=_libs -fi -rmdir .libs 2>/dev/null -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 -$as_echo "$lt_cv_objdir" >&6; } -objdir=$lt_cv_objdir - - - - - -cat >>confdefs.h <<_ACEOF -#define LT_OBJDIR "$lt_cv_objdir/" -_ACEOF - - - - - - - - - - - - - - - - - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -sed_quote_subst='s/\(["`$\\]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\(["`\\]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to delay expansion of an escaped single quote. -delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - -# Global variables: -ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a - -with_gnu_ld="$lt_cv_prog_gnu_ld" - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS -test -z "$LD" && LD=ld -test -z "$ac_objext" && ac_objext=o - -for cc_temp in $compiler""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` - - -# Only perform the check for file, if the check method requires it -test -z "$MAGIC_CMD" && MAGIC_CMD=file -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 -$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } -if ${lt_cv_path_MAGIC_CMD+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $MAGIC_CMD in -[\\/*] | ?:[\\/]*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/${ac_tool_prefix}file; then - lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <<_LT_EOF 1>&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -_LT_EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac -fi - -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 -$as_echo "$MAGIC_CMD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - - - -if test -z "$lt_cv_path_MAGIC_CMD"; then - if test -n "$ac_tool_prefix"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 -$as_echo_n "checking for file... " >&6; } -if ${lt_cv_path_MAGIC_CMD+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $MAGIC_CMD in -[\\/*] | ?:[\\/]*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/file; then - lt_cv_path_MAGIC_CMD="$ac_dir/file" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <<_LT_EOF 1>&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -_LT_EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac -fi - -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 -$as_echo "$MAGIC_CMD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - else - MAGIC_CMD=: - fi -fi - - fi - ;; -esac - -# Use C for the default configuration in the libtool script - -lt_save_CC="$CC" -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -# Source file extension for C test sources. -ac_ext=c - -# Object file extension for compiled C test sources. -objext=o -objext=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}' - - - - - - - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC - -# Save the default compiler, since it gets overwritten when the other -# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. -compiler_DEFAULT=$CC - -# save warnings/boilerplate of simple test code -ac_outfile=conftest.$ac_objext -echo "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$RM conftest* - -ac_outfile=conftest.$ac_objext -echo "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$RM -r conftest* - - -## CAVEAT EMPTOR: -## There is no encapsulation within the following macros, do not change -## the running order or otherwise move them around unless you know exactly -## what you are doing... -if test -n "$compiler"; then - -lt_prog_compiler_no_builtin_flag= - -if test "$GCC" = yes; then - lt_prog_compiler_no_builtin_flag=' -fno-builtin' - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 -$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } -if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_rtti_exceptions=no - ac_outfile=conftest.$ac_objext - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="-fno-rtti -fno-exceptions" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6977: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:6981: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_rtti_exceptions=yes - fi - fi - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 -$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } - -if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then - lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" -else - : -fi - -fi - - - - - - - lt_prog_compiler_wl= -lt_prog_compiler_pic= -lt_prog_compiler_static= - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 -$as_echo_n "checking for $compiler option to produce PIC... " >&6; } - - if test "$GCC" = yes; then - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_static='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - lt_prog_compiler_pic='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - lt_prog_compiler_pic='-DDLL_EXPORT' - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - lt_prog_compiler_pic='-fno-common' - ;; - - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic='-fPIC' - ;; - esac - ;; - - interix[3-9]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - lt_prog_compiler_can_build_shared=no - enable_shared=no - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - lt_prog_compiler_pic='-fPIC -shared' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - lt_prog_compiler_pic=-Kconform_pic - fi - ;; - - *) - lt_prog_compiler_pic='-fPIC' - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - lt_prog_compiler_wl='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static='-Bstatic' - else - lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' - fi - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_prog_compiler_pic='-DDLL_EXPORT' - ;; - - hpux9* | hpux10* | hpux11*) - lt_prog_compiler_wl='-Wl,' - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - lt_prog_compiler_static='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - lt_prog_compiler_wl='-Wl,' - # PIC (with -KPIC) is the default. - lt_prog_compiler_static='-non_shared' - ;; - - linux* | k*bsd*-gnu) - case $cc_basename in - # old Intel for x86_64 which still supported -KPIC. - ecc*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-static' - ;; - # icc used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - icc* | ifort*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-fPIC' - lt_prog_compiler_static='-static' - ;; - # Lahey Fortran 8.1. - lf95*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='--shared' - lt_prog_compiler_static='--static' - ;; - pgcc* | pgf77* | pgf90* | pgf95*) - # Portland Group compilers (*not* the Pentium gcc compiler, - # which looks to be a dead project) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-fpic' - lt_prog_compiler_static='-Bstatic' - ;; - ccc*) - lt_prog_compiler_wl='-Wl,' - # All Alpha code is PIC. - lt_prog_compiler_static='-non_shared' - ;; - xl*) - # IBM XL C 8.0/Fortran 10.1 on PPC - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-qpic' - lt_prog_compiler_static='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C 5.9 - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - lt_prog_compiler_wl='-Wl,' - ;; - *Sun\ F*) - # Sun Fortran 8.3 passes all unrecognized flags to the linker - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - lt_prog_compiler_wl='' - ;; - esac - ;; - esac - ;; - - newsos6) - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - lt_prog_compiler_pic='-fPIC -shared' - ;; - - osf3* | osf4* | osf5*) - lt_prog_compiler_wl='-Wl,' - # All OSF/1 code is PIC. - lt_prog_compiler_static='-non_shared' - ;; - - rdos*) - lt_prog_compiler_static='-non_shared' - ;; - - solaris*) - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - case $cc_basename in - f77* | f90* | f95*) - lt_prog_compiler_wl='-Qoption ld ';; - *) - lt_prog_compiler_wl='-Wl,';; - esac - ;; - - sunos4*) - lt_prog_compiler_wl='-Qoption ld ' - lt_prog_compiler_pic='-PIC' - lt_prog_compiler_static='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - lt_prog_compiler_pic='-Kconform_pic' - lt_prog_compiler_static='-Bstatic' - fi - ;; - - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - ;; - - unicos*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_can_build_shared=no - ;; - - uts4*) - lt_prog_compiler_pic='-pic' - lt_prog_compiler_static='-Bstatic' - ;; - - *) - lt_prog_compiler_can_build_shared=no - ;; - esac - fi - -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - lt_prog_compiler_pic= - ;; - *) - lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" - ;; -esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic" >&5 -$as_echo "$lt_prog_compiler_pic" >&6; } - - - - - - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$lt_prog_compiler_pic"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 -$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } -if ${lt_cv_prog_compiler_pic_works+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_pic_works=no - ac_outfile=conftest.$ac_objext - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$lt_prog_compiler_pic -DPIC" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7316: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:7320: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_pic_works=yes - fi - fi - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 -$as_echo "$lt_cv_prog_compiler_pic_works" >&6; } - -if test x"$lt_cv_prog_compiler_pic_works" = xyes; then - case $lt_prog_compiler_pic in - "" | " "*) ;; - *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; - esac -else - lt_prog_compiler_pic= - lt_prog_compiler_can_build_shared=no -fi - -fi - - - - - - -# -# Check to make sure the static flag actually works. -# -wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 -$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } -if ${lt_cv_prog_compiler_static_works+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_static_works=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $lt_tmp_static_flag" - echo "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&5 - $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_static_works=yes - fi - else - lt_cv_prog_compiler_static_works=yes - fi - fi - $RM -r conftest* - LDFLAGS="$save_LDFLAGS" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 -$as_echo "$lt_cv_prog_compiler_static_works" >&6; } - -if test x"$lt_cv_prog_compiler_static_works" = xyes; then - : -else - lt_prog_compiler_static= -fi - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if ${lt_cv_prog_compiler_c_o+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_c_o=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7421: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:7425: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - lt_cv_prog_compiler_c_o=yes - fi - fi - chmod u+w . 2>&5 - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 -$as_echo "$lt_cv_prog_compiler_c_o" >&6; } - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if ${lt_cv_prog_compiler_c_o+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_c_o=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7476: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:7480: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - lt_cv_prog_compiler_c_o=yes - fi - fi - chmod u+w . 2>&5 - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 -$as_echo "$lt_cv_prog_compiler_c_o" >&6; } - - - - -hard_links="nottested" -if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 -$as_echo_n "checking if we can lock with hard links... " >&6; } - hard_links=yes - $RM conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 -$as_echo "$hard_links" >&6; } - if test "$hard_links" = no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} - need_locks=warn - fi -else - need_locks=no -fi - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } - - runpath_var= - allow_undefined_flag= - always_export_symbols=no - archive_cmds= - archive_expsym_cmds= - compiler_needs_object=no - enable_shared_with_static_runtimes=no - export_dynamic_flag_spec= - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - hardcode_automatic=no - hardcode_direct=no - hardcode_direct_absolute=no - hardcode_libdir_flag_spec= - hardcode_libdir_flag_spec_ld= - hardcode_libdir_separator= - hardcode_minus_L=no - hardcode_shlibpath_var=unsupported - inherit_rpath=no - link_all_deplibs=unknown - module_cmds= - module_expsym_cmds= - old_archive_from_new_cmds= - old_archive_from_expsyms_cmds= - thread_safe_flag_spec= - whole_archive_flag_spec= - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - include_expsyms= - # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. - exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' - # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out - # platforms (ab)use it in PIC code, but their linkers get confused if - # the symbol is explicitly referenced. Since portable code cannot - # rely on this symbol name, it's probably fine to never include it in - # preloaded symbol tables. - # Exclude shared library initialization/finalization symbols. - extract_expsyms_cmds= - - case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; - esac - - ld_shlibs=yes - if test "$with_gnu_ld" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - export_dynamic_flag_spec='${wl}--export-dynamic' - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then - whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - whole_archive_flag_spec= - fi - supports_anon_versioning=no - case `$LD -v 2>&1` in - *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 - *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... - *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... - *\ 2.11.*) ;; # other 2.11 versions - *) supports_anon_versioning=yes ;; - esac - - # See if GNU ld supports shared libraries. - case $host_os in - aix[3-9]*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - ld_shlibs=no - cat <<_LT_EOF 1>&2 - -*** Warning: the GNU linker, at least up to release 2.9.1, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to modify your PATH -*** so that a non-GNU linker is found, and then restart. - -_LT_EOF - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='' - ;; - m68k) - archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - esac - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - allow_undefined_flag=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - ld_shlibs=no - fi - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, - # as there is no search path for DLLs. - hardcode_libdir_flag_spec='-L$libdir' - allow_undefined_flag=unsupported - always_export_symbols=no - enable_shared_with_static_runtimes=yes - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - ld_shlibs=no - fi - ;; - - interix[3-9]*) - hardcode_direct=no - hardcode_shlibpath_var=no - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - export_dynamic_flag_spec='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - - gnu* | linux* | tpf* | k*bsd*-gnu) - tmp_diet=no - if test "$host_os" = linux-dietlibc; then - case $cc_basename in - diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) - esac - fi - if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ - && test "$tmp_diet" = no - then - tmp_addflag= - tmp_sharedflag='-shared' - case $cc_basename,$host_cpu in - pgcc*) # Portland Group C compiler - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag -Mnomain' ;; - ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 - tmp_addflag=' -i_dynamic' ;; - efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 - tmp_addflag=' -i_dynamic -nofor_main' ;; - ifc* | ifort*) # Intel Fortran compiler - tmp_addflag=' -nofor_main' ;; - lf95*) # Lahey Fortran 8.1 - whole_archive_flag_spec= - tmp_sharedflag='--shared' ;; - xl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) - tmp_sharedflag='-qmkshrobj' - tmp_addflag= ;; - esac - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) # Sun C 5.9 - whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - compiler_needs_object=yes - tmp_sharedflag='-G' ;; - *Sun\ F*) # Sun Fortran 8.3 - tmp_sharedflag='-G' ;; - esac - archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - - if test "x$supports_anon_versioning" = xyes; then - archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - - case $cc_basename in - xlf*) - # IBM XL Fortran 10.1 on PPC cannot create shared libs itself - whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' - hardcode_libdir_flag_spec= - hardcode_libdir_flag_spec_ld='-rpath $libdir' - archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' - fi - ;; - esac - else - ld_shlibs=no - fi - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris*) - if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then - ld_shlibs=no - cat <<_LT_EOF 1>&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) - ld_shlibs=no - cat <<_LT_EOF 1>&2 - -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not -*** reliably create shared libraries on SCO systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.16.91.0.3 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - ;; - *) - # For security reasons, it is highly recommended that you always - # use absolute paths for naming shared libraries, and exclude the - # DT_RUNPATH tag from executables and libraries. But doing so - # requires that you compile everything twice, which is a pain. - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - esac - ;; - - sunos4*) - archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - *) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - esac - - if test "$ld_shlibs" = no; then - runpath_var= - hardcode_libdir_flag_spec= - export_dynamic_flag_spec= - whole_archive_flag_spec= - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - allow_undefined_flag=unsupported - always_export_symbols=yes - archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - hardcode_minus_L=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct=unsupported - fi - ;; - - aix[4-9]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - archive_cmds='' - hardcode_direct=yes - hardcode_direct_absolute=yes - hardcode_libdir_separator=':' - link_all_deplibs=yes - file_list_spec='${wl}-f,' - - if test "$GCC" = yes; then - case $host_os in aix4.[012]|aix4.[012].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - hardcode_direct=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - hardcode_minus_L=yes - hardcode_libdir_flag_spec='-L$libdir' - hardcode_libdir_separator= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - export_dynamic_flag_spec='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - always_export_symbols=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - allow_undefined_flag='-berok' - # Determine the default libpath from the value encoded in an - # empty executable. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - -lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\(.*\)$/\1/ - p - } - }' -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then - aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' - allow_undefined_flag="-z nodefs" - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - -lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\(.*\)$/\1/ - p - } - }' -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then - aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi - - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - no_undefined_flag=' ${wl}-bernotok' - allow_undefined_flag=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - whole_archive_flag_spec='$convenience' - archive_cmds_need_lc=yes - # This is similar to how AIX traditionally builds its shared libraries. - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='' - ;; - m68k) - archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - ;; - esac - ;; - - bsdi[45]*) - export_dynamic_flag_spec=-rdynamic - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec=' ' - allow_undefined_flag=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - old_archive_from_new_cmds='true' - # FIXME: Should let the user specify the lib program. - old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' - fix_srcfile_path='`cygpath -w "$srcfile"`' - enable_shared_with_static_runtimes=yes - ;; - - darwin* | rhapsody*) - - - archive_cmds_need_lc=no - hardcode_direct=no - hardcode_automatic=yes - hardcode_shlibpath_var=unsupported - whole_archive_flag_spec='' - link_all_deplibs=yes - allow_undefined_flag="$_lt_dar_allow_undefined" - case $cc_basename in - ifort*) _lt_dar_can_shared=yes ;; - *) _lt_dar_can_shared=$GCC ;; - esac - if test "$_lt_dar_can_shared" = "yes"; then - output_verbose_link_cmd=echo - archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" - archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" - - else - ld_shlibs=no - fi - - ;; - - dgux*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_shlibpath_var=no - ;; - - freebsd1*) - ld_shlibs=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) - archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - hpux9*) - if test "$GCC" = yes; then - archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - fi - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - export_dynamic_flag_spec='${wl}-E' - ;; - - hpux10*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_flag_spec_ld='+b $libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - hardcode_direct_absolute=yes - export_dynamic_flag_spec='${wl}-E' - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - fi - ;; - - hpux11*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - case $host_cpu in - hppa*64*) - archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - else - case $host_cpu in - hppa*64*) - archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - - case $host_cpu in - hppa*64*|ia64*) - hardcode_direct=no - hardcode_shlibpath_var=no - ;; - *) - hardcode_direct=yes - hardcode_direct_absolute=yes - export_dynamic_flag_spec='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - hardcode_minus_L=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - # Try to use the -exported_symbol ld option, if it does not - # work, assume that -exports_file does not work either and - # implicitly export all symbols. - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int foo(void) {} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" - else - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' - fi - archive_cmds_need_lc='no' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - inherit_rpath=yes - link_all_deplibs=yes - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - newsos6) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_shlibpath_var=no - ;; - - *nto* | *qnx*) - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - hardcode_direct=yes - hardcode_shlibpath_var=no - hardcode_direct_absolute=yes - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - export_dynamic_flag_spec='${wl}-E' - else - case $host_os in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-R$libdir' - ;; - *) - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - esac - fi - else - ld_shlibs=no - fi - ;; - - os2*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - allow_undefined_flag=unsupported - archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - fi - archive_cmds_need_lc='no' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - else - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ - $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' - - # Both c and cxx compiler support -rpath directly - hardcode_libdir_flag_spec='-rpath $libdir' - fi - archive_cmds_need_lc='no' - hardcode_libdir_separator=: - ;; - - solaris*) - no_undefined_flag=' -z defs' - if test "$GCC" = yes; then - wlarc='${wl}' - archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - else - case `$CC -V 2>&1` in - *"Compilers 5.0"*) - wlarc='' - archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' - ;; - *) - wlarc='${wl}' - archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - ;; - esac - fi - hardcode_libdir_flag_spec='-R$libdir' - hardcode_shlibpath_var=no - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. GCC discards it without `$wl', - # but is careful enough not to reorder. - # Supported since Solaris 2.6 (maybe 2.5.1?) - if test "$GCC" = yes; then - whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - else - whole_archive_flag_spec='-z allextract$convenience -z defaultextract' - fi - ;; - esac - link_all_deplibs=yes - ;; - - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; - - sysv4) - case $host_vendor in - sni) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' - reload_cmds='$CC -r -o $output$reload_objs' - hardcode_direct=no - ;; - motorola) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var=no - ;; - - sysv4.3*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - export_dynamic_flag_spec='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ld_shlibs=yes - fi - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) - no_undefined_flag='${wl}-z,text' - archive_cmds_need_lc=no - hardcode_shlibpath_var=no - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - no_undefined_flag='${wl}-z,text' - allow_undefined_flag='${wl}-z,nodefs' - archive_cmds_need_lc=no - hardcode_shlibpath_var=no - hardcode_libdir_flag_spec='${wl}-R,$libdir' - hardcode_libdir_separator=':' - link_all_deplibs=yes - export_dynamic_flag_spec='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - uts4*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_shlibpath_var=no - ;; - - *) - ld_shlibs=no - ;; - esac - - if test x$host_vendor = xsni; then - case $host in - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - export_dynamic_flag_spec='${wl}-Blargedynsym' - ;; - esac - fi - fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 -$as_echo "$ld_shlibs" >&6; } -test "$ld_shlibs" = no && can_build_shared=no - -with_gnu_ld=$with_gnu_ld - - - - - - - - - - - - - - - -# -# Do we need to explicitly link libc? -# -case "x$archive_cmds_need_lc" in -x|xyes) - # Assume -lc should be added - archive_cmds_need_lc=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $archive_cmds in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 -$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } - $RM conftest* - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_prog_compiler_wl - pic_flag=$lt_prog_compiler_pic - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$allow_undefined_flag - allow_undefined_flag= - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 - (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - then - archive_cmds_need_lc=no - else - archive_cmds_need_lc=yes - fi - allow_undefined_flag=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $RM conftest* - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc" >&5 -$as_echo "$archive_cmds_need_lc" >&6; } - ;; - esac - fi - ;; -esac - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 -$as_echo_n "checking dynamic linker characteristics... " >&6; } - -if test "$GCC" = yes; then - case $host_os in - darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; - *) lt_awk_arg="/^libraries:/" ;; - esac - lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` - else - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - # Ok, now we have the path, separated by spaces, we can step through it - # and add multilib dir if necessary. - lt_tmp_lt_search_path_spec= - lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` - for lt_sys_path in $lt_search_path_spec; do - if test -d "$lt_sys_path/$lt_multi_os_dir"; then - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" - else - test -d "$lt_sys_path" && \ - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" - fi - done - lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' -BEGIN {RS=" "; FS="/|\n";} { - lt_foo=""; - lt_count=0; - for (lt_i = NF; lt_i > 0; lt_i--) { - if ($lt_i != "" && $lt_i != ".") { - if ($lt_i == "..") { - lt_count++; - } else { - if (lt_count == 0) { - lt_foo="/" $lt_i lt_foo; - } else { - lt_count--; - } - } - } - } - if (lt_foo != "") { lt_freq[lt_foo]++; } - if (lt_freq[lt_foo] == 1) { print lt_foo; } -}'` - sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix[4-9]*) - version_type=linux - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[01] | aix4.[01].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - case $host_cpu in - powerpc) - # Since July 2007 AmigaOS4 officially supports .so libraries. - # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - ;; - m68k) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - esac - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[45]*) - version_type=linux - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32* | cegcc*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname~ - if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then - eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; - fi' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - #soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - soname_spec='`echo ${libname} | sed -e 's/^lib//'`${shared_ext}' - sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" - ;; - mingw* | cegcc*) - # MinGW DLLs use traditional 'lib' prefix - #soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - soname_spec='`echo ${libname} | $SED -e 's/^lib//'`${shared_ext}' - sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then - # It is most probably a Windows format PATH printed by - # mingw gcc, but we are running on Cygwin. Gcc prints its search - # path with ; separators, and with drive letters. We can handle the - # drive letters (cygwin fileutils understands them), so leave them, - # especially as we might pass files found there to a mingw objdump, - # which wouldn't understand a cygwinified path. Ahh. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - ;; - esac - ;; - - *) - library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' - ;; - esac - dynamic_linker='Win32 ld.exe' - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' - - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd1*) - dynamic_linker=no - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[123]*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[01]* | freebsdelf3.[01]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ - freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - *) # from 4.6 on, and DragonFly - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' - ;; - -interix[3-9]*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be Linux ELF. -linux* | k*bsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - # Some binutils ld are patched to set DT_RUNPATH - save_LDFLAGS=$LDFLAGS - save_libdir=$libdir - eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ - LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : - shlibpath_overrides_runpath=yes -fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS=$save_LDFLAGS - libdir=$save_libdir - - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -*nto* | *qnx*) - version_type=qnx - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='ldqnx.so' - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[89] | openbsd2.[89].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -rdos*) - dynamic_linker=no - ;; - -solaris*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -tpf*) - # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -uts4*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 -$as_echo "$dynamic_linker" >&6; } -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then - sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" -fi -if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then - sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 -$as_echo_n "checking how to hardcode library paths into programs... " >&6; } -hardcode_action= -if test -n "$hardcode_libdir_flag_spec" || - test -n "$runpath_var" || - test "X$hardcode_automatic" = "Xyes" ; then - - # We can hardcode non-existent directories. - if test "$hardcode_direct" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && - test "$hardcode_minus_L" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - hardcode_action=unsupported -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 -$as_echo "$hardcode_action" >&6; } - -if test "$hardcode_action" = relink || - test "$inherit_rpath" = yes; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi - - - - - - - if test "x$enable_dlopen" != xyes; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen="load_add_on" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - mingw* | pw32* | cegcc*) - lt_cv_dlopen="LoadLibrary" - lt_cv_dlopen_libs= - ;; - - cygwin*) - lt_cv_dlopen="dlopen" - lt_cv_dlopen_libs= - ;; - - darwin*) - # if libdl is installed we need to link against it - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 -$as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dlopen (); -int -main () -{ -return dlopen (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dl_dlopen=yes -else - ac_cv_lib_dl_dlopen=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 -$as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -else - - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - -fi - - ;; - - *) - ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" -if test "x$ac_cv_func_shl_load" = xyes; then : - lt_cv_dlopen="shl_load" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 -$as_echo_n "checking for shl_load in -ldld... " >&6; } -if ${ac_cv_lib_dld_shl_load+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldld $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char shl_load (); -int -main () -{ -return shl_load (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dld_shl_load=yes -else - ac_cv_lib_dld_shl_load=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 -$as_echo "$ac_cv_lib_dld_shl_load" >&6; } -if test "x$ac_cv_lib_dld_shl_load" = xyes; then : - lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" -else - ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" -if test "x$ac_cv_func_dlopen" = xyes; then : - lt_cv_dlopen="dlopen" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 -$as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dlopen (); -int -main () -{ -return dlopen (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dl_dlopen=yes -else - ac_cv_lib_dl_dlopen=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 -$as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 -$as_echo_n "checking for dlopen in -lsvld... " >&6; } -if ${ac_cv_lib_svld_dlopen+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lsvld $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dlopen (); -int -main () -{ -return dlopen (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_svld_dlopen=yes -else - ac_cv_lib_svld_dlopen=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 -$as_echo "$ac_cv_lib_svld_dlopen" >&6; } -if test "x$ac_cv_lib_svld_dlopen" = xyes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 -$as_echo_n "checking for dld_link in -ldld... " >&6; } -if ${ac_cv_lib_dld_dld_link+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldld $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dld_link (); -int -main () -{ -return dld_link (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dld_dld_link=yes -else - ac_cv_lib_dld_dld_link=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 -$as_echo "$ac_cv_lib_dld_dld_link" >&6; } -if test "x$ac_cv_lib_dld_dld_link" = xyes; then : - lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" -fi - - -fi - - -fi - - -fi - - -fi - - -fi - - ;; - esac - - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else - enable_dlopen=no - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS="$LDFLAGS" - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 -$as_echo_n "checking whether a program can dlopen itself... " >&6; } -if ${lt_cv_dlopen_self+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - lt_cv_dlopen_self=cross -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF -#line 9845 "configure" -#include "confdefs.h" - -#if HAVE_DLFCN_H -#include -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -void fnord() { int i=42;} -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - /* dlclose (self); */ - } - else - puts (dlerror ()); - - return status; -} -_LT_EOF - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 - (eval $ac_link) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&5 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; - x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self=no - fi -fi -rm -fr conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 -$as_echo "$lt_cv_dlopen_self" >&6; } - - if test "x$lt_cv_dlopen_self" = xyes; then - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 -$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } -if ${lt_cv_dlopen_self_static+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - lt_cv_dlopen_self_static=cross -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF -#line 9941 "configure" -#include "confdefs.h" - -#if HAVE_DLFCN_H -#include -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -void fnord() { int i=42;} -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - /* dlclose (self); */ - } - else - puts (dlerror ()); - - return status; -} -_LT_EOF - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 - (eval $ac_link) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&5 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; - esac - else : - # compilation failed - lt_cv_dlopen_self_static=no - fi -fi -rm -fr conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 -$as_echo "$lt_cv_dlopen_self_static" >&6; } - fi - - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi - - - - - - - - - - - - - - - - - -striplib= -old_striplib= -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 -$as_echo_n "checking whether stripping libraries is possible... " >&6; } -if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP" ; then - striplib="$STRIP -x" - old_striplib="$STRIP -S" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - fi - ;; - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ;; - esac -fi - - - - - - - - - - - - - # Report which library types will actually be built - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 -$as_echo_n "checking if libtool supports shared libraries... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 -$as_echo "$can_build_shared" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 -$as_echo_n "checking whether to build shared libraries... " >&6; } - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - - aix[4-9]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 -$as_echo "$enable_shared" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 -$as_echo_n "checking whether to build static libraries... " >&6; } - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 -$as_echo "$enable_static" >&6; } - - - - -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -CC="$lt_save_CC" - - - - - - - - - - - - - - ac_config_commands="$ac_config_commands libtool" - - - - -# Only expand once: - - - -LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION -LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE` -LT_REVISION=$INTERFACE_AGE -LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE` - - - - - - - -ac_aux_dir= -for ac_dir in $srcdir/build-scripts; do - if test -f "$ac_dir/install-sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f "$ac_dir/install.sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f "$ac_dir/shtool"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi -done -if test -z "$ac_aux_dir"; then - as_fn_error $? "cannot find install-sh, install.sh, or shtool in $srcdir/build-scripts" "$LINENO" 5 -fi - -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. -ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. -ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - - - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -struct stat; -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -# Reject install programs that cannot install multiple files. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 -$as_echo_n "checking for a BSD-compatible install... " >&6; } -if test -z "$INSTALL"; then -if ${ac_cv_path_install+:} false; then : - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in #(( - ./ | .// | /[cC]/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - rm -rf conftest.one conftest.two conftest.dir - echo one > conftest.one - echo two > conftest.two - mkdir conftest.dir - if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && - test -s conftest.one && test -s conftest.two && - test -s conftest.dir/conftest.one && - test -s conftest.dir/conftest.two - then - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - fi - done - done - ;; -esac - - done -IFS=$as_save_IFS - -rm -rf conftest.one conftest.two conftest.dir - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. Don't cache a - # value for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - INSTALL=$ac_install_sh - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 -$as_echo "$INSTALL" >&6; } - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } -set x ${MAKE-make} -ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat >conftest.make <<\_ACEOF -SHELL = /bin/sh -all: - @echo '@@@%%%=$(MAKE)=@@@%%%' -_ACEOF -# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac -rm -f conftest.make -fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - SET_MAKE= -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - SET_MAKE="MAKE=${MAKE-make}" -fi - -if test -z "$host_alias"; then - hostaliaswindres= -else - hostaliaswindres="$host_alias-windres" -fi -for ac_prog in windres $hostaliaswindres $host_os-windres -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_WINDRES+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$WINDRES"; then - ac_cv_prog_WINDRES="$WINDRES" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_WINDRES="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -WINDRES=$ac_cv_prog_WINDRES -if test -n "$WINDRES"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WINDRES" >&5 -$as_echo "$WINDRES" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$WINDRES" && break -done - - -case "$host" in - *-*-cygwin*) - # We build SDL on cygwin without the UNIX emulation layer - BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin" - BASE_LDFLAGS="-mno-cygwin" - ;; - *) - BASE_CFLAGS="-D_GNU_SOURCE=1" - BASE_LDFLAGS="" - ;; -esac -BUILD_CFLAGS="$CFLAGS $CPPFLAGS" -EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS" -BUILD_LDFLAGS="$LDFLAGS" -EXTRA_LDFLAGS="$BASE_LDFLAGS" -## These are common directories to find software packages -#for path in /usr/freeware /usr/pkg /usr/local; do -# if test -d $path/include; then -# EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include" -# fi -# if test -d $path/lib; then -# EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib" -# fi -#done -CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS" -CFLAGS="$CFLAGS $EXTRA_CFLAGS" -LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 -$as_echo_n "checking for an ANSI C-conforming const... " >&6; } -if ${ac_cv_c_const+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - -#ifndef __cplusplus - /* Ultrix mips cc rejects this sort of thing. */ - typedef int charset[2]; - const charset cs = { 0, 0 }; - /* SunOS 4.1.1 cc rejects this. */ - char const *const *pcpcc; - char **ppc; - /* NEC SVR4.0.2 mips cc rejects this. */ - struct point {int x, y;}; - static struct point const zero = {0,0}; - /* AIX XL C 1.02.0.0 rejects this. - It does not let you subtract one const X* pointer from another in - an arm of an if-expression whose if-part is not a constant - expression */ - const char *g = "string"; - pcpcc = &g + (g ? g-g : 0); - /* HPUX 7.0 cc rejects these. */ - ++pcpcc; - ppc = (char**) pcpcc; - pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this sort of thing. */ - char tx; - char *t = &tx; - char const *s = 0 ? (char *) 0 : (char const *) 0; - - *t++ = 0; - if (s) return 0; - } - { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ - int x[] = {25, 17}; - const int *foo = &x[0]; - ++foo; - } - { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ - typedef const int *iptr; - iptr p = 0; - ++p; - } - { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying - "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; } bx; - struct s *b = &bx; b->j = 5; - } - { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ - const int foo = 10; - if (!foo) return 0; - } - return !cs[0] && !zero.x; -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_const=yes -else - ac_cv_c_const=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 -$as_echo "$ac_cv_c_const" >&6; } -if test $ac_cv_c_const = no; then - -$as_echo "#define const /**/" >>confdefs.h - -fi - - -# Check whether --enable-dependency-tracking was given. -if test "${enable_dependency_tracking+set}" = set; then : - enableval=$enable_dependency_tracking; -else - enable_dependency_tracking=yes -fi - -if test x$enable_dependency_tracking = xyes; then - have_gcc_mmd_mt=no - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -MMD -MT option" >&5 -$as_echo_n "checking for GCC -MMD -MT option... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #if !defined(__GNUC__) || __GNUC__ < 3 - #error Dependency tracking requires GCC 3.0 or newer - #endif - -int -main () -{ - - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - have_gcc_mmd_mt=yes - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_mmd_mt" >&5 -$as_echo "$have_gcc_mmd_mt" >&6; } - - if test x$have_gcc_mmd_mt = xyes; then - DEPENDENCY_TRACKING_OPTIONS="-MMD -MT \$@" - fi -fi - -case "$host" in - *mingw32ce*) - #VERSION_SOURCES="$srcdir/version.rc" - EXE=".exe" - ;; - *-*-cygwin* | *-*-mingw32*) - VERSION_SOURCES="$srcdir/version.rc" - EXE=".exe" - if test "$build" != "$host"; then # cross-compiling - # Default cross-compile location - ac_default_prefix=/usr/local/cross-tools/$host - else - # Look for the location of the tools and install there - if test "$BUILD_PREFIX" != ""; then - ac_default_prefix=$BUILD_PREFIX - fi - fi - ;; - *) - EXE="" - ;; -esac - -# Standard C sources -SOURCES=`ls $srcdir/*.c | fgrep -v playwave.c | fgrep -v playmus.c` - -base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'` - -CheckVisibilityHidden() -{ - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -fvisibility=hidden option" >&5 -$as_echo_n "checking for GCC -fvisibility=hidden option... " >&6; } - have_gcc_fvisibility=no - - visibility_CFLAGS="-fvisibility=hidden" - save_CFLAGS="$CFLAGS" - CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #if !defined(__GNUC__) || __GNUC__ < 4 - #error SDL only uses visibility attributes in GCC 4 or newer - #endif - -int -main () -{ - - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - have_gcc_fvisibility=yes - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_fvisibility" >&5 -$as_echo "$have_gcc_fvisibility" >&6; } - CFLAGS="$save_CFLAGS" - - if test x$have_gcc_fvisibility = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS" - fi -} - - -find_lib() -{ - gcc_bin_path=`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'` - gcc_lib_path=`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'` - env_lib_path=`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'` - if test "$cross_compiling" = yes; then - host_lib_path="" - else - host_lib_path="/usr/$base_libdir /usr/local/$base_libdir" - fi - for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do - lib=`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1` - if test x$lib != x; then - echo $lib - return - fi - done -} - -SDL_VERSION=2.0.7 - - -if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. -set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PKG_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -PKG_CONFIG=$ac_cv_path_PKG_CONFIG -if test -n "$PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 -$as_echo "$PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_path_PKG_CONFIG"; then - ac_pt_PKG_CONFIG=$PKG_CONFIG - # Extract the first word of "pkg-config", so it can be a program name with args. -set dummy pkg-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $ac_pt_PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG -if test -n "$ac_pt_PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 -$as_echo "$ac_pt_PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_pt_PKG_CONFIG" = x; then - PKG_CONFIG="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - PKG_CONFIG=$ac_pt_PKG_CONFIG - fi -else - PKG_CONFIG="$ac_cv_path_PKG_CONFIG" -fi - -fi -if test -n "$PKG_CONFIG"; then - _pkg_min_version=0.9.0 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 -$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } - if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - PKG_CONFIG="" - fi - -fi - -# Check whether --with-sdl-prefix was given. -if test "${with_sdl_prefix+set}" = set; then : - withval=$with_sdl_prefix; sdl_prefix="$withval" -else - sdl_prefix="" -fi - - -# Check whether --with-sdl-exec-prefix was given. -if test "${with_sdl_exec_prefix+set}" = set; then : - withval=$with_sdl_exec_prefix; sdl_exec_prefix="$withval" -else - sdl_exec_prefix="" -fi - -# Check whether --enable-sdltest was given. -if test "${enable_sdltest+set}" = set; then : - enableval=$enable_sdltest; -else - enable_sdltest=yes -fi - - - min_sdl_version=$SDL_VERSION - - if test "x$sdl_prefix$sdl_exec_prefix" = x ; then - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SDL" >&5 -$as_echo_n "checking for SDL... " >&6; } - -if test -n "$PKG_CONFIG"; then - if test -n "$SDL_CFLAGS"; then - pkg_cv_SDL_CFLAGS="$SDL_CFLAGS" - else - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl2 >= \$min_sdl_version\""; } >&5 - ($PKG_CONFIG --exists --print-errors "sdl2 >= $min_sdl_version") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_SDL_CFLAGS=`$PKG_CONFIG --cflags "sdl2 >= $min_sdl_version" 2>/dev/null` -else - pkg_failed=yes -fi - fi -else - pkg_failed=untried -fi -if test -n "$PKG_CONFIG"; then - if test -n "$SDL_LIBS"; then - pkg_cv_SDL_LIBS="$SDL_LIBS" - else - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sdl2 >= \$min_sdl_version\""; } >&5 - ($PKG_CONFIG --exists --print-errors "sdl2 >= $min_sdl_version") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_SDL_LIBS=`$PKG_CONFIG --libs "sdl2 >= $min_sdl_version" 2>/dev/null` -else - pkg_failed=yes -fi - fi -else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - SDL_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "sdl2 >= $min_sdl_version"` - else - SDL_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "sdl2 >= $min_sdl_version"` - fi - # Put the nasty error message in config.log where it belongs - echo "$SDL_PKG_ERRORS" >&5 - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - sdl_pc=no -elif test $pkg_failed = untried; then - sdl_pc=no -else - SDL_CFLAGS=$pkg_cv_SDL_CFLAGS - SDL_LIBS=$pkg_cv_SDL_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - sdl_pc=yes -fi - else - sdl_pc=no - if test x$sdl_exec_prefix != x ; then - sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix" - if test x${SDL2_CONFIG+set} != xset ; then - SDL2_CONFIG=$sdl_exec_prefix/bin/sdl2-config - fi - fi - if test x$sdl_prefix != x ; then - sdl_config_args="$sdl_config_args --prefix=$sdl_prefix" - if test x${SDL2_CONFIG+set} != xset ; then - SDL2_CONFIG=$sdl_prefix/bin/sdl2-config - fi - fi - fi - - if test "x$sdl_pc" = xyes ; then - no_sdl="" - SDL2_CONFIG="pkg-config sdl2" - else - as_save_PATH="$PATH" - if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then - PATH="$prefix/bin:$prefix/usr/bin:$PATH" - fi - # Extract the first word of "sdl2-config", so it can be a program name with args. -set dummy sdl2-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_SDL2_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $SDL2_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_SDL2_CONFIG="$SDL2_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_SDL2_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - test -z "$ac_cv_path_SDL2_CONFIG" && ac_cv_path_SDL2_CONFIG="no" - ;; -esac -fi -SDL2_CONFIG=$ac_cv_path_SDL2_CONFIG -if test -n "$SDL2_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SDL2_CONFIG" >&5 -$as_echo "$SDL2_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - PATH="$as_save_PATH" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SDL - version >= $min_sdl_version" >&5 -$as_echo_n "checking for SDL - version >= $min_sdl_version... " >&6; } - no_sdl="" - - if test "$SDL2_CONFIG" = "no" ; then - no_sdl=yes - else - SDL_CFLAGS=`$SDL2_CONFIG $sdl_config_args --cflags` - SDL_LIBS=`$SDL2_CONFIG $sdl_config_args --libs` - - sdl_major_version=`$SDL2_CONFIG $sdl_config_args --version | \ - sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` - sdl_minor_version=`$SDL2_CONFIG $sdl_config_args --version | \ - sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` - sdl_micro_version=`$SDL2_CONFIG $sdl_config_args --version | \ - sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` - if test "x$enable_sdltest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_CXXFLAGS="$CXXFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $SDL_CFLAGS" - CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" - LIBS="$LIBS $SDL_LIBS" - rm -f conf.sdltest - if test "$cross_compiling" = yes; then : - echo $ac_n "cross compiling; assumed OK... $ac_c" -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include "SDL.h" - -char* -my_strdup (char *str) -{ - char *new_str; - - if (str) - { - new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); - strcpy (new_str, str); - } - else - new_str = NULL; - - return new_str; -} - -int main (int argc, char *argv[]) -{ - int major, minor, micro; - char *tmp_version; - - /* This hangs on some systems (?) - system ("touch conf.sdltest"); - */ - { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } - - /* HP/UX 9 (%@#!) writes to sscanf strings */ - tmp_version = my_strdup("$min_sdl_version"); - if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { - printf("%s, bad version string\n", "$min_sdl_version"); - exit(1); - } - - if (($sdl_major_version > major) || - (($sdl_major_version == major) && ($sdl_minor_version > minor)) || - (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) - { - return 0; - } - else - { - printf("\n*** 'sdl2-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); - printf("*** of SDL required is %d.%d.%d. If sdl2-config is correct, then it is\n", major, minor, micro); - printf("*** best to upgrade to the required version.\n"); - printf("*** If sdl2-config was wrong, set the environment variable SDL2_CONFIG\n"); - printf("*** to point to the correct copy of sdl2-config, and remove the file\n"); - printf("*** config.cache before re-running configure\n"); - return 1; - } -} - - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - no_sdl=yes -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - CFLAGS="$ac_save_CFLAGS" - CXXFLAGS="$ac_save_CXXFLAGS" - LIBS="$ac_save_LIBS" - fi - fi - if test "x$no_sdl" = x ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - fi - fi - if test "x$no_sdl" = x ; then - : - else - if test "$SDL2_CONFIG" = "no" ; then - echo "*** The sdl2-config script installed by SDL could not be found" - echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" - echo "*** your path, or set the SDL2_CONFIG environment variable to the" - echo "*** full path to sdl2-config." - else - if test -f conf.sdltest ; then - : - else - echo "*** Could not run SDL test program, checking why..." - CFLAGS="$CFLAGS $SDL_CFLAGS" - CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" - LIBS="$LIBS $SDL_LIBS" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include "SDL.h" - -int main(int argc, char *argv[]) -{ return 0; } -#undef main -#define main K_and_R_C_main - -int -main () -{ - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - echo "*** The test program compiled, but did not run. This usually means" - echo "*** that the run-time linker is not finding SDL or finding the wrong" - echo "*** version of SDL. If it is not finding SDL, you'll need to set your" - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" - echo "*** to the installed location Also, make sure you have run ldconfig if that" - echo "*** is required on your system" - echo "***" - echo "*** If you have an old version installed, it is best to remove it, although" - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" -else - echo "*** The test program failed to compile or link. See the file config.log for the" - echo "*** exact error that occured. This usually means SDL was incorrectly installed" - echo "*** or that you have moved SDL since it was installed. In the latter case, you" - echo "*** may want to edit the sdl2-config script: $SDL2_CONFIG" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - CFLAGS="$ac_save_CFLAGS" - CXXFLAGS="$ac_save_CXXFLAGS" - LIBS="$ac_save_LIBS" - fi - fi - SDL_CFLAGS="" - SDL_LIBS="" - as_fn_error $? "*** SDL version $SDL_VERSION not found!" "$LINENO" 5 - - fi - - - rm -f conf.sdltest - -EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS" -EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pow in -lm" >&5 -$as_echo_n "checking for pow in -lm... " >&6; } -if ${ac_cv_lib_m_pow+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lm $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char pow (); -int -main () -{ -return pow (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_m_pow=yes -else - ac_cv_lib_m_pow=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow" >&5 -$as_echo "$ac_cv_lib_m_pow" >&6; } -if test "x$ac_cv_lib_m_pow" = xyes; then : - LIBM="-lm" -fi - - -for ac_header in signal.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "signal.h" "ac_cv_header_signal_h" "$ac_includes_default" -if test "x$ac_cv_header_signal_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SIGNAL_H 1 -_ACEOF - EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SIGNAL_H" -fi - -done - -for ac_func in setbuf -do : - ac_fn_c_check_func "$LINENO" "setbuf" "ac_cv_func_setbuf" -if test "x$ac_cv_func_setbuf" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SETBUF 1 -_ACEOF - EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SETBUF" -fi -done - - - -CheckVisibilityHidden - -# Check whether --enable-music-cmd was given. -if test "${enable_music_cmd+set}" = set; then : - enableval=$enable_music_cmd; -else - enable_music_cmd=detect -fi - -if test "x$enable_music_cmd" != xno; then - for ac_func in fork vfork -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - if test "x$ac_cv_func_fork" = "xyes"; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_FORK" - elif test "x$ac_cv_func_vfork" = "xyes"; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_VFORK" - elif test "x$enable_music_cmd" = "xyes"; then - as_fn_error $? "external music player not available on your platform" "$LINENO" 5 - else - enable_music_cmd=no - fi - if test "x$enable_music_cmd" != xno; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_CMD" - fi -fi - -# Check whether --enable-music-wave was given. -if test "${enable_music_wave+set}" = set; then : - enableval=$enable_music_wave; -else - enable_music_wave=yes -fi - -if test x$enable_music_wave = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_WAV" -fi - -# Check whether --enable-music-mod was given. -if test "${enable_music_mod+set}" = set; then : - enableval=$enable_music_mod; -else - enable_music_mod=yes -fi - - -# Check whether --enable-music-mod-modplug was given. -if test "${enable_music_mod_modplug+set}" = set; then : - enableval=$enable_music_mod_modplug; -else - enable_music_mod_modplug=yes -fi - -# Check whether --enable-music-mod-modplug-shared was given. -if test "${enable_music_mod_modplug_shared+set}" = set; then : - enableval=$enable_music_mod_modplug_shared; -else - enable_music_mod_modplug_shared=yes -fi - -if test x$enable_music_mod = xyes -a x$enable_music_mod_modplug = xyes; then - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MODPLUG" >&5 -$as_echo_n "checking for MODPLUG... " >&6; } - -if test -n "$PKG_CONFIG"; then - if test -n "$MODPLUG_CFLAGS"; then - pkg_cv_MODPLUG_CFLAGS="$MODPLUG_CFLAGS" - else - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libmodplug >= 0.8.8\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libmodplug >= 0.8.8") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_MODPLUG_CFLAGS=`$PKG_CONFIG --cflags "libmodplug >= 0.8.8" 2>/dev/null` -else - pkg_failed=yes -fi - fi -else - pkg_failed=untried -fi -if test -n "$PKG_CONFIG"; then - if test -n "$MODPLUG_LIBS"; then - pkg_cv_MODPLUG_LIBS="$MODPLUG_LIBS" - else - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libmodplug >= 0.8.8\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libmodplug >= 0.8.8") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_MODPLUG_LIBS=`$PKG_CONFIG --libs "libmodplug >= 0.8.8" 2>/dev/null` -else - pkg_failed=yes -fi - fi -else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - MODPLUG_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "libmodplug >= 0.8.8"` - else - MODPLUG_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "libmodplug >= 0.8.8"` - fi - # Put the nasty error message in config.log where it belongs - echo "$MODPLUG_PKG_ERRORS" >&5 - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ac_fn_c_check_header_mongrel "$LINENO" "libmodplug/modplug.h" "ac_cv_header_libmodplug_modplug_h" "$ac_includes_default" -if test "x$ac_cv_header_libmodplug_modplug_h" = xyes; then : - have_libmodplug_hdr=yes -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ModPlug_Load in -lmodplug" >&5 -$as_echo_n "checking for ModPlug_Load in -lmodplug... " >&6; } -if ${ac_cv_lib_modplug_ModPlug_Load+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lmodplug $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char ModPlug_Load (); -int -main () -{ -return ModPlug_Load (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_modplug_ModPlug_Load=yes -else - ac_cv_lib_modplug_ModPlug_Load=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_modplug_ModPlug_Load" >&5 -$as_echo "$ac_cv_lib_modplug_ModPlug_Load" >&6; } -if test "x$ac_cv_lib_modplug_ModPlug_Load" = xyes; then : - have_libmodplug_lib=yes;MODPLUG_LIBS="-lmodplug" -fi - - -elif test $pkg_failed = untried; then - ac_fn_c_check_header_mongrel "$LINENO" "libmodplug/modplug.h" "ac_cv_header_libmodplug_modplug_h" "$ac_includes_default" -if test "x$ac_cv_header_libmodplug_modplug_h" = xyes; then : - have_libmodplug_hdr=yes -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ModPlug_Load in -lmodplug" >&5 -$as_echo_n "checking for ModPlug_Load in -lmodplug... " >&6; } -if ${ac_cv_lib_modplug_ModPlug_Load+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lmodplug $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char ModPlug_Load (); -int -main () -{ -return ModPlug_Load (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_modplug_ModPlug_Load=yes -else - ac_cv_lib_modplug_ModPlug_Load=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_modplug_ModPlug_Load" >&5 -$as_echo "$ac_cv_lib_modplug_ModPlug_Load" >&6; } -if test "x$ac_cv_lib_modplug_ModPlug_Load" = xyes; then : - have_libmodplug_lib=yes;MODPLUG_LIBS="-lmodplug" -fi - - -else - MODPLUG_CFLAGS=$pkg_cv_MODPLUG_CFLAGS - MODPLUG_LIBS=$pkg_cv_MODPLUG_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - have_libmodplug_hdr=yes - have_libmodplug_lib=yes - -fi - - if test x$have_libmodplug_hdr = xyes -a x$have_libmodplug_lib = xyes; then - have_libmodplug=yes - case "$host" in - *-*-darwin*) - modplug_lib=`find_lib libmodplug.dylib` - ;; - *-*-cygwin* | *-*-mingw32*) - modplug_lib=`find_lib "libmodplug*.dll"` - ;; - *) - modplug_lib=`find_lib "libmodplug[0-9]*.so.*"` - if test x$modplug_lib = x; then - modplug_lib=`find_lib "libmodplug.so.*"` - fi - ;; - esac - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MODPLUG $MODPLUG_CFLAGS" - if test x$enable_music_mod_modplug_shared = xyes && test x$modplug_lib != x; then - echo "-- dynamic libmodplug -> $modplug_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_DYNAMIC=\\\"$modplug_lib\\\"" - else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS" - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)" >&5 -$as_echo "$as_me: WARNING: *** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)" >&2;} - fi -fi - -# Check whether --enable-music-mod-mikmod was given. -if test "${enable_music_mod_mikmod+set}" = set; then : - enableval=$enable_music_mod_mikmod; -else - enable_music_mod_mikmod=no -fi - -# Check whether --enable-music-mod-mikmod-shared was given. -if test "${enable_music_mod_mikmod_shared+set}" = set; then : - enableval=$enable_music_mod_mikmod_shared; -else - enable_music_mod_mikmod_shared=yes -fi - -if test x$enable_music_mod = xyes -a x$enable_music_mod_mikmod = xyes; then - have_libmikmod=no - libmikmod_maj=3 - libmikmod_min=1 - libmikmod_rev=10 - libmikmod_ver="$libmikmod_maj.$libmikmod_min.$libmikmod_rev" - CFLAGS_SAVED="$CFLAGS" - LIBS_SAVED="$LIBS" - # Extract the first word of "libmikmod-config", so it can be a program name with args. -set dummy libmikmod-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_LIBMIKMOD_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $LIBMIKMOD_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_LIBMIKMOD_CONFIG="$LIBMIKMOD_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_LIBMIKMOD_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - test -z "$ac_cv_path_LIBMIKMOD_CONFIG" && ac_cv_path_LIBMIKMOD_CONFIG="no" - ;; -esac -fi -LIBMIKMOD_CONFIG=$ac_cv_path_LIBMIKMOD_CONFIG -if test -n "$LIBMIKMOD_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBMIKMOD_CONFIG" >&5 -$as_echo "$LIBMIKMOD_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - if test "$LIBMIKMOD_CONFIG" != "no" ; then - CFLAGS="$CFLAGS `$LIBMIKMOD_CONFIG --cflags`" - LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`" - have_libmikmod=yes - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libmikmod - version >= $libmikmod_ver" >&5 -$as_echo_n "checking for libmikmod - version >= $libmikmod_ver... " >&6; } - if test "$cross_compiling" = yes; then : - echo $ac_n "cross compiling; assumed OK... $ac_c" -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include "mikmod.h" -#include "stdio.h" - -int main(int argc, char **argv) -{ -long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion(); -/*printf("(%d.%d.%d) ",ver>>16,(ver>>8)&0xff,ver&0xff);*/ -if(ver>=((maj<<16)|(min<<8)|(rev))) { - printf("yes\n"); - return 0; -} -printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev); -return 1; -} - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - have_libmikmod=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - fi - - if test x$have_libmikmod = xyes; then - case "$host" in - *-*-darwin*) - mikmod_lib=`find_lib libmikmod.dylib` - ;; - *-*-cygwin* | *-*-mingw32*) - mikmod_lib=`find_lib "libmikmod*.dll"` - ;; - *) - mikmod_lib=`find_lib "libmikmod[0-9]*.so.*"` - if test x$mikmod_lib = x; then - mikmod_lib=`find_lib "libmikmod.so.*"` - fi - ;; - esac - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MIKMOD `$LIBMIKMOD_CONFIG --cflags`" - if test x$enable_music_mod_mikmod_shared = xyes && test x$mikmod_lib != x; then - echo "-- dynamic libmikmod -> $mikmod_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMIKMOD_DYNAMIC=\\\"$mikmod_lib\\\"" - else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`" - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find MikMod library (http://mikmod.raphnet.net/)" >&5 -$as_echo "$as_me: WARNING: *** Unable to find MikMod library (http://mikmod.raphnet.net/)" >&2;} - fi - LIBS="$LIBS_SAVED" - CFLAGS="$CFLAGS_SAVED" -fi - -if test x$have_libmodplug != xyes -a x$have_libmikmod != xyes ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MOD support disabled" >&5 -$as_echo "$as_me: WARNING: MOD support disabled" >&2;} -fi - -# Check whether --enable-music-midi was given. -if test "${enable_music_midi+set}" = set; then : - enableval=$enable_music_midi; -else - enable_music_midi=yes -fi - -if test x$enable_music_midi = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID" - # Check whether --enable-music-midi-timidity was given. -if test "${enable_music_midi_timidity+set}" = set; then : - enableval=$enable_music_midi_timidity; -else - enable_music_midi_timidity=yes -fi - - if test x$enable_music_midi_timidity = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_TIMIDITY -I\$(srcdir)/timidity" - SOURCES="$SOURCES $srcdir/timidity/*.c" - fi - # Check whether --enable-music-midi-native was given. -if test "${enable_music_midi_native+set}" = set; then : - enableval=$enable_music_midi_native; -else - enable_music_midi_native=yes -fi - - if test x$enable_music_midi_native = xyes; then - use_music_midi_native=no - case "$host" in - *mingw32ce*) - use_music_midi_native=no - ;; - *-*-cygwin* | *-*-mingw32*) - use_music_midi_native=yes - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm" - ;; - *-*-darwin*) - use_music_midi_native=yes - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,CoreServices" - ;; - *-*-haiku*) - use_music_midi_native=yes_cpp - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmidi" - ;; - esac - if test x$use_music_midi_native = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi" - SOURCES="$SOURCES $srcdir/native_midi/*.c" - elif test x$use_music_midi_native = xyes_cpp; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi" - SOURCES="$SOURCES $srcdir/native_midi/*.c" - SOURCES_CXX="$SOURCES_CXX $srcdir/native_midi/*.cpp" - fi - fi - # Check whether --enable-music-midi-fluidsynth was given. -if test "${enable_music_midi_fluidsynth+set}" = set; then : - enableval=$enable_music_midi_fluidsynth; -else - enable_music_midi_fluidsynth=yes -fi - - # Check whether --enable-music-midi-fluidsynth-shared was given. -if test "${enable_music_midi_fluidsynth_shared+set}" = set; then : - enableval=$enable_music_midi_fluidsynth_shared; -else - enable_music_midi_fluidsynth_shared=yes -fi - - if test x$enable_music_midi_fluidsynth = xyes; then - ac_fn_c_check_header_mongrel "$LINENO" "fluidsynth.h" "ac_cv_header_fluidsynth_h" "$ac_includes_default" -if test "x$ac_cv_header_fluidsynth_h" = xyes; then : - have_fluidsynth_hdr=yes -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fluid_player_add_mem in -lfluidsynth" >&5 -$as_echo_n "checking for fluid_player_add_mem in -lfluidsynth... " >&6; } -if ${ac_cv_lib_fluidsynth_fluid_player_add_mem+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lfluidsynth $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char fluid_player_add_mem (); -int -main () -{ -return fluid_player_add_mem (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_fluidsynth_fluid_player_add_mem=yes -else - ac_cv_lib_fluidsynth_fluid_player_add_mem=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_fluidsynth_fluid_player_add_mem" >&5 -$as_echo "$ac_cv_lib_fluidsynth_fluid_player_add_mem" >&6; } -if test "x$ac_cv_lib_fluidsynth_fluid_player_add_mem" = xyes; then : - have_fluidsynth_lib=yes -fi - - if test x$have_fluidsynth_hdr = xyes -a x$have_fluidsynth_lib = xyes; then - have_fluidsynth=yes - case "$host" in - *-*-darwin*) - fluidsynth_lib=`find_lib libfluidsynth.dylib` - ;; - *-*-cygwin* | *-*-mingw32*) - fluidsynth_lib=`find_lib "fluidsynth*.dll"` - ;; - *) - fluidsynth_lib=`find_lib "libfluidsynth[0-9]*.so.*"` - if test x$fluidsynth_lib = x; then - fluidsynth_lib=`find_lib "libfluidsynth.so.*"` - fi - ;; - esac - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_FLUIDSYNTH" - if test x$enable_music_midi_fluidsynth_shared = xyes && test x$fluidsynth_lib != x; then - echo "-- dynamic libfluidsynth -> $fluidsynth_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLUIDSYNTH_DYNAMIC=\\\"$fluidsynth_lib\\\"" - else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lfluidsynth" - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find FluidSynth library (http://www.fluidsynth.org/)" >&5 -$as_echo "$as_me: WARNING: *** Unable to find FluidSynth library (http://www.fluidsynth.org/)" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: FluidSynth support disabled" >&5 -$as_echo "$as_me: WARNING: FluidSynth support disabled" >&2;} - fi - fi -fi - -if test x$enable_music_midi_timidity != xyes -a \ - x$use_music_midi_native != xyes -a x$use_music_midi_native != xyes_cpp -a \ - x$have_fluidsynth != xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MIDI support disabled" >&5 -$as_echo "$as_me: WARNING: MIDI support disabled" >&2;} -fi - -# Check whether --enable-music-ogg was given. -if test "${enable_music_ogg+set}" = set; then : - enableval=$enable_music_ogg; -else - enable_music_ogg=yes -fi - -# Check whether --enable-music-ogg-tremor was given. -if test "${enable_music_ogg_tremor+set}" = set; then : - enableval=$enable_music_ogg_tremor; -else - enable_music_ogg_tremor=no -fi - -# Check whether --enable-music-ogg-shared was given. -if test "${enable_music_ogg_shared+set}" = set; then : - enableval=$enable_music_ogg_shared; -else - enable_music_ogg_shared=yes -fi - -if test x$enable_music_ogg = xyes; then - LIBS_SAVED="$LIBS" - if test x$enable_music_ogg_tremor = xyes; then - ac_fn_c_check_header_mongrel "$LINENO" "tremor/ivorbisfile.h" "ac_cv_header_tremor_ivorbisfile_h" "$ac_includes_default" -if test "x$ac_cv_header_tremor_ivorbisfile_h" = xyes; then : - have_tremor_hdr=yes -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ov_open_callbacks in -lvorbisidec" >&5 -$as_echo_n "checking for ov_open_callbacks in -lvorbisidec... " >&6; } -if ${ac_cv_lib_vorbisidec_ov_open_callbacks+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lvorbisidec -logg $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char ov_open_callbacks (); -int -main () -{ -return ov_open_callbacks (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_vorbisidec_ov_open_callbacks=yes -else - ac_cv_lib_vorbisidec_ov_open_callbacks=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_vorbisidec_ov_open_callbacks" >&5 -$as_echo "$ac_cv_lib_vorbisidec_ov_open_callbacks" >&6; } -if test "x$ac_cv_lib_vorbisidec_ov_open_callbacks" = xyes; then : - have_tremor_lib=yes -fi - - if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then - case "$host" in - *-*-darwin*) - ogg_lib=`find_lib libvorbisidec.dylib` - ;; - *-*-cygwin* | *-*-mingw32*) - ogg_lib=`find_lib "vorbisidec*.dll"` - ;; - *) - ogg_lib=`find_lib "libvorbisidec[0-9]*.so.*"` - if test x$ogg_lib = x; then - ogg_lib=`find_lib "libvorbisidec.so.*"` - fi - ;; - esac - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG -DOGG_USE_TREMOR" - if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then - echo "-- dynamic libvorbisidec -> $ogg_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\"" - else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec -lvorbis" - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)" >&5 -$as_echo "$as_me: WARNING: *** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ogg Vorbis support disabled" >&5 -$as_echo "$as_me: WARNING: Ogg Vorbis support disabled" >&2;} - fi - else - ac_fn_c_check_header_mongrel "$LINENO" "vorbis/vorbisfile.h" "ac_cv_header_vorbis_vorbisfile_h" "$ac_includes_default" -if test "x$ac_cv_header_vorbis_vorbisfile_h" = xyes; then : - have_ogg_hdr=yes -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ov_open_callbacks in -lvorbisfile" >&5 -$as_echo_n "checking for ov_open_callbacks in -lvorbisfile... " >&6; } -if ${ac_cv_lib_vorbisfile_ov_open_callbacks+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lvorbisfile -lvorbis -logg -lm $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char ov_open_callbacks (); -int -main () -{ -return ov_open_callbacks (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_vorbisfile_ov_open_callbacks=yes -else - ac_cv_lib_vorbisfile_ov_open_callbacks=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_vorbisfile_ov_open_callbacks" >&5 -$as_echo "$ac_cv_lib_vorbisfile_ov_open_callbacks" >&6; } -if test "x$ac_cv_lib_vorbisfile_ov_open_callbacks" = xyes; then : - have_ogg_lib=yes -fi - - if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then - case "$host" in - *-*-darwin*) - ogg_lib=`find_lib libvorbisfile.dylib` - ;; - *-*-cygwin* | *-*-mingw32*) - ogg_lib=`find_lib "libvorbisfile*.dll"` - ;; - *) - ogg_lib=`find_lib "libvorbisfile[0-9]*.so.*"` - if test x$ogg_lib = x; then - ogg_lib=`find_lib "libvorbisfile.so.*"` - fi - ;; - esac - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG" - if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then - echo "-- dynamic libvorbisfile -> $ogg_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\"" - else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis" - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find Ogg Vorbis library (http://www.xiph.org/)" >&5 -$as_echo "$as_me: WARNING: *** Unable to find Ogg Vorbis library (http://www.xiph.org/)" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ogg Vorbis support disabled" >&5 -$as_echo "$as_me: WARNING: Ogg Vorbis support disabled" >&2;} - fi - fi - LIBS="$LIBS_SAVED" -fi - -libflac_ver=8 -# Check whether --enable-music-flac was given. -if test "${enable_music_flac+set}" = set; then : - enableval=$enable_music_flac; -else - enable_music_flac=yes -fi - -# Check whether --enable-music-flac-shared was given. -if test "${enable_music_flac_shared+set}" = set; then : - enableval=$enable_music_flac_shared; -else - enable_music_flac_shared=yes -fi - -if test x$enable_music_flac = xyes; then - ac_fn_c_check_header_mongrel "$LINENO" "FLAC/export.h" "ac_cv_header_FLAC_export_h" "$ac_includes_default" -if test "x$ac_cv_header_FLAC_export_h" = xyes; then : - have_flac_export=yes -fi - - - if test x$have_flac_export = xyes; then - LIBS_SAVED="$LIBS" - LIBS="-lFLAC" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libflac so-name version >= $libflac_ver" >&5 -$as_echo_n "checking for libflac so-name version >= $libflac_ver... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include "FLAC/export.h" -#include "stdio.h" - -int -main () -{ - -#if defined(FLAC_API_VERSION_CURRENT) && (FLAC_API_VERSION_CURRENT >= $libflac_ver) -#else -#error "old-flac" -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - have_flac_ver=yes -else - have_flac_ver=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - LIBS="$LIBS_SAVED" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_flac_ver" >&5 -$as_echo "$have_flac_ver" >&6; } - fi - - if test x$have_flac_ver = xyes; then - ac_fn_c_check_header_mongrel "$LINENO" "FLAC/stream_decoder.h" "ac_cv_header_FLAC_stream_decoder_h" "$ac_includes_default" -if test "x$ac_cv_header_FLAC_stream_decoder_h" = xyes; then : - have_flac_hdr=yes -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FLAC__stream_decoder_new in -lFLAC" >&5 -$as_echo_n "checking for FLAC__stream_decoder_new in -lFLAC... " >&6; } -if ${ac_cv_lib_FLAC_FLAC__stream_decoder_new+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lFLAC $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char FLAC__stream_decoder_new (); -int -main () -{ -return FLAC__stream_decoder_new (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_FLAC_FLAC__stream_decoder_new=yes -else - ac_cv_lib_FLAC_FLAC__stream_decoder_new=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_FLAC_FLAC__stream_decoder_new" >&5 -$as_echo "$ac_cv_lib_FLAC_FLAC__stream_decoder_new" >&6; } -if test "x$ac_cv_lib_FLAC_FLAC__stream_decoder_new" = xyes; then : - have_flac_lib=yes -fi - - if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then - case "$host" in - *-*-darwin*) - flac_lib=`find_lib libFLAC.dylib` - ;; - *-*-cygwin* | *-*-mingw32*) - flac_lib=`find_lib "libFLAC-*.dll"` - ;; - *) - flac_lib=`find_lib "libFLAC[0-9]*.so.*"` - if test x$flac_lib = x; then - flac_lib=`find_lib "libFLAC.so.*"` - fi - ;; - esac - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_FLAC" - if test x$enable_music_flac_shared = xyes && test x$flac_lib != x; then - echo "-- dynamic libFLAC -> $flac_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_DYNAMIC=\\\"$flac_lib\\\"" - else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lFLAC" - fi - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find FLAC library (http://flac.sourceforge.net/)" >&5 -$as_echo "$as_me: WARNING: *** Unable to find FLAC library (http://flac.sourceforge.net/)" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: FLAC support disabled" >&5 -$as_echo "$as_me: WARNING: FLAC support disabled" >&2;} - fi -fi - -# Check whether --enable-music-mp3 was given. -if test "${enable_music_mp3+set}" = set; then : - enableval=$enable_music_mp3; -else - enable_music_mp3=yes -fi - - -# Check whether --enable-music-mp3-mad-gpl was given. -if test "${enable_music_mp3_mad_gpl+set}" = set; then : - enableval=$enable_music_mp3_mad_gpl; -else - enable_music_mp3_mad_gpl=no -fi - -# Check whether --enable-music-mp3-mad-gpl-dithering was given. -if test "${enable_music_mp3_mad_gpl_dithering+set}" = set; then : - enableval=$enable_music_mp3_mad_gpl_dithering; -else - enable_music_mp3_mad_gpl_dithering=yes -fi - -if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_mad_gpl = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libmad headers" >&5 -$as_echo_n "checking for libmad headers... " >&6; } - have_libmad=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #include "mad.h" - -int -main () -{ - - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - have_libmad=yes - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_libmad" >&5 -$as_echo "$have_libmad" >&6; } - if test x$have_libmad = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD" - if test x$enable_music_mp3_mad_gpl_dithering = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Using GPL libmad and MP3 dithering routines, this build of SDL_mixer is now under the GPL" >&5 -$as_echo "$as_me: WARNING: *** Using GPL libmad and MP3 dithering routines, this build of SDL_mixer is now under the GPL" >&2;} - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD_GPL_DITHERING" - fi - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find MAD library (http://www.underbit.com/products/mad/)" >&5 -$as_echo "$as_me: WARNING: *** Unable to find MAD library (http://www.underbit.com/products/mad/)" >&2;} - fi -fi - -# Check whether --enable-music-mp3-mpg123 was given. -if test "${enable_music_mp3_mpg123+set}" = set; then : - enableval=$enable_music_mp3_mpg123; -else - enable_music_mp3_mpg123=yes -fi - -# Check whether --enable-music-mp3-mpg123-shared was given. -if test "${enable_music_mp3_mpg123_shared+set}" = set; then : - enableval=$enable_music_mp3_mpg123_shared; -else - enable_music_mp3_mpg123_shared=yes -fi - -if test x$enable_music_mp3_mpg123 = xyes; then - ac_fn_c_check_header_mongrel "$LINENO" "mpg123.h" "ac_cv_header_mpg123_h" "$ac_includes_default" -if test "x$ac_cv_header_mpg123_h" = xyes; then : - have_mpg123_hdr=yes -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mpg123_replace_reader_handle in -lmpg123" >&5 -$as_echo_n "checking for mpg123_replace_reader_handle in -lmpg123... " >&6; } -if ${ac_cv_lib_mpg123_mpg123_replace_reader_handle+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lmpg123 $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char mpg123_replace_reader_handle (); -int -main () -{ -return mpg123_replace_reader_handle (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_mpg123_mpg123_replace_reader_handle=yes -else - ac_cv_lib_mpg123_mpg123_replace_reader_handle=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mpg123_mpg123_replace_reader_handle" >&5 -$as_echo "$ac_cv_lib_mpg123_mpg123_replace_reader_handle" >&6; } -if test "x$ac_cv_lib_mpg123_mpg123_replace_reader_handle" = xyes; then : - have_mpg123_lib=yes -fi - - if test x$have_mpg123_hdr = xyes -a x$have_mpg123_lib = xyes; then - have_libmpg123=yes - case "$host" in - *-*-darwin*) - mpg123_lib=`find_lib libmpg123.dylib` - ;; - *-*-cygwin* | *-*-mingw32*) - mpg123_lib=`find_lib "libmpg123*.dll"` - ;; - *) - mpg123_lib=`find_lib "libmpg123.so.*"` - ;; - esac - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MPG123" - if test x$enable_music_mp3_mpg123_shared = xyes && test x$mpg123_lib != x; then - echo "-- dynamic libmpg123 -> $mpg123_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMPG123_DYNAMIC=\\\"$mpg123_lib\\\"" - else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmpg123" - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find mpg123 library (https://www.mpg123.de)" >&5 -$as_echo "$as_me: WARNING: *** Unable to find mpg123 library (https://www.mpg123.de)" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: mpg123 support disabled" >&5 -$as_echo "$as_me: WARNING: mpg123 support disabled" >&2;} - fi -fi - -if test x$have_libmad = xyes -o x$have_libmpg123 = xyes; then - : -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MP3 support disabled" >&5 -$as_echo "$as_me: WARNING: MP3 support disabled" >&2;} -fi - -# Check whether --enable-music-opus was given. -if test "${enable_music_opus+set}" = set; then : - enableval=$enable_music_opus; -else - enable_music_opus=yes -fi - - -# Check whether --enable-music-opus-shared was given. -if test "${enable_music_opus_shared+set}" = set; then : - enableval=$enable_music_opus_shared; -else - enable_music_opus_shared=yes -fi - -if test x$enable_music_opus = xyes; then - LIBS_SAVED="$LIBS" - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OPUSFILE" >&5 -$as_echo_n "checking for OPUSFILE... " >&6; } - -if test -n "$PKG_CONFIG"; then - if test -n "$OPUSFILE_CFLAGS"; then - pkg_cv_OPUSFILE_CFLAGS="$OPUSFILE_CFLAGS" - else - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"opusfile >= 0.2\""; } >&5 - ($PKG_CONFIG --exists --print-errors "opusfile >= 0.2") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_OPUSFILE_CFLAGS=`$PKG_CONFIG --cflags "opusfile >= 0.2" 2>/dev/null` -else - pkg_failed=yes -fi - fi -else - pkg_failed=untried -fi -if test -n "$PKG_CONFIG"; then - if test -n "$OPUSFILE_LIBS"; then - pkg_cv_OPUSFILE_LIBS="$OPUSFILE_LIBS" - else - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"opusfile >= 0.2\""; } >&5 - ($PKG_CONFIG --exists --print-errors "opusfile >= 0.2") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_OPUSFILE_LIBS=`$PKG_CONFIG --libs "opusfile >= 0.2" 2>/dev/null` -else - pkg_failed=yes -fi - fi -else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - OPUSFILE_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "opusfile >= 0.2"` - else - OPUSFILE_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "opusfile >= 0.2"` - fi - # Put the nasty error message in config.log where it belongs - echo "$OPUSFILE_PKG_ERRORS" >&5 - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ac_fn_c_check_header_mongrel "$LINENO" "opus/opusfile.h" "ac_cv_header_opus_opusfile_h" "$ac_includes_default" -if test "x$ac_cv_header_opus_opusfile_h" = xyes; then : - have_opusfile_hdr=yes -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for op_open_callbacks in -lopusfile" >&5 -$as_echo_n "checking for op_open_callbacks in -lopusfile... " >&6; } -if ${ac_cv_lib_opusfile_op_open_callbacks+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lopusfile -lopus -logg -lm $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char op_open_callbacks (); -int -main () -{ -return op_open_callbacks (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_opusfile_op_open_callbacks=yes -else - ac_cv_lib_opusfile_op_open_callbacks=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_opusfile_op_open_callbacks" >&5 -$as_echo "$ac_cv_lib_opusfile_op_open_callbacks" >&6; } -if test "x$ac_cv_lib_opusfile_op_open_callbacks" = xyes; then : - have_opusfile_lib=yes;OPUSFILE_LIBS="-lopusfile -lopus" -fi - - -elif test $pkg_failed = untried; then - ac_fn_c_check_header_mongrel "$LINENO" "opus/opusfile.h" "ac_cv_header_opus_opusfile_h" "$ac_includes_default" -if test "x$ac_cv_header_opus_opusfile_h" = xyes; then : - have_opusfile_hdr=yes -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for op_open_callbacks in -lopusfile" >&5 -$as_echo_n "checking for op_open_callbacks in -lopusfile... " >&6; } -if ${ac_cv_lib_opusfile_op_open_callbacks+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lopusfile -lopus -logg -lm $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char op_open_callbacks (); -int -main () -{ -return op_open_callbacks (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_opusfile_op_open_callbacks=yes -else - ac_cv_lib_opusfile_op_open_callbacks=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_opusfile_op_open_callbacks" >&5 -$as_echo "$ac_cv_lib_opusfile_op_open_callbacks" >&6; } -if test "x$ac_cv_lib_opusfile_op_open_callbacks" = xyes; then : - have_opusfile_lib=yes;OPUSFILE_LIBS="-lopusfile -lopus" -fi - - -else - OPUSFILE_CFLAGS=$pkg_cv_OPUSFILE_CFLAGS - OPUSFILE_LIBS=$pkg_cv_OPUSFILE_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - have_opusfile_hdr=yes - have_opusfile_lib=yes - -fi - LIBS="$LIBS_SAVED" - - if test x$have_opusfile_hdr = xyes -a x$have_opusfile_lib = xyes; then - have_opusfile=yes - case "$host" in - *-*-darwin*) - opusfile_lib=`find_lib libopusfile.dylib` - ;; - *-*-cygwin* | *-*-mingw32*) - opusfile_lib=`find_lib "libopusfile*.dll"` - ;; - *) - opusfile_lib=`find_lib "libopusfile[0-9]*.so.*"` - if test x$opusfile_lib = x; then - opusfile_lib=`find_lib "libopusfile.so.*"` - fi - ;; - esac - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OPUS $OPUSFILE_CFLAGS" - if test x$enable_music_opus_shared = xyes && test x$opusfile_lib != x; then - echo "-- dynamic opusfile -> $opusfile_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DOPUS_DYNAMIC=\\\"$opusfile_lib\\\"" - else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS $OPUSFILE_LIBS" - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find opusfile library (http://opus-codec.org/)" >&5 -$as_echo "$as_me: WARNING: *** Unable to find opusfile library (http://opus-codec.org/)" >&2;} - fi -fi - -EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBM" - -OBJECTS=`echo $SOURCES` -DEPENDS=`echo $SOURCES` -OBJECTS=`echo "$OBJECTS" | sed 's,[^ ]*/\([^ ]*\)\.c,$(objects)/\1.lo,g'` -DEPENDS=`echo "$DEPENDS" | sed 's,\([^ ]*\)/\([^ ]*\)\.c,\\ -$(objects)/\2.lo: \1/\2.c\\ - \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'` - -OBJECTS_CXX=`echo $SOURCES_CXX` -DEPENDS_CXX=`echo $SOURCES_CXX` -OBJECTS_CXX=`echo "$OBJECTS_CXX" | sed 's,[^ ]*/\([^ ]*\)\.cpp,$(objects)/\1.lo,g'` -DEPENDS_CXX=`echo "$DEPENDS_CXX" | sed 's,\([^ ]*\)/\([^ ]*\)\.cpp,\\ -$(objects)/\2.lo: \1/\2.cpp\\ - \$(LIBTOOL) --mode=compile \$(CXX) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'` -OBJECTS="$OBJECTS $OBJECTS_CXX" -DEPENDS="$DEPENDS $DEPENDS_CXX" -DEPENDS=`echo "$DEPENDS" | sed 's,\\$,\\\\$,g'` - -VERSION_OBJECTS=`echo $VERSION_SOURCES` -VERSION_DEPENDS=`echo $VERSION_SOURCES` -VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[^ ]*/\([^ ]*\)\.rc,$(objects)/\1.o,g'` -VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\([^ ]*\)/\([^ ]*\)\.rc,\\ -$(objects)/\2.o: \1/\2.rc\\ - \$(WINDRES) \$< \$@,g'` -VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\\$,\\\\$,g'` - -PLAYWAVE_SOURCES="$srcdir/playwave.c" -PLAYWAVE_OBJECTS=`echo $PLAYWAVE_SOURCES` -PLAYWAVE_DEPENDS=`echo $PLAYWAVE_SOURCES` -PLAYWAVE_OBJECTS=`echo "$PLAYWAVE_OBJECTS" | sed 's,[^ ]*/\([^ ]*\)\.c,$(objects)/\1.lo,g'` -PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\([^ ]*\)/\([^ ]*\)\.c,\\ -$(objects)/\2.lo: \1/\2.c\\ - \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'` -PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\\$,\\\\$,g'` - -PLAYMUS_SOURCES="$srcdir/playmus.c" -PLAYMUS_OBJECTS=`echo $PLAYMUS_SOURCES` -PLAYMUS_DEPENDS=`echo $PLAYMUS_SOURCES` -PLAYMUS_OBJECTS=`echo "$PLAYMUS_OBJECTS" | sed 's,[^ ]*/\([^ ]*\)\.c,$(objects)/\1.lo,g'` -PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\([^ ]*\)/\([^ ]*\)\.c,\\ -$(objects)/\2.lo: \1/\2.c\\ - \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'` -PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\\$,\\\\$,g'` - - - - - - - - - - - - - - - - -ac_config_files="$ac_config_files " - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes: double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \. - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - if test "x$cache_file" != "x/dev/null"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 -$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -# -# If the first sed substitution is executed (which looks for macros that -# take arguments), then branch to the quote section. Otherwise, -# look for a macro that doesn't take arguments. -ac_script=' -:mline -/\\$/{ - N - s,\\\n,, - b mline -} -t clear -:clear -s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g -t quote -s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g -t quote -b any -:quote -s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g -s/\[/\\&/g -s/\]/\\&/g -s/\$/$$/g -H -:any -${ - g - s/^\n// - s/\n/ /g - p -} -' -DEFS=`sed -n "$ac_script" confdefs.h` - - -ac_libobjs= -ac_ltlibobjs= -U= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`$as_echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" - as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - - -: "${CONFIG_STATUS=./config.status}" -ac_write_fail=0 -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -as_write_fail=0 -cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false - -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 -## ----------------------------------- ## -## Main body of $CONFIG_STATUS script. ## -## ----------------------------------- ## -_ASEOF -test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# Save the log message, to keep $0 and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by $as_me, which was -generated by GNU Autoconf 2.69. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -case $ac_config_files in *" -"*) set x $ac_config_files; shift; ac_config_files=$*;; -esac - - - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# Files that config.status was made for. -config_files="$ac_config_files" -config_commands="$ac_config_commands" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -ac_cs_usage="\ -\`$as_me' instantiates files and other configuration actions -from templates according to the current configuration. Unless the files -and actions are specified as TAGs, all are instantiated by default. - -Usage: $0 [OPTION]... [TAG]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - --config print configuration, then exit - -q, --quiet, --silent - do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - -Configuration files: -$config_files - -Configuration commands: -$config_commands - -Report bugs to the package provider." - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" -ac_cs_version="\\ -config.status -configured by $0, generated by GNU Autoconf 2.69, - with options \\"\$ac_cs_config\\" - -Copyright (C) 2012 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -INSTALL='$INSTALL' -test -n "\$AWK" || AWK=awk -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# The default lists apply if the user does not specify any file. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=?*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - --*=) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg= - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - $as_echo "$ac_cs_version"; exit ;; - --config | --confi | --conf | --con | --co | --c ) - $as_echo "$ac_cs_config"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - '') as_fn_error $? "missing file argument" ;; - esac - as_fn_append CONFIG_FILES " '$ac_optarg'" - ac_need_defaults=false;; - --he | --h | --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) as_fn_error $? "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; - - *) as_fn_append ac_config_targets " $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -if \$ac_cs_recheck; then - set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion - shift - \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 - CONFIG_SHELL='$SHELL' - export CONFIG_SHELL - exec "\$@" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - $as_echo "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# -# INIT-COMMANDS -# - - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -sed_quote_subst='$sed_quote_subst' -double_quote_subst='$double_quote_subst' -delay_variable_subst='$delay_variable_subst' -macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`' -macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`' -AS='`$ECHO "X$AS" | $Xsed -e "$delay_single_quote_subst"`' -DLLTOOL='`$ECHO "X$DLLTOOL" | $Xsed -e "$delay_single_quote_subst"`' -OBJDUMP='`$ECHO "X$OBJDUMP" | $Xsed -e "$delay_single_quote_subst"`' -enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`' -enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`' -pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`' -enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`' -host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`' -host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`' -host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`' -build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`' -build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`' -build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`' -SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`' -Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`' -GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`' -EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`' -FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`' -LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`' -NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`' -LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`' -max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`' -ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`' -exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`' -lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`' -lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`' -lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`' -reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`' -reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`' -deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`' -file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`' -AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`' -AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`' -STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`' -RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`' -old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' -old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' -old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' -CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`' -CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`' -compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`' -GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' -objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`' -SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`' -ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`' -MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`' -lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`' -lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`' -lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`' -lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`' -need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`' -DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`' -NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`' -LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`' -OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`' -OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`' -libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`' -shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`' -extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' -archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`' -enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`' -export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' -whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' -compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`' -old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`' -old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' -archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' -archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' -module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`' -module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' -with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`' -allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' -no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`' -inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`' -link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`' -fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`' -always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`' -export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`' -exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`' -include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`' -prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`' -file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`' -variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`' -need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' -need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`' -version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`' -runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`' -shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' -shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`' -libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`' -library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`' -soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`' -postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' -postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' -finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`' -finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`' -sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`' -sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`' -enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`' -enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`' -enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`' -old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`' -striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`' - -LTCC='$LTCC' -LTCFLAGS='$LTCFLAGS' -compiler='$compiler_DEFAULT' - -# Quote evaled strings. -for var in SED \ -GREP \ -EGREP \ -FGREP \ -LD \ -NM \ -LN_S \ -lt_SP2NL \ -lt_NL2SP \ -reload_flag \ -deplibs_check_method \ -file_magic_cmd \ -AR \ -AR_FLAGS \ -STRIP \ -RANLIB \ -CC \ -CFLAGS \ -compiler \ -lt_cv_sys_global_symbol_pipe \ -lt_cv_sys_global_symbol_to_cdecl \ -lt_cv_sys_global_symbol_to_c_name_address \ -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ -SHELL \ -ECHO \ -lt_prog_compiler_no_builtin_flag \ -lt_prog_compiler_wl \ -lt_prog_compiler_pic \ -lt_prog_compiler_static \ -lt_cv_prog_compiler_c_o \ -need_locks \ -DSYMUTIL \ -NMEDIT \ -LIPO \ -OTOOL \ -OTOOL64 \ -shrext_cmds \ -export_dynamic_flag_spec \ -whole_archive_flag_spec \ -compiler_needs_object \ -with_gnu_ld \ -allow_undefined_flag \ -no_undefined_flag \ -hardcode_libdir_flag_spec \ -hardcode_libdir_flag_spec_ld \ -hardcode_libdir_separator \ -fix_srcfile_path \ -exclude_expsyms \ -include_expsyms \ -file_list_spec \ -variables_saved_for_relink \ -libname_spec \ -library_names_spec \ -soname_spec \ -finish_eval \ -old_striplib \ -striplib; do - case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in - *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Double-quote double-evaled strings. -for var in reload_cmds \ -old_postinstall_cmds \ -old_postuninstall_cmds \ -old_archive_cmds \ -extract_expsyms_cmds \ -old_archive_from_new_cmds \ -old_archive_from_expsyms_cmds \ -archive_cmds \ -archive_expsym_cmds \ -module_cmds \ -module_expsym_cmds \ -export_symbols_cmds \ -prelink_cmds \ -postinstall_cmds \ -postuninstall_cmds \ -finish_cmds \ -sys_lib_search_path_spec \ -sys_lib_dlsearch_path_spec; do - case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in - *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Fix-up fallback echo if it was mangled by the above quoting rules. -case \$lt_ECHO in -*'\\\$0 --fallback-echo"') lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\` - ;; -esac - -ac_aux_dir='$ac_aux_dir' -xsi_shell='$xsi_shell' -lt_shell_append='$lt_shell_append' - -# See if we are running on zsh, and set the options which allow our -# commands through without removal of \ escapes INIT. -if test -n "\${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi - - - PACKAGE='$PACKAGE' - VERSION='$VERSION' - TIMESTAMP='$TIMESTAMP' - RM='$RM' - ofile='$ofile' - - - - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; - - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= ac_tmp= - trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status -' 0 - trap 'as_fn_exit 1' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp - -# Set up the scripts for CONFIG_FILES section. -# No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. -if test -n "$CONFIG_FILES"; then - - -ac_cr=`echo X | tr X '\015'` -# On cygwin, bash can eat \r inside `` if the user requested igncr. -# But we know of no other shell where ac_cr would be empty at this -# point, so we can use a bashism as a fallback. -if test "x$ac_cr" = x; then - eval ac_cr=\$\'\\r\' -fi -ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` -if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' -else - ac_cs_awk_cr=$ac_cr -fi - -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && -_ACEOF - - -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - . ./conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` - if test $ac_delim_n = $ac_delim_num; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done -rm -f conf$$subs.sh - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && -_ACEOF -sed -n ' -h -s/^/S["/; s/!.*/"]=/ -p -g -s/^[^!]*!// -:repl -t repl -s/'"$ac_delim"'$// -t delim -:nl -h -s/\(.\{148\}\)..*/\1/ -t more1 -s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ -p -n -b repl -:more1 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t nl -:delim -h -s/\(.\{148\}\)..*/\1/ -t more2 -s/["\\]/\\&/g; s/^/"/; s/$/"/ -p -b -:more2 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t delim -' >$CONFIG_STATUS || ac_write_fail=1 -rm -f conf$$subs.awk -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACAWK -cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" - -} -{ - line = $ 0 - nfields = split(line, field, "@") - substed = 0 - len = length(field[1]) - for (i = 2; i < nfields; i++) { - key = field[i] - keylen = length(key) - if (S_is_set[key]) { - value = S[key] - line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) - len += length(value) + length(field[++i]) - substed = 1 - } else - len += 1 + keylen - } - - print line -} - -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" -else - cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ - || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 -_ACEOF - -# VPATH may cause trouble with some makes, so we remove sole $(srcdir), -# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ -h -s/// -s/^/:/ -s/[ ]*$/:/ -s/:\$(srcdir):/:/g -s/:\${srcdir}:/:/g -s/:@srcdir@:/:/g -s/^:*// -s/:*$// -x -s/\(=[ ]*\).*/\1/ -G -s/\n// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -fi # test -n "$CONFIG_FILES" - - -eval set X " :F $CONFIG_FILES :C $CONFIG_COMMANDS" -shift -for ac_tag -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$ac_tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append ac_file_inputs " '$ac_f'" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input='Generated from '` - $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' - `' by configure.' - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} - fi - # Neutralize special characters interpreted by sed in replacement strings. - case $configure_input in #( - *\&* | *\|* | *\\* ) - ac_sed_conf_input=`$as_echo "$configure_input" | - sed 's/[\\\\&|]/\\\\&/g'`;; #( - *) ac_sed_conf_input=$configure_input;; - esac - - case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir="$ac_dir"; as_fn_mkdir_p - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - - case $INSTALL in - [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; - esac -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= -ac_sed_dataroot=' -/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac -_ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_sed_extra="$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@top_build_prefix@&$ac_top_build_prefix&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -s&@INSTALL@&$ac_INSTALL&;t t -$ac_datarootdir_hack -" -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&5 -$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&2;} - - rm -f "$ac_tmp/stdin" - case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; - esac \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - ;; - - - :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 -$as_echo "$as_me: executing $ac_file commands" >&6;} - ;; - esac - - - case $ac_file$ac_mode in - "libtool":C) - - # See if we are running on zsh, and set the options which allow our - # commands through without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST - fi - - cfgfile="${ofile}T" - trap "$RM \"$cfgfile\"; exit 1" 1 2 15 - $RM "$cfgfile" - - cat <<_LT_EOF >> "$cfgfile" -#! $SHELL - -# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008 Free Software Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is part of GNU Libtool. -# -# GNU Libtool is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, or -# obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - -# The names of the tagged configurations supported by this script. -available_tags="" - -# ### BEGIN LIBTOOL CONFIG - -# Which release of libtool.m4 was used? -macro_version=$macro_version -macro_revision=$macro_revision - -# Assembler program. -AS=$AS - -# DLL creation program. -DLLTOOL=$DLLTOOL - -# Object dumper program. -OBJDUMP=$OBJDUMP - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# What type of objects to build. -pic_mode=$pic_mode - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host -host_os=$host_os - -# The build system. -build_alias=$build_alias -build=$build -build_os=$build_os - -# A sed program that does not truncate output. -SED=$lt_SED - -# Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="\$SED -e 1s/^X//" - -# A grep program that handles long lines. -GREP=$lt_GREP - -# An ERE matcher. -EGREP=$lt_EGREP - -# A literal string matcher. -FGREP=$lt_FGREP - -# A BSD- or MS-compatible name lister. -NM=$lt_NM - -# Whether we need soft or hard links. -LN_S=$lt_LN_S - -# What is the maximum length of a command? -max_cmd_len=$max_cmd_len - -# Object file suffix (normally "o"). -objext=$ac_objext - -# Executable file suffix (normally ""). -exeext=$exeext - -# whether the shell understands "unset". -lt_unset=$lt_unset - -# turn spaces into newlines. -SP2NL=$lt_lt_SP2NL - -# turn newlines into spaces. -NL2SP=$lt_lt_NL2SP - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# Method to check whether dependent libraries are shared objects. -deplibs_check_method=$lt_deplibs_check_method - -# Command to use when deplibs_check_method == "file_magic". -file_magic_cmd=$lt_file_magic_cmd - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# A symbol stripping program. -STRIP=$lt_STRIP - -# Commands used to install an old-style archive. -RANLIB=$lt_RANLIB -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# A C compiler. -LTCC=$lt_CC - -# LTCC compiler flags. -LTCFLAGS=$lt_CFLAGS - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe - -# Transform the output of nm in a proper C declaration. -global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl - -# Transform the output of nm in a C name address pair. -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# Transform the output of nm in a C name address pair when lib prefix is needed. -global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# An echo program that does not interpret backslashes. -ECHO=$lt_ECHO - -# Used to examine libraries when file_magic_cmd begins with "file". -MAGIC_CMD=$MAGIC_CMD - -# Must we lock files when doing compilation? -need_locks=$lt_need_locks - -# Tool to manipulate archived DWARF debug symbol files on Mac OS X. -DSYMUTIL=$lt_DSYMUTIL - -# Tool to change global to local symbols on Mac OS X. -NMEDIT=$lt_NMEDIT - -# Tool to manipulate fat objects and archives on Mac OS X. -LIPO=$lt_LIPO - -# ldd/readelf like tool for Mach-O binaries on Mac OS X. -OTOOL=$lt_OTOOL - -# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. -OTOOL64=$lt_OTOOL64 - -# Old archive suffix (normally "a"). -libext=$libext - -# Shared library suffix (normally ".so"). -shrext_cmds=$lt_shrext_cmds - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at link time. -variables_saved_for_relink=$lt_variables_saved_for_relink - -# Do we need the "lib" prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Library versioning type. -version_type=$version_type - -# Shared library runtime path variable. -runpath_var=$runpath_var - -# Shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Command to use after installation of a shared archive. -postinstall_cmds=$lt_postinstall_cmds - -# Command to use after uninstallation of a shared archive. -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# As "finish_cmds", except a single script fragment to be evaled but -# not shown. -finish_eval=$lt_finish_eval - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Compile-time system search path for libraries. -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec - -# Run-time system search path for libraries. -sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - - -# The linker used to build libraries. -LD=$lt_LD - -# Commands used to build an old-style archive. -old_archive_cmds=$lt_old_archive_cmds - -# A language specific compiler. -CC=$lt_compiler - -# Is the compiler the GNU compiler? -with_gcc=$GCC - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_lt_prog_compiler_static - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_lt_cv_prog_compiler_c_o - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$archive_cmds_need_lc - -# Whether or not to disallow shared libs when runtime libs are static. -allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec - -# Whether the compiler copes with passing no objects directly. -compiler_needs_object=$lt_compiler_needs_object - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds - -# Commands used to build a shared archive. -archive_cmds=$lt_archive_cmds -archive_expsym_cmds=$lt_archive_expsym_cmds - -# Commands used to build a loadable module if different from building -# a shared archive. -module_cmds=$lt_module_cmds -module_expsym_cmds=$lt_module_expsym_cmds - -# Whether we are building with GNU ld or not. -with_gnu_ld=$lt_with_gnu_ld - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag - -# Flag that enforces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec - -# If ld is used when linking, flag to hardcode \$libdir into a binary -# during linking. This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld - -# Whether we need a single "-rpath" flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator - -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes -# DIR into the resulting binary. -hardcode_direct=$hardcode_direct - -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes -# DIR into the resulting binary and the resulting library dependency is -# "absolute",i.e impossible to change by setting \${shlibpath_var} if the -# library is relocated. -hardcode_direct_absolute=$hardcode_direct_absolute - -# Set to "yes" if using the -LDIR flag during linking hardcodes DIR -# into the resulting binary. -hardcode_minus_L=$hardcode_minus_L - -# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR -# into the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var - -# Set to "yes" if building a shared library automatically hardcodes DIR -# into the library and all subsequent libraries and executables linked -# against it. -hardcode_automatic=$hardcode_automatic - -# Set to yes if linker adds runtime paths of dependent libraries -# to runtime path list. -inherit_rpath=$inherit_rpath - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path=$lt_fix_srcfile_path - -# Set to "yes" if exported symbols are required. -always_export_symbols=$always_export_symbols - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms - -# Commands necessary for linking programs (against libraries) with templates. -prelink_cmds=$lt_prelink_cmds - -# Specify filename containing input files. -file_list_spec=$lt_file_list_spec - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action - -# ### END LIBTOOL CONFIG - -_LT_EOF - - case $host_os in - aix3*) - cat <<\_LT_EOF >> "$cfgfile" -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES -fi -_LT_EOF - ;; - esac - - -ltmain="$ac_aux_dir/ltmain.sh" - - - # We use sed instead of cat because bash on DJGPP gets confused if - # if finds mixed CR/LF and LF-only lines. Since sed operates in - # text mode, it properly converts lines to CR/LF. This bash problem - # is reportedly fixed, but why not run on old versions too? - sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - case $xsi_shell in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac -} - -# func_basename file -func_basename () -{ - func_basename_result="${1##*/}" -} - -# func_dirname_and_basename file append nondir_replacement -# perform func_basename and func_dirname in a single function -# call: -# dirname: Compute the dirname of FILE. If nonempty, -# add APPEND to the result, otherwise set result -# to NONDIR_REPLACEMENT. -# value returned in "$func_dirname_result" -# basename: Compute filename of FILE. -# value retuned in "$func_basename_result" -# Implementation must be kept synchronized with func_dirname -# and func_basename. For efficiency, we do not delegate to -# those functions but instead duplicate the functionality here. -func_dirname_and_basename () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac - func_basename_result="${1##*/}" -} - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -func_stripname () -{ - # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are - # positional parameters, so assign one to ordinary parameter first. - func_stripname_result=${3} - func_stripname_result=${func_stripname_result#"${1}"} - func_stripname_result=${func_stripname_result%"${2}"} -} - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=${1%%=*} - func_opt_split_arg=${1#*=} -} - -# func_lo2o object -func_lo2o () -{ - case ${1} in - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; - *) func_lo2o_result=${1} ;; - esac -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=${1%.*}.lo -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=$(( $* )) -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=${#1} -} - -_LT_EOF - ;; - *) # Bourne compatible functions. - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi -} - -# func_basename file -func_basename () -{ - func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` -} - - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# func_strip_suffix prefix name -func_stripname () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "X${3}" \ - | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "X${3}" \ - | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; - esac -} - -# sed scripts: -my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q' -my_sed_long_arg='1s/^-[^=]*=//' - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` - func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` -} - -# func_lo2o object -func_lo2o () -{ - func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'` -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=`expr "$@"` -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` -} - -_LT_EOF -esac - -case $lt_shell_append in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$1+=\$2" -} -_LT_EOF - ;; - *) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$1=\$$1\$2" -} - -_LT_EOF - ;; - esac - - - sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - mv -f "$cfgfile" "$ofile" || - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" - - ;; - - esac -done # for ac_tag - - -as_fn_exit 0 -_ACEOF -ac_clean_files=$ac_clean_files_save - -test $ac_write_fail = 0 || - as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit 1 -fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} -fi - -ac_config_files="$ac_config_files Makefile SDL2_mixer.spec SDL2_mixer.pc" - -ac_config_commands="$ac_config_commands default" - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes: double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \. - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - if test "x$cache_file" != "x/dev/null"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 -$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -# -# If the first sed substitution is executed (which looks for macros that -# take arguments), then branch to the quote section. Otherwise, -# look for a macro that doesn't take arguments. -ac_script=' -:mline -/\\$/{ - N - s,\\\n,, - b mline -} -t clear -:clear -s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g -t quote -s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g -t quote -b any -:quote -s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g -s/\[/\\&/g -s/\]/\\&/g -s/\$/$$/g -H -:any -${ - g - s/^\n// - s/\n/ /g - p -} -' -DEFS=`sed -n "$ac_script" confdefs.h` - - -ac_libobjs= -ac_ltlibobjs= -U= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`$as_echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" - as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - - -: "${CONFIG_STATUS=./config.status}" -ac_write_fail=0 -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -as_write_fail=0 -cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false - -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 -## ----------------------------------- ## -## Main body of $CONFIG_STATUS script. ## -## ----------------------------------- ## -_ASEOF -test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# Save the log message, to keep $0 and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by $as_me, which was -generated by GNU Autoconf 2.69. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -case $ac_config_files in *" -"*) set x $ac_config_files; shift; ac_config_files=$*;; -esac - - - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# Files that config.status was made for. -config_files="$ac_config_files" -config_commands="$ac_config_commands" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -ac_cs_usage="\ -\`$as_me' instantiates files and other configuration actions -from templates according to the current configuration. Unless the files -and actions are specified as TAGs, all are instantiated by default. - -Usage: $0 [OPTION]... [TAG]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - --config print configuration, then exit - -q, --quiet, --silent - do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - -Configuration files: -$config_files - -Configuration commands: -$config_commands - -Report bugs to the package provider." - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" -ac_cs_version="\\ -config.status -configured by $0, generated by GNU Autoconf 2.69, - with options \\"\$ac_cs_config\\" - -Copyright (C) 2012 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -INSTALL='$INSTALL' -test -n "\$AWK" || AWK=awk -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# The default lists apply if the user does not specify any file. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=?*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - --*=) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg= - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - $as_echo "$ac_cs_version"; exit ;; - --config | --confi | --conf | --con | --co | --c ) - $as_echo "$ac_cs_config"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - '') as_fn_error $? "missing file argument" ;; - esac - as_fn_append CONFIG_FILES " '$ac_optarg'" - ac_need_defaults=false;; - --he | --h | --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) as_fn_error $? "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; - - *) as_fn_append ac_config_targets " $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -if \$ac_cs_recheck; then - set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion - shift - \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 - CONFIG_SHELL='$SHELL' - export CONFIG_SHELL - exec "\$@" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - $as_echo "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# -# INIT-COMMANDS -# - - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -sed_quote_subst='$sed_quote_subst' -double_quote_subst='$double_quote_subst' -delay_variable_subst='$delay_variable_subst' -macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`' -macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`' -AS='`$ECHO "X$AS" | $Xsed -e "$delay_single_quote_subst"`' -DLLTOOL='`$ECHO "X$DLLTOOL" | $Xsed -e "$delay_single_quote_subst"`' -OBJDUMP='`$ECHO "X$OBJDUMP" | $Xsed -e "$delay_single_quote_subst"`' -enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`' -enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`' -pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`' -enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`' -host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`' -host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`' -host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`' -build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`' -build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`' -build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`' -SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`' -Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`' -GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`' -EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`' -FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`' -LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`' -NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`' -LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`' -max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`' -ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`' -exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`' -lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`' -lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`' -lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`' -reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`' -reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`' -deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`' -file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`' -AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`' -AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`' -STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`' -RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`' -old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' -old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' -old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' -CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`' -CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`' -compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`' -GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' -objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`' -SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`' -ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`' -MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`' -lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`' -lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`' -lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`' -lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`' -need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`' -DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`' -NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`' -LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`' -OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`' -OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`' -libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`' -shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`' -extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' -archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`' -enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`' -export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' -whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' -compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`' -old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`' -old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' -archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' -archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' -module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`' -module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' -with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`' -allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' -no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`' -inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`' -link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`' -fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`' -always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`' -export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`' -exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`' -include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`' -prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`' -file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`' -variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`' -need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' -need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`' -version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`' -runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`' -shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' -shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`' -libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`' -library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`' -soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`' -postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' -postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' -finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`' -finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`' -sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`' -sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`' -enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`' -enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`' -enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`' -old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`' -striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`' - -LTCC='$LTCC' -LTCFLAGS='$LTCFLAGS' -compiler='$compiler_DEFAULT' - -# Quote evaled strings. -for var in SED \ -GREP \ -EGREP \ -FGREP \ -LD \ -NM \ -LN_S \ -lt_SP2NL \ -lt_NL2SP \ -reload_flag \ -deplibs_check_method \ -file_magic_cmd \ -AR \ -AR_FLAGS \ -STRIP \ -RANLIB \ -CC \ -CFLAGS \ -compiler \ -lt_cv_sys_global_symbol_pipe \ -lt_cv_sys_global_symbol_to_cdecl \ -lt_cv_sys_global_symbol_to_c_name_address \ -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ -SHELL \ -ECHO \ -lt_prog_compiler_no_builtin_flag \ -lt_prog_compiler_wl \ -lt_prog_compiler_pic \ -lt_prog_compiler_static \ -lt_cv_prog_compiler_c_o \ -need_locks \ -DSYMUTIL \ -NMEDIT \ -LIPO \ -OTOOL \ -OTOOL64 \ -shrext_cmds \ -export_dynamic_flag_spec \ -whole_archive_flag_spec \ -compiler_needs_object \ -with_gnu_ld \ -allow_undefined_flag \ -no_undefined_flag \ -hardcode_libdir_flag_spec \ -hardcode_libdir_flag_spec_ld \ -hardcode_libdir_separator \ -fix_srcfile_path \ -exclude_expsyms \ -include_expsyms \ -file_list_spec \ -variables_saved_for_relink \ -libname_spec \ -library_names_spec \ -soname_spec \ -finish_eval \ -old_striplib \ -striplib; do - case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in - *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Double-quote double-evaled strings. -for var in reload_cmds \ -old_postinstall_cmds \ -old_postuninstall_cmds \ -old_archive_cmds \ -extract_expsyms_cmds \ -old_archive_from_new_cmds \ -old_archive_from_expsyms_cmds \ -archive_cmds \ -archive_expsym_cmds \ -module_cmds \ -module_expsym_cmds \ -export_symbols_cmds \ -prelink_cmds \ -postinstall_cmds \ -postuninstall_cmds \ -finish_cmds \ -sys_lib_search_path_spec \ -sys_lib_dlsearch_path_spec; do - case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in - *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Fix-up fallback echo if it was mangled by the above quoting rules. -case \$lt_ECHO in -*'\\\$0 --fallback-echo"') lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\` - ;; -esac - -ac_aux_dir='$ac_aux_dir' -xsi_shell='$xsi_shell' -lt_shell_append='$lt_shell_append' - -# See if we are running on zsh, and set the options which allow our -# commands through without removal of \ escapes INIT. -if test -n "\${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi - - - PACKAGE='$PACKAGE' - VERSION='$VERSION' - TIMESTAMP='$TIMESTAMP' - RM='$RM' - ofile='$ofile' - -ac_aux_dir='$ac_aux_dir' - - - -DEPENDS="$DEPENDS" -VERSION_DEPENDS="$VERSION_DEPENDS" -PLAYWAVE_DEPENDS="$PLAYWAVE_DEPENDS" -PLAYMUS_DEPENDS="$PLAYMUS_DEPENDS" - - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "SDL2_mixer.spec") CONFIG_FILES="$CONFIG_FILES SDL2_mixer.spec" ;; - "SDL2_mixer.pc") CONFIG_FILES="$CONFIG_FILES SDL2_mixer.pc" ;; - "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;; - - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= ac_tmp= - trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status -' 0 - trap 'as_fn_exit 1' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp - -# Set up the scripts for CONFIG_FILES section. -# No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. -if test -n "$CONFIG_FILES"; then - - -ac_cr=`echo X | tr X '\015'` -# On cygwin, bash can eat \r inside `` if the user requested igncr. -# But we know of no other shell where ac_cr would be empty at this -# point, so we can use a bashism as a fallback. -if test "x$ac_cr" = x; then - eval ac_cr=\$\'\\r\' -fi -ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` -if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' -else - ac_cs_awk_cr=$ac_cr -fi - -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && -_ACEOF - - -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - . ./conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` - if test $ac_delim_n = $ac_delim_num; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done -rm -f conf$$subs.sh - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && -_ACEOF -sed -n ' -h -s/^/S["/; s/!.*/"]=/ -p -g -s/^[^!]*!// -:repl -t repl -s/'"$ac_delim"'$// -t delim -:nl -h -s/\(.\{148\}\)..*/\1/ -t more1 -s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ -p -n -b repl -:more1 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t nl -:delim -h -s/\(.\{148\}\)..*/\1/ -t more2 -s/["\\]/\\&/g; s/^/"/; s/$/"/ -p -b -:more2 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t delim -' >$CONFIG_STATUS || ac_write_fail=1 -rm -f conf$$subs.awk -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACAWK -cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" - -} -{ - line = $ 0 - nfields = split(line, field, "@") - substed = 0 - len = length(field[1]) - for (i = 2; i < nfields; i++) { - key = field[i] - keylen = length(key) - if (S_is_set[key]) { - value = S[key] - line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) - len += length(value) + length(field[++i]) - substed = 1 - } else - len += 1 + keylen - } - - print line -} - -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" -else - cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ - || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 -_ACEOF - -# VPATH may cause trouble with some makes, so we remove sole $(srcdir), -# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ -h -s/// -s/^/:/ -s/[ ]*$/:/ -s/:\$(srcdir):/:/g -s/:\${srcdir}:/:/g -s/:@srcdir@:/:/g -s/^:*// -s/:*$// -x -s/\(=[ ]*\).*/\1/ -G -s/\n// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -fi # test -n "$CONFIG_FILES" - - -eval set X " :F $CONFIG_FILES :C $CONFIG_COMMANDS" -shift -for ac_tag -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$ac_tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append ac_file_inputs " '$ac_f'" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input='Generated from '` - $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' - `' by configure.' - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} - fi - # Neutralize special characters interpreted by sed in replacement strings. - case $configure_input in #( - *\&* | *\|* | *\\* ) - ac_sed_conf_input=`$as_echo "$configure_input" | - sed 's/[\\\\&|]/\\\\&/g'`;; #( - *) ac_sed_conf_input=$configure_input;; - esac - - case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir="$ac_dir"; as_fn_mkdir_p - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - - case $INSTALL in - [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; - esac -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= -ac_sed_dataroot=' -/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac -_ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_sed_extra="$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@top_build_prefix@&$ac_top_build_prefix&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -s&@INSTALL@&$ac_INSTALL&;t t -$ac_datarootdir_hack -" -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&5 -$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&2;} - - rm -f "$ac_tmp/stdin" - case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; - esac \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - ;; - - - :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 -$as_echo "$as_me: executing $ac_file commands" >&6;} - ;; - esac - - - case $ac_file$ac_mode in - "libtool":C) - - # See if we are running on zsh, and set the options which allow our - # commands through without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST - fi - - cfgfile="${ofile}T" - trap "$RM \"$cfgfile\"; exit 1" 1 2 15 - $RM "$cfgfile" - - cat <<_LT_EOF >> "$cfgfile" -#! $SHELL - -# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008 Free Software Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is part of GNU Libtool. -# -# GNU Libtool is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, or -# obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - -# The names of the tagged configurations supported by this script. -available_tags="" - -# ### BEGIN LIBTOOL CONFIG - -# Which release of libtool.m4 was used? -macro_version=$macro_version -macro_revision=$macro_revision - -# Assembler program. -AS=$AS - -# DLL creation program. -DLLTOOL=$DLLTOOL - -# Object dumper program. -OBJDUMP=$OBJDUMP - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# What type of objects to build. -pic_mode=$pic_mode - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host -host_os=$host_os - -# The build system. -build_alias=$build_alias -build=$build -build_os=$build_os - -# A sed program that does not truncate output. -SED=$lt_SED - -# Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="\$SED -e 1s/^X//" - -# A grep program that handles long lines. -GREP=$lt_GREP - -# An ERE matcher. -EGREP=$lt_EGREP - -# A literal string matcher. -FGREP=$lt_FGREP - -# A BSD- or MS-compatible name lister. -NM=$lt_NM - -# Whether we need soft or hard links. -LN_S=$lt_LN_S - -# What is the maximum length of a command? -max_cmd_len=$max_cmd_len - -# Object file suffix (normally "o"). -objext=$ac_objext - -# Executable file suffix (normally ""). -exeext=$exeext - -# whether the shell understands "unset". -lt_unset=$lt_unset - -# turn spaces into newlines. -SP2NL=$lt_lt_SP2NL - -# turn newlines into spaces. -NL2SP=$lt_lt_NL2SP - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# Method to check whether dependent libraries are shared objects. -deplibs_check_method=$lt_deplibs_check_method - -# Command to use when deplibs_check_method == "file_magic". -file_magic_cmd=$lt_file_magic_cmd - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# A symbol stripping program. -STRIP=$lt_STRIP - -# Commands used to install an old-style archive. -RANLIB=$lt_RANLIB -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# A C compiler. -LTCC=$lt_CC - -# LTCC compiler flags. -LTCFLAGS=$lt_CFLAGS - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe - -# Transform the output of nm in a proper C declaration. -global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl - -# Transform the output of nm in a C name address pair. -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# Transform the output of nm in a C name address pair when lib prefix is needed. -global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# An echo program that does not interpret backslashes. -ECHO=$lt_ECHO - -# Used to examine libraries when file_magic_cmd begins with "file". -MAGIC_CMD=$MAGIC_CMD - -# Must we lock files when doing compilation? -need_locks=$lt_need_locks - -# Tool to manipulate archived DWARF debug symbol files on Mac OS X. -DSYMUTIL=$lt_DSYMUTIL - -# Tool to change global to local symbols on Mac OS X. -NMEDIT=$lt_NMEDIT - -# Tool to manipulate fat objects and archives on Mac OS X. -LIPO=$lt_LIPO - -# ldd/readelf like tool for Mach-O binaries on Mac OS X. -OTOOL=$lt_OTOOL - -# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. -OTOOL64=$lt_OTOOL64 - -# Old archive suffix (normally "a"). -libext=$libext - -# Shared library suffix (normally ".so"). -shrext_cmds=$lt_shrext_cmds - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at link time. -variables_saved_for_relink=$lt_variables_saved_for_relink - -# Do we need the "lib" prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Library versioning type. -version_type=$version_type - -# Shared library runtime path variable. -runpath_var=$runpath_var - -# Shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Command to use after installation of a shared archive. -postinstall_cmds=$lt_postinstall_cmds - -# Command to use after uninstallation of a shared archive. -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# As "finish_cmds", except a single script fragment to be evaled but -# not shown. -finish_eval=$lt_finish_eval - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Compile-time system search path for libraries. -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec - -# Run-time system search path for libraries. -sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - - -# The linker used to build libraries. -LD=$lt_LD - -# Commands used to build an old-style archive. -old_archive_cmds=$lt_old_archive_cmds - -# A language specific compiler. -CC=$lt_compiler - -# Is the compiler the GNU compiler? -with_gcc=$GCC - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_lt_prog_compiler_static - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_lt_cv_prog_compiler_c_o - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$archive_cmds_need_lc - -# Whether or not to disallow shared libs when runtime libs are static. -allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec - -# Whether the compiler copes with passing no objects directly. -compiler_needs_object=$lt_compiler_needs_object - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds - -# Commands used to build a shared archive. -archive_cmds=$lt_archive_cmds -archive_expsym_cmds=$lt_archive_expsym_cmds - -# Commands used to build a loadable module if different from building -# a shared archive. -module_cmds=$lt_module_cmds -module_expsym_cmds=$lt_module_expsym_cmds - -# Whether we are building with GNU ld or not. -with_gnu_ld=$lt_with_gnu_ld - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag - -# Flag that enforces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec - -# If ld is used when linking, flag to hardcode \$libdir into a binary -# during linking. This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld - -# Whether we need a single "-rpath" flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator - -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes -# DIR into the resulting binary. -hardcode_direct=$hardcode_direct - -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes -# DIR into the resulting binary and the resulting library dependency is -# "absolute",i.e impossible to change by setting \${shlibpath_var} if the -# library is relocated. -hardcode_direct_absolute=$hardcode_direct_absolute - -# Set to "yes" if using the -LDIR flag during linking hardcodes DIR -# into the resulting binary. -hardcode_minus_L=$hardcode_minus_L - -# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR -# into the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var - -# Set to "yes" if building a shared library automatically hardcodes DIR -# into the library and all subsequent libraries and executables linked -# against it. -hardcode_automatic=$hardcode_automatic - -# Set to yes if linker adds runtime paths of dependent libraries -# to runtime path list. -inherit_rpath=$inherit_rpath - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path=$lt_fix_srcfile_path - -# Set to "yes" if exported symbols are required. -always_export_symbols=$always_export_symbols - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms - -# Commands necessary for linking programs (against libraries) with templates. -prelink_cmds=$lt_prelink_cmds - -# Specify filename containing input files. -file_list_spec=$lt_file_list_spec - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action - -# ### END LIBTOOL CONFIG - -_LT_EOF - - case $host_os in - aix3*) - cat <<\_LT_EOF >> "$cfgfile" -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES -fi -_LT_EOF - ;; - esac - - -ltmain="$ac_aux_dir/ltmain.sh" - - - # We use sed instead of cat because bash on DJGPP gets confused if - # if finds mixed CR/LF and LF-only lines. Since sed operates in - # text mode, it properly converts lines to CR/LF. This bash problem - # is reportedly fixed, but why not run on old versions too? - sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - case $xsi_shell in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac -} - -# func_basename file -func_basename () -{ - func_basename_result="${1##*/}" -} - -# func_dirname_and_basename file append nondir_replacement -# perform func_basename and func_dirname in a single function -# call: -# dirname: Compute the dirname of FILE. If nonempty, -# add APPEND to the result, otherwise set result -# to NONDIR_REPLACEMENT. -# value returned in "$func_dirname_result" -# basename: Compute filename of FILE. -# value retuned in "$func_basename_result" -# Implementation must be kept synchronized with func_dirname -# and func_basename. For efficiency, we do not delegate to -# those functions but instead duplicate the functionality here. -func_dirname_and_basename () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac - func_basename_result="${1##*/}" -} - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -func_stripname () -{ - # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are - # positional parameters, so assign one to ordinary parameter first. - func_stripname_result=${3} - func_stripname_result=${func_stripname_result#"${1}"} - func_stripname_result=${func_stripname_result%"${2}"} -} - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=${1%%=*} - func_opt_split_arg=${1#*=} -} - -# func_lo2o object -func_lo2o () -{ - case ${1} in - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; - *) func_lo2o_result=${1} ;; - esac -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=${1%.*}.lo -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=$(( $* )) -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=${#1} -} - -_LT_EOF - ;; - *) # Bourne compatible functions. - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi -} - -# func_basename file -func_basename () -{ - func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` -} - - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# func_strip_suffix prefix name -func_stripname () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "X${3}" \ - | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "X${3}" \ - | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; - esac -} - -# sed scripts: -my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q' -my_sed_long_arg='1s/^-[^=]*=//' - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` - func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` -} - -# func_lo2o object -func_lo2o () -{ - func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'` -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=`expr "$@"` -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` -} - -_LT_EOF -esac - -case $lt_shell_append in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$1+=\$2" -} -_LT_EOF - ;; - *) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$1=\$$1\$2" -} - -_LT_EOF - ;; - esac - - - sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - mv -f "$cfgfile" "$ofile" || - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" - - ;; - "default":C) cat >>Makefile <<__EOF__ - -# Build rules for objects --include \$(OBJECTS:.lo=.d) -$DEPENDS -$VERSION_DEPENDS - --include \$(PLAYWAVE_OBJECTS:.lo=.d) -$PLAYWAVE_DEPENDS - --include \$(PLAYMUS_OBJECTS:.lo=.d) -$PLAYMUS_DEPENDS -__EOF__ - ;; - - esac -done # for ac_tag - - -as_fn_exit 0 -_ACEOF -ac_clean_files=$ac_clean_files_save - -test $ac_write_fail = 0 || - as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit 1 -fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} -fi - diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..3cf2dc9 --- /dev/null +++ b/configure.ac @@ -0,0 +1,839 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT +AC_CONFIG_SRCDIR([src/mixer.c]) +AC_CONFIG_AUX_DIR(build-scripts) + +dnl Set various version strings - taken gratefully from the GTk sources + +# Making releases: +# MICRO_VERSION += 1; +# INTERFACE_AGE += 1; +# BINARY_AGE += 1; +# if any functions have been added, set INTERFACE_AGE to 0. +# if backwards compatibility has been broken, +# set BINARY_AGE and INTERFACE_AGE to 0. +# +MAJOR_VERSION=2 +MINOR_VERSION=0 +MICRO_VERSION=4 +INTERFACE_AGE=2 +BINARY_AGE=4 +VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION + +AC_SUBST(MAJOR_VERSION) +AC_SUBST(MINOR_VERSION) +AC_SUBST(MICRO_VERSION) +AC_SUBST(INTERFACE_AGE) +AC_SUBST(BINARY_AGE) +AC_SUBST(VERSION) + +dnl libtool versioning +LT_INIT([win32-dll]) + +LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION +LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE` +LT_REVISION=$INTERFACE_AGE +LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE` +LT_EXTRA="" dnl for OS2 dll name +m4_pattern_allow([^LT_]) + +AC_SUBST(LT_RELEASE) +AC_SUBST(LT_CURRENT) +AC_SUBST(LT_REVISION) +AC_SUBST(LT_AGE) +AC_SUBST(LT_EXTRA) + +dnl Detect the canonical build and host environments +dnl AC_CANONICAL_HOST + +dnl Check for tools +AC_PROG_CC +AC_PROG_INSTALL +AC_PROG_MAKE_SET +LT_PROG_RC + +dnl Set up the compiler and linker flags +case "$host" in + *-*-cygwin*) + # We build SDL on cygwin without the UNIX emulation layer + BASE_CFLAGS="-I/usr/include/mingw" + BASE_LDFLAGS="" + have_no_cygwin=no + AC_MSG_CHECKING(for GCC -mno-cygwin option) + save_CFLAGS="$CFLAGS" + CFLAGS="$save_CFLAGS -mno-cygwin" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], [have_no_cygwin=yes],[]) + AC_MSG_RESULT($have_no_cygwin) + CFLAGS="$save_CFLAGS" + if test x$have_no_cygwin = xyes; then + BASE_CFLAGS="$BASE_CFLAGS -mno-cygwin" + BASE_LDFLAGS="-mno-cygwin" + fi + ;; + *-*-os2*) + # disable static builds on os/2 + enable_static=no + # -DBUILD_SDL is needed for DECLSPEC + BASE_CFLAGS="-DBUILD_SDL" + BASE_LDFLAGS="" + # OS/2 does not support a DLL name longer than 8 characters. + LT_EXTRA="-os2dllname SDL2mix" + ;; + *) + BASE_CFLAGS="-D_GNU_SOURCE=1" + BASE_LDFLAGS="" + ;; +esac +BUILD_CFLAGS="$CFLAGS $CPPFLAGS -I$srcdir/include -I$srcdir/src -I$srcdir/src/codecs" +EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS" +BUILD_LDFLAGS="$LDFLAGS" +EXTRA_LDFLAGS="$BASE_LDFLAGS" +## These are common directories to find software packages +#for path in /usr/freeware /usr/pkg /usr/local; do +# if test -d $path/include; then +# EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include" +# fi +# if test -d $path/lib; then +# EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib" +# fi +#done +CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS" +CFLAGS="$CFLAGS $EXTRA_CFLAGS" +LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS" + +dnl Check for compiler characteristics +AC_C_CONST + +dnl See whether we can use gcc style dependency tracking +AC_ARG_ENABLE(dependency-tracking, +[AS_HELP_STRING([--enable-dependency-tracking], + [Use gcc -MMD -MT dependency tracking [default=yes]])], + , enable_dependency_tracking=yes) +if test x$enable_dependency_tracking = xyes; then + have_gcc_mmd_mt=no + AC_MSG_CHECKING(for GCC -MMD -MT option) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #if !defined(__GNUC__) || __GNUC__ < 3 + #error Dependency tracking requires GCC 3.0 or newer + #endif + ]],[])], [have_gcc_mmd_mt=yes],[]) + AC_MSG_RESULT($have_gcc_mmd_mt) + + if test x$have_gcc_mmd_mt = xyes; then + DEPENDENCY_TRACKING_OPTIONS="-MMD -MT \$@" + fi +fi + +case "$host" in + *-*-cygwin* | *-*-mingw*) + VERSION_SOURCES="$srcdir/version.rc" + EXE=".exe" + if test "$build" != "$host"; then # cross-compiling + # Default cross-compile location + ac_default_prefix=/usr/local/cross-tools/$host + else + # Look for the location of the tools and install there + if test "$BUILD_PREFIX" != ""; then + ac_default_prefix=$BUILD_PREFIX + fi + fi + ;; + *-*-os2*) + EXE=".exe" + ;; + *) + EXE="" + ;; +esac + +# Standard C sources +SOURCES=`ls $srcdir/src/*.c $srcdir/src/codecs/*.c | fgrep -v playwave.c | fgrep -v playmus.c` + +dnl set this to use on systems that use lib64 instead of lib +base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'` + +dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually). +dnl Details of this flag are here: http://gcc.gnu.org/wiki/Visibility +CheckVisibilityHidden() +{ + AC_MSG_CHECKING(for GCC -fvisibility=hidden option) + have_gcc_fvisibility=no + + visibility_CFLAGS="-fvisibility=hidden" + save_CFLAGS="$CFLAGS" + CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #if !defined(__GNUC__) || __GNUC__ < 4 + #error SDL only uses visibility attributes in GCC 4 or newer + #endif + ]],[])], [have_gcc_fvisibility=yes],[]) + AC_MSG_RESULT($have_gcc_fvisibility) + CFLAGS="$save_CFLAGS" + + if test x$have_gcc_fvisibility = xyes; then + EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS" + fi +} + + +dnl Function to find a library in the compiler search path +find_lib() +{ + gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`] + gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`] + env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`] + if test "$cross_compiling" = yes; then + host_lib_path="" + else + host_lib_path="/usr/$base_libdir /usr/local/$base_libdir" + fi + for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do + lib=[`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1`] + if test x$lib != x; then + echo $lib + return + fi + done +} + +dnl Check for SDL +SDL_VERSION=2.0.7 +AM_PATH_SDL2($SDL_VERSION, + :, + AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]) +) +EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS" +EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS" + +dnl Check for math library +AC_CHECK_LIB(m, pow, [LIBM="-lm"]) + +AC_CHECK_HEADERS([signal.h], [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SIGNAL_H"]) +AC_CHECK_FUNCS(setbuf, [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SETBUF"]) + +dnl Check command-line options + +CheckVisibilityHidden + +AC_ARG_ENABLE([music-cmd], +[AS_HELP_STRING([--enable-music-cmd], [support an external music player [default=yes]])], + [], [enable_music_cmd=detect]) +if test "x$enable_music_cmd" != xno; then + AC_CHECK_FUNCS([fork vfork]) + if test "x$ac_cv_func_fork" = "xyes"; then + EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_FORK" + elif test "x$ac_cv_func_vfork" = "xyes"; then + EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_VFORK" + elif test "x$enable_music_cmd" = "xyes"; then + AC_MSG_ERROR([external music player not available on your platform]) + else + enable_music_cmd=no + fi + if test "x$enable_music_cmd" != xno; then + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_CMD" + fi +fi + +AC_ARG_ENABLE([music-wave], +[AS_HELP_STRING([--enable-music-wave], [enable streaming WAVE music [default=yes]])], + [], [enable_music_wave=yes]) +if test x$enable_music_wave = xyes; then + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_WAV" +fi + +AC_ARG_ENABLE([music-mod], +[AS_HELP_STRING([--enable-music-mod], [enable MOD music [default=yes]])], + [], [enable_music_mod=yes]) + +AC_ARG_ENABLE([music-mod-modplug], +[AS_HELP_STRING([--enable-music-mod-modplug], [enable MOD music via modplug [default=yes]])], + [], [enable_music_mod_modplug=yes]) +AC_ARG_ENABLE([music-mod-modplug-shared], +[AS_HELP_STRING([--enable-music-mod-modplug-shared], [dynamically load modplug library [default=yes]])], + [], [enable_music_mod_modplug_shared=yes]) +if test x$enable_music_mod = xyes -a x$enable_music_mod_modplug = xyes; then + PKG_CHECK_MODULES([MODPLUG], [libmodplug >= 0.8.8], [dnl + have_libmodplug_hdr=yes + have_libmodplug_lib=yes + ], [dnl + AC_CHECK_HEADER([libmodplug/modplug.h], [have_libmodplug_hdr=yes]) + AC_CHECK_LIB([modplug], [ModPlug_Load], [have_libmodplug_lib=yes;MODPLUG_LIBS="-lmodplug"]) + ]) + + if test x$have_libmodplug_hdr = xyes -a x$have_libmodplug_lib = xyes; then + have_libmodplug=yes + case "$host" in + *-*-darwin*) + modplug_lib=[`find_lib libmodplug.dylib`] + ;; + *-*-cygwin* | *-*-mingw*) + modplug_lib=[`find_lib "libmodplug*.dll"`] + ;; + *) + modplug_lib=[`find_lib "libmodplug[0-9]*.so.*"`] + if test x$modplug_lib = x; then + modplug_lib=[`find_lib "libmodplug.so.*"`] + fi + ;; + esac + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MODPLUG $MODPLUG_CFLAGS" + if test x$enable_music_mod_modplug_shared = xyes && test x$modplug_lib != x; then + echo "-- dynamic libmodplug -> $modplug_lib" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_DYNAMIC=\\\"$modplug_lib\\\"" + else + EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS" + fi + else + AC_MSG_WARN([*** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)]) + fi +fi + +AC_ARG_ENABLE([music-mod-xmp], +[AS_HELP_STRING([--enable-music-mod-xmp], [enable MOD music via libxmp [default=no]])], + [], [enable_music_mod_xmp=no]) +AC_ARG_ENABLE([music-mod-xmp-lite], +[AS_HELP_STRING([--enable-music-mod-xmp-lite], [use libxmp-lite instead of libxmp [default=no]])], + [], [enable_music_mod_xmp_lite=no]) +AC_ARG_ENABLE([music-mod-xmp-shared], +[AS_HELP_STRING([--enable-music-mod-xmp-shared], [dynamically load xmp library [default=yes]])], + [], [enable_music_mod_xmp_shared=yes]) +if test x$enable_music_mod = xyes -a x$enable_music_mod_xmp = xyes; then + xmplib=xmp + if test x$enable_music_mod_xmp_lite = xyes; then + xmplib=xmp-lite + fi + PKG_CHECK_MODULES([XMP], [lib$xmplib >= 4.2], [dnl + have_libxmp_hdr=yes + have_libxmp_lib=yes + ], [dnl + AC_CHECK_HEADER([xmp.h], [have_libxmp_hdr=yes]) + AC_CHECK_LIB([xmp], [xmp_load_module_from_memory], [have_libxmp_lib=yes;XMP_LIBS="-l$xmplib"]) + ]) + + if test x$have_libxmp_hdr = xyes -a x$have_libxmp_lib = xyes; then + have_libxmp=yes + case "$host" in + *-*-darwin*) + xmp_lib=[`find_lib lib$xmplib.dylib`] + ;; + *-*-cygwin* | *-*-mingw*) + xmp_lib=[`find_lib "lib$xmplib*.dll"`] + ;; + *) + xmp_lib=[`find_lib "lib$xmplib[0-9]*.so.*"`] + if test x$xmp_lib = x; then + xmp_lib=[`find_lib "lib$xmplib.so.*"`] + fi + ;; + esac + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_XMP $XMP_CFLAGS" + if test x$enable_music_mod_xmp_shared = xyes && test x$xmp_lib != x; then + echo "-- dynamic libxmp -> $xmp_lib" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DXMP_DYNAMIC=\\\"$xmp_lib\\\"" + else + EXTRA_LDFLAGS="$EXTRA_LDFLAGS $XMP_LIBS" + fi + else + AC_MSG_WARN([*** Unable to find xmp library (http://xmp.sourceforge.net/)]) + fi +fi + +AC_ARG_ENABLE([music-mod-mikmod], +[AS_HELP_STRING([--enable-music-mod-mikmod], [enable MOD music via mikmod [default=no]])], + [], [enable_music_mod_mikmod=no]) +AC_ARG_ENABLE([music-mod-mikmod-shared], +[AS_HELP_STRING([--enable-music-mod-mikmod-shared], [dynamically load mikmod library [default=yes]])], + [], [enable_music_mod_mikmod_shared=yes]) +if test x$enable_music_mod = xyes -a x$enable_music_mod_mikmod = xyes; then + have_libmikmod=no + libmikmod_maj=3 + libmikmod_min=1 + libmikmod_rev=10 + libmikmod_ver="$libmikmod_maj.$libmikmod_min.$libmikmod_rev" + CFLAGS_SAVED="$CFLAGS" + LIBS_SAVED="$LIBS" + AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no, [$PATH]) + if test "$LIBMIKMOD_CONFIG" != "no" ; then + CFLAGS="$CFLAGS `$LIBMIKMOD_CONFIG --cflags`" + LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`" + have_libmikmod=yes + AC_MSG_CHECKING([for libmikmod - version >= $libmikmod_ver]) + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include "mikmod.h" +#include "stdio.h" + +int main(int argc, char **argv) +{ + long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion(); + if (ver>=((maj<<16)|(min<<8)|(rev))) { + printf("yes\n"); + return 0; + } + printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev); + return 1; +} +]])],[],[have_libmikmod=no],[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + fi + + if test x$have_libmikmod = xyes; then + case "$host" in + *-*-darwin*) + mikmod_lib=[`find_lib libmikmod.dylib`] + ;; + *-*-cygwin* | *-*-mingw*) + mikmod_lib=[`find_lib "libmikmod*.dll"`] + ;; + *) + mikmod_lib=[`find_lib "libmikmod[0-9]*.so.*"`] + if test x$mikmod_lib = x; then + mikmod_lib=[`find_lib "libmikmod.so.*"`] + fi + ;; + esac + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MIKMOD `$LIBMIKMOD_CONFIG --cflags`" + if test x$enable_music_mod_mikmod_shared = xyes && test x$mikmod_lib != x; then + echo "-- dynamic libmikmod -> $mikmod_lib" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMIKMOD_DYNAMIC=\\\"$mikmod_lib\\\"" + else + EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`" + fi + else + AC_MSG_WARN([*** Unable to find MikMod library (http://mikmod.sourceforge.net/)]) + fi + LIBS="$LIBS_SAVED" + CFLAGS="$CFLAGS_SAVED" +fi + +if test x$have_libmodplug != xyes -a x$have_libmikmod != xyes -a x$have_libxmp != xyes; then + AC_MSG_WARN([MOD support disabled]) +fi + +AC_ARG_ENABLE([music-midi], +[AS_HELP_STRING([--enable-music-midi], [enable MIDI music [default=yes]])], + [], [enable_music_midi=yes]) +if test x$enable_music_midi = xyes; then + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID" + AC_ARG_ENABLE([music-midi-timidity], +[AS_HELP_STRING([--enable-music-midi-timidity], [enable timidity MIDI output [default=yes]])], + [], [enable_music_midi_timidity=yes]) + if test x$enable_music_midi_timidity = xyes; then + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_TIMIDITY -I\$(srcdir)/src/codecs/timidity" + SOURCES="$SOURCES $srcdir/src/codecs/timidity/*.c" + timidity_cfg=no + AC_ARG_WITH([timidity-cfg], +[AS_HELP_STRING([--with-timidity-cfg=FILE],[Specify full path to timidity.cfg])], timidity_cfg="$withval", []) + if test x$timidity_cfg != xyes -a x$timidity_cfg != xno; then + EXTRA_CFLAGS="$EXTRA_CFLAGS -DTIMIDITY_CFG=\\\"$timidity_cfg\\\"" + fi + fi + AC_ARG_ENABLE([music-midi-native], +[AS_HELP_STRING([--enable-music-midi-native], [enable native MIDI music output [default=yes]])], + [], [enable_music_midi_native=yes]) + if test x$enable_music_midi_native = xyes; then + use_music_midi_native=no + case "$host" in + *-*-cygwin* | *-*-mingw*) + use_music_midi_native=yes + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm" + ;; + *-*-darwin*) + use_music_midi_native=yes + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,CoreServices" + ;; + *-*-haiku*) + use_music_midi_native=yes_cpp + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmidi" + ;; + esac + if test x$use_music_midi_native = xyes; then + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/src/codecs/native_midi" + SOURCES="$SOURCES $srcdir/src/codecs/native_midi/*.c" + elif test x$use_music_midi_native = xyes_cpp; then + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/src/codecs/native_midi" + SOURCES="$SOURCES $srcdir/src/codecs/native_midi/*.c" + SOURCES_CXX="$SOURCES_CXX $srcdir/src/codecs/native_midi/*.cpp" + fi + fi + AC_ARG_ENABLE([music-midi-fluidsynth], +[AS_HELP_STRING([--enable-music-midi-fluidsynth], [enable FluidSynth MIDI output [default=yes]])], + [], [enable_music_midi_fluidsynth=yes]) + AC_ARG_ENABLE([music-midi-fluidsynth-shared], +[AS_HELP_STRING([--enable-music-midi-fluidsynth-shared], [dynamically load FluidSynth library [default=yes]])], + [], [enable_music_midi_fluidsynth_shared=yes]) + if test x$enable_music_midi_fluidsynth = xyes; then + AC_CHECK_HEADER([fluidsynth.h], [have_fluidsynth_hdr=yes]) + AC_CHECK_LIB([fluidsynth], [fluid_player_add_mem], [have_fluidsynth_lib=yes]) + if test x$have_fluidsynth_hdr = xyes -a x$have_fluidsynth_lib = xyes; then + have_fluidsynth=yes + case "$host" in + *-*-darwin*) + fluidsynth_lib=[`find_lib libfluidsynth.dylib`] + ;; + *-*-cygwin* | *-*-mingw*) + fluidsynth_lib=[`find_lib "fluidsynth*.dll"`] + if test x$fluidsynth_lib = x; then + fluidsynth_lib=[`find_lib "libfluidsynth*.dll"`] + fi + ;; + *) + fluidsynth_lib=[`find_lib "libfluidsynth[0-9]*.so.*"`] + if test x$fluidsynth_lib = x; then + fluidsynth_lib=[`find_lib "libfluidsynth.so.*"`] + fi + ;; + esac + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_FLUIDSYNTH" + if test x$enable_music_midi_fluidsynth_shared = xyes && test x$fluidsynth_lib != x; then + echo "-- dynamic libfluidsynth -> $fluidsynth_lib" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLUIDSYNTH_DYNAMIC=\\\"$fluidsynth_lib\\\"" + else + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lfluidsynth" + fi + else + AC_MSG_WARN([*** Unable to find FluidSynth library (http://www.fluidsynth.org/)]) + AC_MSG_WARN([FluidSynth support disabled]) + fi + fi +fi + +if test x$enable_music_midi_timidity != xyes -a \ + x$use_music_midi_native != xyes -a x$use_music_midi_native != xyes_cpp -a \ + x$have_fluidsynth != xyes; then + AC_MSG_WARN([MIDI support disabled]) +fi + +AC_ARG_ENABLE([music-ogg], +[AS_HELP_STRING([--enable-music-ogg], [enable Ogg Vorbis music [default=yes]])], + [], [enable_music_ogg=yes]) +AC_ARG_ENABLE(music-ogg-tremor, +[AS_HELP_STRING([--enable-music-ogg-tremor], [enable OGG Vorbis music via libtremor [default=no]])], + [], enable_music_ogg_tremor=no) +AC_ARG_ENABLE([music-ogg-shared], +[AS_HELP_STRING([--enable-music-ogg-shared], [dynamically load Ogg Vorbis library [default=yes]])], + [], [enable_music_ogg_shared=yes]) +if test x$enable_music_ogg = xyes; then + LIBS_SAVED="$LIBS" + if test x$enable_music_ogg_tremor = xyes; then + AC_CHECK_HEADER([tremor/ivorbisfile.h], [have_tremor_hdr=yes]) + AC_CHECK_LIB([vorbisidec], [ov_open_callbacks], [have_tremor_lib=yes], [], [-logg]) + if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then + case "$host" in + *-*-darwin*) + ogg_lib=[`find_lib libvorbisidec.dylib`] + ;; + *-*-cygwin* | *-*-mingw*) + ogg_lib=[`find_lib "vorbisidec*.dll"`] + if test x$ogg_lib = x; then + ogg_lib=[`find_lib "libvorbisidec*.dll"`] + fi + ;; + *) + ogg_lib=[`find_lib "libvorbisidec[0-9]*.so.*"`] + if test x$ogg_lib = x; then + ogg_lib=[`find_lib "libvorbisidec.so.*"`] + fi + ;; + esac + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG -DOGG_USE_TREMOR" + if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then + echo "-- dynamic libvorbisidec -> $ogg_lib" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\"" + else + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec" + fi + else + AC_MSG_WARN([*** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)]) + AC_MSG_WARN([Ogg Vorbis support disabled]) + fi + else + AC_CHECK_HEADER([vorbis/vorbisfile.h], [have_ogg_hdr=yes]) + AC_CHECK_LIB([vorbisfile], [ov_open_callbacks], [have_ogg_lib=yes], [], [-lvorbis -logg -lm]) + if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then + case "$host" in + *-*-darwin*) + ogg_lib=[`find_lib libvorbisfile.dylib`] + ;; + *-*-cygwin* | *-*-mingw*) + ogg_lib=[`find_lib "libvorbisfile*.dll"`] + ;; + *) + ogg_lib=[`find_lib "libvorbisfile[0-9]*.so.*"`] + if test x$ogg_lib = x; then + ogg_lib=[`find_lib "libvorbisfile.so.*"`] + fi + ;; + esac + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG" + if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then + echo "-- dynamic libvorbisfile -> $ogg_lib" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\"" + else + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis" + fi + else + AC_MSG_WARN([*** Unable to find Ogg Vorbis library (http://www.xiph.org/)]) + AC_MSG_WARN([Ogg Vorbis support disabled]) + fi + fi + LIBS="$LIBS_SAVED" +fi + +libflac_ver=8 +AC_ARG_ENABLE([music-flac], +[AS_HELP_STRING([--enable-music-flac], [enable FLAC music [default=yes]])], + [], [enable_music_flac=yes]) +AC_ARG_ENABLE([music-flac-shared], +[AS_HELP_STRING([--enable-music-flac-shared], + [dynamically load FLAC library [default=yes]])], + [], [enable_music_flac_shared=yes]) +if test x$enable_music_flac = xyes; then + AC_CHECK_HEADER([FLAC/export.h], [have_flac_export=yes]) + if test x$have_flac_export = xyes; then + LIBS_SAVED="$LIBS" + LIBS="-lFLAC" + AC_MSG_CHECKING([for libflac so-name version >= $libflac_ver]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include "FLAC/export.h" +#include "stdio.h" +]], [[ +#if defined(FLAC_API_VERSION_CURRENT) && (FLAC_API_VERSION_CURRENT >= $libflac_ver) +#else +#error "old-flac" +#endif +]])], [have_flac_ver=yes],[have_flac_ver=no]) + LIBS="$LIBS_SAVED" + AC_MSG_RESULT($have_flac_ver) + fi + + if test x$have_flac_ver = xyes; then + AC_CHECK_HEADER([FLAC/stream_decoder.h], [have_flac_hdr=yes]) + AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new], [have_flac_lib=yes]) + if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then + case "$host" in + *-*-darwin*) + flac_lib=[`find_lib libFLAC.dylib`] + ;; + *-*-cygwin* | *-*-mingw*) + flac_lib=[`find_lib "libFLAC-*.dll"`] + ;; + *) + flac_lib=[`find_lib "libFLAC[0-9]*.so.*"`] + if test x$flac_lib = x; then + flac_lib=[`find_lib "libFLAC.so.*"`] + fi + ;; + esac + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_FLAC" + if test x$enable_music_flac_shared = xyes && test x$flac_lib != x; then + echo "-- dynamic libFLAC -> $flac_lib" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_DYNAMIC=\\\"$flac_lib\\\"" + else + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lFLAC" + fi + fi + else + AC_MSG_WARN([*** Unable to find FLAC library (http://flac.sourceforge.net/)]) + AC_MSG_WARN([FLAC support disabled]) + fi +fi + +AC_ARG_ENABLE(music-mp3, +[AS_HELP_STRING([--enable-music-mp3], [enable MP3 music [default=yes]])], + [], enable_music_mp3=yes) + +AC_ARG_ENABLE(music-mp3-mad-gpl, +[AS_HELP_STRING([--enable-music-mp3-mad-gpl], [enable MP3 music via libmad GPL code [default=no]])], + [], [enable_music_mp3_mad_gpl=no]) +AC_ARG_ENABLE(music-mp3-mad-gpl-dithering, +[AS_HELP_STRING([--enable-music-mp3-mad-gpl-dithering], [enable MP3 music via libmad GPL code [default=yes]])], + [], [enable_music_mp3_mad_gpl_dithering=yes]) +if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_mad_gpl = xyes; then + AC_MSG_CHECKING(for libmad headers) + have_libmad=no + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include "mad.h" + ]],[])], [have_libmad=yes],[]) + AC_MSG_RESULT($have_libmad) + if test x$have_libmad = xyes; then + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD" + if test x$enable_music_mp3_mad_gpl_dithering = xyes; then + AC_MSG_WARN([*** Using GPL libmad and MP3 dithering routines, this build of SDL_mixer is now under the GPL]) + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD_GPL_DITHERING" + fi + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad" + else + AC_MSG_WARN([*** Unable to find MAD library (http://www.underbit.com/products/mad/)]) + fi +fi + +AC_ARG_ENABLE(music-mp3-mpg123, +[AS_HELP_STRING([--enable-music-mp3-mpg123], [enable MP3 music via libmpg123 [default=yes]])], + [], [enable_music_mp3_mpg123=yes]) +AC_ARG_ENABLE([music-mp3-mpg123-shared], +[AS_HELP_STRING([--enable-music-mp3-mpg123-shared], [dynamically load libmpg123 library [default=yes]])], + [], [enable_music_mp3_mpg123_shared=yes]) +if test x$enable_music_mp3_mpg123 = xyes; then + AC_CHECK_HEADER([mpg123.h], [have_mpg123_hdr=yes]) + AC_CHECK_LIB([mpg123], [mpg123_replace_reader_handle], [have_mpg123_lib=yes]) + if test x$have_mpg123_hdr = xyes -a x$have_mpg123_lib = xyes; then + have_libmpg123=yes + case "$host" in + *-*-darwin*) + mpg123_lib=[`find_lib libmpg123.dylib`] + ;; + *-*-cygwin* | *-*-mingw*) + mpg123_lib=[`find_lib "libmpg123*.dll"`] + ;; + *) + mpg123_lib=[`find_lib "libmpg123.so.*"`] + ;; + esac + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MPG123" + if test x$enable_music_mp3_mpg123_shared = xyes && test x$mpg123_lib != x; then + echo "-- dynamic libmpg123 -> $mpg123_lib" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMPG123_DYNAMIC=\\\"$mpg123_lib\\\"" + else + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmpg123" + fi + else + AC_MSG_WARN([*** Unable to find mpg123 library (https://www.mpg123.de)]) + AC_MSG_WARN([mpg123 support disabled]) + fi +fi + +if test x$have_libmad = xyes -o x$have_libmpg123 = xyes; then + : +else + AC_MSG_WARN([MP3 support disabled]) +fi + +AC_ARG_ENABLE([music-opus], +[AS_HELP_STRING([--enable-music-opus], [enable Opus music [default=yes]])], + [], [enable_music_opus=yes]) + +AC_ARG_ENABLE([music-opus-shared], +[AS_HELP_STRING([--enable-music-opus-shared], [dynamically load opusfile library [default=yes]])], + [], [enable_music_opus_shared=yes]) +if test x$enable_music_opus = xyes; then + LIBS_SAVED="$LIBS" + PKG_CHECK_MODULES([OPUSFILE], [opusfile >= 0.2], [dnl + have_opusfile_hdr=yes + have_opusfile_lib=yes + ], [dnl + AC_CHECK_HEADER([opus/opusfile.h], [have_opusfile_hdr=yes]) + AC_CHECK_LIB([opusfile], [op_open_callbacks], [have_opusfile_lib=yes;OPUSFILE_LIBS="-lopusfile -lopus"], [], [-lopus -logg -lm]) + ]) + LIBS="$LIBS_SAVED" + + if test x$have_opusfile_hdr = xyes -a x$have_opusfile_lib = xyes; then + have_opusfile=yes + case "$host" in + *-*-darwin*) + opusfile_lib=[`find_lib libopusfile.dylib`] + ;; + *-*-cygwin* | *-*-mingw*) + opusfile_lib=[`find_lib "libopusfile*.dll"`] + ;; + *) + opusfile_lib=[`find_lib "libopusfile[0-9]*.so.*"`] + if test x$opusfile_lib = x; then + opusfile_lib=[`find_lib "libopusfile.so.*"`] + fi + ;; + esac + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OPUS $OPUSFILE_CFLAGS" + if test x$enable_music_opus_shared = xyes && test x$opusfile_lib != x; then + echo "-- dynamic opusfile -> $opusfile_lib" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DOPUS_DYNAMIC=\\\"$opusfile_lib\\\"" + else + EXTRA_LDFLAGS="$EXTRA_LDFLAGS $OPUSFILE_LIBS" + fi + else + AC_MSG_WARN([*** Unable to find opusfile library (http://opus-codec.org/)]) + fi +fi + +EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBM" + +OBJECTS=`echo $SOURCES` +DEPENDS=`echo $SOURCES` +OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'` +DEPENDS=`echo "$DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\ +$(objects)/\2.lo: \1/\2.c \$(objects)/.created\\ + \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'` + +OBJECTS_CXX=`echo $SOURCES_CXX` +DEPENDS_CXX=`echo $SOURCES_CXX` +OBJECTS_CXX=`echo "$OBJECTS_CXX" | sed 's,[[^ ]]*/\([[^ ]]*\)\.cpp,$(objects)/\1.lo,g'` +DEPENDS_CXX=`echo "$DEPENDS_CXX" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.cpp,\\ +$(objects)/\2.lo: \1/\2.cpp \$(objects)/.created\\ + \$(LIBTOOL) --mode=compile \$(CXX) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'` +OBJECTS="$OBJECTS $OBJECTS_CXX" +DEPENDS="$DEPENDS $DEPENDS_CXX" +DEPENDS=`echo "$DEPENDS" | sed 's,\\$,\\\\$,g'` + +VERSION_OBJECTS=`echo $VERSION_SOURCES` +VERSION_DEPENDS=`echo $VERSION_SOURCES` +VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.lo,g'` +VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.rc,\\ +$(objects)/\2.lo: \1/\2.rc \$(objects)/.created\\ + \$(LIBTOOL) --tag=RC --mode=compile \$(RC) \$< -o \$@,g'` +VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\\$,\\\\$,g'` + +PLAYWAVE_SOURCES="$srcdir/playwave.c" +PLAYWAVE_OBJECTS=`echo $PLAYWAVE_SOURCES` +PLAYWAVE_DEPENDS=`echo $PLAYWAVE_SOURCES` +PLAYWAVE_OBJECTS=`echo "$PLAYWAVE_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'` +PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\ +$(objects)/\2.lo: \1/\2.c \$(objects)/.created\\ + \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'` +PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\\$,\\\\$,g'` + +PLAYMUS_SOURCES="$srcdir/playmus.c" +PLAYMUS_OBJECTS=`echo $PLAYMUS_SOURCES` +PLAYMUS_DEPENDS=`echo $PLAYMUS_SOURCES` +PLAYMUS_OBJECTS=`echo "$PLAYMUS_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'` +PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\ +$(objects)/\2.lo: \1/\2.c \$(objects)/.created\\ + \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'` +PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\\$,\\\\$,g'` + +dnl Expand the sources and objects needed to build the library +AC_SUBST(ac_aux_dir) +AC_SUBST(OBJECTS) +AC_SUBST(VERSION_OBJECTS) +AC_SUBST(PLAYWAVE_OBJECTS) +AC_SUBST(PLAYMUS_OBJECTS) +AC_SUBST(BUILD_CFLAGS) +AC_SUBST(EXTRA_CFLAGS) +AC_SUBST(BUILD_LDFLAGS) +AC_SUBST(EXTRA_LDFLAGS) +AC_SUBST(EXE) +AC_SUBST(SDL_VERSION) +AC_SUBST(SDL_CFLAGS) +AC_SUBST(SDL_LIBS) + +AC_CONFIG_FILES([ + Makefile SDL2_mixer.spec SDL2_mixer.pc +]) +AC_CONFIG_COMMANDS([default], + [cat >>Makefile <<__EOF__ + +# Build rules for objects +-include \$(OBJECTS:.lo=.d) +$DEPENDS +$VERSION_DEPENDS + +-include \$(PLAYWAVE_OBJECTS:.lo=.d) +$PLAYWAVE_DEPENDS + +-include \$(PLAYMUS_OBJECTS:.lo=.d) +$PLAYMUS_DEPENDS +__EOF__ +], [ +DEPENDS="$DEPENDS" +VERSION_DEPENDS="$VERSION_DEPENDS" +PLAYWAVE_DEPENDS="$PLAYWAVE_DEPENDS" +PLAYMUS_DEPENDS="$PLAYMUS_DEPENDS" +]) +AC_OUTPUT diff --git a/configure.in b/configure.in deleted file mode 100644 index 240a322..0000000 --- a/configure.in +++ /dev/null @@ -1,778 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. -AC_INIT(README.txt) -AC_CONFIG_AUX_DIR(build-scripts) - -dnl Set various version strings - taken gratefully from the GTk sources - -# Making releases: -# MICRO_VERSION += 1; -# INTERFACE_AGE += 1; -# BINARY_AGE += 1; -# if any functions have been added, set INTERFACE_AGE to 0. -# if backwards compatibility has been broken, -# set BINARY_AGE and INTERFACE_AGE to 0. -# -MAJOR_VERSION=2 -MINOR_VERSION=0 -MICRO_VERSION=4 -INTERFACE_AGE=2 -BINARY_AGE=4 -VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION - -AC_SUBST(MAJOR_VERSION) -AC_SUBST(MINOR_VERSION) -AC_SUBST(MICRO_VERSION) -AC_SUBST(INTERFACE_AGE) -AC_SUBST(BINARY_AGE) -AC_SUBST(VERSION) - -# libtool versioning -LT_INIT([win32-dll]) - -LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION -LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE` -LT_REVISION=$INTERFACE_AGE -LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE` -m4_pattern_allow([^LT_]) - -AC_SUBST(LT_RELEASE) -AC_SUBST(LT_CURRENT) -AC_SUBST(LT_REVISION) -AC_SUBST(LT_AGE) - -dnl Detect the canonical build and host environments -AC_CONFIG_AUX_DIRS($srcdir/build-scripts) -dnl AC_CANONICAL_HOST - -dnl Check for tools -AC_PROG_LIBTOOL -AC_PROG_CC -AC_PROG_INSTALL -AC_PROG_MAKE_SET -if test -z "$host_alias"; then - hostaliaswindres= -else - hostaliaswindres="$host_alias-windres" -fi -AC_CHECK_PROGS(WINDRES, [windres $hostaliaswindres $host_os-windres]) - -dnl Set up the compiler and linker flags -case "$host" in - *-*-cygwin*) - # We build SDL on cygwin without the UNIX emulation layer - BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin" - BASE_LDFLAGS="-mno-cygwin" - ;; - *) - BASE_CFLAGS="-D_GNU_SOURCE=1" - BASE_LDFLAGS="" - ;; -esac -BUILD_CFLAGS="$CFLAGS $CPPFLAGS" -EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS" -BUILD_LDFLAGS="$LDFLAGS" -EXTRA_LDFLAGS="$BASE_LDFLAGS" -## These are common directories to find software packages -#for path in /usr/freeware /usr/pkg /usr/local; do -# if test -d $path/include; then -# EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include" -# fi -# if test -d $path/lib; then -# EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib" -# fi -#done -CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS" -CFLAGS="$CFLAGS $EXTRA_CFLAGS" -LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS" - -dnl Check for compiler characteristics -AC_C_CONST - -dnl See whether we can use gcc style dependency tracking -AC_ARG_ENABLE(dependency-tracking, -AC_HELP_STRING([--enable-dependency-tracking], - [Use gcc -MMD -MT dependency tracking [[default=yes]]]), - , enable_dependency_tracking=yes) -if test x$enable_dependency_tracking = xyes; then - have_gcc_mmd_mt=no - AC_MSG_CHECKING(for GCC -MMD -MT option) - AC_TRY_COMPILE([ - #if !defined(__GNUC__) || __GNUC__ < 3 - #error Dependency tracking requires GCC 3.0 or newer - #endif - ],[ - ],[ - have_gcc_mmd_mt=yes - ]) - AC_MSG_RESULT($have_gcc_mmd_mt) - - if test x$have_gcc_mmd_mt = xyes; then - DEPENDENCY_TRACKING_OPTIONS="-MMD -MT \$@" - fi -fi - -case "$host" in - *mingw32ce*) - #VERSION_SOURCES="$srcdir/version.rc" - EXE=".exe" - ;; - *-*-cygwin* | *-*-mingw32*) - VERSION_SOURCES="$srcdir/version.rc" - EXE=".exe" - if test "$build" != "$host"; then # cross-compiling - # Default cross-compile location - ac_default_prefix=/usr/local/cross-tools/$host - else - # Look for the location of the tools and install there - if test "$BUILD_PREFIX" != ""; then - ac_default_prefix=$BUILD_PREFIX - fi - fi - ;; - *) - EXE="" - ;; -esac - -# Standard C sources -SOURCES=`ls $srcdir/*.c | fgrep -v playwave.c | fgrep -v playmus.c` - -dnl set this to use on systems that use lib64 instead of lib -base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'` - -dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually). -dnl Details of this flag are here: http://gcc.gnu.org/wiki/Visibility -CheckVisibilityHidden() -{ - AC_MSG_CHECKING(for GCC -fvisibility=hidden option) - have_gcc_fvisibility=no - - visibility_CFLAGS="-fvisibility=hidden" - save_CFLAGS="$CFLAGS" - CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror" - AC_TRY_COMPILE([ - #if !defined(__GNUC__) || __GNUC__ < 4 - #error SDL only uses visibility attributes in GCC 4 or newer - #endif - ],[ - ],[ - have_gcc_fvisibility=yes - ]) - AC_MSG_RESULT($have_gcc_fvisibility) - CFLAGS="$save_CFLAGS" - - if test x$have_gcc_fvisibility = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS" - fi -} - - -dnl Function to find a library in the compiler search path -find_lib() -{ - gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`] - gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`] - env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`] - if test "$cross_compiling" = yes; then - host_lib_path="" - else - host_lib_path="/usr/$base_libdir /usr/local/$base_libdir" - fi - for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do - lib=[`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1`] - if test x$lib != x; then - echo $lib - return - fi - done -} - -dnl Check for SDL -SDL_VERSION=2.0.7 -AM_PATH_SDL2($SDL_VERSION, - :, - AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]) -) -EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS" -EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS" - -dnl Check for math library -AC_CHECK_LIB(m, pow, [LIBM="-lm"]) - -AC_CHECK_HEADERS([signal.h], [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SIGNAL_H"]) -AC_CHECK_FUNCS(setbuf, [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SETBUF"]) - -dnl Check command-line options - -CheckVisibilityHidden - -AC_ARG_ENABLE([music-cmd], -AC_HELP_STRING([--enable-music-cmd], [support an external music player [[default=yes]]]), - [], [enable_music_cmd=detect]) -if test "x$enable_music_cmd" != xno; then - AC_CHECK_FUNCS([fork vfork]) - if test "x$ac_cv_func_fork" = "xyes"; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_FORK" - elif test "x$ac_cv_func_vfork" = "xyes"; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_VFORK" - elif test "x$enable_music_cmd" = "xyes"; then - AC_MSG_ERROR([external music player not available on your platform]) - else - enable_music_cmd=no - fi - if test "x$enable_music_cmd" != xno; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_CMD" - fi -fi - -AC_ARG_ENABLE([music-wave], -AC_HELP_STRING([--enable-music-wave], [enable streaming WAVE music [[default=yes]]]), - [], [enable_music_wave=yes]) -if test x$enable_music_wave = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_WAV" -fi - -AC_ARG_ENABLE([music-mod], -AC_HELP_STRING([--enable-music-mod], [enable MOD music [[default=yes]]]), - [], [enable_music_mod=yes]) - -AC_ARG_ENABLE([music-mod-modplug], -AC_HELP_STRING([--enable-music-mod-modplug], [enable MOD music via modplug [[default=yes]]]), - [], [enable_music_mod_modplug=yes]) -AC_ARG_ENABLE([music-mod-modplug-shared], -AC_HELP_STRING([--enable-music-mod-modplug-shared], [dynamically load modplug library [[default=yes]]]), - [], [enable_music_mod_modplug_shared=yes]) -if test x$enable_music_mod = xyes -a x$enable_music_mod_modplug = xyes; then - PKG_CHECK_MODULES([MODPLUG], [libmodplug >= 0.8.8], [dnl - have_libmodplug_hdr=yes - have_libmodplug_lib=yes - ], [dnl - AC_CHECK_HEADER([libmodplug/modplug.h], [have_libmodplug_hdr=yes]) - AC_CHECK_LIB([modplug], [ModPlug_Load], [have_libmodplug_lib=yes;MODPLUG_LIBS="-lmodplug"]) - ]) - - if test x$have_libmodplug_hdr = xyes -a x$have_libmodplug_lib = xyes; then - have_libmodplug=yes - case "$host" in - *-*-darwin*) - modplug_lib=[`find_lib libmodplug.dylib`] - ;; - *-*-cygwin* | *-*-mingw32*) - modplug_lib=[`find_lib "libmodplug*.dll"`] - ;; - *) - modplug_lib=[`find_lib "libmodplug[0-9]*.so.*"`] - if test x$modplug_lib = x; then - modplug_lib=[`find_lib "libmodplug.so.*"`] - fi - ;; - esac - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MODPLUG $MODPLUG_CFLAGS" - if test x$enable_music_mod_modplug_shared = xyes && test x$modplug_lib != x; then - echo "-- dynamic libmodplug -> $modplug_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_DYNAMIC=\\\"$modplug_lib\\\"" - else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS" - fi - else - AC_MSG_WARN([*** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)]) - fi -fi - -AC_ARG_ENABLE([music-mod-mikmod], -AC_HELP_STRING([--enable-music-mod-mikmod], [enable MOD music via mikmod [[default=no]]]), - [], [enable_music_mod_mikmod=no]) -AC_ARG_ENABLE([music-mod-mikmod-shared], -AC_HELP_STRING([--enable-music-mod-mikmod-shared], [dynamically load mikmod library [[default=yes]]]), - [], [enable_music_mod_mikmod_shared=yes]) -if test x$enable_music_mod = xyes -a x$enable_music_mod_mikmod = xyes; then - have_libmikmod=no - libmikmod_maj=3 - libmikmod_min=1 - libmikmod_rev=10 - libmikmod_ver="$libmikmod_maj.$libmikmod_min.$libmikmod_rev" - CFLAGS_SAVED="$CFLAGS" - LIBS_SAVED="$LIBS" - AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no, [$PATH]) - if test "$LIBMIKMOD_CONFIG" != "no" ; then - CFLAGS="$CFLAGS `$LIBMIKMOD_CONFIG --cflags`" - LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`" - have_libmikmod=yes - AC_MSG_CHECKING([for libmikmod - version >= $libmikmod_ver]) - AC_TRY_RUN([ -#include "mikmod.h" -#include "stdio.h" - -int main(int argc, char **argv) -{ -long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion(); -/*printf("(%d.%d.%d) ",ver>>16,(ver>>8)&0xff,ver&0xff);*/ -if(ver>=((maj<<16)|(min<<8)|(rev))) { - printf("yes\n"); - return 0; -} -printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev); -return 1; -} -], [], [have_libmikmod=no], [echo $ac_n "cross compiling; assumed OK... $ac_c"]) - fi - - if test x$have_libmikmod = xyes; then - case "$host" in - *-*-darwin*) - mikmod_lib=[`find_lib libmikmod.dylib`] - ;; - *-*-cygwin* | *-*-mingw32*) - mikmod_lib=[`find_lib "libmikmod*.dll"`] - ;; - *) - mikmod_lib=[`find_lib "libmikmod[0-9]*.so.*"`] - if test x$mikmod_lib = x; then - mikmod_lib=[`find_lib "libmikmod.so.*"`] - fi - ;; - esac - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MIKMOD `$LIBMIKMOD_CONFIG --cflags`" - if test x$enable_music_mod_mikmod_shared = xyes && test x$mikmod_lib != x; then - echo "-- dynamic libmikmod -> $mikmod_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMIKMOD_DYNAMIC=\\\"$mikmod_lib\\\"" - else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`" - fi - else - AC_MSG_WARN([*** Unable to find MikMod library (http://mikmod.raphnet.net/)]) - fi - LIBS="$LIBS_SAVED" - CFLAGS="$CFLAGS_SAVED" -fi - -if test x$have_libmodplug != xyes -a x$have_libmikmod != xyes ; then - AC_MSG_WARN([MOD support disabled]) -fi - -AC_ARG_ENABLE([music-midi], -AC_HELP_STRING([--enable-music-midi], [enable MIDI music [[default=yes]]]), - [], [enable_music_midi=yes]) -if test x$enable_music_midi = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID" - AC_ARG_ENABLE([music-midi-timidity], -AC_HELP_STRING([--enable-music-midi-timidity], [enable timidity MIDI output [[default=yes]]]), - [], [enable_music_midi_timidity=yes]) - if test x$enable_music_midi_timidity = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_TIMIDITY -I\$(srcdir)/timidity" - SOURCES="$SOURCES $srcdir/timidity/*.c" - fi - AC_ARG_ENABLE([music-midi-native], -AC_HELP_STRING([--enable-music-midi-native], [enable native MIDI music output [[default=yes]]]), - [], [enable_music_midi_native=yes]) - if test x$enable_music_midi_native = xyes; then - use_music_midi_native=no - case "$host" in - *mingw32ce*) - use_music_midi_native=no - ;; - *-*-cygwin* | *-*-mingw32*) - use_music_midi_native=yes - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm" - ;; - *-*-darwin*) - use_music_midi_native=yes - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,CoreServices" - ;; - *-*-haiku*) - use_music_midi_native=yes_cpp - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmidi" - ;; - esac - if test x$use_music_midi_native = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi" - SOURCES="$SOURCES $srcdir/native_midi/*.c" - elif test x$use_music_midi_native = xyes_cpp; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi" - SOURCES="$SOURCES $srcdir/native_midi/*.c" - SOURCES_CXX="$SOURCES_CXX $srcdir/native_midi/*.cpp" - fi - fi - AC_ARG_ENABLE([music-midi-fluidsynth], -AC_HELP_STRING([--enable-music-midi-fluidsynth], [enable FluidSynth MIDI output [[default=yes]]]), - [], [enable_music_midi_fluidsynth=yes]) - AC_ARG_ENABLE([music-midi-fluidsynth-shared], -AC_HELP_STRING([--enable-music-midi-fluidsynth-shared], [dynamically load FluidSynth library [[default=yes]]]), - [], [enable_music_midi_fluidsynth_shared=yes]) - if test x$enable_music_midi_fluidsynth = xyes; then - AC_CHECK_HEADER([fluidsynth.h], [have_fluidsynth_hdr=yes]) - AC_CHECK_LIB([fluidsynth], [fluid_player_add_mem], [have_fluidsynth_lib=yes]) - if test x$have_fluidsynth_hdr = xyes -a x$have_fluidsynth_lib = xyes; then - have_fluidsynth=yes - case "$host" in - *-*-darwin*) - fluidsynth_lib=[`find_lib libfluidsynth.dylib`] - ;; - *-*-cygwin* | *-*-mingw32*) - fluidsynth_lib=[`find_lib "fluidsynth*.dll"`] - ;; - *) - fluidsynth_lib=[`find_lib "libfluidsynth[0-9]*.so.*"`] - if test x$fluidsynth_lib = x; then - fluidsynth_lib=[`find_lib "libfluidsynth.so.*"`] - fi - ;; - esac - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_FLUIDSYNTH" - if test x$enable_music_midi_fluidsynth_shared = xyes && test x$fluidsynth_lib != x; then - echo "-- dynamic libfluidsynth -> $fluidsynth_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLUIDSYNTH_DYNAMIC=\\\"$fluidsynth_lib\\\"" - else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lfluidsynth" - fi - else - AC_MSG_WARN([*** Unable to find FluidSynth library (http://www.fluidsynth.org/)]) - AC_MSG_WARN([FluidSynth support disabled]) - fi - fi -fi - -if test x$enable_music_midi_timidity != xyes -a \ - x$use_music_midi_native != xyes -a x$use_music_midi_native != xyes_cpp -a \ - x$have_fluidsynth != xyes; then - AC_MSG_WARN([MIDI support disabled]) -fi - -AC_ARG_ENABLE([music-ogg], -AC_HELP_STRING([--enable-music-ogg], [enable Ogg Vorbis music [[default=yes]]]), - [], [enable_music_ogg=yes]) -AC_ARG_ENABLE(music-ogg-tremor, -AC_HELP_STRING([--enable-music-ogg-tremor], [enable OGG Vorbis music via libtremor [[default=no]]]), - [], enable_music_ogg_tremor=no) -AC_ARG_ENABLE([music-ogg-shared], -AC_HELP_STRING([--enable-music-ogg-shared], [dynamically load Ogg Vorbis library [[default=yes]]]), - [], [enable_music_ogg_shared=yes]) -if test x$enable_music_ogg = xyes; then - LIBS_SAVED="$LIBS" - if test x$enable_music_ogg_tremor = xyes; then - AC_CHECK_HEADER([tremor/ivorbisfile.h], [have_tremor_hdr=yes]) - AC_CHECK_LIB([vorbisidec], [ov_open_callbacks], [have_tremor_lib=yes], [], [-logg]) - if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then - case "$host" in - *-*-darwin*) - ogg_lib=[`find_lib libvorbisidec.dylib`] - ;; - *-*-cygwin* | *-*-mingw32*) - ogg_lib=[`find_lib "vorbisidec*.dll"`] - ;; - *) - ogg_lib=[`find_lib "libvorbisidec[0-9]*.so.*"`] - if test x$ogg_lib = x; then - ogg_lib=[`find_lib "libvorbisidec.so.*"`] - fi - ;; - esac - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG -DOGG_USE_TREMOR" - if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then - echo "-- dynamic libvorbisidec -> $ogg_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\"" - else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec -lvorbis" - fi - else - AC_MSG_WARN([*** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)]) - AC_MSG_WARN([Ogg Vorbis support disabled]) - fi - else - AC_CHECK_HEADER([vorbis/vorbisfile.h], [have_ogg_hdr=yes]) - AC_CHECK_LIB([vorbisfile], [ov_open_callbacks], [have_ogg_lib=yes], [], [-lvorbis -logg -lm]) - if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then - case "$host" in - *-*-darwin*) - ogg_lib=[`find_lib libvorbisfile.dylib`] - ;; - *-*-cygwin* | *-*-mingw32*) - ogg_lib=[`find_lib "libvorbisfile*.dll"`] - ;; - *) - ogg_lib=[`find_lib "libvorbisfile[0-9]*.so.*"`] - if test x$ogg_lib = x; then - ogg_lib=[`find_lib "libvorbisfile.so.*"`] - fi - ;; - esac - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG" - if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then - echo "-- dynamic libvorbisfile -> $ogg_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\"" - else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis" - fi - else - AC_MSG_WARN([*** Unable to find Ogg Vorbis library (http://www.xiph.org/)]) - AC_MSG_WARN([Ogg Vorbis support disabled]) - fi - fi - LIBS="$LIBS_SAVED" -fi - -libflac_ver=8 -AC_ARG_ENABLE([music-flac], -AC_HELP_STRING([--enable-music-flac], [enable FLAC music [[default=yes]]]), - [], [enable_music_flac=yes]) -AC_ARG_ENABLE([music-flac-shared], -AC_HELP_STRING([--enable-music-flac-shared], - [dynamically load FLAC library [[default=yes]]]), - [], [enable_music_flac_shared=yes]) -if test x$enable_music_flac = xyes; then - AC_CHECK_HEADER([FLAC/export.h], [have_flac_export=yes]) - if test x$have_flac_export = xyes; then - LIBS_SAVED="$LIBS" - LIBS="-lFLAC" - AC_MSG_CHECKING([for libflac so-name version >= $libflac_ver]) - AC_TRY_COMPILE([ -#include "FLAC/export.h" -#include "stdio.h" -],[ -#if defined(FLAC_API_VERSION_CURRENT) && (FLAC_API_VERSION_CURRENT >= $libflac_ver) -#else -#error "old-flac" -#endif -], have_flac_ver=yes, have_flac_ver=no) - LIBS="$LIBS_SAVED" - AC_MSG_RESULT($have_flac_ver) - fi - - if test x$have_flac_ver = xyes; then - AC_CHECK_HEADER([FLAC/stream_decoder.h], [have_flac_hdr=yes]) - AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new], [have_flac_lib=yes]) - if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then - case "$host" in - *-*-darwin*) - flac_lib=[`find_lib libFLAC.dylib`] - ;; - *-*-cygwin* | *-*-mingw32*) - flac_lib=[`find_lib "libFLAC-*.dll"`] - ;; - *) - flac_lib=[`find_lib "libFLAC[0-9]*.so.*"`] - if test x$flac_lib = x; then - flac_lib=[`find_lib "libFLAC.so.*"`] - fi - ;; - esac - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_FLAC" - if test x$enable_music_flac_shared = xyes && test x$flac_lib != x; then - echo "-- dynamic libFLAC -> $flac_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_DYNAMIC=\\\"$flac_lib\\\"" - else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lFLAC" - fi - fi - else - AC_MSG_WARN([*** Unable to find FLAC library (http://flac.sourceforge.net/)]) - AC_MSG_WARN([FLAC support disabled]) - fi -fi - -AC_ARG_ENABLE(music-mp3, -AC_HELP_STRING([--enable-music-mp3], [enable MP3 music [[default=yes]]]), - [], enable_music_mp3=yes) - -AC_ARG_ENABLE(music-mp3-mad-gpl, -AC_HELP_STRING([--enable-music-mp3-mad-gpl], [enable MP3 music via libmad GPL code [[default=no]]]), - [], [enable_music_mp3_mad_gpl=no]) -AC_ARG_ENABLE(music-mp3-mad-gpl-dithering, -AC_HELP_STRING([--enable-music-mp3-mad-gpl-dithering], [enable MP3 music via libmad GPL code [[default=yes]]]), - [], [enable_music_mp3_mad_gpl_dithering=yes]) -if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_mad_gpl = xyes; then - AC_MSG_CHECKING(for libmad headers) - have_libmad=no - AC_TRY_COMPILE([ - #include "mad.h" - ],[ - ],[ - have_libmad=yes - ]) - AC_MSG_RESULT($have_libmad) - if test x$have_libmad = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD" - if test x$enable_music_mp3_mad_gpl_dithering = xyes; then - AC_MSG_WARN([*** Using GPL libmad and MP3 dithering routines, this build of SDL_mixer is now under the GPL]) - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD_GPL_DITHERING" - fi - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad" - else - AC_MSG_WARN([*** Unable to find MAD library (http://www.underbit.com/products/mad/)]) - fi -fi - -AC_ARG_ENABLE(music-mp3-mpg123, -AC_HELP_STRING([--enable-music-mp3-mpg123], [enable MP3 music via libmpg123 [[default=yes]]]), - [], [enable_music_mp3_mpg123=yes]) -AC_ARG_ENABLE([music-mp3-mpg123-shared], -AC_HELP_STRING([--enable-music-mp3-mpg123-shared], [dynamically load libmpg123 library [[default=yes]]]), - [], [enable_music_mp3_mpg123_shared=yes]) -if test x$enable_music_mp3_mpg123 = xyes; then - AC_CHECK_HEADER([mpg123.h], [have_mpg123_hdr=yes]) - AC_CHECK_LIB([mpg123], [mpg123_replace_reader_handle], [have_mpg123_lib=yes]) - if test x$have_mpg123_hdr = xyes -a x$have_mpg123_lib = xyes; then - have_libmpg123=yes - case "$host" in - *-*-darwin*) - mpg123_lib=[`find_lib libmpg123.dylib`] - ;; - *-*-cygwin* | *-*-mingw32*) - mpg123_lib=[`find_lib "libmpg123*.dll"`] - ;; - *) - mpg123_lib=[`find_lib "libmpg123.so.*"`] - ;; - esac - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MPG123" - if test x$enable_music_mp3_mpg123_shared = xyes && test x$mpg123_lib != x; then - echo "-- dynamic libmpg123 -> $mpg123_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMPG123_DYNAMIC=\\\"$mpg123_lib\\\"" - else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmpg123" - fi - else - AC_MSG_WARN([*** Unable to find mpg123 library (https://www.mpg123.de)]) - AC_MSG_WARN([mpg123 support disabled]) - fi -fi - -if test x$have_libmad = xyes -o x$have_libmpg123 = xyes; then - : -else - AC_MSG_WARN([MP3 support disabled]) -fi - -AC_ARG_ENABLE([music-opus], -AC_HELP_STRING([--enable-music-opus], [enable Opus music [[default=yes]]]), - [], [enable_music_opus=yes]) - -AC_ARG_ENABLE([music-opus-shared], -AC_HELP_STRING([--enable-music-opus-shared], [dynamically load opusfile library [[default=yes]]]), - [], [enable_music_opus_shared=yes]) -if test x$enable_music_opus = xyes; then - LIBS_SAVED="$LIBS" - PKG_CHECK_MODULES([OPUSFILE], [opusfile >= 0.2], [dnl - have_opusfile_hdr=yes - have_opusfile_lib=yes - ], [dnl - AC_CHECK_HEADER([opus/opusfile.h], [have_opusfile_hdr=yes]) - AC_CHECK_LIB([opusfile], [op_open_callbacks], [have_opusfile_lib=yes;OPUSFILE_LIBS="-lopusfile -lopus"], [], [-lopus -logg -lm]) - ]) - LIBS="$LIBS_SAVED" - - if test x$have_opusfile_hdr = xyes -a x$have_opusfile_lib = xyes; then - have_opusfile=yes - case "$host" in - *-*-darwin*) - opusfile_lib=[`find_lib libopusfile.dylib`] - ;; - *-*-cygwin* | *-*-mingw32*) - opusfile_lib=[`find_lib "libopusfile*.dll"`] - ;; - *) - opusfile_lib=[`find_lib "libopusfile[0-9]*.so.*"`] - if test x$opusfile_lib = x; then - opusfile_lib=[`find_lib "libopusfile.so.*"`] - fi - ;; - esac - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OPUS $OPUSFILE_CFLAGS" - if test x$enable_music_opus_shared = xyes && test x$opusfile_lib != x; then - echo "-- dynamic opusfile -> $opusfile_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DOPUS_DYNAMIC=\\\"$opusfile_lib\\\"" - else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS $OPUSFILE_LIBS" - fi - else - AC_MSG_WARN([*** Unable to find opusfile library (http://opus-codec.org/)]) - fi -fi - -EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBM" - -OBJECTS=`echo $SOURCES` -DEPENDS=`echo $SOURCES` -OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'` -DEPENDS=`echo "$DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\ -$(objects)/\2.lo: \1/\2.c\\ - \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'` - -OBJECTS_CXX=`echo $SOURCES_CXX` -DEPENDS_CXX=`echo $SOURCES_CXX` -OBJECTS_CXX=`echo "$OBJECTS_CXX" | sed 's,[[^ ]]*/\([[^ ]]*\)\.cpp,$(objects)/\1.lo,g'` -DEPENDS_CXX=`echo "$DEPENDS_CXX" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.cpp,\\ -$(objects)/\2.lo: \1/\2.cpp\\ - \$(LIBTOOL) --mode=compile \$(CXX) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'` -OBJECTS="$OBJECTS $OBJECTS_CXX" -DEPENDS="$DEPENDS $DEPENDS_CXX" -DEPENDS=`echo "$DEPENDS" | sed 's,\\$,\\\\$,g'` - -VERSION_OBJECTS=`echo $VERSION_SOURCES` -VERSION_DEPENDS=`echo $VERSION_SOURCES` -VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'` -VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.rc,\\ -$(objects)/\2.o: \1/\2.rc\\ - \$(WINDRES) \$< \$@,g'` -VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\\$,\\\\$,g'` - -PLAYWAVE_SOURCES="$srcdir/playwave.c" -PLAYWAVE_OBJECTS=`echo $PLAYWAVE_SOURCES` -PLAYWAVE_DEPENDS=`echo $PLAYWAVE_SOURCES` -PLAYWAVE_OBJECTS=`echo "$PLAYWAVE_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'` -PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\ -$(objects)/\2.lo: \1/\2.c\\ - \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'` -PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\\$,\\\\$,g'` - -PLAYMUS_SOURCES="$srcdir/playmus.c" -PLAYMUS_OBJECTS=`echo $PLAYMUS_SOURCES` -PLAYMUS_DEPENDS=`echo $PLAYMUS_SOURCES` -PLAYMUS_OBJECTS=`echo "$PLAYMUS_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'` -PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\ -$(objects)/\2.lo: \1/\2.c\\ - \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'` -PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\\$,\\\\$,g'` - -dnl Expand the sources and objects needed to build the library -AC_SUBST(ac_aux_dir) -AC_SUBST(OBJECTS) -AC_SUBST(VERSION_OBJECTS) -AC_SUBST(PLAYWAVE_OBJECTS) -AC_SUBST(PLAYMUS_OBJECTS) -AC_SUBST(BUILD_CFLAGS) -AC_SUBST(EXTRA_CFLAGS) -AC_SUBST(BUILD_LDFLAGS) -AC_SUBST(EXTRA_LDFLAGS) -AC_SUBST(EXE) -AC_SUBST(WINDRES) -AC_SUBST(SDL_VERSION) -AC_SUBST(SDL_CFLAGS) -AC_SUBST(SDL_LIBS) - -AC_OUTPUT([ -]) -AC_CONFIG_FILES([ - Makefile SDL2_mixer.spec SDL2_mixer.pc -]) -AC_CONFIG_COMMANDS([default], - [cat >>Makefile <<__EOF__ - -# Build rules for objects --include \$(OBJECTS:.lo=.d) -$DEPENDS -$VERSION_DEPENDS - --include \$(PLAYWAVE_OBJECTS:.lo=.d) -$PLAYWAVE_DEPENDS - --include \$(PLAYMUS_OBJECTS:.lo=.d) -$PLAYMUS_DEPENDS -__EOF__ -], [ -DEPENDS="$DEPENDS" -VERSION_DEPENDS="$VERSION_DEPENDS" -PLAYWAVE_DEPENDS="$PLAYWAVE_DEPENDS" -PLAYMUS_DEPENDS="$PLAYMUS_DEPENDS" -]) -AC_OUTPUT diff --git a/effect_position.c b/effect_position.c deleted file mode 100644 index d532e74..0000000 --- a/effect_position.c +++ /dev/null @@ -1,2049 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - This file by Ryan C. Gordon (icculus@icculus.org) - - These are some internally supported special effects that use SDL_mixer's - effect callback API. They are meant for speed over quality. :) -*/ - -/* $Id$ */ - -#include -#include -#include - -#include "SDL.h" -#include "SDL_endian.h" -#include "SDL_mixer.h" -#include "mixer.h" - -#define __MIX_INTERNAL_EFFECT__ -#include "effects_internal.h" - -/* profile code: - #include - #include - struct timeval tv1; - struct timeval tv2; - - gettimeofday(&tv1, NULL); - - ... do your thing here ... - - gettimeofday(&tv2, NULL); - printf("%ld\n", tv2.tv_usec - tv1.tv_usec); -*/ - - -/* - * Positional effects...panning, distance attenuation, etc. - */ - -typedef struct _Eff_positionargs -{ - volatile float left_f; - volatile float right_f; - volatile Uint8 left_u8; - volatile Uint8 right_u8; - volatile float left_rear_f; - volatile float right_rear_f; - volatile float center_f; - volatile float lfe_f; - volatile Uint8 left_rear_u8; - volatile Uint8 right_rear_u8; - volatile Uint8 center_u8; - volatile Uint8 lfe_u8; - volatile float distance_f; - volatile Uint8 distance_u8; - volatile Sint16 room_angle; - volatile int in_use; - volatile int channels; -} position_args; - -static position_args **pos_args_array = NULL; -static position_args *pos_args_global = NULL; -static int position_channels = 0; - -void _Eff_PositionDeinit(void) -{ - int i; - for (i = 0; i < position_channels; i++) { - SDL_free(pos_args_array[i]); - } - - position_channels = 0; - - SDL_free(pos_args_global); - pos_args_global = NULL; - SDL_free(pos_args_array); - pos_args_array = NULL; -} - - -/* This just frees up the callback-specific data. */ -static void SDLCALL _Eff_PositionDone(int channel, void *udata) -{ - if (channel < 0) { - if (pos_args_global != NULL) { - SDL_free(pos_args_global); - pos_args_global = NULL; - } - } - - else if (pos_args_array[channel] != NULL) { - SDL_free(pos_args_array[channel]); - pos_args_array[channel] = NULL; - } -} - - -static void SDLCALL _Eff_position_u8(int chan, void *stream, int len, void *udata) -{ - volatile position_args *args = (volatile position_args *) udata; - Uint8 *ptr = (Uint8 *) stream; - int i; - - /* - * if there's only a mono channnel (the only way we wouldn't have - * a len divisible by 2 here), then left_f and right_f are always - * 1.0, and are therefore throwaways. - */ - if (len % sizeof (Uint16) != 0) { - *ptr = (Uint8) (((float) *ptr) * args->distance_f); - ptr++; - len--; - } - - if (args->room_angle == 180) - for (i = 0; i < len; i += sizeof (Uint8) * 2) { - /* must adjust the sample so that 0 is the center */ - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_f) * args->distance_f) + 128); - ptr++; - } - else for (i = 0; i < len; i += sizeof (Uint8) * 2) { - /* must adjust the sample so that 0 is the center */ - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_f) * args->distance_f) + 128); - ptr++; - } -} -static void SDLCALL _Eff_position_u8_c4(int chan, void *stream, int len, void *udata) -{ - volatile position_args *args = (volatile position_args *) udata; - Uint8 *ptr = (Uint8 *) stream; - int i; - - /* - * if there's only a mono channnel (the only way we wouldn't have - * a len divisible by 2 here), then left_f and right_f are always - * 1.0, and are therefore throwaways. - */ - if (len % sizeof (Uint16) != 0) { - *ptr = (Uint8) (((float) *ptr) * args->distance_f); - ptr++; - len--; - } - - if (args->room_angle == 0) - for (i = 0; i < len; i += sizeof (Uint8) * 6) { - /* must adjust the sample so that 0 is the center */ - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_rear_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_rear_f) * args->distance_f) + 128); - ptr++; - } - else if (args->room_angle == 90) - for (i = 0; i < len; i += sizeof (Uint8) * 6) { - /* must adjust the sample so that 0 is the center */ - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_rear_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_rear_f) * args->distance_f) + 128); - ptr++; - } - else if (args->room_angle == 180) - for (i = 0; i < len; i += sizeof (Uint8) * 6) { - /* must adjust the sample so that 0 is the center */ - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_rear_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_rear_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_f) * args->distance_f) + 128); - ptr++; - } - else if (args->room_angle == 270) - for (i = 0; i < len; i += sizeof (Uint8) * 6) { - /* must adjust the sample so that 0 is the center */ - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_rear_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_rear_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_f) * args->distance_f) + 128); - ptr++; - } -} - - -static void SDLCALL _Eff_position_u8_c6(int chan, void *stream, int len, void *udata) -{ - volatile position_args *args = (volatile position_args *) udata; - Uint8 *ptr = (Uint8 *) stream; - int i; - - /* - * if there's only a mono channnel (the only way we wouldn't have - * a len divisible by 2 here), then left_f and right_f are always - * 1.0, and are therefore throwaways. - */ - if (len % sizeof (Uint16) != 0) { - *ptr = (Uint8) (((float) *ptr) * args->distance_f); - ptr++; - len--; - } - - if (args->room_angle == 0) - for (i = 0; i < len; i += sizeof (Uint8) * 6) { - /* must adjust the sample so that 0 is the center */ - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_rear_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_rear_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->center_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->lfe_f) * args->distance_f) + 128); - ptr++; - } - else if (args->room_angle == 90) - for (i = 0; i < len; i += sizeof (Uint8) * 6) { - /* must adjust the sample so that 0 is the center */ - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_rear_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_rear_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_rear_f) * args->distance_f/2) + 128) - + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_f) * args->distance_f/2) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->lfe_f) * args->distance_f) + 128); - ptr++; - } - else if (args->room_angle == 180) - for (i = 0; i < len; i += sizeof (Uint8) * 6) { - /* must adjust the sample so that 0 is the center */ - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_rear_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_rear_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_rear_f) * args->distance_f/2) + 128) - + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_rear_f) * args->distance_f/2) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->lfe_f) * args->distance_f) + 128); - ptr++; - } - else if (args->room_angle == 270) - for (i = 0; i < len; i += sizeof (Uint8) * 6) { - /* must adjust the sample so that 0 is the center */ - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_rear_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_rear_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->right_f) * args->distance_f) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_f) * args->distance_f/2) + 128) - + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->left_rear_f) * args->distance_f/2) + 128); - ptr++; - *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) - * args->lfe_f) * args->distance_f) + 128); - ptr++; - } -} - - -/* - * This one runs about 10.1 times faster than the non-table version, with - * no loss in quality. It does, however, require 64k of memory for the - * lookup table. Also, this will only update position information once per - * call; the non-table version always checks the arguments for each sample, - * in case the user has called Mix_SetPanning() or whatnot again while this - * callback is running. - */ -static void SDLCALL _Eff_position_table_u8(int chan, void *stream, int len, void *udata) -{ - volatile position_args *args = (volatile position_args *) udata; - Uint8 *ptr = (Uint8 *) stream; - Uint32 *p; - int i; - Uint8 *l = ((Uint8 *) _Eff_volume_table) + (256 * args->left_u8); - Uint8 *r = ((Uint8 *) _Eff_volume_table) + (256 * args->right_u8); - Uint8 *d = ((Uint8 *) _Eff_volume_table) + (256 * args->distance_u8); - - if (args->room_angle == 180) { - Uint8 *temp = l; - l = r; - r = temp; - } - /* - * if there's only a mono channnel, then l[] and r[] are always - * volume 255, and are therefore throwaways. Still, we have to - * be sure not to overrun the audio buffer... - */ - while (len % sizeof (Uint32) != 0) { - *ptr = d[l[*ptr]]; - ptr++; - if (args->channels > 1) { - *ptr = d[r[*ptr]]; - ptr++; - } - len -= args->channels; - } - - p = (Uint32 *) ptr; - - for (i = 0; i < len; i += sizeof (Uint32)) { -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - *p = (d[l[(*p & 0xFF000000) >> 24]] << 24) | - (d[r[(*p & 0x00FF0000) >> 16]] << 16) | - (d[l[(*p & 0x0000FF00) >> 8]] << 8) | - (d[r[(*p & 0x000000FF) ]] ) ; -#else - *p = (d[r[(*p & 0xFF000000) >> 24]] << 24) | - (d[l[(*p & 0x00FF0000) >> 16]] << 16) | - (d[r[(*p & 0x0000FF00) >> 8]] << 8) | - (d[l[(*p & 0x000000FF) ]] ) ; -#endif - ++p; - } -} - - -static void SDLCALL _Eff_position_s8(int chan, void *stream, int len, void *udata) -{ - volatile position_args *args = (volatile position_args *) udata; - Sint8 *ptr = (Sint8 *) stream; - int i; - - /* - * if there's only a mono channnel (the only way we wouldn't have - * a len divisible by 2 here), then left_f and right_f are always - * 1.0, and are therefore throwaways. - */ - if (len % sizeof (Sint16) != 0) { - *ptr = (Sint8) (((float) *ptr) * args->distance_f); - ptr++; - len--; - } - - if (args->room_angle == 180) - for (i = 0; i < len; i += sizeof (Sint8) * 2) { - *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); - ptr++; - *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); - ptr++; - } - else - for (i = 0; i < len; i += sizeof (Sint8) * 2) { - *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); - ptr++; - *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); - ptr++; - } -} -static void SDLCALL _Eff_position_s8_c4(int chan, void *stream, int len, void *udata) -{ - volatile position_args *args = (volatile position_args *) udata; - Sint8 *ptr = (Sint8 *) stream; - int i; - - /* - * if there's only a mono channnel (the only way we wouldn't have - * a len divisible by 2 here), then left_f and right_f are always - * 1.0, and are therefore throwaways. - */ - if (len % sizeof (Sint16) != 0) { - *ptr = (Sint8) (((float) *ptr) * args->distance_f); - ptr++; - len--; - } - - for (i = 0; i < len; i += sizeof (Sint8) * 4) { - switch (args->room_angle) { - case 0: - *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++; - break; - case 90: - *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++; - break; - case 180: - *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++; - break; - case 270: - *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++; - break; - } - } -} -static void SDLCALL _Eff_position_s8_c6(int chan, void *stream, int len, void *udata) -{ - volatile position_args *args = (volatile position_args *) udata; - Sint8 *ptr = (Sint8 *) stream; - int i; - - /* - * if there's only a mono channnel (the only way we wouldn't have - * a len divisible by 2 here), then left_f and right_f are always - * 1.0, and are therefore throwaways. - */ - if (len % sizeof (Sint16) != 0) { - *ptr = (Sint8) (((float) *ptr) * args->distance_f); - ptr++; - len--; - } - - for (i = 0; i < len; i += sizeof (Sint8) * 6) { - switch (args->room_angle) { - case 0: - *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->center_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++; - break; - case 90: - *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f / 2) - + (Sint8)((((float) *ptr) * args->right_f) * args->distance_f / 2); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++; - break; - case 180: - *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f / 2) - + (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f / 2); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++; - break; - case 270: - *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f / 2) - + (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f / 2); ptr++; - *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++; - break; - } - } -} - - -/* - * This one runs about 10.1 times faster than the non-table version, with - * no loss in quality. It does, however, require 64k of memory for the - * lookup table. Also, this will only update position information once per - * call; the non-table version always checks the arguments for each sample, - * in case the user has called Mix_SetPanning() or whatnot again while this - * callback is running. - */ -static void SDLCALL _Eff_position_table_s8(int chan, void *stream, int len, void *udata) -{ - volatile position_args *args = (volatile position_args *) udata; - Sint8 *ptr = (Sint8 *) stream; - Uint32 *p; - int i; - Sint8 *l = ((Sint8 *) _Eff_volume_table) + (256 * args->left_u8); - Sint8 *r = ((Sint8 *) _Eff_volume_table) + (256 * args->right_u8); - Sint8 *d = ((Sint8 *) _Eff_volume_table) + (256 * args->distance_u8); - - if (args->room_angle == 180) { - Sint8 *temp = l; - l = r; - r = temp; - } - - - while (len % sizeof (Uint32) != 0) { - *ptr = d[l[*ptr]]; - ptr++; - if (args->channels > 1) { - *ptr = d[r[*ptr]]; - ptr++; - } - len -= args->channels; - } - - p = (Uint32 *) ptr; - - for (i = 0; i < len; i += sizeof (Uint32)) { -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - *p = (d[l[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) | - (d[r[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) | - (d[l[((Sint16)(Sint8)((*p & 0x0000FF00) >> 8))+128]] << 8) | - (d[r[((Sint16)(Sint8)((*p & 0x000000FF) ))+128]] ) ; -#else - *p = (d[r[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) | - (d[l[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) | - (d[r[((Sint16)(Sint8)((*p & 0x0000FF00) >> 8))+128]] << 8) | - (d[l[((Sint16)(Sint8)((*p & 0x000000FF) ))+128]] ) ; -#endif - ++p; - } - - -} - - -/* !!! FIXME : Optimize the code for 16-bit samples? */ - -static void SDLCALL _Eff_position_u16lsb(int chan, void *stream, int len, void *udata) -{ - volatile position_args *args = (volatile position_args *) udata; - Uint16 *ptr = (Uint16 *) stream; - int i; - - for (i = 0; i < len; i += sizeof (Uint16) * 2) { - Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768); - Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768); - - Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f) - * args->distance_f) + 32768); - Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f) - * args->distance_f) + 32768); - - if (args->room_angle == 180) { - *(ptr++) = (Uint16) SDL_SwapLE16(swapr); - *(ptr++) = (Uint16) SDL_SwapLE16(swapl); - } - else { - *(ptr++) = (Uint16) SDL_SwapLE16(swapl); - *(ptr++) = (Uint16) SDL_SwapLE16(swapr); - } - } -} -static void SDLCALL _Eff_position_u16lsb_c4(int chan, void *stream, int len, void *udata) -{ - volatile position_args *args = (volatile position_args *) udata; - Uint16 *ptr = (Uint16 *) stream; - int i; - - for (i = 0; i < len; i += sizeof (Uint16) * 4) { - Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768); - Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768); - Sint16 samplr = (Sint16) (SDL_SwapLE16(*(ptr+2)) - 32768); - Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768); - - Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f) - * args->distance_f) + 32768); - Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f) - * args->distance_f) + 32768); - Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f) - * args->distance_f) + 32768); - Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f) - * args->distance_f) + 32768); - - switch (args->room_angle) { - case 0: - *(ptr++) = (Uint16) SDL_SwapLE16(swapl); - *(ptr++) = (Uint16) SDL_SwapLE16(swapr); - *(ptr++) = (Uint16) SDL_SwapLE16(swaplr); - *(ptr++) = (Uint16) SDL_SwapLE16(swaprr); - break; - case 90: - *(ptr++) = (Uint16) SDL_SwapLE16(swapr); - *(ptr++) = (Uint16) SDL_SwapLE16(swaprr); - *(ptr++) = (Uint16) SDL_SwapLE16(swapl); - *(ptr++) = (Uint16) SDL_SwapLE16(swaplr); - break; - case 180: - *(ptr++) = (Uint16) SDL_SwapLE16(swaprr); - *(ptr++) = (Uint16) SDL_SwapLE16(swaplr); - *(ptr++) = (Uint16) SDL_SwapLE16(swapr); - *(ptr++) = (Uint16) SDL_SwapLE16(swapl); - break; - case 270: - *(ptr++) = (Uint16) SDL_SwapLE16(swaplr); - *(ptr++) = (Uint16) SDL_SwapLE16(swapl); - *(ptr++) = (Uint16) SDL_SwapLE16(swaprr); - *(ptr++) = (Uint16) SDL_SwapLE16(swapr); - break; - } - } -} -static void SDLCALL _Eff_position_u16lsb_c6(int chan, void *stream, int len, void *udata) -{ - volatile position_args *args = (volatile position_args *) udata; - Uint16 *ptr = (Uint16 *) stream; - int i; - - for (i = 0; i < len; i += sizeof (Uint16) * 6) { - Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768); - Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768); - Sint16 samplr = (Sint16) (SDL_SwapLE16(*(ptr+2)) - 32768); - Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768); - Sint16 sampce = (Sint16) (SDL_SwapLE16(*(ptr+4)) - 32768); - Sint16 sampwf = (Sint16) (SDL_SwapLE16(*(ptr+5)) - 32768); - - Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f) - * args->distance_f) + 32768); - Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f) - * args->distance_f) + 32768); - Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f) - * args->distance_f) + 32768); - Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f) - * args->distance_f) + 32768); - Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f) - * args->distance_f) + 32768); - Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f) - * args->distance_f) + 32768); - - switch (args->room_angle) { - case 0: - *(ptr++) = (Uint16) SDL_SwapLE16(swapl); - *(ptr++) = (Uint16) SDL_SwapLE16(swapr); - *(ptr++) = (Uint16) SDL_SwapLE16(swaplr); - *(ptr++) = (Uint16) SDL_SwapLE16(swaprr); - *(ptr++) = (Uint16) SDL_SwapLE16(swapce); - *(ptr++) = (Uint16) SDL_SwapLE16(swapwf); - break; - case 90: - *(ptr++) = (Uint16) SDL_SwapLE16(swapr); - *(ptr++) = (Uint16) SDL_SwapLE16(swaprr); - *(ptr++) = (Uint16) SDL_SwapLE16(swapl); - *(ptr++) = (Uint16) SDL_SwapLE16(swaplr); - *(ptr++) = (Uint16) SDL_SwapLE16(swapr)/2 + (Uint16) SDL_SwapLE16(swaprr)/2; - *(ptr++) = (Uint16) SDL_SwapLE16(swapwf); - break; - case 180: - *(ptr++) = (Uint16) SDL_SwapLE16(swaprr); - *(ptr++) = (Uint16) SDL_SwapLE16(swaplr); - *(ptr++) = (Uint16) SDL_SwapLE16(swapr); - *(ptr++) = (Uint16) SDL_SwapLE16(swapl); - *(ptr++) = (Uint16) SDL_SwapLE16(swaprr)/2 + (Uint16) SDL_SwapLE16(swaplr)/2; - *(ptr++) = (Uint16) SDL_SwapLE16(swapwf); - break; - case 270: - *(ptr++) = (Uint16) SDL_SwapLE16(swaplr); - *(ptr++) = (Uint16) SDL_SwapLE16(swapl); - *(ptr++) = (Uint16) SDL_SwapLE16(swaprr); - *(ptr++) = (Uint16) SDL_SwapLE16(swapr); - *(ptr++) = (Uint16) SDL_SwapLE16(swapl)/2 + (Uint16) SDL_SwapLE16(swaplr)/2; - *(ptr++) = (Uint16) SDL_SwapLE16(swapwf); - break; - } - } -} - -static void SDLCALL _Eff_position_s16lsb(int chan, void *stream, int len, void *udata) -{ - /* 16 signed bits (lsb) * 2 channels. */ - volatile position_args *args = (volatile position_args *) udata; - Sint16 *ptr = (Sint16 *) stream; - int i; - -#if 0 - if (len % (sizeof(Sint16) * 2)) { - fprintf(stderr,"Not an even number of frames! len=%d\n", len); - return; - } -#endif - - for (i = 0; i < len; i += sizeof (Sint16) * 2) { - Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) * - args->left_f) * args->distance_f); - Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) * - args->right_f) * args->distance_f); - if (args->room_angle == 180) { - *(ptr++) = (Sint16) SDL_SwapLE16(swapr); - *(ptr++) = (Sint16) SDL_SwapLE16(swapl); - } - else { - *(ptr++) = (Sint16) SDL_SwapLE16(swapl); - *(ptr++) = (Sint16) SDL_SwapLE16(swapr); - } - } -} -static void SDLCALL _Eff_position_s16lsb_c4(int chan, void *stream, int len, void *udata) -{ - /* 16 signed bits (lsb) * 4 channels. */ - volatile position_args *args = (volatile position_args *) udata; - Sint16 *ptr = (Sint16 *) stream; - int i; - - for (i = 0; i < len; i += sizeof (Sint16) * 4) { - Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) * - args->left_f) * args->distance_f); - Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) * - args->right_f) * args->distance_f); - Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) * - args->left_rear_f) * args->distance_f); - Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+2))) * - args->right_rear_f) * args->distance_f); - switch (args->room_angle) { - case 0: - *(ptr++) = (Sint16) SDL_SwapLE16(swapl); - *(ptr++) = (Sint16) SDL_SwapLE16(swapr); - *(ptr++) = (Sint16) SDL_SwapLE16(swaplr); - *(ptr++) = (Sint16) SDL_SwapLE16(swaprr); - break; - case 90: - *(ptr++) = (Sint16) SDL_SwapLE16(swapr); - *(ptr++) = (Sint16) SDL_SwapLE16(swaprr); - *(ptr++) = (Sint16) SDL_SwapLE16(swapl); - *(ptr++) = (Sint16) SDL_SwapLE16(swaplr); - break; - case 180: - *(ptr++) = (Sint16) SDL_SwapLE16(swaprr); - *(ptr++) = (Sint16) SDL_SwapLE16(swaplr); - *(ptr++) = (Sint16) SDL_SwapLE16(swapr); - *(ptr++) = (Sint16) SDL_SwapLE16(swapl); - break; - case 270: - *(ptr++) = (Sint16) SDL_SwapLE16(swaplr); - *(ptr++) = (Sint16) SDL_SwapLE16(swapl); - *(ptr++) = (Sint16) SDL_SwapLE16(swaprr); - *(ptr++) = (Sint16) SDL_SwapLE16(swapr); - break; - } - } -} - -static void SDLCALL _Eff_position_s16lsb_c6(int chan, void *stream, int len, void *udata) -{ - /* 16 signed bits (lsb) * 6 channels. */ - volatile position_args *args = (volatile position_args *) udata; - Sint16 *ptr = (Sint16 *) stream; - int i; - - for (i = 0; i < len; i += sizeof (Sint16) * 6) { - Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) * - args->left_f) * args->distance_f); - Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) * - args->right_f) * args->distance_f); - Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+2))) * - args->left_rear_f) * args->distance_f); - Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+3))) * - args->right_rear_f) * args->distance_f); - Sint16 swapce = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+4))) * - args->center_f) * args->distance_f); - Sint16 swapwf = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+5))) * - args->lfe_f) * args->distance_f); - switch (args->room_angle) { - case 0: - *(ptr++) = (Sint16) SDL_SwapLE16(swapl); - *(ptr++) = (Sint16) SDL_SwapLE16(swapr); - *(ptr++) = (Sint16) SDL_SwapLE16(swaplr); - *(ptr++) = (Sint16) SDL_SwapLE16(swaprr); - *(ptr++) = (Sint16) SDL_SwapLE16(swapce); - *(ptr++) = (Sint16) SDL_SwapLE16(swapwf); - break; - case 90: - *(ptr++) = (Sint16) SDL_SwapLE16(swapr); - *(ptr++) = (Sint16) SDL_SwapLE16(swaprr); - *(ptr++) = (Sint16) SDL_SwapLE16(swapl); - *(ptr++) = (Sint16) SDL_SwapLE16(swaplr); - *(ptr++) = (Sint16) SDL_SwapLE16(swapr)/2 + (Sint16) SDL_SwapLE16(swaprr)/2; - *(ptr++) = (Sint16) SDL_SwapLE16(swapwf); - break; - case 180: - *(ptr++) = (Sint16) SDL_SwapLE16(swaprr); - *(ptr++) = (Sint16) SDL_SwapLE16(swaplr); - *(ptr++) = (Sint16) SDL_SwapLE16(swapr); - *(ptr++) = (Sint16) SDL_SwapLE16(swapl); - *(ptr++) = (Sint16) SDL_SwapLE16(swaprr)/2 + (Sint16) SDL_SwapLE16(swaplr)/2; - *(ptr++) = (Sint16) SDL_SwapLE16(swapwf); - break; - case 270: - *(ptr++) = (Sint16) SDL_SwapLE16(swaplr); - *(ptr++) = (Sint16) SDL_SwapLE16(swapl); - *(ptr++) = (Sint16) SDL_SwapLE16(swaprr); - *(ptr++) = (Sint16) SDL_SwapLE16(swapr); - *(ptr++) = (Sint16) SDL_SwapLE16(swapl)/2 + (Sint16) SDL_SwapLE16(swaplr)/2; - *(ptr++) = (Sint16) SDL_SwapLE16(swapwf); - break; - } - } -} - -static void SDLCALL _Eff_position_u16msb(int chan, void *stream, int len, void *udata) -{ - /* 16 signed bits (lsb) * 2 channels. */ - volatile position_args *args = (volatile position_args *) udata; - Uint16 *ptr = (Uint16 *) stream; - int i; - - for (i = 0; i < len; i += sizeof (Sint16) * 2) { - Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768); - Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768); - - Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f) - * args->distance_f) + 32768); - Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f) - * args->distance_f) + 32768); - - if (args->room_angle == 180) { - *(ptr++) = (Uint16) SDL_SwapBE16(swapr); - *(ptr++) = (Uint16) SDL_SwapBE16(swapl); - } - else { - *(ptr++) = (Uint16) SDL_SwapBE16(swapl); - *(ptr++) = (Uint16) SDL_SwapBE16(swapr); - } - } -} -static void SDLCALL _Eff_position_u16msb_c4(int chan, void *stream, int len, void *udata) -{ - /* 16 signed bits (lsb) * 4 channels. */ - volatile position_args *args = (volatile position_args *) udata; - Uint16 *ptr = (Uint16 *) stream; - int i; - - for (i = 0; i < len; i += sizeof (Sint16) * 4) { - Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768); - Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768); - Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768); - Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768); - - Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f) - * args->distance_f) + 32768); - Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f) - * args->distance_f) + 32768); - Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f) - * args->distance_f) + 32768); - Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f) - * args->distance_f) + 32768); - - switch (args->room_angle) { - case 0: - *(ptr++) = (Uint16) SDL_SwapBE16(swapl); - *(ptr++) = (Uint16) SDL_SwapBE16(swapr); - *(ptr++) = (Uint16) SDL_SwapBE16(swaplr); - *(ptr++) = (Uint16) SDL_SwapBE16(swaprr); - break; - case 90: - *(ptr++) = (Uint16) SDL_SwapBE16(swapr); - *(ptr++) = (Uint16) SDL_SwapBE16(swaprr); - *(ptr++) = (Uint16) SDL_SwapBE16(swapl); - *(ptr++) = (Uint16) SDL_SwapBE16(swaplr); - break; - case 180: - *(ptr++) = (Uint16) SDL_SwapBE16(swaprr); - *(ptr++) = (Uint16) SDL_SwapBE16(swaplr); - *(ptr++) = (Uint16) SDL_SwapBE16(swapr); - *(ptr++) = (Uint16) SDL_SwapBE16(swapl); - break; - case 270: - *(ptr++) = (Uint16) SDL_SwapBE16(swaplr); - *(ptr++) = (Uint16) SDL_SwapBE16(swapl); - *(ptr++) = (Uint16) SDL_SwapBE16(swaprr); - *(ptr++) = (Uint16) SDL_SwapBE16(swapr); - break; - } - } -} -static void SDLCALL _Eff_position_u16msb_c6(int chan, void *stream, int len, void *udata) -{ - /* 16 signed bits (lsb) * 6 channels. */ - volatile position_args *args = (volatile position_args *) udata; - Uint16 *ptr = (Uint16 *) stream; - int i; - - for (i = 0; i < len; i += sizeof (Sint16) * 6) { - Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768); - Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768); - Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768); - Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768); - Sint16 sampce = (Sint16) (SDL_SwapBE16(*(ptr+4)) - 32768); - Sint16 sampwf = (Sint16) (SDL_SwapBE16(*(ptr+5)) - 32768); - - Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f) - * args->distance_f) + 32768); - Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f) - * args->distance_f) + 32768); - Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f) - * args->distance_f) + 32768); - Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f) - * args->distance_f) + 32768); - Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f) - * args->distance_f) + 32768); - Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f) - * args->distance_f) + 32768); - - switch (args->room_angle) { - case 0: - *(ptr++) = (Uint16) SDL_SwapBE16(swapl); - *(ptr++) = (Uint16) SDL_SwapBE16(swapr); - *(ptr++) = (Uint16) SDL_SwapBE16(swaplr); - *(ptr++) = (Uint16) SDL_SwapBE16(swaprr); - *(ptr++) = (Uint16) SDL_SwapBE16(swapce); - *(ptr++) = (Uint16) SDL_SwapBE16(swapwf); - break; - case 90: - *(ptr++) = (Uint16) SDL_SwapBE16(swapr); - *(ptr++) = (Uint16) SDL_SwapBE16(swaprr); - *(ptr++) = (Uint16) SDL_SwapBE16(swapl); - *(ptr++) = (Uint16) SDL_SwapBE16(swaplr); - *(ptr++) = (Uint16) SDL_SwapBE16(swapr)/2 + (Uint16) SDL_SwapBE16(swaprr)/2; - *(ptr++) = (Uint16) SDL_SwapBE16(swapwf); - break; - case 180: - *(ptr++) = (Uint16) SDL_SwapBE16(swaprr); - *(ptr++) = (Uint16) SDL_SwapBE16(swaplr); - *(ptr++) = (Uint16) SDL_SwapBE16(swapr); - *(ptr++) = (Uint16) SDL_SwapBE16(swapl); - *(ptr++) = (Uint16) SDL_SwapBE16(swaprr)/2 + (Uint16) SDL_SwapBE16(swaplr)/2; - *(ptr++) = (Uint16) SDL_SwapBE16(swapwf); - break; - case 270: - *(ptr++) = (Uint16) SDL_SwapBE16(swaplr); - *(ptr++) = (Uint16) SDL_SwapBE16(swapl); - *(ptr++) = (Uint16) SDL_SwapBE16(swaprr); - *(ptr++) = (Uint16) SDL_SwapBE16(swapr); - *(ptr++) = (Uint16) SDL_SwapBE16(swapl)/2 + (Uint16) SDL_SwapBE16(swaplr)/2; - *(ptr++) = (Uint16) SDL_SwapBE16(swapwf); - break; - } - } -} - -static void SDLCALL _Eff_position_s16msb(int chan, void *stream, int len, void *udata) -{ - /* 16 signed bits (lsb) * 2 channels. */ - volatile position_args *args = (volatile position_args *) udata; - Sint16 *ptr = (Sint16 *) stream; - int i; - - for (i = 0; i < len; i += sizeof (Sint16) * 2) { - Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) * - args->left_f) * args->distance_f); - Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) * - args->right_f) * args->distance_f); - *(ptr++) = (Sint16) SDL_SwapBE16(swapl); - *(ptr++) = (Sint16) SDL_SwapBE16(swapr); - } -} -static void SDLCALL _Eff_position_s16msb_c4(int chan, void *stream, int len, void *udata) -{ - /* 16 signed bits (lsb) * 4 channels. */ - volatile position_args *args = (volatile position_args *) udata; - Sint16 *ptr = (Sint16 *) stream; - int i; - - for (i = 0; i < len; i += sizeof (Sint16) * 4) { - Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) * - args->left_f) * args->distance_f); - Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) * - args->right_f) * args->distance_f); - Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+2))) * - args->left_rear_f) * args->distance_f); - Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+3))) * - args->right_rear_f) * args->distance_f); - switch (args->room_angle) { - case 0: - *(ptr++) = (Sint16) SDL_SwapBE16(swapl); - *(ptr++) = (Sint16) SDL_SwapBE16(swapr); - *(ptr++) = (Sint16) SDL_SwapBE16(swaplr); - *(ptr++) = (Sint16) SDL_SwapBE16(swaprr); - break; - case 90: - *(ptr++) = (Sint16) SDL_SwapBE16(swapr); - *(ptr++) = (Sint16) SDL_SwapBE16(swaprr); - *(ptr++) = (Sint16) SDL_SwapBE16(swapl); - *(ptr++) = (Sint16) SDL_SwapBE16(swaplr); - break; - case 180: - *(ptr++) = (Sint16) SDL_SwapBE16(swaprr); - *(ptr++) = (Sint16) SDL_SwapBE16(swaplr); - *(ptr++) = (Sint16) SDL_SwapBE16(swapr); - *(ptr++) = (Sint16) SDL_SwapBE16(swapl); - break; - case 270: - *(ptr++) = (Sint16) SDL_SwapBE16(swaplr); - *(ptr++) = (Sint16) SDL_SwapBE16(swapl); - *(ptr++) = (Sint16) SDL_SwapBE16(swaprr); - *(ptr++) = (Sint16) SDL_SwapBE16(swapr); - break; - } - } -} -static void SDLCALL _Eff_position_s16msb_c6(int chan, void *stream, int len, void *udata) -{ - /* 16 signed bits (lsb) * 6 channels. */ - volatile position_args *args = (volatile position_args *) udata; - Sint16 *ptr = (Sint16 *) stream; - int i; - - for (i = 0; i < len; i += sizeof (Sint16) * 6) { - Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) * - args->left_f) * args->distance_f); - Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) * - args->right_f) * args->distance_f); - Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+2))) * - args->left_rear_f) * args->distance_f); - Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+3))) * - args->right_rear_f) * args->distance_f); - Sint16 swapce = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+4))) * - args->center_f) * args->distance_f); - Sint16 swapwf = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+5))) * - args->lfe_f) * args->distance_f); - - switch (args->room_angle) { - case 0: - *(ptr++) = (Sint16) SDL_SwapBE16(swapl); - *(ptr++) = (Sint16) SDL_SwapBE16(swapr); - *(ptr++) = (Sint16) SDL_SwapBE16(swaplr); - *(ptr++) = (Sint16) SDL_SwapBE16(swaprr); - *(ptr++) = (Sint16) SDL_SwapBE16(swapce); - *(ptr++) = (Sint16) SDL_SwapBE16(swapwf); - break; - case 90: - *(ptr++) = (Sint16) SDL_SwapBE16(swapr); - *(ptr++) = (Sint16) SDL_SwapBE16(swaprr); - *(ptr++) = (Sint16) SDL_SwapBE16(swapl); - *(ptr++) = (Sint16) SDL_SwapBE16(swaplr); - *(ptr++) = (Sint16) SDL_SwapBE16(swapr)/2 + (Sint16) SDL_SwapBE16(swaprr)/2; - *(ptr++) = (Sint16) SDL_SwapBE16(swapwf); - break; - case 180: - *(ptr++) = (Sint16) SDL_SwapBE16(swaprr); - *(ptr++) = (Sint16) SDL_SwapBE16(swaplr); - *(ptr++) = (Sint16) SDL_SwapBE16(swapr); - *(ptr++) = (Sint16) SDL_SwapBE16(swapl); - *(ptr++) = (Sint16) SDL_SwapBE16(swaprr)/2 + (Sint16) SDL_SwapBE16(swaplr)/2; - *(ptr++) = (Sint16) SDL_SwapBE16(swapwf); - break; - case 270: - *(ptr++) = (Sint16) SDL_SwapBE16(swaplr); - *(ptr++) = (Sint16) SDL_SwapBE16(swapl); - *(ptr++) = (Sint16) SDL_SwapBE16(swaprr); - *(ptr++) = (Sint16) SDL_SwapBE16(swapr); - *(ptr++) = (Sint16) SDL_SwapBE16(swapl)/2 + (Sint16) SDL_SwapBE16(swaplr)/2; - *(ptr++) = (Sint16) SDL_SwapBE16(swapwf); - break; - } - } -} - -static void SDLCALL _Eff_position_s32lsb(int chan, void *stream, int len, void *udata) -{ - /* 32 signed bits (lsb) * 2 channels. */ - volatile position_args *args = (volatile position_args *) udata; - Sint32 *ptr = (Sint32 *) stream; - int i; - -#if 0 - if (len % (sizeof(Sint32) * 2)) { - fprintf(stderr,"Not an even number of frames! len=%d\n", len); - return; - } -#endif - - for (i = 0; i < len; i += sizeof (Sint32) * 2) { - Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) * - args->left_f) * args->distance_f); - Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) * - args->right_f) * args->distance_f); - if (args->room_angle == 180) { - *(ptr++) = (Sint32) SDL_SwapLE32(swapr); - *(ptr++) = (Sint32) SDL_SwapLE32(swapl); - } - else { - *(ptr++) = (Sint32) SDL_SwapLE32(swapl); - *(ptr++) = (Sint32) SDL_SwapLE32(swapr); - } - } -} -static void SDLCALL _Eff_position_s32lsb_c4(int chan, void *stream, int len, void *udata) -{ - /* 32 signed bits (lsb) * 4 channels. */ - volatile position_args *args = (volatile position_args *) udata; - Sint32 *ptr = (Sint32 *) stream; - int i; - - for (i = 0; i < len; i += sizeof (Sint32) * 4) { - Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) * - args->left_f) * args->distance_f); - Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) * - args->right_f) * args->distance_f); - Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) * - args->left_rear_f) * args->distance_f); - Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+2))) * - args->right_rear_f) * args->distance_f); - switch (args->room_angle) { - case 0: - *(ptr++) = (Sint32) SDL_SwapLE32(swapl); - *(ptr++) = (Sint32) SDL_SwapLE32(swapr); - *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); - *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); - break; - case 90: - *(ptr++) = (Sint32) SDL_SwapLE32(swapr); - *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); - *(ptr++) = (Sint32) SDL_SwapLE32(swapl); - *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); - break; - case 180: - *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); - *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); - *(ptr++) = (Sint32) SDL_SwapLE32(swapr); - *(ptr++) = (Sint32) SDL_SwapLE32(swapl); - break; - case 270: - *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); - *(ptr++) = (Sint32) SDL_SwapLE32(swapl); - *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); - *(ptr++) = (Sint32) SDL_SwapLE32(swapr); - break; - } - } -} - -static void SDLCALL _Eff_position_s32lsb_c6(int chan, void *stream, int len, void *udata) -{ - /* 32 signed bits (lsb) * 6 channels. */ - volatile position_args *args = (volatile position_args *) udata; - Sint32 *ptr = (Sint32 *) stream; - int i; - - for (i = 0; i < len; i += sizeof (Sint32) * 6) { - Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) * - args->left_f) * args->distance_f); - Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) * - args->right_f) * args->distance_f); - Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+2))) * - args->left_rear_f) * args->distance_f); - Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+3))) * - args->right_rear_f) * args->distance_f); - Sint32 swapce = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+4))) * - args->center_f) * args->distance_f); - Sint32 swapwf = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+5))) * - args->lfe_f) * args->distance_f); - switch (args->room_angle) { - case 0: - *(ptr++) = (Sint32) SDL_SwapLE32(swapl); - *(ptr++) = (Sint32) SDL_SwapLE32(swapr); - *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); - *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); - *(ptr++) = (Sint32) SDL_SwapLE32(swapce); - *(ptr++) = (Sint32) SDL_SwapLE32(swapwf); - break; - case 90: - *(ptr++) = (Sint32) SDL_SwapLE32(swapr); - *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); - *(ptr++) = (Sint32) SDL_SwapLE32(swapl); - *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); - *(ptr++) = (Sint32) SDL_SwapLE32(swapr)/2 + (Sint32) SDL_SwapLE32(swaprr)/2; - *(ptr++) = (Sint32) SDL_SwapLE32(swapwf); - break; - case 180: - *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); - *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); - *(ptr++) = (Sint32) SDL_SwapLE32(swapr); - *(ptr++) = (Sint32) SDL_SwapLE32(swapl); - *(ptr++) = (Sint32) SDL_SwapLE32(swaprr)/2 + (Sint32) SDL_SwapLE32(swaplr)/2; - *(ptr++) = (Sint32) SDL_SwapLE32(swapwf); - break; - case 270: - *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); - *(ptr++) = (Sint32) SDL_SwapLE32(swapl); - *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); - *(ptr++) = (Sint32) SDL_SwapLE32(swapr); - *(ptr++) = (Sint32) SDL_SwapLE32(swapl)/2 + (Sint32) SDL_SwapLE32(swaplr)/2; - *(ptr++) = (Sint32) SDL_SwapLE32(swapwf); - break; - } - } -} - -static void SDLCALL _Eff_position_s32msb(int chan, void *stream, int len, void *udata) -{ - /* 32 signed bits (lsb) * 2 channels. */ - volatile position_args *args = (volatile position_args *) udata; - Sint32 *ptr = (Sint32 *) stream; - int i; - - for (i = 0; i < len; i += sizeof (Sint32) * 2) { - Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) * - args->left_f) * args->distance_f); - Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) * - args->right_f) * args->distance_f); - *(ptr++) = (Sint32) SDL_SwapBE32(swapl); - *(ptr++) = (Sint32) SDL_SwapBE32(swapr); - } -} -static void SDLCALL _Eff_position_s32msb_c4(int chan, void *stream, int len, void *udata) -{ - /* 32 signed bits (lsb) * 4 channels. */ - volatile position_args *args = (volatile position_args *) udata; - Sint32 *ptr = (Sint32 *) stream; - int i; - - for (i = 0; i < len; i += sizeof (Sint32) * 4) { - Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) * - args->left_f) * args->distance_f); - Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) * - args->right_f) * args->distance_f); - Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+2))) * - args->left_rear_f) * args->distance_f); - Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+3))) * - args->right_rear_f) * args->distance_f); - switch (args->room_angle) { - case 0: - *(ptr++) = (Sint32) SDL_SwapBE32(swapl); - *(ptr++) = (Sint32) SDL_SwapBE32(swapr); - *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); - *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); - break; - case 90: - *(ptr++) = (Sint32) SDL_SwapBE32(swapr); - *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); - *(ptr++) = (Sint32) SDL_SwapBE32(swapl); - *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); - break; - case 180: - *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); - *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); - *(ptr++) = (Sint32) SDL_SwapBE32(swapr); - *(ptr++) = (Sint32) SDL_SwapBE32(swapl); - break; - case 270: - *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); - *(ptr++) = (Sint32) SDL_SwapBE32(swapl); - *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); - *(ptr++) = (Sint32) SDL_SwapBE32(swapr); - break; - } - } -} -static void SDLCALL _Eff_position_s32msb_c6(int chan, void *stream, int len, void *udata) -{ - /* 32 signed bits (lsb) * 6 channels. */ - volatile position_args *args = (volatile position_args *) udata; - Sint32 *ptr = (Sint32 *) stream; - int i; - - for (i = 0; i < len; i += sizeof (Sint32) * 6) { - Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) * - args->left_f) * args->distance_f); - Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) * - args->right_f) * args->distance_f); - Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+2))) * - args->left_rear_f) * args->distance_f); - Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+3))) * - args->right_rear_f) * args->distance_f); - Sint32 swapce = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+4))) * - args->center_f) * args->distance_f); - Sint32 swapwf = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+5))) * - args->lfe_f) * args->distance_f); - - switch (args->room_angle) { - case 0: - *(ptr++) = (Sint32) SDL_SwapBE32(swapl); - *(ptr++) = (Sint32) SDL_SwapBE32(swapr); - *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); - *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); - *(ptr++) = (Sint32) SDL_SwapBE32(swapce); - *(ptr++) = (Sint32) SDL_SwapBE32(swapwf); - break; - case 90: - *(ptr++) = (Sint32) SDL_SwapBE32(swapr); - *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); - *(ptr++) = (Sint32) SDL_SwapBE32(swapl); - *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); - *(ptr++) = (Sint32) SDL_SwapBE32(swapr)/2 + (Sint32) SDL_SwapBE32(swaprr)/2; - *(ptr++) = (Sint32) SDL_SwapBE32(swapwf); - break; - case 180: - *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); - *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); - *(ptr++) = (Sint32) SDL_SwapBE32(swapr); - *(ptr++) = (Sint32) SDL_SwapBE32(swapl); - *(ptr++) = (Sint32) SDL_SwapBE32(swaprr)/2 + (Sint32) SDL_SwapBE32(swaplr)/2; - *(ptr++) = (Sint32) SDL_SwapBE32(swapwf); - break; - case 270: - *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); - *(ptr++) = (Sint32) SDL_SwapBE32(swapl); - *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); - *(ptr++) = (Sint32) SDL_SwapBE32(swapr); - *(ptr++) = (Sint32) SDL_SwapBE32(swapl)/2 + (Sint32) SDL_SwapBE32(swaplr)/2; - *(ptr++) = (Sint32) SDL_SwapBE32(swapwf); - break; - } - } -} - -static void SDLCALL _Eff_position_f32sys(int chan, void *stream, int len, void *udata) -{ - /* float * 2 channels. */ - volatile position_args *args = (volatile position_args *) udata; - float *ptr = (float *) stream; - int i; - - for (i = 0; i < len; i += sizeof (float) * 2) { - float swapl = ((*(ptr+0) * args->left_f) * args->distance_f); - float swapr = ((*(ptr+1) * args->right_f) * args->distance_f); - *(ptr++) = swapl; - *(ptr++) = swapr; - } -} -static void SDLCALL _Eff_position_f32sys_c4(int chan, void *stream, int len, void *udata) -{ - /* float * 4 channels. */ - volatile position_args *args = (volatile position_args *) udata; - float *ptr = (float *) stream; - int i; - - for (i = 0; i < len; i += sizeof (float) * 4) { - float swapl = ((*(ptr+0) * args->left_f) * args->distance_f); - float swapr = ((*(ptr+1) * args->right_f) * args->distance_f); - float swaplr = ((*(ptr+2) * args->left_rear_f) * args->distance_f); - float swaprr = ((*(ptr+3) * args->right_rear_f) * args->distance_f); - switch (args->room_angle) { - case 0: - *(ptr++) = swapl; - *(ptr++) = swapr; - *(ptr++) = swaplr; - *(ptr++) = swaprr; - break; - case 90: - *(ptr++) = swapr; - *(ptr++) = swaprr; - *(ptr++) = swapl; - *(ptr++) = swaplr; - break; - case 180: - *(ptr++) = swaprr; - *(ptr++) = swaplr; - *(ptr++) = swapr; - *(ptr++) = swapl; - break; - case 270: - *(ptr++) = swaplr; - *(ptr++) = swapl; - *(ptr++) = swaprr; - *(ptr++) = swapr; - break; - } - } -} -static void SDLCALL _Eff_position_f32sys_c6(int chan, void *stream, int len, void *udata) -{ - /* float * 6 channels. */ - volatile position_args *args = (volatile position_args *) udata; - float *ptr = (float *) stream; - int i; - - for (i = 0; i < len; i += sizeof (float) * 6) { - float swapl = ((*(ptr+0) * args->left_f) * args->distance_f); - float swapr = ((*(ptr+1) * args->right_f) * args->distance_f); - float swaplr = ((*(ptr+2) * args->left_rear_f) * args->distance_f); - float swaprr = ((*(ptr+3) * args->right_rear_f) * args->distance_f); - float swapce = ((*(ptr+4) * args->center_f) * args->distance_f); - float swapwf = ((*(ptr+5) * args->lfe_f) * args->distance_f); - - switch (args->room_angle) { - case 0: - *(ptr++) = swapl; - *(ptr++) = swapr; - *(ptr++) = swaplr; - *(ptr++) = swaprr; - *(ptr++) = swapce; - *(ptr++) = swapwf; - break; - case 90: - *(ptr++) = swapr; - *(ptr++) = swaprr; - *(ptr++) = swapl; - *(ptr++) = swaplr; - *(ptr++) = swapr/2.0f + swaprr/2.0f; - *(ptr++) = swapwf; - break; - case 180: - *(ptr++) = swaprr; - *(ptr++) = swaplr; - *(ptr++) = swapr; - *(ptr++) = swapl; - *(ptr++) = swaprr/2.0f + swaplr/2.0f; - *(ptr++) = swapwf; - break; - case 270: - *(ptr++) = swaplr; - *(ptr++) = swapl; - *(ptr++) = swaprr; - *(ptr++) = swapr; - *(ptr++) = swapl/2.0f + swaplr/2.0f; - *(ptr++) = swapwf; - break; - } - } -} - -static void init_position_args(position_args *args) -{ - SDL_memset(args, '\0', sizeof (position_args)); - args->in_use = 0; - args->room_angle = 0; - args->left_u8 = args->right_u8 = args->distance_u8 = 255; - args->left_f = args->right_f = args->distance_f = 1.0f; - args->left_rear_u8 = args->right_rear_u8 = args->center_u8 = args->lfe_u8 = 255; - args->left_rear_f = args->right_rear_f = args->center_f = args->lfe_f = 1.0f; - Mix_QuerySpec(NULL, NULL, (int *) &args->channels); -} - - -static position_args *get_position_arg(int channel) -{ - void *rc; - int i; - - if (channel < 0) { - if (pos_args_global == NULL) { - pos_args_global = SDL_malloc(sizeof (position_args)); - if (pos_args_global == NULL) { - Mix_SetError("Out of memory"); - return(NULL); - } - init_position_args(pos_args_global); - } - - return(pos_args_global); - } - - if (channel >= position_channels) { - rc = SDL_realloc(pos_args_array, (channel + 1) * sizeof (position_args *)); - if (rc == NULL) { - Mix_SetError("Out of memory"); - return(NULL); - } - pos_args_array = (position_args **) rc; - for (i = position_channels; i <= channel; i++) { - pos_args_array[i] = NULL; - } - position_channels = channel + 1; - } - - if (pos_args_array[channel] == NULL) { - pos_args_array[channel] = (position_args *)SDL_malloc(sizeof(position_args)); - if (pos_args_array[channel] == NULL) { - Mix_SetError("Out of memory"); - return(NULL); - } - init_position_args(pos_args_array[channel]); - } - - return(pos_args_array[channel]); -} - - -static Mix_EffectFunc_t get_position_effect_func(Uint16 format, int channels) -{ - Mix_EffectFunc_t f = NULL; - - switch (format) { - case AUDIO_U8: - switch (channels) { - case 1: - case 2: - f = (_Eff_build_volume_table_u8()) ? _Eff_position_table_u8 : - _Eff_position_u8; - break; - case 4: - f = _Eff_position_u8_c4; - break; - case 6: - f = _Eff_position_u8_c6; - break; - default: - Mix_SetError("Unsupported audio channels"); - break; - } - break; - - case AUDIO_S8: - switch (channels) { - case 1: - case 2: - f = (_Eff_build_volume_table_s8()) ? _Eff_position_table_s8 : - _Eff_position_s8; - break; - case 4: - f = _Eff_position_s8_c4; - break; - case 6: - f = _Eff_position_s8_c6; - break; - default: - Mix_SetError("Unsupported audio channels"); - break; - } - break; - - case AUDIO_U16LSB: - switch (channels) { - case 1: - case 2: - f = _Eff_position_u16lsb; - break; - case 4: - f = _Eff_position_u16lsb_c4; - break; - case 6: - f = _Eff_position_u16lsb_c6; - break; - default: - Mix_SetError("Unsupported audio channels"); - break; - } - break; - - case AUDIO_S16LSB: - switch (channels) { - case 1: - case 2: - f = _Eff_position_s16lsb; - break; - case 4: - f = _Eff_position_s16lsb_c4; - break; - case 6: - f = _Eff_position_s16lsb_c6; - break; - default: - Mix_SetError("Unsupported audio channels"); - break; - } - break; - - case AUDIO_U16MSB: - switch (channels) { - case 1: - case 2: - f = _Eff_position_u16msb; - break; - case 4: - f = _Eff_position_u16msb_c4; - break; - case 6: - f = _Eff_position_u16msb_c6; - break; - default: - Mix_SetError("Unsupported audio channels"); - break; - } - break; - - case AUDIO_S16MSB: - switch (channels) { - case 1: - case 2: - f = _Eff_position_s16msb; - break; - case 4: - f = _Eff_position_s16msb_c4; - break; - case 6: - f = _Eff_position_s16msb_c6; - break; - default: - Mix_SetError("Unsupported audio channels"); - break; - } - break; - - case AUDIO_S32MSB: - switch (channels) { - case 1: - case 2: - f = _Eff_position_s32msb; - break; - case 4: - f = _Eff_position_s32msb_c4; - break; - case 6: - f = _Eff_position_s32msb_c6; - break; - default: - Mix_SetError("Unsupported audio channels"); - break; - } - break; - - case AUDIO_S32LSB: - switch (channels) { - case 1: - case 2: - f = _Eff_position_s32lsb; - break; - case 4: - f = _Eff_position_s32lsb_c4; - break; - case 6: - f = _Eff_position_s32lsb_c6; - break; - default: - Mix_SetError("Unsupported audio channels"); - break; - } - break; - - case AUDIO_F32SYS: - switch (channels) { - case 1: - case 2: - f = _Eff_position_f32sys; - break; - case 4: - f = _Eff_position_f32sys_c4; - break; - case 6: - f = _Eff_position_f32sys_c6; - break; - default: - Mix_SetError("Unsupported audio channels"); - break; - } - break; - - default: - Mix_SetError("Unsupported audio format"); - break; - } - - return(f); -} - -static Uint8 speaker_amplitude[6]; - -static void set_amplitudes(int channels, int angle, int room_angle) -{ - int left = 255, right = 255; - int left_rear = 255, right_rear = 255, center = 255; - - angle = SDL_abs(angle) % 360; /* make angle between 0 and 359. */ - - if (channels == 2) - { - /* - * We only attenuate by position if the angle falls on the far side - * of center; That is, an angle that's due north would not attenuate - * either channel. Due west attenuates the right channel to 0.0, and - * due east attenuates the left channel to 0.0. Slightly east of - * center attenuates the left channel a little, and the right channel - * not at all. I think of this as occlusion by one's own head. :) - * - * ...so, we split our angle circle into four quadrants... - */ - if (angle < 90) { - left = 255 - ((int) (255.0f * (((float) angle) / 89.0f))); - } else if (angle < 180) { - left = (int) (255.0f * (((float) (angle - 90)) / 89.0f)); - } else if (angle < 270) { - right = 255 - ((int) (255.0f * (((float) (angle - 180)) / 89.0f))); - } else { - right = (int) (255.0f * (((float) (angle - 270)) / 89.0f)); - } - } - - if (channels == 4 || channels == 6) - { - /* - * An angle that's due north does not attenuate the center channel. - * An angle in the first quadrant, 0-90, does not attenuate the RF. - * - * ...so, we split our angle circle into 8 ... - * - * CE - * 0 - * LF | RF - * | - * 270<-------|----------->90 - * | - * LR | RR - * 180 - * - */ - if (angle < 45) { - left = ((int) (255.0f * (((float) (180 - angle)) / 179.0f))); - left_rear = 255 - ((int) (255.0f * (((float) (angle + 45)) / 89.0f))); - right_rear = 255 - ((int) (255.0f * (((float) (90 - angle)) / 179.0f))); - } else if (angle < 90) { - center = ((int) (255.0f * (((float) (225 - angle)) / 179.0f))); - left = ((int) (255.0f * (((float) (180 - angle)) / 179.0f))); - left_rear = 255 - ((int) (255.0f * (((float) (135 - angle)) / 89.0f))); - right_rear = ((int) (255.0f * (((float) (90 + angle)) / 179.0f))); - } else if (angle < 135) { - center = ((int) (255.0f * (((float) (225 - angle)) / 179.0f))); - left = 255 - ((int) (255.0f * (((float) (angle - 45)) / 89.0f))); - right = ((int) (255.0f * (((float) (270 - angle)) / 179.0f))); - left_rear = ((int) (255.0f * (((float) (angle)) / 179.0f))); - } else if (angle < 180) { - center = 255 - ((int) (255.0f * (((float) (angle - 90)) / 89.0f))); - left = 255 - ((int) (255.0f * (((float) (225 - angle)) / 89.0f))); - right = ((int) (255.0f * (((float) (270 - angle)) / 179.0f))); - left_rear = ((int) (255.0f * (((float) (angle)) / 179.0f))); - } else if (angle < 225) { - center = 255 - ((int) (255.0f * (((float) (270 - angle)) / 89.0f))); - left = ((int) (255.0f * (((float) (angle - 90)) / 179.0f))); - right = 255 - ((int) (255.0f * (((float) (angle - 135)) / 89.0f))); - right_rear = ((int) (255.0f * (((float) (360 - angle)) / 179.0f))); - } else if (angle < 270) { - center = ((int) (255.0f * (((float) (angle - 135)) / 179.0f))); - left = ((int) (255.0f * (((float) (angle - 90)) / 179.0f))); - right = 255 - ((int) (255.0f * (((float) (315 - angle)) / 89.0f))); - right_rear = ((int) (255.0f * (((float) (360 - angle)) / 179.0f))); - } else if (angle < 315) { - center = ((int) (255.0f * (((float) (angle - 135)) / 179.0f))); - right = ((int) (255.0f * (((float) (angle - 180)) / 179.0f))); - left_rear = ((int) (255.0f * (((float) (450 - angle)) / 179.0f))); - right_rear = 255 - ((int) (255.0f * (((float) (angle - 225)) / 89.0f))); - } else { - right = ((int) (255.0f * (((float) (angle - 180)) / 179.0f))); - left_rear = ((int) (255.0f * (((float) (450 - angle)) / 179.0f))); - right_rear = 255 - ((int) (255.0f * (((float) (405 - angle)) / 89.0f))); - } - } - - if (left < 0) left = 0; if (left > 255) left = 255; - if (right < 0) right = 0; if (right > 255) right = 255; - if (left_rear < 0) left_rear = 0; if (left_rear > 255) left_rear = 255; - if (right_rear < 0) right_rear = 0; if (right_rear > 255) right_rear = 255; - if (center < 0) center = 0; if (center > 255) center = 255; - - if (room_angle == 90) { - speaker_amplitude[0] = (Uint8)left_rear; - speaker_amplitude[1] = (Uint8)left; - speaker_amplitude[2] = (Uint8)right_rear; - speaker_amplitude[3] = (Uint8)right; - } - else if (room_angle == 180) { - if (channels == 2) { - speaker_amplitude[0] = (Uint8)right; - speaker_amplitude[1] = (Uint8)left; - } - else { - speaker_amplitude[0] = (Uint8)right_rear; - speaker_amplitude[1] = (Uint8)left_rear; - speaker_amplitude[2] = (Uint8)right; - speaker_amplitude[3] = (Uint8)left; - } - } - else if (room_angle == 270) { - speaker_amplitude[0] = (Uint8)right; - speaker_amplitude[1] = (Uint8)right_rear; - speaker_amplitude[2] = (Uint8)left; - speaker_amplitude[3] = (Uint8)left_rear; - } - else { - speaker_amplitude[0] = (Uint8)left; - speaker_amplitude[1] = (Uint8)right; - speaker_amplitude[2] = (Uint8)left_rear; - speaker_amplitude[3] = (Uint8)right_rear; - } - speaker_amplitude[4] = (Uint8)center; - speaker_amplitude[5] = 255; -} - -int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance); - -int Mix_SetPanning(int channel, Uint8 left, Uint8 right) -{ - Mix_EffectFunc_t f = NULL; - int channels; - Uint16 format; - position_args *args = NULL; - int retval = 1; - - Mix_QuerySpec(NULL, &format, &channels); - - if (channels != 2 && channels != 4 && channels != 6) /* it's a no-op; we call that successful. */ - return(1); - - if (channels > 2) { - /* left = right = 255 => angle = 0, to unregister effect as when channels = 2 */ - /* left = 255 => angle = -90; left = 0 => angle = +89 */ - int angle = 0; - if ((left != 255) || (right != 255)) { - angle = (int)left; - angle = 127 - angle; - angle = -angle; - angle = angle * 90 / 128; /* Make it larger for more effect? */ - } - return(Mix_SetPosition(channel, angle, 0)); - } - - f = get_position_effect_func(format, channels); - if (f == NULL) - return(0); - - Mix_LockAudio(); - args = get_position_arg(channel); - if (!args) { - Mix_UnlockAudio(); - return(0); - } - - /* it's a no-op; unregister the effect, if it's registered. */ - if ((args->distance_u8 == 255) && (left == 255) && (right == 255)) { - if (args->in_use) { - retval = _Mix_UnregisterEffect_locked(channel, f); - Mix_UnlockAudio(); - return(retval); - } else { - Mix_UnlockAudio(); - return(1); - } - } - - args->left_u8 = left; - args->left_f = ((float) left) / 255.0f; - args->right_u8 = right; - args->right_f = ((float) right) / 255.0f; - args->room_angle = 0; - - if (!args->in_use) { - args->in_use = 1; - retval=_Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void*)args); - } - - Mix_UnlockAudio(); - return(retval); -} - - -int Mix_SetDistance(int channel, Uint8 distance) -{ - Mix_EffectFunc_t f = NULL; - Uint16 format; - position_args *args = NULL; - int channels; - int retval = 1; - - Mix_QuerySpec(NULL, &format, &channels); - f = get_position_effect_func(format, channels); - if (f == NULL) - return(0); - - Mix_LockAudio(); - args = get_position_arg(channel); - if (!args) { - Mix_UnlockAudio(); - return(0); - } - - distance = 255 - distance; /* flip it to our scale. */ - - /* it's a no-op; unregister the effect, if it's registered. */ - if ((distance == 255) && (args->left_u8 == 255) && (args->right_u8 == 255)) { - if (args->in_use) { - retval = _Mix_UnregisterEffect_locked(channel, f); - Mix_UnlockAudio(); - return(retval); - } else { - Mix_UnlockAudio(); - return(1); - } - } - - args->distance_u8 = distance; - args->distance_f = ((float) distance) / 255.0f; - if (!args->in_use) { - args->in_use = 1; - retval = _Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void *) args); - } - - Mix_UnlockAudio(); - return(retval); -} - - -int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance) -{ - Mix_EffectFunc_t f = NULL; - Uint16 format; - int channels; - position_args *args = NULL; - Sint16 room_angle = 0; - int retval = 1; - - Mix_QuerySpec(NULL, &format, &channels); - f = get_position_effect_func(format, channels); - if (f == NULL) - return(0); - - angle = SDL_abs(angle) % 360; /* make angle between 0 and 359. */ - - Mix_LockAudio(); - args = get_position_arg(channel); - if (!args) { - Mix_UnlockAudio(); - return(0); - } - - /* it's a no-op; unregister the effect, if it's registered. */ - if ((!distance) && (!angle)) { - if (args->in_use) { - retval = _Mix_UnregisterEffect_locked(channel, f); - Mix_UnlockAudio(); - return(retval); - } else { - Mix_UnlockAudio(); - return(1); - } - } - - if (channels == 2) - { - if (angle > 180) - room_angle = 180; /* exchange left and right channels */ - else room_angle = 0; - } - - if (channels == 4 || channels == 6) - { - if (angle > 315) room_angle = 0; - else if (angle > 225) room_angle = 270; - else if (angle > 135) room_angle = 180; - else if (angle > 45) room_angle = 90; - else room_angle = 0; - } - - - distance = 255 - distance; /* flip it to scale Mix_SetDistance() uses. */ - - set_amplitudes(channels, angle, room_angle); - - args->left_u8 = speaker_amplitude[0]; - args->left_f = ((float) speaker_amplitude[0]) / 255.0f; - args->right_u8 = speaker_amplitude[1]; - args->right_f = ((float) speaker_amplitude[1]) / 255.0f; - args->left_rear_u8 = speaker_amplitude[2]; - args->left_rear_f = ((float) speaker_amplitude[2]) / 255.0f; - args->right_rear_u8 = speaker_amplitude[3]; - args->right_rear_f = ((float) speaker_amplitude[3]) / 255.0f; - args->center_u8 = speaker_amplitude[4]; - args->center_f = ((float) speaker_amplitude[4]) / 255.0f; - args->lfe_u8 = speaker_amplitude[5]; - args->lfe_f = ((float) speaker_amplitude[5]) / 255.0f; - args->distance_u8 = distance; - args->distance_f = ((float) distance) / 255.0f; - args->room_angle = room_angle; - if (!args->in_use) { - args->in_use = 1; - retval = _Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void *) args); - } - - Mix_UnlockAudio(); - return(retval); -} - - -/* end of effects_position.c ... */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/effect_stereoreverse.c b/effect_stereoreverse.c deleted file mode 100644 index 2f753ad..0000000 --- a/effect_stereoreverse.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - This file by Ryan C. Gordon (icculus@icculus.org) - - These are some internally supported special effects that use SDL_mixer's - effect callback API. They are meant for speed over quality. :) -*/ - -/* $Id$ */ - -#include -#include - -#include "SDL.h" -#include "SDL_mixer.h" - -#define __MIX_INTERNAL_EFFECT__ -#include "effects_internal.h" - -/* profile code: - #include - #include - struct timeval tv1; - struct timeval tv2; - - gettimeofday(&tv1, NULL); - - ... do your thing here ... - - gettimeofday(&tv2, NULL); - printf("%ld\n", tv2.tv_usec - tv1.tv_usec); -*/ - - - -/* - * Stereo reversal effect...this one's pretty straightforward... - */ - -static void SDLCALL _Eff_reversestereo32(int chan, void *stream, int len, void *udata) -{ - /* 16 bits * 2 channels. */ - Uint32 *ptr = (Uint32 *) stream; - Uint32 tmp; - int i; - - for (i = 0; i < len; i += 2 * sizeof (Uint32), ptr += 2) { - tmp = ptr[0]; - ptr[0] = ptr[1]; - ptr[1] = tmp; - } -} - - -static void SDLCALL _Eff_reversestereo16(int chan, void *stream, int len, void *udata) -{ - /* 16 bits * 2 channels. */ - Uint32 *ptr = (Uint32 *) stream; - int i; - - for (i = 0; i < len; i += sizeof (Uint32), ptr++) { - *ptr = (((*ptr) & 0xFFFF0000) >> 16) | (((*ptr) & 0x0000FFFF) << 16); - } -} - - -static void SDLCALL _Eff_reversestereo8(int chan, void *stream, int len, void *udata) -{ - /* 8 bits * 2 channels. */ - Uint32 *ptr = (Uint32 *) stream; - int i; - - /* get the last two bytes if len is not divisible by four... */ - if (len % sizeof (Uint32) != 0) { - Uint16 *p = (Uint16 *) (((Uint8 *) stream) + (len - 2)); - *p = (Uint16)((((*p) & 0xFF00) >> 8) | (((*ptr) & 0x00FF) << 8)); - len -= 2; - } - - for (i = 0; i < len; i += sizeof (Uint32), ptr++) { - *ptr = (((*ptr) & 0x0000FF00) >> 8) | (((*ptr) & 0x000000FF) << 8) | - (((*ptr) & 0xFF000000) >> 8) | (((*ptr) & 0x00FF0000) << 8); - } -} - - -int Mix_SetReverseStereo(int channel, int flip) -{ - Mix_EffectFunc_t f = NULL; - int channels; - Uint16 format; - - Mix_QuerySpec(NULL, &format, &channels); - - if (channels == 2) { - int bits = (format & 0xFF); - switch (bits) { - case 8: - f = _Eff_reversestereo8; - break; - case 16: - f = _Eff_reversestereo16; - break; - case 32: - f = _Eff_reversestereo32; - break; - default: - Mix_SetError("Unsupported audio format"); - return(0); - } - - if (!flip) { - return(Mix_UnregisterEffect(channel, f)); - } else { - return(Mix_RegisterEffect(channel, f, NULL, NULL)); - } - } else { - Mix_SetError("Trying to reverse stereo on a non-stereo stream"); - return(0); - } - - return(1); -} - - -/* end of effect_stereoreverse.c ... */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/effects_internal.c b/effects_internal.c deleted file mode 100644 index 4e677ab..0000000 --- a/effects_internal.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - This file by Ryan C. Gordon (icculus@icculus.org) - - These are some helper functions for the internal mixer special effects. -*/ - -/* $Id$ */ - - - /* ------ These are used internally only. Don't touch. ------ */ - - - -#include -#include -#include "SDL_mixer.h" - -#define __MIX_INTERNAL_EFFECT__ -#include "effects_internal.h" - -/* Should we favor speed over memory usage and/or quality of output? */ -int _Mix_effects_max_speed = 0; - - -void _Mix_InitEffects(void) -{ - _Mix_effects_max_speed = (SDL_getenv(MIX_EFFECTSMAXSPEED) != NULL); -} - -void _Mix_DeinitEffects(void) -{ - _Eff_PositionDeinit(); -} - - -void *_Eff_volume_table = NULL; - - -/* Build the volume table for Uint8-format samples. - * - * Each column of the table is a possible sample, while each row of the - * table is a volume. Volume is a Uint8, where 0 is silence and 255 is full - * volume. So _Eff_volume_table[128][mysample] would be the value of - * mysample, at half volume. - */ -void *_Eff_build_volume_table_u8(void) -{ - int volume; - int sample; - Uint8 *rc; - - if (!_Mix_effects_max_speed) { - return(NULL); - } - - if (!_Eff_volume_table) { - rc = SDL_malloc(256 * 256); - if (rc) { - _Eff_volume_table = (void *) rc; - for (volume = 0; volume < 256; volume++) { - for (sample = -128; sample < 128; sample ++) { - *rc = (Uint8)(((float) sample) * ((float) volume / 255.0)) - + 128; - rc++; - } - } - } - } - - return(_Eff_volume_table); -} - - -/* Build the volume table for Sint8-format samples. - * - * Each column of the table is a possible sample, while each row of the - * table is a volume. Volume is a Uint8, where 0 is silence and 255 is full - * volume. So _Eff_volume_table[128][mysample+128] would be the value of - * mysample, at half volume. - */ -void *_Eff_build_volume_table_s8(void) -{ - int volume; - int sample; - Sint8 *rc; - - if (!_Eff_volume_table) { - rc = SDL_malloc(256 * 256); - if (rc) { - _Eff_volume_table = (void *) rc; - for (volume = 0; volume < 256; volume++) { - for (sample = -128; sample < 128; sample ++) { - *rc = (Sint8)(((float) sample) * ((float) volume / 255.0)); - rc++; - } - } - } - } - - return(_Eff_volume_table); -} - - -/* end of effects.c ... */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/effects_internal.h b/effects_internal.h deleted file mode 100644 index ed16bd9..0000000 --- a/effects_internal.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* $Id$ */ - -#ifndef _INCLUDE_EFFECTS_INTERNAL_H_ -#define _INCLUDE_EFFECTS_INTERNAL_H_ - -#ifndef __MIX_INTERNAL_EFFECT__ -#error You should not include this file or use these functions. -#endif - -#include "SDL_mixer.h" - -extern int _Mix_effects_max_speed; -extern void *_Eff_volume_table; -void *_Eff_build_volume_table_u8(void); -void *_Eff_build_volume_table_s8(void); - -void _Mix_InitEffects(void); -void _Mix_DeinitEffects(void); -void _Eff_PositionDeinit(void); - -int _Mix_RegisterEffect_locked(int channel, Mix_EffectFunc_t f, - Mix_EffectDone_t d, void *arg); -int _Mix_UnregisterEffect_locked(int channel, Mix_EffectFunc_t f); -int _Mix_UnregisterAllEffects_locked(int channel); - -#endif /* _INCLUDE_EFFECTS_INTERNAL_H_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/include/SDL_mixer.h b/include/SDL_mixer.h new file mode 100644 index 0000000..fefc816 --- /dev/null +++ b/include/SDL_mixer.h @@ -0,0 +1,702 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_MIXER_H_ +#define SDL_MIXER_H_ + +#include "SDL_stdinc.h" +#include "SDL_rwops.h" +#include "SDL_audio.h" +#include "SDL_endian.h" +#include "SDL_version.h" +#include "begin_code.h" + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL +*/ +#define SDL_MIXER_MAJOR_VERSION 2 +#define SDL_MIXER_MINOR_VERSION 0 +#define SDL_MIXER_PATCHLEVEL 4 + +/* This macro can be used to fill a version structure with the compile-time + * version of the SDL_mixer library. + */ +#define SDL_MIXER_VERSION(X) \ +{ \ + (X)->major = SDL_MIXER_MAJOR_VERSION; \ + (X)->minor = SDL_MIXER_MINOR_VERSION; \ + (X)->patch = SDL_MIXER_PATCHLEVEL; \ +} + +/* Backwards compatibility */ +#define MIX_MAJOR_VERSION SDL_MIXER_MAJOR_VERSION +#define MIX_MINOR_VERSION SDL_MIXER_MINOR_VERSION +#define MIX_PATCHLEVEL SDL_MIXER_PATCHLEVEL +#define MIX_VERSION(X) SDL_MIXER_VERSION(X) + +/** + * This is the version number macro for the current SDL_mixer version. + */ +#define SDL_MIXER_COMPILEDVERSION \ + SDL_VERSIONNUM(SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL) + +/** + * This macro will evaluate to true if compiled with SDL_mixer at least X.Y.Z. + */ +#define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \ + (SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) + +/* This function gets the version of the dynamically linked SDL_mixer library. + it should NOT be used to fill a version structure, instead you should + use the SDL_MIXER_VERSION() macro. + */ +extern DECLSPEC const SDL_version * SDLCALL Mix_Linked_Version(void); + +typedef enum +{ + MIX_INIT_FLAC = 0x00000001, + MIX_INIT_MOD = 0x00000002, + MIX_INIT_MP3 = 0x00000008, + MIX_INIT_OGG = 0x00000010, + MIX_INIT_MID = 0x00000020, + MIX_INIT_OPUS = 0x00000040 +} MIX_InitFlags; + +/* Loads dynamic libraries and prepares them for use. Flags should be + one or more flags from MIX_InitFlags OR'd together. + It returns the flags successfully initialized, or 0 on failure. + */ +extern DECLSPEC int SDLCALL Mix_Init(int flags); + +/* Unloads libraries loaded with Mix_Init */ +extern DECLSPEC void SDLCALL Mix_Quit(void); + + +/* The default mixer has 8 simultaneous mixing channels */ +#ifndef MIX_CHANNELS +#define MIX_CHANNELS 8 +#endif + +/* Good default values for a PC soundcard */ +#define MIX_DEFAULT_FREQUENCY 44100 +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define MIX_DEFAULT_FORMAT AUDIO_S16LSB +#else +#define MIX_DEFAULT_FORMAT AUDIO_S16MSB +#endif +#define MIX_DEFAULT_CHANNELS 2 +#define MIX_MAX_VOLUME SDL_MIX_MAXVOLUME /* Volume of a chunk */ + +/* The internal format for an audio chunk */ +typedef struct Mix_Chunk { + int allocated; + Uint8 *abuf; + Uint32 alen; + Uint8 volume; /* Per-sample volume, 0-128 */ +} Mix_Chunk; + +/* The different fading types supported */ +typedef enum { + MIX_NO_FADING, + MIX_FADING_OUT, + MIX_FADING_IN +} Mix_Fading; + +/* These are types of music files (not libraries used to load them) */ +typedef enum { + MUS_NONE, + MUS_CMD, + MUS_WAV, + MUS_MOD, + MUS_MID, + MUS_OGG, + MUS_MP3, + MUS_MP3_MAD_UNUSED, + MUS_FLAC, + MUS_MODPLUG_UNUSED, + MUS_OPUS +} Mix_MusicType; + +/* The internal format for a music chunk interpreted via mikmod */ +typedef struct _Mix_Music Mix_Music; + +/* Open the mixer with a certain audio format */ +extern DECLSPEC int SDLCALL Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize); + +/* Open the mixer with specific device and certain audio format */ +extern DECLSPEC int SDLCALL Mix_OpenAudioDevice(int frequency, Uint16 format, int channels, int chunksize, const char* device, int allowed_changes); + +/* Dynamically change the number of channels managed by the mixer. + If decreasing the number of channels, the upper channels are + stopped. + This function returns the new number of allocated channels. + */ +extern DECLSPEC int SDLCALL Mix_AllocateChannels(int numchans); + +/* Find out what the actual audio device parameters are. + This function returns 1 if the audio has been opened, 0 otherwise. + */ +extern DECLSPEC int SDLCALL Mix_QuerySpec(int *frequency,Uint16 *format,int *channels); + +/* Load a wave file or a music (.mod .s3m .it .xm) file */ +extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV_RW(SDL_RWops *src, int freesrc); +#define Mix_LoadWAV(file) Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1) +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file); + +/* Load a music file from an SDL_RWop object + * Matt Campbell (matt@campbellhome.dhs.org) April 2000 */ +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *src, int freesrc); + +/* Load a music file from an SDL_RWop object assuming a specific format */ +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc); + +/* Load a wave file of the mixer format from a memory buffer */ +extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_WAV(Uint8 *mem); + +/* Load raw audio data of the mixer format from a memory buffer */ +extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len); + +/* Free an audio chunk previously loaded */ +extern DECLSPEC void SDLCALL Mix_FreeChunk(Mix_Chunk *chunk); +extern DECLSPEC void SDLCALL Mix_FreeMusic(Mix_Music *music); + +/* Get a list of chunk/music decoders that this build of SDL_mixer provides. + This list can change between builds AND runs of the program, if external + libraries that add functionality become available. + You must successfully call Mix_OpenAudio() before calling these functions. + This API is only available in SDL_mixer 1.2.9 and later. + + // usage... + int i; + const int total = Mix_GetNumChunkDecoders(); + for (i = 0; i < total; i++) + printf("Supported chunk decoder: [%s]\n", Mix_GetChunkDecoder(i)); + + Appearing in this list doesn't promise your specific audio file will + decode...but it's handy to know if you have, say, a functioning Timidity + install. + + These return values are static, read-only data; do not modify or free it. + The pointers remain valid until you call Mix_CloseAudio(). +*/ +extern DECLSPEC int SDLCALL Mix_GetNumChunkDecoders(void); +extern DECLSPEC const char * SDLCALL Mix_GetChunkDecoder(int index); +extern DECLSPEC SDL_bool SDLCALL Mix_HasChunkDecoder(const char *name); +extern DECLSPEC int SDLCALL Mix_GetNumMusicDecoders(void); +extern DECLSPEC const char * SDLCALL Mix_GetMusicDecoder(int index); +extern DECLSPEC SDL_bool SDLCALL Mix_HasMusicDecoder(const char *name); + +/* Find out the music format of a mixer music, or the currently playing + music, if 'music' is NULL. +*/ +extern DECLSPEC Mix_MusicType SDLCALL Mix_GetMusicType(const Mix_Music *music); + +/* Get music title from meta-tag if possible. If title tag is empty, filename will be returned */ +extern DECLSPEC const char *SDLCALL Mix_GetMusicTitle(const Mix_Music *music); +/* Get music title from meta-tag if possible */ +extern DECLSPEC const char *SDLCALL Mix_GetMusicTitleTag(const Mix_Music *music); +/* Get music artist from meta-tag if possible */ +extern DECLSPEC const char *SDLCALL Mix_GetMusicArtistTag(const Mix_Music *music); +/* Get music album from meta-tag if possible */ +extern DECLSPEC const char *SDLCALL Mix_GetMusicAlbumTag(const Mix_Music *music); +/* Get music copyright from meta-tag if possible */ +extern DECLSPEC const char *SDLCALL Mix_GetMusicCopyrightTag(const Mix_Music *music); + +/* Set a function that is called after all mixing is performed. + This can be used to provide real-time visual display of the audio stream + or add a custom mixer filter for the stream data. +*/ +extern DECLSPEC void SDLCALL Mix_SetPostMix(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg); + +/* Add your own music player or additional mixer function. + If 'mix_func' is NULL, the default music player is re-enabled. + */ +extern DECLSPEC void SDLCALL Mix_HookMusic(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg); + +/* Add your own callback for when the music has finished playing or when it is + * stopped from a call to Mix_HaltMusic. + */ +extern DECLSPEC void SDLCALL Mix_HookMusicFinished(void (SDLCALL *music_finished)(void)); + +/* Get a pointer to the user data for the current music hook */ +extern DECLSPEC void * SDLCALL Mix_GetMusicHookData(void); + +/* + * Add your own callback when a channel has finished playing. NULL + * to disable callback. The callback may be called from the mixer's audio + * callback or it could be called as a result of Mix_HaltChannel(), etc. + * do not call SDL_LockAudio() from this callback; you will either be + * inside the audio callback, or SDL_mixer will explicitly lock the audio + * before calling your callback. + */ +extern DECLSPEC void SDLCALL Mix_ChannelFinished(void (SDLCALL *channel_finished)(int channel)); + + +/* Special Effects API by ryan c. gordon. (icculus@icculus.org) */ + +#define MIX_CHANNEL_POST (-2) + +/* This is the format of a special effect callback: + * + * myeffect(int chan, void *stream, int len, void *udata); + * + * (chan) is the channel number that your effect is affecting. (stream) is + * the buffer of data to work upon. (len) is the size of (stream), and + * (udata) is a user-defined bit of data, which you pass as the last arg of + * Mix_RegisterEffect(), and is passed back unmolested to your callback. + * Your effect changes the contents of (stream) based on whatever parameters + * are significant, or just leaves it be, if you prefer. You can do whatever + * you like to the buffer, though, and it will continue in its changed state + * down the mixing pipeline, through any other effect functions, then finally + * to be mixed with the rest of the channels and music for the final output + * stream. + * + * DO NOT EVER call SDL_LockAudio() from your callback function! + */ +typedef void (SDLCALL *Mix_EffectFunc_t)(int chan, void *stream, int len, void *udata); + +/* + * This is a callback that signifies that a channel has finished all its + * loops and has completed playback. This gets called if the buffer + * plays out normally, or if you call Mix_HaltChannel(), implicitly stop + * a channel via Mix_AllocateChannels(), or unregister a callback while + * it's still playing. + * + * DO NOT EVER call SDL_LockAudio() from your callback function! + */ +typedef void (SDLCALL *Mix_EffectDone_t)(int chan, void *udata); + + +/* Register a special effect function. At mixing time, the channel data is + * copied into a buffer and passed through each registered effect function. + * After it passes through all the functions, it is mixed into the final + * output stream. The copy to buffer is performed once, then each effect + * function performs on the output of the previous effect. Understand that + * this extra copy to a buffer is not performed if there are no effects + * registered for a given chunk, which saves CPU cycles, and any given + * effect will be extra cycles, too, so it is crucial that your code run + * fast. Also note that the data that your function is given is in the + * format of the sound device, and not the format you gave to Mix_OpenAudio(), + * although they may in reality be the same. This is an unfortunate but + * necessary speed concern. Use Mix_QuerySpec() to determine if you can + * handle the data before you register your effect, and take appropriate + * actions. + * You may also specify a callback (Mix_EffectDone_t) that is called when + * the channel finishes playing. This gives you a more fine-grained control + * than Mix_ChannelFinished(), in case you need to free effect-specific + * resources, etc. If you don't need this, you can specify NULL. + * You may set the callbacks before or after calling Mix_PlayChannel(). + * Things like Mix_SetPanning() are just internal special effect functions, + * so if you are using that, you've already incurred the overhead of a copy + * to a separate buffer, and that these effects will be in the queue with + * any functions you've registered. The list of registered effects for a + * channel is reset when a chunk finishes playing, so you need to explicitly + * set them with each call to Mix_PlayChannel*(). + * You may also register a special effect function that is to be run after + * final mixing occurs. The rules for these callbacks are identical to those + * in Mix_RegisterEffect, but they are run after all the channels and the + * music have been mixed into a single stream, whereas channel-specific + * effects run on a given channel before any other mixing occurs. These + * global effect callbacks are call "posteffects". Posteffects only have + * their Mix_EffectDone_t function called when they are unregistered (since + * the main output stream is never "done" in the same sense as a channel). + * You must unregister them manually when you've had enough. Your callback + * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the + * processing is considered a posteffect. + * + * After all these effects have finished processing, the callback registered + * through Mix_SetPostMix() runs, and then the stream goes to the audio + * device. + * + * DO NOT EVER call SDL_LockAudio() from your callback function! + * + * returns zero if error (no such channel), nonzero if added. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_RegisterEffect(int chan, Mix_EffectFunc_t f, Mix_EffectDone_t d, void *arg); + + +/* You may not need to call this explicitly, unless you need to stop an + * effect from processing in the middle of a chunk's playback. + * Posteffects are never implicitly unregistered as they are for channels, + * but they may be explicitly unregistered through this function by + * specifying MIX_CHANNEL_POST for a channel. + * returns zero if error (no such channel or effect), nonzero if removed. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f); + + +/* You may not need to call this explicitly, unless you need to stop all + * effects from processing in the middle of a chunk's playback. Note that + * this will also shut off some internal effect processing, since + * Mix_SetPanning() and others may use this API under the hood. This is + * called internally when a channel completes playback. + * Posteffects are never implicitly unregistered as they are for channels, + * but they may be explicitly unregistered through this function by + * specifying MIX_CHANNEL_POST for a channel. + * returns zero if error (no such channel), nonzero if all effects removed. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_UnregisterAllEffects(int channel); + + +#define MIX_EFFECTSMAXSPEED "MIX_EFFECTSMAXSPEED" + +/* + * These are the internally-defined mixing effects. They use the same API that + * effects defined in the application use, but are provided here as a + * convenience. Some effects can reduce their quality or use more memory in + * the name of speed; to enable this, make sure the environment variable + * MIX_EFFECTSMAXSPEED (see above) is defined before you call + * Mix_OpenAudio(). + */ + + +/* Set the panning of a channel. The left and right channels are specified + * as integers between 0 and 255, quietest to loudest, respectively. + * + * Technically, this is just individual volume control for a sample with + * two (stereo) channels, so it can be used for more than just panning. + * If you want real panning, call it like this: + * + * Mix_SetPanning(channel, left, 255 - left); + * + * ...which isn't so hard. + * + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and + * the panning will be done to the final mixed stream before passing it on + * to the audio device. + * + * This uses the Mix_RegisterEffect() API internally, and returns without + * registering the effect function if the audio device is not configured + * for stereo output. Setting both (left) and (right) to 255 causes this + * effect to be unregistered, since that is the data's normal state. + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if panning effect enabled. Note that an audio device in mono + * mode is a no-op, but this call will return successful in that case. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_SetPanning(int channel, Uint8 left, Uint8 right); + + +/* Set the position of a channel. (angle) is an integer from 0 to 360, that + * specifies the location of the sound in relation to the listener. (angle) + * will be reduced as neccesary (540 becomes 180 degrees, -100 becomes 260). + * Angle 0 is due north, and rotates clockwise as the value increases. + * For efficiency, the precision of this effect may be limited (angles 1 + * through 7 might all produce the same effect, 8 through 15 are equal, etc). + * (distance) is an integer between 0 and 255 that specifies the space + * between the sound and the listener. The larger the number, the further + * away the sound is. Using 255 does not guarantee that the channel will be + * culled from the mixing process or be completely silent. For efficiency, + * the precision of this effect may be limited (distance 0 through 5 might + * all produce the same effect, 6 through 10 are equal, etc). Setting (angle) + * and (distance) to 0 unregisters this effect, since the data would be + * unchanged. + * + * If you need more precise positional audio, consider using OpenAL for + * spatialized effects instead of SDL_mixer. This is only meant to be a + * basic effect for simple "3D" games. + * + * If the audio device is configured for mono output, then you won't get + * any effectiveness from the angle; however, distance attenuation on the + * channel will still occur. While this effect will function with stereo + * voices, it makes more sense to use voices with only one channel of sound, + * so when they are mixed through this effect, the positioning will sound + * correct. You can convert them to mono through SDL before giving them to + * the mixer in the first place if you like. + * + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and + * the positioning will be done to the final mixed stream before passing it + * on to the audio device. + * + * This is a convenience wrapper over Mix_SetDistance() and Mix_SetPanning(). + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if position effect is enabled. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_SetPosition(int channel, Sint16 angle, Uint8 distance); + + +/* Set the "distance" of a channel. (distance) is an integer from 0 to 255 + * that specifies the location of the sound in relation to the listener. + * Distance 0 is overlapping the listener, and 255 is as far away as possible + * A distance of 255 does not guarantee silence; in such a case, you might + * want to try changing the chunk's volume, or just cull the sample from the + * mixing process with Mix_HaltChannel(). + * For efficiency, the precision of this effect may be limited (distances 1 + * through 7 might all produce the same effect, 8 through 15 are equal, etc). + * (distance) is an integer between 0 and 255 that specifies the space + * between the sound and the listener. The larger the number, the further + * away the sound is. + * Setting (distance) to 0 unregisters this effect, since the data would be + * unchanged. + * If you need more precise positional audio, consider using OpenAL for + * spatialized effects instead of SDL_mixer. This is only meant to be a + * basic effect for simple "3D" games. + * + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and + * the distance attenuation will be done to the final mixed stream before + * passing it on to the audio device. + * + * This uses the Mix_RegisterEffect() API internally. + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if position effect is enabled. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_SetDistance(int channel, Uint8 distance); + + +/* + * !!! FIXME : Haven't implemented, since the effect goes past the + * end of the sound buffer. Will have to think about this. + * --ryan. + */ +#if 0 +/* Causes an echo effect to be mixed into a sound. (echo) is the amount + * of echo to mix. 0 is no echo, 255 is infinite (and probably not + * what you want). + * + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and + * the reverbing will be done to the final mixed stream before passing it on + * to the audio device. + * + * This uses the Mix_RegisterEffect() API internally. If you specify an echo + * of zero, the effect is unregistered, as the data is already in that state. + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if reversing effect is enabled. + * Error messages can be retrieved from Mix_GetError(). + */ +extern no_parse_DECLSPEC int SDLCALL Mix_SetReverb(int channel, Uint8 echo); +#endif + +/* Causes a channel to reverse its stereo. This is handy if the user has his + * speakers hooked up backwards, or you would like to have a minor bit of + * psychedelia in your sound code. :) Calling this function with (flip) + * set to non-zero reverses the chunks's usual channels. If (flip) is zero, + * the effect is unregistered. + * + * This uses the Mix_RegisterEffect() API internally, and thus is probably + * more CPU intensive than having the user just plug in his speakers + * correctly. Mix_SetReverseStereo() returns without registering the effect + * function if the audio device is not configured for stereo output. + * + * If you specify MIX_CHANNEL_POST for (channel), then this the effect is used + * on the final mixed stream before sending it on to the audio device (a + * posteffect). + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if reversing effect is enabled. Note that an audio device in mono + * mode is a no-op, but this call will return successful in that case. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_SetReverseStereo(int channel, int flip); + +/* end of effects API. --ryan. */ + + +/* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate + them dynamically to the next sample if requested with a -1 value below. + Returns the number of reserved channels. + */ +extern DECLSPEC int SDLCALL Mix_ReserveChannels(int num); + +/* Channel grouping functions */ + +/* Attach a tag to a channel. A tag can be assigned to several mixer + channels, to form groups of channels. + If 'tag' is -1, the tag is removed (actually -1 is the tag used to + represent the group of all the channels). + Returns true if everything was OK. + */ +extern DECLSPEC int SDLCALL Mix_GroupChannel(int which, int tag); +/* Assign several consecutive channels to a group */ +extern DECLSPEC int SDLCALL Mix_GroupChannels(int from, int to, int tag); +/* Finds the first available channel in a group of channels, + returning -1 if none are available. + */ +extern DECLSPEC int SDLCALL Mix_GroupAvailable(int tag); +/* Returns the number of channels in a group. This is also a subtle + way to get the total number of channels when 'tag' is -1 + */ +extern DECLSPEC int SDLCALL Mix_GroupCount(int tag); +/* Finds the "oldest" sample playing in a group of channels */ +extern DECLSPEC int SDLCALL Mix_GroupOldest(int tag); +/* Finds the "most recent" (i.e. last) sample playing in a group of channels */ +extern DECLSPEC int SDLCALL Mix_GroupNewer(int tag); + +/* Play an audio chunk on a specific channel. + If the specified channel is -1, play on the first free channel. + If 'loops' is greater than zero, loop the sound that many times. + If 'loops' is -1, loop inifinitely (~65000 times). + Returns which channel was used to play the sound. +*/ +#define Mix_PlayChannel(channel,chunk,loops) Mix_PlayChannelTimed(channel,chunk,loops,-1) +/* The same as above, but the sound is played at most 'ticks' milliseconds */ +extern DECLSPEC int SDLCALL Mix_PlayChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ticks); +extern DECLSPEC int SDLCALL Mix_PlayMusic(Mix_Music *music, int loops); + +/* Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions */ +extern DECLSPEC int SDLCALL Mix_FadeInMusic(Mix_Music *music, int loops, int ms); +extern DECLSPEC int SDLCALL Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position); +#define Mix_FadeInChannel(channel,chunk,loops,ms) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1) +extern DECLSPEC int SDLCALL Mix_FadeInChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ms, int ticks); + +/* Set the volume in the range of 0-128 of a specific channel or chunk. + If the specified channel is -1, set volume for all channels. + Returns the original volume. + If the specified volume is -1, just return the current volume. +*/ +extern DECLSPEC int SDLCALL Mix_Volume(int channel, int volume); +extern DECLSPEC int SDLCALL Mix_VolumeChunk(Mix_Chunk *chunk, int volume); +extern DECLSPEC int SDLCALL Mix_VolumeMusic(int volume); +/* Get the current volume value in the range of 0-128 of a music stream */ +extern DECLSPEC int SDLCALL Mix_GetMusicVolume(Mix_Music *music); + +/* Halt playing of a particular channel */ +extern DECLSPEC int SDLCALL Mix_HaltChannel(int channel); +extern DECLSPEC int SDLCALL Mix_HaltGroup(int tag); +extern DECLSPEC int SDLCALL Mix_HaltMusic(void); + +/* Change the expiration delay for a particular channel. + The sample will stop playing after the 'ticks' milliseconds have elapsed, + or remove the expiration if 'ticks' is -1 +*/ +extern DECLSPEC int SDLCALL Mix_ExpireChannel(int channel, int ticks); + +/* Halt a channel, fading it out progressively till it's silent + The ms parameter indicates the number of milliseconds the fading + will take. + */ +extern DECLSPEC int SDLCALL Mix_FadeOutChannel(int which, int ms); +extern DECLSPEC int SDLCALL Mix_FadeOutGroup(int tag, int ms); +extern DECLSPEC int SDLCALL Mix_FadeOutMusic(int ms); + +/* Query the fading status of a channel */ +extern DECLSPEC Mix_Fading SDLCALL Mix_FadingMusic(void); +extern DECLSPEC Mix_Fading SDLCALL Mix_FadingChannel(int which); + +/* Pause/Resume a particular channel */ +extern DECLSPEC void SDLCALL Mix_Pause(int channel); +extern DECLSPEC void SDLCALL Mix_Resume(int channel); +extern DECLSPEC int SDLCALL Mix_Paused(int channel); + +/* Pause/Resume the music stream */ +extern DECLSPEC void SDLCALL Mix_PauseMusic(void); +extern DECLSPEC void SDLCALL Mix_ResumeMusic(void); +extern DECLSPEC void SDLCALL Mix_RewindMusic(void); +extern DECLSPEC int SDLCALL Mix_PausedMusic(void); + +/* Jump to a given order in mod music. + Returns 0 if successful, or -1 if failed or isn't implemented. + Only for MOD music formats. + */ +extern DECLSPEC int SDLCALL Mix_ModMusicJumpToOrder(int order); + +/* Set the current position in the music stream. + This returns 0 if successful, or -1 if it failed or isn't implemented. + This function is only implemented for MOD music formats (set pattern + order number) and for WAV, OGG, FLAC, MP3_MAD, MP3_MPG, and MODPLUG music + (set position in seconds), at the moment. +*/ +extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position); + +/* + Get the time current position of music stream + returns -1.0 if this feature is not supported for some codec + */ +extern DECLSPEC double SDLCALL Mix_GetMusicPosition(Mix_Music *music); + +/* Return music duration in seconds. + If NULL is passed, returns duration of current playing music. + Returns -1 on error. + */ +extern DECLSPEC double SDLCALL Mix_MusicDuration(Mix_Music *music); + +/* + Get the loop start time position of music stream + returns -1.0 if this feature is not used for this music or not supported for some codec + */ +extern DECLSPEC double SDLCALL Mix_GetMusicLoopStartTime(Mix_Music *music); +/* + Get the loop end time position of music stream + returns -1.0 if this feature is not used for this music or not supported for some codec + */ +extern DECLSPEC double SDLCALL Mix_GetMusicLoopEndTime(Mix_Music *music); +/* + Get the loop time length of music stream + returns -1.0 if this feature is not used for this music or not supported for some codec + */ +extern DECLSPEC double SDLCALL Mix_GetMusicLoopLengthTime(Mix_Music *music); + +/* Check the status of a specific channel. + If the specified channel is -1, check all channels. +*/ +extern DECLSPEC int SDLCALL Mix_Playing(int channel); +extern DECLSPEC int SDLCALL Mix_PlayingMusic(void); + +/* Stop music and set external music playback command */ +extern DECLSPEC int SDLCALL Mix_SetMusicCMD(const char *command); + +/* Synchro value is set by MikMod from modules while playing */ +extern DECLSPEC int SDLCALL Mix_SetSynchroValue(int value); +extern DECLSPEC int SDLCALL Mix_GetSynchroValue(void); + +/* Set/Get/Iterate SoundFonts paths to use by supported MIDI backends */ +extern DECLSPEC int SDLCALL Mix_SetSoundFonts(const char *paths); +extern DECLSPEC const char* SDLCALL Mix_GetSoundFonts(void); +extern DECLSPEC int SDLCALL Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data); + +/* Set/Get full path of Timidity config file (e.g. /etc/timidity.cfg) */ +extern DECLSPEC int SDLCALL Mix_SetTimidityCfg(const char *path); +extern DECLSPEC const char* SDLCALL Mix_GetTimidityCfg(void); + +/* Get the Mix_Chunk currently associated with a mixer channel + Returns NULL if it's an invalid channel, or there's no chunk associated. +*/ +extern DECLSPEC Mix_Chunk * SDLCALL Mix_GetChunk(int channel); + +/* Close the mixer, halting all playing audio */ +extern DECLSPEC void SDLCALL Mix_CloseAudio(void); + +/* We'll use SDL for reporting errors */ +#define Mix_SetError SDL_SetError +#define Mix_GetError SDL_GetError +#define Mix_ClearError SDL_ClearError + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_MIXER_H_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/load_aiff.c b/load_aiff.c deleted file mode 100644 index 42620a1..0000000 --- a/load_aiff.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - This is the source needed to decode an AIFF file into a waveform. - It's pretty straightforward once you get going. The only - externally-callable function is Mix_LoadAIFF_RW(), which is meant to - act as identically to SDL_LoadWAV_RW() as possible. - - This file by Torbjörn Andersson (torbjorn.andersson@eurotime.se) - 8SVX file support added by Marc Le Douarain (mavati@club-internet.fr) - in december 2002. -*/ - -#include "SDL_endian.h" -#include "SDL_mixer.h" -#include "load_aiff.h" - -/*********************************************/ -/* Define values for AIFF (IFF audio) format */ -/*********************************************/ -#define FORM 0x4d524f46 /* "FORM" */ - -#define AIFF 0x46464941 /* "AIFF" */ -#define SSND 0x444e5353 /* "SSND" */ -#define COMM 0x4d4d4f43 /* "COMM" */ - -#define _8SVX 0x58565338 /* "8SVX" */ -#define VHDR 0x52444856 /* "VHDR" */ -#define BODY 0x59444F42 /* "BODY" */ - -/* This function was taken from libsndfile. I don't pretend to fully - * understand it. - */ - -static Uint32 SANE_to_Uint32 (Uint8 *sanebuf) -{ - /* Is the frequency outside of what we can represent with Uint32? */ - if ((sanebuf[0] & 0x80) || (sanebuf[0] <= 0x3F) || (sanebuf[0] > 0x40) - || (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C)) - return 0; - - return ((sanebuf[2] << 23) | (sanebuf[3] << 15) | (sanebuf[4] << 7) - | (sanebuf[5] >> 1)) >> (29 - sanebuf[1]); -} - -/* This function is based on SDL_LoadWAV_RW(). */ - -SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc, - SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) -{ - int was_error; - int found_SSND; - int found_COMM; - int found_VHDR; - int found_BODY; - Sint64 start = 0; - - Uint32 chunk_type; - Uint32 chunk_length; - Sint64 next_chunk; - - /* AIFF magic header */ - Uint32 FORMchunk; - Uint32 AIFFmagic; - - /* SSND chunk */ - Uint32 offset; - Uint32 blocksize; - - /* COMM format chunk */ - Uint16 channels = 0; - Uint32 numsamples = 0; - Uint16 samplesize = 0; - Uint8 sane_freq[10]; - Uint32 frequency = 0; - - /* Make sure we are passed a valid data source */ - was_error = 0; - if (src == NULL) { - was_error = 1; - goto done; - } - - FORMchunk = SDL_ReadLE32(src); - chunk_length = SDL_ReadBE32(src); - if (chunk_length == AIFF) { /* The FORMchunk has already been read */ - AIFFmagic = chunk_length; - chunk_length = FORMchunk; - FORMchunk = FORM; - } else { - AIFFmagic = SDL_ReadLE32(src); - } - if ((FORMchunk != FORM) || ((AIFFmagic != AIFF) && (AIFFmagic != _8SVX))) { - SDL_SetError("Unrecognized file type (not AIFF nor 8SVX)"); - was_error = 1; - goto done; - } - - /* TODO: Better santity-checking. */ - - found_SSND = 0; - found_COMM = 0; - found_VHDR = 0; - found_BODY = 0; - - do { - chunk_type = SDL_ReadLE32(src); - chunk_length = SDL_ReadBE32(src); - next_chunk = SDL_RWtell(src) + chunk_length; - /* Paranoia to avoid infinite loops */ - if (chunk_length == 0) - break; - - switch (chunk_type) { - case SSND: - found_SSND = 1; - offset = SDL_ReadBE32(src); - blocksize = SDL_ReadBE32(src); - start = SDL_RWtell(src) + offset; - break; - - case COMM: - found_COMM = 1; - channels = SDL_ReadBE16(src); - numsamples = SDL_ReadBE32(src); - samplesize = SDL_ReadBE16(src); - SDL_RWread(src, sane_freq, sizeof(sane_freq), 1); - frequency = SANE_to_Uint32(sane_freq); - if (frequency == 0) { - SDL_SetError("Bad AIFF sample frequency"); - was_error = 1; - goto done; - } - break; - - case VHDR: - found_VHDR = 1; - SDL_ReadBE32(src); - SDL_ReadBE32(src); - SDL_ReadBE32(src); - frequency = SDL_ReadBE16(src); - channels = 1; - samplesize = 8; - break; - - case BODY: - found_BODY = 1; - numsamples = chunk_length; - start = SDL_RWtell(src); - break; - - default: - break; - } - /* a 0 pad byte can be stored for any odd-length chunk */ - if (chunk_length&1) - next_chunk++; - } while ((((AIFFmagic == AIFF) && (!found_SSND || !found_COMM)) - || ((AIFFmagic == _8SVX) && (!found_VHDR || !found_BODY))) - && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != 1); - - if ((AIFFmagic == AIFF) && !found_SSND) { - SDL_SetError("Bad AIFF (no SSND chunk)"); - was_error = 1; - goto done; - } - - if ((AIFFmagic == AIFF) && !found_COMM) { - SDL_SetError("Bad AIFF (no COMM chunk)"); - was_error = 1; - goto done; - } - - if ((AIFFmagic == _8SVX) && !found_VHDR) { - SDL_SetError("Bad 8SVX (no VHDR chunk)"); - was_error = 1; - goto done; - } - - if ((AIFFmagic == _8SVX) && !found_BODY) { - SDL_SetError("Bad 8SVX (no BODY chunk)"); - was_error = 1; - goto done; - } - - /* Decode the audio data format */ - SDL_memset(spec, 0, sizeof(*spec)); - spec->freq = frequency; - switch (samplesize) { - case 8: - spec->format = AUDIO_S8; - break; - case 16: - spec->format = AUDIO_S16MSB; - break; - default: - SDL_SetError("Unsupported AIFF samplesize"); - was_error = 1; - goto done; - } - spec->channels = (Uint8) channels; - spec->samples = 4096; /* Good default buffer size */ - - *audio_len = channels * numsamples * (samplesize / 8); - *audio_buf = (Uint8 *)SDL_malloc(*audio_len); - if (*audio_buf == NULL) { - SDL_SetError("Out of memory"); - return(NULL); - } - SDL_RWseek(src, start, RW_SEEK_SET); - if (SDL_RWread(src, *audio_buf, *audio_len, 1) != 1) { - SDL_SetError("Unable to read audio data"); - return(NULL); - } - - /* Don't return a buffer that isn't a multiple of samplesize */ - *audio_len &= ~((samplesize / 8) - 1); - -done: - if (freesrc && src) { - SDL_RWclose(src); - } - if (was_error) { - spec = NULL; - } - return(spec); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/load_aiff.h b/load_aiff.h deleted file mode 100644 index 4fd876c..0000000 --- a/load_aiff.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - This is the source needed to decode an AIFF file into a waveform. - It's pretty straightforward once you get going. The only - externally-callable function is Mix_LoadAIFF_RW(), which is meant to - act as identically to SDL_LoadWAV_RW() as possible. - - This file by Torbjörn Andersson (torbjorn.andersson@eurotime.se) -*/ - -/* Don't call this directly; use Mix_LoadWAV_RW() for now. */ -SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc, - SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/load_voc.c b/load_voc.c deleted file mode 100644 index 7f0ab2d..0000000 --- a/load_voc.c +++ /dev/null @@ -1,451 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - This is the source needed to decode a Creative Labs VOC file into a - waveform. It's pretty straightforward once you get going. The only - externally-callable function is Mix_LoadVOC_RW(), which is meant to - act as identically to SDL_LoadWAV_RW() as possible. - - This file by Ryan C. Gordon (icculus@icculus.org). - - Heavily borrowed from sox v12.17.1's voc.c. - (http://www.freshmeat.net/projects/sox/) -*/ - -#include "SDL_mixer.h" -#include "load_voc.h" - -/* Private data for VOC file */ -typedef struct vocstuff { - Uint32 rest; /* bytes remaining in current block */ - Uint32 rate; /* rate code (byte) of this chunk */ - int silent; /* sound or silence? */ - Uint32 srate; /* rate code (byte) of silence */ - Uint32 blockseek; /* start of current output block */ - Uint32 samples; /* number of samples output */ - Uint32 size; /* word length of data */ - Uint8 channels; /* number of sound channels */ - int has_extended; /* Has an extended block been read? */ -} vs_t; - -/* Size field */ -/* SJB: note that the 1st 3 are sometimes used as sizeof(type) */ -#define ST_SIZE_BYTE 1 -#define ST_SIZE_8BIT 1 -#define ST_SIZE_WORD 2 -#define ST_SIZE_16BIT 2 -#define ST_SIZE_DWORD 4 -#define ST_SIZE_32BIT 4 -#define ST_SIZE_FLOAT 5 -#define ST_SIZE_DOUBLE 6 -#define ST_SIZE_IEEE 7 /* IEEE 80-bit floats. */ - -/* Style field */ -#define ST_ENCODING_UNSIGNED 1 /* unsigned linear: Sound Blaster */ -#define ST_ENCODING_SIGN2 2 /* signed linear 2's comp: Mac */ -#define ST_ENCODING_ULAW 3 /* U-law signed logs: US telephony, SPARC */ -#define ST_ENCODING_ALAW 4 /* A-law signed logs: non-US telephony */ -#define ST_ENCODING_ADPCM 5 /* Compressed PCM */ -#define ST_ENCODING_IMA_ADPCM 6 /* Compressed PCM */ -#define ST_ENCODING_GSM 7 /* GSM 6.10 33-byte frame lossy compression */ - -#define VOC_TERM 0 -#define VOC_DATA 1 -#define VOC_CONT 2 -#define VOC_SILENCE 3 -#define VOC_MARKER 4 -#define VOC_TEXT 5 -#define VOC_LOOP 6 -#define VOC_LOOPEND 7 -#define VOC_EXTENDED 8 -#define VOC_DATA_16 9 - - -static int voc_check_header(SDL_RWops *src) -{ - /* VOC magic header */ - Uint8 signature[20]; /* "Creative Voice File\032" */ - Uint16 datablockofs; - - SDL_RWseek(src, 0, RW_SEEK_SET); - - if (SDL_RWread(src, signature, sizeof (signature), 1) != 1) - return(0); - - if (SDL_memcmp(signature, "Creative Voice File\032", sizeof (signature)) != 0) { - SDL_SetError("Unrecognized file type (not VOC)"); - return(0); - } - - /* get the offset where the first datablock is located */ - if (SDL_RWread(src, &datablockofs, sizeof (Uint16), 1) != 1) - return(0); - - datablockofs = SDL_SwapLE16(datablockofs); - - if (SDL_RWseek(src, datablockofs, RW_SEEK_SET) != datablockofs) - return(0); - - return(1); /* success! */ -} /* voc_check_header */ - - -/* Read next block header, save info, leave position at start of data */ -static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec) -{ - Uint8 bits24[3]; - Uint8 uc, block; - Uint32 sblen; - Uint16 new_rate_short; - Uint32 new_rate_long; - Uint8 trash[6]; - Uint16 period; - unsigned int i; - - v->silent = 0; - while (v->rest == 0) - { - if (SDL_RWread(src, &block, sizeof (block), 1) != 1) - return 1; /* assume that's the end of the file. */ - - if (block == VOC_TERM) - return 1; - - if (SDL_RWread(src, bits24, sizeof (bits24), 1) != 1) - return 1; /* assume that's the end of the file. */ - - /* Size is an 24-bit value. Ugh. */ - sblen = ((bits24[0]) | (bits24[1] << 8) | (bits24[2] << 16)); - - switch(block) - { - case VOC_DATA: - if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1) - return 0; - - /* When DATA block preceeded by an EXTENDED */ - /* block, the DATA blocks rate value is invalid */ - if (!v->has_extended) - { - if (uc == 0) - { - SDL_SetError("VOC Sample rate is zero?"); - return 0; - } - - if ((v->rate != -1) && (uc != v->rate)) - { - SDL_SetError("VOC sample rate codes differ"); - return 0; - } - - v->rate = uc; - spec->freq = (Uint16)(1000000.0/(256 - v->rate)); - v->channels = 1; - } - - if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1) - return 0; - - if (uc != 0) - { - SDL_SetError("VOC decoder only interprets 8-bit data"); - return 0; - } - - v->has_extended = 0; - v->rest = sblen - 2; - v->size = ST_SIZE_BYTE; - return 1; - - case VOC_DATA_16: - if (SDL_RWread(src, &new_rate_long, sizeof (new_rate_long), 1) != 1) - return 0; - new_rate_long = SDL_SwapLE32(new_rate_long); - if (new_rate_long == 0) - { - SDL_SetError("VOC Sample rate is zero?"); - return 0; - } - if ((v->rate != -1) && (new_rate_long != v->rate)) - { - SDL_SetError("VOC sample rate codes differ"); - return 0; - } - v->rate = new_rate_long; - spec->freq = new_rate_long; - - if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1) - return 0; - - switch (uc) - { - case 8: v->size = ST_SIZE_BYTE; break; - case 16: v->size = ST_SIZE_WORD; break; - default: - SDL_SetError("VOC with unknown data size"); - return 0; - } - - if (SDL_RWread(src, &v->channels, sizeof (Uint8), 1) != 1) - return 0; - - if (SDL_RWread(src, trash, sizeof (Uint8), 6) != 6) - return 0; - - v->rest = sblen - 12; - return 1; - - case VOC_CONT: - v->rest = sblen; - return 1; - - case VOC_SILENCE: - if (SDL_RWread(src, &period, sizeof (period), 1) != 1) - return 0; - period = SDL_SwapLE16(period); - - if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1) - return 0; - if (uc == 0) - { - SDL_SetError("VOC silence sample rate is zero"); - return 0; - } - - /* - * Some silence-packed files have gratuitously - * different sample rate codes in silence. - * Adjust period. - */ - if ((v->rate != -1) && (uc != v->rate)) - period = (Uint16)((period * (256 - uc))/(256 - v->rate)); - else - v->rate = uc; - v->rest = period; - v->silent = 1; - return 1; - - case VOC_LOOP: - case VOC_LOOPEND: - for(i = 0; i < sblen; i++) /* skip repeat loops. */ - { - if (SDL_RWread(src, trash, sizeof (Uint8), 1) != 1) - return 0; - } - break; - - case VOC_EXTENDED: - /* An Extended block is followed by a data block */ - /* Set this byte so we know to use the rate */ - /* value from the extended block and not the */ - /* data block. */ - v->has_extended = 1; - if (SDL_RWread(src, &new_rate_short, sizeof (new_rate_short), 1) != 1) - return 0; - new_rate_short = SDL_SwapLE16(new_rate_short); - if (new_rate_short == 0) - { - SDL_SetError("VOC sample rate is zero"); - return 0; - } - if ((v->rate != -1) && (new_rate_short != v->rate)) - { - SDL_SetError("VOC sample rate codes differ"); - return 0; - } - v->rate = new_rate_short; - - if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1) - return 0; - - if (uc != 0) - { - SDL_SetError("VOC decoder only interprets 8-bit data"); - return 0; - } - - if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1) - return 0; - - if (uc) - spec->channels = 2; /* Stereo */ - /* Needed number of channels before finishing - compute for rate */ - spec->freq = (256000000L/(65536L - v->rate))/spec->channels; - /* An extended block must be followed by a data */ - /* block to be valid so loop back to top so it */ - /* can be grabed. */ - continue; - - case VOC_MARKER: - if (SDL_RWread(src, trash, sizeof (Uint8), 2) != 2) - return 0; - - /* Falling! Falling! */ - - default: /* text block or other krapola. */ - for(i = 0; i < sblen; i++) - { - if (SDL_RWread(src, &trash, sizeof (Uint8), 1) != 1) - return 0; - } - - if (block == VOC_TEXT) - continue; /* get next block */ - } - } - - return 1; -} - - -static int voc_read(SDL_RWops *src, vs_t *v, Uint8 *buf, SDL_AudioSpec *spec) -{ - Uint32 done = 0; - Uint8 silence = 0x80; - - if (v->rest == 0) - { - if (!voc_get_block(src, v, spec)) - return 0; - } - - if (v->rest == 0) - return 0; - - if (v->silent) - { - if (v->size == ST_SIZE_WORD) - silence = 0x00; - - /* Fill in silence */ - SDL_memset(buf, silence, v->rest); - done = v->rest; - v->rest = 0; - } - - else - { - done = (Uint32)SDL_RWread(src, buf, 1, v->rest); - v->rest -= done; - if (v->size == ST_SIZE_WORD) - { - #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - Uint16 *samples = (Uint16 *)buf; - for (; v->rest > 0; v->rest -= 2) - { - *samples = SDL_SwapLE16(*samples); - samples++; - } - #endif - done >>= 1; - } - } - - return done; -} /* voc_read */ - - -/* don't call this directly; use Mix_LoadWAV_RW() for now. */ -SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc, - SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) -{ - vs_t v; - int was_error = 1; - int samplesize; - Uint8 *fillptr; - void *ptr; - - if ((!src) || (!audio_buf) || (!audio_len)) /* sanity checks. */ - goto done; - - if (!voc_check_header(src)) - goto done; - - v.rate = -1; - v.rest = 0; - v.has_extended = 0; - *audio_buf = NULL; - *audio_len = 0; - SDL_memset(spec, '\0', sizeof (SDL_AudioSpec)); - - if (!voc_get_block(src, &v, spec)) - goto done; - - if (v.rate == -1) - { - SDL_SetError("VOC data had no sound!"); - goto done; - } - - spec->format = ((v.size == ST_SIZE_WORD) ? AUDIO_S16 : AUDIO_U8); - if (spec->channels == 0) - spec->channels = v.channels; - - *audio_len = v.rest; - *audio_buf = SDL_malloc(v.rest); - if (*audio_buf == NULL) - goto done; - - fillptr = *audio_buf; - - while (voc_read(src, &v, fillptr, spec) > 0) - { - if (!voc_get_block(src, &v, spec)) - goto done; - - *audio_len += v.rest; - ptr = SDL_realloc(*audio_buf, *audio_len); - if (ptr == NULL) - { - SDL_free(*audio_buf); - *audio_buf = NULL; - *audio_len = 0; - goto done; - } - - *audio_buf = ptr; - fillptr = ((Uint8 *) ptr) + (*audio_len - v.rest); - } - - spec->samples = (Uint16)(*audio_len / v.size); - - was_error = 0; /* success, baby! */ - - /* Don't return a buffer that isn't a multiple of samplesize */ - samplesize = ((spec->format & 0xFF)/8)*spec->channels; - *audio_len &= ~(samplesize-1); - -done: - if (freesrc && src) { - SDL_RWclose(src); - } - - if (was_error) { - spec = NULL; - } - - return(spec); -} /* Mix_LoadVOC_RW */ - -/* end of load_voc.c ... */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/load_voc.h b/load_voc.h deleted file mode 100644 index f177ce1..0000000 --- a/load_voc.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - This is the source needed to decode a Creative Labs VOC file into a - waveform. It's pretty straightforward once you get going. The only - externally-callable function is Mix_LoadVOC_RW(), which is meant to - act as identically to SDL_LoadWAV_RW() as possible. - - This file by Ryan C. Gordon (icculus@icculus.org). - - Heavily borrowed from sox v12.17.1's voc.c. - (http://www.freshmeat.net/projects/sox/) -*/ - -/* Don't call this directly; use Mix_LoadWAV_RW() for now. */ -SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc, - SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/mixer.c b/mixer.c deleted file mode 100644 index ba2b407..0000000 --- a/mixer.c +++ /dev/null @@ -1,1610 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* $Id$ */ - -#include -#include -#include - -#include "SDL.h" - -#include "SDL_mixer.h" -#include "mixer.h" -#include "music.h" -#include "load_aiff.h" -#include "load_voc.h" - -#define __MIX_INTERNAL_EFFECT__ -#include "effects_internal.h" - -/* Magic numbers for various audio file formats */ -#define RIFF 0x46464952 /* "RIFF" */ -#define WAVE 0x45564157 /* "WAVE" */ -#define FORM 0x4d524f46 /* "FORM" */ -#define CREA 0x61657243 /* "Crea" */ - -static int audio_opened = 0; -static SDL_AudioSpec mixer; -static SDL_AudioDeviceID audio_device; - -typedef struct _Mix_effectinfo -{ - Mix_EffectFunc_t callback; - Mix_EffectDone_t done_callback; - void *udata; - struct _Mix_effectinfo *next; -} effect_info; - -static struct _Mix_Channel { - Mix_Chunk *chunk; - int playing; - int paused; - Uint8 *samples; - int volume; - int looping; - int tag; - Uint32 expire; - Uint32 start_time; - Mix_Fading fading; - int fade_volume; - int fade_volume_reset; - Uint32 fade_length; - Uint32 ticks_fade; - effect_info *effects; -} *mix_channel = NULL; - -static effect_info *posteffects = NULL; - -static int num_channels; -static int reserved_channels = 0; - - -/* Support for hooking into the mixer callback system */ -static void (SDLCALL *mix_postmix)(void *udata, Uint8 *stream, int len) = NULL; -static void *mix_postmix_data = NULL; - -/* rcg07062001 callback to alert when channels are done playing. */ -static void (SDLCALL *channel_done_callback)(int channel) = NULL; - -/* Support for user defined music functions */ -static void (SDLCALL *mix_music)(void *udata, Uint8 *stream, int len) = music_mixer; -static void *music_data = NULL; - -/* rcg06042009 report available decoders at runtime. */ -static const char **chunk_decoders = NULL; -static int num_decoders = 0; - - -int Mix_GetNumChunkDecoders(void) -{ - return(num_decoders); -} - -const char *Mix_GetChunkDecoder(int index) -{ - if ((index < 0) || (index >= num_decoders)) { - return NULL; - } - return(chunk_decoders[index]); -} - -SDL_bool Mix_HasChunkDecoder(const char *name) -{ - int index; - for (index = 0; index < num_decoders; ++index) { - if (SDL_strcasecmp(name, chunk_decoders[index]) == 0) { - return SDL_TRUE; - } - } - return SDL_FALSE; -} - -void add_chunk_decoder(const char *decoder) -{ - int i; - void *ptr; - - /* Check to see if we already have this decoder */ - for (i = 0; i < num_decoders; ++i) { - if (SDL_strcmp(chunk_decoders[i], decoder) == 0) { - return; - } - } - - ptr = SDL_realloc((void *)chunk_decoders, (num_decoders + 1) * sizeof (const char *)); - if (ptr == NULL) { - return; /* oh well, go on without it. */ - } - chunk_decoders = (const char **) ptr; - chunk_decoders[num_decoders++] = decoder; -} - -/* rcg06192001 get linked library's version. */ -const SDL_version *Mix_Linked_Version(void) -{ - static SDL_version linked_version; - SDL_MIXER_VERSION(&linked_version); - return(&linked_version); -} - -int Mix_Init(int flags) -{ - int result = 0; - - if (flags & MIX_INIT_FLAC) { - if (load_music_type(MUS_FLAC)) { - open_music_type(MUS_FLAC); - result |= MIX_INIT_FLAC; - } else { - Mix_SetError("FLAC support not available"); - } - } - if (flags & MIX_INIT_MOD) { - if (load_music_type(MUS_MOD)) { - open_music_type(MUS_MOD); - result |= MIX_INIT_MOD; - } else { - Mix_SetError("MOD support not available"); - } - } - if (flags & MIX_INIT_MP3) { - if (load_music_type(MUS_MP3)) { - open_music_type(MUS_MP3); - result |= MIX_INIT_MP3; - } else { - Mix_SetError("MP3 support not available"); - } - } - if (flags & MIX_INIT_OGG) { - if (load_music_type(MUS_OGG)) { - open_music_type(MUS_OGG); - result |= MIX_INIT_OGG; - } else { - Mix_SetError("OGG support not available"); - } - } - if (flags & MIX_INIT_OPUS) { - if (load_music_type(MUS_OPUS)) { - open_music_type(MUS_OPUS); - result |= MIX_INIT_OPUS; - } else { - Mix_SetError("OPUS support not available"); - } - } - if (flags & MIX_INIT_MID) { - if (load_music_type(MUS_MID)) { - open_music_type(MUS_MID); - result |= MIX_INIT_MID; - } else { - Mix_SetError("MIDI support not available"); - } - } - return result; -} - -void Mix_Quit() -{ - unload_music(); -} - -static int _Mix_remove_all_effects(int channel, effect_info **e); - -/* - * rcg06122001 Cleanup effect callbacks. - * MAKE SURE Mix_LockAudio() is called before this (or you're in the - * audio callback). - */ -static void _Mix_channel_done_playing(int channel) -{ - if (channel_done_callback) { - channel_done_callback(channel); - } - - /* - * Call internal function directly, to avoid locking audio from - * inside audio callback. - */ - _Mix_remove_all_effects(channel, &mix_channel[channel].effects); -} - - -static void *Mix_DoEffects(int chan, void *snd, int len) -{ - int posteffect = (chan == MIX_CHANNEL_POST); - effect_info *e = ((posteffect) ? posteffects : mix_channel[chan].effects); - void *buf = snd; - - if (e != NULL) { /* are there any registered effects? */ - /* if this is the postmix, we can just overwrite the original. */ - if (!posteffect) { - buf = SDL_malloc(len); - if (buf == NULL) { - return(snd); - } - SDL_memcpy(buf, snd, len); - } - - for (; e != NULL; e = e->next) { - if (e->callback != NULL) { - e->callback(chan, buf, len, e->udata); - } - } - } - - /* be sure to SDL_free() the return value if != snd ... */ - return(buf); -} - - -/* Mixing function */ -static void SDLCALL -mix_channels(void *udata, Uint8 *stream, int len) -{ - Uint8 *mix_input; - int i, mixable, volume = MIX_MAX_VOLUME; - Uint32 sdl_ticks; - -#if SDL_VERSION_ATLEAST(1, 3, 0) - /* Need to initialize the stream in SDL 1.3+ */ - SDL_memset(stream, mixer.silence, len); -#endif - - /* Mix the music (must be done before the channels are added) */ - mix_music(music_data, stream, len); - - /* Mix any playing channels... */ - sdl_ticks = SDL_GetTicks(); - for (i=0; i 0 && mix_channel[i].expire < sdl_ticks) { - /* Expiration delay for that channel is reached */ - mix_channel[i].playing = 0; - mix_channel[i].looping = 0; - mix_channel[i].fading = MIX_NO_FADING; - mix_channel[i].expire = 0; - _Mix_channel_done_playing(i); - } else if (mix_channel[i].fading != MIX_NO_FADING) { - Uint32 ticks = sdl_ticks - mix_channel[i].ticks_fade; - if (ticks >= mix_channel[i].fade_length) { - Mix_Volume(i, mix_channel[i].fade_volume_reset); /* Restore the volume */ - if(mix_channel[i].fading == MIX_FADING_OUT) { - mix_channel[i].playing = 0; - mix_channel[i].looping = 0; - mix_channel[i].expire = 0; - _Mix_channel_done_playing(i); - } - mix_channel[i].fading = MIX_NO_FADING; - } else { - if (mix_channel[i].fading == MIX_FADING_OUT) { - Mix_Volume(i, (mix_channel[i].fade_volume * (mix_channel[i].fade_length-ticks)) - / mix_channel[i].fade_length); - } else { - Mix_Volume(i, (mix_channel[i].fade_volume * ticks) / mix_channel[i].fade_length); - } - } - } - if (mix_channel[i].playing > 0) { - int index = 0; - int remaining = len; - while (mix_channel[i].playing > 0 && index < len) { - remaining = len - index; - volume = (mix_channel[i].volume*mix_channel[i].chunk->volume) / MIX_MAX_VOLUME; - mixable = mix_channel[i].playing; - if (mixable > remaining) { - mixable = remaining; - } - - mix_input = Mix_DoEffects(i, mix_channel[i].samples, mixable); - SDL_MixAudioFormat(stream+index,mix_input,mixer.format,mixable,volume); - if (mix_input != mix_channel[i].samples) - SDL_free(mix_input); - - mix_channel[i].samples += mixable; - mix_channel[i].playing -= mixable; - index += mixable; - - /* rcg06072001 Alert app if channel is done playing. */ - if (!mix_channel[i].playing && !mix_channel[i].looping) { - _Mix_channel_done_playing(i); - } - } - - /* If looping the sample and we are at its end, make sure - we will still return a full buffer */ - while (mix_channel[i].looping && index < len) { - int alen = mix_channel[i].chunk->alen; - remaining = len - index; - if (remaining > alen) { - remaining = alen; - } - - mix_input = Mix_DoEffects(i, mix_channel[i].chunk->abuf, remaining); - SDL_MixAudioFormat(stream+index, mix_input, mixer.format, remaining, volume); - if (mix_input != mix_channel[i].chunk->abuf) - SDL_free(mix_input); - - if (mix_channel[i].looping > 0) { - --mix_channel[i].looping; - } - mix_channel[i].samples = mix_channel[i].chunk->abuf + remaining; - mix_channel[i].playing = mix_channel[i].chunk->alen - remaining; - index += remaining; - } - if (! mix_channel[i].playing && mix_channel[i].looping) { - if (mix_channel[i].looping > 0) { - --mix_channel[i].looping; - } - mix_channel[i].samples = mix_channel[i].chunk->abuf; - mix_channel[i].playing = mix_channel[i].chunk->alen; - } - } - } - } - - /* rcg06122001 run posteffects... */ - Mix_DoEffects(MIX_CHANNEL_POST, stream, len); - - if (mix_postmix) { - mix_postmix(mix_postmix_data, stream, len); - } -} - -#if 0 -static void PrintFormat(char *title, SDL_AudioSpec *fmt) -{ - printf("%s: %d bit %s audio (%s) at %u Hz\n", title, (fmt->format&0xFF), - (fmt->format&0x8000) ? "signed" : "unsigned", - (fmt->channels > 2) ? "surround" : - (fmt->channels > 1) ? "stereo" : "mono", fmt->freq); -} -#endif - -/* Open the mixer with a certain desired audio format */ -int Mix_OpenAudioDevice(int frequency, Uint16 format, int nchannels, int chunksize, - const char* device, int allowed_changes) -{ - int i; - SDL_AudioSpec desired; - - /* This used to call SDL_OpenAudio(), which initializes the audio - subsystem if necessary. Since SDL_OpenAudioDevice() doesn't, - we have to handle this case here. */ - if (!SDL_WasInit(SDL_INIT_AUDIO)) { - if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) { - return -1; - } - } - - /* If the mixer is already opened, increment open count */ - if (audio_opened) { - if (format == mixer.format && nchannels == mixer.channels) { - ++audio_opened; - return(0); - } - while (audio_opened) { - Mix_CloseAudio(); - } - } - - /* Set the desired format and frequency */ - desired.freq = frequency; - desired.format = format; - desired.channels = nchannels; - desired.samples = chunksize; - desired.callback = mix_channels; - desired.userdata = NULL; - - /* Accept nearly any audio format */ - if ((audio_device = SDL_OpenAudioDevice(device, 0, &desired, &mixer, allowed_changes)) == 0) { - return(-1); - } -#if 0 - PrintFormat("Audio device", &mixer); -#endif - - num_channels = MIX_CHANNELS; - mix_channel = (struct _Mix_Channel *) SDL_malloc(num_channels * sizeof(struct _Mix_Channel)); - - /* Clear out the audio channels */ - for (i=0; i num_channels) { - /* Initialize the new channels */ - int i; - for(i=num_channels; i < numchans; i++) { - mix_channel[i].chunk = NULL; - mix_channel[i].playing = 0; - mix_channel[i].looping = 0; - mix_channel[i].volume = MIX_MAX_VOLUME; - mix_channel[i].fade_volume = MIX_MAX_VOLUME; - mix_channel[i].fade_volume_reset = MIX_MAX_VOLUME; - mix_channel[i].fading = MIX_NO_FADING; - mix_channel[i].tag = -1; - mix_channel[i].expire = 0; - mix_channel[i].effects = NULL; - mix_channel[i].paused = 0; - } - } - num_channels = numchans; - Mix_UnlockAudio(); - return(num_channels); -} - -/* Return the actual mixer parameters */ -int Mix_QuerySpec(int *frequency, Uint16 *format, int *channels) -{ - if (audio_opened) { - if (frequency) { - *frequency = mixer.freq; - } - if (format) { - *format = mixer.format; - } - if (channels) { - *channels = mixer.channels; - } - } - return(audio_opened); -} - -typedef struct _MusicFragment -{ - Uint8 *data; - int size; - struct _MusicFragment *next; -} MusicFragment; - -static SDL_AudioSpec *Mix_LoadMusic_RW(Mix_MusicType music_type, SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) -{ - int i; - Mix_MusicInterface *interface = NULL; - void *music = NULL; - Sint64 start; - SDL_bool playing; - MusicFragment *first = NULL, *last = NULL, *fragment = NULL; - int count = 0; - int fragment_size; - - if (!load_music_type(music_type) || !open_music_type(music_type)) { - return NULL; - } - - *spec = mixer; - - /* Use fragments sized on full audio frame boundaries - this'll do */ - fragment_size = spec->size; - - start = SDL_RWtell(src); - for (i = 0; i < get_num_music_interfaces(); ++i) { - interface = get_music_interface(i); - if (!interface->opened) { - continue; - } - if (interface->type != music_type) { - continue; - } - if (!interface->CreateFromRW || !interface->GetAudio) { - continue; - } - - /* These music interfaces are not safe to use while music is playing */ - if (interface->api == MIX_MUSIC_CMD || - interface->api == MIX_MUSIC_MIKMOD || - interface->api == MIX_MUSIC_NATIVEMIDI) { - continue; - } - - music = interface->CreateFromRW(src, freesrc); - if (music) { - /* The interface owns the data source now */ - freesrc = SDL_FALSE; - break; - } - - /* Reset the stream for the next decoder */ - SDL_RWseek(src, start, RW_SEEK_SET); - } - - if (!music) { - if (freesrc) { - SDL_RWclose(src); - } - Mix_SetError("Unrecognized audio format"); - return NULL; - } - - Mix_LockAudio(); - - if (interface->Play) { - interface->Play(music, 1); - } - playing = SDL_TRUE; - - while (playing) { - int left; - - fragment = (MusicFragment *)SDL_malloc(sizeof(*fragment)); - if (!fragment) { - /* Uh oh, out of memory, let's return what we have */ - break; - } - fragment->data = (Uint8 *)SDL_malloc(fragment_size); - if (!fragment->data) { - /* Uh oh, out of memory, let's return what we have */ - SDL_free(fragment); - break; - } - fragment->next = NULL; - - left = interface->GetAudio(music, fragment->data, fragment_size); - if (left > 0) { - playing = SDL_FALSE; - } else if (interface->IsPlaying) { - playing = interface->IsPlaying(music); - } - fragment->size = (fragment_size - left); - - if (!first) { - first = fragment; - } - if (last) { - last->next = fragment; - } - last = fragment; - ++count; - } - - if (interface->Stop) { - interface->Stop(music); - } - - if (music) { - interface->Delete(music); - } - - Mix_UnlockAudio(); - - if (count > 0) { - *audio_len = (count - 1) * fragment_size + fragment->size; - *audio_buf = (Uint8 *)SDL_malloc(*audio_len); - if (*audio_buf) { - Uint8 *dst = *audio_buf; - for (fragment = first; fragment; fragment = fragment->next) { - SDL_memcpy(dst, fragment->data, fragment->size); - dst += fragment->size; - } - } else { - SDL_OutOfMemory(); - spec = NULL; - } - } else { - Mix_SetError("No audio data"); - spec = NULL; - } - - while (first) { - fragment = first; - first = first->next; - SDL_free(fragment->data); - SDL_free(fragment); - } - - if (freesrc) { - SDL_RWclose(src); - } - return spec; -} - -/* Load a wave file */ -Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc) -{ - Uint8 magic[4]; - Mix_Chunk *chunk; - SDL_AudioSpec wavespec, *loaded; - SDL_AudioCVT wavecvt; - int samplesize; - - /* rcg06012001 Make sure src is valid */ - if (!src) { - SDL_SetError("Mix_LoadWAV_RW with NULL src"); - return(NULL); - } - - /* Make sure audio has been opened */ - if (!audio_opened) { - SDL_SetError("Audio device hasn't been opened"); - if (freesrc) { - SDL_RWclose(src); - } - return(NULL); - } - - /* Allocate the chunk memory */ - chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk)); - if (chunk == NULL) { - SDL_SetError("Out of memory"); - if (freesrc) { - SDL_RWclose(src); - } - return(NULL); - } - - /* Find out what kind of audio file this is */ - if (SDL_RWread(src, magic, 1, 4) != 4) { - if (freesrc) { - SDL_RWclose(src); - } - Mix_SetError("Couldn't read first 4 bytes of audio data"); - return NULL; - } - /* Seek backwards for compatibility with older loaders */ - SDL_RWseek(src, -4, RW_SEEK_CUR); - - if (SDL_memcmp(magic, "WAVE", 4) == 0 || SDL_memcmp(magic, "RIFF", 4) == 0) { - loaded = SDL_LoadWAV_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen); - } else if (SDL_memcmp(magic, "FORM", 4) == 0) { - loaded = Mix_LoadAIFF_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen); - } else if (SDL_memcmp(magic, "Crea", 4) == 0) { - loaded = Mix_LoadVOC_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen); - } else { - Mix_MusicType music_type = detect_music_type_from_magic(magic); - loaded = Mix_LoadMusic_RW(music_type, src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen); - } - if (!loaded) { - /* The individual loaders have closed src if needed */ - SDL_free(chunk); - return(NULL); - } - -#if 0 - PrintFormat("Audio device", &mixer); - PrintFormat("-- Wave file", &wavespec); -#endif - - /* Build the audio converter and create conversion buffers */ - if (wavespec.format != mixer.format || - wavespec.channels != mixer.channels || - wavespec.freq != mixer.freq) { - if (SDL_BuildAudioCVT(&wavecvt, - wavespec.format, wavespec.channels, wavespec.freq, - mixer.format, mixer.channels, mixer.freq) < 0) { - SDL_free(chunk->abuf); - SDL_free(chunk); - return(NULL); - } - samplesize = ((wavespec.format & 0xFF)/8)*wavespec.channels; - wavecvt.len = chunk->alen & ~(samplesize-1); - wavecvt.buf = (Uint8 *)SDL_calloc(1, wavecvt.len*wavecvt.len_mult); - if (wavecvt.buf == NULL) { - SDL_SetError("Out of memory"); - SDL_free(chunk->abuf); - SDL_free(chunk); - return(NULL); - } - SDL_memcpy(wavecvt.buf, chunk->abuf, wavecvt.len); - SDL_free(chunk->abuf); - - /* Run the audio converter */ - if (SDL_ConvertAudio(&wavecvt) < 0) { - SDL_free(wavecvt.buf); - SDL_free(chunk); - return(NULL); - } - - chunk->abuf = wavecvt.buf; - chunk->alen = wavecvt.len_cvt; - } - - chunk->allocated = 1; - chunk->volume = MIX_MAX_VOLUME; - - return(chunk); -} - -/* Load a wave file of the mixer format from a memory buffer */ -Mix_Chunk *Mix_QuickLoad_WAV(Uint8 *mem) -{ - Mix_Chunk *chunk; - Uint8 magic[4]; - - /* Make sure audio has been opened */ - if (! audio_opened) { - SDL_SetError("Audio device hasn't been opened"); - return(NULL); - } - - /* Allocate the chunk memory */ - chunk = (Mix_Chunk *)SDL_calloc(1,sizeof(Mix_Chunk)); - if (chunk == NULL) { - SDL_SetError("Out of memory"); - return(NULL); - } - - /* Essentially just skip to the audio data (no error checking - fast) */ - chunk->allocated = 0; - mem += 12; /* WAV header */ - do { - SDL_memcpy(magic, mem, 4); - mem += 4; - chunk->alen = ((mem[3]<<24)|(mem[2]<<16)|(mem[1]<<8)|(mem[0])); - mem += 4; - chunk->abuf = mem; - mem += chunk->alen; - } while (memcmp(magic, "data", 4) != 0); - chunk->volume = MIX_MAX_VOLUME; - - return(chunk); -} - -/* Load raw audio data of the mixer format from a memory buffer */ -Mix_Chunk *Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len) -{ - Mix_Chunk *chunk; - - /* Make sure audio has been opened */ - if (! audio_opened) { - SDL_SetError("Audio device hasn't been opened"); - return(NULL); - } - - /* Allocate the chunk memory */ - chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk)); - if (chunk == NULL) { - SDL_SetError("Out of memory"); - return(NULL); - } - - /* Essentially just point at the audio data (no error checking - fast) */ - chunk->allocated = 0; - chunk->alen = len; - chunk->abuf = mem; - chunk->volume = MIX_MAX_VOLUME; - - return(chunk); -} - -/* Free an audio chunk previously loaded */ -void Mix_FreeChunk(Mix_Chunk *chunk) -{ - int i; - - /* Caution -- if the chunk is playing, the mixer will crash */ - if (chunk) { - /* Guarantee that this chunk isn't playing */ - Mix_LockAudio(); - if (mix_channel) { - for (i=0; iallocated) { - SDL_free(chunk->abuf); - } - SDL_free(chunk); - } -} - -/* Set a function that is called after all mixing is performed. - This can be used to provide real-time visual display of the audio stream - or add a custom mixer filter for the stream data. -*/ -void Mix_SetPostMix(void (SDLCALL *mix_func) - (void *udata, Uint8 *stream, int len), void *arg) -{ - Mix_LockAudio(); - mix_postmix_data = arg; - mix_postmix = mix_func; - Mix_UnlockAudio(); -} - -/* Add your own music player or mixer function. - If 'mix_func' is NULL, the default music player is re-enabled. - */ -void Mix_HookMusic(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), - void *arg) -{ - Mix_LockAudio(); - if (mix_func != NULL) { - music_data = arg; - mix_music = mix_func; - } else { - music_data = NULL; - mix_music = music_mixer; - } - Mix_UnlockAudio(); -} - -void *Mix_GetMusicHookData(void) -{ - return(music_data); -} - -void Mix_ChannelFinished(void (SDLCALL *channel_finished)(int channel)) -{ - Mix_LockAudio(); - channel_done_callback = channel_finished; - Mix_UnlockAudio(); -} - - -/* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate - them dynamically to the next sample if requested with a -1 value below. - Returns the number of reserved channels. - */ -int Mix_ReserveChannels(int num) -{ - if (num > num_channels) - num = num_channels; - reserved_channels = num; - return num; -} - -static int checkchunkintegral(Mix_Chunk *chunk) -{ - int frame_width = 1; - - if ((mixer.format & 0xFF) == 16) frame_width = 2; - frame_width *= mixer.channels; - while (chunk->alen % frame_width) chunk->alen--; - return chunk->alen; -} - -/* Play an audio chunk on a specific channel. - If the specified channel is -1, play on the first free channel. - 'ticks' is the number of milliseconds at most to play the sample, or -1 - if there is no limit. - Returns which channel was used to play the sound. -*/ -int Mix_PlayChannelTimed(int which, Mix_Chunk *chunk, int loops, int ticks) -{ - int i; - - /* Don't play null pointers :-) */ - if (chunk == NULL) { - Mix_SetError("Tried to play a NULL chunk"); - return(-1); - } - if (!checkchunkintegral(chunk)) { - Mix_SetError("Tried to play a chunk with a bad frame"); - return(-1); - } - - /* Lock the mixer while modifying the playing channels */ - Mix_LockAudio(); - { - /* If which is -1, play on the first free channel */ - if (which == -1) { - for (i=reserved_channels; i= 0 && which < num_channels) { - Uint32 sdl_ticks = SDL_GetTicks(); - if (Mix_Playing(which)) - _Mix_channel_done_playing(which); - mix_channel[which].samples = chunk->abuf; - mix_channel[which].playing = chunk->alen; - mix_channel[which].looping = loops; - mix_channel[which].chunk = chunk; - mix_channel[which].paused = 0; - mix_channel[which].fading = MIX_NO_FADING; - mix_channel[which].start_time = sdl_ticks; - mix_channel[which].expire = (ticks>0) ? (sdl_ticks + ticks) : 0; - } - } - Mix_UnlockAudio(); - - /* Return the channel on which the sound is being played */ - return(which); -} - -/* Change the expiration delay for a channel */ -int Mix_ExpireChannel(int which, int ticks) -{ - int status = 0; - - if (which == -1) { - int i; - for (i=0; i < num_channels; ++ i) { - status += Mix_ExpireChannel(i, ticks); - } - } else if (which < num_channels) { - Mix_LockAudio(); - mix_channel[which].expire = (ticks>0) ? (SDL_GetTicks() + ticks) : 0; - Mix_UnlockAudio(); - ++ status; - } - return(status); -} - -/* Fade in a sound on a channel, over ms milliseconds */ -int Mix_FadeInChannelTimed(int which, Mix_Chunk *chunk, int loops, int ms, int ticks) -{ - int i; - - /* Don't play null pointers :-) */ - if (chunk == NULL) { - return(-1); - } - if (!checkchunkintegral(chunk)) { - Mix_SetError("Tried to play a chunk with a bad frame"); - return(-1); - } - - /* Lock the mixer while modifying the playing channels */ - Mix_LockAudio(); - { - /* If which is -1, play on the first free channel */ - if (which == -1) { - for (i=reserved_channels; i= 0 && which < num_channels) { - Uint32 sdl_ticks = SDL_GetTicks(); - if (Mix_Playing(which)) - _Mix_channel_done_playing(which); - mix_channel[which].samples = chunk->abuf; - mix_channel[which].playing = chunk->alen; - mix_channel[which].looping = loops; - mix_channel[which].chunk = chunk; - mix_channel[which].paused = 0; - mix_channel[which].fading = MIX_FADING_IN; - mix_channel[which].fade_volume = mix_channel[which].volume; - mix_channel[which].fade_volume_reset = mix_channel[which].volume; - mix_channel[which].volume = 0; - mix_channel[which].fade_length = (Uint32)ms; - mix_channel[which].start_time = mix_channel[which].ticks_fade = sdl_ticks; - mix_channel[which].expire = (ticks > 0) ? (sdl_ticks+ticks) : 0; - } - } - Mix_UnlockAudio(); - - /* Return the channel on which the sound is being played */ - return(which); -} - -/* Set volume of a particular channel */ -int Mix_Volume(int which, int volume) -{ - int i; - int prev_volume = 0; - - if (which == -1) { - for (i=0; i= 0) { - if (volume > MIX_MAX_VOLUME) { - volume = MIX_MAX_VOLUME; - } - mix_channel[which].volume = volume; - } - } - return(prev_volume); -} -/* Set volume of a particular chunk */ -int Mix_VolumeChunk(Mix_Chunk *chunk, int volume) -{ - int prev_volume; - - prev_volume = chunk->volume; - if (volume >= 0) { - if (volume > MIX_MAX_VOLUME) { - volume = MIX_MAX_VOLUME; - } - chunk->volume = volume; - } - return(prev_volume); -} - -/* Halt playing of a particular channel */ -int Mix_HaltChannel(int which) -{ - int i; - - if (which == -1) { - for (i=0; i 0) && - (mix_channel[which].fading != MIX_FADING_OUT)) { - mix_channel[which].fade_volume = mix_channel[which].volume; - mix_channel[which].fading = MIX_FADING_OUT; - mix_channel[which].fade_length = (Uint32)ms; - mix_channel[which].ticks_fade = SDL_GetTicks(); - - /* only change fade_volume_reset if we're not fading. */ - if (mix_channel[which].fading == MIX_NO_FADING) { - mix_channel[which].fade_volume_reset = mix_channel[which].volume; - } - ++status; - } - Mix_UnlockAudio(); - } - } - return(status); -} - -/* Halt playing of a particular group of channels */ -int Mix_FadeOutGroup(int tag, int ms) -{ - int i; - int status = 0; - for (i=0; i= num_channels) { - return MIX_NO_FADING; - } - return mix_channel[which].fading; -} - -/* Check the status of a specific channel. - If the specified mix_channel is -1, check all mix channels. -*/ -int Mix_Playing(int which) -{ - int status; - - status = 0; - if (which == -1) { - int i; - - for (i=0; i 0) || - mix_channel[i].looping) - { - ++status; - } - } - } else if (which < num_channels) { - if ((mix_channel[which].playing > 0) || - mix_channel[which].looping) - { - ++status; - } - } - return(status); -} - -/* rcg06072001 Get the chunk associated with a channel. */ -Mix_Chunk *Mix_GetChunk(int channel) -{ - Mix_Chunk *retval = NULL; - - if ((channel >= 0) && (channel < num_channels)) { - retval = mix_channel[channel].chunk; - } - - return(retval); -} - -/* Close the mixer, halting all playing audio */ -void Mix_CloseAudio(void) -{ - int i; - - if (audio_opened) { - if (audio_opened == 1) { - for (i = 0; i < num_channels; i++) { - Mix_UnregisterAllEffects(i); - } - Mix_UnregisterAllEffects(MIX_CHANNEL_POST); - close_music(); - Mix_SetMusicCMD(NULL); - Mix_HaltChannel(-1); - _Mix_DeinitEffects(); - SDL_CloseAudioDevice(audio_device); - audio_device = 0; - SDL_free(mix_channel); - mix_channel = NULL; - - /* rcg06042009 report available decoders at runtime. */ - SDL_free((void *)chunk_decoders); - chunk_decoders = NULL; - num_decoders = 0; - } - --audio_opened; - } -} - -/* Pause a particular channel (or all) */ -void Mix_Pause(int which) -{ - Uint32 sdl_ticks = SDL_GetTicks(); - if (which == -1) { - int i; - - for (i=0; i 0) { - mix_channel[i].paused = sdl_ticks; - } - } - } else if (which < num_channels) { - if (mix_channel[which].playing > 0) { - mix_channel[which].paused = sdl_ticks; - } - } -} - -/* Resume a paused channel */ -void Mix_Resume(int which) -{ - Uint32 sdl_ticks = SDL_GetTicks(); - - Mix_LockAudio(); - if (which == -1) { - int i; - - for (i=0; i 0) { - if(mix_channel[i].expire > 0) - mix_channel[i].expire += sdl_ticks - mix_channel[i].paused; - mix_channel[i].paused = 0; - } - } - } else if (which < num_channels) { - if (mix_channel[which].playing > 0) { - if(mix_channel[which].expire > 0) - mix_channel[which].expire += sdl_ticks - mix_channel[which].paused; - mix_channel[which].paused = 0; - } - } - Mix_UnlockAudio(); -} - -int Mix_Paused(int which) -{ - if (which < 0) { - int status = 0; - int i; - for(i=0; i < num_channels; ++i) { - if (mix_channel[i].paused) { - ++ status; - } - } - return(status); - } else if (which < num_channels) { - return(mix_channel[which].paused != 0); - } else { - return(0); - } -} - -/* Change the group of a channel */ -int Mix_GroupChannel(int which, int tag) -{ - if (which < 0 || which > num_channels) - return(0); - - Mix_LockAudio(); - mix_channel[which].tag = tag; - Mix_UnlockAudio(); - return(1); -} - -/* Assign several consecutive channels to a group */ -int Mix_GroupChannels(int from, int to, int tag) -{ - int status = 0; - for(; from <= to; ++ from) { - status += Mix_GroupChannel(from, tag); - } - return(status); -} - -/* Finds the first available channel in a group of channels */ -int Mix_GroupAvailable(int tag) -{ - int i; - for(i=0; i < num_channels; i ++) { - if (((tag == -1) || (tag == mix_channel[i].tag)) && - (mix_channel[i].playing <= 0)) - return i; - } - return(-1); -} - -int Mix_GroupCount(int tag) -{ - int count = 0; - int i; - for(i=0; i < num_channels; i ++) { - if (mix_channel[i].tag==tag || tag==-1) - ++ count; - } - return(count); -} - -/* Finds the "oldest" sample playing in a group of channels */ -int Mix_GroupOldest(int tag) -{ - int chan = -1; - Uint32 mintime = SDL_GetTicks(); - int i; - for(i=0; i < num_channels; i ++) { - if ((mix_channel[i].tag==tag || tag==-1) && mix_channel[i].playing > 0 - && mix_channel[i].start_time <= mintime) { - mintime = mix_channel[i].start_time; - chan = i; - } - } - return(chan); -} - -/* Finds the "most recent" (i.e. last) sample playing in a group of channels */ -int Mix_GroupNewer(int tag) -{ - int chan = -1; - Uint32 maxtime = 0; - int i; - for(i=0; i < num_channels; i ++) { - if ((mix_channel[i].tag==tag || tag==-1) && mix_channel[i].playing > 0 - && mix_channel[i].start_time >= maxtime) { - maxtime = mix_channel[i].start_time; - chan = i; - } - } - return(chan); -} - - - -/* - * rcg06122001 The special effects exportable API. - * Please see effect_*.c for internally-implemented effects, such - * as Mix_SetPanning(). - */ - -/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ -static int _Mix_register_effect(effect_info **e, Mix_EffectFunc_t f, - Mix_EffectDone_t d, void *arg) -{ - effect_info *new_e; - - if (!e) { - Mix_SetError("Internal error"); - return(0); - } - - if (f == NULL) { - Mix_SetError("NULL effect callback"); - return(0); - } - - new_e = SDL_malloc(sizeof (effect_info)); - if (new_e == NULL) { - Mix_SetError("Out of memory"); - return(0); - } - - new_e->callback = f; - new_e->done_callback = d; - new_e->udata = arg; - new_e->next = NULL; - - /* add new effect to end of linked list... */ - if (*e == NULL) { - *e = new_e; - } else { - effect_info *cur = *e; - while (1) { - if (cur->next == NULL) { - cur->next = new_e; - break; - } - cur = cur->next; - } - } - - return(1); -} - - -/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ -static int _Mix_remove_effect(int channel, effect_info **e, Mix_EffectFunc_t f) -{ - effect_info *cur; - effect_info *prev = NULL; - effect_info *next = NULL; - - if (!e) { - Mix_SetError("Internal error"); - return(0); - } - - for (cur = *e; cur != NULL; cur = cur->next) { - if (cur->callback == f) { - next = cur->next; - if (cur->done_callback != NULL) { - cur->done_callback(channel, cur->udata); - } - SDL_free(cur); - - if (prev == NULL) { /* removing first item of list? */ - *e = next; - } else { - prev->next = next; - } - return(1); - } - prev = cur; - } - - Mix_SetError("No such effect registered"); - return(0); -} - - -/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ -static int _Mix_remove_all_effects(int channel, effect_info **e) -{ - effect_info *cur; - effect_info *next; - - if (!e) { - Mix_SetError("Internal error"); - return(0); - } - - for (cur = *e; cur != NULL; cur = next) { - next = cur->next; - if (cur->done_callback != NULL) { - cur->done_callback(channel, cur->udata); - } - SDL_free(cur); - } - *e = NULL; - - return(1); -} - - -/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ -int _Mix_RegisterEffect_locked(int channel, Mix_EffectFunc_t f, - Mix_EffectDone_t d, void *arg) -{ - effect_info **e = NULL; - - if (channel == MIX_CHANNEL_POST) { - e = &posteffects; - } else { - if ((channel < 0) || (channel >= num_channels)) { - Mix_SetError("Invalid channel number"); - return(0); - } - e = &mix_channel[channel].effects; - } - - return _Mix_register_effect(e, f, d, arg); -} - -int Mix_RegisterEffect(int channel, Mix_EffectFunc_t f, - Mix_EffectDone_t d, void *arg) -{ - int retval; - Mix_LockAudio(); - retval = _Mix_RegisterEffect_locked(channel, f, d, arg); - Mix_UnlockAudio(); - return retval; -} - - -/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ -int _Mix_UnregisterEffect_locked(int channel, Mix_EffectFunc_t f) -{ - effect_info **e = NULL; - - if (channel == MIX_CHANNEL_POST) { - e = &posteffects; - } else { - if ((channel < 0) || (channel >= num_channels)) { - Mix_SetError("Invalid channel number"); - return(0); - } - e = &mix_channel[channel].effects; - } - - return _Mix_remove_effect(channel, e, f); -} - -int Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f) -{ - int retval; - Mix_LockAudio(); - retval = _Mix_UnregisterEffect_locked(channel, f); - Mix_UnlockAudio(); - return(retval); -} - -/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ -int _Mix_UnregisterAllEffects_locked(int channel) -{ - effect_info **e = NULL; - - if (channel == MIX_CHANNEL_POST) { - e = &posteffects; - } else { - if ((channel < 0) || (channel >= num_channels)) { - Mix_SetError("Invalid channel number"); - return(0); - } - e = &mix_channel[channel].effects; - } - - return _Mix_remove_all_effects(channel, e); -} - -int Mix_UnregisterAllEffects(int channel) -{ - int retval; - Mix_LockAudio(); - retval = _Mix_UnregisterAllEffects_locked(channel); - Mix_UnlockAudio(); - return(retval); -} - -void Mix_LockAudio(void) -{ - SDL_LockAudioDevice(audio_device); -} - -void Mix_UnlockAudio(void) -{ - SDL_UnlockAudioDevice(audio_device); -} - -/* end of mixer.c ... */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/mixer.h b/mixer.h deleted file mode 100644 index dc06e71..0000000 --- a/mixer.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* Locking wrapper functions */ -extern void Mix_LockAudio(void); -extern void Mix_UnlockAudio(void); - -extern void add_chunk_decoder(const char *decoder); - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music.c b/music.c deleted file mode 100644 index a09373f..0000000 --- a/music.c +++ /dev/null @@ -1,1141 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include /* for strtok() and strtok_s() */ - -#include "SDL_hints.h" -#include "SDL_log.h" -#include "SDL_timer.h" - -#include "SDL_mixer.h" -#include "mixer.h" -#include "music.h" - -#include "music_cmd.h" -#include "music_wav.h" -#include "music_mikmod.h" -#include "music_modplug.h" -#include "music_nativemidi.h" -#include "music_fluidsynth.h" -#include "music_timidity.h" -#include "music_ogg.h" -#include "music_opus.h" -#include "music_mpg123.h" -#include "music_mad.h" -#include "music_flac.h" -#include "native_midi/native_midi.h" - -/* Check to make sure we are building with a new enough SDL */ -#if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 7) -#error You need SDL 2.0.7 or newer from http://www.libsdl.org -#endif - -/* Set this hint to true if you want verbose logging of music interfaces */ -#define SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES \ - "SDL_MIXER_DEBUG_MUSIC_INTERFACES" - -char *music_cmd = NULL; -static SDL_bool music_active = SDL_TRUE; -static int music_volume = MIX_MAX_VOLUME; -static Mix_Music * volatile music_playing = NULL; -SDL_AudioSpec music_spec; - -struct _Mix_Music { - Mix_MusicInterface *interface; - void *context; - - SDL_bool playing; - Mix_Fading fading; - int fade_step; - int fade_steps; -}; - -/* Used to calculate fading steps */ -static int ms_per_step; - -/* rcg06042009 report available decoders at runtime. */ -static const char **music_decoders = NULL; -static int num_decoders = 0; - -/* Semicolon-separated SoundFont paths */ -static char* soundfont_paths = NULL; - -/* Interfaces for the various music interfaces, ordered by priority */ -static Mix_MusicInterface *s_music_interfaces[] = -{ -#ifdef MUSIC_CMD - &Mix_MusicInterface_CMD, -#endif -#ifdef MUSIC_WAV - &Mix_MusicInterface_WAV, -#endif -#ifdef MUSIC_FLAC - &Mix_MusicInterface_FLAC, -#endif -#ifdef MUSIC_OGG - &Mix_MusicInterface_OGG, -#endif -#ifdef MUSIC_OPUS - &Mix_MusicInterface_Opus, -#endif -#ifdef MUSIC_MP3_MPG123 - &Mix_MusicInterface_MPG123, -#endif -#ifdef MUSIC_MP3_MAD - &Mix_MusicInterface_MAD, -#endif -#ifdef MUSIC_MOD_MODPLUG - &Mix_MusicInterface_MODPLUG, -#endif -#ifdef MUSIC_MOD_MIKMOD - &Mix_MusicInterface_MIKMOD, -#endif -#ifdef MUSIC_MID_FLUIDSYNTH - &Mix_MusicInterface_FLUIDSYNTH, -#endif -#ifdef MUSIC_MID_TIMIDITY - &Mix_MusicInterface_TIMIDITY, -#endif -#ifdef MUSIC_MID_NATIVE - &Mix_MusicInterface_NATIVEMIDI, -#endif -}; - -int get_num_music_interfaces(void) -{ - return SDL_arraysize(s_music_interfaces); -} - -Mix_MusicInterface *get_music_interface(int index) -{ - return s_music_interfaces[index]; -} - -int Mix_GetNumMusicDecoders(void) -{ - return(num_decoders); -} - -const char *Mix_GetMusicDecoder(int index) -{ - if ((index < 0) || (index >= num_decoders)) { - return NULL; - } - return(music_decoders[index]); -} - -static void add_music_decoder(const char *decoder) -{ - void *ptr; - int i; - - /* Check to see if we already have this decoder */ - for (i = 0; i < num_decoders; ++i) { - if (SDL_strcmp(music_decoders[i], decoder) == 0) { - return; - } - } - - ptr = SDL_realloc((void *)music_decoders, (num_decoders + 1) * sizeof (const char *)); - if (ptr == NULL) { - return; /* oh well, go on without it. */ - } - music_decoders = (const char **) ptr; - music_decoders[num_decoders++] = decoder; -} - -/* Local low-level functions prototypes */ -static void music_internal_initialize_volume(void); -static void music_internal_volume(int volume); -static int music_internal_play(Mix_Music *music, int play_count, double position); -static int music_internal_position(double position); -static SDL_bool music_internal_playing(void); -static void music_internal_halt(void); - - -/* Support for hooking when the music has finished */ -static void (SDLCALL *music_finished_hook)(void) = NULL; - -void Mix_HookMusicFinished(void (SDLCALL *music_finished)(void)) -{ - Mix_LockAudio(); - music_finished_hook = music_finished; - Mix_UnlockAudio(); -} - -/* Convenience function to fill audio and mix at the specified volume - This is called from many music player's GetAudio callback. - */ -int music_pcm_getaudio(void *context, void *data, int bytes, int volume, - int (*GetSome)(void *context, void *data, int bytes, SDL_bool *done)) -{ - Uint8 *snd = (Uint8 *)data; - Uint8 *dst; - int len = bytes; - SDL_bool done = SDL_FALSE; - - if (volume == MIX_MAX_VOLUME) { - dst = snd; - } else { - dst = SDL_stack_alloc(Uint8, bytes); - } - while (len > 0 && !done) { - int consumed = GetSome(context, dst, len, &done); - if (consumed < 0) { - break; - } - - if (volume == MIX_MAX_VOLUME) { - dst += consumed; - } else { - SDL_MixAudioFormat(snd, dst, music_spec.format, (Uint32)consumed, volume); - snd += consumed; - } - len -= consumed; - } - if (volume != MIX_MAX_VOLUME) { - SDL_stack_free(dst); - } - return len; -} - -/* Mixing function */ -void SDLCALL music_mixer(void *udata, Uint8 *stream, int len) -{ - while (music_playing && music_active && len > 0) { - /* Handle fading */ - if (music_playing->fading != MIX_NO_FADING) { - if (music_playing->fade_step++ < music_playing->fade_steps) { - int volume; - int fade_step = music_playing->fade_step; - int fade_steps = music_playing->fade_steps; - - if (music_playing->fading == MIX_FADING_OUT) { - volume = (music_volume * (fade_steps-fade_step)) / fade_steps; - } else { /* Fading in */ - volume = (music_volume * fade_step) / fade_steps; - } - music_internal_volume(volume); - } else { - if (music_playing->fading == MIX_FADING_OUT) { - music_internal_halt(); - if (music_finished_hook) { - music_finished_hook(); - } - return; - } - music_playing->fading = MIX_NO_FADING; - } - } - - if (music_playing->interface->GetAudio) { - int left = music_playing->interface->GetAudio(music_playing->context, stream, len); - if (left != 0) { - /* Either an error or finished playing with data left */ - music_playing->playing = SDL_FALSE; - } - if (left > 0) { - stream += (len - left); - len = left; - } else { - len = 0; - } - } else { - len = 0; - } - - if (!music_internal_playing()) { - music_internal_halt(); - if (music_finished_hook) { - music_finished_hook(); - } - } - } -} - -/* Load the music interface libraries for a given music type */ -SDL_bool load_music_type(Mix_MusicType type) -{ - int i, loaded = 0; - for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { - Mix_MusicInterface *interface = s_music_interfaces[i]; - if (interface->type != type) { - continue; - } - if (!interface->loaded) { - char hint[64]; - SDL_snprintf(hint, sizeof(hint), "SDL_MIXER_DISABLE_%s", interface->tag); - if (SDL_GetHintBoolean(hint, SDL_FALSE)) { - continue; - } - - if (interface->Load && interface->Load() < 0) { - if (SDL_GetHintBoolean(SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES, SDL_FALSE)) { - SDL_Log("Couldn't load %s: %s\n", interface->tag, Mix_GetError()); - } - continue; - } - interface->loaded = SDL_TRUE; - } - ++loaded; - } - return (loaded > 0) ? SDL_TRUE : SDL_FALSE; -} - -/* Open the music interfaces for a given music type */ -SDL_bool open_music_type(Mix_MusicType type) -{ - int i, opened = 0; - SDL_bool use_native_midi = SDL_FALSE; - - if (!music_spec.format) { - /* Music isn't opened yet */ - return SDL_FALSE; - } - -#ifdef MUSIC_MID_NATIVE - if (type == MUS_MID && SDL_GetHintBoolean("SDL_NATIVE_MUSIC", SDL_FALSE) && native_midi_detect()) { - use_native_midi = SDL_TRUE; - } -#endif - - for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { - Mix_MusicInterface *interface = s_music_interfaces[i]; - if (!interface->loaded) { - continue; - } - if (type != MUS_NONE && interface->type != type) { - continue; - } - - if (interface->type == MUS_MID && use_native_midi && interface->api != MIX_MUSIC_NATIVEMIDI) { - continue; - } - - if (!interface->opened) { - if (interface->Open && interface->Open(&music_spec) < 0) { - if (SDL_GetHintBoolean(SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES, SDL_FALSE)) { - SDL_Log("Couldn't open %s: %s\n", interface->tag, Mix_GetError()); - } - continue; - } - interface->opened = SDL_TRUE; - add_music_decoder(interface->tag); - } - ++opened; - } - - if (has_music(MUS_MOD)) { - add_music_decoder("MOD"); - add_chunk_decoder("MOD"); - } - if (has_music(MUS_MID)) { - add_music_decoder("MIDI"); - add_chunk_decoder("MID"); - } - if (has_music(MUS_OGG)) { - add_music_decoder("OGG"); - add_chunk_decoder("OGG"); - } - if (has_music(MUS_OPUS)) { - add_music_decoder("OPUS"); - add_chunk_decoder("OPUS"); - } - if (has_music(MUS_MP3)) { - add_music_decoder("MP3"); - add_chunk_decoder("MP3"); - } - if (has_music(MUS_FLAC)) { - add_music_decoder("FLAC"); - add_chunk_decoder("FLAC"); - } - - return (opened > 0) ? SDL_TRUE : SDL_FALSE; -} - -/* Initialize the music interfaces with a certain desired audio format */ -void open_music(const SDL_AudioSpec *spec) -{ -#ifdef MIX_INIT_SOUNDFONT_PATHS - if (!soundfont_paths) { - soundfont_paths = SDL_strdup(MIX_INIT_SOUNDFONT_PATHS); - } -#endif - - /* Load the music interfaces that don't have explicit initialization */ - load_music_type(MUS_CMD); - load_music_type(MUS_WAV); - - /* Open all the interfaces that are loaded */ - music_spec = *spec; - open_music_type(MUS_NONE); - - Mix_VolumeMusic(MIX_MAX_VOLUME); - - /* Calculate the number of ms for each callback */ - ms_per_step = (int) (((float)spec->samples * 1000.0) / spec->freq); -} - -/* Return SDL_TRUE if the music type is available */ -SDL_bool has_music(Mix_MusicType type) -{ - int i; - for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { - Mix_MusicInterface *interface = s_music_interfaces[i]; - if (interface->type != type) { - continue; - } - if (interface->opened) { - return SDL_TRUE; - } - } - return SDL_FALSE; -} - -Mix_MusicType detect_music_type_from_magic(const Uint8 *magic) -{ - /* Ogg Vorbis files have the magic four bytes "OggS" */ - if (SDL_memcmp(magic, "OggS", 4) == 0) { - return MUS_OGG; - } - - /* FLAC files have the magic four bytes "fLaC" */ - if (SDL_memcmp(magic, "fLaC", 4) == 0) { - return MUS_FLAC; - } - - /* MIDI files have the magic four bytes "MThd" */ - if (SDL_memcmp(magic, "MThd", 4) == 0) { - return MUS_MID; - } - - if (SDL_memcmp(magic, "ID3", 3) == 0 || - (magic[0] == 0xFF && (magic[1] & 0xFE) == 0xFA)) { - return MUS_MP3; - } - - /* Assume MOD format. - * - * Apparently there is no way to check if the file is really a MOD, - * or there are too many formats supported by MikMod/ModPlug, or - * MikMod/ModPlug does this check by itself. */ - return MUS_MOD; -} - -static Mix_MusicType detect_music_type(SDL_RWops *src) -{ - Uint8 magic[12]; - Mix_MusicType t; - - if (SDL_RWread(src, magic, 1, 12) != 12) { - Mix_SetError("Couldn't read first 12 bytes of audio data"); - return MUS_NONE; - } - SDL_RWseek(src, -12, RW_SEEK_CUR); - - /* WAVE files have the magic four bytes "RIFF" - AIFF files have the magic 12 bytes "FORM" XXXX "AIFF" */ - if (((SDL_memcmp(magic, "RIFF", 4) == 0) && (SDL_memcmp((magic+8), "WAVE", 4) == 0)) || - (SDL_memcmp(magic, "FORM", 4) == 0)) { - return MUS_WAV; - } - t = detect_music_type_from_magic(magic); - if (t == MUS_OGG) { - Sint64 pos = SDL_RWtell(src); - SDL_RWseek(src, 28, RW_SEEK_CUR); - SDL_RWread(src, magic, 1, 8); - SDL_RWseek(src, pos, RW_SEEK_SET); - if (SDL_memcmp(magic, "OpusHead", 8) == 0) { - return MUS_OPUS; - } - } - return t; -} - -/* Load a music file */ -Mix_Music *Mix_LoadMUS(const char *file) -{ - int i; - void *context; - char *ext; - Mix_MusicType type; - SDL_RWops *src; - - for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { - Mix_MusicInterface *interface = s_music_interfaces[i]; - if (!interface->opened || !interface->CreateFromFile) { - continue; - } - - context = interface->CreateFromFile(file); - if (context) { - /* Allocate memory for the music structure */ - Mix_Music *music = (Mix_Music *)SDL_calloc(1, sizeof(Mix_Music)); - if (music == NULL) { - Mix_SetError("Out of memory"); - return NULL; - } - music->interface = interface; - music->context = context; - return music; - } - } - - src = SDL_RWFromFile(file, "rb"); - if (src == NULL) { - Mix_SetError("Couldn't open '%s'", file); - return NULL; - } - - /* Use the extension as a first guess on the file type */ - type = MUS_NONE; - ext = strrchr(file, '.'); - if (ext) { - ++ext; /* skip the dot in the extension */ - if (SDL_strcasecmp(ext, "WAV") == 0) { - type = MUS_WAV; - } else if (SDL_strcasecmp(ext, "MID") == 0 || - SDL_strcasecmp(ext, "MIDI") == 0 || - SDL_strcasecmp(ext, "KAR") == 0) { - type = MUS_MID; - } else if (SDL_strcasecmp(ext, "OGG") == 0) { - type = MUS_OGG; - } else if (SDL_strcasecmp(ext, "OPUS") == 0) { - type = MUS_OPUS; - } else if (SDL_strcasecmp(ext, "FLAC") == 0) { - type = MUS_FLAC; - } else if (SDL_strcasecmp(ext, "MPG") == 0 || - SDL_strcasecmp(ext, "MPEG") == 0 || - SDL_strcasecmp(ext, "MP3") == 0 || - SDL_strcasecmp(ext, "MAD") == 0) { - type = MUS_MP3; - } else if (SDL_strcasecmp(ext, "669") == 0 || - SDL_strcasecmp(ext, "AMF") == 0 || - SDL_strcasecmp(ext, "AMS") == 0 || - SDL_strcasecmp(ext, "DBM") == 0 || - SDL_strcasecmp(ext, "DSM") == 0 || - SDL_strcasecmp(ext, "FAR") == 0 || - SDL_strcasecmp(ext, "IT") == 0 || - SDL_strcasecmp(ext, "MED") == 0 || - SDL_strcasecmp(ext, "MDL") == 0 || - SDL_strcasecmp(ext, "MOD") == 0 || - SDL_strcasecmp(ext, "MOL") == 0 || - SDL_strcasecmp(ext, "MTM") == 0 || - SDL_strcasecmp(ext, "NST") == 0 || - SDL_strcasecmp(ext, "OKT") == 0 || - SDL_strcasecmp(ext, "PTM") == 0 || - SDL_strcasecmp(ext, "S3M") == 0 || - SDL_strcasecmp(ext, "STM") == 0 || - SDL_strcasecmp(ext, "ULT") == 0 || - SDL_strcasecmp(ext, "UMX") == 0 || - SDL_strcasecmp(ext, "WOW") == 0 || - SDL_strcasecmp(ext, "XM") == 0) { - type = MUS_MOD; - } - } - return Mix_LoadMUSType_RW(src, type, SDL_TRUE); -} - -Mix_Music *Mix_LoadMUS_RW(SDL_RWops *src, int freesrc) -{ - return Mix_LoadMUSType_RW(src, MUS_NONE, freesrc); -} - -Mix_Music *Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc) -{ - int i; - void *context; - Sint64 start; - - if (!src) { - Mix_SetError("RWops pointer is NULL"); - return NULL; - } - start = SDL_RWtell(src); - - /* If the caller wants auto-detection, figure out what kind of file - * this is. */ - if (type == MUS_NONE) { - if ((type = detect_music_type(src)) == MUS_NONE) { - /* Don't call Mix_SetError() since detect_music_type() does that. */ - if (freesrc) { - SDL_RWclose(src); - } - return NULL; - } - } - - Mix_ClearError(); - - if (load_music_type(type) && open_music_type(type)) { - for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { - Mix_MusicInterface *interface = s_music_interfaces[i]; - if (!interface->opened || type != interface->type || !interface->CreateFromRW) { - continue; - } - - context = interface->CreateFromRW(src, freesrc); - if (context) { - /* Allocate memory for the music structure */ - Mix_Music *music = (Mix_Music *)SDL_calloc(1, sizeof(Mix_Music)); - if (music == NULL) { - interface->Delete(context); - Mix_SetError("Out of memory"); - return NULL; - } - music->interface = interface; - music->context = context; - - if (SDL_GetHintBoolean(SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES, SDL_FALSE)) { - SDL_Log("Loaded music with %s\n", interface->tag); - } - return music; - } - - /* Reset the stream for the next decoder */ - SDL_RWseek(src, start, RW_SEEK_SET); - } - } - - if (!*Mix_GetError()) { - Mix_SetError("Unrecognized audio format"); - } - if (freesrc) { - SDL_RWclose(src); - } else { - SDL_RWseek(src, start, RW_SEEK_SET); - } - return NULL; -} - -/* Free a music chunk previously loaded */ -void Mix_FreeMusic(Mix_Music *music) -{ - if (music) { - /* Stop the music if it's currently playing */ - Mix_LockAudio(); - if (music == music_playing) { - /* Wait for any fade out to finish */ - while (music->fading == MIX_FADING_OUT) { - Mix_UnlockAudio(); - SDL_Delay(100); - Mix_LockAudio(); - } - if (music == music_playing) { - music_internal_halt(); - } - } - Mix_UnlockAudio(); - - music->interface->Delete(music->context); - SDL_free(music); - } -} - -/* Find out the music format of a mixer music, or the currently playing - music, if 'music' is NULL. -*/ -Mix_MusicType Mix_GetMusicType(const Mix_Music *music) -{ - Mix_MusicType type = MUS_NONE; - - if (music) { - type = music->interface->type; - } else { - Mix_LockAudio(); - if (music_playing) { - type = music_playing->interface->type; - } - Mix_UnlockAudio(); - } - return(type); -} - -/* Play a music chunk. Returns 0, or -1 if there was an error. - */ -static int music_internal_play(Mix_Music *music, int play_count, double position) -{ - int retval = 0; - -#if defined(__MACOSX__) && defined(MID_MUSIC_NATIVE) - /* This fixes a bug with native MIDI on Mac OS X, where you - can't really stop and restart MIDI from the audio callback. - */ - if (music == music_playing && music->api == MIX_MUSIC_NATIVEMIDI) { - /* Just a seek suffices to restart playing */ - music_internal_position(position); - return 0; - } -#endif - - /* Note the music we're playing */ - if (music_playing) { - music_internal_halt(); - } - music_playing = music; - music_playing->playing = SDL_TRUE; - - /* Set the initial volume */ - music_internal_initialize_volume(); - - /* Set up for playback */ - retval = music->interface->Play(music->context, play_count); - - /* Set the playback position, note any errors if an offset is used */ - if (retval == 0) { - if (position > 0.0) { - if (music_internal_position(position) < 0) { - Mix_SetError("Position not implemented for music type"); - retval = -1; - } - } else { - music_internal_position(0.0); - } - } - - /* If the setup failed, we're not playing any music anymore */ - if (retval < 0) { - music->playing = SDL_FALSE; - music_playing = NULL; - } - return(retval); -} - -int Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position) -{ - int retval; - - if (ms_per_step == 0) { - SDL_SetError("Audio device hasn't been opened"); - return(-1); - } - - /* Don't play null pointers :-) */ - if (music == NULL) { - Mix_SetError("music parameter was NULL"); - return(-1); - } - - /* Setup the data */ - if (ms) { - music->fading = MIX_FADING_IN; - } else { - music->fading = MIX_NO_FADING; - } - music->fade_step = 0; - music->fade_steps = ms/ms_per_step; - - /* Play the puppy */ - Mix_LockAudio(); - /* If the current music is fading out, wait for the fade to complete */ - while (music_playing && (music_playing->fading == MIX_FADING_OUT)) { - Mix_UnlockAudio(); - SDL_Delay(100); - Mix_LockAudio(); - } - if (loops == 0) { - /* Loop is the number of times to play the audio */ - loops = 1; - } - retval = music_internal_play(music, loops, position); - music_active = (retval == 0); - Mix_UnlockAudio(); - - return(retval); -} -int Mix_FadeInMusic(Mix_Music *music, int loops, int ms) -{ - return Mix_FadeInMusicPos(music, loops, ms, 0.0); -} -int Mix_PlayMusic(Mix_Music *music, int loops) -{ - return Mix_FadeInMusicPos(music, loops, 0, 0.0); -} - -/* Set the playing music position */ -int music_internal_position(double position) -{ - if (music_playing->interface->Seek) { - return music_playing->interface->Seek(music_playing->context, position); - } - return -1; -} -int Mix_SetMusicPosition(double position) -{ - int retval; - - Mix_LockAudio(); - if (music_playing) { - retval = music_internal_position(position); - if (retval < 0) { - Mix_SetError("Position not implemented for music type"); - } - } else { - Mix_SetError("Music isn't playing"); - retval = -1; - } - Mix_UnlockAudio(); - - return(retval); -} - -/* Set the music's initial volume */ -static void music_internal_initialize_volume(void) -{ - if (music_playing->fading == MIX_FADING_IN) { - music_internal_volume(0); - } else { - music_internal_volume(music_volume); - } -} - -/* Set the music volume */ -static void music_internal_volume(int volume) -{ - if (music_playing->interface->SetVolume) { - music_playing->interface->SetVolume(music_playing->context, volume); - } -} -int Mix_VolumeMusic(int volume) -{ - int prev_volume; - - prev_volume = music_volume; - if (volume < 0) { - return prev_volume; - } - if (volume > SDL_MIX_MAXVOLUME) { - volume = SDL_MIX_MAXVOLUME; - } - music_volume = volume; - Mix_LockAudio(); - if (music_playing) { - music_internal_volume(music_volume); - } - Mix_UnlockAudio(); - return(prev_volume); -} - -/* Halt playing of music */ -static void music_internal_halt(void) -{ - if (music_playing->interface->Stop) { - music_playing->interface->Stop(music_playing->context); - } - - music_playing->playing = SDL_FALSE; - music_playing->fading = MIX_NO_FADING; - music_playing = NULL; -} -int Mix_HaltMusic(void) -{ - Mix_LockAudio(); - if (music_playing) { - music_internal_halt(); - if (music_finished_hook) { - music_finished_hook(); - } - } - Mix_UnlockAudio(); - - return(0); -} - -/* Progressively stop the music */ -int Mix_FadeOutMusic(int ms) -{ - int retval = 0; - - if (ms_per_step == 0) { - SDL_SetError("Audio device hasn't been opened"); - return 0; - } - - if (ms <= 0) { /* just halt immediately. */ - Mix_HaltMusic(); - return 1; - } - - Mix_LockAudio(); - if (music_playing) { - int fade_steps = (ms + ms_per_step - 1) / ms_per_step; - if (music_playing->fading == MIX_NO_FADING) { - music_playing->fade_step = 0; - } else { - int step; - int old_fade_steps = music_playing->fade_steps; - if (music_playing->fading == MIX_FADING_OUT) { - step = music_playing->fade_step; - } else { - step = old_fade_steps - music_playing->fade_step + 1; - } - music_playing->fade_step = (step * fade_steps) / old_fade_steps; - } - music_playing->fading = MIX_FADING_OUT; - music_playing->fade_steps = fade_steps; - retval = 1; - } - Mix_UnlockAudio(); - - return(retval); -} - -Mix_Fading Mix_FadingMusic(void) -{ - Mix_Fading fading = MIX_NO_FADING; - - Mix_LockAudio(); - if (music_playing) { - fading = music_playing->fading; - } - Mix_UnlockAudio(); - - return(fading); -} - -/* Pause/Resume the music stream */ -void Mix_PauseMusic(void) -{ - Mix_LockAudio(); - if (music_playing) { - if (music_playing->interface->Pause) { - music_playing->interface->Pause(music_playing->context); - } - } - music_active = SDL_FALSE; - Mix_UnlockAudio(); -} - -void Mix_ResumeMusic(void) -{ - Mix_LockAudio(); - if (music_playing) { - if (music_playing->interface->Resume) { - music_playing->interface->Resume(music_playing->context); - } - } - music_active = SDL_TRUE; - Mix_UnlockAudio(); -} - -void Mix_RewindMusic(void) -{ - Mix_SetMusicPosition(0.0); -} - -int Mix_PausedMusic(void) -{ - return (music_active == SDL_FALSE); -} - -/* Check the status of the music */ -static SDL_bool music_internal_playing(void) -{ - if (!music_playing) { - return SDL_FALSE; - } - - if (music_playing->interface->IsPlaying) { - music_playing->playing = music_playing->interface->IsPlaying(music_playing->context); - } - return music_playing->playing; -} -int Mix_PlayingMusic(void) -{ - SDL_bool playing; - - Mix_LockAudio(); - playing = music_internal_playing(); - Mix_UnlockAudio(); - - return playing ? 1 : 0; -} - -/* Set the external music playback command */ -int Mix_SetMusicCMD(const char *command) -{ - Mix_HaltMusic(); - if (music_cmd) { - SDL_free(music_cmd); - music_cmd = NULL; - } - if (command) { - size_t length = SDL_strlen(command) + 1; - music_cmd = (char *)SDL_malloc(length); - if (music_cmd == NULL) { - return SDL_OutOfMemory(); - } - SDL_memcpy(music_cmd, command, length); - } - return 0; -} - -int Mix_SetSynchroValue(int i) -{ - /* Not supported by any players at this time */ - return(-1); -} - -int Mix_GetSynchroValue(void) -{ - /* Not supported by any players at this time */ - return(-1); -} - - -/* Uninitialize the music interfaces */ -void close_music(void) -{ - int i; - - Mix_HaltMusic(); - - for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { - Mix_MusicInterface *interface = s_music_interfaces[i]; - if (!interface || !interface->opened) { - continue; - } - - if (interface->Close) { - interface->Close(); - } - interface->opened = SDL_FALSE; - } - - if (soundfont_paths) { - SDL_free(soundfont_paths); - soundfont_paths = NULL; - } - - /* rcg06042009 report available decoders at runtime. */ - if (music_decoders) { - SDL_free((void *)music_decoders); - music_decoders = NULL; - } - num_decoders = 0; - - ms_per_step = 0; -} - -/* Unload the music interface libraries */ -void unload_music(void) -{ - int i; - for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { - Mix_MusicInterface *interface = s_music_interfaces[i]; - if (!interface || !interface->loaded) { - continue; - } - - if (interface->Unload) { - interface->Unload(); - } - interface->loaded = SDL_FALSE; - } -} - -int Mix_SetSoundFonts(const char *paths) -{ - if (soundfont_paths) { - SDL_free(soundfont_paths); - soundfont_paths = NULL; - } - - if (paths) { - if (!(soundfont_paths = SDL_strdup(paths))) { - Mix_SetError("Insufficient memory to set SoundFonts"); - return 0; - } - } - return 1; -} - -const char* Mix_GetSoundFonts(void) -{ - const char *env_paths = SDL_getenv("SDL_SOUNDFONTS"); - SDL_bool force_env_paths = SDL_GetHintBoolean("SDL_FORCE_SOUNDFONTS", SDL_FALSE); - if (force_env_paths && (!env_paths || !*env_paths)) { - force_env_paths = SDL_FALSE; - } - if (soundfont_paths && *soundfont_paths && !force_env_paths) { - return soundfont_paths; - } - if (env_paths) { - return env_paths; - } - - /* We don't have any sound fonts set programmatically or in the environment - Time to start guessing where they might be... - */ - { - static char *s_soundfont_paths[] = { - "/usr/share/sounds/sf2/FluidR3_GM.sf2" /* Remember to add ',' here */ - }; - unsigned i; - - for (i = 0; i < SDL_arraysize(s_soundfont_paths); ++i) { - SDL_RWops *rwops = SDL_RWFromFile(s_soundfont_paths[i], "rb"); - if (rwops) { - SDL_RWclose(rwops); - return s_soundfont_paths[i]; - } - } - } - return NULL; -} - -int Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data) -{ - char *context, *path, *paths; - const char* cpaths = Mix_GetSoundFonts(); - int soundfonts_found = 0; - - if (!cpaths) { - Mix_SetError("No SoundFonts have been requested"); - return 0; - } - - if (!(paths = SDL_strdup(cpaths))) { - Mix_SetError("Insufficient memory to iterate over SoundFonts"); - return 0; - } - -#if defined(__MINGW32__) || defined(__MINGW64__) || defined(__WATCOMC__) - for (path = strtok(paths, ";"); path; path = strtok(NULL, ";")) { -#elif defined(_WIN32) - for (path = strtok_s(paths, ";", &context); path; path = strtok_s(NULL, ";", &context)) { -#else - for (path = strtok_r(paths, ":;", &context); path; path = strtok_r(NULL, ":;", &context)) { -#endif - if (!function(path, data)) { - continue; - } else { - soundfonts_found++; - } - } - - SDL_free(paths); - if (soundfonts_found > 0) - return 1; - else - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music.h b/music.h deleted file mode 100644 index caec82f..0000000 --- a/music.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_mixer.h" - -#ifndef MUSIC_H_ -#define MUSIC_H_ - -/* Supported music APIs, in order of preference */ - -typedef enum -{ - MIX_MUSIC_CMD, - MIX_MUSIC_WAVE, - MIX_MUSIC_MODPLUG, - MIX_MUSIC_MIKMOD, - MIX_MUSIC_FLUIDSYNTH, - MIX_MUSIC_TIMIDITY, - MIX_MUSIC_NATIVEMIDI, - MIX_MUSIC_OGG, - MIX_MUSIC_MPG123, - MIX_MUSIC_MAD, - MIX_MUSIC_FLAC, - MIX_MUSIC_OPUS, - MIX_MUSIC_LAST -} Mix_MusicAPI; - - -/* Music API implementation */ - -typedef struct -{ - const char *tag; - Mix_MusicAPI api; - Mix_MusicType type; - SDL_bool loaded; - SDL_bool opened; - - /* Load the library */ - int (*Load)(void); - - /* Initialize for the audio output */ - int (*Open)(const SDL_AudioSpec *spec); - - /* Create a music object from an SDL_RWops stream - * If the function returns NULL, 'src' will be freed if needed by the caller. - */ - void *(*CreateFromRW)(SDL_RWops *src, int freesrc); - - /* Create a music object from a file, if SDL_RWops are not supported */ - void *(*CreateFromFile)(const char *file); - - /* Set the volume */ - void (*SetVolume)(void *music, int volume); - - /* Start playing music from the beginning with an optional loop count */ - int (*Play)(void *music, int play_count); - - /* Returns SDL_TRUE if music is still playing */ - SDL_bool (*IsPlaying)(void *music); - - /* Get music data, returns the number of bytes left */ - int (*GetAudio)(void *music, void *data, int bytes); - - /* Seek to a play position (in seconds) */ - int (*Seek)(void *music, double position); - - /* Pause playing music */ - void (*Pause)(void *music); - - /* Resume playing music */ - void (*Resume)(void *music); - - /* Stop playing music */ - void (*Stop)(void *music); - - /* Delete a music object */ - void (*Delete)(void *music); - - /* Close the library and clean up */ - void (*Close)(void); - - /* Unload the library */ - void (*Unload)(void); - -} Mix_MusicInterface; - - -extern int get_num_music_interfaces(void); -extern Mix_MusicInterface *get_music_interface(int index); -extern Mix_MusicType detect_music_type_from_magic(const Uint8 *magic); -extern SDL_bool load_music_type(Mix_MusicType type); -extern SDL_bool open_music_type(Mix_MusicType type); -extern SDL_bool has_music(Mix_MusicType type); -extern void open_music(const SDL_AudioSpec *spec); -extern int music_pcm_getaudio(void *context, void *data, int bytes, int volume, - int (*GetSome)(void *context, void *data, int bytes, SDL_bool *done)); -extern void SDLCALL music_mixer(void *udata, Uint8 *stream, int len); -extern void close_music(void); -extern void unload_music(void); - -extern char *music_cmd; -extern SDL_AudioSpec music_spec; - -#endif /* MUSIC_H_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_cmd.c b/music_cmd.c deleted file mode 100644 index f9f7298..0000000 --- a/music_cmd.c +++ /dev/null @@ -1,292 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_config.h" - -/* This file supports an external command for playing music */ - -#ifdef MUSIC_CMD - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if defined(__linux__) && defined(__arm__) -# include -#endif - -#include "music_cmd.h" - - -typedef struct { - char *file; - char *cmd; - pid_t pid; - int play_count; -} MusicCMD; - - -/* Load a music stream from the given file */ -static void *MusicCMD_CreateFromFile(const char *file) -{ - MusicCMD *music; - - if (!music_cmd) { - Mix_SetError("You must call Mix_SetMusicCMD() first"); - return NULL; - } - - /* Allocate and fill the music structure */ - music = (MusicCMD *)SDL_calloc(1, sizeof *music); - if (music == NULL) { - Mix_SetError("Out of memory"); - return NULL; - } - music->file = SDL_strdup(file); - music->cmd = SDL_strdup(music_cmd); - music->pid = 0; - - /* We're done */ - return music; -} - -/* Parse a command line buffer into arguments */ -static int ParseCommandLine(char *cmdline, char **argv) -{ - char *bufp; - int argc; - - argc = 0; - for (bufp = cmdline; *bufp;) { - /* Skip leading whitespace */ - while (isspace(*bufp)) { - ++bufp; - } - /* Skip over argument */ - if (*bufp == '"') { - ++bufp; - if (*bufp) { - if (argv) { - argv[argc] = bufp; - } - ++argc; - } - /* Skip over word */ - while (*bufp && (*bufp != '"')) { - ++bufp; - } - } else { - if (*bufp) { - if (argv) { - argv[argc] = bufp; - } - ++argc; - } - /* Skip over word */ - while (*bufp && ! isspace(*bufp)) { - ++bufp; - } - } - if (*bufp) { - if (argv) { - *bufp = '\0'; - } - ++bufp; - } - } - if (argv) { - argv[argc] = NULL; - } - return(argc); -} - -static char **parse_args(char *command, char *last_arg) -{ - int argc; - char **argv; - - /* Parse the command line */ - argc = ParseCommandLine(command, NULL); - if (last_arg) { - ++argc; - } - argv = (char **)SDL_malloc((argc+1)*(sizeof *argv)); - if (argv == NULL) { - return(NULL); - } - argc = ParseCommandLine(command, argv); - - /* Add last command line argument */ - if (last_arg) { - argv[argc++] = last_arg; - } - argv[argc] = NULL; - - /* We're ready! */ - return(argv); -} - -/* Start playback of a given music stream */ -static int MusicCMD_Play(void *context, int play_count) -{ - MusicCMD *music = (MusicCMD *)context; - - music->play_count = play_count; -#ifdef HAVE_FORK - music->pid = fork(); -#else - music->pid = vfork(); -#endif - switch(music->pid) { - /* Failed fork() system call */ - case -1: - Mix_SetError("fork() failed"); - return -1; - - /* Child process - executes here */ - case 0: { - char **argv; - - /* Unblock signals in case we're called from a thread */ - { - sigset_t mask; - sigemptyset(&mask); - sigprocmask(SIG_SETMASK, &mask, NULL); - } - - /* Execute the command */ - argv = parse_args(music->cmd, music->file); - if (argv != NULL) { - execvp(argv[0], argv); - - /* exec() failed */ - perror(argv[0]); - } - _exit(-1); - } - break; - - /* Parent process - executes here */ - default: - break; - } - return 0; -} - -/* Return non-zero if a stream is currently playing */ -static SDL_bool MusicCMD_IsPlaying(void *context) -{ - MusicCMD *music = (MusicCMD *)context; - int status; - - if (music->pid > 0) { - waitpid(music->pid, &status, WNOHANG); - if (kill(music->pid, 0) == 0) { - return SDL_TRUE; - } - - /* We might want to loop */ - if (music->play_count != 1) { - int play_count = -1; - if (music->play_count > 0) { - play_count = (music->play_count - 1); - } - MusicCMD_Play(music, play_count); - return SDL_TRUE; - } - } - return SDL_FALSE; -} - -/* Pause playback of a given music stream */ -static void MusicCMD_Pause(void *context) -{ - MusicCMD *music = (MusicCMD *)context; - if (music->pid > 0) { - kill(music->pid, SIGSTOP); - } -} - -/* Resume playback of a given music stream */ -static void MusicCMD_Resume(void *context) -{ - MusicCMD *music = (MusicCMD *)context; - if (music->pid > 0) { - kill(music->pid, SIGCONT); - } -} - -/* Stop playback of a stream previously started with MusicCMD_Start() */ -static void MusicCMD_Stop(void *context) -{ - MusicCMD *music = (MusicCMD *)context; - int status; - - if (music->pid > 0) { - while (kill(music->pid, 0) == 0) { - kill(music->pid, SIGTERM); - sleep(1); - waitpid(music->pid, &status, WNOHANG); - } - music->pid = 0; - } -} - -/* Close the given music stream */ -void MusicCMD_Delete(void *context) -{ - MusicCMD *music = (MusicCMD *)context; - SDL_free(music->file); - SDL_free(music); -} - -Mix_MusicInterface Mix_MusicInterface_CMD = -{ - "CMD", - MIX_MUSIC_CMD, - MUS_CMD, - SDL_FALSE, - SDL_FALSE, - - NULL, /* Load */ - NULL, /* Open */ - NULL, /* CreateFromRW */ - MusicCMD_CreateFromFile, - NULL, /* SetVolume */ - MusicCMD_Play, - MusicCMD_IsPlaying, - NULL, /* GetAudio */ - NULL, /* Seek */ - MusicCMD_Pause, - MusicCMD_Resume, - MusicCMD_Stop, - MusicCMD_Delete, - NULL, /* Close */ - NULL, /* Unload */ -}; - -#endif /* MUSIC_CMD */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_cmd.h b/music_cmd.h deleted file mode 100644 index c1f0ece..0000000 --- a/music_cmd.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* This file supports an external command for playing music */ - -#include "music.h" - -extern Mix_MusicInterface Mix_MusicInterface_CMD; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_flac.c b/music_flac.c deleted file mode 100644 index 98d6665..0000000 --- a/music_flac.c +++ /dev/null @@ -1,567 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - This file is used to support SDL_LoadMUS playback of FLAC files. - ~ Austen Dicken (admin@cvpcs.org) -*/ - -#ifdef MUSIC_FLAC - -#include "SDL_assert.h" -#include "SDL_loadso.h" - -#include "music_flac.h" - -#include - - -typedef struct { - int loaded; - void *handle; - FLAC__StreamDecoder *(*FLAC__stream_decoder_new)(void); - void (*FLAC__stream_decoder_delete)(FLAC__StreamDecoder *decoder); - FLAC__StreamDecoderInitStatus (*FLAC__stream_decoder_init_stream)( - FLAC__StreamDecoder *decoder, - FLAC__StreamDecoderReadCallback read_callback, - FLAC__StreamDecoderSeekCallback seek_callback, - FLAC__StreamDecoderTellCallback tell_callback, - FLAC__StreamDecoderLengthCallback length_callback, - FLAC__StreamDecoderEofCallback eof_callback, - FLAC__StreamDecoderWriteCallback write_callback, - FLAC__StreamDecoderMetadataCallback metadata_callback, - FLAC__StreamDecoderErrorCallback error_callback, - void *client_data); - FLAC__bool (*FLAC__stream_decoder_finish)(FLAC__StreamDecoder *decoder); - FLAC__bool (*FLAC__stream_decoder_flush)(FLAC__StreamDecoder *decoder); - FLAC__bool (*FLAC__stream_decoder_process_single)( - FLAC__StreamDecoder *decoder); - FLAC__bool (*FLAC__stream_decoder_process_until_end_of_metadata)( - FLAC__StreamDecoder *decoder); - FLAC__bool (*FLAC__stream_decoder_process_until_end_of_stream)( - FLAC__StreamDecoder *decoder); - FLAC__bool (*FLAC__stream_decoder_seek_absolute)( - FLAC__StreamDecoder *decoder, - FLAC__uint64 sample); - FLAC__StreamDecoderState (*FLAC__stream_decoder_get_state)( - const FLAC__StreamDecoder *decoder); -} flac_loader; - -static flac_loader flac = { - 0, NULL -}; - -#ifdef FLAC_DYNAMIC -#define FUNCTION_LOADER(FUNC, SIG) \ - flac.FUNC = (SIG) SDL_LoadFunction(flac.handle, #FUNC); \ - if (flac.FUNC == NULL) { SDL_UnloadObject(flac.handle); return -1; } -#else -#define FUNCTION_LOADER(FUNC, SIG) \ - flac.FUNC = FUNC; -#endif - -static int FLAC_Load(void) -{ - if (flac.loaded == 0) { -#ifdef FLAC_DYNAMIC - flac.handle = SDL_LoadObject(FLAC_DYNAMIC); - if (flac.handle == NULL) { - return -1; - } -#elif defined(__MACOSX__) - extern FLAC__StreamDecoder *FLAC__stream_decoder_new(void) __attribute__((weak_import)); - if (FLAC__stream_decoder_new == NULL) - { - /* Missing weakly linked framework */ - Mix_SetError("Missing FLAC.framework"); - return -1; - } -#endif - - FUNCTION_LOADER(FLAC__stream_decoder_new, FLAC__StreamDecoder *(*)(void)) - FUNCTION_LOADER(FLAC__stream_decoder_delete, void (*)(FLAC__StreamDecoder *)) - FUNCTION_LOADER(FLAC__stream_decoder_init_stream, FLAC__StreamDecoderInitStatus (*)( - FLAC__StreamDecoder *, - FLAC__StreamDecoderReadCallback, - FLAC__StreamDecoderSeekCallback, - FLAC__StreamDecoderTellCallback, - FLAC__StreamDecoderLengthCallback, - FLAC__StreamDecoderEofCallback, - FLAC__StreamDecoderWriteCallback, - FLAC__StreamDecoderMetadataCallback, - FLAC__StreamDecoderErrorCallback, - void *)) - FUNCTION_LOADER(FLAC__stream_decoder_finish, FLAC__bool (*)(FLAC__StreamDecoder *)) - FUNCTION_LOADER(FLAC__stream_decoder_flush, FLAC__bool (*)(FLAC__StreamDecoder *)) - FUNCTION_LOADER(FLAC__stream_decoder_process_single, FLAC__bool (*)(FLAC__StreamDecoder *)) - FUNCTION_LOADER(FLAC__stream_decoder_process_until_end_of_metadata, FLAC__bool (*)(FLAC__StreamDecoder *)) - FUNCTION_LOADER(FLAC__stream_decoder_process_until_end_of_stream, FLAC__bool (*)(FLAC__StreamDecoder *)) - FUNCTION_LOADER(FLAC__stream_decoder_seek_absolute, FLAC__bool (*)(FLAC__StreamDecoder *, FLAC__uint64)) - FUNCTION_LOADER(FLAC__stream_decoder_get_state, FLAC__StreamDecoderState (*)(const FLAC__StreamDecoder *decoder)) - } - ++flac.loaded; - - return 0; -} - -static void FLAC_Unload(void) -{ - if (flac.loaded == 0) { - return; - } - if (flac.loaded == 1) { -#ifdef FLAC_DYNAMIC - SDL_UnloadObject(flac.handle); -#endif - } - --flac.loaded; -} - - -typedef struct { - int volume; - int play_count; - FLAC__StreamDecoder *flac_decoder; - unsigned sample_rate; - unsigned channels; - unsigned bits_per_sample; - SDL_RWops *src; - int freesrc; - SDL_AudioStream *stream; -} FLAC_Music; - - -static int FLAC_Seek(void *context, double position); - -static FLAC__StreamDecoderReadStatus flac_read_music_cb( - const FLAC__StreamDecoder *decoder, - FLAC__byte buffer[], - size_t *bytes, - void *client_data) -{ - FLAC_Music *data = (FLAC_Music*)client_data; - - /* make sure there is something to be reading */ - if (*bytes > 0) { - *bytes = SDL_RWread (data->src, buffer, sizeof (FLAC__byte), *bytes); - - if (*bytes == 0) { /* error or no data was read (EOF) */ - return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - } else { /* data was read, continue */ - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - } - } else { - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - } -} - -static FLAC__StreamDecoderSeekStatus flac_seek_music_cb( - const FLAC__StreamDecoder *decoder, - FLAC__uint64 absolute_byte_offset, - void *client_data) -{ - FLAC_Music *data = (FLAC_Music*)client_data; - - if (SDL_RWseek(data->src, absolute_byte_offset, RW_SEEK_SET) < 0) { - return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; - } else { - return FLAC__STREAM_DECODER_SEEK_STATUS_OK; - } -} - -static FLAC__StreamDecoderTellStatus flac_tell_music_cb( - const FLAC__StreamDecoder *decoder, - FLAC__uint64 *absolute_byte_offset, - void *client_data) -{ - FLAC_Music *data = (FLAC_Music*)client_data; - - Sint64 pos = SDL_RWtell(data->src); - - if (pos < 0) { - return FLAC__STREAM_DECODER_TELL_STATUS_ERROR; - } else { - *absolute_byte_offset = (FLAC__uint64)pos; - return FLAC__STREAM_DECODER_TELL_STATUS_OK; - } -} - -static FLAC__StreamDecoderLengthStatus flac_length_music_cb( - const FLAC__StreamDecoder *decoder, - FLAC__uint64 *stream_length, - void *client_data) -{ - FLAC_Music *data = (FLAC_Music*)client_data; - - Sint64 pos = SDL_RWtell(data->src); - Sint64 length = SDL_RWseek(data->src, 0, RW_SEEK_END); - - if (SDL_RWseek(data->src, pos, RW_SEEK_SET) != pos || length < 0) { - /* there was an error attempting to return the stream to the original - * position, or the length was invalid. */ - return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR; - } else { - *stream_length = (FLAC__uint64)length; - return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; - } -} - -static FLAC__bool flac_eof_music_cb( - const FLAC__StreamDecoder *decoder, - void *client_data) -{ - FLAC_Music *data = (FLAC_Music*)client_data; - - Sint64 pos = SDL_RWtell(data->src); - Sint64 end = SDL_RWseek(data->src, 0, RW_SEEK_END); - - /* was the original position equal to the end (a.k.a. the seek didn't move)? */ - if (pos == end) { - /* must be EOF */ - return true; - } else { - /* not EOF, return to the original position */ - SDL_RWseek(data->src, pos, RW_SEEK_SET); - return false; - } -} - -static FLAC__StreamDecoderWriteStatus flac_write_music_cb( - const FLAC__StreamDecoder *decoder, - const FLAC__Frame *frame, - const FLAC__int32 *const buffer[], - void *client_data) -{ - FLAC_Music *music = (FLAC_Music *)client_data; - Sint16 *data; - unsigned int i, j, channels; - int shift_amount = 0; - - if (!music->stream) { - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - - switch (music->bits_per_sample) { - case 16: - shift_amount = 0; - break; - case 20: - shift_amount = 4; - break; - case 24: - shift_amount = 8; - break; - default: - SDL_SetError("FLAC decoder doesn't support %d bits_per_sample", music->bits_per_sample); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - - if (music->channels == 3) { - /* We'll just drop the center channel for now */ - channels = 2; - } else { - channels = music->channels; - } - - data = SDL_stack_alloc(Sint16, (frame->header.blocksize * channels)); - if (!data) { - SDL_SetError("Couldn't allocate %d bytes stack memory", (int)(frame->header.blocksize * channels * sizeof(*data))); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - if (music->channels == 3) { - Sint16 *dst = data; - for (i = 0; i < frame->header.blocksize; ++i) { - Sint16 FL = (buffer[0][i] >> shift_amount); - Sint16 FR = (buffer[1][i] >> shift_amount); - Sint16 FCmix = (Sint16)((buffer[2][i] >> shift_amount) * 0.5f); - int sample; - - sample = (FL + FCmix); - if (sample > SDL_MAX_SINT16) { - *dst = SDL_MAX_SINT16; - } else if (sample < SDL_MIN_SINT16) { - *dst = SDL_MIN_SINT16; - } else { - *dst = sample; - } - ++dst; - - sample = (FR + FCmix); - if (sample > SDL_MAX_SINT16) { - *dst = SDL_MAX_SINT16; - } else if (sample < SDL_MIN_SINT16) { - *dst = SDL_MIN_SINT16; - } else { - *dst = sample; - } - ++dst; - } - } else { - for (i = 0; i < channels; ++i) { - Sint16 *dst = data + i; - for (j = 0; j < frame->header.blocksize; ++j) { - *dst = (buffer[i][j] >> shift_amount); - dst += channels; - } - } - } - SDL_AudioStreamPut(music->stream, data, (frame->header.blocksize * channels * sizeof(*data))); - SDL_stack_free(data); - - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - -static void flac_metadata_music_cb( - const FLAC__StreamDecoder *decoder, - const FLAC__StreamMetadata *metadata, - void *client_data) -{ - FLAC_Music *music = (FLAC_Music *)client_data; - int channels; - - if (metadata->type != FLAC__METADATA_TYPE_STREAMINFO) { - return; - } - - music->sample_rate = metadata->data.stream_info.sample_rate; - music->channels = metadata->data.stream_info.channels; - music->bits_per_sample = metadata->data.stream_info.bits_per_sample; -/*printf("FLAC: Sample rate = %d, channels = %d, bits_per_sample = %d\n", music->sample_rate, music->channels, music->bits_per_sample);*/ - - /* SDL's channel mapping and FLAC channel mapping are the same, - except for 3 channels: SDL is FL FR LFE and FLAC is FL FR FC - */ - if (music->channels == 3) { - channels = 2; - } else { - channels = music->channels; - } - /* We check for NULL stream later when we get data */ - SDL_assert(!music->stream); - music->stream = SDL_NewAudioStream(AUDIO_S16SYS, channels, music->sample_rate, - music_spec.format, music_spec.channels, music_spec.freq); -} - -static void flac_error_music_cb( - const FLAC__StreamDecoder *decoder, - FLAC__StreamDecoderErrorStatus status, - void *client_data) -{ - /* print an SDL error based on the error status */ - switch (status) { - case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC: - SDL_SetError("Error processing the FLAC file [LOST_SYNC]."); - break; - case FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER: - SDL_SetError("Error processing the FLAC file [BAD_HEADER]."); - break; - case FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH: - SDL_SetError("Error processing the FLAC file [CRC_MISMATCH]."); - break; - case FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM: - SDL_SetError("Error processing the FLAC file [UNPARSEABLE]."); - break; - default: - SDL_SetError("Error processing the FLAC file [UNKNOWN]."); - break; - } -} - -/* Load an FLAC stream from an SDL_RWops object */ -static void *FLAC_CreateFromRW(SDL_RWops *src, int freesrc) -{ - FLAC_Music *music; - int init_stage = 0; - int was_error = 1; - - music = (FLAC_Music *)SDL_calloc(1, sizeof(*music)); - if (!music) { - SDL_OutOfMemory(); - return NULL; - } - music->src = src; - music->volume = MIX_MAX_VOLUME; - - music->flac_decoder = flac.FLAC__stream_decoder_new(); - if (music->flac_decoder) { - init_stage++; /* stage 1! */ - - if (flac.FLAC__stream_decoder_init_stream( - music->flac_decoder, - flac_read_music_cb, flac_seek_music_cb, - flac_tell_music_cb, flac_length_music_cb, - flac_eof_music_cb, flac_write_music_cb, - flac_metadata_music_cb, flac_error_music_cb, - music) == FLAC__STREAM_DECODER_INIT_STATUS_OK) { - init_stage++; /* stage 2! */ - - if (flac.FLAC__stream_decoder_process_until_end_of_metadata(music->flac_decoder)) { - was_error = 0; - } else { - SDL_SetError("FLAC__stream_decoder_process_until_end_of_metadata() failed"); - } - } else { - SDL_SetError("FLAC__stream_decoder_init_stream() failed"); - } - } else { - SDL_SetError("FLAC__stream_decoder_new() failed"); - } - - if (was_error) { - switch (init_stage) { - case 2: - flac.FLAC__stream_decoder_finish(music->flac_decoder); - case 1: - flac.FLAC__stream_decoder_delete(music->flac_decoder); - case 0: - SDL_free(music); - break; - } - return NULL; - } - - music->freesrc = freesrc; - return music; -} - -/* Set the volume for an FLAC stream */ -static void FLAC_SetVolume(void *context, int volume) -{ - FLAC_Music *music = (FLAC_Music *)context; - music->volume = volume; -} - -/* Start playback of a given FLAC stream */ -static int FLAC_Play(void *context, int play_count) -{ - FLAC_Music *music = (FLAC_Music *)context; - music->play_count = play_count; - return FLAC_Seek(music, 0.0); -} - -/* Read some FLAC stream data and convert it for output */ -static int FLAC_GetSome(void *context, void *data, int bytes, SDL_bool *done) -{ - FLAC_Music *music = (FLAC_Music *)context; - int filled; - - filled = SDL_AudioStreamGet(music->stream, data, bytes); - if (filled != 0) { - return filled; - } - - if (!music->play_count) { - /* All done */ - *done = SDL_TRUE; - return 0; - } - - if (!flac.FLAC__stream_decoder_process_single(music->flac_decoder)) { - SDL_SetError("FLAC__stream_decoder_process_single() failed"); - return -1; - } - - if (flac.FLAC__stream_decoder_get_state(music->flac_decoder) == FLAC__STREAM_DECODER_END_OF_STREAM) { - if (music->play_count == 1) { - music->play_count = 0; - SDL_AudioStreamFlush(music->stream); - } else { - int play_count = -1; - if (music->play_count > 0) { - play_count = (music->play_count - 1); - } - if (FLAC_Play(music, play_count) < 0) { - return -1; - } - } - } - return 0; -} - -/* Play some of a stream previously started with FLAC_play() */ -static int FLAC_GetAudio(void *context, void *data, int bytes) -{ - FLAC_Music *music = (FLAC_Music *)context; - return music_pcm_getaudio(context, data, bytes, music->volume, FLAC_GetSome); -} - -/* Jump (seek) to a given position (position is in seconds) */ -static int FLAC_Seek(void *context, double position) -{ - FLAC_Music *music = (FLAC_Music *)context; - double seek_sample = music->sample_rate * position; - - if (!flac.FLAC__stream_decoder_seek_absolute(music->flac_decoder, (FLAC__uint64)seek_sample)) { - if (flac.FLAC__stream_decoder_get_state(music->flac_decoder) == FLAC__STREAM_DECODER_SEEK_ERROR) { - flac.FLAC__stream_decoder_flush(music->flac_decoder); - } - - SDL_SetError("Seeking of FLAC stream failed: libFLAC seek failed."); - return -1; - } - return 0; -} - -/* Close the given FLAC_Music object */ -static void FLAC_Delete(void *context) -{ - FLAC_Music *music = (FLAC_Music *)context; - if (music) { - if (music->flac_decoder) { - flac.FLAC__stream_decoder_finish(music->flac_decoder); - flac.FLAC__stream_decoder_delete(music->flac_decoder); - } - if (music->stream) { - SDL_FreeAudioStream(music->stream); - } - if (music->freesrc) { - SDL_RWclose(music->src); - } - SDL_free(music); - } -} - -Mix_MusicInterface Mix_MusicInterface_FLAC = -{ - "FLAC", - MIX_MUSIC_FLAC, - MUS_FLAC, - SDL_FALSE, - SDL_FALSE, - - FLAC_Load, - NULL, /* Open */ - FLAC_CreateFromRW, - NULL, /* CreateFromFile */ - FLAC_SetVolume, - FLAC_Play, - NULL, /* IsPlaying */ - FLAC_GetAudio, - FLAC_Seek, - NULL, /* Pause */ - NULL, /* Resume */ - NULL, /* Stop */ - FLAC_Delete, - NULL, /* Close */ - FLAC_Unload, -}; - -#endif /* MUSIC_FLAC */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_flac.h b/music_flac.h deleted file mode 100644 index 65b9502..0000000 --- a/music_flac.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "music.h" - -extern Mix_MusicInterface Mix_MusicInterface_FLAC; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_fluidsynth.c b/music_fluidsynth.c deleted file mode 100644 index f5346a4..0000000 --- a/music_fluidsynth.c +++ /dev/null @@ -1,309 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - James Le Cuirot - chewi@aura-online.co.uk -*/ - -#ifdef MUSIC_MID_FLUIDSYNTH - -#include - -#include "SDL_loadso.h" - -#include "music_fluidsynth.h" - -#include - - -typedef struct { - int loaded; - void *handle; - - int (*delete_fluid_player)(fluid_player_t*); - void (*delete_fluid_settings)(fluid_settings_t*); - int (*delete_fluid_synth)(fluid_synth_t*); - int (*fluid_player_add)(fluid_player_t*, const char*); - int (*fluid_player_add_mem)(fluid_player_t*, const void*, size_t); - int (*fluid_player_get_status)(fluid_player_t*); - int (*fluid_player_play)(fluid_player_t*); - int (*fluid_player_set_loop)(fluid_player_t*, int); - int (*fluid_player_stop)(fluid_player_t*); - int (*fluid_settings_setnum)(fluid_settings_t*, const char*, double); - fluid_settings_t* (*fluid_synth_get_settings)(fluid_synth_t*); - void (*fluid_synth_set_gain)(fluid_synth_t*, float); - int (*fluid_synth_sfload)(fluid_synth_t*, const char*, int); - int (*fluid_synth_write_s16)(fluid_synth_t*, int, void*, int, int, void*, int, int); - fluid_player_t* (*new_fluid_player)(fluid_synth_t*); - fluid_settings_t* (*new_fluid_settings)(void); - fluid_synth_t* (*new_fluid_synth)(fluid_settings_t*); -} fluidsynth_loader; - -static fluidsynth_loader fluidsynth = { - 0, NULL -}; - -#ifdef FLUIDSYNTH_DYNAMIC -#define FUNCTION_LOADER(FUNC, SIG) \ - fluidsynth.FUNC = (SIG) SDL_LoadFunction(fluidsynth.handle, #FUNC); \ - if (fluidsynth.FUNC == NULL) { SDL_UnloadObject(fluidsynth.handle); return -1; } -#else -#define FUNCTION_LOADER(FUNC, SIG) \ - fluidsynth.FUNC = FUNC; -#endif - -static int FLUIDSYNTH_Load() -{ - if (fluidsynth.loaded == 0) { -#ifdef FLUIDSYNTH_DYNAMIC - fluidsynth.handle = SDL_LoadObject(FLUIDSYNTH_DYNAMIC); - if (fluidsynth.handle == NULL) { - return -1; - } -#endif - FUNCTION_LOADER(delete_fluid_player, int (*)(fluid_player_t*)) - FUNCTION_LOADER(delete_fluid_settings, void (*)(fluid_settings_t*)) - FUNCTION_LOADER(delete_fluid_synth, int (*)(fluid_synth_t*)) - FUNCTION_LOADER(fluid_player_add, int (*)(fluid_player_t*, const char*)) - FUNCTION_LOADER(fluid_player_add_mem, int (*)(fluid_player_t*, const void*, size_t)) - FUNCTION_LOADER(fluid_player_get_status, int (*)(fluid_player_t*)) - FUNCTION_LOADER(fluid_player_play, int (*)(fluid_player_t*)) - FUNCTION_LOADER(fluid_player_set_loop, int (*)(fluid_player_t*, int)) - FUNCTION_LOADER(fluid_player_stop, int (*)(fluid_player_t*)) - FUNCTION_LOADER(fluid_settings_setnum, int (*)(fluid_settings_t*, const char*, double)) - FUNCTION_LOADER(fluid_synth_get_settings, fluid_settings_t* (*)(fluid_synth_t*)) - FUNCTION_LOADER(fluid_synth_set_gain, void (*)(fluid_synth_t*, float)) - FUNCTION_LOADER(fluid_synth_sfload, int(*)(fluid_synth_t*, const char*, int)) - FUNCTION_LOADER(fluid_synth_write_s16, int(*)(fluid_synth_t*, int, void*, int, int, void*, int, int)) - FUNCTION_LOADER(new_fluid_player, fluid_player_t* (*)(fluid_synth_t*)) - FUNCTION_LOADER(new_fluid_settings, fluid_settings_t* (*)(void)) - FUNCTION_LOADER(new_fluid_synth, fluid_synth_t* (*)(fluid_settings_t*)) - } - ++fluidsynth.loaded; - - return 0; -} - -static void FLUIDSYNTH_Unload() -{ - if (fluidsynth.loaded == 0) { - return; - } - if (fluidsynth.loaded == 1) { -#ifdef FLUIDSYNTH_DYNAMIC - SDL_UnloadObject(fluidsynth.handle); -#endif - } - --fluidsynth.loaded; -} - - -typedef struct { - fluid_synth_t *synth; - fluid_player_t *player; - SDL_AudioStream *stream; - void *buffer; - int buffer_size; -} FLUIDSYNTH_Music; - - -static int SDLCALL fluidsynth_check_soundfont(const char *path, void *data) -{ - FILE *file = fopen(path, "r"); - - if (file) { - fclose(file); - return 1; - } else { - Mix_SetError("Failed to access the SoundFont %s", path); - return 0; - } -} - -static int SDLCALL fluidsynth_load_soundfont(const char *path, void *data) -{ - /* If this fails, it's too late to try Timidity so pray that at least one works. */ - fluidsynth.fluid_synth_sfload((fluid_synth_t*) data, path, 1); - return 1; -} - -static int FLUIDSYNTH_Open(const SDL_AudioSpec *spec) -{ - if (!Mix_EachSoundFont(fluidsynth_check_soundfont, NULL)) { - return -1; - } - return 0; -} - -static FLUIDSYNTH_Music *FLUIDSYNTH_LoadMusic(void *data) -{ - SDL_RWops *src = (SDL_RWops *)data; - FLUIDSYNTH_Music *music; - fluid_settings_t *settings; - - if ((music = SDL_calloc(1, sizeof(FLUIDSYNTH_Music)))) { - int channels = 2; - if ((music->stream = SDL_NewAudioStream(AUDIO_S16SYS, channels, music_spec.freq, music_spec.format, music_spec.channels, music_spec.freq))) { - music->buffer_size = music_spec.samples * sizeof(Sint16) * channels; - if ((music->buffer = SDL_malloc(music->buffer_size))) { - if ((settings = fluidsynth.new_fluid_settings())) { - fluidsynth.fluid_settings_setnum(settings, "synth.sample-rate", (double) music_spec.freq); - - if ((music->synth = fluidsynth.new_fluid_synth(settings))) { - if (Mix_EachSoundFont(fluidsynth_load_soundfont, (void*) music->synth)) { - if ((music->player = fluidsynth.new_fluid_player(music->synth))) { - void *buffer; - size_t size; - - buffer = SDL_LoadFile_RW(src, &size, SDL_FALSE); - if (buffer) { - if (fluidsynth.fluid_player_add_mem(music->player, buffer, size) == FLUID_OK) { - SDL_free(buffer); - return music; - } else { - Mix_SetError("FluidSynth failed to load in-memory song"); - } - SDL_free(buffer); - } else { - SDL_OutOfMemory(); - } - fluidsynth.delete_fluid_player(music->player); - } else { - Mix_SetError("Failed to create FluidSynth player"); - } - } - fluidsynth.delete_fluid_synth(music->synth); - } else { - Mix_SetError("Failed to create FluidSynth synthesizer"); - } - fluidsynth.delete_fluid_settings(settings); - } else { - Mix_SetError("Failed to create FluidSynth settings"); - } - } else { - SDL_OutOfMemory(); - } - } - SDL_free(music); - } else { - SDL_OutOfMemory(); - } - return NULL; -} - -static void *FLUIDSYNTH_CreateFromRW(SDL_RWops *src, int freesrc) -{ - FLUIDSYNTH_Music *music; - - music = FLUIDSYNTH_LoadMusic(src); - if (music && freesrc) { - SDL_RWclose(src); - } - return music; -} - -static void FLUIDSYNTH_SetVolume(void *context, int volume) -{ - FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; - /* FluidSynth's default is 0.2. Make 1.2 the maximum. */ - fluidsynth.fluid_synth_set_gain(music->synth, (float) (volume * 1.2 / MIX_MAX_VOLUME)); -} - -static int FLUIDSYNTH_Play(void *context, int play_count) -{ - FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; - fluidsynth.fluid_player_set_loop(music->player, play_count); - fluidsynth.fluid_player_play(music->player); - return 0; -} - -static SDL_bool FLUIDSYNTH_IsPlaying(void *context) -{ - FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; - return fluidsynth.fluid_player_get_status(music->player) == FLUID_PLAYER_PLAYING ? SDL_TRUE : SDL_FALSE; -} - -static int FLUIDSYNTH_GetSome(void *context, void *data, int bytes, SDL_bool *done) -{ - FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; - int filled; - - filled = SDL_AudioStreamGet(music->stream, data, bytes); - if (filled != 0) { - return filled; - } - - if (fluidsynth.fluid_synth_write_s16(music->synth, music_spec.samples, music->buffer, 0, 2, music->buffer, 1, 2) != FLUID_OK) { - Mix_SetError("Error generating FluidSynth audio"); - return -1; - } - if (SDL_AudioStreamPut(music->stream, music->buffer, music->buffer_size) < 0) { - return -1; - } - return 0; -} -static int FLUIDSYNTH_GetAudio(void *context, void *data, int bytes) -{ - return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, FLUIDSYNTH_GetSome); -} - -static void FLUIDSYNTH_Stop(void *context) -{ - FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; - fluidsynth.fluid_player_stop(music->player); -} - -static void FLUIDSYNTH_Delete(void *context) -{ - FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; - fluidsynth.delete_fluid_player(music->player); - fluidsynth.delete_fluid_settings(fluidsynth.fluid_synth_get_settings(music->synth)); - fluidsynth.delete_fluid_synth(music->synth); - SDL_free(music); -} - -Mix_MusicInterface Mix_MusicInterface_FLUIDSYNTH = -{ - "FLUIDSYNTH", - MIX_MUSIC_FLUIDSYNTH, - MUS_MID, - SDL_FALSE, - SDL_FALSE, - - FLUIDSYNTH_Load, - FLUIDSYNTH_Open, - FLUIDSYNTH_CreateFromRW, - NULL, /* CreateFromFile */ - FLUIDSYNTH_SetVolume, - FLUIDSYNTH_Play, - FLUIDSYNTH_IsPlaying, - FLUIDSYNTH_GetAudio, - NULL, /* Seek */ - NULL, /* Pause */ - NULL, /* Resume */ - FLUIDSYNTH_Stop, - FLUIDSYNTH_Delete, - NULL, /* Close */ - FLUIDSYNTH_Unload, -}; - -#endif /* MUSIC_MID_FLUIDSYNTH */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_fluidsynth.h b/music_fluidsynth.h deleted file mode 100644 index 5946973..0000000 --- a/music_fluidsynth.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - James Le Cuirot - chewi@aura-online.co.uk -*/ - -/* This file supports playing MIDI files with FluidSynth */ - -#include "music.h" - -extern Mix_MusicInterface Mix_MusicInterface_FLUIDSYNTH; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_mad.c b/music_mad.c deleted file mode 100644 index b385a31..0000000 --- a/music_mad.c +++ /dev/null @@ -1,554 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef MUSIC_MP3_MAD - -#include "music_mad.h" - -#include "mad.h" - - -/* NOTE: The dithering functions are GPL, which should be fine if your - application is GPL (which would need to be true if you enabled - libmad support in SDL_mixer). If you're using libmad under the - commercial license, you need to disable this code. -*/ -/************************ dithering functions ***************************/ - -#ifdef MUSIC_MP3_MAD_GPL_DITHERING - -/* All dithering done here is taken from the GPL'ed xmms-mad plugin. */ - -/* Copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura. */ -/* Any feedback is very welcome. For any question, comments, */ -/* see http://www.math.keio.ac.jp/matumoto/emt.html or email */ -/* matumoto@math.keio.ac.jp */ - -/* Period parameters */ -#define MP3_DITH_N 624 -#define MP3_DITH_M 397 -#define MATRIX_A 0x9908b0df /* constant vector a */ -#define UPPER_MASK 0x80000000 /* most significant w-r bits */ -#define LOWER_MASK 0x7fffffff /* least significant r bits */ - -/* Tempering parameters */ -#define TEMPERING_MASK_B 0x9d2c5680 -#define TEMPERING_MASK_C 0xefc60000 -#define TEMPERING_SHIFT_U(y) (y >> 11) -#define TEMPERING_SHIFT_S(y) (y << 7) -#define TEMPERING_SHIFT_T(y) (y << 15) -#define TEMPERING_SHIFT_L(y) (y >> 18) - -static unsigned long mt[MP3_DITH_N]; /* the array for the state vector */ -static int mti=MP3_DITH_N+1; /* mti==MP3_DITH_N+1 means mt[MP3_DITH_N] is not initialized */ - -/* initializing the array with a NONZERO seed */ -static void sgenrand(unsigned long seed) -{ - /* setting initial seeds to mt[MP3_DITH_N] using */ - /* the generator Line 25 of Table 1 in */ - /* [KNUTH 1981, The Art of Computer Programming */ - /* Vol. 2 (2nd Ed.), pp102] */ - mt[0]= seed & 0xffffffff; - for (mti=1; mti= MP3_DITH_N) { /* generate MP3_DITH_N words at one time */ - int kk; - - if (mti == MP3_DITH_N+1) /* if sgenrand() has not been called, */ - sgenrand(4357); /* a default initial seed is used */ - - for (kk=0;kk> 1) ^ mag01[y & 0x1]; - } - for (;kk> 1) ^ mag01[y & 0x1]; - } - y = (mt[MP3_DITH_N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK); - mt[MP3_DITH_N-1] = mt[MP3_DITH_M-1] ^ (y >> 1) ^ mag01[y & 0x1]; - - mti = 0; - } - - y = mt[mti++]; - y ^= TEMPERING_SHIFT_U(y); - y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B; - y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C; - y ^= TEMPERING_SHIFT_L(y); - - return y; -} - -static long triangular_dither_noise(int nbits) { - /* parameter nbits : the peak-to-peak amplitude desired (in bits) - * use with nbits set to 2 + nber of bits to be trimmed. - * (because triangular is made from two uniformly distributed processes, - * it starts at 2 bits peak-to-peak amplitude) - * see The Theory of Dithered Quantization by Robert Alexander Wannamaker - * for complete proof of why that's optimal - */ - long v = (genrand()/2 - genrand()/2); /* in ]-2^31, 2^31[ */ - long P = 1 << (32 - nbits); /* the power of 2 */ - v /= P; - /* now v in ]-2^(nbits-1), 2^(nbits-1) [ */ - - return v; -} - -#endif /* MUSIC_MP3_MAD_GPL_DITHERING */ - - -#define MAD_INPUT_BUFFER_SIZE (5*8192) - -enum { - MS_input_eof = 0x0001, - MS_input_error = 0x0001, - MS_decode_error = 0x0002, - MS_error_flags = 0x000f, -}; - -typedef struct { - int play_count; - SDL_RWops *src; - int freesrc; - struct mad_stream stream; - struct mad_frame frame; - struct mad_synth synth; - mad_timer_t next_frame_start; - int volume; - int status; - SDL_AudioStream *audiostream; - - unsigned char input_buffer[MAD_INPUT_BUFFER_SIZE + MAD_BUFFER_GUARD]; -} MAD_Music; - - -static int MAD_Seek(void *context, double position); - -static void *MAD_CreateFromRW(SDL_RWops *src, int freesrc) -{ - MAD_Music *music; - - music = (MAD_Music *)SDL_calloc(1, sizeof(MAD_Music)); - if (!music) { - SDL_OutOfMemory(); - return NULL; - } - music->src = src; - music->volume = MIX_MAX_VOLUME; - - mad_stream_init(&music->stream); - mad_frame_init(&music->frame); - mad_synth_init(&music->synth); - mad_timer_reset(&music->next_frame_start); - - music->freesrc = freesrc; - return music; -} - -static void MAD_SetVolume(void *context, int volume) -{ - MAD_Music *music = (MAD_Music *)context; - music->volume = volume; -} - -/* Starts the playback. */ -static int MAD_Play(void *context, int play_count) -{ - MAD_Music *music = (MAD_Music *)context; - music->play_count = play_count; - return MAD_Seek(music, 0.0); -} - - -/*************************** TAG HANDLING: ******************************/ - -static SDL_INLINE SDL_bool is_id3v1(const Uint8 *data, size_t length) -{ - /* http://id3.org/ID3v1 : 3 bytes "TAG" identifier and 125 bytes tag data */ - if (length < 3 || SDL_memcmp(data,"TAG",3) != 0) { - return SDL_FALSE; - } - return SDL_TRUE; -} -static SDL_INLINE SDL_bool is_id3v2(const Uint8 *data, size_t length) -{ - /* ID3v2 header is 10 bytes: http://id3.org/id3v2.4.0-structure */ - /* bytes 0-2: "ID3" identifier */ - if (length < 10 || SDL_memcmp(data,"ID3",3) != 0) { - return SDL_FALSE; - } - /* bytes 3-4: version num (major,revision), each byte always less than 0xff. */ - if (data[3] == 0xff || data[4] == 0xff) { - return SDL_FALSE; - } - /* bytes 6-9 are the ID3v2 tag size: a 32 bit 'synchsafe' integer, i.e. the - * highest bit 7 in each byte zeroed. i.e.: 7 bit information in each byte -> - * effectively a 28 bit value. */ - if (data[6] >= 0x80 || data[7] >= 0x80 || data[8] >= 0x80 || data[9] >= 0x80) { - return SDL_FALSE; - } - return SDL_TRUE; -} -static SDL_INLINE SDL_bool is_apetag(const Uint8 *data, size_t length) -{ - /* http://wiki.hydrogenaud.io/index.php?title=APEv2_specification - * APEv2 header is 32 bytes: bytes 0-7 ident, bytes 8-11 version, - * bytes 12-17 size. bytes 24-31 are reserved: must be all zeroes. - * APEv1 has no header, so no luck. */ - Uint32 v; - - if (length < 32 || SDL_memcmp(data,"APETAGEX",8) != 0) { - return SDL_FALSE; - } - v = (data[11]<<24) | (data[10]<<16) | (data[9]<<8) | data[8]; /* version */ - if (v != 2000U) { - return SDL_FALSE; - } - v = 0; /* reserved bits : */ - if (SDL_memcmp(&data[24],&v,4) != 0 || SDL_memcmp(&data[28],&v,4) != 0) { - return SDL_FALSE; - } - return SDL_TRUE; -} - -static size_t get_tagsize(const Uint8 *data, size_t length) -{ - size_t size; - - if (is_id3v1(data, length)) { - return 128; /* fixed length */ - } - if (is_id3v2(data, length)) { - /* size is a 'synchsafe' integer (see above) */ - size = (data[6]<<21) + (data[7]<<14) + (data[8]<<7) + data[9]; - size += 10; /* header size */ - /* ID3v2 header[5] is flags (bits 4-7 only, 0-3 are zero). - * bit 4 set: footer is present (a copy of the header but - * with "3DI" as ident.) */ - if (data[5] & 0x10) { - size += 10; /* footer size */ - } - /* optional padding (always zeroes) */ - while (size < length && data[size] == 0) { - ++size; - } - return size; - } - if (is_apetag(data, length)) { - size = (data[15]<<24) | (data[14]<<16) | (data[13]<<8) | data[12]; - size += 32; /* header size */ - return size; - } - return 0; -} - -static int consume_tag(struct mad_stream *stream) -{ - /* FIXME: what if the buffer doesn't have the full tag ??? */ - size_t remaining = stream->bufend - stream->next_frame; - size_t tagsize = get_tagsize(stream->this_frame, remaining); - if (tagsize != 0) { - mad_stream_skip(stream, tagsize); - return 0; - } - return -1; -} - -/* Reads the next frame from the file. - Returns true on success or false on failure. - */ -static SDL_bool read_next_frame(MAD_Music *music) -{ - if (music->stream.buffer == NULL || - music->stream.error == MAD_ERROR_BUFLEN) { - size_t read_size; - size_t remaining; - unsigned char *read_start; - - /* There might be some bytes in the buffer left over from last - time. If so, move them down and read more bytes following - them. */ - if (music->stream.next_frame != NULL) { - remaining = music->stream.bufend - music->stream.next_frame; - memmove(music->input_buffer, music->stream.next_frame, remaining); - read_start = music->input_buffer + remaining; - read_size = MAD_INPUT_BUFFER_SIZE - remaining; - - } else { - read_size = MAD_INPUT_BUFFER_SIZE; - read_start = music->input_buffer; - remaining = 0; - } - - /* Now read additional bytes from the input file. */ - read_size = SDL_RWread(music->src, read_start, 1, read_size); - - if (read_size == 0) { - if ((music->status & (MS_input_eof | MS_input_error)) == 0) { - /* FIXME: how to detect error? */ - music->status |= MS_input_eof; - - /* At the end of the file, we must stuff MAD_BUFFER_GUARD - number of 0 bytes. */ - SDL_memset(read_start + read_size, 0, MAD_BUFFER_GUARD); - read_size += MAD_BUFFER_GUARD; - } - } - - /* Now feed those bytes into the libmad stream. */ - mad_stream_buffer(&music->stream, music->input_buffer, - read_size + remaining); - music->stream.error = MAD_ERROR_NONE; - } - - /* Now ask libmad to extract a frame from the data we just put in - its buffer. */ - if (mad_frame_decode(&music->frame, &music->stream)) { - if (MAD_RECOVERABLE(music->stream.error)) { - consume_tag(&music->stream); /* consume any ID3 tags */ - mad_stream_sync(&music->stream); /* to frame seek mode */ - return SDL_FALSE; - - } else if (music->stream.error == MAD_ERROR_BUFLEN) { - return SDL_FALSE; - - } else { - Mix_SetError("mad_frame_decode() failed, corrupt stream?"); - music->status |= MS_decode_error; - return SDL_FALSE; - } - } - - mad_timer_add(&music->next_frame_start, music->frame.header.duration); - - return SDL_TRUE; -} - -/* Scale a MAD sample to 16 bits for output. */ -static Sint16 scale(mad_fixed_t sample) -{ - const int n_bits_to_loose = MAD_F_FRACBITS + 1 - 16; - - /* round */ - sample += (1L << (n_bits_to_loose - 1)); - -#ifdef MUSIC_MP3_MAD_GPL_DITHERING - sample += triangular_dither_noise(n_bits_to_loose + 1); -#endif - - /* clip */ - if (sample >= MAD_F_ONE) - sample = MAD_F_ONE - 1; - else if (sample < -MAD_F_ONE) - sample = -MAD_F_ONE; - - /* quantize */ - return (Sint16)(sample >> n_bits_to_loose); -} - -/* Once the frame has been read, copies its samples into the output buffer. */ -static SDL_bool decode_frame(MAD_Music *music) -{ - struct mad_pcm *pcm; - unsigned int i, nchannels, nsamples; - mad_fixed_t const *left_ch, *right_ch; - Sint16 *buffer, *dst; - int result; - - mad_synth_frame(&music->synth, &music->frame); - pcm = &music->synth.pcm; - - if (!music->audiostream) { - music->audiostream = SDL_NewAudioStream(AUDIO_S16, pcm->channels, pcm->samplerate, music_spec.format, music_spec.channels, music_spec.freq); - if (!music->audiostream) { - return SDL_FALSE; - } - } - - nchannels = pcm->channels; - nsamples = pcm->length; - left_ch = pcm->samples[0]; - right_ch = pcm->samples[1]; - buffer = SDL_stack_alloc(Sint16, nsamples*nchannels); - if (!buffer) { - SDL_OutOfMemory(); - return SDL_FALSE; - } - - dst = buffer; - if (nchannels == 1) { - for (i = nsamples; i--;) { - *dst++ = scale(*left_ch++); - } - } else { - for (i = nsamples; i--;) { - *dst++ = scale(*left_ch++); - *dst++ = scale(*right_ch++); - } - } - - result = SDL_AudioStreamPut(music->audiostream, buffer, (nsamples * nchannels * sizeof(Sint16))); - SDL_stack_free(buffer); - - if (result < 0) { - return SDL_FALSE; - } - return SDL_TRUE; -} - -static int MAD_GetSome(void *context, void *data, int bytes, SDL_bool *done) -{ - MAD_Music *music = (MAD_Music *)context; - int filled; - - if (music->audiostream) { - filled = SDL_AudioStreamGet(music->audiostream, data, bytes); - if (filled != 0) { - return filled; - } - } - - if (!music->play_count) { - /* All done */ - *done = SDL_TRUE; - return 0; - } - - if (read_next_frame(music)) { - if (!decode_frame(music)) { - return -1; - } - } else if (music->status & MS_input_eof) { - int play_count = -1; - if (music->play_count > 0) { - play_count = (music->play_count - 1); - } - if (MAD_Play(music, play_count) < 0) { - return -1; - } - } else if (music->status & MS_decode_error) { - return -1; - } - return 0; -} -static int MAD_GetAudio(void *context, void *data, int bytes) -{ - MAD_Music *music = (MAD_Music *)context; - return music_pcm_getaudio(context, data, bytes, music->volume, MAD_GetSome); -} - -static int MAD_Seek(void *context, double position) -{ - MAD_Music *music = (MAD_Music *)context; - mad_timer_t target; - int int_part; - - int_part = (int)position; - mad_timer_set(&target, int_part, (int)((position - int_part) * 1000000), 1000000); - - if (mad_timer_compare(music->next_frame_start, target) > 0) { - /* In order to seek backwards in a VBR file, we have to rewind and - start again from the beginning. This isn't necessary if the - file happens to be CBR, of course; in that case we could seek - directly to the frame we want. But I leave that little - optimization for the future developer who discovers she really - needs it. */ - mad_timer_reset(&music->next_frame_start); - music->status &= ~MS_error_flags; - - SDL_RWseek(music->src, 0, RW_SEEK_SET); - } - - /* Now we have to skip frames until we come to the right one. - Again, only truly necessary if the file is VBR. */ - while (mad_timer_compare(music->next_frame_start, target) < 0) { - if (!read_next_frame(music)) { - if ((music->status & MS_error_flags) != 0) { - /* Couldn't read a frame; either an error condition or - end-of-file. Stop. */ - return Mix_SetError("Seek position out of range"); - } - } - } - - /* Here we are, at the beginning of the frame that contains the - target time. Ehh, I say that's close enough. If we wanted to, - we could get more precise by decoding the frame now and counting - the appropriate number of samples out of it. */ - return 0; -} - -static void MAD_Delete(void *context) -{ - MAD_Music *music = (MAD_Music *)context; - - mad_stream_finish(&music->stream); - mad_frame_finish(&music->frame); - mad_synth_finish(&music->synth); - - if (music->audiostream) { - SDL_FreeAudioStream(music->audiostream); - } - if (music->freesrc) { - SDL_RWclose(music->src); - } - SDL_free(music); -} - -Mix_MusicInterface Mix_MusicInterface_MAD = -{ - "MAD", - MIX_MUSIC_MAD, - MUS_MP3, - SDL_FALSE, - SDL_FALSE, - - NULL, /* Load */ - NULL, /* Open */ - MAD_CreateFromRW, - NULL, /* CreateFromFile */ - MAD_SetVolume, - MAD_Play, - NULL, /* IsPlaying */ - MAD_GetAudio, - MAD_Seek, - NULL, /* Pause */ - NULL, /* Resume */ - NULL, /* Stop */ - MAD_Delete, - NULL, /* Close */ - NULL, /* Unload */ -}; - -#endif /* MUSIC_MP3_MAD */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_mad.h b/music_mad.h deleted file mode 100644 index b6011ba..0000000 --- a/music_mad.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* This file supports playing MP3 files with libmad */ - -#include "music.h" - -extern Mix_MusicInterface Mix_MusicInterface_MAD; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_mikmod.c b/music_mikmod.c deleted file mode 100644 index 83b8547..0000000 --- a/music_mikmod.c +++ /dev/null @@ -1,488 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef MUSIC_MOD_MIKMOD - -/* This file supports MOD tracker music streams */ - -#include "SDL_loadso.h" - -#include "music_mikmod.h" - -#include "mikmod.h" - - -/* libmikmod >= 3.3.2 constified several funcs */ -#if (LIBMIKMOD_VERSION < 0x030302) -#define MIKMOD3_CONST -#else -#define MIKMOD3_CONST const -#endif - -typedef struct { - int loaded; - void *handle; - - void (*MikMod_Exit)(void); - CHAR* (*MikMod_InfoDriver)(void); - CHAR* (*MikMod_InfoLoader)(void); - int (*MikMod_Init)(MIKMOD3_CONST CHAR*); - void (*MikMod_RegisterAllLoaders)(void); - void (*MikMod_RegisterDriver)(struct MDRIVER*); - int* MikMod_errno; - MIKMOD3_CONST char* (*MikMod_strerror)(int); - void (*MikMod_free)(void*); - BOOL (*Player_Active)(void); - void (*Player_Free)(MODULE*); - MODULE* (*Player_LoadGeneric)(MREADER*,int,BOOL); - void (*Player_SetPosition)(UWORD); - void (*Player_SetVolume)(SWORD); - void (*Player_Start)(MODULE*); - void (*Player_Stop)(void); - ULONG (*VC_WriteBytes)(SBYTE*,ULONG); - struct MDRIVER* drv_nos; - UWORD* md_device; - UWORD* md_mixfreq; - UWORD* md_mode; - UBYTE* md_musicvolume; - UBYTE* md_pansep; - UBYTE* md_reverb; - UBYTE* md_sndfxvolume; - UBYTE* md_volume; -} mikmod_loader; - -static mikmod_loader mikmod = { - 0, NULL -}; - -#ifdef MIKMOD_DYNAMIC -#define FUNCTION_LOADER(FUNC, SIG) \ - mikmod.FUNC = (SIG) SDL_LoadFunction(mikmod.handle, #FUNC); \ - if (mikmod.FUNC == NULL) { SDL_UnloadObject(mikmod.handle); return -1; } -#define VARIABLE_LOADER(NAME, SIG) \ - mikmod.NAME = (SIG) SDL_LoadFunction(mikmod.handle, #NAME); \ - if (mikmod.NAME == NULL) { SDL_UnloadObject(mikmod.handle); return -1; } -#else -#define FUNCTION_LOADER(FUNC, SIG) \ - mikmod.FUNC = FUNC; -#define VARIABLE_LOADER(NAME, SIG) \ - mikmod.NAME = &NAME; -#endif - -static int MIKMOD_Load() -{ - if (mikmod.loaded == 0) { -#ifdef MIKMOD_DYNAMIC - mikmod.handle = SDL_LoadObject(MIKMOD_DYNAMIC); - if (mikmod.handle == NULL) { - return -1; - } -#elif defined(__MACOSX__) - extern void Player_Start(MODULE*) __attribute__((weak_import)); - if (Player_Start == NULL) - { - /* Missing weakly linked framework */ - Mix_SetError("Missing mikmod.framework"); - return -1; - } -#endif - FUNCTION_LOADER(MikMod_Exit, void (*)(void)) - FUNCTION_LOADER(MikMod_InfoDriver, CHAR* (*)(void)) - FUNCTION_LOADER(MikMod_InfoLoader, CHAR* (*)(void)) - FUNCTION_LOADER(MikMod_Init, int (*)(MIKMOD3_CONST CHAR*)) - FUNCTION_LOADER(MikMod_RegisterAllLoaders, void (*)(void)) - FUNCTION_LOADER(MikMod_RegisterDriver, void (*)(struct MDRIVER*)) - VARIABLE_LOADER(MikMod_errno, int*) - FUNCTION_LOADER(MikMod_strerror, MIKMOD3_CONST char* (*)(int)) -#ifdef MIKMOD_DYNAMIC - mikmod.MikMod_free = (void (*)(void*)) SDL_LoadFunction(mikmod.handle, "MikMod_free"); - if (!mikmod.MikMod_free) { - /* libmikmod 3.1 and earlier doesn't have it */ - mikmod.MikMod_free = free; - } -#else -#if (LIBMIKMOD_VERSION < 0x030200) || !defined(DMODE_NOISEREDUCTION) - /* libmikmod 3.2.0-beta2 or older */ - mikmod.MikMod_free = free; -#else - mikmod.MikMod_free = MikMod_free; -#endif -#endif /* MIKMOD_DYNAMIC */ - FUNCTION_LOADER(Player_Active, BOOL (*)(void)) - FUNCTION_LOADER(Player_Free, void (*)(MODULE*)) - FUNCTION_LOADER(Player_LoadGeneric, MODULE* (*)(MREADER*,int,BOOL)) - FUNCTION_LOADER(Player_SetPosition, void (*)(UWORD)) - FUNCTION_LOADER(Player_SetVolume, void (*)(SWORD)) - FUNCTION_LOADER(Player_Start, void (*)(MODULE*)) - FUNCTION_LOADER(Player_Stop, void (*)(void)) - FUNCTION_LOADER(VC_WriteBytes, ULONG (*)(SBYTE*,ULONG)) - VARIABLE_LOADER(drv_nos, MDRIVER*) - VARIABLE_LOADER(md_device, UWORD*) - VARIABLE_LOADER(md_mixfreq, UWORD*) - VARIABLE_LOADER(md_mode, UWORD*) - VARIABLE_LOADER(md_musicvolume, UBYTE*) - VARIABLE_LOADER(md_pansep, UBYTE*) - VARIABLE_LOADER(md_reverb, UBYTE*) - VARIABLE_LOADER(md_sndfxvolume, UBYTE*) - VARIABLE_LOADER(md_volume, UBYTE*) - } - ++mikmod.loaded; - - return 0; -} - -static void MIKMOD_Unload() -{ - if (mikmod.loaded == 0) { - return; - } - if (mikmod.loaded == 1) { -#ifdef MIKMOD_DYNAMIC - SDL_UnloadObject(mikmod.handle); -#endif - } - --mikmod.loaded; -} - - -typedef struct -{ - int play_count; - int volume; - MODULE *module; - SDL_AudioStream *stream; - SBYTE *buffer; - ULONG buffer_size; -} MIKMOD_Music; - - -static int MIKMOD_Seek(void *context, double position); -static void MIKMOD_Delete(void *context); - -/* Initialize the MOD player, with the given mixer settings - This function returns 0, or -1 if there was an error. - */ -static int MIKMOD_Open(const SDL_AudioSpec *spec) -{ - CHAR *list; - - /* Set the MikMod music format */ - if (spec->format == AUDIO_S8 || spec->format == AUDIO_U8) { - /* MIKMOD audio format is AUDIO_U8 */ - *mikmod.md_mode = 0; - } else { - /* MIKMOD audio format is AUDIO_S16SYS */ - *mikmod.md_mode = DMODE_16BITS; - } - if (spec->channels > 1) { - *mikmod.md_mode |= DMODE_STEREO; - } - *mikmod.md_mixfreq = spec->freq; - *mikmod.md_device = 0; - *mikmod.md_volume = 96; - *mikmod.md_musicvolume = 128; - *mikmod.md_sndfxvolume = 128; - *mikmod.md_pansep = 128; - *mikmod.md_reverb = 0; - *mikmod.md_mode |= DMODE_HQMIXER|DMODE_SOFT_MUSIC|DMODE_SURROUND; - - list = mikmod.MikMod_InfoDriver(); - if (list) { - mikmod.MikMod_free(list); - } else { - mikmod.MikMod_RegisterDriver(mikmod.drv_nos); - } - - list = mikmod.MikMod_InfoLoader(); - if (list) { - mikmod.MikMod_free(list); - } else { - mikmod.MikMod_RegisterAllLoaders(); - } - - if (mikmod.MikMod_Init(NULL)) { - Mix_SetError("%s", mikmod.MikMod_strerror(*mikmod.MikMod_errno)); - return -1; - } - return 0; -} - -/* Uninitialize the music players */ -static void MIKMOD_Close(void) -{ - if (mikmod.MikMod_Exit) { - mikmod.MikMod_Exit(); - } -} - -typedef struct -{ - MREADER mr; - /* struct MREADER in libmikmod <= 3.2.0-beta2 - * doesn't have iobase members. adding them here - * so that if we compile against 3.2.0-beta2, we - * can still run OK against 3.2.0b3 and newer. */ - long iobase, prev_iobase; - Sint64 offset; - Sint64 eof; - SDL_RWops *src; -} LMM_MREADER; - -int LMM_Seek(struct MREADER *mr,long to,int dir) -{ - Sint64 offset = to; - LMM_MREADER* lmmmr = (LMM_MREADER*)mr; - if (dir == SEEK_SET) { - offset += lmmmr->offset; - if (offset < lmmmr->offset) - return -1; - } - return (SDL_RWseek(lmmmr->src, offset, dir) < lmmmr->offset)? -1 : 0; -} -long LMM_Tell(struct MREADER *mr) -{ - LMM_MREADER* lmmmr = (LMM_MREADER*)mr; - return (long)(SDL_RWtell(lmmmr->src) - lmmmr->offset); -} -BOOL LMM_Read(struct MREADER *mr,void *buf,size_t sz) -{ - LMM_MREADER* lmmmr = (LMM_MREADER*)mr; - return SDL_RWread(lmmmr->src, buf, sz, 1); -} -int LMM_Get(struct MREADER *mr) -{ - unsigned char c; - LMM_MREADER* lmmmr = (LMM_MREADER*)mr; - if (SDL_RWread(lmmmr->src, &c, 1, 1)) { - return c; - } - return EOF; -} -BOOL LMM_Eof(struct MREADER *mr) -{ - Sint64 offset; - LMM_MREADER* lmmmr = (LMM_MREADER*)mr; - offset = LMM_Tell(mr); - return offset >= lmmmr->eof; -} -MODULE *MikMod_LoadSongRW(SDL_RWops *src, int maxchan) -{ - LMM_MREADER lmmmr = { - { LMM_Seek, LMM_Tell, LMM_Read, LMM_Get, LMM_Eof }, - 0, - 0, - 0 - }; - lmmmr.offset = SDL_RWtell(src); - SDL_RWseek(src, 0, RW_SEEK_END); - lmmmr.eof = SDL_RWtell(src); - SDL_RWseek(src, lmmmr.offset, RW_SEEK_SET); - lmmmr.src = src; - return mikmod.Player_LoadGeneric((MREADER*)&lmmmr, maxchan, 0); -} - -/* Load a MOD stream from an SDL_RWops object */ -void *MIKMOD_CreateFromRW(SDL_RWops *src, int freesrc) -{ - MIKMOD_Music *music; - SDL_AudioFormat format; - Uint8 channels; - - music = (MIKMOD_Music *)SDL_calloc(1, sizeof(*music)); - if (!music) { - SDL_OutOfMemory(); - return NULL; - } - music->volume = MIX_MAX_VOLUME; - - music->module = MikMod_LoadSongRW(src, 64); - if (!music->module) { - Mix_SetError("%s", mikmod.MikMod_strerror(*mikmod.MikMod_errno)); - MIKMOD_Delete(music); - return NULL; - } - - /* Allow implicit looping, disable fade out and other flags. */ - music->module->extspd = 1; - music->module->panflag = 1; - music->module->wrap = 0; - music->module->loop = 1; - music->module->fadeout = 0; - - if ((*mikmod.md_mode & DMODE_16BITS) == DMODE_16BITS) { - format = AUDIO_S16SYS; - } else { - format = AUDIO_U8; - } - if ((*mikmod.md_mode & DMODE_STEREO) == DMODE_STEREO) { - channels = 2; - } else { - channels = 1; - } - music->stream = SDL_NewAudioStream(format, channels, *mikmod.md_mixfreq, - music_spec.format, music_spec.channels, music_spec.freq); - if (!music->stream) { - MIKMOD_Delete(music); - return NULL; - } - - music->buffer_size = music_spec.samples * (SDL_AUDIO_BITSIZE(format) / 8) * channels; - music->buffer = (SBYTE *)SDL_malloc(music->buffer_size); - if (!music->buffer) { - SDL_OutOfMemory(); - MIKMOD_Delete(music); - return NULL; - } - - if (freesrc) { - SDL_RWclose(src); - } - return music; -} - -/* Set the volume for a MOD stream */ -static void MIKMOD_SetVolume(void *context, int volume) -{ - MIKMOD_Music *music = (MIKMOD_Music *)context; - music->volume = volume; - mikmod.Player_SetVolume((SWORD)volume); -} - -/* Start playback of a given MOD stream */ -static int MIKMOD_Play(void *context, int play_count) -{ - MIKMOD_Music *music = (MIKMOD_Music *)context; - music->play_count = play_count; - music->module->initvolume = music->volume; - mikmod.Player_Start(music->module); - return MIKMOD_Seek(music, 0.0); -} - -/* Return non-zero if a stream is currently playing */ -static SDL_bool MIKMOD_IsPlaying(void *context) -{ - return mikmod.Player_Active() ? SDL_TRUE : SDL_FALSE; -} - -/* Play some of a stream previously started with MOD_play() */ -static int MIKMOD_GetSome(void *context, void *data, int bytes, SDL_bool *done) -{ - MIKMOD_Music *music = (MIKMOD_Music *)context; - int filled; - - filled = SDL_AudioStreamGet(music->stream, data, bytes); - if (filled != 0) { - return filled; - } - - if (!music->play_count) { - /* All done */ - *done = SDL_TRUE; - return 0; - } - - /* This never fails, and always writes a full buffer */ - mikmod.VC_WriteBytes(music->buffer, music->buffer_size); - - if (SDL_AudioStreamPut(music->stream, music->buffer, music->buffer_size) < 0) { - return -1; - } - - /* Check to see if we're done now */ - if (!mikmod.Player_Active()) { - if (music->play_count == 1) { - music->play_count = 0; - SDL_AudioStreamFlush(music->stream); - } else { - int play_count = -1; - if (music->play_count > 0) { - play_count = (music->play_count - 1); - } - if (MIKMOD_Play(music, play_count) < 0) { - return -1; - } - } - } - return 0; -} -static int MIKMOD_GetAudio(void *context, void *data, int bytes) -{ - return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, MIKMOD_GetSome); -} - -/* Jump (seek) to a given position (time is in seconds) */ -static int MIKMOD_Seek(void *context, double position) -{ - mikmod.Player_SetPosition((UWORD)position); - return 0; -} - -/* Stop playback of a stream previously started with MOD_play() */ -static void MIKMOD_Stop(void *context) -{ - mikmod.Player_Stop(); -} - -/* Close the given MOD stream */ -static void MIKMOD_Delete(void *context) -{ - MIKMOD_Music *music = (MIKMOD_Music *)context; - - if (music->module) { - mikmod.Player_Free(music->module); - } - if (music->stream) { - SDL_FreeAudioStream(music->stream); - } - if (music->buffer) { - SDL_free(music->buffer); - } - SDL_free(music); -} - -Mix_MusicInterface Mix_MusicInterface_MIKMOD = -{ - "MIKMOD", - MIX_MUSIC_MIKMOD, - MUS_MOD, - SDL_FALSE, - SDL_FALSE, - - MIKMOD_Load, - MIKMOD_Open, - MIKMOD_CreateFromRW, - NULL, /* CreateFromFile */ - MIKMOD_SetVolume, - MIKMOD_Play, - MIKMOD_IsPlaying, - MIKMOD_GetAudio, - MIKMOD_Seek, - NULL, /* Pause */ - NULL, /* Resume */ - MIKMOD_Stop, - MIKMOD_Delete, - MIKMOD_Close, - MIKMOD_Unload, -}; - -#endif /* MUSIC_MOD_MIKMOD */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_mikmod.h b/music_mikmod.h deleted file mode 100644 index 436fffc..0000000 --- a/music_mikmod.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* This file supports playing MOD files with libmikmod */ - -#include "music.h" - -extern Mix_MusicInterface Mix_MusicInterface_MIKMOD; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_modplug.c b/music_modplug.c deleted file mode 100644 index e187943..0000000 --- a/music_modplug.c +++ /dev/null @@ -1,310 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef MUSIC_MOD_MODPLUG - -#include "SDL_loadso.h" - -#include "music_modplug.h" - -#ifdef MODPLUG_HEADER -#include MODPLUG_HEADER -#else -#include -#endif - -typedef struct { - int loaded; - void *handle; - - ModPlugFile* (*ModPlug_Load)(const void* data, int size); - void (*ModPlug_Unload)(ModPlugFile* file); - int (*ModPlug_Read)(ModPlugFile* file, void* buffer, int size); - void (*ModPlug_Seek)(ModPlugFile* file, int millisecond); - void (*ModPlug_GetSettings)(ModPlug_Settings* settings); - void (*ModPlug_SetSettings)(const ModPlug_Settings* settings); - void (*ModPlug_SetMasterVolume)(ModPlugFile* file,unsigned int cvol) ; -} modplug_loader; - -static modplug_loader modplug = { - 0, NULL -}; - - -static ModPlug_Settings settings; - -#ifdef MODPLUG_DYNAMIC -#define FUNCTION_LOADER(FUNC, SIG) \ - modplug.FUNC = (SIG) SDL_LoadFunction(modplug.handle, #FUNC); \ - if (modplug.FUNC == NULL) { SDL_UnloadObject(modplug.handle); return -1; } -#else -#define FUNCTION_LOADER(FUNC, SIG) \ - modplug.FUNC = FUNC; -#endif - -static int MODPLUG_Load(void) -{ - if (modplug.loaded == 0) { -#ifdef MODPLUG_DYNAMIC - modplug.handle = SDL_LoadObject(MODPLUG_DYNAMIC); - if (modplug.handle == NULL) { - return -1; - } -#elif defined(__MACOSX__) - extern ModPlugFile* ModPlug_Load(const void* data, int size) __attribute__((weak_import)); - if (ModPlug_Load == NULL) - { - /* Missing weakly linked framework */ - Mix_SetError("Missing modplug.framework"); - return -1; - } -#endif - FUNCTION_LOADER(ModPlug_Load, ModPlugFile* (*)(const void* data, int size)) - FUNCTION_LOADER(ModPlug_Unload, void (*)(ModPlugFile* file)) - FUNCTION_LOADER(ModPlug_Read, int (*)(ModPlugFile* file, void* buffer, int size)) - FUNCTION_LOADER(ModPlug_Seek, void (*)(ModPlugFile* file, int millisecond)) - FUNCTION_LOADER(ModPlug_GetSettings, void (*)(ModPlug_Settings* settings)) - FUNCTION_LOADER(ModPlug_SetSettings, void (*)(const ModPlug_Settings* settings)) - FUNCTION_LOADER(ModPlug_SetMasterVolume, void (*)(ModPlugFile* file,unsigned int cvol)) - } - ++modplug.loaded; - - return 0; -} - -static void MODPLUG_Unload(void) -{ - if (modplug.loaded == 0) { - return; - } - if (modplug.loaded == 1) { -#ifdef MODPLUG_DYNAMIC - SDL_UnloadObject(modplug.handle); -#endif - } - --modplug.loaded; -} - - -typedef struct -{ - int play_count; - ModPlugFile *file; - SDL_AudioStream *stream; - void *buffer; - int buffer_size; -} MODPLUG_Music; - - -static int MODPLUG_Seek(void *context, double position); -static void MODPLUG_Delete(void *context); - -static int MODPLUG_Open(const SDL_AudioSpec *spec) -{ - /* ModPlug supports U8 or S16 audio output */ - modplug.ModPlug_GetSettings(&settings); - settings.mFlags = MODPLUG_ENABLE_OVERSAMPLING; - if (spec->channels == 1) { - settings.mChannels = 1; - } else { - settings.mChannels = 2; - } - if (SDL_AUDIO_BITSIZE(spec->format) == 8) { - settings.mBits = 8; - } else { - settings.mBits = 16; - } - if (spec->freq >= 44100) { - settings.mFrequency = 44100; - } else if (spec->freq >= 22050) { - settings.mFrequency = 22050; - } else { - settings.mFrequency = 11025; - } - settings.mResamplingMode = MODPLUG_RESAMPLE_FIR; - settings.mReverbDepth = 0; - settings.mReverbDelay = 100; - settings.mBassAmount = 0; - settings.mBassRange = 50; - settings.mSurroundDepth = 0; - settings.mSurroundDelay = 10; - settings.mLoopCount = 0; - modplug.ModPlug_SetSettings(&settings); - return 0; -} - -/* Load a modplug stream from an SDL_RWops object */ -void *MODPLUG_CreateFromRW(SDL_RWops *src, int freesrc) -{ - MODPLUG_Music *music; - void *buffer; - size_t size; - - music = (MODPLUG_Music *)SDL_calloc(1, sizeof(*music)); - if (!music) { - SDL_OutOfMemory(); - return NULL; - } - - music->stream = SDL_NewAudioStream((settings.mBits == 8) ? AUDIO_U8 : AUDIO_S16SYS, settings.mChannels, settings.mFrequency, - music_spec.format, music_spec.channels, music_spec.freq); - if (!music->stream) { - MODPLUG_Delete(music); - return NULL; - } - - music->buffer_size = music_spec.samples * (settings.mBits / 8) * settings.mChannels; - music->buffer = SDL_malloc(music->buffer_size); - if (!music->buffer) { - MODPLUG_Delete(music); - return NULL; - } - - buffer = SDL_LoadFile_RW(src, &size, SDL_FALSE); - if (buffer) { - music->file = modplug.ModPlug_Load(buffer, (int)size); - if (!music->file) { - Mix_SetError("ModPlug_Load failed"); - } - SDL_free(buffer); - } - - if (!music->file) { - MODPLUG_Delete(music); - return NULL; - } - - if (freesrc) { - SDL_RWclose(src); - } - return music; -} - -/* Set the volume for a modplug stream */ -static void MODPLUG_SetVolume(void *context, int volume) -{ - MODPLUG_Music *music = (MODPLUG_Music *)context; - modplug.ModPlug_SetMasterVolume(music->file, volume*4); -} - -/* Start playback of a given modplug stream */ -static int MODPLUG_Play(void *context, int play_count) -{ - MODPLUG_Music *music = (MODPLUG_Music *)context; - music->play_count = play_count; - return MODPLUG_Seek(music, 0.0); -} - -/* Play some of a stream previously started with modplug_play() */ -static int MODPLUG_GetSome(void *context, void *data, int bytes, SDL_bool *done) -{ - MODPLUG_Music *music = (MODPLUG_Music *)context; - int filled, amount; - - filled = SDL_AudioStreamGet(music->stream, data, bytes); - if (filled != 0) { - return filled; - } - - if (!music->play_count) { - /* All done */ - *done = SDL_TRUE; - return 0; - } - - amount = modplug.ModPlug_Read(music->file, music->buffer, music->buffer_size); - if (amount > 0) { - if (SDL_AudioStreamPut(music->stream, music->buffer, amount) < 0) { - return -1; - } - } else { - if (music->play_count == 1) { - music->play_count = 0; - SDL_AudioStreamFlush(music->stream); - } else { - int play_count = -1; - if (music->play_count > 0) { - play_count = (music->play_count - 1); - } - if (MODPLUG_Play(music, play_count) < 0) { - return -1; - } - } - } - return 0; -} -static int MODPLUG_GetAudio(void *context, void *data, int bytes) -{ - return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, MODPLUG_GetSome); -} - -/* Jump (seek) to a given position */ -static int MODPLUG_Seek(void *context, double position) -{ - MODPLUG_Music *music = (MODPLUG_Music *)context; - modplug.ModPlug_Seek(music->file, (int)(position*1000)); - return 0; -} - -/* Close the given modplug stream */ -static void MODPLUG_Delete(void *context) -{ - MODPLUG_Music *music = (MODPLUG_Music *)context; - if (music->file) { - modplug.ModPlug_Unload(music->file); - } - if (music->stream) { - SDL_FreeAudioStream(music->stream); - } - if (music->buffer) { - SDL_free(music->buffer); - } - SDL_free(music); -} - -Mix_MusicInterface Mix_MusicInterface_MODPLUG = -{ - "MODPLUG", - MIX_MUSIC_MODPLUG, - MUS_MOD, - SDL_FALSE, - SDL_FALSE, - - MODPLUG_Load, - MODPLUG_Open, - MODPLUG_CreateFromRW, - NULL, /* CreateFromFile */ - MODPLUG_SetVolume, - MODPLUG_Play, - NULL, /* IsPlaying */ - MODPLUG_GetAudio, - MODPLUG_Seek, - NULL, /* Pause */ - NULL, /* Resume */ - NULL, /* Stop */ - MODPLUG_Delete, - NULL, /* Close */ - MODPLUG_Unload, -}; - -#endif /* MUSIC_MOD_MODPLUG */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_modplug.h b/music_modplug.h deleted file mode 100644 index ca0553e..0000000 --- a/music_modplug.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* This file supports playing MOD files with libmodplug */ - -#include "music.h" - -extern Mix_MusicInterface Mix_MusicInterface_MODPLUG; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_mpg123.c b/music_mpg123.c deleted file mode 100644 index cd151b9..0000000 --- a/music_mpg123.c +++ /dev/null @@ -1,431 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* This file supports playing MP3 files with mpg123 */ - -#ifdef MUSIC_MP3_MPG123 - -#include // For SEEK_SET - -#include "SDL_assert.h" -#include "SDL_loadso.h" - -#include "music_mpg123.h" - -#include - - -typedef struct { - int loaded; - void *handle; - - int (*mpg123_close)(mpg123_handle *mh); - void (*mpg123_delete)(mpg123_handle *mh); - void (*mpg123_exit)(void); - int (*mpg123_format)( mpg123_handle *mh, long rate, int channels, int encodings ); - int (*mpg123_format_none)(mpg123_handle *mh); - int (*mpg123_getformat)( mpg123_handle *mh, long *rate, int *channels, int *encoding ); - int (*mpg123_init)(void); - mpg123_handle *(*mpg123_new)(const char* decoder, int *error); - int (*mpg123_open_handle)(mpg123_handle *mh, void *iohandle); - const char* (*mpg123_plain_strerror)(int errcode); - void (*mpg123_rates)(const long **list, size_t *number); - int (*mpg123_read)(mpg123_handle *mh, unsigned char *outmemory, size_t outmemsize, size_t *done ); - int (*mpg123_replace_reader_handle)( mpg123_handle *mh, ssize_t (*r_read) (void *, void *, size_t), off_t (*r_lseek)(void *, off_t, int), void (*cleanup)(void*) ); - off_t (*mpg123_seek)( mpg123_handle *mh, off_t sampleoff, int whence ); - const char* (*mpg123_strerror)(mpg123_handle *mh); -} mpg123_loader; - -static mpg123_loader mpg123 = { - 0, NULL -}; - -#ifdef MPG123_DYNAMIC -#define FUNCTION_LOADER(FUNC, SIG) \ - mpg123.FUNC = (SIG) SDL_LoadFunction(mpg123.handle, #FUNC); \ - if (mpg123.FUNC == NULL) { SDL_UnloadObject(mpg123.handle); return -1; } -#else -#define FUNCTION_LOADER(FUNC, SIG) \ - mpg123.FUNC = FUNC; -#endif - -static int MPG123_Load(void) -{ - if (mpg123.loaded == 0) { -#ifdef MPG123_DYNAMIC - mpg123.handle = SDL_LoadObject(MPG123_DYNAMIC); - if (mpg123.handle == NULL) { - return -1; - } -#elif defined(__MACOSX__) - extern int mpg123_init(void) __attribute__((weak_import)); - if (mpg123_init == NULL) - { - /* Missing weakly linked framework */ - Mix_SetError("Missing mpg123.framework"); - return -1; - } -#endif - FUNCTION_LOADER(mpg123_close, int (*)(mpg123_handle *mh)) - FUNCTION_LOADER(mpg123_delete, void (*)(mpg123_handle *mh)) - FUNCTION_LOADER(mpg123_exit, void (*)(void)) - FUNCTION_LOADER(mpg123_format, int (*)( mpg123_handle *mh, long rate, int channels, int encodings )) - FUNCTION_LOADER(mpg123_format_none, int (*)(mpg123_handle *mh)) - FUNCTION_LOADER(mpg123_getformat, int (*)( mpg123_handle *mh, long *rate, int *channels, int *encoding )) - FUNCTION_LOADER(mpg123_init, int (*)(void)) - FUNCTION_LOADER(mpg123_new, mpg123_handle *(*)(const char* decoder, int *error)) - FUNCTION_LOADER(mpg123_open_handle, int (*)(mpg123_handle *mh, void *iohandle)) - FUNCTION_LOADER(mpg123_plain_strerror, const char* (*)(int errcode)) - FUNCTION_LOADER(mpg123_rates, void (*)(const long **list, size_t *number)); - FUNCTION_LOADER(mpg123_read, int (*)(mpg123_handle *mh, unsigned char *outmemory, size_t outmemsize, size_t *done )) - FUNCTION_LOADER(mpg123_replace_reader_handle, int (*)( mpg123_handle *mh, ssize_t (*r_read) (void *, void *, size_t), off_t (*r_lseek)(void *, off_t, int), void (*cleanup)(void*) )) - FUNCTION_LOADER(mpg123_seek, off_t (*)( mpg123_handle *mh, off_t sampleoff, int whence )) - FUNCTION_LOADER(mpg123_strerror, const char* (*)(mpg123_handle *mh)) - } - ++mpg123.loaded; - - return 0; -} - -static void MPG123_Unload(void) -{ - if (mpg123.loaded == 0) { - return; - } - if (mpg123.loaded == 1) { -#ifdef MPG123_DYNAMIC - SDL_UnloadObject(mpg123.handle); -#endif - } - --mpg123.loaded; -} - - -typedef struct -{ - int play_count; - SDL_RWops* src; - int freesrc; - int volume; - - mpg123_handle* handle; - SDL_AudioStream *stream; - unsigned char *buffer; - size_t buffer_size; -} MPG123_Music; - - -static int MPG123_Seek(void *context, double secs); -static void MPG123_Delete(void *context); - -static int mpg123_format_to_sdl(int fmt) -{ - switch (fmt) - { - case MPG123_ENC_SIGNED_8: return AUDIO_S8; - case MPG123_ENC_UNSIGNED_8: return AUDIO_U8; - case MPG123_ENC_SIGNED_16: return AUDIO_S16SYS; - case MPG123_ENC_UNSIGNED_16: return AUDIO_U16SYS; - case MPG123_ENC_SIGNED_32: return AUDIO_S32SYS; - case MPG123_ENC_FLOAT_32: return AUDIO_F32SYS; - default: return -1; - } -} - -/* -static const char *mpg123_format_str(int fmt) -{ - switch (fmt) - { -#define f(x) case x: return #x; - f(MPG123_ENC_UNSIGNED_8) - f(MPG123_ENC_UNSIGNED_16) - f(MPG123_ENC_SIGNED_8) - f(MPG123_ENC_SIGNED_16) - f(MPG123_ENC_SIGNED_32) - f(MPG123_ENC_FLOAT_32) -#undef f - } - return "unknown"; -} -*/ - -static char const* mpg_err(mpg123_handle* mpg, int result) -{ - char const* err = "unknown error"; - - if (mpg && result == MPG123_ERR) { - err = mpg123.mpg123_strerror(mpg); - } else { - err = mpg123.mpg123_plain_strerror(result); - } - return err; -} - -/* we're gonna override mpg123's I/O with these wrappers for RWops */ -static ssize_t rwops_read(void* p, void* dst, size_t n) -{ - return (ssize_t)SDL_RWread((SDL_RWops*)p, dst, 1, n); -} - -static off_t rwops_seek(void* p, off_t offset, int whence) -{ - return (off_t)SDL_RWseek((SDL_RWops*)p, (Sint64)offset, whence); -} - -static void rwops_cleanup(void* p) -{ - (void)p; - /* do nothing, we will free the file later */ -} - - -static int MPG123_Open(const SDL_AudioSpec *spec) -{ - if (mpg123.mpg123_init() != MPG123_OK) { - Mix_SetError("mpg123_init() failed"); - return -1; - } - return 0; -} - -static void *MPG123_CreateFromRW(SDL_RWops *src, int freesrc) -{ - MPG123_Music *music; - int result; - const long *rates; - size_t i, num_rates; - - music = (MPG123_Music*)SDL_calloc(1, sizeof(*music)); - if (!music) { - return NULL; - } - music->src = src; - music->volume = MIX_MAX_VOLUME; - - /* Just assume 16-bit 2 channel audio for now */ - music->buffer_size = music_spec.samples * sizeof(Sint16) * 2; - music->buffer = (unsigned char *)SDL_malloc(music->buffer_size); - if (!music->buffer) { - MPG123_Delete(music); - SDL_OutOfMemory(); - return NULL; - } - - music->handle = mpg123.mpg123_new(0, &result); - if (result != MPG123_OK) { - MPG123_Delete(music); - Mix_SetError("mpg123_new failed"); - return NULL; - } - - result = mpg123.mpg123_replace_reader_handle( - music->handle, - rwops_read, rwops_seek, rwops_cleanup - ); - if (result != MPG123_OK) { - MPG123_Delete(music); - Mix_SetError("mpg123_replace_reader_handle: %s", mpg_err(music->handle, result)); - return NULL; - } - - result = mpg123.mpg123_format_none(music->handle); - if (result != MPG123_OK) { - MPG123_Delete(music); - Mix_SetError("mpg123_format_none: %s", mpg_err(music->handle, result)); - return NULL; - } - - mpg123.mpg123_rates(&rates, &num_rates); - for (i = 0; i < num_rates; ++i) { - const int channels = (MPG123_MONO|MPG123_STEREO); - const int formats = (MPG123_ENC_SIGNED_8 | - MPG123_ENC_UNSIGNED_8 | - MPG123_ENC_SIGNED_16 | - MPG123_ENC_UNSIGNED_16 | - MPG123_ENC_SIGNED_32 | - MPG123_ENC_FLOAT_32); - - mpg123.mpg123_format(music->handle, rates[i], channels, formats); - } - - result = mpg123.mpg123_open_handle(music->handle, music->src); - if (result != MPG123_OK) { - MPG123_Delete(music); - Mix_SetError("mpg123_open_handle: %s", mpg_err(music->handle, result)); - return NULL; - } - - music->freesrc = freesrc; - return music; -} - -static void MPG123_SetVolume(void *context, int volume) -{ - MPG123_Music *music = (MPG123_Music *)context; - music->volume = volume; -} - -static int MPG123_Play(void *context, int play_count) -{ - MPG123_Music *music = (MPG123_Music *)context; - music->play_count = play_count; - return MPG123_Seek(music, 0.0); -} - -/* read some mp3 stream data and convert it for output */ -static int MPG123_GetSome(void *context, void *data, int bytes, SDL_bool *done) -{ - MPG123_Music *music = (MPG123_Music *)context; - int filled, result; - size_t amount; - long rate; - int channels, encoding, format; - - if (music->stream) { - filled = SDL_AudioStreamGet(music->stream, data, bytes); - if (filled != 0) { - return filled; - } - } - - if (!music->play_count) { - /* All done */ - *done = SDL_TRUE; - return 0; - } - - result = mpg123.mpg123_read(music->handle, music->buffer, music->buffer_size, &amount); - switch (result) { - case MPG123_OK: - if (SDL_AudioStreamPut(music->stream, music->buffer, (int)amount) < 0) { - return -1; - } - break; - - case MPG123_NEW_FORMAT: - result = mpg123.mpg123_getformat(music->handle, &rate, &channels, &encoding); - if (result != MPG123_OK) { - Mix_SetError("mpg123_getformat: %s", mpg_err(music->handle, result)); - return -1; - } -/*printf("MPG123 format: %s, channels = %d, rate = %ld\n", mpg123_format_str(encoding), channels, rate);*/ - - format = mpg123_format_to_sdl(encoding); - SDL_assert(format != -1); - - music->stream = SDL_NewAudioStream(format, channels, (int)rate, - music_spec.format, music_spec.channels, music_spec.freq); - if (!music->stream) { - return -1; - } - break; - - case MPG123_DONE: - if (music->play_count == 1) { - music->play_count = 0; - SDL_AudioStreamFlush(music->stream); - } else { - int play_count = -1; - if (music->play_count > 0) { - play_count = (music->play_count - 1); - } - if (MPG123_Play(music, play_count) < 0) { - return -1; - } - } - break; - default: - Mix_SetError("mpg123_read: %s", mpg_err(music->handle, result)); - return -1; - } - return 0; -} -static int MPG123_GetAudio(void *context, void *data, int bytes) -{ - MPG123_Music *music = (MPG123_Music *)context; - return music_pcm_getaudio(context, data, bytes, music->volume, MPG123_GetSome); -} - -static int MPG123_Seek(void *context, double secs) -{ - MPG123_Music *music = (MPG123_Music *)context; - off_t offset = (off_t)(music_spec.freq * secs); - - if ((offset = mpg123.mpg123_seek(music->handle, offset, SEEK_SET)) < 0) { - return Mix_SetError("mpg123_seek: %s", mpg_err(music->handle, (int)-offset)); - } - return 0; -} - -static void MPG123_Delete(void *context) -{ - MPG123_Music *music = (MPG123_Music *)context; - - if (music->handle) { - mpg123.mpg123_close(music->handle); - mpg123.mpg123_delete(music->handle); - } - if (music->stream) { - SDL_FreeAudioStream(music->stream); - } - if (music->buffer) { - SDL_free(music->buffer); - } - if (music->freesrc) { - SDL_RWclose(music->src); - } - SDL_free(music); -} - -static void MPG123_Close(void) -{ - mpg123.mpg123_exit(); -} - -Mix_MusicInterface Mix_MusicInterface_MPG123 = -{ - "MPG123", - MIX_MUSIC_MPG123, - MUS_MP3, - SDL_FALSE, - SDL_FALSE, - - MPG123_Load, - MPG123_Open, - MPG123_CreateFromRW, - NULL, /* CreateFromFile */ - MPG123_SetVolume, - MPG123_Play, - NULL, /* IsPlaying */ - MPG123_GetAudio, - MPG123_Seek, - NULL, /* Pause */ - NULL, /* Resume */ - NULL, /* Stop */ - MPG123_Delete, - MPG123_Close, - MPG123_Unload -}; - -#endif /* MUSIC_MP3_MPG123 */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_mpg123.h b/music_mpg123.h deleted file mode 100644 index 9c30257..0000000 --- a/music_mpg123.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* This file supports playing MP3 files with mpg123 */ - -#include "music.h" - -extern Mix_MusicInterface Mix_MusicInterface_MPG123; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_nativemidi.c b/music_nativemidi.c deleted file mode 100644 index d9a69eb..0000000 --- a/music_nativemidi.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef MUSIC_MID_NATIVE - -/* This file supports playing MIDI files with OS APIs */ - -#include "music_nativemidi.h" -#include "native_midi/native_midi.h" - - -static void *NATIVEMIDI_CreateFromRW(SDL_RWops *src, int freesrc) -{ - NativeMidiSong *music = native_midi_loadsong_RW(src, freesrc); - if (!music) { - Mix_SetError("%s", native_midi_error()); - } - return music; -} - -static int NATIVEMIDI_Play(void *context, int play_count) -{ - NativeMidiSong *music = (NativeMidiSong *)context; - int loops = play_count; - if (loops > 0) { - --loops; - } - native_midi_start(music, loops); - return 0; -} - -static void NATIVEMIDI_SetVolume(void *context, int volume) -{ - native_midi_setvolume(volume); -} - -static SDL_bool NATIVEMIDI_IsPlaying(void *context) -{ - return native_midi_active() ? SDL_TRUE : SDL_FALSE; -} - -static void NATIVEMIDI_Pause(void *context) -{ - native_midi_pause(); -} - -static void NATIVEMIDI_Resume(void *context) -{ - native_midi_resume(); -} - -static void NATIVEMIDI_Stop(void *context) -{ - native_midi_stop(); -} - -static void NATIVEMIDI_Delete(void *context) -{ - NativeMidiSong *music = (NativeMidiSong *)context; - native_midi_freesong(music); -} - -Mix_MusicInterface Mix_MusicInterface_NATIVEMIDI = -{ - "NATIVEMIDI", - MIX_MUSIC_NATIVEMIDI, - MUS_MID, - SDL_FALSE, - SDL_FALSE, - - NULL, /* Load */ - NULL, /* Open */ - NATIVEMIDI_CreateFromRW, - NULL, /* CreateFromFile */ - NATIVEMIDI_SetVolume, - NATIVEMIDI_Play, - NATIVEMIDI_IsPlaying, - NULL, /* GetAudio */ - NULL, /* Seek */ - NATIVEMIDI_Pause, - NATIVEMIDI_Resume, - NATIVEMIDI_Stop, - NATIVEMIDI_Delete, - NULL, /* Close */ - NULL, /* Unload */ -}; - -#endif /* MUSIC_MID_NATIVE */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_nativemidi.h b/music_nativemidi.h deleted file mode 100644 index 35ccc1e..0000000 --- a/music_nativemidi.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* This file supports playing MIDI files with OS APIs */ - -#include "music.h" - -extern Mix_MusicInterface Mix_MusicInterface_NATIVEMIDI; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_ogg.c b/music_ogg.c deleted file mode 100644 index 8323653..0000000 --- a/music_ogg.c +++ /dev/null @@ -1,457 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef MUSIC_OGG - -/* This file supports Ogg Vorbis music streams */ - -#include "SDL_loadso.h" - -#include "music_ogg.h" - -#define OV_EXCLUDE_STATIC_CALLBACKS -#if defined(OGG_HEADER) -#include OGG_HEADER -#elif defined(OGG_USE_TREMOR) -#include -#else -#include -#endif - -typedef struct { - int loaded; - void *handle; - int (*ov_clear)(OggVorbis_File *vf); - vorbis_info *(*ov_info)(OggVorbis_File *vf,int link); - vorbis_comment *(*ov_comment)(OggVorbis_File *vf,int link); - int (*ov_open_callbacks)(void *datasource, OggVorbis_File *vf, const char *initial, long ibytes, ov_callbacks callbacks); - ogg_int64_t (*ov_pcm_total)(OggVorbis_File *vf,int i); -#ifdef OGG_USE_TREMOR - long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int *bitstream); -#else - long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int bigendianp,int word,int sgned,int *bitstream); -#endif -#ifdef OGG_USE_TREMOR - int (*ov_time_seek)(OggVorbis_File *vf,ogg_int64_t pos); -#else - int (*ov_time_seek)(OggVorbis_File *vf,double pos); -#endif - int (*ov_pcm_seek)(OggVorbis_File *vf, ogg_int64_t pos); - ogg_int64_t (*ov_pcm_tell)(OggVorbis_File *vf); -} vorbis_loader; - -static vorbis_loader vorbis = { - 0, NULL -}; - -#ifdef OGG_DYNAMIC -#define FUNCTION_LOADER(FUNC, SIG) \ - vorbis.FUNC = (SIG) SDL_LoadFunction(vorbis.handle, #FUNC); \ - if (vorbis.FUNC == NULL) { SDL_UnloadObject(vorbis.handle); return -1; } -#else -#define FUNCTION_LOADER(FUNC, SIG) \ - vorbis.FUNC = FUNC; -#endif - -static int OGG_Load(void) -{ - if (vorbis.loaded == 0) { -#ifdef OGG_DYNAMIC - vorbis.handle = SDL_LoadObject(OGG_DYNAMIC); - if (vorbis.handle == NULL) { - return -1; - } -#elif defined(__MACOSX__) - extern int ov_open_callbacks(void*, OggVorbis_File*, const char*, long, ov_callbacks) __attribute__((weak_import)); - if (ov_open_callbacks == NULL) - { - /* Missing weakly linked framework */ - Mix_SetError("Missing Vorbis.framework"); - return -1; - } -#endif - FUNCTION_LOADER(ov_clear, int (*)(OggVorbis_File *)) - FUNCTION_LOADER(ov_info, vorbis_info *(*)(OggVorbis_File *,int)) - FUNCTION_LOADER(ov_comment, vorbis_comment *(*)(OggVorbis_File *,int)) - FUNCTION_LOADER(ov_open_callbacks, int (*)(void *, OggVorbis_File *, const char *, long, ov_callbacks)) - FUNCTION_LOADER(ov_pcm_total, ogg_int64_t (*)(OggVorbis_File *,int)) -#ifdef OGG_USE_TREMOR - FUNCTION_LOADER(ov_read, long (*)(OggVorbis_File *,char *,int,int *)) - FUNCTION_LOADER(ov_time_seek, long (*)(OggVorbis_File *,ogg_int64_t)) -#else - FUNCTION_LOADER(ov_read, long (*)(OggVorbis_File *,char *,int,int,int,int,int *)) - FUNCTION_LOADER(ov_time_seek, int (*)(OggVorbis_File *,double)) -#endif - FUNCTION_LOADER(ov_pcm_seek, int (*)(OggVorbis_File *,ogg_int64_t)) - FUNCTION_LOADER(ov_pcm_tell, ogg_int64_t (*)(OggVorbis_File *)) - } - ++vorbis.loaded; - - return 0; -} - -static void OGG_Unload(void) -{ - if (vorbis.loaded == 0) { - return; - } - if (vorbis.loaded == 1) { -#ifdef OGG_DYNAMIC - SDL_UnloadObject(vorbis.handle); -#endif - } - --vorbis.loaded; -} - - -typedef struct { - SDL_RWops *src; - int freesrc; - int play_count; - int volume; - OggVorbis_File vf; - vorbis_info vi; - int section; - SDL_AudioStream *stream; - char *buffer; - int buffer_size; - int loop; - ogg_int64_t loop_start; - ogg_int64_t loop_end; - ogg_int64_t loop_len; - ogg_int64_t channels; -} OGG_music; - - -static int set_ov_error(const char *function, int error) -{ -#define HANDLE_ERROR_CASE(X) case X: Mix_SetError("%s: %s", function, #X); break; - switch (error) { - HANDLE_ERROR_CASE(OV_FALSE); - HANDLE_ERROR_CASE(OV_EOF); - HANDLE_ERROR_CASE(OV_HOLE); - HANDLE_ERROR_CASE(OV_EREAD); - HANDLE_ERROR_CASE(OV_EFAULT); - HANDLE_ERROR_CASE(OV_EIMPL); - HANDLE_ERROR_CASE(OV_EINVAL); - HANDLE_ERROR_CASE(OV_ENOTVORBIS); - HANDLE_ERROR_CASE(OV_EBADHEADER); - HANDLE_ERROR_CASE(OV_EVERSION); - HANDLE_ERROR_CASE(OV_ENOTAUDIO); - HANDLE_ERROR_CASE(OV_EBADPACKET); - HANDLE_ERROR_CASE(OV_EBADLINK); - HANDLE_ERROR_CASE(OV_ENOSEEK); - default: - Mix_SetError("%s: unknown error %d\n", function, error); - break; - } - return -1; -} - -static size_t sdl_read_func(void *ptr, size_t size, size_t nmemb, void *datasource) -{ - return SDL_RWread((SDL_RWops*)datasource, ptr, size, nmemb); -} - -static int sdl_seek_func(void *datasource, ogg_int64_t offset, int whence) -{ - return (int)SDL_RWseek((SDL_RWops*)datasource, offset, whence); -} - -static long sdl_tell_func(void *datasource) -{ - return (long)SDL_RWtell((SDL_RWops*)datasource); -} - -static int OGG_Seek(void *context, double time); -static void OGG_Delete(void *context); - -static int OGG_UpdateSection(OGG_music *music) -{ - vorbis_info *vi; - - vi = vorbis.ov_info(&music->vf, -1); - if (!vi) { - Mix_SetError("ov_info returned NULL"); - return -1; - } - - if (vi->channels == music->vi.channels && vi->rate == music->vi.rate) { - return 0; - } - SDL_memcpy(&music->vi, vi, sizeof(*vi)); - - if (music->buffer) { - SDL_free(music->buffer); - music->buffer = NULL; - } - - if (music->stream) { - SDL_FreeAudioStream(music->stream); - music->stream = NULL; - } - - music->stream = SDL_NewAudioStream(AUDIO_S16, vi->channels, (int)vi->rate, - music_spec.format, music_spec.channels, music_spec.freq); - if (!music->stream) { - return -1; - } - - music->buffer_size = music_spec.samples * sizeof(Sint16) * vi->channels; - music->buffer = (char *)SDL_malloc(music->buffer_size); - if (!music->buffer) { - return -1; - } - return 0; -} - -/* Load an OGG stream from an SDL_RWops object */ -static void *OGG_CreateFromRW(SDL_RWops *src, int freesrc) -{ - OGG_music *music; - ov_callbacks callbacks; - vorbis_comment *vc; - int isLoopLength = 0, i; - ogg_int64_t fullLength; - - music = (OGG_music *)SDL_calloc(1, sizeof *music); - if (!music) { - SDL_OutOfMemory(); - return NULL; - } - music->src = src; - music->volume = MIX_MAX_VOLUME; - music->section = -1; - music->loop = -1; - music->loop_start = -1; - music->loop_end = 0; - music->loop_len = 0; - - SDL_zero(callbacks); - callbacks.read_func = sdl_read_func; - callbacks.seek_func = sdl_seek_func; - callbacks.tell_func = sdl_tell_func; - - if (vorbis.ov_open_callbacks(src, &music->vf, NULL, 0, callbacks) < 0) { - SDL_SetError("Not an Ogg Vorbis audio stream"); - SDL_free(music); - return NULL; - } - - if (OGG_UpdateSection(music) < 0) { - OGG_Delete(music); - return NULL; - } - - vc = vorbis.ov_comment(&music->vf, -1); - for (i = 0; i < vc->comments; i++) { - char *param = SDL_strdup(vc->user_comments[i]); - char *argument = param; - char *value = SDL_strchr(param, '='); - if (value == NULL) { - value = param + SDL_strlen(param); - } else { - *(value++) = '\0'; - } - - if (SDL_strcasecmp(argument, "LOOPSTART") == 0) - music->loop_start = SDL_strtoull(value, NULL, 0); - else if (SDL_strcasecmp(argument, "LOOPLENGTH") == 0) { - music->loop_len = SDL_strtoull(value, NULL, 0); - isLoopLength = 1; - } else if (SDL_strcasecmp(argument, "LOOPEND") == 0) { - isLoopLength = 0; - music->loop_end = SDL_strtoull(value, NULL, 0); - } - SDL_free(param); - } - - if (isLoopLength == 1) { - music->loop_end = music->loop_start + music->loop_len; - } else { - music->loop_len = music->loop_end - music->loop_start; - } - - fullLength = vorbis.ov_pcm_total(&music->vf, -1); - if (((music->loop_start >= 0) || (music->loop_end > 0)) && - ((music->loop_start < music->loop_end) || (music->loop_end == 0)) && - (music->loop_start < fullLength) && - (music->loop_end <= fullLength)) { - if (music->loop_start < 0) music->loop_start = 0; - if (music->loop_end == 0) music->loop_end = fullLength; - music->loop = 1; - } - - music->freesrc = freesrc; - return music; -} - -/* Set the volume for an OGG stream */ -static void OGG_SetVolume(void *context, int volume) -{ - OGG_music *music = (OGG_music *)context; - music->volume = volume; -} - -/* Start playback of a given OGG stream */ -static int OGG_Play(void *context, int play_count) -{ - OGG_music *music = (OGG_music *)context; - music->play_count = play_count; - return OGG_Seek(music, 0.0); -} - -/* Play some of a stream previously started with OGG_play() */ -static int OGG_GetSome(void *context, void *data, int bytes, SDL_bool *done) -{ - OGG_music *music = (OGG_music *)context; - SDL_bool looped = SDL_FALSE; - int filled, amount, result; - int section; - ogg_int64_t pcmPos; - - filled = SDL_AudioStreamGet(music->stream, data, bytes); - if (filled != 0) { - return filled; - } - - if (!music->play_count) { - /* All done */ - *done = SDL_TRUE; - return 0; - } - - section = music->section; -#ifdef OGG_USE_TREMOR - amount = vorbis.ov_read(&music->vf, music->buffer, music->buffer_size, §ion); -#else - amount = (int)vorbis.ov_read(&music->vf, music->buffer, music->buffer_size, 0, 2, 1, §ion); -#endif - if (amount < 0) { - set_ov_error("ov_read", amount); - return -1; - } - - if (section != music->section) { - music->section = section; - if (OGG_UpdateSection(music) < 0) { - return -1; - } - } - - pcmPos = vorbis.ov_pcm_tell(&music->vf); - if ((music->loop == 1) && (pcmPos >= music->loop_end)) { - amount -= (int)((pcmPos - music->loop_end) * music->channels) * sizeof(Sint16); - result = vorbis.ov_pcm_seek(&music->vf, music->loop_start); - if (result < 0) { - set_ov_error("ov_pcm_seek", result); - return -1; - } - looped = SDL_TRUE; - } - - if (amount > 0) { - if (SDL_AudioStreamPut(music->stream, music->buffer, amount) < 0) { - return -1; - } - } else if (!looped) { - if (music->play_count == 1) { - music->play_count = 0; - SDL_AudioStreamFlush(music->stream); - } else { - int play_count = -1; - if (music->play_count > 0) { - play_count = (music->play_count - 1); - } - if (OGG_Play(music, play_count) < 0) { - return -1; - } - } - } - return 0; -} -static int OGG_GetAudio(void *context, void *data, int bytes) -{ - OGG_music *music = (OGG_music *)context; - return music_pcm_getaudio(context, data, bytes, music->volume, OGG_GetSome); -} - -/* Jump (seek) to a given position (time is in seconds) */ -static int OGG_Seek(void *context, double time) -{ - OGG_music *music = (OGG_music *)context; - int result; -#ifdef OGG_USE_TREMOR - result = vorbis.ov_time_seek(&music->vf, (ogg_int64_t)(time * 1000.0)); -#else - result = vorbis.ov_time_seek(&music->vf, time); -#endif - if (result < 0) { - return set_ov_error("ov_time_seek", result); - } - return 0; -} - -/* Close the given OGG stream */ -static void OGG_Delete(void *context) -{ - OGG_music *music = (OGG_music *)context; - vorbis.ov_clear(&music->vf); - if (music->stream) { - SDL_FreeAudioStream(music->stream); - } - if (music->buffer) { - SDL_free(music->buffer); - } - if (music->freesrc) { - SDL_RWclose(music->src); - } - SDL_free(music); -} - -Mix_MusicInterface Mix_MusicInterface_OGG = -{ - "OGG", - MIX_MUSIC_OGG, - MUS_OGG, - SDL_FALSE, - SDL_FALSE, - - OGG_Load, - NULL, /* Open */ - OGG_CreateFromRW, - NULL, /* CreateFromFile */ - OGG_SetVolume, - OGG_Play, - NULL, /* IsPlaying */ - OGG_GetAudio, - OGG_Seek, - NULL, /* Pause */ - NULL, /* Resume */ - NULL, /* Stop */ - OGG_Delete, - NULL, /* Close */ - OGG_Unload, -}; - -#endif /* MUSIC_OGG */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_ogg.h b/music_ogg.h deleted file mode 100644 index 30fba4d..0000000 --- a/music_ogg.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* This file supports Ogg Vorbis music streams */ - -#include "music.h" - -extern Mix_MusicInterface Mix_MusicInterface_OGG; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_opus.c b/music_opus.c deleted file mode 100644 index 9b4bcb8..0000000 --- a/music_opus.c +++ /dev/null @@ -1,373 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef MUSIC_OPUS - -/* This file supports Ogg Opus music streams */ - -#include "SDL_loadso.h" - -#include "music_opus.h" - -#if defined(OPUS_HEADER) -#include OPUS_HEADER -#else -#include -#endif - -typedef struct { - int loaded; - void *handle; - OggOpusFile *(*op_open_callbacks)(void *,const OpusFileCallbacks *,const unsigned char *,size_t,int *); - void (*op_free)(OggOpusFile *); - const OpusHead *(*op_head)(const OggOpusFile *,int); - int (*op_seekable)(const OggOpusFile *); - int (*op_read)(OggOpusFile *, opus_int16 *,int,int *); - int (*op_pcm_seek)(OggOpusFile *,ogg_int64_t); -} opus_loader; - -static opus_loader opus = { - 0, NULL -}; - -#ifdef OPUS_DYNAMIC -#define FUNCTION_LOADER(FUNC, SIG) \ - opus.FUNC = (SIG) SDL_LoadFunction(opus.handle, #FUNC); \ - if (opus.FUNC == NULL) { SDL_UnloadObject(opus.handle); return -1; } -#else -#define FUNCTION_LOADER(FUNC, SIG) \ - opus.FUNC = FUNC; -#endif - -static int OPUS_Load(void) -{ - if (opus.loaded == 0) { -#ifdef OPUS_DYNAMIC - opus.handle = SDL_LoadObject(OPUS_DYNAMIC); - if (opus.handle == NULL) { - return -1; - } -#elif defined(__MACOSX__) - extern OggOpusFile *op_open_callbacks(void *,const OpusFileCallbacks *,const unsigned char *,size_t,int *) __attribute__((weak_import)); - if (op_open_callbacks == NULL) { - /* Missing weakly linked framework */ - Mix_SetError("Missing OpusFile.framework"); - return -1; - } -#endif - FUNCTION_LOADER(op_open_callbacks, OggOpusFile *(*)(void *,const OpusFileCallbacks *,const unsigned char *,size_t,int *)) - FUNCTION_LOADER(op_free, void (*)(OggOpusFile *)) - FUNCTION_LOADER(op_head, const OpusHead *(*)(const OggOpusFile *,int)) - FUNCTION_LOADER(op_seekable, int (*)(const OggOpusFile *)) - FUNCTION_LOADER(op_read, int (*)(OggOpusFile *, opus_int16 *,int,int *)) - FUNCTION_LOADER(op_pcm_seek, int (*)(OggOpusFile *,ogg_int64_t)) - } - ++opus.loaded; - - return 0; -} - -static void OPUS_Unload(void) -{ - if (opus.loaded == 0) { - return; - } - if (opus.loaded == 1) { -#ifdef OPUS_DYNAMIC - SDL_UnloadObject(opus.handle); -#endif - } - --opus.loaded; -} - - -typedef struct { - SDL_RWops *src; - int freesrc; - int play_count; - int volume; - OggOpusFile *of; - const OpusHead *op_info; - int section; - SDL_AudioStream *stream; - char *buffer; - int buffer_size; -} OPUS_music; - - -static int set_op_error(const char *function, int error) -{ -#define HANDLE_ERROR_CASE(X) case X: Mix_SetError("%s: %s", function, #X); break; - switch (error) { - HANDLE_ERROR_CASE(OP_FALSE); - HANDLE_ERROR_CASE(OP_EOF); - HANDLE_ERROR_CASE(OP_HOLE); - HANDLE_ERROR_CASE(OP_EREAD); - HANDLE_ERROR_CASE(OP_EFAULT); - HANDLE_ERROR_CASE(OP_EIMPL); - HANDLE_ERROR_CASE(OP_EINVAL); - HANDLE_ERROR_CASE(OP_ENOTFORMAT); - HANDLE_ERROR_CASE(OP_EBADHEADER); - HANDLE_ERROR_CASE(OP_EVERSION); - HANDLE_ERROR_CASE(OP_ENOTAUDIO); - HANDLE_ERROR_CASE(OP_EBADPACKET); - HANDLE_ERROR_CASE(OP_EBADLINK); - HANDLE_ERROR_CASE(OP_ENOSEEK); - HANDLE_ERROR_CASE(OP_EBADTIMESTAMP); - default: - Mix_SetError("%s: unknown error %d\n", function, error); - break; - } - return -1; -} - -static int sdl_read_func(void *datasource, unsigned char *ptr, int size) -{ - return (int)SDL_RWread((SDL_RWops*)datasource, ptr, 1, size); -} - -static int sdl_seek_func(void *datasource, opus_int64 offset, int whence) -{ - return (SDL_RWseek((SDL_RWops*)datasource, offset, whence) < 0)? -1 : 0; -} - -static opus_int64 sdl_tell_func(void *datasource) -{ - return SDL_RWtell((SDL_RWops*)datasource); -} - -static int OPUS_Seek(void*, double); -static void OPUS_Delete(void*); - -static int OPUS_UpdateSection(OPUS_music *music) -{ - const OpusHead *op_info; - - op_info = opus.op_head(music->of, -1); - if (!op_info) { - Mix_SetError("op_head returned NULL"); - return -1; - } - - if (music->op_info && op_info->channel_count == music->op_info->channel_count) { - return 0; - } - music->op_info = op_info; - - if (music->buffer) { - SDL_free(music->buffer); - music->buffer = NULL; - } - - if (music->stream) { - SDL_FreeAudioStream(music->stream); - music->stream = NULL; - } - - music->stream = SDL_NewAudioStream(AUDIO_S16, op_info->channel_count, 48000, - music_spec.format, music_spec.channels, music_spec.freq); - if (!music->stream) { - return -1; - } - - music->buffer_size = music_spec.samples * sizeof(opus_int16) * op_info->channel_count; - music->buffer = (char *)SDL_malloc(music->buffer_size); - if (!music->buffer) { - return -1; - } - return 0; -} - -/* Load an Opus stream from an SDL_RWops object */ -static void *OPUS_CreateFromRW(SDL_RWops *src, int freesrc) -{ - OPUS_music *music; - OpusFileCallbacks callbacks; - int err = 0; - - music = (OPUS_music *)SDL_calloc(1, sizeof *music); - if (!music) { - SDL_OutOfMemory(); - return NULL; - } - music->src = src; - music->volume = MIX_MAX_VOLUME; - music->section = -1; - - SDL_zero(callbacks); - callbacks.read = sdl_read_func; - callbacks.seek = sdl_seek_func; - callbacks.tell = sdl_tell_func; - - music->of = opus.op_open_callbacks(src, &callbacks, NULL, 0, &err); - if (music->of == NULL) { - /* set_op_error("op_open_callbacks", err);*/ - SDL_SetError("Not an Opus audio stream"); - SDL_free(music); - return NULL; - } - - if (!opus.op_seekable(music->of)) { - OPUS_Delete(music); - Mix_SetError("Opus stream not seekable"); - return NULL; - } - - if (OPUS_UpdateSection(music) < 0) { - OPUS_Delete(music); - return NULL; - } - - music->freesrc = freesrc; - return music; -} - -/* Set the volume for an Opus stream */ -static void OPUS_SetVolume(void *context, int volume) -{ - OPUS_music *music = (OPUS_music *)context; - music->volume = volume; -} - -/* Start playback of a given Opus stream */ -static int OPUS_Play(void *context, int play_count) -{ - OPUS_music *music = (OPUS_music *)context; - music->play_count = play_count; - return OPUS_Seek(music, 0.0); -} - -/* Play some of a stream previously started with OPUS_Play() */ -static int OPUS_GetSome(void *context, void *data, int bytes, SDL_bool *done) -{ - OPUS_music *music = (OPUS_music *)context; - int filled, samples, section; - - filled = SDL_AudioStreamGet(music->stream, data, bytes); - if (filled != 0) { - return filled; - } - - if (!music->play_count) { - /* All done */ - *done = SDL_TRUE; - return 0; - } - - section = music->section; - samples = opus.op_read(music->of, (opus_int16 *)music->buffer, music->buffer_size / sizeof(opus_int16), §ion); - if (samples < 0) { - set_op_error("op_read", samples); - return -1; - } - - if (section != music->section) { - music->section = section; - if (OPUS_UpdateSection(music) < 0) { - return -1; - } - } - - if (samples > 0) { - filled = samples * music->op_info->channel_count * 2; - if (SDL_AudioStreamPut(music->stream, music->buffer, filled) < 0) { - return -1; - } - } else { - if (music->play_count == 1) { - music->play_count = 0; - SDL_AudioStreamFlush(music->stream); - } else { - int play_count = -1; - if (music->play_count > 0) { - play_count = (music->play_count - 1); - } - if (OPUS_Play(music, play_count) < 0) { - return -1; - } - } - } - return 0; -} - -static int OPUS_GetAudio(void *context, void *data, int bytes) -{ - OPUS_music *music = (OPUS_music *)context; - return music_pcm_getaudio(context, data, bytes, music->volume, OPUS_GetSome); -} - -/* Jump (seek) to a given position (time is in seconds) */ -static int OPUS_Seek(void *context, double time) -{ - OPUS_music *music = (OPUS_music *)context; - int result; - result = opus.op_pcm_seek(music->of, (ogg_int64_t)(time * 48000)); - if (result < 0) { - return set_op_error("op_pcm_seek", result); - } - return 0; -} - -/* Close the given Opus stream */ -static void OPUS_Delete(void *context) -{ - OPUS_music *music = (OPUS_music *)context; - opus.op_free(music->of); - if (music->stream) { - SDL_FreeAudioStream(music->stream); - } - if (music->buffer) { - SDL_free(music->buffer); - } - if (music->freesrc) { - SDL_RWclose(music->src); - } - SDL_free(music); -} - -Mix_MusicInterface Mix_MusicInterface_Opus = -{ - "OPUS", - MIX_MUSIC_OPUS, - MUS_OPUS, - SDL_FALSE, - SDL_FALSE, - - OPUS_Load, - NULL, /* Open */ - OPUS_CreateFromRW, - NULL, /* CreateFromFile */ - OPUS_SetVolume, - OPUS_Play, - NULL, /* IsPlaying */ - OPUS_GetAudio, - OPUS_Seek, - NULL, /* Pause */ - NULL, /* Resume */ - NULL, /* Stop */ - OPUS_Delete, - NULL, /* Close */ - OPUS_Unload, -}; - -#endif /* MUSIC_OPUS */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_opus.h b/music_opus.h deleted file mode 100644 index a207bc5..0000000 --- a/music_opus.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* This file supports Ogg Opus music streams */ - -#include "music.h" - -extern Mix_MusicInterface Mix_MusicInterface_Opus; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_timidity.c b/music_timidity.c deleted file mode 100644 index 68634fd..0000000 --- a/music_timidity.c +++ /dev/null @@ -1,220 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* This file supports playing MIDI files with timidity */ - -#ifdef MUSIC_MID_TIMIDITY - -#include "music_timidity.h" - -#include "timidity/timidity.h" - - -typedef struct -{ - int play_count; - MidiSong *song; - SDL_AudioStream *stream; - void *buffer; - Sint32 buffer_size; -} TIMIDITY_Music; - - -static int TIMIDITY_Seek(void *context, double position); -static void TIMIDITY_Delete(void *context); - -static int TIMIDITY_Open(const SDL_AudioSpec *spec) -{ - return Timidity_Init(); -} - -static void TIMIDITY_Close(void) -{ - Timidity_Exit(); -} - -void *TIMIDITY_CreateFromRW(SDL_RWops *src, int freesrc) -{ - TIMIDITY_Music *music; - SDL_AudioSpec spec; - SDL_bool need_stream = SDL_FALSE; - - music = (TIMIDITY_Music *)SDL_calloc(1, sizeof(*music)); - if (!music) { - SDL_OutOfMemory(); - return NULL; - } - - SDL_memcpy(&spec, &music_spec, sizeof(spec)); - if (spec.channels > 2) { - need_stream = SDL_TRUE; - spec.channels = 2; - } - music->song = Timidity_LoadSong(src, &spec); - if (!music->song) { - TIMIDITY_Delete(music); - return NULL; - } - - if (need_stream) { - music->stream = SDL_NewAudioStream(spec.format, spec.channels, spec.freq, - music_spec.format, music_spec.channels, music_spec.freq); - if (!music->stream) { - TIMIDITY_Delete(music); - return NULL; - } - - music->buffer_size = spec.samples * (SDL_AUDIO_BITSIZE(spec.format) / 8) * spec.channels; - music->buffer = SDL_malloc(music->buffer_size); - if (!music->buffer) { - SDL_OutOfMemory(); - TIMIDITY_Delete(music); - return NULL; - } - } - - if (freesrc) { - SDL_RWclose(src); - } - return music; -} - -static void TIMIDITY_SetVolume(void *context, int volume) -{ - TIMIDITY_Music *music = (TIMIDITY_Music *)context; - Timidity_SetVolume(music->song, volume); -} - -static int TIMIDITY_Play(void *context, int play_count) -{ - TIMIDITY_Music *music = (TIMIDITY_Music *)context; - music->play_count = play_count; - Timidity_Start(music->song); - return TIMIDITY_Seek(music, 0.0); -} - -static int TIMIDITY_GetSome(void *context, void *data, int bytes, SDL_bool *done) -{ - TIMIDITY_Music *music = (TIMIDITY_Music *)context; - int filled, amount, expected; - - if (music->stream) { - filled = SDL_AudioStreamGet(music->stream, data, bytes); - if (filled != 0) { - return filled; - } - } - - if (!music->play_count) { - /* All done */ - *done = SDL_TRUE; - return 0; - } - - if (music->stream) { - expected = music->buffer_size; - amount = Timidity_PlaySome(music->song, music->buffer, music->buffer_size); - if (SDL_AudioStreamPut(music->stream, music->buffer, amount) < 0) { - return -1; - } - } else { - expected = bytes; - amount = Timidity_PlaySome(music->song, data, bytes); - } - - if (amount < expected) { - if (music->play_count == 1) { - /* We didn't consume anything and we're done */ - music->play_count = 0; - } else { - int play_count = -1; - if (music->play_count > 0) { - play_count = (music->play_count - 1); - } - if (TIMIDITY_Play(music, play_count) < 0) { - return -1; - } - } - } - if (music->stream) { - /* We'll pick it up from the stream next time around */ - return 0; - } else { - /* We wrote output data */ - return amount; - } -} -static int TIMIDITY_GetAudio(void *context, void *data, int bytes) -{ - return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, TIMIDITY_GetSome); -} - -static int TIMIDITY_Seek(void *context, double position) -{ - TIMIDITY_Music *music = (TIMIDITY_Music *)context; - Timidity_Seek(music->song, (Uint32)(position * 1000)); - return 0; -} - -static void TIMIDITY_Delete(void *context) -{ - TIMIDITY_Music *music = (TIMIDITY_Music *)context; - - if (music->song) { - Timidity_FreeSong(music->song); - } - if (music->stream) { - SDL_FreeAudioStream(music->stream); - } - if (music->buffer) { - SDL_free(music->buffer); - } - SDL_free(music); -} - -Mix_MusicInterface Mix_MusicInterface_TIMIDITY = -{ - "TIMIDITY", - MIX_MUSIC_TIMIDITY, - MUS_MID, - SDL_FALSE, - SDL_FALSE, - - NULL, /* Load */ - TIMIDITY_Open, - TIMIDITY_CreateFromRW, - NULL, /* CreateFromFile */ - TIMIDITY_SetVolume, - TIMIDITY_Play, - NULL, /* IsPlaying */ - TIMIDITY_GetAudio, - TIMIDITY_Seek, - NULL, /* Pause */ - NULL, /* Resume */ - NULL, /* Stop */ - TIMIDITY_Delete, - TIMIDITY_Close, - NULL, /* Unload */ -}; - -#endif /* MUSIC_MID_TIMIDITY */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_timidity.h b/music_timidity.h deleted file mode 100644 index 1884097..0000000 --- a/music_timidity.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* This file supports playing MIDI files with timidity */ - -#include "music.h" - -extern Mix_MusicInterface Mix_MusicInterface_TIMIDITY; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_wav.c b/music_wav.c deleted file mode 100644 index 21e20dc..0000000 --- a/music_wav.c +++ /dev/null @@ -1,638 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef MUSIC_WAV - -/* This file supports streaming WAV files */ - -#include "music_wav.h" - - -typedef struct { - SDL_bool active; - Uint32 start; - Uint32 stop; - Uint32 initial_play_count; - Uint32 current_play_count; -} WAVLoopPoint; - -typedef struct { - SDL_RWops *src; - SDL_bool freesrc; - SDL_AudioSpec spec; - int volume; - int play_count; - Sint64 start; - Sint64 stop; - Uint8 *buffer; - SDL_AudioStream *stream; - int numloops; - WAVLoopPoint *loops; -} WAV_Music; - -/* - Taken with permission from SDL_wave.h, part of the SDL library, - available at: http://www.libsdl.org/ - and placed under the same license as this mixer library. -*/ - -/* WAVE files are little-endian */ - -/*******************************************/ -/* Define values for Microsoft WAVE format */ -/*******************************************/ -#define RIFF 0x46464952 /* "RIFF" */ -#define WAVE 0x45564157 /* "WAVE" */ -#define FMT 0x20746D66 /* "fmt " */ -#define DATA 0x61746164 /* "data" */ -#define SMPL 0x6c706d73 /* "smpl" */ -#define PCM_CODE 1 -#define ADPCM_CODE 2 -#define WAVE_MONO 1 -#define WAVE_STEREO 2 - -typedef struct { -/* Not saved in the chunk we read: - Uint32 chunkID; - Uint32 chunkLen; -*/ - Uint16 encoding; - Uint16 channels; /* 1 = mono, 2 = stereo */ - Uint32 frequency; /* One of 11025, 22050, or 44100 Hz */ - Uint32 byterate; /* Average bytes per second */ - Uint16 blockalign; /* Bytes per sample block */ - Uint16 bitspersample; /* One of 8, 12, 16, or 4 for ADPCM */ -} WaveFMT; - -typedef struct { - Uint32 identifier; - Uint32 type; - Uint32 start; - Uint32 end; - Uint32 fraction; - Uint32 play_count; -} SampleLoop; - -typedef struct { -/* Not saved in the chunk we read: - Uint32 chunkID; - Uint32 chunkLen; -*/ - Uint32 manufacturer; - Uint32 product; - Uint32 sample_period; - Uint32 MIDI_unity_note; - Uint32 MIDI_pitch_fraction; - Uint32 SMTPE_format; - Uint32 SMTPE_offset; - Uint32 sample_loops; - Uint32 sampler_data; - SampleLoop loops[1]; -} SamplerChunk; - -/*********************************************/ -/* Define values for AIFF (IFF audio) format */ -/*********************************************/ -#define FORM 0x4d524f46 /* "FORM" */ -#define AIFF 0x46464941 /* "AIFF" */ -#define SSND 0x444e5353 /* "SSND" */ -#define COMM 0x4d4d4f43 /* "COMM" */ - - -/* Function to load the WAV/AIFF stream */ -static SDL_bool LoadWAVMusic(WAV_Music *wave); -static SDL_bool LoadAIFFMusic(WAV_Music *wave); - -static void WAV_Delete(void *context); - -/* Load a WAV stream from the given RWops object */ -static void *WAV_CreateFromRW(SDL_RWops *src, int freesrc) -{ - WAV_Music *music; - Uint32 magic; - SDL_bool loaded = SDL_FALSE; - - music = (WAV_Music *)SDL_calloc(1, sizeof(*music)); - if (!music) { - SDL_OutOfMemory(); - return NULL; - } - music->src = src; - music->volume = MIX_MAX_VOLUME; - - magic = SDL_ReadLE32(src); - if (magic == RIFF || magic == WAVE) { - loaded = LoadWAVMusic(music); - } else if (magic == FORM) { - loaded = LoadAIFFMusic(music); - } else { - Mix_SetError("Unknown WAVE format"); - } - if (!loaded) { - SDL_free(music); - return NULL; - } - music->buffer = (Uint8*)SDL_malloc(music->spec.size); - if (!music->buffer) { - WAV_Delete(music); - return NULL; - } - music->stream = SDL_NewAudioStream( - music->spec.format, music->spec.channels, music->spec.freq, - music_spec.format, music_spec.channels, music_spec.freq); - if (!music->stream) { - WAV_Delete(music); - return NULL; - } - - music->freesrc = freesrc; - return music; -} - -static void WAV_SetVolume(void *context, int volume) -{ - WAV_Music *music = (WAV_Music *)context; - music->volume = volume; -} - -/* Start playback of a given WAV stream */ -static int WAV_Play(void *context, int play_count) -{ - WAV_Music *music = (WAV_Music *)context; - int i; - for (i = 0; i < music->numloops; ++i) { - WAVLoopPoint *loop = &music->loops[i]; - loop->active = SDL_TRUE; - loop->current_play_count = loop->initial_play_count; - } - music->play_count = play_count; - if (SDL_RWseek(music->src, music->start, RW_SEEK_SET) < 0) { - return -1; - } - return 0; -} - -/* Play some of a stream previously started with WAV_Play() */ -static int WAV_GetSome(void *context, void *data, int bytes, SDL_bool *done) -{ - WAV_Music *music = (WAV_Music *)context; - Sint64 pos, stop; - WAVLoopPoint *loop; - Sint64 loop_start; - Sint64 loop_stop; - SDL_bool looped = SDL_FALSE; - int i; - int filled, amount, result; - - filled = SDL_AudioStreamGet(music->stream, data, bytes); - if (filled != 0) { - return filled; - } - - if (!music->play_count) { - /* All done */ - *done = SDL_TRUE; - return 0; - } - - pos = SDL_RWtell(music->src); - stop = music->stop; - loop = NULL; - for (i = 0; i < music->numloops; ++i) { - loop = &music->loops[i]; - if (loop->active) { - const int bytes_per_sample = (SDL_AUDIO_BITSIZE(music->spec.format) / 8) * music->spec.channels; - loop_start = music->start + loop->start * bytes_per_sample; - loop_stop = music->start + (loop->stop + 1) * bytes_per_sample; - if (pos >= loop_start && pos < loop_stop) - { - stop = loop_stop; - break; - } - } - loop = NULL; - } - - amount = music->spec.size; - if ((stop - pos) < amount) { - amount = (int)(stop - pos); - } - amount = (int)SDL_RWread(music->src, music->buffer, 1, amount); - if (amount > 0) { - result = SDL_AudioStreamPut(music->stream, music->buffer, amount); - if (result < 0) { - return -1; - } - } else { - /* We might be looping, continue */ - } - - if (loop && SDL_RWtell(music->src) >= stop) { - if (loop->current_play_count == 1) { - loop->active = SDL_FALSE; - } else { - if (loop->current_play_count > 0) { - --loop->current_play_count; - } - SDL_RWseek(music->src, loop_start, RW_SEEK_SET); - looped = SDL_TRUE; - } - } - - if (!looped && SDL_RWtell(music->src) >= music->stop) { - if (music->play_count == 1) { - music->play_count = 0; - SDL_AudioStreamFlush(music->stream); - } else { - int play_count = -1; - if (music->play_count > 0) { - play_count = (music->play_count - 1); - } - if (WAV_Play(music, play_count) < 0) { - return -1; - } - } - } - - /* We'll get called again in the case where we looped or have more data */ - return 0; -} - -static int WAV_GetAudio(void *context, void *data, int bytes) -{ - WAV_Music *music = (WAV_Music *)context; - return music_pcm_getaudio(context, data, bytes, music->volume, WAV_GetSome); -} - -/* Close the given WAV stream */ -static void WAV_Delete(void *context) -{ - WAV_Music *music = (WAV_Music *)context; - - /* Clean up associated data */ - if (music->loops) { - SDL_free(music->loops); - } - if (music->stream) { - SDL_FreeAudioStream(music->stream); - } - if (music->buffer) { - SDL_free(music->buffer); - } - if (music->freesrc) { - SDL_RWclose(music->src); - } - SDL_free(music); -} - -static SDL_bool ParseFMT(WAV_Music *wave, Uint32 chunk_length) -{ - SDL_AudioSpec *spec = &wave->spec; - WaveFMT *format; - Uint8 *data; - SDL_bool loaded = SDL_FALSE; - - if (chunk_length < sizeof(*format)) { - Mix_SetError("Wave format chunk too small"); - return SDL_FALSE; - } - - data = (Uint8 *)SDL_malloc(chunk_length); - if (!data) { - Mix_SetError("Out of memory"); - return SDL_FALSE; - } - if (!SDL_RWread(wave->src, data, chunk_length, 1)) { - Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length); - return SDL_FALSE; - } - format = (WaveFMT *)data; - - /* Decode the audio data format */ - switch (SDL_SwapLE16(format->encoding)) { - case PCM_CODE: - /* We can understand this */ - break; - default: - Mix_SetError("Unknown WAVE data format"); - goto done; - } - spec->freq = SDL_SwapLE32(format->frequency); - switch (SDL_SwapLE16(format->bitspersample)) { - case 8: - spec->format = AUDIO_U8; - break; - case 16: - spec->format = AUDIO_S16; - break; - default: - Mix_SetError("Unknown PCM data format"); - goto done; - } - spec->channels = (Uint8) SDL_SwapLE16(format->channels); - spec->samples = 4096; /* Good default buffer size */ - /* SDL_CalculateAudioSpec */ - spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8; - spec->size *= spec->channels; - spec->size *= spec->samples; - - loaded = SDL_TRUE; - -done: - SDL_free(data); - return loaded; -} - -static SDL_bool ParseDATA(WAV_Music *wave, Uint32 chunk_length) -{ - wave->start = SDL_RWtell(wave->src); - wave->stop = wave->start + chunk_length; - SDL_RWseek(wave->src, chunk_length, RW_SEEK_CUR); - return SDL_TRUE; -} - -static SDL_bool AddLoopPoint(WAV_Music *wave, Uint32 play_count, Uint32 start, Uint32 stop) -{ - WAVLoopPoint *loop; - WAVLoopPoint *loops = SDL_realloc(wave->loops, (wave->numloops + 1)*sizeof(*wave->loops)); - if (!loops) { - Mix_SetError("Out of memory"); - return SDL_FALSE; - } - - loop = &loops[ wave->numloops ]; - loop->start = start; - loop->stop = stop; - loop->initial_play_count = play_count; - loop->current_play_count = play_count; - - wave->loops = loops; - ++wave->numloops; - return SDL_TRUE; -} - -static SDL_bool ParseSMPL(WAV_Music *wave, Uint32 chunk_length) -{ - SamplerChunk *chunk; - Uint8 *data; - Uint32 i; - SDL_bool loaded = SDL_FALSE; - - data = (Uint8 *)SDL_malloc(chunk_length); - if (!data) { - Mix_SetError("Out of memory"); - return SDL_FALSE; - } - if (!SDL_RWread(wave->src, data, chunk_length, 1)) { - Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length); - return SDL_FALSE; - } - chunk = (SamplerChunk *)data; - - for (i = 0; i < SDL_SwapLE32(chunk->sample_loops); ++i) { - const Uint32 LOOP_TYPE_FORWARD = 0; - Uint32 loop_type = SDL_SwapLE32(chunk->loops[i].type); - if (loop_type == LOOP_TYPE_FORWARD) { - AddLoopPoint(wave, SDL_SwapLE32(chunk->loops[i].play_count), SDL_SwapLE32(chunk->loops[i].start), SDL_SwapLE32(chunk->loops[i].end)); - } - } - - loaded = SDL_TRUE; - SDL_free(data); - return loaded; -} - -static SDL_bool LoadWAVMusic(WAV_Music *wave) -{ - SDL_RWops *src = wave->src; - Uint32 chunk_type; - Uint32 chunk_length; - SDL_bool found_FMT = SDL_FALSE; - SDL_bool found_DATA = SDL_FALSE; - - /* WAV magic header */ - Uint32 wavelen; - Uint32 WAVEmagic; - - /* Check the magic header */ - wavelen = SDL_ReadLE32(src); - WAVEmagic = SDL_ReadLE32(src); - - /* Read the chunks */ - for (; ;) { - chunk_type = SDL_ReadLE32(src); - chunk_length = SDL_ReadLE32(src); - - if (chunk_length == 0) - break; - - switch (chunk_type) - { - case FMT: - found_FMT = SDL_TRUE; - if (!ParseFMT(wave, chunk_length)) - return SDL_FALSE; - break; - case DATA: - found_DATA = SDL_TRUE; - if (!ParseDATA(wave, chunk_length)) - return SDL_FALSE; - break; - case SMPL: - if (!ParseSMPL(wave, chunk_length)) - return SDL_FALSE; - break; - default: - SDL_RWseek(src, chunk_length, RW_SEEK_CUR); - break; - } - } - - if (!found_FMT) { - Mix_SetError("Bad WAV file (no FMT chunk)"); - return SDL_FALSE; - } - - if (!found_DATA) { - Mix_SetError("Bad WAV file (no DATA chunk)"); - return SDL_FALSE; - } - - return SDL_TRUE; -} - -/* I couldn't get SANE_to_double() to work, so I stole this from libsndfile. - * I don't pretend to fully understand it. - */ - -static Uint32 SANE_to_Uint32 (Uint8 *sanebuf) -{ - /* Negative number? */ - if (sanebuf[0] & 0x80) - return 0; - - /* Less than 1? */ - if (sanebuf[0] <= 0x3F) - return 1; - - /* Way too big? */ - if (sanebuf[0] > 0x40) - return 0x4000000; - - /* Still too big? */ - if (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C) - return 800000000; - - return ((sanebuf[2] << 23) | (sanebuf[3] << 15) | (sanebuf[4] << 7) | - (sanebuf[5] >> 1)) >> (29 - sanebuf[1]); -} - -static SDL_bool LoadAIFFMusic(WAV_Music *wave) -{ - SDL_RWops *src = wave->src; - SDL_AudioSpec *spec = &wave->spec; - SDL_bool found_SSND = SDL_FALSE; - SDL_bool found_COMM = SDL_FALSE; - - Uint32 chunk_type; - Uint32 chunk_length; - Sint64 next_chunk; - - /* AIFF magic header */ - Uint32 AIFFmagic; - /* SSND chunk */ - Uint32 offset; - Uint32 blocksize; - /* COMM format chunk */ - Uint16 channels = 0; - Uint32 numsamples = 0; - Uint16 samplesize = 0; - Uint8 sane_freq[10]; - Uint32 frequency = 0; - - /* Check the magic header */ - chunk_length = SDL_ReadBE32(src); - AIFFmagic = SDL_ReadLE32(src); - if (AIFFmagic != AIFF) { - Mix_SetError("Unrecognized file type (not AIFF)"); - return SDL_FALSE; - } - - /* From what I understand of the specification, chunks may appear in - * any order, and we should just ignore unknown ones. - * - * TODO: Better sanity-checking. E.g. what happens if the AIFF file - * contains compressed sound data? - */ - do { - chunk_type = SDL_ReadLE32(src); - chunk_length = SDL_ReadBE32(src); - next_chunk = SDL_RWtell(src) + chunk_length; - - /* Paranoia to avoid infinite loops */ - if (chunk_length == 0) - break; - - switch (chunk_type) { - case SSND: - found_SSND = SDL_TRUE; - offset = SDL_ReadBE32(src); - blocksize = SDL_ReadBE32(src); - wave->start = SDL_RWtell(src) + offset; - break; - - case COMM: - found_COMM = SDL_TRUE; - - /* Read the audio data format chunk */ - channels = SDL_ReadBE16(src); - numsamples = SDL_ReadBE32(src); - samplesize = SDL_ReadBE16(src); - SDL_RWread(src, sane_freq, sizeof(sane_freq), 1); - frequency = SANE_to_Uint32(sane_freq); - break; - - default: - break; - } - } while ((!found_SSND || !found_COMM) - && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != -1); - - if (!found_SSND) { - Mix_SetError("Bad AIFF file (no SSND chunk)"); - return SDL_FALSE; - } - - if (!found_COMM) { - Mix_SetError("Bad AIFF file (no COMM chunk)"); - return SDL_FALSE; - } - - wave->stop = wave->start + channels * numsamples * (samplesize / 8); - - /* Decode the audio data format */ - SDL_memset(spec, 0, (sizeof *spec)); - spec->freq = frequency; - switch (samplesize) { - case 8: - spec->format = AUDIO_S8; - break; - case 16: - spec->format = AUDIO_S16MSB; - break; - default: - Mix_SetError("Unknown samplesize in data format"); - return SDL_FALSE; - } - spec->channels = (Uint8) channels; - spec->samples = 4096; /* Good default buffer size */ - - return SDL_TRUE; -} - -Mix_MusicInterface Mix_MusicInterface_WAV = -{ - "WAVE", - MIX_MUSIC_WAVE, - MUS_WAV, - SDL_FALSE, - SDL_FALSE, - - NULL, /* Load */ - NULL, /* Open */ - WAV_CreateFromRW, - NULL, /* CreateFromFile */ - WAV_SetVolume, - WAV_Play, - NULL, /* IsPlaying */ - WAV_GetAudio, - NULL, /* Seek */ - NULL, /* Pause */ - NULL, /* Resume */ - NULL, /* Stop */ - WAV_Delete, - NULL, /* Close */ - NULL, /* Unload */ -}; - -#endif /* MUSIC_WAV */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_wav.h b/music_wav.h deleted file mode 100644 index 98dc7e6..0000000 --- a/music_wav.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2018 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* This file supports streaming WAV files */ - -#include "music.h" - -extern Mix_MusicInterface Mix_MusicInterface_WAV; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/native_midi/native_midi.h b/native_midi/native_midi.h deleted file mode 100644 index 92d2535..0000000 --- a/native_midi/native_midi.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - native_midi: Hardware Midi support for the SDL_mixer library - Copyright (C) 2000 Florian 'Proff' Schulze - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef _NATIVE_MIDI_H_ -#define _NATIVE_MIDI_H_ - -#include "SDL_rwops.h" - -typedef struct _NativeMidiSong NativeMidiSong; - -int native_midi_detect(void); -NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc); -void native_midi_freesong(NativeMidiSong *song); -void native_midi_start(NativeMidiSong *song, int loops); -void native_midi_pause(void); -void native_midi_resume(void); -void native_midi_stop(void); -int native_midi_active(void); -void native_midi_setvolume(int volume); -const char *native_midi_error(void); - -#endif /* _NATIVE_MIDI_H_ */ diff --git a/native_midi/native_midi_common.c b/native_midi/native_midi_common.c deleted file mode 100644 index 68f898d..0000000 --- a/native_midi/native_midi_common.c +++ /dev/null @@ -1,414 +0,0 @@ -/* - native_midi: Hardware Midi support for the SDL_mixer library - Copyright (C) 2000,2001 Florian 'Proff' Schulze - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "native_midi_common.h" - -#include "../SDL_mixer.h" - -#include -#include -#include - -/* The constant 'MThd' */ -#define MIDI_MAGIC 0x4d546864 - -/* A single midi track as read from the midi file */ -typedef struct -{ - Uint8 *data; /* MIDI message stream */ - int len; /* length of the track data */ -} MIDITrack; - -/* A midi file, stripped down to the absolute minimum - divison & track data */ -typedef struct -{ - int division; /* number of pulses per quarter note (ppqn) */ - int nTracks; /* number of tracks */ - MIDITrack *track; /* tracks */ -} MIDIFile; - - -/* Some macros that help us stay endianess-independant */ -#if SDL_BYTEORDER == SDL_BIG_ENDIAN -#define BE_SHORT(x) (x) -#define BE_LONG(x) (x) -#else -#define BE_SHORT(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF)) -#define BE_LONG(x) ((((x)&0x0000FF)<<24) | \ - (((x)&0x00FF00)<<8) | \ - (((x)&0xFF0000)>>8) | \ - (((x)>>24)&0xFF)) -#endif - - - -/* Get Variable Length Quantity */ -static int GetVLQ(MIDITrack *track, int *currentPos) -{ - int l = 0; - Uint8 c; - while(1) - { - c = track->data[*currentPos]; - (*currentPos)++; - l += (c & 0x7f); - if (!(c & 0x80)) - return l; - l <<= 7; - } -} - -/* Create a single MIDIEvent */ -static MIDIEvent *CreateEvent(Uint32 time, Uint8 event, Uint8 a, Uint8 b) -{ - MIDIEvent *newEvent; - - newEvent = calloc(1, sizeof(MIDIEvent)); - - if (newEvent) - { - newEvent->time = time; - newEvent->status = event; - newEvent->data[0] = a; - newEvent->data[1] = b; - } - else - Mix_SetError("Out of memory"); - - return newEvent; -} - -/* Convert a single midi track to a list of MIDIEvents */ -static MIDIEvent *MIDITracktoStream(MIDITrack *track) -{ - Uint32 atime = 0; - Uint32 len = 0; - Uint8 event,type,a,b; - Uint8 laststatus = 0; - Uint8 lastchan = 0; - int currentPos = 0; - int end = 0; - MIDIEvent *head = CreateEvent(0,0,0,0); /* dummy event to make handling the list easier */ - MIDIEvent *currentEvent = head; - - while (!end) - { - if (currentPos >= track->len) - break; /* End of data stream reached */ - - atime += GetVLQ(track, ¤tPos); - event = track->data[currentPos++]; - - /* Handle SysEx seperatly */ - if (((event>>4) & 0x0F) == MIDI_STATUS_SYSEX) - { - if (event == 0xFF) - { - type = track->data[currentPos]; - currentPos++; - switch(type) - { - case 0x2f: /* End of data marker */ - end = 1; - case 0x51: /* Tempo change */ - /* - a=track->data[currentPos]; - b=track->data[currentPos+1]; - c=track->data[currentPos+2]; - AddEvent(song, atime, MEVT_TEMPO, c, b, a); - */ - break; - } - } - else - type = 0; - - len = GetVLQ(track, ¤tPos); - - /* Create an event and attach the extra data, if any */ - currentEvent->next = CreateEvent(atime, event, type, 0); - currentEvent = currentEvent->next; - if (NULL == currentEvent) - { - FreeMIDIEventList(head); - return NULL; - } - if (len) - { - currentEvent->extraLen = len; - currentEvent->extraData = malloc(len); - memcpy(currentEvent->extraData, &(track->data[currentPos]), len); - currentPos += len; - } - } - else - { - a = event; - if (a & 0x80) /* It's a status byte */ - { - /* Extract channel and status information */ - lastchan = a & 0x0F; - laststatus = (a>>4) & 0x0F; - - /* Read the next byte which should always be a data byte */ - a = track->data[currentPos++] & 0x7F; - } - switch(laststatus) - { - case MIDI_STATUS_NOTE_OFF: - case MIDI_STATUS_NOTE_ON: /* Note on */ - case MIDI_STATUS_AFTERTOUCH: /* Key Pressure */ - case MIDI_STATUS_CONTROLLER: /* Control change */ - case MIDI_STATUS_PITCH_WHEEL: /* Pitch wheel */ - b = track->data[currentPos++] & 0x7F; - currentEvent->next = CreateEvent(atime, (Uint8)((laststatus<<4)+lastchan), a, b); - currentEvent = currentEvent->next; - if (NULL == currentEvent) - { - FreeMIDIEventList(head); - return NULL; - } - break; - - case MIDI_STATUS_PROG_CHANGE: /* Program change */ - case MIDI_STATUS_PRESSURE: /* Channel pressure */ - a &= 0x7f; - currentEvent->next = CreateEvent(atime, (Uint8)((laststatus<<4)+lastchan), a, 0); - currentEvent = currentEvent->next; - if (NULL == currentEvent) - { - FreeMIDIEventList(head); - return NULL; - } - break; - - default: /* Sysex already handled above */ - break; - } - } - } - - currentEvent = head->next; - free(head); /* release the dummy head event */ - return currentEvent; -} - -/* - * Convert a midi song, consisting of up to 32 tracks, to a list of MIDIEvents. - * To do so, first convert the tracks seperatly, then interweave the resulting - * MIDIEvent-Lists to one big list. - */ -static MIDIEvent *MIDItoStream(MIDIFile *mididata) -{ - MIDIEvent **track; - MIDIEvent *head = CreateEvent(0,0,0,0); /* dummy event to make handling the list easier */ - MIDIEvent *currentEvent = head; - int trackID; - - if (NULL == head) - return NULL; - - track = (MIDIEvent**) calloc(1, sizeof(MIDIEvent*) * mididata->nTracks); - if (NULL == track) - { - free(head); - return NULL; - } - - /* First, convert all tracks to MIDIEvent lists */ - for (trackID = 0; trackID < mididata->nTracks; trackID++) - track[trackID] = MIDITracktoStream(&mididata->track[trackID]); - - /* Now, merge the lists. */ - /* TODO */ - while(1) - { - Uint32 lowestTime = INT_MAX; - int currentTrackID = -1; - - /* Find the next event */ - for (trackID = 0; trackID < mididata->nTracks; trackID++) - { - if (track[trackID] && (track[trackID]->time < lowestTime)) - { - currentTrackID = trackID; - lowestTime = track[currentTrackID]->time; - } - } - - /* Check if we processes all events */ - if (currentTrackID == -1) - break; - - currentEvent->next = track[currentTrackID]; - track[currentTrackID] = track[currentTrackID]->next; - - currentEvent = currentEvent->next; - - - lowestTime = 0; - } - - /* Make sure the list is properly terminated */ - currentEvent->next = 0; - - currentEvent = head->next; - free(track); - free(head); /* release the dummy head event */ - return currentEvent; -} - -static int ReadMIDIFile(MIDIFile *mididata, SDL_RWops *src) -{ - int i = 0; - Uint32 ID; - Uint32 size; - Uint16 format; - Uint16 tracks; - Uint16 division; - - if (!mididata) - return 0; - if (!src) - return 0; - - /* Make sure this is really a MIDI file */ - SDL_RWread(src, &ID, 1, 4); - if (BE_LONG(ID) != MIDI_MAGIC) - return 0; - - /* Header size must be 6 */ - SDL_RWread(src, &size, 1, 4); - size = BE_LONG(size); - if (size != 6) - return 0; - - /* We only support format 0 and 1, but not 2 */ - SDL_RWread(src, &format, 1, 2); - format = BE_SHORT(format); - if (format != 0 && format != 1) - return 0; - - SDL_RWread(src, &tracks, 1, 2); - tracks = BE_SHORT(tracks); - mididata->nTracks = tracks; - - /* Allocate tracks */ - mididata->track = (MIDITrack*) calloc(1, sizeof(MIDITrack) * mididata->nTracks); - if (NULL == mididata->track) - { - Mix_SetError("Out of memory"); - goto bail; - } - - /* Retrieve the PPQN value, needed for playback */ - SDL_RWread(src, &division, 1, 2); - mididata->division = BE_SHORT(division); - - - for (i=0; itrack[i].len = size; - mididata->track[i].data = malloc(size); - if (NULL == mididata->track[i].data) - { - Mix_SetError("Out of memory"); - goto bail; - } - SDL_RWread(src, mididata->track[i].data, 1, size); - } - return 1; - -bail: - for(;i >= 0; i--) - { - if (mididata->track[i].data) - free(mididata->track[i].data); - } - - return 0; -} - -MIDIEvent *CreateMIDIEventList(SDL_RWops *src, Uint16 *division) -{ - MIDIFile *mididata = NULL; - MIDIEvent *eventList; - int trackID; - - mididata = calloc(1, sizeof(MIDIFile)); - if (!mididata) - return NULL; - - /* Open the file */ - if ( src != NULL ) - { - /* Read in the data */ - if ( ! ReadMIDIFile(mididata, src)) - { - free(mididata); - return NULL; - } - } - else - { - free(mididata); - return NULL; - } - - if (division) - *division = mididata->division; - - eventList = MIDItoStream(mididata); - if (eventList == NULL) - { - free(mididata); - return NULL; - } - for(trackID = 0; trackID < mididata->nTracks; trackID++) - { - if (mididata->track[trackID].data) - free(mididata->track[trackID].data); - } - free(mididata->track); - free(mididata); - - return eventList; -} - -void FreeMIDIEventList(MIDIEvent *head) -{ - MIDIEvent *cur, *next; - - cur = head; - - while (cur) - { - next = cur->next; - if (cur->extraData) - free (cur->extraData); - free (cur); - cur = next; - } -} diff --git a/native_midi/native_midi_common.h b/native_midi/native_midi_common.h deleted file mode 100644 index 438d53d..0000000 --- a/native_midi/native_midi_common.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - native_midi: Hardware Midi support for the SDL_mixer library - Copyright (C) 2000,2001 Florian 'Proff' Schulze - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef _NATIVE_MIDI_COMMON_H_ -#define _NATIVE_MIDI_COMMON_H_ - -#include "SDL.h" - -/* Midi Status Bytes */ -#define MIDI_STATUS_NOTE_OFF 0x8 -#define MIDI_STATUS_NOTE_ON 0x9 -#define MIDI_STATUS_AFTERTOUCH 0xA -#define MIDI_STATUS_CONTROLLER 0xB -#define MIDI_STATUS_PROG_CHANGE 0xC -#define MIDI_STATUS_PRESSURE 0xD -#define MIDI_STATUS_PITCH_WHEEL 0xE -#define MIDI_STATUS_SYSEX 0xF - -/* We store the midi events in a linked list; this way it is - easy to shuffle the tracks together later on; and we are - flexible in the size of each elemnt. - */ -typedef struct MIDIEvent -{ - Uint32 time; /* Time at which this midi events occurs */ - Uint8 status; /* Status byte */ - Uint8 data[2]; /* 1 or 2 bytes additional data for most events */ - - Uint32 extraLen; /* For some SysEx events, we need additional storage */ - Uint8 *extraData; - - struct MIDIEvent *next; -} MIDIEvent; - - -/* Load a midifile to memory, converting it to a list of MIDIEvents. - This function returns a linked lists of MIDIEvents, 0 if an error occured. - */ -MIDIEvent *CreateMIDIEventList(SDL_RWops *rw, Uint16 *division); - -/* Release a MIDIEvent list after usage. */ -void FreeMIDIEventList(MIDIEvent *head); - - -#endif /* _NATIVE_MIDI_COMMON_H_ */ diff --git a/native_midi/native_midi_haiku.cpp b/native_midi/native_midi_haiku.cpp deleted file mode 100644 index 81b847e..0000000 --- a/native_midi/native_midi_haiku.cpp +++ /dev/null @@ -1,295 +0,0 @@ -/* - native_midi_haiku: Native Midi support on Haiku for the SDL_mixer library - Copyright (C) 2010 Egor Suvorov - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_config.h" - -#ifdef __HAIKU__ -#include -#include -#include -#include -#include -#include -#include -#include -extern "C" { -#include "native_midi.h" -#include "native_midi_common.h" -} - -bool compareMIDIEvent(const MIDIEvent &a, const MIDIEvent &b) -{ - return a.time < b.time; -} - -class MidiEventsStore : public BMidi -{ - public: - MidiEventsStore() - { - fPlaying = false; - fLoops = 0; - } - virtual status_t Import(SDL_RWops *src) - { - fEvs = CreateMIDIEventList(src, &fDivision); - if (!fEvs) { - return B_BAD_MIDI_DATA; - } - fTotal = 0; - for (MIDIEvent *x = fEvs; x; x = x->next) fTotal++; - fPos = fTotal; - - sort_events(); - return B_OK; - } - virtual void Run() - { - fPlaying = true; - fPos = 0; - MIDIEvent *ev = fEvs; - - uint32 startTime = B_NOW; - while (KeepRunning()) - { - if (!ev) { - if (fLoops && fEvs) { - if (fLoops > 0) --fLoops; - fPos = 0; - ev = fEvs; - } else - break; - } - SprayEvent(ev, ev->time + startTime); - ev = ev->next; - fPos++; - } - fPos = fTotal; - fPlaying = false; - } - virtual ~MidiEventsStore() - { - if (!fEvs) return; - FreeMIDIEventList(fEvs); - fEvs = 0; - } - - bool IsPlaying() - { - return fPlaying; - } - - void SetLoops(int loops) - { - fLoops = loops; - } - - protected: - MIDIEvent *fEvs; - Uint16 fDivision; - - int fPos, fTotal; - int fLoops; - bool fPlaying; - - void SprayEvent(MIDIEvent *ev, uint32 time) - { - switch (ev->status & 0xF0) - { - case B_NOTE_OFF: - SprayNoteOff((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time); - break; - case B_NOTE_ON: - SprayNoteOn((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time); - break; - case B_KEY_PRESSURE: - SprayKeyPressure((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time); - break; - case B_CONTROL_CHANGE: - SprayControlChange((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time); - break; - case B_PROGRAM_CHANGE: - SprayProgramChange((ev->status & 0x0F) + 1, ev->data[0], time); - break; - case B_CHANNEL_PRESSURE: - SprayChannelPressure((ev->status & 0x0F) + 1, ev->data[0], time); - break; - case B_PITCH_BEND: - SprayPitchBend((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time); - break; - case 0xF: - switch (ev->status) - { - case B_SYS_EX_START: - SpraySystemExclusive(ev->extraData, ev->extraLen, time); - break; - case B_MIDI_TIME_CODE: - case B_SONG_POSITION: - case B_SONG_SELECT: - case B_CABLE_MESSAGE: - case B_TUNE_REQUEST: - case B_SYS_EX_END: - SpraySystemCommon(ev->status, ev->data[0], ev->data[1], time); - break; - case B_TIMING_CLOCK: - case B_START: - case B_STOP: - case B_CONTINUE: - case B_ACTIVE_SENSING: - SpraySystemRealTime(ev->status, time); - break; - case B_SYSTEM_RESET: - if (ev->data[0] == 0x51 && ev->data[1] == 0x03) - { - assert(ev->extraLen == 3); - int val = (ev->extraData[0] << 16) | (ev->extraData[1] << 8) | ev->extraData[2]; - int tempo = 60000000 / val; - SprayTempoChange(tempo, time); - } - else - { - SpraySystemRealTime(ev->status, time); - } - } - break; - } - } - - void sort_events() - { - MIDIEvent *items = new MIDIEvent[fTotal]; - MIDIEvent *x = fEvs; - for (int i = 0; i < fTotal; i++) - { - memcpy(items + i, x, sizeof(MIDIEvent)); - x = x->next; - } - std::sort(items, items + fTotal, compareMIDIEvent); - - x = fEvs; - for (int i = 0; i < fTotal; i++) - { - MIDIEvent *ne = x->next; - memcpy(x, items + i, sizeof(MIDIEvent)); - x->next = ne; - x = ne; - } - - for (x = fEvs; x && x->next; x = x->next) - assert(x->time <= x->next->time); - - delete[] items; - } -}; - -BMidiSynth synth; -struct _NativeMidiSong { - MidiEventsStore *store; -} *currentSong = NULL; - -char lasterr[1024]; - -int native_midi_detect(void) -{ - status_t res = synth.EnableInput(true, false); - return res == B_OK; -} - -void native_midi_setvolume(int volume) -{ - if (volume < 0) volume = 0; - if (volume > 128) volume = 128; - synth.SetVolume(volume / 128.0); -} - -NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc) -{ - NativeMidiSong *song = new NativeMidiSong; - song->store = new MidiEventsStore; - status_t res = song->store->Import(src); - - if (res != B_OK) - { - snprintf(lasterr, sizeof lasterr, "Cannot Import() midi file: status_t=%d", res); - delete song->store; - delete song; - return NULL; - } - else - { - if (freesrc) { - SDL_RWclose(src); - } - } - return song; -} - -void native_midi_freesong(NativeMidiSong *song) -{ - if (song == NULL) return; - song->store->Stop(); - song->store->Disconnect(&synth); - if (currentSong == song) - { - currentSong = NULL; - } - delete song->store; - delete song; song = 0; -} - -void native_midi_start(NativeMidiSong *song, int loops) -{ - native_midi_stop(); - song->store->Connect(&synth); - song->store->SetLoops(loops); - song->store->Start(); - currentSong = song; -} - -void native_midi_pause(void) -{ -} - -void native_midi_resume(void) -{ -} - -void native_midi_stop(void) -{ - if (currentSong == NULL) return; - currentSong->store->Stop(); - currentSong->store->Disconnect(&synth); - while (currentSong->store->IsPlaying()) - usleep(1000); - currentSong = NULL; -} - -int native_midi_active(void) -{ - if (currentSong == NULL) return 0; - return currentSong->store->IsPlaying(); -} - -const char* native_midi_error(void) -{ - return lasterr; -} - -#endif /* __HAIKU__ */ diff --git a/native_midi/native_midi_mac.c b/native_midi/native_midi_mac.c deleted file mode 100644 index 24a3942..0000000 --- a/native_midi/native_midi_mac.c +++ /dev/null @@ -1,649 +0,0 @@ -/* - native_midi_mac: Native Midi support on MacOS for the SDL_mixer library - Copyright (C) 2001 Max Horn - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_config.h" -#include "SDL_endian.h" -#include "../mixer.h" - -#if __MACOS__ /*|| __MACOSX__ */ - -#include "native_midi.h" -#include "native_midi_common.h" - -#if __MACOSX__ -#include -#else -#include -#endif - -#include -#include -#include - - -/* Native Midi song */ -struct _NativeMidiSong -{ - Uint32 *tuneSequence; - Uint32 *tuneHeader; -}; - -enum -{ - /* number of (32-bit) long words in a note request event */ - kNoteRequestEventLength = ((sizeof(NoteRequest)/sizeof(long)) + 2), - - /* number of (32-bit) long words in a marker event */ - kMarkerEventLength = 1, - - /* number of (32-bit) long words in a general event, minus its data */ - kGeneralEventLength = 2 -}; - -#define ERROR_BUF_SIZE 256 -#define BUFFER_INCREMENT 5000 - -#define REST_IF_NECESSARY() do {\ - int timeDiff = eventPos->time - lastEventTime; \ - if(timeDiff) \ - { \ - timeDiff = (int)(timeDiff*tick); \ - qtma_StuffRestEvent(*tunePos, timeDiff); \ - tunePos++; \ - lastEventTime = eventPos->time; \ - } \ - } while(0) - - -static Uint32 *BuildTuneSequence(MIDIEvent *evntlist, int ppqn, int part_poly_max[32], int part_to_inst[32], int *numParts); -static Uint32 *BuildTuneHeader(int part_poly_max[32], int part_to_inst[32], int numParts); - -/* The global TunePlayer instance */ -static TunePlayer gTunePlayer = NULL; -static int gInstaceCount = 0; -static Uint32 *gCurrentTuneSequence = NULL; -static char gErrorBuffer[ERROR_BUF_SIZE] = ""; - - -/* Check whether QuickTime is available */ -int native_midi_detect(void) -{ - /* TODO */ - return 1; -} - -NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc) -{ - NativeMidiSong *song = NULL; - MIDIEvent *evntlist = NULL; - int part_to_inst[32]; - int part_poly_max[32]; - int numParts = 0; - Uint16 ppqn; - - /* Init the arrays */ - memset(part_poly_max,0,sizeof(part_poly_max)); - memset(part_to_inst,-1,sizeof(part_to_inst)); - - /* Attempt to load the midi file */ - evntlist = CreateMIDIEventList(src, &ppqn); - if (!evntlist) - goto bail; - - /* Allocate memory for the song struct */ - song = malloc(sizeof(NativeMidiSong)); - if (!song) - goto bail; - - /* Build a tune sequence from the event list */ - song->tuneSequence = BuildTuneSequence(evntlist, ppqn, part_poly_max, part_to_inst, &numParts); - if(!song->tuneSequence) - goto bail; - - /* Now build a tune header from the data we collect above, create - all parts as needed and assign them the correct instrument. - */ - song->tuneHeader = BuildTuneHeader(part_poly_max, part_to_inst, numParts); - if(!song->tuneHeader) - goto bail; - - /* Increment the instance count */ - gInstaceCount++; - if (gTunePlayer == NULL) - gTunePlayer = OpenDefaultComponent(kTunePlayerComponentType, 0); - - /* Finally, free the event list */ - FreeMIDIEventList(evntlist); - - if (freerw) { - SDL_RWclose(rw); - } - return song; - -bail: - if (evntlist) - FreeMIDIEventList(evntlist); - - if (song) - { - if(song->tuneSequence) - free(song->tuneSequence); - - if(song->tuneHeader) - DisposePtr((Ptr)song->tuneHeader); - - free(song); - } - return NULL; -} - -void native_midi_freesong(NativeMidiSong *song) -{ - if(!song || !song->tuneSequence) - return; - - /* If this is the currently playing song, stop it now */ - if (song->tuneSequence == gCurrentTuneSequence) - native_midi_stop(); - - /* Finally, free the data storage */ - free(song->tuneSequence); - DisposePtr((Ptr)song->tuneHeader); - free(song); - - /* Increment the instance count */ - gInstaceCount--; - if ((gTunePlayer != NULL) && (gInstaceCount == 0)) - { - CloseComponent(gTunePlayer); - gTunePlayer = NULL; - } -} - -void native_midi_start(NativeMidiSong *song, int loops) -{ - UInt32 queueFlags = 0; - ComponentResult tpError; - - assert (gTunePlayer != NULL); - - /* FIXME: is this code even used anymore? */ - assert (loops == 0); - - SDL_PauseAudio(1); - Mix_UnlockAudio(); - - /* First, stop the currently playing music */ - native_midi_stop(); - - /* Set up the queue flags */ - queueFlags = kTuneStartNow; - - /* Set the time scale (units per second), we want milliseconds */ - tpError = TuneSetTimeScale(gTunePlayer, 1000); - if (tpError != noErr) - { - strncpy (gErrorBuffer, "MIDI error during TuneSetTimeScale", ERROR_BUF_SIZE); - goto done; - } - - /* Set the header, to tell what instruments are used */ - tpError = TuneSetHeader(gTunePlayer, (UInt32 *)song->tuneHeader); - if (tpError != noErr) - { - strncpy (gErrorBuffer, "MIDI error during TuneSetHeader", ERROR_BUF_SIZE); - goto done; - } - - /* Have it allocate whatever resources are needed */ - tpError = TunePreroll(gTunePlayer); - if (tpError != noErr) - { - strncpy (gErrorBuffer, "MIDI error during TunePreroll", ERROR_BUF_SIZE); - goto done; - } - - /* We want to play at normal volume */ - tpError = TuneSetVolume(gTunePlayer, 0x00010000); - if (tpError != noErr) - { - strncpy (gErrorBuffer, "MIDI error during TuneSetVolume", ERROR_BUF_SIZE); - goto done; - } - - /* Finally, start playing the full song */ - gCurrentTuneSequence = song->tuneSequence; - tpError = TuneQueue(gTunePlayer, (UInt32 *)song->tuneSequence, 0x00010000, 0, 0xFFFFFFFF, queueFlags, NULL, 0); - if (tpError != noErr) - { - strncpy (gErrorBuffer, "MIDI error during TuneQueue", ERROR_BUF_SIZE); - goto done; - } - -done: - Mix_LockAudio(); - SDL_PauseAudio(0); -} - -void native_midi_pause(void) -{ -} - -void native_midi_resume(void) -{ -} - -void native_midi_stop(void) -{ - if (gTunePlayer == NULL) - return; - - /* Stop music */ - TuneStop(gTunePlayer, 0); - - /* Deallocate all instruments */ - TuneUnroll(gTunePlayer); -} - -int native_midi_active(void) -{ - if (gTunePlayer != NULL) - { - TuneStatus ts; - - TuneGetStatus(gTunePlayer,&ts); - return ts.queueTime != 0; - } - else - return 0; -} - -void native_midi_setvolume(int volume) -{ - if (gTunePlayer == NULL) - return; - - /* QTMA olume may range from 0.0 to 1.0 (in 16.16 fixed point encoding) */ - TuneSetVolume(gTunePlayer, (0x00010000 * volume)/SDL_MIX_MAXVOLUME); -} - -const char *native_midi_error(void) -{ - return gErrorBuffer; -} - -Uint32 *BuildTuneSequence(MIDIEvent *evntlist, int ppqn, int part_poly_max[32], int part_to_inst[32], int *numParts) -{ - int part_poly[32]; - int channel_to_part[16]; - - int channel_pan[16]; - int channel_vol[16]; - int channel_pitch_bend[16]; - - int lastEventTime = 0; - int tempo = 500000; - double Ippqn = 1.0 / (1000*ppqn); - double tick = tempo * Ippqn; - MIDIEvent *eventPos = evntlist; - MIDIEvent *noteOffPos; - Uint32 *tunePos, *endPos; - Uint32 *tuneSequence; - size_t tuneSize; - - /* allocate space for the tune header */ - tuneSize = 5000; - tuneSequence = (Uint32 *)malloc(tuneSize * sizeof(Uint32)); - if (tuneSequence == NULL) - return NULL; - - /* Set starting position in our tune memory */ - tunePos = tuneSequence; - endPos = tuneSequence + tuneSize; - - /* Initialise the arrays */ - memset(part_poly,0,sizeof(part_poly)); - - memset(channel_to_part,-1,sizeof(channel_to_part)); - memset(channel_pan,-1,sizeof(channel_pan)); - memset(channel_vol,-1,sizeof(channel_vol)); - memset(channel_pitch_bend,-1,sizeof(channel_pitch_bend)); - - *numParts = 0; - - /* - * Now the major work - iterate over all GM events, - * and turn them into QuickTime Music format. - * At the same time, calculate the max. polyphony for each part, - * and also the part->instrument mapping. - */ - while(eventPos) - { - int status = (eventPos->status&0xF0)>>4; - int channel = eventPos->status&0x0F; - int part = channel_to_part[channel]; - int velocity, pitch; - int value, controller; - int bend; - int newInst; - - /* Check if we are running low on space... */ - if((tunePos+16) > endPos) - { - /* Resize our data storage. */ - Uint32 *oldTuneSequence = tuneSequence; - - tuneSize += BUFFER_INCREMENT; - tuneSequence = (Uint32 *)realloc(tuneSequence, tuneSize * sizeof(Uint32)); - if(oldTuneSequence != tuneSequence) - tunePos += tuneSequence - oldTuneSequence; - endPos = tuneSequence + tuneSize; - } - - switch (status) - { - case MIDI_STATUS_NOTE_OFF: - assert(part>=0 && part<=31); - - /* Keep track of the polyphony of the current part */ - part_poly[part]--; - break; - case MIDI_STATUS_NOTE_ON: - if (part < 0) - { - /* If no part is specified yet, we default to the first instrument, which - is piano (or the first drum kit if we are on the drum channel) - */ - int newInst; - - if (channel == 9) - newInst = kFirstDrumkit + 1; /* the first drum kit is the "no drum" kit! */ - else - newInst = kFirstGMInstrument; - part = channel_to_part[channel] = *numParts; - part_to_inst[(*numParts)++] = newInst; - } - /* TODO - add support for more than 32 parts using eXtended QTMA events */ - assert(part<=31); - - /* Decode pitch & velocity */ - pitch = eventPos->data[0]; - velocity = eventPos->data[1]; - - if (velocity == 0) - { - /* was a NOTE OFF in disguise, so we decrement the polyphony */ - part_poly[part]--; - } - else - { - /* Keep track of the polyphony of the current part */ - int foo = ++part_poly[part]; - if (part_poly_max[part] < foo) - part_poly_max[part] = foo; - - /* Now scan forward to find the matching NOTE OFF event */ - for(noteOffPos = eventPos; noteOffPos; noteOffPos = noteOffPos->next) - { - if ((noteOffPos->status&0xF0)>>4 == MIDI_STATUS_NOTE_OFF - && channel == (eventPos->status&0x0F) - && pitch == noteOffPos->data[0]) - break; - /* NOTE ON with velocity == 0 is the same as a NOTE OFF */ - if ((noteOffPos->status&0xF0)>>4 == MIDI_STATUS_NOTE_ON - && channel == (eventPos->status&0x0F) - && pitch == noteOffPos->data[0] - && 0 == noteOffPos->data[1]) - break; - } - - /* Did we find a note off? Should always be the case, but who knows... */ - if (noteOffPos) - { - /* We found a NOTE OFF, now calculate the note duration */ - int duration = (int)((noteOffPos->time - eventPos->time)*tick); - - REST_IF_NECESSARY(); - /* Now we need to check if we get along with a normal Note Event, or if we need an extended one... */ - if (duration < 2048 && pitch>=32 && pitch<=95 && velocity>=0 && velocity<=127) - { - qtma_StuffNoteEvent(*tunePos, part, pitch, velocity, duration); - tunePos++; - } - else - { - qtma_StuffXNoteEvent(*tunePos, *(tunePos+1), part, pitch, velocity, duration); - tunePos+=2; - } - } - } - break; - case MIDI_STATUS_AFTERTOUCH: - /* NYI - use kControllerAfterTouch. But how are the parameters to be mapped? */ - break; - case MIDI_STATUS_CONTROLLER: - controller = eventPos->data[0]; - value = eventPos->data[1]; - - switch(controller) - { - case 0: /* bank change - igore for now */ - break; - case kControllerVolume: - if(channel_vol[channel] != value<<8) - { - channel_vol[channel] = value<<8; - if(part>=0 && part<=31) - { - REST_IF_NECESSARY(); - qtma_StuffControlEvent(*tunePos, part, kControllerVolume, channel_vol[channel]); - tunePos++; - } - } - break; - case kControllerPan: - if(channel_pan[channel] != (value << 1) + 256) - { - channel_pan[channel] = (value << 1) + 256; - if(part>=0 && part<=31) - { - REST_IF_NECESSARY(); - qtma_StuffControlEvent(*tunePos, part, kControllerPan, channel_pan[channel]); - tunePos++; - } - } - break; - default: - /* No other controllers implemented yet */; - break; - } - - break; - case MIDI_STATUS_PROG_CHANGE: - /* Instrument changed */ - newInst = eventPos->data[0]; - - /* Channel 9 (the 10th channel) is different, it indicates a drum kit */ - if (channel == 9) - newInst += kFirstDrumkit; - else - newInst += kFirstGMInstrument; - /* Only if the instrument for this channel *really* changed, add a new part. */ - if(newInst != part_to_inst[part]) - { - /* TODO maybe make use of kGeneralEventPartChange here, - to help QT reuse note channels? - */ - part = channel_to_part[channel] = *numParts; - part_to_inst[(*numParts)++] = newInst; - - if(channel_vol[channel] >= 0) - { - REST_IF_NECESSARY(); - qtma_StuffControlEvent(*tunePos, part, kControllerVolume, channel_vol[channel]); - tunePos++; - } - if(channel_pan[channel] >= 0) - { - REST_IF_NECESSARY(); - qtma_StuffControlEvent(*tunePos, part, kControllerPan, channel_pan[channel]); - tunePos++; - } - if(channel_pitch_bend[channel] >= 0) - { - REST_IF_NECESSARY(); - qtma_StuffControlEvent(*tunePos, part, kControllerPitchBend, channel_pitch_bend[channel]); - tunePos++; - } - } - break; - case MIDI_STATUS_PRESSURE: - /* NYI */ - break; - case MIDI_STATUS_PITCH_WHEEL: - /* In the midi spec, 0x2000 = center, 0x0000 = - 2 semitones, 0x3FFF = +2 semitones - but for QTMA, we specify it as a 8.8 fixed point of semitones - TODO: detect "pitch bend range changes" & honor them! - */ - bend = (eventPos->data[0] & 0x7f) | ((eventPos->data[1] & 0x7f) << 7); - - /* "Center" the bend */ - bend -= 0x2000; - - /* Move it to our format: */ - bend <<= 4; - - /* If it turns out the pitch bend didn't change, stop here */ - if(channel_pitch_bend[channel] == bend) - break; - - channel_pitch_bend[channel] = bend; - if(part>=0 && part<=31) - { - /* Stuff a control event */ - REST_IF_NECESSARY(); - qtma_StuffControlEvent(*tunePos, part, kControllerPitchBend, bend); - tunePos++; - } - break; - case MIDI_STATUS_SYSEX: - if (eventPos->status == 0xFF && eventPos->data[0] == 0x51) /* Tempo change */ - { - tempo = (eventPos->extraData[0] << 16) + - (eventPos->extraData[1] << 8) + - eventPos->extraData[2]; - - tick = tempo * Ippqn; - } - break; - } - - /* on to the next event */ - eventPos = eventPos->next; - } - - /* Finally, place an end marker */ - *tunePos = kEndMarkerValue; - - return tuneSequence; -} - -Uint32 *BuildTuneHeader(int part_poly_max[32], int part_to_inst[32], int numParts) -{ - Uint32 *myHeader; - Uint32 *myPos1, *myPos2; /* pointers to the head and tail long words of a music event */ - NoteRequest *myNoteRequest; - NoteAllocator myNoteAllocator; /* for the NAStuffToneDescription call */ - ComponentResult myErr = noErr; - int part; - - myHeader = NULL; - myNoteAllocator = NULL; - - /* - * Open up the Note Allocator - */ - myNoteAllocator = OpenDefaultComponent(kNoteAllocatorComponentType,0); - if (myNoteAllocator == NULL) - goto bail; - - /* - * Allocate space for the tune header - */ - myHeader = (Uint32 *) - NewPtrClear((numParts * kNoteRequestEventLength + kMarkerEventLength) * sizeof(Uint32)); - if (myHeader == NULL) - goto bail; - - myPos1 = myHeader; - - /* - * Loop over all parts - */ - for(part = 0; part < numParts; ++part) - { - /* - * Stuff request for the instrument with the given polyphony - */ - myPos2 = myPos1 + (kNoteRequestEventLength - 1); /* last longword of general event */ - qtma_StuffGeneralEvent(*myPos1, *myPos2, part, kGeneralEventNoteRequest, kNoteRequestEventLength); - myNoteRequest = (NoteRequest *)(myPos1 + 1); - myNoteRequest->info.flags = 0; - /* I'm told by the Apple people that the Quicktime types were poorly designed and it was - * too late to change them. On little endian, the BigEndian(Short|Fixed) types are structs - * while on big endian they are primitive types. Furthermore, Quicktime failed to - * provide setter and getter functions. To get this to work, we need to case the - * code for the two possible situations. - * My assumption is that the right-side value was always expected to be BigEndian - * as it was written way before the Universal Binary transition. So in the little endian - * case, OSSwap is used. - */ -#if SDL_BYTEORDER == SDL_LIL_ENDIAN - myNoteRequest->info.polyphony.bigEndianValue = OSSwapHostToBigInt16(part_poly_max[part]); - myNoteRequest->info.typicalPolyphony.bigEndianValue = OSSwapHostToBigInt32(0x00010000); -#else - myNoteRequest->info.polyphony = part_poly_max[part]; - myNoteRequest->info.typicalPolyphony = 0x00010000; -#endif - myErr = NAStuffToneDescription(myNoteAllocator,part_to_inst[part],&myNoteRequest->tone); - if (myErr != noErr) - goto bail; - - /* move pointer to beginning of next event */ - myPos1 += kNoteRequestEventLength; - } - - *myPos1 = kEndMarkerValue; /* end of sequence marker */ - - -bail: - if(myNoteAllocator) - CloseComponent(myNoteAllocator); - - /* if we encountered an error, dispose of the storage we allocated and return NULL */ - if (myErr != noErr) { - DisposePtr((Ptr)myHeader); - myHeader = NULL; - } - - return myHeader; -} - -#endif /* MacOS native MIDI support */ diff --git a/native_midi/native_midi_macosx.c b/native_midi/native_midi_macosx.c deleted file mode 100644 index 6ee31e0..0000000 --- a/native_midi/native_midi_macosx.c +++ /dev/null @@ -1,347 +0,0 @@ -/* - native_midi_macosx: Native Midi support on Mac OS X for the SDL_mixer library - Copyright (C) 2009 Ryan C. Gordon - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* This is Mac OS X only, using Core MIDI. - Mac OS 9 support via QuickTime is in native_midi_mac.c */ - -#include "SDL_config.h" - -#if __MACOSX__ - -#include /* ComponentDescription */ -#include -#include -#include - -#include "SDL_endian.h" -#include "../SDL_mixer.h" -#include "../mixer.h" -#include "native_midi.h" - -/* Native Midi song */ -struct _NativeMidiSong -{ - MusicPlayer player; - MusicSequence sequence; - MusicTimeStamp endTime; - AudioUnit audiounit; - int loops; -}; - -static NativeMidiSong *currentsong = NULL; -static int latched_volume = MIX_MAX_VOLUME; - -static OSStatus -GetSequenceLength(MusicSequence sequence, MusicTimeStamp *_sequenceLength) -{ - // http://lists.apple.com/archives/Coreaudio-api/2003/Jul/msg00370.html - // figure out sequence length - UInt32 ntracks, i; - MusicTimeStamp sequenceLength = 0; - OSStatus err; - - err = MusicSequenceGetTrackCount(sequence, &ntracks); - if (err != noErr) - return err; - - for (i = 0; i < ntracks; ++i) - { - MusicTrack track; - MusicTimeStamp tracklen = 0; - UInt32 tracklenlen = sizeof (tracklen); - - err = MusicSequenceGetIndTrack(sequence, i, &track); - if (err != noErr) - return err; - - err = MusicTrackGetProperty(track, kSequenceTrackProperty_TrackLength, - &tracklen, &tracklenlen); - if (err != noErr) - return err; - - if (sequenceLength < tracklen) - sequenceLength = tracklen; - } - - *_sequenceLength = sequenceLength; - - return noErr; -} - - -/* we're looking for the sequence output audiounit. */ -static OSStatus -GetSequenceAudioUnit(MusicSequence sequence, AudioUnit *aunit) -{ - AUGraph graph; - UInt32 nodecount, i; - OSStatus err; - - err = MusicSequenceGetAUGraph(sequence, &graph); - if (err != noErr) - return err; - - err = AUGraphGetNodeCount(graph, &nodecount); - if (err != noErr) - return err; - - for (i = 0; i < nodecount; i++) { - AUNode node; - - if (AUGraphGetIndNode(graph, i, &node) != noErr) - continue; /* better luck next time. */ - -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 /* this is deprecated, but works back to 10.0 */ - { - struct ComponentDescription desc; - UInt32 classdatasize = 0; - void *classdata = NULL; - err = AUGraphGetNodeInfo(graph, node, &desc, &classdatasize, - &classdata, aunit); - if (err != noErr) - continue; - else if (desc.componentType != kAudioUnitType_Output) - continue; - else if (desc.componentSubType != kAudioUnitSubType_DefaultOutput) - continue; - } - #else /* not deprecated, but requires 10.5 or later */ - { - # if !defined(AUDIO_UNIT_VERSION) || ((AUDIO_UNIT_VERSION + 0) < 1060) - /* AUGraphAddNode () is changed to take an AudioComponentDescription* - * desc parameter instead of a ComponentDescription* in the 10.6 SDK. - * AudioComponentDescription is in 10.6 or newer, but it is actually - * the same as struct ComponentDescription with 20 bytes of size and - * the same offsets of all members, therefore, is binary compatible. */ - # define AudioComponentDescription ComponentDescription - # endif - AudioComponentDescription desc; - if (AUGraphNodeInfo(graph, node, &desc, aunit) != noErr) - continue; - else if (desc.componentType != kAudioUnitType_Output) - continue; - else if (desc.componentSubType != kAudioUnitSubType_DefaultOutput) - continue; - } - #endif - - return noErr; /* found it! */ - } - - return kAUGraphErr_NodeNotFound; -} - - -int native_midi_detect(void) -{ - return 1; /* always available. */ -} - -NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc) -{ - NativeMidiSong *retval = NULL; - void *buf = NULL; - Sint64 len = 0; - CFDataRef data = NULL; - - if (SDL_RWseek(src, 0, RW_SEEK_END) < 0) - goto fail; - len = SDL_RWtell(src); - if (len < 0) - goto fail; - if (SDL_RWseek(src, 0, RW_SEEK_SET) < 0) - goto fail; - - buf = malloc(len); - if (buf == NULL) - goto fail; - - if (SDL_RWread(src, buf, len, 1) != 1) - goto fail; - - retval = malloc(sizeof(NativeMidiSong)); - if (retval == NULL) - goto fail; - - memset(retval, '\0', sizeof (*retval)); - - if (NewMusicPlayer(&retval->player) != noErr) - goto fail; - if (NewMusicSequence(&retval->sequence) != noErr) - goto fail; - - data = CFDataCreate(NULL, (const UInt8 *) buf, len); - if (data == NULL) - goto fail; - - free(buf); - buf = NULL; - - #if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 - /* MusicSequenceLoadSMFData() (avail. in 10.2, no 64 bit) is - * equivalent to calling MusicSequenceLoadSMFDataWithFlags() - * with a flags value of 0 (avail. in 10.3, avail. 64 bit). - * So, we use MusicSequenceLoadSMFData() for powerpc versions - * but the *WithFlags() on intel which require 10.4 anyway. */ - # if defined(__ppc__) || defined(__POWERPC__) - if (MusicSequenceLoadSMFData(song->sequence, data) != noErr) - goto fail; - # else - if (MusicSequenceLoadSMFDataWithFlags(retval->sequence, data, 0) != noErr) - goto fail; - # endif - #else /* MusicSequenceFileLoadData() requires 10.5 or later. */ - if (MusicSequenceFileLoadData(retval->sequence, data, 0, 0) != noErr) - goto fail; - #endif - - CFRelease(data); - data = NULL; - - if (GetSequenceLength(retval->sequence, &retval->endTime) != noErr) - goto fail; - - if (MusicPlayerSetSequence(retval->player, retval->sequence) != noErr) - goto fail; - - if (freesrc) - SDL_RWclose(src); - - return retval; - -fail: - if (retval) { - if (retval->sequence) - DisposeMusicSequence(retval->sequence); - if (retval->player) - DisposeMusicPlayer(retval->player); - free(retval); - } - - if (data) - CFRelease(data); - - if (buf) - free(buf); - - return NULL; -} - -void native_midi_freesong(NativeMidiSong *song) -{ - if (song != NULL) { - if (currentsong == song) - currentsong = NULL; - MusicPlayerStop(song->player); - DisposeMusicSequence(song->sequence); - DisposeMusicPlayer(song->player); - free(song); - } -} - -void native_midi_start(NativeMidiSong *song, int loops) -{ - int vol; - - if (song == NULL) - return; - - SDL_PauseAudio(1); - Mix_UnlockAudio(); - - if (currentsong) - MusicPlayerStop(currentsong->player); - - currentsong = song; - currentsong->loops = loops; - - MusicPlayerPreroll(song->player); - MusicPlayerSetTime(song->player, 0); - MusicPlayerStart(song->player); - - GetSequenceAudioUnit(song->sequence, &song->audiounit); - - vol = latched_volume; - latched_volume++; /* just make this not match. */ - native_midi_setvolume(vol); - - Mix_LockAudio(); - SDL_PauseAudio(0); -} - -void native_midi_pause(void) -{ -} - -void native_midi_resume(void) -{ -} - -void native_midi_stop(void) -{ - if (currentsong) { - SDL_PauseAudio(1); - Mix_UnlockAudio(); - MusicPlayerStop(currentsong->player); - currentsong = NULL; - Mix_LockAudio(); - SDL_PauseAudio(0); - } -} - -int native_midi_active(void) -{ - MusicTimeStamp currentTime = 0; - if (currentsong == NULL) - return 0; - - MusicPlayerGetTime(currentsong->player, ¤tTime); - if ((currentTime < currentsong->endTime) || - (currentTime >= kMusicTimeStamp_EndOfTrack)) { - return 1; - } else if (currentsong->loops) { - --currentsong->loops; - MusicPlayerSetTime(currentsong->player, 0); - return 1; - } - return 0; -} - -void native_midi_setvolume(int volume) -{ - if (latched_volume == volume) - return; - - latched_volume = volume; - if ((currentsong) && (currentsong->audiounit)) { - const float floatvol = ((float) volume) / ((float) MIX_MAX_VOLUME); - AudioUnitSetParameter(currentsong->audiounit, kHALOutputParam_Volume, - kAudioUnitScope_Global, 0, floatvol, 0); - } -} - -const char *native_midi_error(void) -{ - return ""; /* !!! FIXME */ -} - -#endif /* Mac OS X native MIDI support */ - diff --git a/native_midi/native_midi_win32.c b/native_midi/native_midi_win32.c deleted file mode 100644 index 44bb055..0000000 --- a/native_midi/native_midi_win32.c +++ /dev/null @@ -1,321 +0,0 @@ -/* - native_midi: Hardware Midi support for the SDL_mixer library - Copyright (C) 2000,2001 Florian 'Proff' Schulze - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_config.h" - -/* everything below is currently one very big bad hack ;) Proff */ - -#if __WIN32__ -#define WIN32_LEAN_AND_MEAN -#include -#include -#include -#include -#include -#include -#include "native_midi.h" -#include "native_midi_common.h" - -struct _NativeMidiSong { - int MusicLoaded; - int MusicPlaying; - int Loops; - int CurrentHdr; - MIDIHDR MidiStreamHdr[2]; - MIDIEVENT *NewEvents; - Uint16 ppqn; - int Size; - int NewPos; -}; - -static UINT MidiDevice=MIDI_MAPPER; -static HMIDISTRM hMidiStream; -static NativeMidiSong *currentsong; - -static int BlockOut(NativeMidiSong *song) -{ - MMRESULT err; - int BlockSize; - MIDIHDR *hdr; - - if ((song->MusicLoaded) && (song->NewEvents)) - { - // proff 12/8/98: Added for safety - song->CurrentHdr = !song->CurrentHdr; - hdr = &song->MidiStreamHdr[song->CurrentHdr]; - midiOutUnprepareHeader((HMIDIOUT)hMidiStream,hdr,sizeof(MIDIHDR)); - if (song->NewPos>=song->Size) - return 0; - BlockSize=(song->Size-song->NewPos); - if (BlockSize<=0) - return 0; - if (BlockSize>36000) - BlockSize=36000; - hdr->lpData=(void *)((unsigned char *)song->NewEvents+song->NewPos); - song->NewPos+=BlockSize; - hdr->dwBufferLength=BlockSize; - hdr->dwBytesRecorded=BlockSize; - hdr->dwFlags=0; - hdr->dwOffset=0; - err=midiOutPrepareHeader((HMIDIOUT)hMidiStream,hdr,sizeof(MIDIHDR)); - if (err!=MMSYSERR_NOERROR) - return 0; - err=midiStreamOut(hMidiStream,hdr,sizeof(MIDIHDR)); - return 0; - } - return 1; -} - -static void MIDItoStream(NativeMidiSong *song, MIDIEvent *evntlist) -{ - int eventcount; - MIDIEvent *event; - MIDIEVENT *newevent; - - eventcount=0; - event=evntlist; - while (event) - { - eventcount++; - event=event->next; - } - song->NewEvents=malloc(eventcount*3*sizeof(DWORD)); - if (!song->NewEvents) - return; - memset(song->NewEvents,0,(eventcount*3*sizeof(DWORD))); - - eventcount=0; - event=evntlist; - newevent=song->NewEvents; - while (event) - { - int status = (event->status&0xF0)>>4; - switch (status) - { - case MIDI_STATUS_NOTE_OFF: - case MIDI_STATUS_NOTE_ON: - case MIDI_STATUS_AFTERTOUCH: - case MIDI_STATUS_CONTROLLER: - case MIDI_STATUS_PROG_CHANGE: - case MIDI_STATUS_PRESSURE: - case MIDI_STATUS_PITCH_WHEEL: - newevent->dwDeltaTime=event->time; - newevent->dwEvent=(event->status|0x80)|(event->data[0]<<8)|(event->data[1]<<16)|(MEVT_SHORTMSG<<24); - newevent=(MIDIEVENT*)((char*)newevent+(3*sizeof(DWORD))); - eventcount++; - break; - - case MIDI_STATUS_SYSEX: - if (event->status == 0xFF && event->data[0] == 0x51) /* Tempo change */ - { - int tempo = (event->extraData[0] << 16) | - (event->extraData[1] << 8) | - event->extraData[2]; - newevent->dwDeltaTime=event->time; - newevent->dwEvent=(MEVT_TEMPO<<24) | tempo; - newevent=(MIDIEVENT*)((char*)newevent+(3*sizeof(DWORD))); - eventcount++; - } - break; - } - - event=event->next; - } - - song->Size=eventcount*3*sizeof(DWORD); - - { - int time; - int temptime; - - song->NewPos=0; - time=0; - newevent=song->NewEvents; - while (song->NewPosSize) - { - temptime=newevent->dwDeltaTime; - newevent->dwDeltaTime-=time; - time=temptime; - if ((song->NewPos+12)>=song->Size) - newevent->dwEvent |= MEVT_F_CALLBACK; - newevent=(MIDIEVENT*)((char*)newevent+(3*sizeof(DWORD))); - song->NewPos+=12; - } - } - song->NewPos=0; - song->MusicLoaded=1; -} - -void CALLBACK MidiProc( HMIDIIN hMidi, UINT uMsg, DWORD_PTR dwInstance, - DWORD_PTR dwParam1, DWORD_PTR dwParam2 ) -{ - switch( uMsg ) - { - case MOM_DONE: - if ((currentsong->MusicLoaded) && (dwParam1 == (DWORD_PTR)¤tsong->MidiStreamHdr[currentsong->CurrentHdr])) - BlockOut(currentsong); - break; - case MOM_POSITIONCB: - if ((currentsong->MusicLoaded) && (dwParam1 == (DWORD_PTR)¤tsong->MidiStreamHdr[currentsong->CurrentHdr])) { - if (currentsong->Loops) { - if (currentsong->Loops > 0) - --currentsong->Loops; - currentsong->NewPos=0; - BlockOut(currentsong); - } else { - currentsong->MusicPlaying=0; - } - } - break; - default: - break; - } -} - -int native_midi_detect(void) -{ - MMRESULT merr; - HMIDISTRM MidiStream; - - merr=midiStreamOpen(&MidiStream,&MidiDevice,(DWORD)1,(DWORD_PTR)MidiProc,(DWORD_PTR)0,CALLBACK_FUNCTION); - if (merr!=MMSYSERR_NOERROR) - return 0; - midiStreamClose(MidiStream); - return 1; -} - -NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc) -{ - NativeMidiSong *newsong; - MIDIEvent *evntlist = NULL; - - newsong=malloc(sizeof(NativeMidiSong)); - if (!newsong) { - return NULL; - } - memset(newsong,0,sizeof(NativeMidiSong)); - - /* Attempt to load the midi file */ - evntlist = CreateMIDIEventList(src, &newsong->ppqn); - if (!evntlist) - { - free(newsong); - return NULL; - } - - MIDItoStream(newsong, evntlist); - - FreeMIDIEventList(evntlist); - - if (freesrc) { - SDL_RWclose(src); - } - return newsong; -} - -void native_midi_freesong(NativeMidiSong *song) -{ - if (hMidiStream) - { - midiStreamStop(hMidiStream); - midiStreamClose(hMidiStream); - } - if (song) - { - if (song->NewEvents) - free(song->NewEvents); - free(song); - } -} - -void native_midi_start(NativeMidiSong *song, int loops) -{ - MMRESULT merr; - MIDIPROPTIMEDIV mptd; - - native_midi_stop(); - if (!hMidiStream) - { - merr=midiStreamOpen(&hMidiStream,&MidiDevice,(DWORD)1,(DWORD_PTR)MidiProc,(DWORD_PTR)0,CALLBACK_FUNCTION); - if (merr!=MMSYSERR_NOERROR) - { - hMidiStream = NULL; // should I do midiStreamClose(hMidiStream) before? - return; - } - //midiStreamStop(hMidiStream); - currentsong=song; - currentsong->NewPos=0; - currentsong->MusicPlaying=1; - currentsong->Loops=loops; - mptd.cbStruct=sizeof(MIDIPROPTIMEDIV); - mptd.dwTimeDiv=currentsong->ppqn; - merr=midiStreamProperty(hMidiStream,(LPBYTE)&mptd,MIDIPROP_SET | MIDIPROP_TIMEDIV); - BlockOut(song); - merr=midiStreamRestart(hMidiStream); - } -} - -void native_midi_pause(void) -{ - if (!hMidiStream) - return; - midiStreamPause(hMidiStream); -} - -void native_midi_resume(void) -{ - if (!hMidiStream) - return; - midiStreamRestart(hMidiStream); -} - -void native_midi_stop(void) -{ - if (!hMidiStream) - return; - midiStreamStop(hMidiStream); - midiStreamClose(hMidiStream); - currentsong=NULL; - hMidiStream = NULL; -} - -int native_midi_active(void) -{ - return currentsong->MusicPlaying; -} - -void native_midi_setvolume(int volume) -{ - int calcVolume; - if (volume > 128) - volume = 128; - if (volume < 0) - volume = 0; - calcVolume = (65535 * volume / 128); - - midiOutSetVolume((HMIDIOUT)hMidiStream, MAKELONG(calcVolume , calcVolume)); -} - -const char *native_midi_error(void) -{ - return ""; -} - -#endif /* Windows native MIDI support */ diff --git a/playmus.c b/playmus.c index 744407e..ffe4dff 100644 --- a/playmus.c +++ b/playmus.c @@ -1,6 +1,6 @@ /* PLAYMUS: A test application for the SDL mixer library. - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2021 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -22,7 +22,7 @@ /* Quiet windows compiler warnings */ #define _CRT_SECURE_NO_WARNINGS -/* $Id$ */ +#include "SDL_stdinc.h" #include #include @@ -67,6 +67,7 @@ SDL_Log("Usage: %s [-i] [-l] [-8] [-f32] [-r rate] [-c channels] [-b buffers] [-v N] [-rwops] \n", argv0); } +/*#define SEEK_TEST */ void Menu(void) { char buf[10]; @@ -75,6 +76,13 @@ fflush(stdin); if (scanf("%s",buf) == 1) { switch(buf[0]){ +#if defined(SEEK_TEST) + case '0': Mix_SetMusicPosition(0); break; + case '1': Mix_SetMusicPosition(10);break; + case '2': Mix_SetMusicPosition(20);break; + case '3': Mix_SetMusicPosition(30);break; + case '4': Mix_SetMusicPosition(40);break; +#endif /* SEEK_TEST */ case 'p': case 'P': Mix_PauseMusic(); break; @@ -117,11 +125,19 @@ int interactive = 0; int rwops = 0; int i; + const char *typ; + const char *tag_title = NULL; + const char *tag_artist = NULL; + const char *tag_album = NULL; + const char *tag_copyright = NULL; + double loop_start, loop_end, loop_length, current_position; + + (void) argc; /* Initialize variables */ - audio_rate = 22050; - audio_format = AUDIO_S16; - audio_channels = 2; + audio_rate = MIX_DEFAULT_FREQUENCY; + audio_format = MIX_DEFAULT_FORMAT; + audio_channels = MIX_DEFAULT_CHANNELS; audio_buffers = 4096; /* Check command line usage */ @@ -215,14 +231,81 @@ CleanUp(2); } + switch (Mix_GetMusicType(music)) { + case MUS_CMD: + typ = "CMD"; + break; + case MUS_WAV: + typ = "WAV"; + break; + case MUS_MOD: + case MUS_MODPLUG_UNUSED: + typ = "MOD"; + break; + case MUS_FLAC: + typ = "FLAC"; + break; + case MUS_MID: + typ = "MIDI"; + break; + case MUS_OGG: + typ = "OGG Vorbis"; + break; + case MUS_MP3: + case MUS_MP3_MAD_UNUSED: + typ = "MP3"; + break; + case MUS_OPUS: + typ = "OPUS"; + break; + case MUS_NONE: + default: + typ = "NONE"; + break; + } + SDL_Log("Detected music type: %s", typ); + + tag_title = Mix_GetMusicTitleTag(music); + if (tag_title && SDL_strlen(tag_title) > 0) { + SDL_Log("Title: %s", tag_title); + } + + tag_artist = Mix_GetMusicArtistTag(music); + if (tag_artist && SDL_strlen(tag_artist) > 0) { + SDL_Log("Artist: %s", tag_artist); + } + + tag_album = Mix_GetMusicAlbumTag(music); + if (tag_album && SDL_strlen(tag_album) > 0) { + SDL_Log("Album: %s", tag_album); + } + + tag_copyright = Mix_GetMusicCopyrightTag(music); + if (tag_copyright && SDL_strlen(tag_copyright) > 0) { + SDL_Log("Copyright: %s", tag_copyright); + } + + loop_start = Mix_GetMusicLoopStartTime(music); + loop_end = Mix_GetMusicLoopEndTime(music); + loop_length = Mix_GetMusicLoopLengthTime(music); + /* Play and then exit */ - SDL_Log("Playing %s\n", argv[i]); + SDL_Log("Playing %s, duration %f\n", argv[i], Mix_MusicDuration(music)); + if (loop_start > 0.0 && loop_end > 0.0 && loop_length > 0.0) { + SDL_Log("Loop points: start %g s, end %g s, length %g s\n", loop_start, loop_end, loop_length); + } Mix_FadeInMusic(music,looping,2000); while (!next_track && (Mix_PlayingMusic() || Mix_PausedMusic())) { if(interactive) Menu(); - else + else { + current_position = Mix_GetMusicPosition(music); + if (current_position >= 0.0) { + printf("Position: %g seconds \r", current_position); + fflush(stdout); + } SDL_Delay(100); + } } Mix_FreeMusic(music); music = NULL; diff --git a/playwave.c b/playwave.c index e98bd55..58dc1f0 100644 --- a/playwave.c +++ b/playwave.c @@ -1,6 +1,6 @@ /* PLAYWAVE: A test application for the SDL mixer library. - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2021 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -19,7 +19,7 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* $Id$ */ +#include "SDL_stdinc.h" #include #include @@ -118,15 +118,15 @@ static void test_versions(void) { SDL_version compiled; - const SDL_version *linked; + SDL_version linked; SDL_VERSION(&compiled); - linked = SDL_Linked_Version(); - output_versions("SDL", &compiled, linked); + SDL_GetVersion(&linked); + output_versions("SDL", &compiled, &linked); SDL_MIXER_VERSION(&compiled); - linked = Mix_Linked_Version(); - output_versions("SDL_mixer", &compiled, linked); + SDL_memcpy(&linked, Mix_Linked_Version(), sizeof(SDL_version)); + output_versions("SDL_mixer", &compiled, &linked); } #endif @@ -137,7 +137,7 @@ { Mix_Chunk *done_chunk = Mix_GetChunk(chan); SDL_Log("We were just alerted that Mixer channel #%d is done.\n", chan); - SDL_Log("Channel's chunk pointer is (%p).\n", done_chunk); + SDL_Log("Channel's chunk pointer is (%p).\n", (void*)done_chunk); SDL_Log(" Which %s correct.\n", (wave == done_chunk) ? "is" : "is NOT"); channel_is_done = 1; } @@ -160,8 +160,8 @@ { static Uint8 leftvol = 128; static Uint8 rightvol = 128; - static Uint8 leftincr = -1; - static Uint8 rightincr = 1; + static Sint8 leftincr = -1; + static Sint8 rightincr = 1; static int panningok = 1; static Uint32 next_panning_update = 0; @@ -174,14 +174,16 @@ } if ((leftvol == 255) || (leftvol == 0)) { - if (leftvol == 255) + if (leftvol == 255) { SDL_Log("All the way in the left speaker.\n"); - leftincr *= -1; + } + leftincr *= -1; } if ((rightvol == 255) || (rightvol == 0)) { - if (rightvol == 255) + if (rightvol == 255) { SDL_Log("All the way in the right speaker.\n"); + } rightincr *= -1; } @@ -197,7 +199,7 @@ static void do_distance_update(void) { static Uint8 distance = 1; - static Uint8 distincr = 1; + static Sint8 distincr = 1; static int distanceok = 1; static Uint32 next_distance_update = 0; @@ -229,13 +231,13 @@ { static Sint16 distance = 1; static Sint8 distincr = 1; - static Uint16 angle = 0; + static Sint16 angle = 0; static Sint8 angleincr = 1; static int positionok = 1; static Uint32 next_position_update = 0; if ((positionok) && (SDL_GetTicks() >= next_position_update)) { - positionok = Mix_SetPosition(0, angle, distance); + positionok = Mix_SetPosition(0, angle, (Uint8)distance); if (!positionok) { SDL_Log("Mix_SetPosition(0, %d, %d) failed!\n", (int) angle, (int) distance); @@ -253,7 +255,6 @@ } distance += distincr; - if (distance < 0) { distance = 0; distincr = 3; @@ -365,6 +366,8 @@ int reverse_stereo = 0; int reverse_sample = 0; + (void) argc; + #ifdef HAVE_SETBUF setbuf(stdout, NULL); /* rcg06132001 for debugging purposes. */ setbuf(stderr, NULL); /* rcg06192001 for debugging purposes, too. */ @@ -374,7 +377,7 @@ /* Initialize variables */ audio_rate = MIX_DEFAULT_FREQUENCY; audio_format = MIX_DEFAULT_FORMAT; - audio_channels = 2; + audio_channels = MIX_DEFAULT_CHANNELS; /* Check command line usage */ for (i=1; argv[i] && (*argv[i] == '-'); ++i) { diff --git a/src/codecs/load_aiff.c b/src/codecs/load_aiff.c new file mode 100644 index 0000000..5d88a11 --- /dev/null +++ b/src/codecs/load_aiff.c @@ -0,0 +1,247 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + This is the source needed to decode an AIFF file into a waveform. + It's pretty straightforward once you get going. The only + externally-callable function is Mix_LoadAIFF_RW(), which is meant to + act as identically to SDL_LoadWAV_RW() as possible. + + This file by Torbjörn Andersson (torbjorn.andersson@eurotime.se) + 8SVX file support added by Marc Le Douarain (mavati@club-internet.fr) + in december 2002. +*/ + +#include "SDL_endian.h" +#include "SDL_mixer.h" +#include "load_aiff.h" + +/*********************************************/ +/* Define values for AIFF (IFF audio) format */ +/*********************************************/ +#define FORM 0x4d524f46 /* "FORM" */ + +#define AIFF 0x46464941 /* "AIFF" */ +#define SSND 0x444e5353 /* "SSND" */ +#define COMM 0x4d4d4f43 /* "COMM" */ + +#define _8SVX 0x58565338 /* "8SVX" */ +#define VHDR 0x52444856 /* "VHDR" */ +#define BODY 0x59444F42 /* "BODY" */ + +/* This function was taken from libsndfile. I don't pretend to fully + * understand it. + */ + +static Uint32 SANE_to_Uint32 (Uint8 *sanebuf) +{ + /* Is the frequency outside of what we can represent with Uint32? */ + if ((sanebuf[0] & 0x80) || (sanebuf[0] <= 0x3F) || (sanebuf[0] > 0x40) + || (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C)) + return 0; + + return ((sanebuf[2] << 23) | (sanebuf[3] << 15) | (sanebuf[4] << 7) + | (sanebuf[5] >> 1)) >> (29 - sanebuf[1]); +} + +/* This function is based on SDL_LoadWAV_RW(). */ + +SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc, + SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) +{ + int was_error; + int found_SSND; + int found_COMM; + int found_VHDR; + int found_BODY; + Sint64 start = 0; + + Uint32 chunk_type; + Uint32 chunk_length; + Sint64 next_chunk; + + /* AIFF magic header */ + Uint32 FORMchunk; + Uint32 AIFFmagic; + + /* SSND chunk */ + Uint32 offset; + Uint32 blocksize; + + /* COMM format chunk */ + Uint16 channels = 0; + Uint32 numsamples = 0; + Uint16 samplesize = 0; + Uint8 sane_freq[10]; + Uint32 frequency = 0; + + /* Make sure we are passed a valid data source */ + was_error = 0; + if (src == NULL) { + was_error = 1; + goto done; + } + + FORMchunk = SDL_ReadLE32(src); + chunk_length = SDL_ReadBE32(src); + if (chunk_length == AIFF) { /* The FORMchunk has already been read */ + AIFFmagic = chunk_length; + chunk_length = FORMchunk; + FORMchunk = FORM; + } else { + AIFFmagic = SDL_ReadLE32(src); + } + if ((FORMchunk != FORM) || ((AIFFmagic != AIFF) && (AIFFmagic != _8SVX))) { + SDL_SetError("Unrecognized file type (not AIFF nor 8SVX)"); + was_error = 1; + goto done; + } + + /* TODO: Better santity-checking. */ + + found_SSND = 0; + found_COMM = 0; + found_VHDR = 0; + found_BODY = 0; + + do { + chunk_type = SDL_ReadLE32(src); + chunk_length = SDL_ReadBE32(src); + next_chunk = SDL_RWtell(src) + chunk_length; + /* Paranoia to avoid infinite loops */ + if (chunk_length == 0) + break; + + switch (chunk_type) { + case SSND: + found_SSND = 1; + offset = SDL_ReadBE32(src); + blocksize = SDL_ReadBE32(src); + start = SDL_RWtell(src) + offset; + (void)blocksize; /* unused. */ + break; + + case COMM: + found_COMM = 1; + channels = SDL_ReadBE16(src); + numsamples = SDL_ReadBE32(src); + samplesize = SDL_ReadBE16(src); + SDL_RWread(src, sane_freq, sizeof(sane_freq), 1); + frequency = SANE_to_Uint32(sane_freq); + if (frequency == 0) { + SDL_SetError("Bad AIFF sample frequency"); + was_error = 1; + goto done; + } + break; + + case VHDR: + found_VHDR = 1; + SDL_ReadBE32(src); + SDL_ReadBE32(src); + SDL_ReadBE32(src); + frequency = SDL_ReadBE16(src); + channels = 1; + samplesize = 8; + break; + + case BODY: + found_BODY = 1; + numsamples = chunk_length; + start = SDL_RWtell(src); + break; + + default: + break; + } + /* a 0 pad byte can be stored for any odd-length chunk */ + if (chunk_length&1) + next_chunk++; + } while ((((AIFFmagic == AIFF) && (!found_SSND || !found_COMM)) + || ((AIFFmagic == _8SVX) && (!found_VHDR || !found_BODY))) + && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != 1); + + if ((AIFFmagic == AIFF) && !found_SSND) { + SDL_SetError("Bad AIFF (no SSND chunk)"); + was_error = 1; + goto done; + } + + if ((AIFFmagic == AIFF) && !found_COMM) { + SDL_SetError("Bad AIFF (no COMM chunk)"); + was_error = 1; + goto done; + } + + if ((AIFFmagic == _8SVX) && !found_VHDR) { + SDL_SetError("Bad 8SVX (no VHDR chunk)"); + was_error = 1; + goto done; + } + + if ((AIFFmagic == _8SVX) && !found_BODY) { + SDL_SetError("Bad 8SVX (no BODY chunk)"); + was_error = 1; + goto done; + } + + /* Decode the audio data format */ + SDL_memset(spec, 0, sizeof(*spec)); + spec->freq = frequency; + switch (samplesize) { + case 8: + spec->format = AUDIO_S8; + break; + case 16: + spec->format = AUDIO_S16MSB; + break; + default: + SDL_SetError("Unsupported AIFF samplesize"); + was_error = 1; + goto done; + } + spec->channels = (Uint8) channels; + spec->samples = 4096; /* Good default buffer size */ + + *audio_len = channels * numsamples * (samplesize / 8); + *audio_buf = (Uint8 *)SDL_malloc(*audio_len); + if (*audio_buf == NULL) { + SDL_SetError("Out of memory"); + return(NULL); + } + SDL_RWseek(src, start, RW_SEEK_SET); + if (SDL_RWread(src, *audio_buf, *audio_len, 1) != 1) { + SDL_SetError("Unable to read audio data"); + return(NULL); + } + + /* Don't return a buffer that isn't a multiple of samplesize */ + *audio_len &= ~((samplesize / 8) - 1); + +done: + if (freesrc && src) { + SDL_RWclose(src); + } + if (was_error) { + spec = NULL; + } + return(spec); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/load_aiff.h b/src/codecs/load_aiff.h new file mode 100644 index 0000000..4c41f90 --- /dev/null +++ b/src/codecs/load_aiff.h @@ -0,0 +1,33 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + This is the source needed to decode an AIFF file into a waveform. + It's pretty straightforward once you get going. The only + externally-callable function is Mix_LoadAIFF_RW(), which is meant to + act as identically to SDL_LoadWAV_RW() as possible. + + This file by Torbjörn Andersson (torbjorn.andersson@eurotime.se) +*/ + +/* Don't call this directly; use Mix_LoadWAV_RW() for now. */ +SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc, + SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/load_voc.c b/src/codecs/load_voc.c new file mode 100644 index 0000000..7e3447d --- /dev/null +++ b/src/codecs/load_voc.c @@ -0,0 +1,454 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + This is the source needed to decode a Creative Labs VOC file into a + waveform. It's pretty straightforward once you get going. The only + externally-callable function is Mix_LoadVOC_RW(), which is meant to + act as identically to SDL_LoadWAV_RW() as possible. + + This file by Ryan C. Gordon (icculus@icculus.org). + + Heavily borrowed from sox v12.17.1's voc.c. + (http://www.freshmeat.net/projects/sox/) +*/ + +#include "SDL_mixer.h" +#include "load_voc.h" + +/* Private data for VOC file */ +typedef struct vocstuff { + Uint32 rest; /* bytes remaining in current block */ + Uint32 rate; /* rate code (byte) of this chunk */ + int silent; /* sound or silence? */ + Uint32 srate; /* rate code (byte) of silence */ + Uint32 blockseek; /* start of current output block */ + Uint32 samples; /* number of samples output */ + Uint32 size; /* word length of data */ + Uint8 channels; /* number of sound channels */ + int has_extended; /* Has an extended block been read? */ +} vs_t; + +/* Size field */ +/* SJB: note that the 1st 3 are sometimes used as sizeof(type) */ +#define ST_SIZE_BYTE 1 +#define ST_SIZE_8BIT 1 +#define ST_SIZE_WORD 2 +#define ST_SIZE_16BIT 2 +#define ST_SIZE_DWORD 4 +#define ST_SIZE_32BIT 4 +#define ST_SIZE_FLOAT 5 +#define ST_SIZE_DOUBLE 6 +#define ST_SIZE_IEEE 7 /* IEEE 80-bit floats. */ + +/* Style field */ +#define ST_ENCODING_UNSIGNED 1 /* unsigned linear: Sound Blaster */ +#define ST_ENCODING_SIGN2 2 /* signed linear 2's comp: Mac */ +#define ST_ENCODING_ULAW 3 /* U-law signed logs: US telephony, SPARC */ +#define ST_ENCODING_ALAW 4 /* A-law signed logs: non-US telephony */ +#define ST_ENCODING_ADPCM 5 /* Compressed PCM */ +#define ST_ENCODING_IMA_ADPCM 6 /* Compressed PCM */ +#define ST_ENCODING_GSM 7 /* GSM 6.10 33-byte frame lossy compression */ + +#define VOC_TERM 0 +#define VOC_DATA 1 +#define VOC_CONT 2 +#define VOC_SILENCE 3 +#define VOC_MARKER 4 +#define VOC_TEXT 5 +#define VOC_LOOP 6 +#define VOC_LOOPEND 7 +#define VOC_EXTENDED 8 +#define VOC_DATA_16 9 + +#define VOC_BAD_RATE ~((Uint32)0) + + +static int voc_check_header(SDL_RWops *src) +{ + /* VOC magic header */ + Uint8 signature[20]; /* "Creative Voice File\032" */ + Uint16 datablockofs; + + SDL_RWseek(src, 0, RW_SEEK_SET); + + if (SDL_RWread(src, signature, sizeof (signature), 1) != 1) + return(0); + + if (SDL_memcmp(signature, "Creative Voice File\032", sizeof (signature)) != 0) { + SDL_SetError("Unrecognized file type (not VOC)"); + return(0); + } + + /* get the offset where the first datablock is located */ + if (SDL_RWread(src, &datablockofs, sizeof (Uint16), 1) != 1) + return(0); + + datablockofs = SDL_SwapLE16(datablockofs); + + if (SDL_RWseek(src, datablockofs, RW_SEEK_SET) != datablockofs) + return(0); + + return(1); /* success! */ +} /* voc_check_header */ + + +/* Read next block header, save info, leave position at start of data */ +static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec) +{ + Uint8 bits24[3]; + Uint8 uc, block; + Uint32 sblen; + Uint16 new_rate_short; + Uint32 new_rate_long; + Uint8 trash[6]; + Uint16 period; + unsigned int i; + + v->silent = 0; + while (v->rest == 0) + { + if (SDL_RWread(src, &block, sizeof (block), 1) != 1) + return 1; /* assume that's the end of the file. */ + + if (block == VOC_TERM) + return 1; + + if (SDL_RWread(src, bits24, sizeof (bits24), 1) != 1) + return 1; /* assume that's the end of the file. */ + + /* Size is an 24-bit value. Ugh. */ + sblen = (Uint32)((bits24[0]) | (bits24[1] << 8) | (bits24[2] << 16)); + + switch(block) + { + case VOC_DATA: + if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1) + return 0; + + /* When DATA block preceeded by an EXTENDED */ + /* block, the DATA blocks rate value is invalid */ + if (!v->has_extended) + { + if (uc == 0) + { + SDL_SetError("VOC Sample rate is zero?"); + return 0; + } + + if ((v->rate != VOC_BAD_RATE) && (uc != v->rate)) + { + SDL_SetError("VOC sample rate codes differ"); + return 0; + } + + v->rate = uc; + spec->freq = (Uint16)(1000000.0/(256 - v->rate)); + v->channels = 1; + } + + if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1) + return 0; + + if (uc != 0) + { + SDL_SetError("VOC decoder only interprets 8-bit data"); + return 0; + } + + v->has_extended = 0; + v->rest = sblen - 2; + v->size = ST_SIZE_BYTE; + return 1; + + case VOC_DATA_16: + if (SDL_RWread(src, &new_rate_long, sizeof (new_rate_long), 1) != 1) + return 0; + new_rate_long = SDL_SwapLE32(new_rate_long); + if (new_rate_long == 0) + { + SDL_SetError("VOC Sample rate is zero?"); + return 0; + } + if ((v->rate != VOC_BAD_RATE) && (new_rate_long != v->rate)) + { + SDL_SetError("VOC sample rate codes differ"); + return 0; + } + v->rate = new_rate_long; + spec->freq = (int)new_rate_long; + + if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1) + return 0; + + switch (uc) + { + case 8: v->size = ST_SIZE_BYTE; break; + case 16: v->size = ST_SIZE_WORD; break; + default: + SDL_SetError("VOC with unknown data size"); + return 0; + } + + if (SDL_RWread(src, &v->channels, sizeof (Uint8), 1) != 1) + return 0; + + if (SDL_RWread(src, trash, sizeof (Uint8), 6) != 6) + return 0; + + v->rest = sblen - 12; + return 1; + + case VOC_CONT: + v->rest = sblen; + return 1; + + case VOC_SILENCE: + if (SDL_RWread(src, &period, sizeof (period), 1) != 1) + return 0; + period = SDL_SwapLE16(period); + + if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1) + return 0; + if (uc == 0) + { + SDL_SetError("VOC silence sample rate is zero"); + return 0; + } + + /* + * Some silence-packed files have gratuitously + * different sample rate codes in silence. + * Adjust period. + */ + if ((v->rate != VOC_BAD_RATE) && (uc != v->rate)) + period = (Uint16)((period * (256 - uc))/(256 - v->rate)); + else + v->rate = uc; + v->rest = period; + v->silent = 1; + return 1; + + case VOC_LOOP: + case VOC_LOOPEND: + for(i = 0; i < sblen; i++) /* skip repeat loops. */ + { + if (SDL_RWread(src, trash, sizeof (Uint8), 1) != 1) + return 0; + } + break; + + case VOC_EXTENDED: + /* An Extended block is followed by a data block */ + /* Set this byte so we know to use the rate */ + /* value from the extended block and not the */ + /* data block. */ + v->has_extended = 1; + if (SDL_RWread(src, &new_rate_short, sizeof (new_rate_short), 1) != 1) + return 0; + new_rate_short = SDL_SwapLE16(new_rate_short); + if (new_rate_short == 0) + { + SDL_SetError("VOC sample rate is zero"); + return 0; + } + if ((v->rate != VOC_BAD_RATE) && (new_rate_short != v->rate)) + { + SDL_SetError("VOC sample rate codes differ"); + return 0; + } + v->rate = new_rate_short; + + if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1) + return 0; + + if (uc != 0) + { + SDL_SetError("VOC decoder only interprets 8-bit data"); + return 0; + } + + if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1) + return 0; + + if (uc) + spec->channels = 2; /* Stereo */ + /* VOC_EXTENDED may be read before spec->channels inited: */ + else spec->channels = 1; + /* Needed number of channels before finishing + compute for rate */ + spec->freq = (256000000L/(65536L - v->rate))/spec->channels; + /* An extended block must be followed by a data */ + /* block to be valid so loop back to top so it */ + /* can be grabed. */ + continue; + + case VOC_MARKER: + if (SDL_RWread(src, trash, sizeof (Uint8), 2) != 2) + return 0; + + /* fallthrough */ + + default: /* text block or other krapola. */ + for(i = 0; i < sblen; i++) + { + if (SDL_RWread(src, &trash, sizeof (Uint8), 1) != 1) + return 0; + } + + if (block == VOC_TEXT) + continue; /* get next block */ + } + } + + return 1; +} + + +static Uint32 voc_read(SDL_RWops *src, vs_t *v, Uint8 *buf, SDL_AudioSpec *spec) +{ + Uint32 done = 0; + Uint8 silence = 0x80; + + if (v->rest == 0) + { + if (!voc_get_block(src, v, spec)) + return 0; + } + + if (v->rest == 0) + return 0; + + if (v->silent) + { + if (v->size == ST_SIZE_WORD) + silence = 0x00; + + /* Fill in silence */ + SDL_memset(buf, silence, v->rest); + done = v->rest; + v->rest = 0; + } + + else + { + done = (Uint32)SDL_RWread(src, buf, 1, v->rest); + v->rest -= done; + if (v->size == ST_SIZE_WORD) + { + #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + Uint16 *samples = (Uint16 *)buf; + for (; v->rest > 0; v->rest -= 2) + { + *samples = SDL_SwapLE16(*samples); + samples++; + } + #endif + done >>= 1; + } + } + + return done; +} /* voc_read */ + + +/* don't call this directly; use Mix_LoadWAV_RW() for now. */ +SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc, + SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) +{ + vs_t v; + int was_error = 1; + int samplesize; + Uint8 *fillptr; + void *ptr; + + if ((!src) || (!audio_buf) || (!audio_len)) /* sanity checks. */ + goto done; + + if (!voc_check_header(src)) + goto done; + + v.rate = VOC_BAD_RATE; + v.rest = 0; + v.has_extended = 0; + *audio_buf = NULL; + *audio_len = 0; + SDL_memset(spec, '\0', sizeof (SDL_AudioSpec)); + + if (!voc_get_block(src, &v, spec)) + goto done; + + if (v.rate == VOC_BAD_RATE) { + SDL_SetError("VOC data had no sound!"); + goto done; + } + + spec->format = ((v.size == ST_SIZE_WORD) ? AUDIO_S16 : AUDIO_U8); + if (spec->channels == 0) + spec->channels = v.channels; + + *audio_len = v.rest; + *audio_buf = SDL_malloc(v.rest); + if (*audio_buf == NULL) + goto done; + + fillptr = *audio_buf; + + while (voc_read(src, &v, fillptr, spec)) + { + if (!voc_get_block(src, &v, spec)) + goto done; + + *audio_len += v.rest; + ptr = SDL_realloc(*audio_buf, *audio_len); + if (ptr == NULL) + { + SDL_free(*audio_buf); + *audio_buf = NULL; + *audio_len = 0; + goto done; + } + + *audio_buf = ptr; + fillptr = ((Uint8 *) ptr) + (*audio_len - v.rest); + } + + spec->samples = (Uint16)(*audio_len / v.size); + + was_error = 0; /* success, baby! */ + + /* Don't return a buffer that isn't a multiple of samplesize */ + samplesize = ((spec->format & 0xFF)/8)*spec->channels; + *audio_len &= (Uint32) ~(samplesize-1); + +done: + if (freesrc && src) { + SDL_RWclose(src); + } + + if (was_error) { + spec = NULL; + } + + return(spec); +} /* Mix_LoadVOC_RW */ + +/* end of load_voc.c ... */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/load_voc.h b/src/codecs/load_voc.h new file mode 100644 index 0000000..4e3bc1c --- /dev/null +++ b/src/codecs/load_voc.h @@ -0,0 +1,36 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + This is the source needed to decode a Creative Labs VOC file into a + waveform. It's pretty straightforward once you get going. The only + externally-callable function is Mix_LoadVOC_RW(), which is meant to + act as identically to SDL_LoadWAV_RW() as possible. + + This file by Ryan C. Gordon (icculus@icculus.org). + + Heavily borrowed from sox v12.17.1's voc.c. + (http://www.freshmeat.net/projects/sox/) +*/ + +/* Don't call this directly; use Mix_LoadWAV_RW() for now. */ +SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc, + SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/mp3utils.c b/src/codecs/mp3utils.c new file mode 100644 index 0000000..36e507e --- /dev/null +++ b/src/codecs/mp3utils.c @@ -0,0 +1,450 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* Functions to discard MP3 tags - + * written by O.Sezer , put into public domain. + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_rwops.h" + +#include "mp3utils.h" + +#if defined(MUSIC_MP3_MAD) || defined(MUSIC_MP3_MPG123) + +/*********************** SDL_RW WITH BOOKKEEPING ************************/ + +int MP3_RWinit(struct mp3file_t *fil, SDL_RWops *src) { + /* Don't use SDL_RWsize() here -- see SDL bug #5509 */ + fil->src = src; + fil->start = SDL_RWtell(src); + fil->length = SDL_RWseek(src, 0, RW_SEEK_END) - fil->start; + fil->pos = 0; + if (fil->start < 0 || fil->length < 0) { + return SDL_Error(SDL_EFSEEK); + } + SDL_RWseek(src, fil->start, RW_SEEK_SET); + return 0; +} + +size_t MP3_RWread(struct mp3file_t *fil, void *ptr, size_t size, size_t maxnum) { + size_t remaining = (size_t)(fil->length - fil->pos); + size_t ret; + maxnum *= size; + if (maxnum > remaining) maxnum = remaining; + ret = SDL_RWread(fil->src, ptr, 1, maxnum); + fil->pos += (Sint64)ret; + return ret; +} + +Sint64 MP3_RWseek(struct mp3file_t *fil, Sint64 offset, int whence) { + Sint64 ret; + switch (whence) { + case RW_SEEK_CUR: + offset += fil->pos; + break; + case RW_SEEK_END: + offset += fil->length; + break; + } + if (offset < 0) return -1; + if (offset > fil->length) + offset = fil->length; + ret = SDL_RWseek(fil->src, fil->start + offset, RW_SEEK_SET); + if (ret < 0) return ret; + fil->pos = offset; + return offset; +} + + +/*************************** TAG HANDLING: ******************************/ + +static SDL_INLINE SDL_bool is_id3v1(const unsigned char *data, long length) { + /* http://id3.org/ID3v1 : 3 bytes "TAG" identifier and 125 bytes tag data */ + if (length < 128 || SDL_memcmp(data,"TAG",3) != 0) { + return SDL_FALSE; + } + return SDL_TRUE; +} +static SDL_bool is_id3v2(const unsigned char *data, size_t length) { + /* ID3v2 header is 10 bytes: http://id3.org/id3v2.4.0-structure */ + /* bytes 0-2: "ID3" identifier */ + if (length < 10 || SDL_memcmp(data,"ID3",3) != 0) { + return SDL_FALSE; + } + /* bytes 3-4: version num (major,revision), each byte always less than 0xff. */ + if (data[3] == 0xff || data[4] == 0xff) { + return SDL_FALSE; + } + /* bytes 6-9 are the ID3v2 tag size: a 32 bit 'synchsafe' integer, i.e. the + * highest bit 7 in each byte zeroed. i.e.: 7 bit information in each byte -> + * effectively a 28 bit value. */ + if (data[6] >= 0x80 || data[7] >= 0x80 || data[8] >= 0x80 || data[9] >= 0x80) { + return SDL_FALSE; + } + return SDL_TRUE; +} +static long get_id3v2_len(const unsigned char *data, long length) { + /* size is a 'synchsafe' integer (see above) */ + long size = (long)((data[6]<<21) + (data[7]<<14) + (data[8]<<7) + data[9]); + size += 10; /* header size */ + /* ID3v2 header[5] is flags (bits 4-7 only, 0-3 are zero). + * bit 4 set: footer is present (a copy of the header but + * with "3DI" as ident.) */ + if (data[5] & 0x10) { + size += 10; /* footer size */ + } + /* optional padding (always zeroes) */ + while (size < length && data[size] == 0) { + ++size; + } + return size; +} +static SDL_bool is_apetag(const unsigned char *data, size_t length) { + /* http://wiki.hydrogenaud.io/index.php?title=APEv2_specification + * Header/footer is 32 bytes: bytes 0-7 ident, bytes 8-11 version, + * bytes 12-17 size. bytes 24-31 are reserved: must be all zeroes. */ + Uint32 v; + + if (length < 32 || SDL_memcmp(data,"APETAGEX",8) != 0) { + return SDL_FALSE; + } + v = (Uint32)((data[11]<<24) | (data[10]<<16) | (data[9]<<8) | data[8]); /* version */ + if (v != 2000U && v != 1000U) { + return SDL_FALSE; + } + v = 0; /* reserved bits : */ + if (SDL_memcmp(&data[24],&v,4) != 0 || SDL_memcmp(&data[28],&v,4) != 0) { + return SDL_FALSE; + } + return SDL_TRUE; +} +static long get_ape_len(const unsigned char *data) { + Uint32 flags, version; + long size = (long)((data[15]<<24) | (data[14]<<16) | (data[13]<<8) | data[12]); + version = (Uint32)((data[11]<<24) | (data[10]<<16) | (data[9]<<8) | data[8]); + flags = (Uint32)((data[23]<<24) | (data[22]<<16) | (data[21]<<8) | data[20]); + if (version == 2000U && (flags & (1U<<31))) size += 32; /* header present. */ + return size; +} +static SDL_INLINE int is_lyrics3tag(const unsigned char *data, long length) { + /* http://id3.org/Lyrics3 + * http://id3.org/Lyrics3v2 */ + if (length < 15) return 0; + if (SDL_memcmp(data+6,"LYRICS200",9) == 0) return 2; /* v2 */ + if (SDL_memcmp(data+6,"LYRICSEND",9) == 0) return 1; /* v1 */ + return 0; +} +static long get_lyrics3v1_len(struct mp3file_t *m) { + const char *p; long i, len; + char buf[5104]; + /* needs manual search: http://id3.org/Lyrics3 */ + if (m->length < 20) return -1; + len = (m->length > 5109)? 5109 : (long)m->length; + MP3_RWseek(m, -len, RW_SEEK_END); + MP3_RWread(m, buf, 1, (len -= 9)); /* exclude footer */ + /* strstr() won't work here. */ + for (i = len - 11, p = buf; i >= 0; --i, ++p) { + if (SDL_memcmp(p, "LYRICSBEGIN", 11) == 0) + break; + } + if (i < 0) return -1; + return len - (long)(p - buf) + 9 /* footer */; +} +static SDL_INLINE long get_lyrics3v2_len(const unsigned char *data, long length) { + /* 6 bytes before the end marker is size in decimal format - + * does not include the 9 bytes end marker and size field. */ + if (length != 6) return 0; + return SDL_strtol((const char *)data, NULL, 10) + 15; +} +static SDL_INLINE SDL_bool verify_lyrics3v2(const unsigned char *data, long length) { + if (length < 11) return SDL_FALSE; + if (SDL_memcmp(data,"LYRICSBEGIN",11) == 0) return SDL_TRUE; + return SDL_FALSE; +} +#define MMTAG_PARANOID +static SDL_bool is_musicmatch(const unsigned char *data, long length) { + /* From docs/musicmatch.txt in id3lib: https://sourceforge.net/projects/id3lib/ + Overall tag structure: + + +-----------------------------+ + | Header | + | (256 bytes, OPTIONAL) | + +-----------------------------+ + | Image extension (4 bytes) | + +-----------------------------+ + | Image binary | + | (var. length >= 4 bytes) | + +-----------------------------+ + | Unused (4 bytes) | + +-----------------------------+ + | Version info (256 bytes) | + +-----------------------------+ + | Audio meta-data | + | (var. length >= 7868 bytes) | + +-----------------------------+ + | Data offsets (20 bytes) | + +-----------------------------+ + | Footer (48 bytes) | + +-----------------------------+ + */ + if (length < 48) return SDL_FALSE; + /* sig: 19 bytes company name + 13 bytes space */ + if (SDL_memcmp(data,"Brava Software Inc. ",32) != 0) { + return SDL_FALSE; + } + /* 4 bytes version: x.xx */ + if (!SDL_isdigit(data[32]) || data[33] != '.' || + !SDL_isdigit(data[34]) ||!SDL_isdigit(data[35])) { + return SDL_FALSE; + } + #ifdef MMTAG_PARANOID + /* [36..47]: 12 bytes trailing space */ + for (length = 36; length < 48; ++length) { + if (data[length] != ' ') return SDL_FALSE; + } + #endif + return SDL_TRUE; +} +static long get_musicmatch_len(struct mp3file_t *m) { + const Sint32 metasizes[4] = { 7868, 7936, 8004, 8132 }; + const unsigned char syncstr[10] = {'1','8','2','7','3','6','4','5',0,0}; + unsigned char buf[256]; + Sint32 i, j, imgext_ofs, version_ofs; + long len; + + MP3_RWseek(m, -68, RW_SEEK_END); + MP3_RWread(m, buf, 1, 20); + imgext_ofs = (Sint32)((buf[3] <<24) | (buf[2] <<16) | (buf[1] <<8) | buf[0] ); + version_ofs = (Sint32)((buf[15]<<24) | (buf[14]<<16) | (buf[13]<<8) | buf[12]); + if (version_ofs <= imgext_ofs) return -1; + if (version_ofs <= 0 || imgext_ofs <= 0) return -1; + /* Try finding the version info section: + * Because metadata section comes after it, and because metadata section + * has different sizes across versions (format ver. <= 3.00: always 7868 + * bytes), we can _not_ directly calculate using deltas from the offsets + * section. */ + for (i = 0; i < 4; ++i) { + /* 48: footer, 20: offsets, 256: version info */ + len = metasizes[i] + 48 + 20 + 256; + if (m->length < len) return -1; + MP3_RWseek(m, -len, RW_SEEK_END); + MP3_RWread(m, buf, 1, 256); + /* [0..9]: sync string, [30..255]: 0x20 */ + #ifdef MMTAG_PARANOID + for (j = 30; j < 256; ++j) { + if (buf[j] != ' ') break; + } + if (j < 256) continue; + #endif + if (SDL_memcmp(buf, syncstr, 10) == 0) { + break; + } + } + if (i == 4) return -1; /* no luck. */ + #ifdef MMTAG_PARANOID + /* unused section: (4 bytes of 0x00) */ + MP3_RWseek(m, -(len + 4), RW_SEEK_END); + MP3_RWread(m, buf, 1, 4); j = 0; + if (SDL_memcmp(buf, &j, 4) != 0) return -1; + #endif + len += (version_ofs - imgext_ofs); + if (m->length < len) return -1; + MP3_RWseek(m, -len, RW_SEEK_END); + MP3_RWread(m, buf, 1, 8); + j = (Sint32)((buf[7] <<24) | (buf[6] <<16) | (buf[5] <<8) | buf[4]); + if (j < 0) return -1; + /* verify image size: */ + /* without this, we may land at a wrong place. */ + if (j + 12 != version_ofs - imgext_ofs) return -1; + /* try finding the optional header */ + if (m->length < len + 256) return len; + MP3_RWseek(m, -(len + 256), RW_SEEK_END); + MP3_RWread(m, buf, 1, 256); + /* [0..9]: sync string, [30..255]: 0x20 */ + if (SDL_memcmp(buf, syncstr, 10) != 0) { + return len; + } + #ifdef MMTAG_PARANOID + for (j = 30; j < 256; ++j) { + if (buf[j] != ' ') return len; + } + #endif + return len + 256; /* header is present. */ +} + +static int probe_id3v1(struct mp3file_t *fil, unsigned char *buf, int atend) { + if (fil->length >= 128) { + MP3_RWseek(fil, -128, RW_SEEK_END); + if (MP3_RWread(fil, buf, 1, 128) != 128) + return -1; + if (is_id3v1(buf, 128)) { + if (!atend) { /* possible false positive? */ + if (is_musicmatch(buf + 128 - 48, 48) || + is_apetag (buf + 128 - 32, 32) || + is_lyrics3tag(buf + 128 - 15, 15)) { + return 0; + } + } + fil->length -= 128; + return 1; + /* FIXME: handle possible double-ID3v1 tags?? */ + } + } + return 0; +} +static int probe_mmtag(struct mp3file_t *fil, unsigned char *buf) { + long len; + if (fil->length >= 68) { + MP3_RWseek(fil, -48, RW_SEEK_END); + if (MP3_RWread(fil, buf, 1, 48) != 48) + return -1; + if (is_musicmatch(buf, 48)) { + len = get_musicmatch_len(fil); + if (len < 0) return -1; + if (len >= fil->length) return -1; + fil->length -= len; + return 1; + } + } + return 0; +} +static int probe_apetag(struct mp3file_t *fil, unsigned char *buf) { + long len; + if (fil->length >= 32) { + MP3_RWseek(fil, -32, RW_SEEK_END); + if (MP3_RWread(fil, buf, 1, 32) != 32) + return -1; + if (is_apetag(buf, 32)) { + len = get_ape_len(buf); + if (len >= fil->length) return -1; + fil->length -= len; + return 1; + } + } + return 0; +} +static int probe_lyrics3(struct mp3file_t *fil, unsigned char *buf) { + long len; + if (fil->length >= 15) { + MP3_RWseek(fil, -15, RW_SEEK_END); + if (MP3_RWread(fil, buf, 1, 15) != 15) + return -1; + len = is_lyrics3tag(buf, 15); + if (len == 2) { + len = get_lyrics3v2_len(buf, 6); + if (len >= fil->length) return -1; + if (len < 15) return -1; + MP3_RWseek(fil, -len, RW_SEEK_END); + if (MP3_RWread(fil, buf, 1, 11) != 11) + return -1; + if (!verify_lyrics3v2(buf, 11)) return -1; + fil->length -= len; + return 1; + } + else if (len == 1) { + len = get_lyrics3v1_len(fil); + if (len < 0) return -1; + fil->length -= len; + return 1; + } + } + return 0; +} + +int mp3_skiptags(struct mp3file_t *fil, SDL_bool keep_id3v2) +{ + unsigned char buf[128]; + long len; size_t readsize; + int c_id3, c_ape, c_lyr, c_mm; + int rc = -1; + + /* MP3 standard has no metadata format, so everyone invented + * their own thing, even with extensions, until ID3v2 became + * dominant: Hence the impossible mess here. + * + * Note: I don't yet care about freaky broken mp3 files with + * double tags. -- O.S. + */ + + readsize = MP3_RWread(fil, buf, 1, 128); + if (!readsize) goto fail; + + /* ID3v2 tag is at the start */ + if (is_id3v2(buf, readsize)) { + len = get_id3v2_len(buf, (long)readsize); + if (len >= fil->length) goto fail; + if (!keep_id3v2) { + fil->start += len; + fil->length -= len; + } + } + /* APE tag _might_ be at the start (discouraged + * but not forbidden, either.) read the header. */ + else if (is_apetag(buf, readsize)) { + len = get_ape_len(buf); + if (len >= fil->length) goto fail; + fil->start += len; + fil->length -= len; + } + + /* it's not impossible that _old_ MusicMatch tag + * placing itself after ID3v1. */ + if ((c_mm = probe_mmtag(fil, buf)) < 0) { + goto fail; + } + /* ID3v1 tag is at the end */ + if ((c_id3 = probe_id3v1(fil, buf, !c_mm)) < 0) { + goto fail; + } + /* we do not know the order of ape or lyrics3 + * or musicmatch tags, hence the loop here.. */ + c_ape = 0; + c_lyr = 0; + for (;;) { + if (!c_lyr) { + /* care about mp3s with double Lyrics3 tags? */ + if ((c_lyr = probe_lyrics3(fil, buf)) < 0) + goto fail; + if (c_lyr) continue; + } + if (!c_mm) { + if ((c_mm = probe_mmtag(fil, buf)) < 0) + goto fail; + if (c_mm) continue; + } + if (!c_ape) { + if ((c_ape = probe_apetag(fil, buf)) < 0) + goto fail; + if (c_ape) continue; + } + break; + } /* for (;;) */ + + rc = (fil->length > 0)? 0 : -1; + fail: + MP3_RWseek(fil, 0, RW_SEEK_SET); + return rc; +} +#endif /* MUSIC_MP3_??? */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/mp3utils.h b/src/codecs/mp3utils.h new file mode 100644 index 0000000..8ff14d9 --- /dev/null +++ b/src/codecs/mp3utils.h @@ -0,0 +1,37 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef MIX_MP3UTILS_H +#define MIX_MP3UTILS_H + +struct mp3file_t { + SDL_RWops *src; + Sint64 start, length, pos; +}; + +extern int mp3_skiptags(struct mp3file_t *fil, SDL_bool keep_id3v2); +extern int MP3_RWinit(struct mp3file_t *fil, SDL_RWops *src); +extern size_t MP3_RWread(struct mp3file_t *fil, void *ptr, size_t size, size_t maxnum); +extern Sint64 MP3_RWseek(struct mp3file_t *fil, Sint64 offset, int whence); + +#endif /* MIX_MP3UTILS_H */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_cmd.c b/src/codecs/music_cmd.c new file mode 100644 index 0000000..7a9156c --- /dev/null +++ b/src/codecs/music_cmd.c @@ -0,0 +1,304 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +/* This file supports an external command for playing music */ + +#ifdef MUSIC_CMD + +#ifdef __APPLE__ +#define _DARWIN_C_SOURCE +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(__linux__) && defined(__arm__) +# include +#endif + +#include "music_cmd.h" + + +typedef struct { + char *file; + char *cmd; + pid_t pid; + int play_count; +} MusicCMD; + + +/* Load a music stream from the given file */ +static void *MusicCMD_CreateFromFile(const char *file) +{ + MusicCMD *music; + + if (!music_cmd) { + Mix_SetError("You must call Mix_SetMusicCMD() first"); + return NULL; + } + + /* Allocate and fill the music structure */ + music = (MusicCMD *)SDL_calloc(1, sizeof *music); + if (music == NULL) { + Mix_SetError("Out of memory"); + return NULL; + } + music->file = SDL_strdup(file); + music->cmd = SDL_strdup(music_cmd); + music->pid = 0; + + /* We're done */ + return music; +} + +/* Parse a command line buffer into arguments */ +static int ParseCommandLine(char *cmdline, char **argv) +{ + char *bufp; + int argc; + + argc = 0; + for (bufp = cmdline; *bufp;) { + /* Skip leading whitespace */ + while (isspace(*bufp)) { + ++bufp; + } + /* Skip over argument */ + if (*bufp == '"') { + ++bufp; + if (*bufp) { + if (argv) { + argv[argc] = bufp; + } + ++argc; + } + /* Skip over word */ + while (*bufp && (*bufp != '"')) { + ++bufp; + } + } else { + if (*bufp) { + if (argv) { + argv[argc] = bufp; + } + ++argc; + } + /* Skip over word */ + while (*bufp && ! isspace(*bufp)) { + ++bufp; + } + } + if (*bufp) { + if (argv) { + *bufp = '\0'; + } + ++bufp; + } + } + if (argv) { + argv[argc] = NULL; + } + return(argc); +} + +static char **parse_args(char *command, char *last_arg) +{ + int argc; + char **argv; + + /* Parse the command line */ + argc = ParseCommandLine(command, NULL); + if (last_arg) { + ++argc; + } + argv = (char **)SDL_malloc((argc+1)*(sizeof *argv)); + if (argv == NULL) { + return(NULL); + } + argc = ParseCommandLine(command, argv); + + /* Add last command line argument */ + if (last_arg) { + argv[argc++] = last_arg; + } + argv[argc] = NULL; + + /* We're ready! */ + return(argv); +} + +/* Start playback of a given music stream */ +static int MusicCMD_Play(void *context, int play_count) +{ + MusicCMD *music = (MusicCMD *)context; + + music->play_count = play_count; +#ifdef HAVE_FORK + music->pid = fork(); +#else + music->pid = vfork(); +#endif + switch(music->pid) { + /* Failed fork() system call */ + case -1: + Mix_SetError("fork() failed"); + return -1; + + /* Child process - executes here */ + case 0: { + char **argv; + + /* Unblock signals in case we're called from a thread */ + { + sigset_t mask; + sigemptyset(&mask); + sigprocmask(SIG_SETMASK, &mask, NULL); + } + + /* Execute the command */ + argv = parse_args(music->cmd, music->file); + if (argv != NULL) { + execvp(argv[0], argv); + + /* exec() failed */ + perror(argv[0]); + } + _exit(-1); + } + break; + + /* Parent process - executes here */ + default: + break; + } + return 0; +} + +/* Return non-zero if a stream is currently playing */ +static SDL_bool MusicCMD_IsPlaying(void *context) +{ + MusicCMD *music = (MusicCMD *)context; + int status; + + if (music->pid > 0) { + waitpid(music->pid, &status, WNOHANG); + if (kill(music->pid, 0) == 0) { + return SDL_TRUE; + } + + /* We might want to loop */ + if (music->play_count != 1) { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + MusicCMD_Play(music, play_count); + return SDL_TRUE; + } + } + return SDL_FALSE; +} + +/* Pause playback of a given music stream */ +static void MusicCMD_Pause(void *context) +{ + MusicCMD *music = (MusicCMD *)context; + if (music->pid > 0) { + kill(music->pid, SIGSTOP); + } +} + +/* Resume playback of a given music stream */ +static void MusicCMD_Resume(void *context) +{ + MusicCMD *music = (MusicCMD *)context; + if (music->pid > 0) { + kill(music->pid, SIGCONT); + } +} + +/* Stop playback of a stream previously started with MusicCMD_Start() */ +static void MusicCMD_Stop(void *context) +{ + MusicCMD *music = (MusicCMD *)context; + int status; + + if (music->pid > 0) { + while (kill(music->pid, 0) == 0) { + kill(music->pid, SIGTERM); + sleep(1); + waitpid(music->pid, &status, WNOHANG); + } + music->pid = 0; + } +} + +/* Close the given music stream */ +void MusicCMD_Delete(void *context) +{ + MusicCMD *music = (MusicCMD *)context; + SDL_free(music->file); + SDL_free(music); +} + +Mix_MusicInterface Mix_MusicInterface_CMD = +{ + "CMD", + MIX_MUSIC_CMD, + MUS_CMD, + SDL_FALSE, + SDL_FALSE, + + NULL, /* Load */ + NULL, /* Open */ + NULL, /* CreateFromRW */ + MusicCMD_CreateFromFile, + NULL, /* SetVolume */ + NULL, /* GetVolume */ + MusicCMD_Play, + MusicCMD_IsPlaying, + NULL, /* GetAudio */ + NULL, /* Jump */ + NULL, /* Seek */ + NULL, /* Tell */ + NULL, /* Duration */ + NULL, /* LoopStart */ + NULL, /* LoopEnd */ + NULL, /* LoopLength */ + NULL, /* GetMetaTag */ + MusicCMD_Pause, + MusicCMD_Resume, + MusicCMD_Stop, + MusicCMD_Delete, + NULL, /* Close */ + NULL /* Unload */ +}; + +#endif /* MUSIC_CMD */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_cmd.h b/src/codecs/music_cmd.h new file mode 100644 index 0000000..a011e2c --- /dev/null +++ b/src/codecs/music_cmd.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports an external command for playing music */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_CMD; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_flac.c b/src/codecs/music_flac.c new file mode 100644 index 0000000..8b89570 --- /dev/null +++ b/src/codecs/music_flac.c @@ -0,0 +1,764 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + This file is used to support SDL_LoadMUS playback of FLAC files. + ~ Austen Dicken (admin@cvpcs.org) +*/ + +#ifdef MUSIC_FLAC + +#include "SDL_loadso.h" +#include "SDL_assert.h" + +#include "music_flac.h" +#include "utils.h" + +#include + + +typedef struct { + int loaded; + void *handle; + FLAC__StreamDecoder *(*FLAC__stream_decoder_new)(void); + void (*FLAC__stream_decoder_delete)(FLAC__StreamDecoder *decoder); + FLAC__StreamDecoderInitStatus (*FLAC__stream_decoder_init_stream)( + FLAC__StreamDecoder *decoder, + FLAC__StreamDecoderReadCallback read_callback, + FLAC__StreamDecoderSeekCallback seek_callback, + FLAC__StreamDecoderTellCallback tell_callback, + FLAC__StreamDecoderLengthCallback length_callback, + FLAC__StreamDecoderEofCallback eof_callback, + FLAC__StreamDecoderWriteCallback write_callback, + FLAC__StreamDecoderMetadataCallback metadata_callback, + FLAC__StreamDecoderErrorCallback error_callback, + void *client_data); + FLAC__bool (*FLAC__stream_decoder_finish)(FLAC__StreamDecoder *decoder); + FLAC__bool (*FLAC__stream_decoder_flush)(FLAC__StreamDecoder *decoder); + FLAC__bool (*FLAC__stream_decoder_process_single)( + FLAC__StreamDecoder *decoder); + FLAC__bool (*FLAC__stream_decoder_process_until_end_of_metadata)( + FLAC__StreamDecoder *decoder); + FLAC__bool (*FLAC__stream_decoder_process_until_end_of_stream)( + FLAC__StreamDecoder *decoder); + FLAC__bool (*FLAC__stream_decoder_seek_absolute)( + FLAC__StreamDecoder *decoder, + FLAC__uint64 sample); + FLAC__StreamDecoderState (*FLAC__stream_decoder_get_state)( + const FLAC__StreamDecoder *decoder); + FLAC__uint64 (*FLAC__stream_decoder_get_total_samples)( + const FLAC__StreamDecoder *decoder); + FLAC__bool (*FLAC__stream_decoder_set_metadata_respond)( + FLAC__StreamDecoder *decoder, + FLAC__MetadataType type); +} flac_loader; + +static flac_loader flac = { + 0, NULL +}; + +#ifdef FLAC_DYNAMIC +#define FUNCTION_LOADER(FUNC, SIG) \ + flac.FUNC = (SIG) SDL_LoadFunction(flac.handle, #FUNC); \ + if (flac.FUNC == NULL) { SDL_UnloadObject(flac.handle); return -1; } +#else +#define FUNCTION_LOADER(FUNC, SIG) \ + flac.FUNC = FUNC; +#endif + +static int FLAC_Load(void) +{ + if (flac.loaded == 0) { +#ifdef FLAC_DYNAMIC + flac.handle = SDL_LoadObject(FLAC_DYNAMIC); + if (flac.handle == NULL) { + return -1; + } +#elif defined(__MACOSX__) + extern FLAC__StreamDecoder *FLAC__stream_decoder_new(void) __attribute__((weak_import)); + if (FLAC__stream_decoder_new == NULL) + { + /* Missing weakly linked framework */ + Mix_SetError("Missing FLAC.framework"); + return -1; + } +#endif + + FUNCTION_LOADER(FLAC__stream_decoder_new, FLAC__StreamDecoder *(*)(void)) + FUNCTION_LOADER(FLAC__stream_decoder_delete, void (*)(FLAC__StreamDecoder *)) + FUNCTION_LOADER(FLAC__stream_decoder_init_stream, FLAC__StreamDecoderInitStatus (*)( + FLAC__StreamDecoder *, + FLAC__StreamDecoderReadCallback, + FLAC__StreamDecoderSeekCallback, + FLAC__StreamDecoderTellCallback, + FLAC__StreamDecoderLengthCallback, + FLAC__StreamDecoderEofCallback, + FLAC__StreamDecoderWriteCallback, + FLAC__StreamDecoderMetadataCallback, + FLAC__StreamDecoderErrorCallback, + void *)) + FUNCTION_LOADER(FLAC__stream_decoder_finish, FLAC__bool (*)(FLAC__StreamDecoder *)) + FUNCTION_LOADER(FLAC__stream_decoder_flush, FLAC__bool (*)(FLAC__StreamDecoder *)) + FUNCTION_LOADER(FLAC__stream_decoder_process_single, FLAC__bool (*)(FLAC__StreamDecoder *)) + FUNCTION_LOADER(FLAC__stream_decoder_process_until_end_of_metadata, FLAC__bool (*)(FLAC__StreamDecoder *)) + FUNCTION_LOADER(FLAC__stream_decoder_process_until_end_of_stream, FLAC__bool (*)(FLAC__StreamDecoder *)) + FUNCTION_LOADER(FLAC__stream_decoder_seek_absolute, FLAC__bool (*)(FLAC__StreamDecoder *, FLAC__uint64)) + FUNCTION_LOADER(FLAC__stream_decoder_get_state, FLAC__StreamDecoderState (*)(const FLAC__StreamDecoder *decoder)) + FUNCTION_LOADER(FLAC__stream_decoder_get_total_samples, + FLAC__uint64 (*)(const FLAC__StreamDecoder *)) + FUNCTION_LOADER(FLAC__stream_decoder_set_metadata_respond, + FLAC__bool (*)(FLAC__StreamDecoder *, + FLAC__MetadataType)) + } + ++flac.loaded; + + return 0; +} + +static void FLAC_Unload(void) +{ + if (flac.loaded == 0) { + return; + } + if (flac.loaded == 1) { +#ifdef FLAC_DYNAMIC + SDL_UnloadObject(flac.handle); +#endif + } + --flac.loaded; +} + + +typedef struct { + int volume; + int play_count; + FLAC__StreamDecoder *flac_decoder; + unsigned sample_rate; + unsigned channels; + unsigned bits_per_sample; + SDL_RWops *src; + int freesrc; + SDL_AudioStream *stream; + int loop; + FLAC__int64 pcm_pos; + FLAC__int64 full_length; + SDL_bool loop_flag; + FLAC__int64 loop_start; + FLAC__int64 loop_end; + FLAC__int64 loop_len; + Mix_MusicMetaTags tags; +} FLAC_Music; + + +static int FLAC_Seek(void *context, double position); + +static FLAC__StreamDecoderReadStatus flac_read_music_cb( + const FLAC__StreamDecoder *decoder, + FLAC__byte buffer[], + size_t *bytes, + void *client_data) +{ + FLAC_Music *data = (FLAC_Music*)client_data; + + (void)decoder; + + /* make sure there is something to be reading */ + if (*bytes > 0) { + *bytes = SDL_RWread (data->src, buffer, sizeof (FLAC__byte), *bytes); + + if (*bytes == 0) { /* error or no data was read (EOF) */ + return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; + } else { /* data was read, continue */ + return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; + } + } else { + return FLAC__STREAM_DECODER_READ_STATUS_ABORT; + } +} + +static FLAC__StreamDecoderSeekStatus flac_seek_music_cb( + const FLAC__StreamDecoder *decoder, + FLAC__uint64 absolute_byte_offset, + void *client_data) +{ + FLAC_Music *data = (FLAC_Music*)client_data; + + (void)decoder; + + if (SDL_RWseek(data->src, (Sint64)absolute_byte_offset, RW_SEEK_SET) < 0) { + return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; + } else { + return FLAC__STREAM_DECODER_SEEK_STATUS_OK; + } +} + +static FLAC__StreamDecoderTellStatus flac_tell_music_cb( + const FLAC__StreamDecoder *decoder, + FLAC__uint64 *absolute_byte_offset, + void *client_data) +{ + FLAC_Music *data = (FLAC_Music*)client_data; + + Sint64 pos = SDL_RWtell(data->src); + + (void)decoder; + + if (pos < 0) { + return FLAC__STREAM_DECODER_TELL_STATUS_ERROR; + } else { + *absolute_byte_offset = (FLAC__uint64)pos; + return FLAC__STREAM_DECODER_TELL_STATUS_OK; + } +} + +static FLAC__StreamDecoderLengthStatus flac_length_music_cb( + const FLAC__StreamDecoder *decoder, + FLAC__uint64 *stream_length, + void *client_data) +{ + FLAC_Music *data = (FLAC_Music*)client_data; + + Sint64 pos = SDL_RWtell(data->src); + Sint64 length = SDL_RWseek(data->src, 0, RW_SEEK_END); + + (void)decoder; + + if (SDL_RWseek(data->src, pos, RW_SEEK_SET) != pos || length < 0) { + /* there was an error attempting to return the stream to the original + * position, or the length was invalid. */ + return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR; + } else { + *stream_length = (FLAC__uint64)length; + return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; + } +} + +static FLAC__bool flac_eof_music_cb( + const FLAC__StreamDecoder *decoder, + void *client_data) +{ + FLAC_Music *data = (FLAC_Music*)client_data; + + Sint64 pos = SDL_RWtell(data->src); + Sint64 end = SDL_RWseek(data->src, 0, RW_SEEK_END); + + (void)decoder; + + /* was the original position equal to the end (a.k.a. the seek didn't move)? */ + if (pos == end) { + /* must be EOF */ + return true; + } else { + /* not EOF, return to the original position */ + SDL_RWseek(data->src, pos, RW_SEEK_SET); + return false; + } +} + +static FLAC__StreamDecoderWriteStatus flac_write_music_cb( + const FLAC__StreamDecoder *decoder, + const FLAC__Frame *frame, + const FLAC__int32 *const buffer[], + void *client_data) +{ + FLAC_Music *music = (FLAC_Music *)client_data; + Sint16 *data; + unsigned int i, j, channels; + int shift_amount = 0, amount; + + (void)decoder; + + if (!music->stream) { + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } + + switch (music->bits_per_sample) { + case 16: + shift_amount = 0; + break; + case 20: + shift_amount = 4; + break; + case 24: + shift_amount = 8; + break; + default: + SDL_SetError("FLAC decoder doesn't support %d bits_per_sample", music->bits_per_sample); + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } + + if (music->channels == 3) { + /* We'll just drop the center channel for now */ + channels = 2; + } else { + channels = music->channels; + } + + data = SDL_stack_alloc(Sint16, (frame->header.blocksize * channels)); + if (!data) { + SDL_SetError("Couldn't allocate %d bytes stack memory", (int)(frame->header.blocksize * channels * sizeof(*data))); + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } + if (music->channels == 3) { + Sint16 *dst = data; + for (i = 0; i < frame->header.blocksize; ++i) { + Sint16 FL = (Sint16)(buffer[0][i] >> shift_amount); + Sint16 FR = (Sint16)(buffer[1][i] >> shift_amount); + Sint16 FCmix = (Sint16)((buffer[2][i] >> shift_amount) * 0.5f); + int sample; + + sample = (FL + FCmix); + if (sample > SDL_MAX_SINT16) { + *dst = SDL_MAX_SINT16; + } else if (sample < SDL_MIN_SINT16) { + *dst = SDL_MIN_SINT16; + } else { + *dst = (Sint16)sample; + } + ++dst; + + sample = (FR + FCmix); + if (sample > SDL_MAX_SINT16) { + *dst = SDL_MAX_SINT16; + } else if (sample < SDL_MIN_SINT16) { + *dst = SDL_MIN_SINT16; + } else { + *dst = (Sint16)sample; + } + ++dst; + } + } else { + for (i = 0; i < channels; ++i) { + Sint16 *dst = data + i; + for (j = 0; j < frame->header.blocksize; ++j) { + *dst = (Sint16)(buffer[i][j] >> shift_amount); + dst += channels; + } + } + } + amount = (int)(frame->header.blocksize * channels * sizeof(*data)); + music->pcm_pos += (FLAC__int64) frame->header.blocksize; + if (music->loop && (music->play_count != 1) && + (music->pcm_pos >= music->loop_end)) { + amount -= (music->pcm_pos - music->loop_end) * channels * (int)sizeof(*data); + music->loop_flag = SDL_TRUE; + } + + SDL_AudioStreamPut(music->stream, data, amount); + SDL_stack_free(data); + + return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; +} + +static void flac_metadata_music_cb( + const FLAC__StreamDecoder *decoder, + const FLAC__StreamMetadata *metadata, + void *client_data) +{ + FLAC_Music *music = (FLAC_Music *)client_data; + const FLAC__StreamMetadata_VorbisComment *vc; + int channels; + unsigned rate; + char *param, *argument, *value; + SDL_bool is_loop_length = SDL_FALSE; + + (void)decoder; + + if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { + music->sample_rate = metadata->data.stream_info.sample_rate; + music->channels = metadata->data.stream_info.channels; + music->bits_per_sample = metadata->data.stream_info.bits_per_sample; + /*printf("FLAC: Sample rate = %d, channels = %d, bits_per_sample = %d\n", music->sample_rate, music->channels, music->bits_per_sample);*/ + + /* SDL's channel mapping and FLAC channel mapping are the same, + except for 3 channels: SDL is FL FR LFE and FLAC is FL FR FC + */ + if (music->channels == 3) { + channels = 2; + } else { + channels = (int)music->channels; + } + + /* We check for NULL stream later when we get data */ + SDL_assert(!music->stream); + music->stream = SDL_NewAudioStream(AUDIO_S16SYS, (Uint8)channels, (int)music->sample_rate, + music_spec.format, music_spec.channels, music_spec.freq); + } else if (metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) { + FLAC__uint32 i; + + vc = &metadata->data.vorbis_comment; + rate = music->sample_rate; + + for (i = 0; i < vc->num_comments; ++i) { + param = SDL_strdup((const char *) vc->comments[i].entry); + argument = param; + value = SDL_strchr(param, '='); + + if (value == NULL) { + value = param + SDL_strlen(param); + } else { + *(value++) = '\0'; + } + + /* Want to match LOOP-START, LOOP_START, etc. Remove - or _ from + * string if it is present at position 4. */ + if (_Mix_IsLoopTag(argument) && ((argument[4] == '_') || (argument[4] == '-'))) { + SDL_memmove(argument + 4, argument + 5, SDL_strlen(argument) - 4); + } + + if (SDL_strcasecmp(argument, "LOOPSTART") == 0) + music->loop_start = _Mix_ParseTime(value, rate); + else if (SDL_strcasecmp(argument, "LOOPLENGTH") == 0) { + music->loop_len = SDL_strtoll(value, NULL, 10); + is_loop_length = SDL_TRUE; + } else if (SDL_strcasecmp(argument, "LOOPEND") == 0) { + music->loop_end = _Mix_ParseTime(value, rate); + is_loop_length = SDL_FALSE; + } else if (SDL_strcasecmp(argument, "TITLE") == 0) { + meta_tags_set(&music->tags, MIX_META_TITLE, value); + } else if (SDL_strcasecmp(argument, "ARTIST") == 0) { + meta_tags_set(&music->tags, MIX_META_ARTIST, value); + } else if (SDL_strcasecmp(argument, "ALBUM") == 0) { + meta_tags_set(&music->tags, MIX_META_ALBUM, value); + } else if (SDL_strcasecmp(argument, "COPYRIGHT") == 0) { + meta_tags_set(&music->tags, MIX_META_COPYRIGHT, value); + } + SDL_free(param); + } + + if (is_loop_length) { + music->loop_end = music->loop_start + music->loop_len; + } else { + music->loop_len = music->loop_end - music->loop_start; + } + + /* Ignore invalid loop tag */ + if (music->loop_start < 0 || music->loop_len < 0 || music->loop_end < 0) { + music->loop_start = 0; + music->loop_len = 0; + music->loop_end = 0; + } + } +} + +static void flac_error_music_cb( + const FLAC__StreamDecoder *decoder, + FLAC__StreamDecoderErrorStatus status, + void *client_data) +{ + (void)decoder; + (void)client_data; + + /* print an SDL error based on the error status */ + switch (status) { + case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC: + SDL_SetError("Error processing the FLAC file [LOST_SYNC]."); + break; + case FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER: + SDL_SetError("Error processing the FLAC file [BAD_HEADER]."); + break; + case FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH: + SDL_SetError("Error processing the FLAC file [CRC_MISMATCH]."); + break; + case FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM: + SDL_SetError("Error processing the FLAC file [UNPARSEABLE]."); + break; + default: + SDL_SetError("Error processing the FLAC file [UNKNOWN]."); + break; + } +} + +/* Load an FLAC stream from an SDL_RWops object */ +static void *FLAC_CreateFromRW(SDL_RWops *src, int freesrc) +{ + FLAC_Music *music; + int init_stage = 0; + int was_error = 1; + FLAC__int64 full_length; + + music = (FLAC_Music *)SDL_calloc(1, sizeof(*music)); + if (!music) { + SDL_OutOfMemory(); + return NULL; + } + music->src = src; + music->volume = MIX_MAX_VOLUME; + + music->flac_decoder = flac.FLAC__stream_decoder_new(); + if (music->flac_decoder) { + init_stage++; /* stage 1! */ + flac.FLAC__stream_decoder_set_metadata_respond(music->flac_decoder, + FLAC__METADATA_TYPE_VORBIS_COMMENT); + + if (flac.FLAC__stream_decoder_init_stream( + music->flac_decoder, + flac_read_music_cb, flac_seek_music_cb, + flac_tell_music_cb, flac_length_music_cb, + flac_eof_music_cb, flac_write_music_cb, + flac_metadata_music_cb, flac_error_music_cb, + music) == FLAC__STREAM_DECODER_INIT_STATUS_OK) { + init_stage++; /* stage 2! */ + + if (flac.FLAC__stream_decoder_process_until_end_of_metadata(music->flac_decoder)) { + was_error = 0; + } else { + SDL_SetError("FLAC__stream_decoder_process_until_end_of_metadata() failed"); + } + } else { + SDL_SetError("FLAC__stream_decoder_init_stream() failed"); + } + } else { + SDL_SetError("FLAC__stream_decoder_new() failed"); + } + + if (was_error) { + switch (init_stage) { + case 2: + flac.FLAC__stream_decoder_finish(music->flac_decoder); /* fallthrough */ + case 1: + flac.FLAC__stream_decoder_delete(music->flac_decoder); /* fallthrough */ + case 0: + SDL_free(music); + break; + } + return NULL; + } + + /* loop_start, loop_end and loop_len get set by metadata callback if tags + * are present in metadata. + */ + full_length = (FLAC__int64) flac.FLAC__stream_decoder_get_total_samples(music->flac_decoder); + if ((music->loop_end > 0) && (music->loop_end <= full_length) && + (music->loop_start < music->loop_end)) { + music->loop = 1; + } + + music->full_length = full_length; + music->freesrc = freesrc; + return music; +} + +static const char* FLAC_GetMetaTag(void *context, Mix_MusicMetaTag tag_type) +{ + FLAC_Music *music = (FLAC_Music *)context; + return meta_tags_get(&music->tags, tag_type); +} + + +/* Set the volume for an FLAC stream */ +static void FLAC_SetVolume(void *context, int volume) +{ + FLAC_Music *music = (FLAC_Music *)context; + music->volume = volume; +} + +/* Get the volume for an FLAC stream */ +static int FLAC_GetVolume(void *context) +{ + FLAC_Music *music = (FLAC_Music *)context; + return music->volume; +} + +/* Start playback of a given FLAC stream */ +static int FLAC_Play(void *context, int play_count) +{ + FLAC_Music *music = (FLAC_Music *)context; + music->play_count = play_count; + return FLAC_Seek(music, 0.0); +} + +/* Read some FLAC stream data and convert it for output */ +static int FLAC_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + FLAC_Music *music = (FLAC_Music *)context; + int filled; + + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + if (!flac.FLAC__stream_decoder_process_single(music->flac_decoder)) { + SDL_SetError("FLAC__stream_decoder_process_single() failed"); + return -1; + } + + if (music->loop_flag) { + music->pcm_pos = music->loop_start; + if (flac.FLAC__stream_decoder_seek_absolute(music->flac_decoder, (FLAC__uint64)music->loop_start) == + FLAC__STREAM_DECODER_SEEK_ERROR) { + SDL_SetError("FLAC__stream_decoder_seek_absolute() failed"); + flac.FLAC__stream_decoder_flush(music->flac_decoder); + return -1; + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + music->play_count = play_count; + music->loop_flag = SDL_FALSE; + } + } + + if (flac.FLAC__stream_decoder_get_state(music->flac_decoder) == FLAC__STREAM_DECODER_END_OF_STREAM) { + if (music->play_count == 1) { + music->play_count = 0; + SDL_AudioStreamFlush(music->stream); + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + if (FLAC_Play(music, play_count) < 0) { + return -1; + } + } + } + return 0; +} + +/* Play some of a stream previously started with FLAC_play() */ +static int FLAC_GetAudio(void *context, void *data, int bytes) +{ + FLAC_Music *music = (FLAC_Music *)context; + return music_pcm_getaudio(context, data, bytes, music->volume, FLAC_GetSome); +} + +/* Jump (seek) to a given position (position is in seconds) */ +static int FLAC_Seek(void *context, double position) +{ + FLAC_Music *music = (FLAC_Music *)context; + FLAC__uint64 seek_sample = (FLAC__uint64) (music->sample_rate * position); + + SDL_AudioStreamClear(music->stream); + music->pcm_pos = (FLAC__int64) seek_sample; + if (!flac.FLAC__stream_decoder_seek_absolute(music->flac_decoder, seek_sample)) { + if (flac.FLAC__stream_decoder_get_state(music->flac_decoder) == FLAC__STREAM_DECODER_SEEK_ERROR) { + flac.FLAC__stream_decoder_flush(music->flac_decoder); + } + + SDL_SetError("Seeking of FLAC stream failed: libFLAC seek failed."); + return -1; + } + return 0; +} + +static double FLAC_Tell(void *context) +{ + FLAC_Music *music = (FLAC_Music *)context; + return (double)music->pcm_pos / music->sample_rate; +} + +/* Return music duration in seconds */ +static double FLAC_Duration(void *context) +{ + FLAC_Music *music = (FLAC_Music *)context; + return (double)music->full_length / music->sample_rate; +} + +static double FLAC_LoopStart(void *music_p) +{ + FLAC_Music *music = (FLAC_Music *)music_p; + if (music->loop > 0) { + return (double)music->loop_start / music->sample_rate; + } + return -1.0; +} + +static double FLAC_LoopEnd(void *music_p) +{ + FLAC_Music *music = (FLAC_Music *)music_p; + if (music->loop > 0) { + return (double)music->loop_end / music->sample_rate; + } + return -1.0; +} + +static double FLAC_LoopLength(void *music_p) +{ + FLAC_Music *music = (FLAC_Music *)music_p; + if (music->loop > 0) { + return (double)music->loop_len / music->sample_rate; + } + return -1.0; +} + +/* Close the given FLAC_Music object */ +static void FLAC_Delete(void *context) +{ + FLAC_Music *music = (FLAC_Music *)context; + if (music) { + meta_tags_clear(&music->tags); + if (music->flac_decoder) { + flac.FLAC__stream_decoder_finish(music->flac_decoder); + flac.FLAC__stream_decoder_delete(music->flac_decoder); + } + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } + if (music->freesrc) { + SDL_RWclose(music->src); + } + SDL_free(music); + } +} + +Mix_MusicInterface Mix_MusicInterface_FLAC = +{ + "FLAC", + MIX_MUSIC_FLAC, + MUS_FLAC, + SDL_FALSE, + SDL_FALSE, + + FLAC_Load, + NULL, /* Open */ + FLAC_CreateFromRW, + NULL, /* CreateFromFile */ + FLAC_SetVolume, + FLAC_GetVolume, + FLAC_Play, + NULL, /* IsPlaying */ + FLAC_GetAudio, + NULL, /* Jump */ + FLAC_Seek, + FLAC_Tell, + FLAC_Duration, + FLAC_LoopStart, + FLAC_LoopEnd, + FLAC_LoopLength, + FLAC_GetMetaTag,/* GetMetaTag */ + NULL, /* Pause */ + NULL, /* Resume */ + NULL, /* Stop */ + FLAC_Delete, + NULL, /* Close */ + FLAC_Unload +}; + +#endif /* MUSIC_FLAC */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_flac.h b/src/codecs/music_flac.h new file mode 100644 index 0000000..f0b73f7 --- /dev/null +++ b/src/codecs/music_flac.h @@ -0,0 +1,26 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_FLAC; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_fluidsynth.c b/src/codecs/music_fluidsynth.c new file mode 100644 index 0000000..ff3f309 --- /dev/null +++ b/src/codecs/music_fluidsynth.c @@ -0,0 +1,378 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + James Le Cuirot + chewi@aura-online.co.uk +*/ + +#ifdef MUSIC_MID_FLUIDSYNTH + +#include "SDL_loadso.h" +#include "SDL_rwops.h" + +#include "music_fluidsynth.h" + +#include + + +typedef struct { + int loaded; + void *handle; + +#if (FLUIDSYNTH_VERSION_MAJOR >= 2) + void (*delete_fluid_player)(fluid_player_t*); + void (*delete_fluid_synth)(fluid_synth_t*); +#else + int (*delete_fluid_player)(fluid_player_t*); + int (*delete_fluid_synth)(fluid_synth_t*); +#endif + void (*delete_fluid_settings)(fluid_settings_t*); + int (*fluid_player_add)(fluid_player_t*, const char*); + int (*fluid_player_add_mem)(fluid_player_t*, const void*, size_t); + int (*fluid_player_get_status)(fluid_player_t*); + int (*fluid_player_play)(fluid_player_t*); + int (*fluid_player_set_loop)(fluid_player_t*, int); + int (*fluid_player_stop)(fluid_player_t*); + int (*fluid_settings_setnum)(fluid_settings_t*, const char*, double); + int (*fluid_settings_getnum)(fluid_settings_t*, const char*, double*); + fluid_settings_t* (*fluid_synth_get_settings)(fluid_synth_t*); + void (*fluid_synth_set_gain)(fluid_synth_t*, float); + int (*fluid_synth_sfload)(fluid_synth_t*, const char*, int); + int (*fluid_synth_write_s16)(fluid_synth_t*, int, void*, int, int, void*, int, int); + int (*fluid_synth_write_float)(fluid_synth_t*, int, void*, int, int, void*, int, int); + fluid_player_t* (*new_fluid_player)(fluid_synth_t*); + fluid_settings_t* (*new_fluid_settings)(void); + fluid_synth_t* (*new_fluid_synth)(fluid_settings_t*); +} fluidsynth_loader; + +static fluidsynth_loader fluidsynth = { + 0, NULL +}; + +#ifdef FLUIDSYNTH_DYNAMIC +#define FUNCTION_LOADER(FUNC, SIG) \ + fluidsynth.FUNC = (SIG) SDL_LoadFunction(fluidsynth.handle, #FUNC); \ + if (fluidsynth.FUNC == NULL) { SDL_UnloadObject(fluidsynth.handle); return -1; } +#else +#define FUNCTION_LOADER(FUNC, SIG) \ + fluidsynth.FUNC = FUNC; +#endif + +static int FLUIDSYNTH_Load() +{ + if (fluidsynth.loaded == 0) { +#ifdef FLUIDSYNTH_DYNAMIC + fluidsynth.handle = SDL_LoadObject(FLUIDSYNTH_DYNAMIC); + if (fluidsynth.handle == NULL) { + return -1; + } +#endif +#if (FLUIDSYNTH_VERSION_MAJOR >= 2) + FUNCTION_LOADER(delete_fluid_player, void (*)(fluid_player_t*)) + FUNCTION_LOADER(delete_fluid_synth, void (*)(fluid_synth_t*)) +#else + FUNCTION_LOADER(delete_fluid_player, int (*)(fluid_player_t*)) + FUNCTION_LOADER(delete_fluid_synth, int (*)(fluid_synth_t*)) +#endif + FUNCTION_LOADER(delete_fluid_settings, void (*)(fluid_settings_t*)) + FUNCTION_LOADER(fluid_player_add, int (*)(fluid_player_t*, const char*)) + FUNCTION_LOADER(fluid_player_add_mem, int (*)(fluid_player_t*, const void*, size_t)) + FUNCTION_LOADER(fluid_player_get_status, int (*)(fluid_player_t*)) + FUNCTION_LOADER(fluid_player_play, int (*)(fluid_player_t*)) + FUNCTION_LOADER(fluid_player_set_loop, int (*)(fluid_player_t*, int)) + FUNCTION_LOADER(fluid_player_stop, int (*)(fluid_player_t*)) + FUNCTION_LOADER(fluid_settings_setnum, int (*)(fluid_settings_t*, const char*, double)) + FUNCTION_LOADER(fluid_settings_getnum, int (*)(fluid_settings_t*, const char*, double*)) + FUNCTION_LOADER(fluid_synth_get_settings, fluid_settings_t* (*)(fluid_synth_t*)) + FUNCTION_LOADER(fluid_synth_set_gain, void (*)(fluid_synth_t*, float)) + FUNCTION_LOADER(fluid_synth_sfload, int(*)(fluid_synth_t*, const char*, int)) + FUNCTION_LOADER(fluid_synth_write_s16, int(*)(fluid_synth_t*, int, void*, int, int, void*, int, int)) + FUNCTION_LOADER(fluid_synth_write_float, int(*)(fluid_synth_t*, int, void*, int, int, void*, int, int)) + FUNCTION_LOADER(new_fluid_player, fluid_player_t* (*)(fluid_synth_t*)) + FUNCTION_LOADER(new_fluid_settings, fluid_settings_t* (*)(void)) + FUNCTION_LOADER(new_fluid_synth, fluid_synth_t* (*)(fluid_settings_t*)) + } + ++fluidsynth.loaded; + + return 0; +} + +static void FLUIDSYNTH_Unload() +{ + if (fluidsynth.loaded == 0) { + return; + } + if (fluidsynth.loaded == 1) { +#ifdef FLUIDSYNTH_DYNAMIC + SDL_UnloadObject(fluidsynth.handle); +#endif + } + --fluidsynth.loaded; +} + + +typedef struct { + fluid_synth_t *synth; + fluid_settings_t *settings; + fluid_player_t *player; + int (*synth_write)(fluid_synth_t*, int, void*, int, int, void*, int, int); + SDL_AudioStream *stream; + void *buffer; + int buffer_size; + int volume; +} FLUIDSYNTH_Music; + +static void FLUIDSYNTH_Delete(void *context); + +static int SDLCALL fluidsynth_check_soundfont(const char *path, void *data) +{ + SDL_RWops *rw = SDL_RWFromFile(path, "rb"); + + (void)data; + if (rw) { + SDL_RWclose(rw); + return 1; + } else { + Mix_SetError("Failed to access the SoundFont %s", path); + return 0; + } +} + +static int SDLCALL fluidsynth_load_soundfont(const char *path, void *data) +{ + /* If this fails, it's too late to try Timidity so pray that at least one works. */ + fluidsynth.fluid_synth_sfload((fluid_synth_t*) data, path, 1); + return 1; +} + +static int FLUIDSYNTH_Open(const SDL_AudioSpec *spec) +{ + (void)spec; + if (!Mix_EachSoundFont(fluidsynth_check_soundfont, NULL)) { + return -1; + } + return 0; +} + +static FLUIDSYNTH_Music *FLUIDSYNTH_LoadMusic(void *data) +{ + SDL_RWops *src = (SDL_RWops *)data; + FLUIDSYNTH_Music *music; + double samplerate; /* as set by the lib. */ + const Uint8 channels = 2; + int src_format = AUDIO_S16SYS; + void *rw_mem; + size_t rw_size; + int ret; + + if (!(music = SDL_calloc(1, sizeof(FLUIDSYNTH_Music)))) { + SDL_OutOfMemory(); + return NULL; + } + + music->volume = MIX_MAX_VOLUME; + music->buffer_size = music_spec.samples * sizeof(Sint16) * channels; + music->synth_write = fluidsynth.fluid_synth_write_s16; + if (music_spec.format & 0x0020) { /* 32 bit. */ + src_format = AUDIO_F32SYS; + music->buffer_size <<= 1; + music->synth_write = fluidsynth.fluid_synth_write_float; + } + + if (!(music->buffer = SDL_malloc((size_t)music->buffer_size))) { + SDL_OutOfMemory(); + goto fail; + } + + if (!(music->settings = fluidsynth.new_fluid_settings())) { + Mix_SetError("Failed to create FluidSynth settings"); + goto fail; + } + + fluidsynth.fluid_settings_setnum(music->settings, "synth.sample-rate", (double) music_spec.freq); + fluidsynth.fluid_settings_getnum(music->settings, "synth.sample-rate", &samplerate); + + if (!(music->synth = fluidsynth.new_fluid_synth(music->settings))) { + Mix_SetError("Failed to create FluidSynth synthesizer"); + goto fail; + } + + if (!Mix_EachSoundFont(fluidsynth_load_soundfont, music->synth)) { + goto fail; + } + + if (!(music->player = fluidsynth.new_fluid_player(music->synth))) { + Mix_SetError("Failed to create FluidSynth player"); + goto fail; + } + + rw_mem = SDL_LoadFile_RW(src, &rw_size, SDL_FALSE); + if (!rw_mem) { + SDL_OutOfMemory(); + goto fail; + } + + ret = fluidsynth.fluid_player_add_mem(music->player, rw_mem, rw_size); + SDL_free(rw_mem); + if (ret != FLUID_OK) { + Mix_SetError("FluidSynth failed to load in-memory song"); + goto fail; + } + + if (!(music->stream = SDL_NewAudioStream(src_format, channels, (int) samplerate, + music_spec.format, music_spec.channels, music_spec.freq))) { + goto fail; + } + + return music; +fail: + FLUIDSYNTH_Delete(music); + return NULL; +} + +static void *FLUIDSYNTH_CreateFromRW(SDL_RWops *src, int freesrc) +{ + FLUIDSYNTH_Music *music; + + music = FLUIDSYNTH_LoadMusic(src); + if (music && freesrc) { + SDL_RWclose(src); + } + return music; +} + +static void FLUIDSYNTH_SetVolume(void *context, int volume) +{ + FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; + /* FluidSynth's default is 0.2. Make 1.2 the maximum. */ + music->volume = volume; + fluidsynth.fluid_synth_set_gain(music->synth, (float) (volume * 1.2 / MIX_MAX_VOLUME)); +} + +static int FLUIDSYNTH_GetVolume(void *context) +{ + FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; + return music->volume; +} + +static int FLUIDSYNTH_Play(void *context, int play_count) +{ + FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; + fluidsynth.fluid_player_set_loop(music->player, play_count); + fluidsynth.fluid_player_play(music->player); + return 0; +} + +static SDL_bool FLUIDSYNTH_IsPlaying(void *context) +{ + FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; + return fluidsynth.fluid_player_get_status(music->player) == FLUID_PLAYER_PLAYING ? SDL_TRUE : SDL_FALSE; +} + +static int FLUIDSYNTH_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; + int filled; + + (void)done; + + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + + if (music->synth_write(music->synth, music_spec.samples, music->buffer, 0, 2, music->buffer, 1, 2) != FLUID_OK) { + Mix_SetError("Error generating FluidSynth audio"); + return -1; + } + if (SDL_AudioStreamPut(music->stream, music->buffer, music->buffer_size) < 0) { + return -1; + } + return 0; +} +static int FLUIDSYNTH_GetAudio(void *context, void *data, int bytes) +{ + return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, FLUIDSYNTH_GetSome); +} + +static void FLUIDSYNTH_Stop(void *context) +{ + FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; + fluidsynth.fluid_player_stop(music->player); +} + +static void FLUIDSYNTH_Delete(void *context) +{ + FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; + + if (music->player) { + fluidsynth.delete_fluid_player(music->player); + } + if (music->synth) { + fluidsynth.delete_fluid_synth(music->synth); + } + if (music->settings) { + fluidsynth.delete_fluid_settings(music->settings); + } + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } + if (music->buffer) { + SDL_free(music->buffer); + } + SDL_free(music); +} + +Mix_MusicInterface Mix_MusicInterface_FLUIDSYNTH = +{ + "FLUIDSYNTH", + MIX_MUSIC_FLUIDSYNTH, + MUS_MID, + SDL_FALSE, + SDL_FALSE, + + FLUIDSYNTH_Load, + FLUIDSYNTH_Open, + FLUIDSYNTH_CreateFromRW, + NULL, /* CreateFromFile */ + FLUIDSYNTH_SetVolume, + FLUIDSYNTH_GetVolume, + FLUIDSYNTH_Play, + FLUIDSYNTH_IsPlaying, + FLUIDSYNTH_GetAudio, + NULL, /* Jump */ + NULL, /* Seek */ + NULL, /* Tell */ + NULL, /* Duration */ + NULL, /* LoopStart */ + NULL, /* LoopEnd */ + NULL, /* LoopLength */ + NULL, /* GetMetaTag */ + NULL, /* Pause */ + NULL, /* Resume */ + FLUIDSYNTH_Stop, + FLUIDSYNTH_Delete, + NULL, /* Close */ + FLUIDSYNTH_Unload +}; + +#endif /* MUSIC_MID_FLUIDSYNTH */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_fluidsynth.h b/src/codecs/music_fluidsynth.h new file mode 100644 index 0000000..031f943 --- /dev/null +++ b/src/codecs/music_fluidsynth.h @@ -0,0 +1,31 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + James Le Cuirot + chewi@aura-online.co.uk +*/ + +/* This file supports playing MIDI files with FluidSynth */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_FLUIDSYNTH; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_mad.c b/src/codecs/music_mad.c new file mode 100644 index 0000000..999a9e6 --- /dev/null +++ b/src/codecs/music_mad.c @@ -0,0 +1,678 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef MUSIC_MP3_MAD + +#include "music_mad.h" +#include "mp3utils.h" + +#include "mad.h" + + +/* NOTE: The dithering functions are GPL, which should be fine if your + application is GPL (which would need to be true if you enabled + libmad support in SDL_mixer). If you're using libmad under the + commercial license, you need to disable this code. +*/ +/************************ dithering functions ***************************/ + +#ifdef MUSIC_MP3_MAD_GPL_DITHERING + +/* All dithering done here is taken from the GPL'ed xmms-mad plugin. */ + +/* Copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura. */ +/* Any feedback is very welcome. For any question, comments, */ +/* see http://www.math.keio.ac.jp/matumoto/emt.html or email */ +/* matumoto@math.keio.ac.jp */ + +/* Period parameters */ +#define MP3_DITH_N 624 +#define MP3_DITH_M 397 +#define MATRIX_A 0x9908b0df /* constant vector a */ +#define UPPER_MASK 0x80000000 /* most significant w-r bits */ +#define LOWER_MASK 0x7fffffff /* least significant r bits */ + +/* Tempering parameters */ +#define TEMPERING_MASK_B 0x9d2c5680 +#define TEMPERING_MASK_C 0xefc60000 +#define TEMPERING_SHIFT_U(y) (y >> 11) +#define TEMPERING_SHIFT_S(y) (y << 7) +#define TEMPERING_SHIFT_T(y) (y << 15) +#define TEMPERING_SHIFT_L(y) (y >> 18) + +static unsigned long mt[MP3_DITH_N]; /* the array for the state vector */ +static int mti=MP3_DITH_N+1; /* mti==MP3_DITH_N+1 means mt[MP3_DITH_N] is not initialized */ + +/* initializing the array with a NONZERO seed */ +static void sgenrand(unsigned long seed) +{ + /* setting initial seeds to mt[MP3_DITH_N] using */ + /* the generator Line 25 of Table 1 in */ + /* [KNUTH 1981, The Art of Computer Programming */ + /* Vol. 2 (2nd Ed.), pp102] */ + mt[0]= seed & 0xffffffff; + for (mti=1; mti= MP3_DITH_N) { /* generate MP3_DITH_N words at one time */ + int kk; + + if (mti == MP3_DITH_N+1) /* if sgenrand() has not been called, */ + sgenrand(4357); /* a default initial seed is used */ + + for (kk=0;kk> 1) ^ mag01[y & 0x1]; + } + for (;kk> 1) ^ mag01[y & 0x1]; + } + y = (mt[MP3_DITH_N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK); + mt[MP3_DITH_N-1] = mt[MP3_DITH_M-1] ^ (y >> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= TEMPERING_SHIFT_U(y); + y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B; + y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C; + y ^= TEMPERING_SHIFT_L(y); + + return y; +} + +static long triangular_dither_noise(int nbits) { + /* parameter nbits : the peak-to-peak amplitude desired (in bits) + * use with nbits set to 2 + nber of bits to be trimmed. + * (because triangular is made from two uniformly distributed processes, + * it starts at 2 bits peak-to-peak amplitude) + * see The Theory of Dithered Quantization by Robert Alexander Wannamaker + * for complete proof of why that's optimal + */ + long v = (genrand()/2 - genrand()/2); /* in ]-2^31, 2^31[ */ + long P = 1 << (32 - nbits); /* the power of 2 */ + v /= P; + /* now v in ]-2^(nbits-1), 2^(nbits-1) [ */ + + return v; +} + +#endif /* MUSIC_MP3_MAD_GPL_DITHERING */ + + +#define MAD_INPUT_BUFFER_SIZE (5*8192) + +enum { + MS_input_eof = 0x0001, + MS_input_error = 0x0001, + MS_decode_error = 0x0002, + MS_error_flags = 0x000f +}; + +typedef struct { + struct mp3file_t mp3file; + int play_count; + int freesrc; + struct mad_stream stream; + struct mad_frame frame; + struct mad_synth synth; + mad_timer_t next_frame_start; + int volume; + int status; + SDL_AudioStream *audiostream; + unsigned short last_nchannels; + unsigned int last_samplerate; + + double total_length; + int sample_rate; + int sample_position; + + unsigned char input_buffer[MAD_INPUT_BUFFER_SIZE + MAD_BUFFER_GUARD]; +} MAD_Music; + +static void read_update_buffer(struct mad_stream *stream, MAD_Music *music); + +static double extract_length(struct mad_header *header, struct mad_stream *stream, Sint64 file_size) +{ + int mpeg_version = 0; + int xing_offset = 0; + Uint32 samples_per_frame = 0; + Uint32 frames_count = 0; + unsigned char const *frames_count_raw; + + /* There are two methods to compute duration: + * - Using Xing/Info/VBRI headers + * - Rely on filesize and first size of frame in condition of CRB + * https://www.codeproject.com/Articles/8295/MPEG-Audio-Frame-Header#VBRHeaders + */ + + if (!stream->this_frame || !stream->next_frame || + stream->next_frame <= stream->this_frame || + (stream->next_frame - stream->this_frame) < 48) { + return -1.0; /* Too small buffer to get any necessary headers */ + } + + mpeg_version = (stream->this_frame[1] >> 3) & 0x03; + + switch(mpeg_version) { + case 0x03: /* MPEG1 */ + if (header->mode == MAD_MODE_SINGLE_CHANNEL) { + xing_offset = 4 + 17; + } else { + xing_offset = 4 + 32; + } + break; + default: /* MPEG2 and MPEG2.5 */ + if (header->mode == MAD_MODE_SINGLE_CHANNEL) { + xing_offset = 4 + 17; + } else { + xing_offset = 4 + 9; + } + break; + } + + switch(header->layer) + { + case MAD_LAYER_I: + samples_per_frame = 384; + break; + case MAD_LAYER_II: + samples_per_frame = 1152; + break; + case MAD_LAYER_III: + if (mpeg_version == 0x03) { + samples_per_frame = 1152; + } else { + samples_per_frame = 576; + } + break; + default: + return -1.0; + } + + if (SDL_memcmp(stream->this_frame + xing_offset, "Xing", 4) == 0 || + SDL_memcmp(stream->this_frame + xing_offset, "Info", 4) == 0) { + /* Xing header to get the count of frames for VBR */ + frames_count_raw = stream->this_frame + xing_offset + 8; + frames_count = ((Uint32)frames_count_raw[0] << 24) + + ((Uint32)frames_count_raw[1] << 16) + + ((Uint32)frames_count_raw[2] << 8) + + ((Uint32)frames_count_raw[3]); + } + else if (SDL_memcmp(stream->this_frame + xing_offset, "VBRI", 4) == 0) { + /* VBRI header to get the count of frames for VBR */ + frames_count_raw = stream->this_frame + xing_offset + 14; + frames_count = ((Uint32)frames_count_raw[0] << 24) + + ((Uint32)frames_count_raw[1] << 16) + + ((Uint32)frames_count_raw[2] << 8) + + ((Uint32)frames_count_raw[3]); + } else { + /* To get a count of frames for CBR, divide the file size with a size of one frame */ + frames_count = (Uint32)(file_size / (stream->next_frame - stream->this_frame)); + } + + return (double)(frames_count * samples_per_frame) / header->samplerate; +} + +static int calculate_total_time(MAD_Music *music) +{ + mad_timer_t time = mad_timer_zero; + struct mad_header header; + struct mad_stream stream; + SDL_bool is_first_frame = SDL_TRUE; + int ret = 0; + + mad_header_init(&header); + mad_stream_init(&stream); + + while (1) + { + read_update_buffer(&stream, music); + + if (mad_header_decode(&header, &stream) == -1) { + if (MAD_RECOVERABLE(stream.error)) { + if ((music->status & MS_input_error) == 0) { + continue; + } + if (is_first_frame) { + ret = -1; + } + break; + } else if (stream.error == MAD_ERROR_BUFLEN) { + if ((music->status & MS_input_error) == 0) { + continue; + } + if (is_first_frame) { + ret = -1; + } + break; + } else { + Mix_SetError("mad_frame_decode() failed, corrupt stream?"); + music->status |= MS_decode_error; + if (is_first_frame) { + ret = -1; + } + break; + } + } + + music->sample_rate = (int)header.samplerate; + mad_timer_add(&time, header.duration); + + if (is_first_frame) { + music->total_length = extract_length(&header, &stream, music->mp3file.length); + if (music->total_length > 0.0) { + break; /* Duration has been recognized */ + } + is_first_frame = SDL_FALSE; + /* Otherwise, do the full scan of MP3 file to retrieve a duration */ + } + } + + if (!is_first_frame) { + music->total_length = (double)(mad_timer_count(time, (enum mad_units)music->sample_rate)) / (double)music->sample_rate; + } + mad_stream_finish(&stream); + mad_header_finish(&header); + SDL_memset(music->input_buffer, 0, sizeof(music->input_buffer)); + + music->status = 0; + + MP3_RWseek(&music->mp3file, 0, RW_SEEK_SET); + return ret; +} + +static int MAD_Seek(void *context, double position); + +static void *MAD_CreateFromRW(SDL_RWops *src, int freesrc) +{ + MAD_Music *music; + + music = (MAD_Music *)SDL_calloc(1, sizeof(MAD_Music)); + if (!music) { + SDL_OutOfMemory(); + return NULL; + } + music->volume = MIX_MAX_VOLUME; + + if (MP3_RWinit(&music->mp3file, src) < 0) { + SDL_free(music); + return NULL; + } + if (mp3_skiptags(&music->mp3file, SDL_FALSE) < 0) { + SDL_free(music); + Mix_SetError("music_mad: corrupt mp3 file (bad tags.)"); + return NULL; + } + + if (calculate_total_time(music) < 0) { + SDL_free(music); + Mix_SetError("music_mad: corrupt mp3 file (bad stream.)"); + return NULL; + } + + mad_stream_init(&music->stream); + mad_frame_init(&music->frame); + mad_synth_init(&music->synth); + mad_timer_reset(&music->next_frame_start); + + music->freesrc = freesrc; + return music; +} + +static void MAD_SetVolume(void *context, int volume) +{ + MAD_Music *music = (MAD_Music *)context; + music->volume = volume; +} + +static int MAD_GetVolume(void *context) +{ + MAD_Music *music = (MAD_Music *)context; + return music->volume; +} + +/* Starts the playback. */ +static int MAD_Play(void *context, int play_count) +{ + MAD_Music *music = (MAD_Music *)context; + music->play_count = play_count; + return MAD_Seek(music, 0.0); +} + + +/* Reads the next frame from the file. + Returns true on success or false on failure. + */ +static void read_update_buffer(struct mad_stream *stream, MAD_Music *music) +{ + if (stream->buffer == NULL || + stream->error == MAD_ERROR_BUFLEN) { + size_t read_size; + size_t remaining; + unsigned char *read_start; + + /* There might be some bytes in the buffer left over from last + time. If so, move them down and read more bytes following + them. */ + if (stream->next_frame != NULL) { + remaining = (size_t)(stream->bufend - stream->next_frame); + SDL_memmove(music->input_buffer, stream->next_frame, remaining); + read_start = music->input_buffer + remaining; + read_size = MAD_INPUT_BUFFER_SIZE - remaining; + + } else { + read_size = MAD_INPUT_BUFFER_SIZE; + read_start = music->input_buffer; + remaining = 0; + } + + /* Now read additional bytes from the input file. */ + read_size = MP3_RWread(&music->mp3file, read_start, 1, read_size); + + if (read_size == 0) { + if ((music->status & (MS_input_eof | MS_input_error)) == 0) { + /* FIXME: how to detect error? */ + music->status |= MS_input_eof; + + /* At the end of the file, we must stuff MAD_BUFFER_GUARD + number of 0 bytes. */ + SDL_memset(read_start + read_size, 0, MAD_BUFFER_GUARD); + read_size += MAD_BUFFER_GUARD; + } + } + + /* Now feed those bytes into the libmad stream. */ + mad_stream_buffer(stream, music->input_buffer, + read_size + remaining); + stream->error = MAD_ERROR_NONE; + } +} + +/* Reads the next frame from the file. + Returns true on success or false on failure. + */ +static SDL_bool read_next_frame(MAD_Music *music) +{ + read_update_buffer(&music->stream, music); + + /* Now ask libmad to extract a frame from the data we just put in + its buffer. */ + if (mad_frame_decode(&music->frame, &music->stream)) { + if (MAD_RECOVERABLE(music->stream.error)) { + mad_stream_sync(&music->stream); /* to frame seek mode */ + return SDL_FALSE; + + } else if (music->stream.error == MAD_ERROR_BUFLEN) { + return SDL_FALSE; + + } else { + Mix_SetError("mad_frame_decode() failed, corrupt stream?"); + music->status |= MS_decode_error; + return SDL_FALSE; + } + } + + mad_timer_add(&music->next_frame_start, music->frame.header.duration); + + return SDL_TRUE; +} + +/* Scale a MAD sample to 16 bits for output. */ +static Sint16 scale(mad_fixed_t sample) +{ + const int n_bits_to_loose = MAD_F_FRACBITS + 1 - 16; + + /* round */ + sample += (1L << (n_bits_to_loose - 1)); + +#ifdef MUSIC_MP3_MAD_GPL_DITHERING + sample += triangular_dither_noise(n_bits_to_loose + 1); +#endif + + /* clip */ + if (sample >= MAD_F_ONE) + sample = MAD_F_ONE - 1; + else if (sample < -MAD_F_ONE) + sample = -MAD_F_ONE; + + /* quantize */ + return (Sint16)(sample >> n_bits_to_loose); +} + +/* Once the frame has been read, copies its samples into the output buffer. */ +static SDL_bool decode_frame(MAD_Music *music) +{ + struct mad_pcm *pcm; + unsigned int i, nchannels, nsamples; + mad_fixed_t const *left_ch, *right_ch; + Sint16 *buffer, *dst; + int result; + + mad_synth_frame(&music->synth, &music->frame); + pcm = &music->synth.pcm; + + if (!music->audiostream || music->last_nchannels != pcm->channels || music->last_samplerate != pcm->samplerate) { + if (music->audiostream) { + SDL_FreeAudioStream(music->audiostream); + } + music->audiostream = SDL_NewAudioStream(AUDIO_S16SYS, (Uint8)pcm->channels, (int)pcm->samplerate, + music_spec.format, music_spec.channels, music_spec.freq); + if (!music->audiostream) { + return SDL_FALSE; + } + music->last_nchannels = pcm->channels; + music->last_samplerate = pcm->samplerate; + } + + nchannels = pcm->channels; + nsamples = pcm->length; + left_ch = pcm->samples[0]; + right_ch = pcm->samples[1]; + buffer = SDL_stack_alloc(Sint16, nsamples*nchannels); + if (!buffer) { + SDL_OutOfMemory(); + return SDL_FALSE; + } + + dst = buffer; + if (nchannels == 1) { + for (i = nsamples; i--;) { + *dst++ = scale(*left_ch++); + } + } else { + for (i = nsamples; i--;) { + *dst++ = scale(*left_ch++); + *dst++ = scale(*right_ch++); + } + } + + music->sample_position += nsamples; + result = SDL_AudioStreamPut(music->audiostream, buffer, (int)(nsamples * nchannels * sizeof(Sint16))); + SDL_stack_free(buffer); + + if (result < 0) { + return SDL_FALSE; + } + return SDL_TRUE; +} + +static int MAD_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + MAD_Music *music = (MAD_Music *)context; + int filled; + + if (music->audiostream) { + filled = SDL_AudioStreamGet(music->audiostream, data, bytes); + if (filled != 0) { + return filled; + } + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + if (read_next_frame(music)) { + if (!decode_frame(music)) { + return -1; + } + } else if (music->status & MS_input_eof) { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + if (MAD_Play(music, play_count) < 0) { + return -1; + } + } else if (music->status & MS_decode_error) { + return -1; + } + return 0; +} + +static int MAD_GetAudio(void *context, void *data, int bytes) +{ + MAD_Music *music = (MAD_Music *)context; + return music_pcm_getaudio(context, data, bytes, music->volume, MAD_GetSome); +} + +static int MAD_Seek(void *context, double position) +{ + MAD_Music *music = (MAD_Music *)context; + mad_timer_t target; + int int_part; + + int_part = (int)position; + mad_timer_set(&target, (unsigned long)int_part, (unsigned long)((position - int_part) * 1000000), 1000000); + + music->sample_position = (int)(position * music->sample_rate); + + if (mad_timer_compare(music->next_frame_start, target) > 0) { + /* In order to seek backwards in a VBR file, we have to rewind and + start again from the beginning. This isn't necessary if the + file happens to be CBR, of course; in that case we could seek + directly to the frame we want. But I leave that little + optimization for the future developer who discovers she really + needs it. */ + mad_timer_reset(&music->next_frame_start); + music->status &= ~MS_error_flags; + + MP3_RWseek(&music->mp3file, 0, RW_SEEK_SET); + /* Avoid junk chunk be played after seek -- Vitaly Novichkov */ + SDL_memset(music->input_buffer, 0, sizeof(music->input_buffer)); + } + + /* Now we have to skip frames until we come to the right one. + Again, only truly necessary if the file is VBR. */ + while (mad_timer_compare(music->next_frame_start, target) < 0) { + if (!read_next_frame(music)) { + if ((music->status & MS_error_flags) != 0) { + /* Couldn't read a frame; either an error condition or + end-of-file. Stop. */ + return Mix_SetError("Seek position out of range"); + } + } + } + + /* Here we are, at the beginning of the frame that contains the + target time. Ehh, I say that's close enough. If we wanted to, + we could get more precise by decoding the frame now and counting + the appropriate number of samples out of it. */ + return 0; +} + +static double MAD_Tell(void *context) +{ + MAD_Music *music = (MAD_Music *)context; + return (double)music->sample_position / (double)music->sample_rate; +} + +static double MAD_Duration(void *context) +{ + MAD_Music *music = (MAD_Music *)context; + return music->total_length; +} + +static void MAD_Delete(void *context) +{ + MAD_Music *music = (MAD_Music *)context; + + mad_stream_finish(&music->stream); + mad_frame_finish(&music->frame); + mad_synth_finish(&music->synth); + + if (music->audiostream) { + SDL_FreeAudioStream(music->audiostream); + } + if (music->freesrc) { + SDL_RWclose(music->mp3file.src); + } + SDL_free(music); +} + +Mix_MusicInterface Mix_MusicInterface_MAD = +{ + "MAD", + MIX_MUSIC_MAD, + MUS_MP3, + SDL_FALSE, + SDL_FALSE, + + NULL, /* Load */ + NULL, /* Open */ + MAD_CreateFromRW, + NULL, /* CreateFromFile */ + MAD_SetVolume, + MAD_GetVolume, + MAD_Play, + NULL, /* IsPlaying */ + MAD_GetAudio, + NULL, /* Jump */ + MAD_Seek, + MAD_Tell, + MAD_Duration, + NULL, /* LoopStart */ + NULL, /* LoopEnd */ + NULL, /* LoopLength */ + NULL, /* GetMetaTag */ + NULL, /* Pause */ + NULL, /* Resume */ + NULL, /* Stop */ + MAD_Delete, + NULL, /* Close */ + NULL /* Unload */ +}; + +#endif /* MUSIC_MP3_MAD */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_mad.h b/src/codecs/music_mad.h new file mode 100644 index 0000000..aef77ea --- /dev/null +++ b/src/codecs/music_mad.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports playing MP3 files with libmad */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_MAD; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_mikmod.c b/src/codecs/music_mikmod.c new file mode 100644 index 0000000..ec4f829 --- /dev/null +++ b/src/codecs/music_mikmod.c @@ -0,0 +1,531 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef MUSIC_MOD_MIKMOD + +/* This file supports MOD tracker music streams */ + +#include "SDL_loadso.h" + +#include "music_mikmod.h" + +#include "mikmod.h" + + +/* libmikmod >= 3.3.2 constified several funcs */ +#if (LIBMIKMOD_VERSION < 0x030302) +#define MIKMOD3_CONST +#else +#define MIKMOD3_CONST const +#endif + +typedef struct { + int loaded; + void *handle; + + void (*MikMod_Exit)(void); + CHAR* (*MikMod_InfoDriver)(void); + CHAR* (*MikMod_InfoLoader)(void); + int (*MikMod_Init)(MIKMOD3_CONST CHAR*); + void (*MikMod_RegisterAllLoaders)(void); + void (*MikMod_RegisterDriver)(struct MDRIVER*); + int* MikMod_errno; + MIKMOD3_CONST char* (*MikMod_strerror)(int); + void (*MikMod_free)(void*); + BOOL (*Player_Active)(void); + void (*Player_Free)(MODULE*); + MODULE* (*Player_LoadGeneric)(MREADER*,int,BOOL); + void (*Player_SetPosition)(UWORD); + void (*Player_SetVolume)(SWORD); + void (*Player_Start)(MODULE*); + void (*Player_Stop)(void); + ULONG (*VC_WriteBytes)(SBYTE*,ULONG); + struct MDRIVER* drv_nos; + UWORD* md_device; + UWORD* md_mixfreq; + UWORD* md_mode; + UBYTE* md_musicvolume; + UBYTE* md_pansep; + UBYTE* md_reverb; + UBYTE* md_sndfxvolume; + UBYTE* md_volume; +} mikmod_loader; + +static mikmod_loader mikmod = { + 0, NULL +}; + +#ifdef MIKMOD_DYNAMIC +#define FUNCTION_LOADER(FUNC, SIG) \ + mikmod.FUNC = (SIG) SDL_LoadFunction(mikmod.handle, #FUNC); \ + if (mikmod.FUNC == NULL) { SDL_UnloadObject(mikmod.handle); return -1; } +#define VARIABLE_LOADER(NAME, SIG) \ + mikmod.NAME = (SIG) SDL_LoadFunction(mikmod.handle, #NAME); \ + if (mikmod.NAME == NULL) { SDL_UnloadObject(mikmod.handle); return -1; } +#else +#define FUNCTION_LOADER(FUNC, SIG) \ + mikmod.FUNC = FUNC; +#define VARIABLE_LOADER(NAME, SIG) \ + mikmod.NAME = &NAME; +#endif + +static int MIKMOD_Load(void) +{ + if (mikmod.loaded == 0) { +#ifdef MIKMOD_DYNAMIC + mikmod.handle = SDL_LoadObject(MIKMOD_DYNAMIC); + if (mikmod.handle == NULL) { + return -1; + } +#elif defined(__MACOSX__) + extern void Player_Start(MODULE*) __attribute__((weak_import)); + if (Player_Start == NULL) + { + /* Missing weakly linked framework */ + Mix_SetError("Missing mikmod.framework"); + return -1; + } +#endif + FUNCTION_LOADER(MikMod_Exit, void (*)(void)) + FUNCTION_LOADER(MikMod_InfoDriver, CHAR* (*)(void)) + FUNCTION_LOADER(MikMod_InfoLoader, CHAR* (*)(void)) + FUNCTION_LOADER(MikMod_Init, int (*)(MIKMOD3_CONST CHAR*)) + FUNCTION_LOADER(MikMod_RegisterAllLoaders, void (*)(void)) + FUNCTION_LOADER(MikMod_RegisterDriver, void (*)(struct MDRIVER*)) + VARIABLE_LOADER(MikMod_errno, int*) + FUNCTION_LOADER(MikMod_strerror, MIKMOD3_CONST char* (*)(int)) +#ifdef MIKMOD_DYNAMIC + mikmod.MikMod_free = (void (*)(void*)) SDL_LoadFunction(mikmod.handle, "MikMod_free"); + if (!mikmod.MikMod_free) { + /* libmikmod-3.2.0-beta2 and earlier doesn't have it. */ + mikmod.MikMod_free = free; + } +#else +#if (LIBMIKMOD_VERSION < 0x030200) || (LIBMIKMOD_VERSION == 0x030200 && !defined(DMODE_NOISEREDUCTION)) + /* libmikmod 3.2.0-beta2 or earlier */ + mikmod.MikMod_free = free; +#else + mikmod.MikMod_free = MikMod_free; +#endif +#endif /* MIKMOD_DYNAMIC */ + FUNCTION_LOADER(Player_Active, BOOL (*)(void)) + FUNCTION_LOADER(Player_Free, void (*)(MODULE*)) + FUNCTION_LOADER(Player_LoadGeneric, MODULE* (*)(MREADER*,int,BOOL)) + FUNCTION_LOADER(Player_SetPosition, void (*)(UWORD)) + FUNCTION_LOADER(Player_SetVolume, void (*)(SWORD)) + FUNCTION_LOADER(Player_Start, void (*)(MODULE*)) + FUNCTION_LOADER(Player_Stop, void (*)(void)) + FUNCTION_LOADER(VC_WriteBytes, ULONG (*)(SBYTE*,ULONG)) + VARIABLE_LOADER(drv_nos, MDRIVER*) + VARIABLE_LOADER(md_device, UWORD*) + VARIABLE_LOADER(md_mixfreq, UWORD*) + VARIABLE_LOADER(md_mode, UWORD*) + VARIABLE_LOADER(md_musicvolume, UBYTE*) + VARIABLE_LOADER(md_pansep, UBYTE*) + VARIABLE_LOADER(md_reverb, UBYTE*) + VARIABLE_LOADER(md_sndfxvolume, UBYTE*) + VARIABLE_LOADER(md_volume, UBYTE*) + } + ++mikmod.loaded; + + return 0; +} + +static void MIKMOD_Unload(void) +{ + if (mikmod.loaded == 0) { + return; + } + if (mikmod.loaded == 1) { +#ifdef MIKMOD_DYNAMIC + SDL_UnloadObject(mikmod.handle); +#endif + } + --mikmod.loaded; +} + + +typedef struct +{ + int play_count; + int volume; + MODULE *module; + SDL_AudioStream *stream; + SBYTE *buffer; + ULONG buffer_size; + Mix_MusicMetaTags tags; +} MIKMOD_Music; + + +static int MIKMOD_Seek(void *context, double position); +static void MIKMOD_Delete(void *context); + +/* Initialize the MOD player, with the given mixer settings + This function returns 0, or -1 if there was an error. + */ +static int MIKMOD_Open(const SDL_AudioSpec *spec) +{ + CHAR *list; + + /* Set the MikMod music format */ + if (spec->format == AUDIO_S8 || spec->format == AUDIO_U8) { + /* MIKMOD audio format is AUDIO_U8 */ + *mikmod.md_mode = 0; + } else { + /* MIKMOD audio format is AUDIO_S16SYS */ + *mikmod.md_mode = DMODE_16BITS; + } + if (spec->channels > 1) { + *mikmod.md_mode |= DMODE_STEREO; + } + *mikmod.md_mixfreq = (spec->freq <= 65535) ? (UWORD)spec->freq : 44100; + *mikmod.md_device = 0; + *mikmod.md_volume = 96; + *mikmod.md_musicvolume = 128; + *mikmod.md_sndfxvolume = 128; + *mikmod.md_pansep = 128; + *mikmod.md_reverb = 0; + *mikmod.md_mode |= DMODE_HQMIXER|DMODE_SOFT_MUSIC|DMODE_SURROUND; + + list = mikmod.MikMod_InfoDriver(); + if (list) { + mikmod.MikMod_free(list); + } else { + mikmod.MikMod_RegisterDriver(mikmod.drv_nos); + } + + list = mikmod.MikMod_InfoLoader(); + if (list) { + mikmod.MikMod_free(list); + } else { + mikmod.MikMod_RegisterAllLoaders(); + } + + if (mikmod.MikMod_Init(NULL)) { + Mix_SetError("%s", mikmod.MikMod_strerror(*mikmod.MikMod_errno)); + return -1; + } + return 0; +} + +/* Uninitialize the music players */ +static void MIKMOD_Close(void) +{ + if (mikmod.MikMod_Exit) { + mikmod.MikMod_Exit(); + } +} + +typedef struct +{ + /* MREADER basic members in libmikmod2/3: */ + int (*Seek)(struct MREADER*, long, int); + long (*Tell)(struct MREADER*); + BOOL (*Read)(struct MREADER*, void*, size_t); + int (*Get)(struct MREADER*); + BOOL (*Eof)(struct MREADER*); + /* no iobase members in libmikmod <= 3.2.0-beta2 */ + long iobase, prev_iobase; + + Sint64 eof; + SDL_RWops *src; +} LMM_MREADER; + +int LMM_Seek(struct MREADER *mr,long to,int dir) +{ + Sint64 offset = to; + LMM_MREADER* lmmmr = (LMM_MREADER*)mr; + if (dir == SEEK_SET) { + offset += lmmmr->iobase; + if (offset < lmmmr->iobase) + return -1; + } + return (SDL_RWseek(lmmmr->src, offset, dir) < lmmmr->iobase)? -1 : 0; +} +long LMM_Tell(struct MREADER *mr) +{ + LMM_MREADER* lmmmr = (LMM_MREADER*)mr; + return (long)(SDL_RWtell(lmmmr->src) - lmmmr->iobase); +} +BOOL LMM_Read(struct MREADER *mr,void *buf,size_t sz) +{ + LMM_MREADER* lmmmr = (LMM_MREADER*)mr; + return (BOOL)SDL_RWread(lmmmr->src, buf, sz, 1); +} +int LMM_Get(struct MREADER *mr) +{ + unsigned char c; + LMM_MREADER* lmmmr = (LMM_MREADER*)mr; + if (SDL_RWread(lmmmr->src, &c, 1, 1)) { + return c; + } + return EOF; +} +BOOL LMM_Eof(struct MREADER *mr) +{ + Sint64 offset; + LMM_MREADER* lmmmr = (LMM_MREADER*)mr; + offset = LMM_Tell(mr); + return offset >= lmmmr->eof; +} +MODULE *MikMod_LoadSongRW(SDL_RWops *src, int maxchan) +{ + LMM_MREADER lmmmr; + SDL_memset(&lmmmr, 0, sizeof(LMM_MREADER)); + lmmmr.Seek = LMM_Seek; + lmmmr.Tell = LMM_Tell; + lmmmr.Read = LMM_Read; + lmmmr.Get = LMM_Get; + lmmmr.Eof = LMM_Eof; + + lmmmr.prev_iobase = lmmmr.iobase = SDL_RWtell(src); + SDL_RWseek(src, 0, RW_SEEK_END); + lmmmr.eof = SDL_RWtell(src); + SDL_RWseek(src, lmmmr.iobase, RW_SEEK_SET); + lmmmr.src = src; + return mikmod.Player_LoadGeneric((MREADER*)&lmmmr, maxchan, 0); +} + +/* Load a MOD stream from an SDL_RWops object */ +void *MIKMOD_CreateFromRW(SDL_RWops *src, int freesrc) +{ + MIKMOD_Music *music; + SDL_AudioFormat format; + Uint8 channels; + + music = (MIKMOD_Music *)SDL_calloc(1, sizeof(*music)); + if (!music) { + SDL_OutOfMemory(); + return NULL; + } + music->volume = MIX_MAX_VOLUME; + + music->module = MikMod_LoadSongRW(src, 64); + if (!music->module) { + Mix_SetError("%s", mikmod.MikMod_strerror(*mikmod.MikMod_errno)); + MIKMOD_Delete(music); + return NULL; + } + + /* Allow implicit looping, disable fade out and other flags. */ + music->module->extspd = 1; + music->module->panflag = 1; + music->module->wrap = 0; + music->module->loop = 1; + music->module->fadeout = 0; + + meta_tags_init(&music->tags); + meta_tags_set(&music->tags, MIX_META_TITLE, music->module->songname); + + if ((*mikmod.md_mode & DMODE_16BITS) == DMODE_16BITS) { + format = AUDIO_S16SYS; + } else { + format = AUDIO_U8; + } + if ((*mikmod.md_mode & DMODE_STEREO) == DMODE_STEREO) { + channels = 2; + } else { + channels = 1; + } + music->stream = SDL_NewAudioStream(format, channels, *mikmod.md_mixfreq, + music_spec.format, music_spec.channels, music_spec.freq); + if (!music->stream) { + MIKMOD_Delete(music); + return NULL; + } + + music->buffer_size = music_spec.samples * (SDL_AUDIO_BITSIZE(format) / 8) * channels; + music->buffer = (SBYTE *)SDL_malloc(music->buffer_size); + if (!music->buffer) { + SDL_OutOfMemory(); + MIKMOD_Delete(music); + return NULL; + } + + if (freesrc) { + SDL_RWclose(src); + } + + return music; +} + +/* Set the volume for a MOD stream */ +static void MIKMOD_SetVolume(void *context, int volume) +{ + MIKMOD_Music *music = (MIKMOD_Music *)context; + music->volume = volume; + mikmod.Player_SetVolume((SWORD)volume); +} + +/* Set the volume for a MOD stream */ +static int MIKMOD_GetVolume(void *context) +{ + MIKMOD_Music *music = (MIKMOD_Music *)context; + return music->volume; +} + +/* Start playback of a given MOD stream */ +static int MIKMOD_Play(void *context, int play_count) +{ + MIKMOD_Music *music = (MIKMOD_Music *)context; + music->play_count = play_count; + music->module->initvolume = (UBYTE)music->volume; + mikmod.Player_Start(music->module); + return MIKMOD_Seek(music, 0.0); +} + +/* Return non-zero if a stream is currently playing */ +static SDL_bool MIKMOD_IsPlaying(void *context) +{ + (void)context; + return mikmod.Player_Active() ? SDL_TRUE : SDL_FALSE; +} + +/* Play some of a stream previously started with MOD_play() */ +static int MIKMOD_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + MIKMOD_Music *music = (MIKMOD_Music *)context; + int filled; + + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + /* This never fails, and always writes a full buffer */ + mikmod.VC_WriteBytes(music->buffer, music->buffer_size); + + if (SDL_AudioStreamPut(music->stream, music->buffer, (int)music->buffer_size) < 0) { + return -1; + } + + /* Check to see if we're done now */ + if (!mikmod.Player_Active()) { + if (music->play_count == 1) { + music->play_count = 0; + SDL_AudioStreamFlush(music->stream); + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + if (MIKMOD_Play(music, play_count) < 0) { + return -1; + } + } + } + return 0; +} +static int MIKMOD_GetAudio(void *context, void *data, int bytes) +{ + return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, MIKMOD_GetSome); +} + +/* Jump to a given order */ +static int MIKMOD_Jump(void *context, int order) +{ + (void)context; + mikmod.Player_SetPosition((UWORD)order); + return 0; +} + +/* Jump (seek) to a given position (time is in seconds) */ +static int MIKMOD_Seek(void *context, double position) +{ + (void)context; + /* FIXME: WRONG: THIS IS NOT A TIME SEEK */ + mikmod.Player_SetPosition((UWORD)position); + return 0; +} + +/* Stop playback of a stream previously started with MOD_play() */ +static void MIKMOD_Stop(void *context) +{ + (void)context; + mikmod.Player_Stop(); +} + +static const char* MIKMOD_GetMetaTag(void *context, Mix_MusicMetaTag tag_type) +{ + MIKMOD_Music *music = (MIKMOD_Music *)context; + return meta_tags_get(&music->tags, tag_type); +} + +/* Close the given MOD stream */ +static void MIKMOD_Delete(void *context) +{ + MIKMOD_Music *music = (MIKMOD_Music *)context; + + meta_tags_clear(&music->tags); + if (music->module) { + mikmod.Player_Free(music->module); + } + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } + if (music->buffer) { + SDL_free(music->buffer); + } + SDL_free(music); +} + +Mix_MusicInterface Mix_MusicInterface_MIKMOD = +{ + "MIKMOD", + MIX_MUSIC_MIKMOD, + MUS_MOD, + SDL_FALSE, + SDL_FALSE, + + MIKMOD_Load, + MIKMOD_Open, + MIKMOD_CreateFromRW, + NULL, /* CreateFromFile */ + MIKMOD_SetVolume, + MIKMOD_GetVolume, + MIKMOD_Play, + MIKMOD_IsPlaying, + MIKMOD_GetAudio, + MIKMOD_Jump, + MIKMOD_Seek, + NULL, /* Tell */ + NULL, /* Duration */ + NULL, /* LoopStart */ + NULL, /* LoopEnd */ + NULL, /* LoopLength */ + MIKMOD_GetMetaTag, + NULL, /* Pause */ + NULL, /* Resume */ + MIKMOD_Stop, + MIKMOD_Delete, + MIKMOD_Close, + MIKMOD_Unload +}; + +#endif /* MUSIC_MOD_MIKMOD */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_mikmod.h b/src/codecs/music_mikmod.h new file mode 100644 index 0000000..1572a30 --- /dev/null +++ b/src/codecs/music_mikmod.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports playing MOD files with libmikmod */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_MIKMOD; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_modplug.c b/src/codecs/music_modplug.c new file mode 100644 index 0000000..062afe6 --- /dev/null +++ b/src/codecs/music_modplug.c @@ -0,0 +1,361 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef MUSIC_MOD_MODPLUG + +#include "SDL_loadso.h" + +#include "music_modplug.h" + +#ifdef MODPLUG_HEADER +#include MODPLUG_HEADER +#else +#include +#endif + +typedef struct { + int loaded; + void *handle; + + ModPlugFile* (*ModPlug_Load)(const void* data, int size); + void (*ModPlug_Unload)(ModPlugFile* file); + int (*ModPlug_Read)(ModPlugFile* file, void* buffer, int size); + void (*ModPlug_Seek)(ModPlugFile* file, int millisecond); + void (*ModPlug_SeekOrder)(ModPlugFile* file, int order); + int (*ModPlug_GetLength)(ModPlugFile* file); + void (*ModPlug_GetSettings)(ModPlug_Settings* settings); + void (*ModPlug_SetSettings)(const ModPlug_Settings* settings); + void (*ModPlug_SetMasterVolume)(ModPlugFile* file,unsigned int cvol); + const char* (*ModPlug_GetName)(ModPlugFile* file); +} modplug_loader; + +static modplug_loader modplug = { + 0, NULL +}; + + +static ModPlug_Settings settings; + +#ifdef MODPLUG_DYNAMIC +#define FUNCTION_LOADER(FUNC, SIG) \ + modplug.FUNC = (SIG) SDL_LoadFunction(modplug.handle, #FUNC); \ + if (modplug.FUNC == NULL) { SDL_UnloadObject(modplug.handle); return -1; } +#else +#define FUNCTION_LOADER(FUNC, SIG) \ + modplug.FUNC = FUNC; +#endif + +static int MODPLUG_Load(void) +{ + if (modplug.loaded == 0) { +#ifdef MODPLUG_DYNAMIC + modplug.handle = SDL_LoadObject(MODPLUG_DYNAMIC); + if (modplug.handle == NULL) { + return -1; + } +#elif defined(__MACOSX__) + extern ModPlugFile* ModPlug_Load(const void* data, int size) __attribute__((weak_import)); + if (ModPlug_Load == NULL) { + /* Missing weakly linked framework */ + Mix_SetError("Missing modplug.framework"); + return -1; + } +#endif + FUNCTION_LOADER(ModPlug_Load, ModPlugFile* (*)(const void* data, int size)) + FUNCTION_LOADER(ModPlug_Unload, void (*)(ModPlugFile* file)) + FUNCTION_LOADER(ModPlug_Read, int (*)(ModPlugFile* file, void* buffer, int size)) + FUNCTION_LOADER(ModPlug_Seek, void (*)(ModPlugFile* file, int millisecond)) + FUNCTION_LOADER(ModPlug_SeekOrder, void (*)(ModPlugFile* file, int order)) + FUNCTION_LOADER(ModPlug_GetLength, int (*)(ModPlugFile* file)) + FUNCTION_LOADER(ModPlug_GetSettings, void (*)(ModPlug_Settings* settings)) + FUNCTION_LOADER(ModPlug_SetSettings, void (*)(const ModPlug_Settings* settings)) + FUNCTION_LOADER(ModPlug_SetMasterVolume, void (*)(ModPlugFile* file,unsigned int cvol)) + FUNCTION_LOADER(ModPlug_GetName, const char* (*)(ModPlugFile* file)) + } + ++modplug.loaded; + + return 0; +} + +static void MODPLUG_Unload(void) +{ + if (modplug.loaded == 0) { + return; + } + if (modplug.loaded == 1) { +#ifdef MODPLUG_DYNAMIC + SDL_UnloadObject(modplug.handle); +#endif + } + --modplug.loaded; +} + + +typedef struct +{ + int volume; + int play_count; + ModPlugFile *file; + SDL_AudioStream *stream; + void *buffer; + int buffer_size; + Mix_MusicMetaTags tags; +} MODPLUG_Music; + + +static int MODPLUG_Seek(void *context, double position); +static void MODPLUG_Delete(void *context); + +static int MODPLUG_Open(const SDL_AudioSpec *spec) +{ + /* ModPlug supports U8 or S16 audio output */ + modplug.ModPlug_GetSettings(&settings); + settings.mFlags = MODPLUG_ENABLE_OVERSAMPLING; + if (spec->channels == 1) { + settings.mChannels = 1; + } else { + settings.mChannels = 2; + } + if (SDL_AUDIO_BITSIZE(spec->format) == 8) { + settings.mBits = 8; + } else { + settings.mBits = 16; + } + if (spec->freq >= 44100) { + settings.mFrequency = 44100; + } else if (spec->freq >= 22050) { + settings.mFrequency = 22050; + } else { + settings.mFrequency = 11025; + } + settings.mResamplingMode = MODPLUG_RESAMPLE_FIR; + settings.mReverbDepth = 0; + settings.mReverbDelay = 100; + settings.mBassAmount = 0; + settings.mBassRange = 50; + settings.mSurroundDepth = 0; + settings.mSurroundDelay = 10; + settings.mLoopCount = -1; + modplug.ModPlug_SetSettings(&settings); + return 0; +} + +/* Load a modplug stream from an SDL_RWops object */ +void *MODPLUG_CreateFromRW(SDL_RWops *src, int freesrc) +{ + MODPLUG_Music *music; + void *buffer; + size_t size; + + music = (MODPLUG_Music *)SDL_calloc(1, sizeof(*music)); + if (!music) { + SDL_OutOfMemory(); + return NULL; + } + + music->volume = MIX_MAX_VOLUME; + + music->stream = SDL_NewAudioStream((settings.mBits == 8) ? AUDIO_U8 : AUDIO_S16SYS, (Uint8)settings.mChannels, settings.mFrequency, + music_spec.format, music_spec.channels, music_spec.freq); + if (!music->stream) { + MODPLUG_Delete(music); + return NULL; + } + + music->buffer_size = music_spec.samples * (settings.mBits / 8) * settings.mChannels; + music->buffer = SDL_malloc((size_t)music->buffer_size); + if (!music->buffer) { + MODPLUG_Delete(music); + return NULL; + } + + buffer = SDL_LoadFile_RW(src, &size, SDL_FALSE); + if (buffer) { + music->file = modplug.ModPlug_Load(buffer, (int)size); + if (!music->file) { + Mix_SetError("ModPlug_Load failed"); + } + SDL_free(buffer); + } + + if (!music->file) { + MODPLUG_Delete(music); + return NULL; + } + + meta_tags_init(&music->tags); + meta_tags_set(&music->tags, MIX_META_TITLE, modplug.ModPlug_GetName(music->file)); + + if (freesrc) { + SDL_RWclose(src); + } + return music; +} + +/* Set the volume for a modplug stream */ +static void MODPLUG_SetVolume(void *context, int volume) +{ + MODPLUG_Music *music = (MODPLUG_Music *)context; + music->volume = volume; + modplug.ModPlug_SetMasterVolume(music->file, (unsigned int)volume * 2); /* 0-512, reduced to 0-256 to prevent clipping */ +} + +/* Get the volume for a modplug stream */ +static int MODPLUG_GetVolume(void *context) +{ + MODPLUG_Music *music = (MODPLUG_Music *)context; + return music->volume; +} + +/* Start playback of a given modplug stream */ +static int MODPLUG_Play(void *context, int play_count) +{ + MODPLUG_Music *music = (MODPLUG_Music *)context; + music->play_count = play_count; + return MODPLUG_Seek(music, 0.0); +} + +/* Play some of a stream previously started with modplug_play() */ +static int MODPLUG_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + MODPLUG_Music *music = (MODPLUG_Music *)context; + int filled, amount; + + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + amount = modplug.ModPlug_Read(music->file, music->buffer, music->buffer_size); + if (amount > 0) { + if (SDL_AudioStreamPut(music->stream, music->buffer, amount) < 0) { + return -1; + } + } else { + if (music->play_count == 1) { + music->play_count = 0; + SDL_AudioStreamFlush(music->stream); + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + if (MODPLUG_Play(music, play_count) < 0) { + return -1; + } + } + } + return 0; +} + +static int MODPLUG_GetAudio(void *context, void *data, int bytes) +{ + return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, MODPLUG_GetSome); +} + +/* Jump to a given order */ +static int MODPLUG_Jump(void *context, int order) +{ + MODPLUG_Music *music = (MODPLUG_Music *)context; + modplug.ModPlug_SeekOrder(music->file, order); + return 0; +} + +/* Jump (seek) to a given position */ +static int MODPLUG_Seek(void *context, double position) +{ + MODPLUG_Music *music = (MODPLUG_Music *)context; + modplug.ModPlug_Seek(music->file, (int)(position*1000)); + return 0; +} + +/* Return music duration in seconds */ +static double MODPLUG_Duration(void *context) +{ + MODPLUG_Music *music = (MODPLUG_Music *)context; + return modplug.ModPlug_GetLength(music->file) / 1000.0; +} + +static const char* MODPLUG_GetMetaTag(void *context, Mix_MusicMetaTag tag_type) +{ + MODPLUG_Music *music = (MODPLUG_Music *)context; + return meta_tags_get(&music->tags, tag_type); +} + +/* Close the given modplug stream */ +static void MODPLUG_Delete(void *context) +{ + MODPLUG_Music *music = (MODPLUG_Music *)context; + meta_tags_clear(&music->tags); + if (music->file) { + modplug.ModPlug_Unload(music->file); + } + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } + if (music->buffer) { + SDL_free(music->buffer); + } + SDL_free(music); +} + +Mix_MusicInterface Mix_MusicInterface_MODPLUG = +{ + "MODPLUG", + MIX_MUSIC_MODPLUG, + MUS_MOD, + SDL_FALSE, + SDL_FALSE, + + MODPLUG_Load, + MODPLUG_Open, + MODPLUG_CreateFromRW, + NULL, /* CreateFromFile */ + MODPLUG_SetVolume, + MODPLUG_GetVolume, + MODPLUG_Play, + NULL, /* IsPlaying */ + MODPLUG_GetAudio, + MODPLUG_Jump, + MODPLUG_Seek, + NULL, /* Tell */ + MODPLUG_Duration, + NULL, /* LoopStart */ + NULL, /* LoopEnd */ + NULL, /* LoopLength */ + MODPLUG_GetMetaTag, + NULL, /* Pause */ + NULL, /* Resume */ + NULL, /* Stop */ + MODPLUG_Delete, + NULL, /* Close */ + MODPLUG_Unload +}; + +#endif /* MUSIC_MOD_MODPLUG */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_modplug.h b/src/codecs/music_modplug.h new file mode 100644 index 0000000..54d26f5 --- /dev/null +++ b/src/codecs/music_modplug.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports playing MOD files with libmodplug */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_MODPLUG; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_mpg123.c b/src/codecs/music_mpg123.c new file mode 100644 index 0000000..43d11dc --- /dev/null +++ b/src/codecs/music_mpg123.c @@ -0,0 +1,522 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports playing MP3 files with mpg123 */ + +#ifdef MUSIC_MP3_MPG123 + +#include "SDL_loadso.h" +#include "SDL_assert.h" + +#include "music_mpg123.h" +#include "mp3utils.h" + +#include /* For SEEK_SET */ +#include +#ifdef _MSC_VER +typedef ptrdiff_t MIX_SSIZE_T; +#else +typedef ssize_t MIX_SSIZE_T; +#endif + + +typedef struct { + int loaded; + void *handle; + + int (*mpg123_close)(mpg123_handle *mh); + void (*mpg123_delete)(mpg123_handle *mh); + void (*mpg123_exit)(void); + int (*mpg123_format)( mpg123_handle *mh, long rate, int channels, int encodings ); + int (*mpg123_format_none)(mpg123_handle *mh); + int (*mpg123_getformat)( mpg123_handle *mh, long *rate, int *channels, int *encoding ); + int (*mpg123_init)(void); + mpg123_handle *(*mpg123_new)(const char* decoder, int *error); + int (*mpg123_open_handle)(mpg123_handle *mh, void *iohandle); + const char* (*mpg123_plain_strerror)(int errcode); + void (*mpg123_rates)(const long **list, size_t *number); + int (*mpg123_read)(mpg123_handle *mh, unsigned char *outmemory, size_t outmemsize, size_t *done ); + int (*mpg123_replace_reader_handle)( mpg123_handle *mh, MIX_SSIZE_T (*r_read) (void *, void *, size_t), off_t (*r_lseek)(void *, off_t, int), void (*cleanup)(void*) ); + off_t (*mpg123_seek)( mpg123_handle *mh, off_t sampleoff, int whence ); + off_t (*mpg123_tell)( mpg123_handle *mh); + off_t (*mpg123_length)(mpg123_handle *mh); + const char* (*mpg123_strerror)(mpg123_handle *mh); +} mpg123_loader; + +static mpg123_loader mpg123 = { + 0, NULL +}; + +#ifdef MPG123_DYNAMIC +#define FUNCTION_LOADER(FUNC, SIG) \ + mpg123.FUNC = (SIG) SDL_LoadFunction(mpg123.handle, #FUNC); \ + if (mpg123.FUNC == NULL) { SDL_UnloadObject(mpg123.handle); return -1; } +#else +#define FUNCTION_LOADER(FUNC, SIG) \ + mpg123.FUNC = FUNC; +#endif + +static int MPG123_Load(void) +{ + if (mpg123.loaded == 0) { +#ifdef MPG123_DYNAMIC + mpg123.handle = SDL_LoadObject(MPG123_DYNAMIC); + if (mpg123.handle == NULL) { + return -1; + } +#elif defined(__MACOSX__) + extern int mpg123_init(void) __attribute__((weak_import)); + if (mpg123_init == NULL) + { + /* Missing weakly linked framework */ + Mix_SetError("Missing mpg123.framework"); + return -1; + } +#endif + FUNCTION_LOADER(mpg123_close, int (*)(mpg123_handle *mh)) + FUNCTION_LOADER(mpg123_delete, void (*)(mpg123_handle *mh)) + FUNCTION_LOADER(mpg123_exit, void (*)(void)) + FUNCTION_LOADER(mpg123_format, int (*)( mpg123_handle *mh, long rate, int channels, int encodings )) + FUNCTION_LOADER(mpg123_format_none, int (*)(mpg123_handle *mh)) + FUNCTION_LOADER(mpg123_getformat, int (*)( mpg123_handle *mh, long *rate, int *channels, int *encoding )) + FUNCTION_LOADER(mpg123_init, int (*)(void)) + FUNCTION_LOADER(mpg123_new, mpg123_handle *(*)(const char* decoder, int *error)) + FUNCTION_LOADER(mpg123_open_handle, int (*)(mpg123_handle *mh, void *iohandle)) + FUNCTION_LOADER(mpg123_plain_strerror, const char* (*)(int errcode)) + FUNCTION_LOADER(mpg123_rates, void (*)(const long **list, size_t *number)) + FUNCTION_LOADER(mpg123_read, int (*)(mpg123_handle *mh, unsigned char *outmemory, size_t outmemsize, size_t *done )) + FUNCTION_LOADER(mpg123_replace_reader_handle, int (*)( mpg123_handle *mh, MIX_SSIZE_T (*r_read) (void *, void *, size_t), off_t (*r_lseek)(void *, off_t, int), void (*cleanup)(void*) )) + FUNCTION_LOADER(mpg123_seek, off_t (*)( mpg123_handle *mh, off_t sampleoff, int whence )) + FUNCTION_LOADER(mpg123_tell, off_t (*)( mpg123_handle *mh)) + FUNCTION_LOADER(mpg123_length, off_t (*)(mpg123_handle *mh)) + FUNCTION_LOADER(mpg123_strerror, const char* (*)(mpg123_handle *mh)) + } + ++mpg123.loaded; + + return 0; +} + +static void MPG123_Unload(void) +{ + if (mpg123.loaded == 0) { + return; + } + if (mpg123.loaded == 1) { +#ifdef MPG123_DYNAMIC + SDL_UnloadObject(mpg123.handle); +#endif + } + --mpg123.loaded; +} + + +typedef struct +{ + struct mp3file_t mp3file; + int play_count; + int freesrc; + int volume; + + mpg123_handle* handle; + SDL_AudioStream *stream; + unsigned char *buffer; + size_t buffer_size; + long sample_rate; + off_t total_length; +} MPG123_Music; + + +static int MPG123_Seek(void *context, double secs); +static void MPG123_Delete(void *context); + + +static int mpg123_format_to_sdl(int fmt) +{ + switch (fmt) { + case MPG123_ENC_SIGNED_8: return AUDIO_S8; + case MPG123_ENC_UNSIGNED_8: return AUDIO_U8; + case MPG123_ENC_SIGNED_16: return AUDIO_S16SYS; + case MPG123_ENC_UNSIGNED_16: return AUDIO_U16SYS; + case MPG123_ENC_SIGNED_32: return AUDIO_S32SYS; + case MPG123_ENC_FLOAT_32: return AUDIO_F32SYS; + default: return -1; + } +} + +/*#define DEBUG_MPG123*/ +#ifdef DEBUG_MPG123 +static const char *mpg123_format_str(int fmt) +{ + switch (fmt) { +#define f(x) case x: return #x; + f(MPG123_ENC_UNSIGNED_8) + f(MPG123_ENC_UNSIGNED_16) + f(MPG123_ENC_SIGNED_8) + f(MPG123_ENC_SIGNED_16) + f(MPG123_ENC_SIGNED_32) + f(MPG123_ENC_FLOAT_32) +#undef f + } + return "unknown"; +} +#endif + +static char const* mpg_err(mpg123_handle* mpg, int result) +{ + char const* err = "unknown error"; + + if (mpg && result == MPG123_ERR) { + err = mpg123.mpg123_strerror(mpg); + } else { + err = mpg123.mpg123_plain_strerror(result); + } + return err; +} + +/* we're gonna override mpg123's I/O with these wrappers for RWops */ +static MIX_SSIZE_T rwops_read(void* p, void* dst, size_t n) +{ + return (MIX_SSIZE_T)MP3_RWread((struct mp3file_t *)p, dst, 1, n); +} + +static off_t rwops_seek(void* p, off_t offset, int whence) +{ + return (off_t)MP3_RWseek((struct mp3file_t *)p, (Sint64)offset, whence); +} + +static void rwops_cleanup(void* p) +{ + (void)p; + /* do nothing, we will free the file later */ +} + + +static int MPG123_Open(const SDL_AudioSpec *spec) +{ + (void)spec; + if (mpg123.mpg123_init() != MPG123_OK) { + Mix_SetError("mpg123_init() failed"); + return -1; + } + return 0; +} + +static void *MPG123_CreateFromRW(SDL_RWops *src, int freesrc) +{ + MPG123_Music *music; + int result, format, channels, encoding; + long rate; + const long *rates; + size_t i, num_rates; + + music = (MPG123_Music*)SDL_calloc(1, sizeof(*music)); + if (!music) { + SDL_OutOfMemory(); + return NULL; + } + music->volume = MIX_MAX_VOLUME; + + if (MP3_RWinit(&music->mp3file, src) < 0) { + SDL_free(music); + return NULL; + } + if (mp3_skiptags(&music->mp3file, SDL_TRUE) < 0) { + SDL_free(music); + Mix_SetError("music_mpg123: corrupt mp3 file (bad tags.)"); + return NULL; + } + + /* Just assume 16-bit 2 channel audio for now */ + music->buffer_size = music_spec.samples * sizeof(Sint16) * 2; + music->buffer = (unsigned char *)SDL_malloc(music->buffer_size); + if (!music->buffer) { + MPG123_Delete(music); + SDL_OutOfMemory(); + return NULL; + } + + music->handle = mpg123.mpg123_new(0, &result); + if (result != MPG123_OK) { + MPG123_Delete(music); + Mix_SetError("mpg123_new failed"); + return NULL; + } + + result = mpg123.mpg123_replace_reader_handle( + music->handle, + rwops_read, rwops_seek, rwops_cleanup + ); + if (result != MPG123_OK) { + MPG123_Delete(music); + Mix_SetError("mpg123_replace_reader_handle: %s", mpg_err(music->handle, result)); + return NULL; + } + + result = mpg123.mpg123_format_none(music->handle); + if (result != MPG123_OK) { + MPG123_Delete(music); + Mix_SetError("mpg123_format_none: %s", mpg_err(music->handle, result)); + return NULL; + } + + mpg123.mpg123_rates(&rates, &num_rates); + for (i = 0; i < num_rates; ++i) { + const int channels = (MPG123_MONO|MPG123_STEREO); + const int formats = (MPG123_ENC_SIGNED_8 | + MPG123_ENC_UNSIGNED_8 | + MPG123_ENC_SIGNED_16 | + MPG123_ENC_UNSIGNED_16 | + MPG123_ENC_SIGNED_32 | + MPG123_ENC_FLOAT_32); + + mpg123.mpg123_format(music->handle, rates[i], channels, formats); + } + + result = mpg123.mpg123_open_handle(music->handle, &music->mp3file); + if (result != MPG123_OK) { + MPG123_Delete(music); + Mix_SetError("mpg123_open_handle: %s", mpg_err(music->handle, result)); + return NULL; + } + + result = mpg123.mpg123_getformat(music->handle, &rate, &channels, &encoding); + if (result != MPG123_OK) { + MPG123_Delete(music); + Mix_SetError("mpg123_getformat: %s", mpg_err(music->handle, result)); + return NULL; + } +#ifdef DEBUG_MPG123 + printf("MPG123 format: %s, channels: %d, rate: %ld\n", + mpg123_format_str(encoding), channels, rate); +#endif + + format = mpg123_format_to_sdl(encoding); + SDL_assert(format != -1); + music->sample_rate = rate; + + music->stream = SDL_NewAudioStream((SDL_AudioFormat)format, (Uint8)channels, (int)rate, + music_spec.format, music_spec.channels, music_spec.freq); + if (!music->stream) { + MPG123_Delete(music); + return NULL; + } + + music->total_length = mpg123.mpg123_length(music->handle); + + music->freesrc = freesrc; + return music; +} + +static void MPG123_SetVolume(void *context, int volume) +{ + MPG123_Music *music = (MPG123_Music *)context; + music->volume = volume; +} + +static int MPG123_GetVolume(void *context) +{ + MPG123_Music *music = (MPG123_Music *)context; + return music->volume; +} + +static int MPG123_Play(void *context, int play_count) +{ + MPG123_Music *music = (MPG123_Music *)context; + music->play_count = play_count; + return MPG123_Seek(music, 0.0); +} + +/* read some mp3 stream data and convert it for output */ +static int MPG123_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + MPG123_Music *music = (MPG123_Music *)context; + int filled, result; + size_t amount; + long rate; + int channels, encoding, format; + + if (music->stream) { + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + result = mpg123.mpg123_read(music->handle, music->buffer, music->buffer_size, &amount); + switch (result) { + case MPG123_OK: + if (SDL_AudioStreamPut(music->stream, music->buffer, (int)amount) < 0) { + return -1; + } + break; + + case MPG123_NEW_FORMAT: + result = mpg123.mpg123_getformat(music->handle, &rate, &channels, &encoding); + if (result != MPG123_OK) { + Mix_SetError("mpg123_getformat: %s", mpg_err(music->handle, result)); + return -1; + } +#ifdef DEBUG_MPG123 + printf("MPG123 format: %s, channels: %d, rate: %ld\n", + mpg123_format_str(encoding), channels, rate); +#endif + + format = mpg123_format_to_sdl(encoding); + SDL_assert(format != -1); + + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } + music->stream = SDL_NewAudioStream((SDL_AudioFormat)format, (Uint8)channels, (int)rate, + music_spec.format, music_spec.channels, music_spec.freq); + if (!music->stream) { + return -1; + } + music->sample_rate = rate; + break; + + case MPG123_DONE: + if (music->play_count == 1) { + music->play_count = 0; + SDL_AudioStreamFlush(music->stream); + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + if (MPG123_Play(music, play_count) < 0) { + return -1; + } + } + break; + default: + Mix_SetError("mpg123_read: %s", mpg_err(music->handle, result)); + return -1; + } + return 0; +} +static int MPG123_GetAudio(void *context, void *data, int bytes) +{ + MPG123_Music *music = (MPG123_Music *)context; + return music_pcm_getaudio(context, data, bytes, music->volume, MPG123_GetSome); +} + +static int MPG123_Seek(void *context, double secs) +{ + MPG123_Music *music = (MPG123_Music *)context; + off_t offset = (off_t)(music->sample_rate * secs); + + if ((offset = mpg123.mpg123_seek(music->handle, offset, SEEK_SET)) < 0) { + return Mix_SetError("mpg123_seek: %s", mpg_err(music->handle, (int)-offset)); + } + return 0; +} + +static double MPG123_Tell(void *context) +{ + MPG123_Music *music = (MPG123_Music *)context; + off_t offset = 0; + if (!music->sample_rate) { + return 0.0; + } + if ((offset = mpg123.mpg123_tell(music->handle)) < 0) { + return Mix_SetError("mpg123_tell: %s", mpg_err(music->handle, (int)-offset)); + } + return (double)offset / music->sample_rate; +} + +/* Return music duration in seconds */ +static double MPG123_Duration(void *context) +{ + MPG123_Music *music = (MPG123_Music *)context; + if (music->total_length < 0) { + return -1.0; + } + return (double)music->total_length / music->sample_rate; +} + +static void MPG123_Delete(void *context) +{ + MPG123_Music *music = (MPG123_Music *)context; + + if (music->handle) { + mpg123.mpg123_close(music->handle); + mpg123.mpg123_delete(music->handle); + } + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } + if (music->buffer) { + SDL_free(music->buffer); + } + if (music->freesrc) { + SDL_RWclose(music->mp3file.src); + } + SDL_free(music); +} + +static void MPG123_Close(void) +{ + mpg123.mpg123_exit(); +} + +Mix_MusicInterface Mix_MusicInterface_MPG123 = +{ + "MPG123", + MIX_MUSIC_MPG123, + MUS_MP3, + SDL_FALSE, + SDL_FALSE, + + MPG123_Load, + MPG123_Open, + MPG123_CreateFromRW, + NULL, /* CreateFromFile */ + MPG123_SetVolume, + MPG123_GetVolume, + MPG123_Play, + NULL, /* IsPlaying */ + MPG123_GetAudio, + NULL, /* Jump */ + MPG123_Seek, + MPG123_Tell, + MPG123_Duration, + NULL, /* LoopStart */ + NULL, /* LoopEnd */ + NULL, /* LoopLength */ + NULL, /* GetMetaTag */ + NULL, /* Pause */ + NULL, /* Resume */ + NULL, /* Stop */ + MPG123_Delete, + MPG123_Close, + MPG123_Unload +}; + +#endif /* MUSIC_MP3_MPG123 */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_mpg123.h b/src/codecs/music_mpg123.h new file mode 100644 index 0000000..d576604 --- /dev/null +++ b/src/codecs/music_mpg123.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports playing MP3 files with mpg123 */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_MPG123; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_nativemidi.c b/src/codecs/music_nativemidi.c new file mode 100644 index 0000000..b5c0103 --- /dev/null +++ b/src/codecs/music_nativemidi.c @@ -0,0 +1,121 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef MUSIC_MID_NATIVE + +/* This file supports playing MIDI files with OS APIs */ + +#include "music_nativemidi.h" +#include "native_midi/native_midi.h" + + +static void *NATIVEMIDI_CreateFromRW(SDL_RWops *src, int freesrc) +{ + NativeMidiSong *music = native_midi_loadsong_RW(src, freesrc); + if (!music) { + Mix_SetError("%s", native_midi_error()); + } + return music; +} + +static int NATIVEMIDI_Play(void *context, int play_count) +{ + NativeMidiSong *music = (NativeMidiSong *)context; + int loops = play_count; + if (loops > 0) { + --loops; + } + native_midi_start(music, loops); + return 0; +} + +static void NATIVEMIDI_SetVolume(void *context, int volume) +{ + (void)context; + native_midi_setvolume(volume); +} + +static SDL_bool NATIVEMIDI_IsPlaying(void *context) +{ + (void)context; + return native_midi_active() ? SDL_TRUE : SDL_FALSE; +} + +static void NATIVEMIDI_Pause(void *context) +{ + (void)context; + native_midi_pause(); +} + +static void NATIVEMIDI_Resume(void *context) +{ + (void)context; + native_midi_resume(); +} + +static void NATIVEMIDI_Stop(void *context) +{ + (void)context; + native_midi_stop(); +} + +static void NATIVEMIDI_Delete(void *context) +{ + NativeMidiSong *music = (NativeMidiSong *)context; + native_midi_freesong(music); +} + +Mix_MusicInterface Mix_MusicInterface_NATIVEMIDI = +{ + "NATIVEMIDI", + MIX_MUSIC_NATIVEMIDI, + MUS_MID, + SDL_FALSE, + SDL_FALSE, + + NULL, /* Load */ + NULL, /* Open */ + NATIVEMIDI_CreateFromRW, + NULL, /* CreateFromFile */ + NATIVEMIDI_SetVolume, + NULL, /* GetVolume */ + NATIVEMIDI_Play, + NATIVEMIDI_IsPlaying, + NULL, /* GetAudio */ + NULL, /* Jump */ + NULL, /* Seek */ + NULL, /* Tell */ + NULL, /* Duration */ + NULL, /* LoopStart */ + NULL, /* LoopEnd */ + NULL, /* LoopLength */ + NULL, /* GetMetaTag */ + NATIVEMIDI_Pause, + NATIVEMIDI_Resume, + NATIVEMIDI_Stop, + NATIVEMIDI_Delete, + NULL, /* Close */ + NULL /* Unload */ +}; + +#endif /* MUSIC_MID_NATIVE */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_nativemidi.h b/src/codecs/music_nativemidi.h new file mode 100644 index 0000000..a8c3970 --- /dev/null +++ b/src/codecs/music_nativemidi.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports playing MIDI files with OS APIs */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_NATIVEMIDI; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_ogg.c b/src/codecs/music_ogg.c new file mode 100644 index 0000000..820f2b7 --- /dev/null +++ b/src/codecs/music_ogg.c @@ -0,0 +1,559 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef MUSIC_OGG + +/* This file supports Ogg Vorbis music streams */ + +#include "SDL_loadso.h" + +#include "music_ogg.h" +#include "utils.h" + +#define OV_EXCLUDE_STATIC_CALLBACKS +#if defined(OGG_HEADER) +#include OGG_HEADER +#elif defined(OGG_USE_TREMOR) +#include +#else +#include +#endif + + +typedef struct { + int loaded; + void *handle; + int (*ov_clear)(OggVorbis_File *vf); + vorbis_info *(*ov_info)(OggVorbis_File *vf,int link); + vorbis_comment *(*ov_comment)(OggVorbis_File *vf,int link); + int (*ov_open_callbacks)(void *datasource, OggVorbis_File *vf, const char *initial, long ibytes, ov_callbacks callbacks); + ogg_int64_t (*ov_pcm_total)(OggVorbis_File *vf,int i); +#ifdef OGG_USE_TREMOR + long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int *bitstream); + int (*ov_time_seek)(OggVorbis_File *vf,ogg_int64_t pos); + ogg_int64_t (*ov_time_tell)(OggVorbis_File *vf); + ogg_int64_t (*ov_time_total)(OggVorbis_File *vf, int i); +#else + long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int bigendianp,int word,int sgned,int *bitstream); + int (*ov_time_seek)(OggVorbis_File *vf,double pos); + double (*ov_time_tell)(OggVorbis_File *vf); + double (*ov_time_total)(OggVorbis_File *vf, int i); +#endif + int (*ov_pcm_seek)(OggVorbis_File *vf, ogg_int64_t pos); + ogg_int64_t (*ov_pcm_tell)(OggVorbis_File *vf); +} vorbis_loader; + +static vorbis_loader vorbis = { + 0, NULL +}; + +#ifdef OGG_DYNAMIC +#define FUNCTION_LOADER(FUNC, SIG) \ + vorbis.FUNC = (SIG) SDL_LoadFunction(vorbis.handle, #FUNC); \ + if (vorbis.FUNC == NULL) { SDL_UnloadObject(vorbis.handle); return -1; } +#else +#define FUNCTION_LOADER(FUNC, SIG) \ + vorbis.FUNC = FUNC; +#endif + +static int OGG_Load(void) +{ + if (vorbis.loaded == 0) { +#ifdef OGG_DYNAMIC + vorbis.handle = SDL_LoadObject(OGG_DYNAMIC); + if (vorbis.handle == NULL) { + return -1; + } +#elif defined(__MACOSX__) + extern int ov_open_callbacks(void*, OggVorbis_File*, const char*, long, ov_callbacks) __attribute__((weak_import)); + if (ov_open_callbacks == NULL) + { + /* Missing weakly linked framework */ + Mix_SetError("Missing Vorbis.framework"); + return -1; + } +#endif + FUNCTION_LOADER(ov_clear, int (*)(OggVorbis_File *)) + FUNCTION_LOADER(ov_info, vorbis_info *(*)(OggVorbis_File *,int)) + FUNCTION_LOADER(ov_comment, vorbis_comment *(*)(OggVorbis_File *,int)) + FUNCTION_LOADER(ov_open_callbacks, int (*)(void *,OggVorbis_File *,const char *,long,ov_callbacks)) + FUNCTION_LOADER(ov_pcm_total, ogg_int64_t (*)(OggVorbis_File *,int)) +#ifdef OGG_USE_TREMOR + FUNCTION_LOADER(ov_read, long (*)(OggVorbis_File *,char *,int,int *)) + FUNCTION_LOADER(ov_time_seek, int (*)(OggVorbis_File *,ogg_int64_t)) + FUNCTION_LOADER(ov_time_tell, ogg_int64_t (*)(OggVorbis_File *)) + FUNCTION_LOADER(ov_time_total, ogg_int64_t (*)(OggVorbis_File *, int)) +#else + FUNCTION_LOADER(ov_read, long (*)(OggVorbis_File *,char *,int,int,int,int,int *)) + FUNCTION_LOADER(ov_time_seek, int (*)(OggVorbis_File *,double)) + FUNCTION_LOADER(ov_time_tell, double (*)(OggVorbis_File *)) + FUNCTION_LOADER(ov_time_total, double (*)(OggVorbis_File *, int)) +#endif + FUNCTION_LOADER(ov_pcm_seek, int (*)(OggVorbis_File *,ogg_int64_t)) + FUNCTION_LOADER(ov_pcm_tell, ogg_int64_t (*)(OggVorbis_File *)) + } + ++vorbis.loaded; + + return 0; +} + +static void OGG_Unload(void) +{ + if (vorbis.loaded == 0) { + return; + } + if (vorbis.loaded == 1) { +#ifdef OGG_DYNAMIC + SDL_UnloadObject(vorbis.handle); +#endif + } + --vorbis.loaded; +} + + +typedef struct { + SDL_RWops *src; + int freesrc; + int play_count; + int volume; + OggVorbis_File vf; + vorbis_info vi; + int section; + SDL_AudioStream *stream; + char *buffer; + int buffer_size; + int loop; + ogg_int64_t loop_start; + ogg_int64_t loop_end; + ogg_int64_t loop_len; + Mix_MusicMetaTags tags; +} OGG_music; + + +static int set_ov_error(const char *function, int error) +{ +#define HANDLE_ERROR_CASE(X) case X: Mix_SetError("%s: %s", function, #X); break; + switch (error) { + HANDLE_ERROR_CASE(OV_FALSE) + HANDLE_ERROR_CASE(OV_EOF) + HANDLE_ERROR_CASE(OV_HOLE) + HANDLE_ERROR_CASE(OV_EREAD) + HANDLE_ERROR_CASE(OV_EFAULT) + HANDLE_ERROR_CASE(OV_EIMPL) + HANDLE_ERROR_CASE(OV_EINVAL) + HANDLE_ERROR_CASE(OV_ENOTVORBIS) + HANDLE_ERROR_CASE(OV_EBADHEADER) + HANDLE_ERROR_CASE(OV_EVERSION) + HANDLE_ERROR_CASE(OV_ENOTAUDIO) + HANDLE_ERROR_CASE(OV_EBADPACKET) + HANDLE_ERROR_CASE(OV_EBADLINK) + HANDLE_ERROR_CASE(OV_ENOSEEK) + default: + Mix_SetError("%s: unknown error %d\n", function, error); + break; + } + return -1; +} + +static size_t sdl_read_func(void *ptr, size_t size, size_t nmemb, void *datasource) +{ + return SDL_RWread((SDL_RWops*)datasource, ptr, size, nmemb); +} + +static int sdl_seek_func(void *datasource, ogg_int64_t offset, int whence) +{ + return (int)SDL_RWseek((SDL_RWops*)datasource, offset, whence); +} + +static long sdl_tell_func(void *datasource) +{ + return (long)SDL_RWtell((SDL_RWops*)datasource); +} + +static int OGG_Seek(void *context, double time); +static void OGG_Delete(void *context); + +static int OGG_UpdateSection(OGG_music *music) +{ + vorbis_info *vi; + + vi = vorbis.ov_info(&music->vf, -1); + if (!vi) { + Mix_SetError("ov_info returned NULL"); + return -1; + } + + if (vi->channels == music->vi.channels && vi->rate == music->vi.rate) { + return 0; + } + SDL_memcpy(&music->vi, vi, sizeof(*vi)); + + if (music->buffer) { + SDL_free(music->buffer); + music->buffer = NULL; + } + + if (music->stream) { + SDL_FreeAudioStream(music->stream); + music->stream = NULL; + } + + music->stream = SDL_NewAudioStream(AUDIO_S16SYS, (Uint8)vi->channels, (int)vi->rate, + music_spec.format, music_spec.channels, music_spec.freq); + if (!music->stream) { + return -1; + } + + music->buffer_size = music_spec.samples * (int)sizeof(Sint16) * vi->channels; + music->buffer = (char *)SDL_malloc((size_t)music->buffer_size); + if (!music->buffer) { + return -1; + } + return 0; +} + +/* Load an OGG stream from an SDL_RWops object */ +static void *OGG_CreateFromRW(SDL_RWops *src, int freesrc) +{ + OGG_music *music; + ov_callbacks callbacks; + vorbis_comment *vc; + long rate; + ogg_int64_t full_length; + SDL_bool is_loop_length = SDL_FALSE; + int i; + + music = (OGG_music *)SDL_calloc(1, sizeof *music); + if (!music) { + SDL_OutOfMemory(); + return NULL; + } + music->src = src; + music->volume = MIX_MAX_VOLUME; + music->section = -1; + + SDL_zero(callbacks); + callbacks.read_func = sdl_read_func; + callbacks.seek_func = sdl_seek_func; + callbacks.tell_func = sdl_tell_func; + + if (vorbis.ov_open_callbacks(src, &music->vf, NULL, 0, callbacks) < 0) { + SDL_SetError("Not an Ogg Vorbis audio stream"); + SDL_free(music); + return NULL; + } + + if (OGG_UpdateSection(music) < 0) { + OGG_Delete(music); + return NULL; + } + + rate = music->vi.rate; + vc = vorbis.ov_comment(&music->vf, -1); + if (vc != NULL) { + for (i = 0; i < vc->comments; i++) { + char *param = SDL_strdup(vc->user_comments[i]); + char *argument = param; + char *value = SDL_strchr(param, '='); + if (value == NULL) { + value = param + SDL_strlen(param); + } else { + *(value++) = '\0'; + } + + /* Want to match LOOP-START, LOOP_START, etc. Remove - or _ from + * string if it is present at position 4. */ + if (_Mix_IsLoopTag(argument) && ((argument[4] == '_') || (argument[4] == '-'))) { + SDL_memmove(argument + 4, argument + 5, SDL_strlen(argument) - 4); + } + + if (SDL_strcasecmp(argument, "LOOPSTART") == 0) + music->loop_start = _Mix_ParseTime(value, rate); + else if (SDL_strcasecmp(argument, "LOOPLENGTH") == 0) { + music->loop_len = SDL_strtoll(value, NULL, 10); + is_loop_length = SDL_TRUE; + } else if (SDL_strcasecmp(argument, "LOOPEND") == 0) { + music->loop_end = _Mix_ParseTime(value, rate); + is_loop_length = SDL_FALSE; + } else if (SDL_strcasecmp(argument, "TITLE") == 0) { + meta_tags_set(&music->tags, MIX_META_TITLE, value); + } else if (SDL_strcasecmp(argument, "ARTIST") == 0) { + meta_tags_set(&music->tags, MIX_META_ARTIST, value); + } else if (SDL_strcasecmp(argument, "ALBUM") == 0) { + meta_tags_set(&music->tags, MIX_META_ALBUM, value); + } else if (SDL_strcasecmp(argument, "COPYRIGHT") == 0) { + meta_tags_set(&music->tags, MIX_META_COPYRIGHT, value); + } + SDL_free(param); + } + + if (is_loop_length) { + music->loop_end = music->loop_start + music->loop_len; + } else { + music->loop_len = music->loop_end - music->loop_start; + } + + /* Ignore invalid loop tag */ + if (music->loop_start < 0 || music->loop_len < 0 || music->loop_end < 0) { + music->loop_start = 0; + music->loop_len = 0; + music->loop_end = 0; + } + } + + full_length = vorbis.ov_pcm_total(&music->vf, -1); + if ((music->loop_end > 0) && (music->loop_end <= full_length) && + (music->loop_start < music->loop_end)) { + music->loop = 1; + } + + music->freesrc = freesrc; + return music; +} + +static const char* OGG_GetMetaTag(void *context, Mix_MusicMetaTag tag_type) +{ + OGG_music *music = (OGG_music *)context; + return meta_tags_get(&music->tags, tag_type); +} + +/* Set the volume for an OGG stream */ +static void OGG_SetVolume(void *context, int volume) +{ + OGG_music *music = (OGG_music *)context; + music->volume = volume; +} + +/* Get the volume for an OGG stream */ +static int OGG_GetVolume(void *context) +{ + OGG_music *music = (OGG_music *)context; + return music->volume; +} + +/* Start playback of a given OGG stream */ +static int OGG_Play(void *context, int play_count) +{ + OGG_music *music = (OGG_music *)context; + music->play_count = play_count; + return OGG_Seek(music, 0.0); +} + +/* Play some of a stream previously started with OGG_play() */ +static int OGG_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + OGG_music *music = (OGG_music *)context; + SDL_bool looped = SDL_FALSE; + int filled, amount, result; + int section; + ogg_int64_t pcmPos; + + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + section = music->section; +#ifdef OGG_USE_TREMOR + amount = (int)vorbis.ov_read(&music->vf, music->buffer, music->buffer_size, §ion); +#else + amount = (int)vorbis.ov_read(&music->vf, music->buffer, music->buffer_size, SDL_BYTEORDER == SDL_BIG_ENDIAN, 2, 1, §ion); +#endif + if (amount < 0) { + set_ov_error("ov_read", amount); + return -1; + } + + if (section != music->section) { + music->section = section; + if (OGG_UpdateSection(music) < 0) { + return -1; + } + } + + pcmPos = vorbis.ov_pcm_tell(&music->vf); + if (music->loop && (music->play_count != 1) && (pcmPos >= music->loop_end)) { + amount -= (int)((pcmPos - music->loop_end) * music->vi.channels) * (int)sizeof(Sint16); + result = vorbis.ov_pcm_seek(&music->vf, music->loop_start); + if (result < 0) { + set_ov_error("ov_pcm_seek", result); + return -1; + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + music->play_count = play_count; + } + looped = SDL_TRUE; + } + + if (amount > 0) { + if (SDL_AudioStreamPut(music->stream, music->buffer, amount) < 0) { + return -1; + } + } else if (!looped) { + if (music->play_count == 1) { + music->play_count = 0; + SDL_AudioStreamFlush(music->stream); + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + if (OGG_Play(music, play_count) < 0) { + return -1; + } + } + } + return 0; +} +static int OGG_GetAudio(void *context, void *data, int bytes) +{ + OGG_music *music = (OGG_music *)context; + return music_pcm_getaudio(context, data, bytes, music->volume, OGG_GetSome); +} + +/* Jump (seek) to a given position (time is in seconds) */ +static int OGG_Seek(void *context, double time) +{ + OGG_music *music = (OGG_music *)context; + int result; +#ifdef OGG_USE_TREMOR + result = vorbis.ov_time_seek(&music->vf, (ogg_int64_t)(time * 1000.0)); +#else + result = vorbis.ov_time_seek(&music->vf, time); +#endif + if (result < 0) { + return set_ov_error("ov_time_seek", result); + } + return 0; +} + +static double OGG_Tell(void *context) +{ + OGG_music *music = (OGG_music *)context; +#ifdef OGG_USE_TREMOR + return vorbis.ov_time_tell(&music->vf) / 1000.0; +#else + return vorbis.ov_time_tell(&music->vf); +#endif +} + +/* Return music duration in seconds */ +static double OGG_Duration(void *context) +{ + OGG_music *music = (OGG_music *)context; +#ifdef OGG_USE_TREMOR + return vorbis.ov_time_total(&music->vf, -1) / 1000.0; +#else + return vorbis.ov_time_total(&music->vf, -1); +#endif +} + +static double OGG_LoopStart(void *music_p) +{ + OGG_music *music = (OGG_music *)music_p; + if (music->loop > 0) { + return (double)music->loop_start / music->vi.rate; + } + return -1.0; +} + +static double OGG_LoopEnd(void *music_p) +{ + OGG_music *music = (OGG_music *)music_p; + if (music->loop > 0) { + return (double)music->loop_end / music->vi.rate; + } + return -1.0; +} + +static double OGG_LoopLength(void *music_p) +{ + OGG_music *music = (OGG_music *)music_p; + if (music->loop > 0) { + return (double)music->loop_len / music->vi.rate; + } + return -1.0; +} + + +/* Close the given OGG stream */ +static void OGG_Delete(void *context) +{ + OGG_music *music = (OGG_music *)context; + meta_tags_clear(&music->tags); + vorbis.ov_clear(&music->vf); + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } + if (music->buffer) { + SDL_free(music->buffer); + } + if (music->freesrc) { + SDL_RWclose(music->src); + } + SDL_free(music); +} + +Mix_MusicInterface Mix_MusicInterface_OGG = +{ + "OGG", + MIX_MUSIC_OGG, + MUS_OGG, + SDL_FALSE, + SDL_FALSE, + + OGG_Load, + NULL, /* Open */ + OGG_CreateFromRW, + NULL, /* CreateFromFile */ + OGG_SetVolume, + OGG_GetVolume, + OGG_Play, + NULL, /* IsPlaying */ + OGG_GetAudio, + NULL, /* Jump */ + OGG_Seek, + OGG_Tell, + OGG_Duration, + OGG_LoopStart, + OGG_LoopEnd, + OGG_LoopLength, + OGG_GetMetaTag, /* GetMetaTag */ + NULL, /* Pause */ + NULL, /* Resume */ + NULL, /* Stop */ + OGG_Delete, + NULL, /* Close */ + OGG_Unload +}; + +#endif /* MUSIC_OGG */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_ogg.h b/src/codecs/music_ogg.h new file mode 100644 index 0000000..3ffb0d8 --- /dev/null +++ b/src/codecs/music_ogg.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports Ogg Vorbis music streams */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_OGG; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_opus.c b/src/codecs/music_opus.c new file mode 100644 index 0000000..beac121 --- /dev/null +++ b/src/codecs/music_opus.c @@ -0,0 +1,528 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef MUSIC_OPUS + +/* This file supports Ogg Opus music streams */ + +#include "SDL_loadso.h" + +#include "music_opus.h" +#include "utils.h" + +#if defined(OPUS_HEADER) +#include OPUS_HEADER +#else +#include +#endif + +typedef struct { + int loaded; + void *handle; + const OpusTags *(*op_tags)(const OggOpusFile *,int); + OggOpusFile *(*op_open_callbacks)(void *,const OpusFileCallbacks *,const unsigned char *,size_t,int *); + void (*op_free)(OggOpusFile *); + const OpusHead *(*op_head)(const OggOpusFile *,int); + int (*op_seekable)(const OggOpusFile *); + int (*op_read)(OggOpusFile *, opus_int16 *,int,int *); + int (*op_pcm_seek)(OggOpusFile *,ogg_int64_t); + ogg_int64_t (*op_pcm_tell)(const OggOpusFile *); + ogg_int64_t (*op_pcm_total)(const OggOpusFile *, int); +} opus_loader; + +static opus_loader opus = { + 0, NULL +}; + +#ifdef OPUS_DYNAMIC +#define FUNCTION_LOADER(FUNC, SIG) \ + opus.FUNC = (SIG) SDL_LoadFunction(opus.handle, #FUNC); \ + if (opus.FUNC == NULL) { SDL_UnloadObject(opus.handle); return -1; } +#else +#define FUNCTION_LOADER(FUNC, SIG) \ + opus.FUNC = FUNC; +#endif + +static int OPUS_Load(void) +{ + if (opus.loaded == 0) { +#ifdef OPUS_DYNAMIC + opus.handle = SDL_LoadObject(OPUS_DYNAMIC); + if (opus.handle == NULL) { + return -1; + } +#elif defined(__MACOSX__) + extern OggOpusFile *op_open_callbacks(void *,const OpusFileCallbacks *,const unsigned char *,size_t,int *) __attribute__((weak_import)); + if (op_open_callbacks == NULL) { + /* Missing weakly linked framework */ + Mix_SetError("Missing OpusFile.framework"); + return -1; + } +#endif + FUNCTION_LOADER(op_open_callbacks, OggOpusFile *(*)(void *,const OpusFileCallbacks *,const unsigned char *,size_t,int *)) + FUNCTION_LOADER(op_tags, const OpusTags *(*)(const OggOpusFile *,int)) + FUNCTION_LOADER(op_free, void (*)(OggOpusFile *)) + FUNCTION_LOADER(op_head, const OpusHead *(*)(const OggOpusFile *,int)) + FUNCTION_LOADER(op_seekable, int (*)(const OggOpusFile *)) + FUNCTION_LOADER(op_read, int (*)(OggOpusFile *, opus_int16 *,int,int *)) + FUNCTION_LOADER(op_pcm_seek, int (*)(OggOpusFile *,ogg_int64_t)) + FUNCTION_LOADER(op_pcm_tell, ogg_int64_t (*)(const OggOpusFile *)) + FUNCTION_LOADER(op_pcm_total, ogg_int64_t (*)(const OggOpusFile *, int)) + } + ++opus.loaded; + + return 0; +} + +static void OPUS_Unload(void) +{ + if (opus.loaded == 0) { + return; + } + if (opus.loaded == 1) { +#ifdef OPUS_DYNAMIC + SDL_UnloadObject(opus.handle); +#endif + } + --opus.loaded; +} + + +typedef struct { + SDL_RWops *src; + int freesrc; + int play_count; + int volume; + OggOpusFile *of; + const OpusHead *op_info; + int section; + SDL_AudioStream *stream; + char *buffer; + int buffer_size; + int loop; + ogg_int64_t loop_start; + ogg_int64_t loop_end; + ogg_int64_t loop_len; + ogg_int64_t full_length; + Mix_MusicMetaTags tags; +} OPUS_music; + + +static int set_op_error(const char *function, int error) +{ +#define HANDLE_ERROR_CASE(X) case X: Mix_SetError("%s: %s", function, #X); break; + switch (error) { + HANDLE_ERROR_CASE(OP_FALSE) + HANDLE_ERROR_CASE(OP_EOF) + HANDLE_ERROR_CASE(OP_HOLE) + HANDLE_ERROR_CASE(OP_EREAD) + HANDLE_ERROR_CASE(OP_EFAULT) + HANDLE_ERROR_CASE(OP_EIMPL) + HANDLE_ERROR_CASE(OP_EINVAL) + HANDLE_ERROR_CASE(OP_ENOTFORMAT) + HANDLE_ERROR_CASE(OP_EBADHEADER) + HANDLE_ERROR_CASE(OP_EVERSION) + HANDLE_ERROR_CASE(OP_ENOTAUDIO) + HANDLE_ERROR_CASE(OP_EBADPACKET) + HANDLE_ERROR_CASE(OP_EBADLINK) + HANDLE_ERROR_CASE(OP_ENOSEEK) + HANDLE_ERROR_CASE(OP_EBADTIMESTAMP) + default: + Mix_SetError("%s: unknown error %d\n", function, error); + break; + } + return -1; +} + +static int sdl_read_func(void *datasource, unsigned char *ptr, int size) +{ + return (int)SDL_RWread((SDL_RWops*)datasource, ptr, 1, (size_t)size); +} + +static int sdl_seek_func(void *datasource, opus_int64 offset, int whence) +{ + return (SDL_RWseek((SDL_RWops*)datasource, offset, whence) < 0)? -1 : 0; +} + +static opus_int64 sdl_tell_func(void *datasource) +{ + return SDL_RWtell((SDL_RWops*)datasource); +} + +static int OPUS_Seek(void*, double); +static void OPUS_Delete(void*); + +static int OPUS_UpdateSection(OPUS_music *music) +{ + const OpusHead *op_info; + + op_info = opus.op_head(music->of, -1); + if (!op_info) { + Mix_SetError("op_head returned NULL"); + return -1; + } + + if (music->op_info && op_info->channel_count == music->op_info->channel_count) { + return 0; + } + music->op_info = op_info; + + if (music->buffer) { + SDL_free(music->buffer); + music->buffer = NULL; + } + + if (music->stream) { + SDL_FreeAudioStream(music->stream); + music->stream = NULL; + } + + music->stream = SDL_NewAudioStream(AUDIO_S16SYS, (Uint8)op_info->channel_count, 48000, + music_spec.format, music_spec.channels, music_spec.freq); + if (!music->stream) { + return -1; + } + + music->buffer_size = (int)music_spec.samples * (int)sizeof(opus_int16) * op_info->channel_count; + music->buffer = (char *)SDL_malloc((size_t)music->buffer_size); + if (!music->buffer) { + return -1; + } + return 0; +} + +/* Load an Opus stream from an SDL_RWops object */ +static void *OPUS_CreateFromRW(SDL_RWops *src, int freesrc) +{ + OPUS_music *music; + OpusFileCallbacks callbacks; + const OpusTags* tags; + int err = 0, ci; + SDL_bool is_loop_length = SDL_FALSE; + ogg_int64_t full_length; + + music = (OPUS_music *)SDL_calloc(1, sizeof *music); + if (!music) { + SDL_OutOfMemory(); + return NULL; + } + music->src = src; + music->volume = MIX_MAX_VOLUME; + music->section = -1; + + SDL_zero(callbacks); + callbacks.read = sdl_read_func; + callbacks.seek = sdl_seek_func; + callbacks.tell = sdl_tell_func; + + music->of = opus.op_open_callbacks(src, &callbacks, NULL, 0, &err); + if (music->of == NULL) { + /* set_op_error("op_open_callbacks", err);*/ + SDL_SetError("Not an Opus audio stream"); + SDL_free(music); + return NULL; + } + + if (!opus.op_seekable(music->of)) { + OPUS_Delete(music); + Mix_SetError("Opus stream not seekable"); + return NULL; + } + + if (OPUS_UpdateSection(music) < 0) { + OPUS_Delete(music); + return NULL; + } + + tags = opus.op_tags(music->of, -1); + if (tags != NULL) { + for (ci = 0; ci < tags->comments; ci++) { + char *param = SDL_strdup(tags->user_comments[ci]); + char *argument = param; + char *value = SDL_strchr(param, '='); + if (value == NULL) { + value = param + SDL_strlen(param); + } else { + *(value++) = '\0'; + } + + /* Want to match LOOP-START, LOOP_START, etc. Remove - or _ from + * string if it is present at position 4. */ + if (_Mix_IsLoopTag(argument) && ((argument[4] == '_') || (argument[4] == '-'))) { + SDL_memmove(argument + 4, argument + 5, SDL_strlen(argument) - 4); + } + + if (SDL_strcasecmp(argument, "LOOPSTART") == 0) + music->loop_start = _Mix_ParseTime(value, 48000); + else if (SDL_strcasecmp(argument, "LOOPLENGTH") == 0) { + music->loop_len = SDL_strtoll(value, NULL, 10); + is_loop_length = SDL_TRUE; + } else if (SDL_strcasecmp(argument, "LOOPEND") == 0) { + music->loop_end = _Mix_ParseTime(value, 48000); + is_loop_length = SDL_FALSE; + } else if (SDL_strcasecmp(argument, "TITLE") == 0) { + meta_tags_set(&music->tags, MIX_META_TITLE, value); + } else if (SDL_strcasecmp(argument, "ARTIST") == 0) { + meta_tags_set(&music->tags, MIX_META_ARTIST, value); + } else if (SDL_strcasecmp(argument, "ALBUM") == 0) { + meta_tags_set(&music->tags, MIX_META_ALBUM, value); + } else if (SDL_strcasecmp(argument, "COPYRIGHT") == 0) { + meta_tags_set(&music->tags, MIX_META_COPYRIGHT, value); + } + SDL_free(param); + } + + if (is_loop_length) { + music->loop_end = music->loop_start + music->loop_len; + } else { + music->loop_len = music->loop_end - music->loop_start; + } + + /* Ignore invalid loop tag */ + if (music->loop_start < 0 || music->loop_len < 0 || music->loop_end < 0) { + music->loop_start = 0; + music->loop_len = 0; + music->loop_end = 0; + } + } + + full_length = opus.op_pcm_total(music->of, -1); + if ((music->loop_end > 0) && (music->loop_end <= full_length) && + (music->loop_start < music->loop_end)) { + music->loop = 1; + } + + music->full_length = full_length; + music->freesrc = freesrc; + return music; +} + +static const char* OPUS_GetMetaTag(void *context, Mix_MusicMetaTag tag_type) +{ + OPUS_music *music = (OPUS_music *)context; + return meta_tags_get(&music->tags, tag_type); +} + +/* Set the volume for an Opus stream */ +static void OPUS_SetVolume(void *context, int volume) +{ + OPUS_music *music = (OPUS_music *)context; + music->volume = volume; +} + +/* Get the volume for an Opus stream */ +static int OPUS_GetVolume(void *context) +{ + OPUS_music *music = (OPUS_music *)context; + return music->volume; +} + +/* Start playback of a given Opus stream */ +static int OPUS_Play(void *context, int play_count) +{ + OPUS_music *music = (OPUS_music *)context; + music->play_count = play_count; + return OPUS_Seek(music, 0.0); +} + +/* Play some of a stream previously started with OPUS_Play() */ +static int OPUS_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + OPUS_music *music = (OPUS_music *)context; + int filled, samples, section; + int result; + SDL_bool looped = SDL_FALSE; + ogg_int64_t pcmPos; + + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + section = music->section; + samples = opus.op_read(music->of, (opus_int16 *)music->buffer, music->buffer_size / (int)sizeof(opus_int16), §ion); + if (samples < 0) { + set_op_error("op_read", samples); + return -1; + } + + if (section != music->section) { + music->section = section; + if (OPUS_UpdateSection(music) < 0) { + return -1; + } + } + + pcmPos = opus.op_pcm_tell(music->of); + if (music->loop && (music->play_count != 1) && (pcmPos >= music->loop_end)) { + samples -= (int)((pcmPos - music->loop_end) * music->op_info->channel_count) * (int)sizeof(Sint16); + result = opus.op_pcm_seek(music->of, music->loop_start); + if (result < 0) { + set_op_error("ov_pcm_seek", result); + return -1; + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + music->play_count = play_count; + } + looped = SDL_TRUE; + } + + if (samples > 0) { + filled = samples * music->op_info->channel_count * 2; + if (SDL_AudioStreamPut(music->stream, music->buffer, filled) < 0) { + return -1; + } + } else if (!looped) { + if (music->play_count == 1) { + music->play_count = 0; + SDL_AudioStreamFlush(music->stream); + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + if (OPUS_Play(music, play_count) < 0) { + return -1; + } + } + } + return 0; +} + +static int OPUS_GetAudio(void *context, void *data, int bytes) +{ + OPUS_music *music = (OPUS_music *)context; + return music_pcm_getaudio(context, data, bytes, music->volume, OPUS_GetSome); +} + +/* Jump (seek) to a given position (time is in seconds) */ +static int OPUS_Seek(void *context, double time) +{ + OPUS_music *music = (OPUS_music *)context; + int result = opus.op_pcm_seek(music->of, (ogg_int64_t)(time * 48000)); + if (result < 0) { + return set_op_error("op_pcm_seek", result); + } + return 0; +} + +static double OPUS_Tell(void *context) +{ + OPUS_music *music = (OPUS_music *)context; + return (double)(opus.op_pcm_tell(music->of)) / 48000.0; +} + +/* Return music duration in seconds */ +static double OPUS_Duration(void *context) +{ + OPUS_music *music = (OPUS_music *)context; + return music->full_length / 48000.0; +} + +static double OPUS_LoopStart(void *music_p) +{ + OPUS_music *music = (OPUS_music *)music_p; + if (music->loop > 0) { + return (double)music->loop_start / 48000.0; + } + return -1.0; +} + +static double OPUS_LoopEnd(void *music_p) +{ + OPUS_music *music = (OPUS_music *)music_p; + if (music->loop > 0) { + return (double)music->loop_end / 48000.0; + } + return -1.0; +} + +static double OPUS_LoopLength(void *music_p) +{ + OPUS_music *music = (OPUS_music *)music_p; + if (music->loop > 0) { + return (double)music->loop_len / 48000.0; + } + return -1.0; +} + +/* Close the given Opus stream */ +static void OPUS_Delete(void *context) +{ + OPUS_music *music = (OPUS_music *)context; + opus.op_free(music->of); + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } + if (music->buffer) { + SDL_free(music->buffer); + } + if (music->freesrc) { + SDL_RWclose(music->src); + } + SDL_free(music); +} + +Mix_MusicInterface Mix_MusicInterface_Opus = +{ + "OPUS", + MIX_MUSIC_OPUS, + MUS_OPUS, + SDL_FALSE, + SDL_FALSE, + + OPUS_Load, + NULL, /* Open */ + OPUS_CreateFromRW, + NULL, /* CreateFromFile */ + OPUS_SetVolume, + OPUS_GetVolume, + OPUS_Play, + NULL, /* IsPlaying */ + OPUS_GetAudio, + NULL, /* Jump */ + OPUS_Seek, + OPUS_Tell, + OPUS_Duration, + OPUS_LoopStart, + OPUS_LoopEnd, + OPUS_LoopLength, + OPUS_GetMetaTag, + NULL, /* Pause */ + NULL, /* Resume */ + NULL, /* Stop */ + OPUS_Delete, + NULL, /* Close */ + OPUS_Unload +}; + +#endif /* MUSIC_OPUS */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_opus.h b/src/codecs/music_opus.h new file mode 100644 index 0000000..fe30875 --- /dev/null +++ b/src/codecs/music_opus.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports Ogg Opus music streams */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_Opus; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_timidity.c b/src/codecs/music_timidity.c new file mode 100644 index 0000000..1072b7f --- /dev/null +++ b/src/codecs/music_timidity.c @@ -0,0 +1,297 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports playing MIDI files with timidity */ + +#ifdef MUSIC_MID_TIMIDITY + +#include "music_timidity.h" + +#include "timidity/timidity.h" + + +typedef struct +{ + int play_count; + MidiSong *song; + SDL_AudioStream *stream; + void *buffer; + Sint32 buffer_size; + int volume; +} TIMIDITY_Music; + + +static int TIMIDITY_Seek(void *context, double position); +static void TIMIDITY_Delete(void *context); + +/* Config file should contain any other directory that needs + * to be added to the search path. The library adds the path + * of the config file to its search path, too. */ +#if defined(__WIN32__) +# define TIMIDITY_CFG "C:\\TIMIDITY\\TIMIDITY.CFG" +#elif defined(__OS2__) +# define TIMIDITY_CFG "C:\\TIMIDITY\\TIMIDITY.CFG" +# define TIMIDITY_CFG_ETC "/@unixroot/etc/timidity/timidity.cfg" +#else /* unix: */ +# define TIMIDITY_CFG_ETC "/etc/timidity.cfg" +# define TIMIDITY_CFG_FREEPATS "/etc/timidity/freepats.cfg" +#endif + +static int TIMIDITY_Open(const SDL_AudioSpec *spec) +{ + const char *cfg; + int rc = -1; + + (void) spec; + + cfg = SDL_getenv("TIMIDITY_CFG"); + if(!cfg) cfg = Mix_GetTimidityCfg(); + if (cfg) { + return Timidity_Init(cfg); /* env or user override: no other tries */ + } +#if defined(TIMIDITY_CFG) + if (rc < 0) rc = Timidity_Init(TIMIDITY_CFG); +#endif +#if defined(TIMIDITY_CFG_ETC) + if (rc < 0) rc = Timidity_Init(TIMIDITY_CFG_ETC); +#endif +#if defined(TIMIDITY_CFG_FREEPATS) + if (rc < 0) rc = Timidity_Init(TIMIDITY_CFG_FREEPATS); +#endif + if (rc < 0) rc = Timidity_Init(NULL); /* library's default cfg. */ + + return rc; +} + +static void TIMIDITY_Close(void) +{ + Timidity_Exit(); +} + +void *TIMIDITY_CreateFromRW(SDL_RWops *src, int freesrc) +{ + TIMIDITY_Music *music; + SDL_AudioSpec spec; + SDL_bool need_stream = SDL_FALSE; + + music = (TIMIDITY_Music *)SDL_calloc(1, sizeof(*music)); + if (!music) { + SDL_OutOfMemory(); + return NULL; + } + + music->volume = MIX_MAX_VOLUME; + + SDL_memcpy(&spec, &music_spec, sizeof(spec)); + if (spec.channels > 2) { + need_stream = SDL_TRUE; + spec.channels = 2; + } + music->song = Timidity_LoadSong(src, &spec); + if (!music->song) { + TIMIDITY_Delete(music); + return NULL; + } + + if (need_stream) { + music->stream = SDL_NewAudioStream(spec.format, spec.channels, spec.freq, + music_spec.format, music_spec.channels, music_spec.freq); + if (!music->stream) { + TIMIDITY_Delete(music); + return NULL; + } + + music->buffer_size = spec.samples * (SDL_AUDIO_BITSIZE(spec.format) / 8) * spec.channels; + music->buffer = SDL_malloc((size_t)music->buffer_size); + if (!music->buffer) { + SDL_OutOfMemory(); + TIMIDITY_Delete(music); + return NULL; + } + } + + if (freesrc) { + SDL_RWclose(src); + } + return music; +} + +static void TIMIDITY_SetVolume(void *context, int volume) +{ + TIMIDITY_Music *music = (TIMIDITY_Music *)context; + music->volume = volume; + Timidity_SetVolume(music->song, volume); +} + +static int TIMIDITY_GetVolume(void *context) +{ + TIMIDITY_Music *music = (TIMIDITY_Music *)context; + return music->volume; +} + +static int TIMIDITY_Play(void *context, int play_count) +{ + TIMIDITY_Music *music = (TIMIDITY_Music *)context; + music->play_count = play_count; + Timidity_Start(music->song); + return TIMIDITY_Seek(music, 0.0); +} + +static SDL_bool TIMIDITY_IsPlaying(void *context) +{ + TIMIDITY_Music *music = (TIMIDITY_Music *)context; + return Timidity_IsActive(music->song); +} + +static int TIMIDITY_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + TIMIDITY_Music *music = (TIMIDITY_Music *)context; + int filled, amount, expected; + + if (music->stream) { + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + if (music->stream) { + expected = music->buffer_size; + amount = Timidity_PlaySome(music->song, music->buffer, music->buffer_size); + if (SDL_AudioStreamPut(music->stream, music->buffer, amount) < 0) { + return -1; + } + } else { + expected = bytes; + amount = Timidity_PlaySome(music->song, data, bytes); + } + + if (amount < expected) { + if (music->play_count == 1) { + /* We didn't consume anything and we're done */ + music->play_count = 0; + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + if (TIMIDITY_Play(music, play_count) < 0) { + return -1; + } + } + } + if (music->stream) { + /* We'll pick it up from the stream next time around */ + return 0; + } else { + /* We wrote output data */ + return amount; + } +} + +static int TIMIDITY_GetAudio(void *context, void *data, int bytes) +{ + return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, TIMIDITY_GetSome); +} + +static int TIMIDITY_Seek(void *context, double position) +{ + TIMIDITY_Music *music = (TIMIDITY_Music *)context; + Timidity_Seek(music->song, (Uint32)(position * 1000)); + return 0; +} + +static double TIMIDITY_Tell(void *context) +{ + TIMIDITY_Music *music = (TIMIDITY_Music *)context; + return Timidity_GetSongTime(music->song) / 1000.0; +} + +static double TIMIDITY_Duration(void *context) +{ + TIMIDITY_Music *music = (TIMIDITY_Music *)context; + return Timidity_GetSongLength(music->song) / 1000.0; +} + +static void TIMIDITY_Delete(void *context) +{ + TIMIDITY_Music *music = (TIMIDITY_Music *)context; + + if (music->song) { + Timidity_FreeSong(music->song); + } + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } + if (music->buffer) { + SDL_free(music->buffer); + } + SDL_free(music); +} + +static void TIMIDITY_Stop(void *context) +{ + TIMIDITY_Music *music = (TIMIDITY_Music *)context; + Timidity_Stop(music->song); +} + +Mix_MusicInterface Mix_MusicInterface_TIMIDITY = +{ + "TIMIDITY", + MIX_MUSIC_TIMIDITY, + MUS_MID, + SDL_FALSE, + SDL_FALSE, + + NULL, /* Load */ + TIMIDITY_Open, + TIMIDITY_CreateFromRW, + NULL, /* CreateFromFile */ + TIMIDITY_SetVolume, + TIMIDITY_GetVolume, + TIMIDITY_Play, + TIMIDITY_IsPlaying, + TIMIDITY_GetAudio, + NULL, /* Jump */ + TIMIDITY_Seek, + TIMIDITY_Tell, + TIMIDITY_Duration, + NULL, /* LoopStart */ + NULL, /* LoopEnd */ + NULL, /* LoopLength */ + NULL, /* GetMetaTag */ + NULL, /* Pause */ + NULL, /* Resume */ + TIMIDITY_Stop, + TIMIDITY_Delete, + TIMIDITY_Close, + NULL /* Unload */ +}; + +#endif /* MUSIC_MID_TIMIDITY */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_timidity.h b/src/codecs/music_timidity.h new file mode 100644 index 0000000..202e615 --- /dev/null +++ b/src/codecs/music_timidity.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports playing MIDI files with timidity */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_TIMIDITY; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_wav.c b/src/codecs/music_wav.c new file mode 100644 index 0000000..8150188 --- /dev/null +++ b/src/codecs/music_wav.c @@ -0,0 +1,1220 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef MUSIC_WAV + +/* This file supports streaming WAV files */ + +#include "music_wav.h" + + +typedef struct { + SDL_bool active; + Uint32 start; + Uint32 stop; + Uint32 initial_play_count; + Uint32 current_play_count; +} WAVLoopPoint; + +typedef struct { + SDL_RWops *src; + int freesrc; + SDL_AudioSpec spec; + int volume; + int play_count; + Sint64 start; + Sint64 stop; + Sint64 samplesize; + Uint8 *buffer; + SDL_AudioStream *stream; + unsigned int numloops; + WAVLoopPoint *loops; + Mix_MusicMetaTags tags; + Uint16 encoding; + int (*decode)(void *music, int length); +} WAV_Music; + +/* + Taken with permission from SDL_wave.h, part of the SDL library, + available at: http://www.libsdl.org/ + and placed under the same license as this mixer library. +*/ + +/* WAVE files are little-endian */ + +/*******************************************/ +/* Define values for Microsoft WAVE format */ +/*******************************************/ +#define RIFF 0x46464952 /* "RIFF" */ +#define WAVE 0x45564157 /* "WAVE" */ +#define FMT 0x20746D66 /* "fmt " */ +#define DATA 0x61746164 /* "data" */ +#define SMPL 0x6c706d73 /* "smpl" */ +#define LIST 0x5453494c /* "LIST" */ +#define ID3_ 0x20336469 /* "id3 " */ +#define PCM_CODE 1 /* WAVE_FORMAT_PCM */ +#define ADPCM_CODE 2 /* WAVE_FORMAT_ADPCM */ +#define FLOAT_CODE 3 /* WAVE_FORMAT_IEEE_FLOAT */ +#define ALAW_CODE 6 /* WAVE_FORMAT_ALAW */ +#define uLAW_CODE 7 /* WAVE_FORMAT_MULAW */ +#define EXT_CODE 0xFFFE /* WAVE_FORMAT_EXTENSIBLE */ +#define WAVE_MONO 1 +#define WAVE_STEREO 2 + +typedef struct { +/* Not saved in the chunk we read: + Uint32 chunkID; + Uint32 chunkLen; +*/ + Uint16 encoding; + Uint16 channels; /* 1 = mono, 2 = stereo */ + Uint32 frequency; /* One of 11025, 22050, or 44100 Hz */ + Uint32 byterate; /* Average bytes per second */ + Uint16 blockalign; /* Bytes per sample block */ + Uint16 bitspersample; /* One of 8, 12, 16, or 4 for ADPCM */ +} WaveFMT; + +typedef struct { + Uint16 cbSize; + union { + Uint16 validbitspersample; /* bits of precision */ + Uint16 samplesperblock; /* valid if wBitsPerSample==0 */ + Uint16 reserved; /* If neither applies, set to zero. */ + } Samples; + Uint32 channelsmask; + /* GUID subFormat 16 bytes */ + Uint32 subencoding; + Uint16 sub_data2; + Uint16 sub_data3; + Uint8 sub_data[8]; +} WaveFMTex; + +typedef struct { + Uint32 identifier; + Uint32 type; + Uint32 start; + Uint32 end; + Uint32 fraction; + Uint32 play_count; +} SampleLoop; + +typedef struct { +/* Not saved in the chunk we read: + Uint32 chunkID; + Uint32 chunkLen; +*/ + Uint32 manufacturer; + Uint32 product; + Uint32 sample_period; + Uint32 MIDI_unity_note; + Uint32 MIDI_pitch_fraction; + Uint32 SMTPE_format; + Uint32 SMTPE_offset; + Uint32 sample_loops; + Uint32 sampler_data; + SampleLoop loops[1]; +} SamplerChunk; + +/*********************************************/ +/* Define values for AIFF (IFF audio) format */ +/*********************************************/ +#define FORM 0x4d524f46 /* "FORM" */ +#define AIFF 0x46464941 /* "AIFF" */ +#define AIFC 0x43464941 /* "AIFС" */ +#define FVER 0x52455646 /* "FVER" */ +#define SSND 0x444e5353 /* "SSND" */ +#define COMM 0x4d4d4f43 /* "COMM" */ +#define AIFF_ID3_ 0x20334449 /* "ID3 " */ +#define MARK 0x4B52414D /* "MARK" */ +#define INST 0x54534E49 /* "INST" */ +#define AUTH 0x48545541 /* "AUTH" */ +#define NAME 0x454D414E /* "NAME" */ +#define _c__ 0x20296328 /* "(c) " */ + +/* Supported compression types */ +#define NONE 0x454E4F4E /* "NONE" */ +#define sowt 0x74776F73 /* "sowt" */ +#define raw_ 0x20776172 /* "raw " */ +#define ulaw 0x77616C75 /* "ulaw" */ +#define alaw 0x77616C61 /* "alaw" */ +#define ULAW 0x57414C55 /* "ULAW" */ +#define ALAW 0x57414C41 /* "ALAW" */ +#define fl32 0x32336C66 /* "fl32" */ +#define fl64 0x34366C66 /* "fl64" */ +#define FL32 0x32334C46 /* "FL32" */ + +/* Function to load the WAV/AIFF stream */ +static SDL_bool LoadWAVMusic(WAV_Music *wave); +static SDL_bool LoadAIFFMusic(WAV_Music *wave); + +static void WAV_Delete(void *context); + +static int fetch_pcm(void *context, int length); + +/* Load a WAV stream from the given RWops object */ +static void *WAV_CreateFromRW(SDL_RWops *src, int freesrc) +{ + WAV_Music *music; + Uint32 magic; + SDL_bool loaded = SDL_FALSE; + + music = (WAV_Music *)SDL_calloc(1, sizeof(*music)); + if (!music) { + SDL_OutOfMemory(); + return NULL; + } + music->src = src; + music->volume = MIX_MAX_VOLUME; + /* Default decoder is PCM */ + music->decode = fetch_pcm; + music->encoding = PCM_CODE; + + magic = SDL_ReadLE32(src); + if (magic == RIFF || magic == WAVE) { + loaded = LoadWAVMusic(music); + } else if (magic == FORM) { + loaded = LoadAIFFMusic(music); + } else { + Mix_SetError("Unknown WAVE format"); + } + if (!loaded) { + WAV_Delete(music); + return NULL; + } + music->buffer = (Uint8*)SDL_malloc(music->spec.size); + if (!music->buffer) { + WAV_Delete(music); + return NULL; + } + music->stream = SDL_NewAudioStream( + music->spec.format, music->spec.channels, music->spec.freq, + music_spec.format, music_spec.channels, music_spec.freq); + if (!music->stream) { + WAV_Delete(music); + return NULL; + } + + music->freesrc = freesrc; + return music; +} + +static void WAV_SetVolume(void *context, int volume) +{ + WAV_Music *music = (WAV_Music *)context; + music->volume = volume; +} + +static int WAV_GetVolume(void *context) +{ + WAV_Music *music = (WAV_Music *)context; + return music->volume; +} + +/* Start playback of a given WAV stream */ +static int WAV_Play(void *context, int play_count) +{ + WAV_Music *music = (WAV_Music *)context; + unsigned int i; + for (i = 0; i < music->numloops; ++i) { + WAVLoopPoint *loop = &music->loops[i]; + loop->active = SDL_TRUE; + loop->current_play_count = loop->initial_play_count; + } + music->play_count = play_count; + if (SDL_RWseek(music->src, music->start, RW_SEEK_SET) < 0) { + return -1; + } + return 0; +} + +static int fetch_pcm(void *context, int length) +{ + WAV_Music *music = (WAV_Music *)context; + return (int)SDL_RWread(music->src, music->buffer, 1, (size_t)length); +} + +static Uint32 PCM_S24_to_S32_BE(Uint8 *x) { + const Uint32 bits = 24; + Uint32 in = (((Uint32)x[0] << 0) & 0x0000FF) | + (((Uint32)x[1] << 8) & 0x00FF00) | + (((Uint32)x[2] << 16) & 0xFF0000); + Uint32 m = 1u << (bits - 1); + return (in ^ m) - m; +} + +static Uint32 PCM_S24_to_S32_LE(Uint8 *x) { + const Uint32 bits = 24; + Uint32 in = (((Uint32)x[2] << 0) & 0x0000FF) | + (((Uint32)x[1] << 8) & 0x00FF00) | + (((Uint32)x[0] << 16) & 0xFF0000); + Uint32 m = 1u << (bits - 1); + return (in ^ m) - m; +} + +static int fetch_pcm24be(void *context, int length) +{ + WAV_Music *music = (WAV_Music *)context; + int i = 0, o = 0; + length = (int)SDL_RWread(music->src, music->buffer, 1, (size_t)((length / 4) * 3)); + if (length % music->samplesize != 0) { + length -= length % music->samplesize; + } + for (i = length - 3, o = ((length - 3) / 3) * 4; i >= 0; i -= 3, o -= 4) { + Uint32 decoded = PCM_S24_to_S32_BE(music->buffer + i); + music->buffer[o + 0] = (decoded >> 0) & 0xFF; + music->buffer[o + 1] = (decoded >> 8) & 0xFF; + music->buffer[o + 2] = (decoded >> 16) & 0xFF; + music->buffer[o + 3] = (decoded >> 24) & 0xFF; + } + return (length / 3) * 4; +} + +static int fetch_pcm24le(void *context, int length) +{ + WAV_Music *music = (WAV_Music *)context; + int i = 0, o = 0; + length = (int)SDL_RWread(music->src, music->buffer, 1, (size_t)((length / 4) * 3)); + if (length % music->samplesize != 0) { + length -= length % music->samplesize; + } + for (i = length - 3, o = ((length - 3) / 3) * 4; i >= 0; i -= 3, o -= 4) { + Uint32 decoded = PCM_S24_to_S32_LE(music->buffer + i); + music->buffer[o + 3] = (decoded >> 0) & 0xFF; + music->buffer[o + 2] = (decoded >> 8) & 0xFF; + music->buffer[o + 1] = (decoded >> 16) & 0xFF; + music->buffer[o + 0] = (decoded >> 24) & 0xFF; + } + return (length / 3) * 4; +} + +SDL_FORCE_INLINE double +Mix_SwapDouble(double x) +{ + union + { + double f; + Uint64 ui64; + } swapper; + swapper.f = x; + swapper.ui64 = SDL_Swap64(swapper.ui64); + return swapper.f; +} + +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define Mix_SwapDoubleLE(X) (X) +#define Mix_SwapDoubleBE(X) Mix_SwapDouble(X) +#else +#define Mix_SwapDoubleLE(X) Mix_SwapDouble(X) +#define Mix_SwapDoubleBE(X) (X) +#endif + +static int fetch_float64be(void *context, int length) +{ + WAV_Music *music = (WAV_Music *)context; + int i = 0, o = 0; + length = (int)SDL_RWread(music->src, music->buffer, 1, (size_t)(length)); + if (length % music->samplesize != 0) { + length -= length % music->samplesize; + } + for (i = 0, o = 0; i <= length; i += 8, o += 4) { + union + { + float f; + Uint32 ui32; + } sample; + sample.f = (float)Mix_SwapDoubleBE(*(double*)(music->buffer + i)); + music->buffer[o + 0] = (sample.ui32 >> 0) & 0xFF; + music->buffer[o + 1] = (sample.ui32 >> 8) & 0xFF; + music->buffer[o + 2] = (sample.ui32 >> 16) & 0xFF; + music->buffer[o + 3] = (sample.ui32 >> 24) & 0xFF; + } + return length / 2; +} + +static int fetch_float64le(void *context, int length) +{ + WAV_Music *music = (WAV_Music *)context; + int i = 0, o = 0; + length = (int)SDL_RWread(music->src, music->buffer, 1, (size_t)(length)); + if (length % music->samplesize != 0) { + length -= length % music->samplesize; + } + for (i = 0, o = 0; i <= length; i += 8, o += 4) { + union + { + float f; + Uint32 ui32; + } sample; + sample.f = (float)Mix_SwapDoubleLE(*(double*)(music->buffer + i)); + music->buffer[o + 0] = (sample.ui32 >> 0) & 0xFF; + music->buffer[o + 1] = (sample.ui32 >> 8) & 0xFF; + music->buffer[o + 2] = (sample.ui32 >> 16) & 0xFF; + music->buffer[o + 3] = (sample.ui32 >> 24) & 0xFF; + } + return length / 2; +} + +/* + G711 decode tables taken from SDL2 (src/audio/SDL_wave.c) +*/ +#ifdef SDL_WAVE_LAW_LUT +static const Sint16 alaw_lut[256] = { + -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736, -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784, -2752, + -2624, -3008, -2880, -2240, -2112, -2496, -2368, -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392, -22016, + -20992, -24064, -23040, -17920, -16896, -19968, -18944, -30208, -29184, -32256, -31232, -26112, -25088, -28160, -27136, -11008, + -10496, -12032, -11520, -8960, -8448, -9984, -9472, -15104, -14592, -16128, -15616, -13056, -12544, -14080, -13568, -344, + -328, -376, -360, -280, -264, -312, -296, -472, -456, -504, -488, -408, -392, -440, -424, -88, + -72, -120, -104, -24, -8, -56, -40, -216, -200, -248, -232, -152, -136, -184, -168, -1376, + -1312, -1504, -1440, -1120, -1056, -1248, -1184, -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696, -688, + -656, -752, -720, -560, -528, -624, -592, -944, -912, -1008, -976, -816, -784, -880, -848, 5504, + 5248, 6016, 5760, 4480, 4224, 4992, 4736, 7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784, 2752, + 2624, 3008, 2880, 2240, 2112, 2496, 2368, 3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392, 22016, + 20992, 24064, 23040, 17920, 16896, 19968, 18944, 30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136, 11008, + 10496, 12032, 11520, 8960, 8448, 9984, 9472, 15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568, 344, + 328, 376, 360, 280, 264, 312, 296, 472, 456, 504, 488, 408, 392, 440, 424, 88, + 72, 120, 104, 24, 8, 56, 40, 216, 200, 248, 232, 152, 136, 184, 168, 1376, + 1312, 1504, 1440, 1120, 1056, 1248, 1184, 1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696, 688, + 656, 752, 720, 560, 528, 624, 592, 944, 912, 1008, 976, 816, 784, 880, 848 +}; + +static const Sint16 mulaw_lut[256] = { + -32124, -31100, -30076, -29052, -28028, -27004, -25980, -24956, -23932, -22908, -21884, -20860, -19836, -18812, -17788, -16764, -15996, + -15484, -14972, -14460, -13948, -13436, -12924, -12412, -11900, -11388, -10876, -10364, -9852, -9340, -8828, -8316, -7932, + -7676, -7420, -7164, -6908, -6652, -6396, -6140, -5884, -5628, -5372, -5116, -4860, -4604, -4348, -4092, -3900, + -3772, -3644, -3516, -3388, -3260, -3132, -3004, -2876, -2748, -2620, -2492, -2364, -2236, -2108, -1980, -1884, + -1820, -1756, -1692, -1628, -1564, -1500, -1436, -1372, -1308, -1244, -1180, -1116, -1052, -988, -924, -876, + -844, -812, -780, -748, -716, -684, -652, -620, -588, -556, -524, -492, -460, -428, -396, -372, + -356, -340, -324, -308, -292, -276, -260, -244, -228, -212, -196, -180, -164, -148, -132, -120, + -112, -104, -96, -88, -80, -72, -64, -56, -48, -40, -32, -24, -16, -8, 0, 32124, + 31100, 30076, 29052, 28028, 27004, 25980, 24956, 23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764, 15996, + 15484, 14972, 14460, 13948, 13436, 12924, 12412, 11900, 11388, 10876, 10364, 9852, 9340, 8828, 8316, 7932, + 7676, 7420, 7164, 6908, 6652, 6396, 6140, 5884, 5628, 5372, 5116, 4860, 4604, 4348, 4092, 3900, + 3772, 3644, 3516, 3388, 3260, 3132, 3004, 2876, 2748, 2620, 2492, 2364, 2236, 2108, 1980, 1884, + 1820, 1756, 1692, 1628, 1564, 1500, 1436, 1372, 1308, 1244, 1180, 1116, 1052, 988, 924, 876, + 844, 812, 780, 748, 716, 684, 652, 620, 588, 556, 524, 492, 460, 428, 396, 372, + 356, 340, 324, 308, 292, 276, 260, 244, 228, 212, 196, 180, 164, 148, 132, 120, + 112, 104, 96, 88, 80, 72, 64, 56, 48, 40, 32, 24, 16, 8, 0 +}; +#endif + +static Sint16 uLAW_To_PCM16(Uint8 u_val) +{ +#ifdef SDL_WAVE_LAW_LUT + return mulaw_lut[u_val]; +#else + Uint8 nibble = ~u_val; + Sint16 mantissa = nibble & 0xf; + Uint8 exponent = (nibble >> 4) & 0x7; + Sint16 step = (Sint16)(4 << (exponent + 1)); + + mantissa = (Sint16)(0x80 << exponent) + step * mantissa + step / 2 - 132; + + return nibble & 0x80 ? -mantissa : mantissa; +#endif +} + +static Sint16 ALAW_To_PCM16(Uint8 a_val) +{ +#ifdef SDL_WAVE_LAW_LUT + return alaw_lut[a_val]; +#else + Uint8 nibble = a_val; + Uint8 exponent = (nibble & 0x7f) ^ 0x55; + Sint16 mantissa = exponent & 0xf; + + exponent >>= 4; + if (exponent > 0) { + mantissa |= 0x10; + } + mantissa = (Sint16)(mantissa << 4) | 0x8; + if (exponent > 1) { + mantissa <<= exponent - 1; + } + + return nibble & 0x80 ? mantissa : -mantissa; +#endif +} + +static int fetch_xlaw(Sint16 (*decode_sample)(Uint8), void *context, int length) +{ + WAV_Music *music = (WAV_Music *)context; + int i = 0, o = 0; + length = (int)SDL_RWread(music->src, music->buffer, 1, (size_t)(length / 2)); + if (length % music->samplesize != 0) { + length -= length % music->samplesize; + } + for (i = length - 1, o = (length - 1) * 2; i >= 0; i--, o -= 2) { + Uint16 decoded = (Uint16)decode_sample(music->buffer[i]); + music->buffer[o] = decoded & 0xFF; + music->buffer[o + 1] = (decoded >> 8) & 0xFF; + } + return length * 2; +} + +static int fetch_ulaw(void *context, int length) +{ + return fetch_xlaw(uLAW_To_PCM16, context, length); +} + +static int fetch_alaw(void *context, int length) +{ + return fetch_xlaw(ALAW_To_PCM16, context, length); +} + +/* Play some of a stream previously started with WAV_Play() */ +static int WAV_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + WAV_Music *music = (WAV_Music *)context; + Sint64 pos, stop; + WAVLoopPoint *loop; + Sint64 loop_start = music->start; + Sint64 loop_stop = music->stop; + SDL_bool looped = SDL_FALSE; + SDL_bool at_end = SDL_FALSE; + unsigned int i; + int filled, amount, result; + + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + pos = SDL_RWtell(music->src); + stop = music->stop; + loop = NULL; + for (i = 0; i < music->numloops; ++i) { + loop = &music->loops[i]; + if (loop->active) { + const int bytes_per_sample = (SDL_AUDIO_BITSIZE(music->spec.format) / 8) * music->spec.channels; + loop_start = music->start + loop->start * (Uint32)bytes_per_sample; + loop_stop = music->start + (loop->stop + 1) * (Uint32)bytes_per_sample; + if (pos >= loop_start && pos < loop_stop) { + stop = loop_stop; + break; + } + } + loop = NULL; + } + + amount = (int)music->spec.size; + if ((stop - pos) < amount) { + amount = (int)(stop - pos); + } + + amount = music->decode(music, amount); + if (amount > 0) { + result = SDL_AudioStreamPut(music->stream, music->buffer, amount); + if (result < 0) { + return -1; + } + } else { + /* We might be looping, continue */ + at_end = SDL_TRUE; + } + + if (loop && SDL_RWtell(music->src) >= stop) { + if (loop->current_play_count == 1) { + loop->active = SDL_FALSE; + } else { + if (loop->current_play_count > 0) { + --loop->current_play_count; + } + SDL_RWseek(music->src, loop_start, RW_SEEK_SET); + looped = SDL_TRUE; + } + } + + if (!looped && (at_end || SDL_RWtell(music->src) >= music->stop)) { + if (music->play_count == 1) { + music->play_count = 0; + SDL_AudioStreamFlush(music->stream); + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + if (WAV_Play(music, play_count) < 0) { + return -1; + } + } + } + + /* We'll get called again in the case where we looped or have more data */ + return 0; +} + +static int WAV_GetAudio(void *context, void *data, int bytes) +{ + WAV_Music *music = (WAV_Music *)context; + return music_pcm_getaudio(context, data, bytes, music->volume, WAV_GetSome); +} + +static int WAV_Seek(void *context, double position) +{ + WAV_Music *music = (WAV_Music *)context; + Sint64 sample_size = music->spec.freq * music->samplesize; + Sint64 dest_offset = (Sint64)(position * (double)music->spec.freq * music->samplesize); + Sint64 destpos = music->start + dest_offset; + destpos -= dest_offset % sample_size; + if (destpos > music->stop) + return -1; + SDL_RWseek(music->src, destpos, RW_SEEK_SET); + return 0; +} + +static double WAV_Tell(void *context) +{ + WAV_Music *music = (WAV_Music *)context; + Sint64 phys_pos = SDL_RWtell(music->src); + return (double)(phys_pos - music->start) / (double)(music->spec.freq * music->samplesize); +} + +/* Return music duration in seconds */ +static double WAV_Duration(void *context) +{ + WAV_Music *music = (WAV_Music *)context; + Sint64 sample_size = music->spec.freq * music->samplesize; + return (double)(music->stop - music->start) / sample_size; +} + +static const char* WAV_GetMetaTag(void *context, Mix_MusicMetaTag tag_type) +{ + WAV_Music *music = (WAV_Music *)context; + return meta_tags_get(&music->tags, tag_type); +} + +/* Close the given WAV stream */ +static void WAV_Delete(void *context) +{ + WAV_Music *music = (WAV_Music *)context; + + /* Clean up associated data */ + meta_tags_clear(&music->tags); + if (music->loops) { + SDL_free(music->loops); + } + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } + if (music->buffer) { + SDL_free(music->buffer); + } + if (music->freesrc) { + SDL_RWclose(music->src); + } + SDL_free(music); +} + +static SDL_bool ParseFMT(WAV_Music *wave, Uint32 chunk_length) +{ + SDL_AudioSpec *spec = &wave->spec; + WaveFMT *format; + WaveFMTex *formatEx = NULL; + Uint8 *data; + int bits; + SDL_bool loaded = SDL_FALSE; + + if (chunk_length < sizeof(*format)) { + Mix_SetError("Wave format chunk too small"); + return SDL_FALSE; + } + + data = (Uint8 *)SDL_malloc(chunk_length); + if (!data) { + Mix_SetError("Out of memory"); + return SDL_FALSE; + } + if (!SDL_RWread(wave->src, data, chunk_length, 1)) { + Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length); + goto done; + } + format = (WaveFMT *)data; + + wave->encoding = SDL_SwapLE16(format->encoding); + + if (wave->encoding == EXT_CODE) { + formatEx = (WaveFMTex*)(data + sizeof(WaveFMT)); + wave->encoding = (Uint16)SDL_SwapLE32(formatEx->subencoding); + } + + /* Decode the audio data format */ + switch (wave->encoding) { + case PCM_CODE: + case FLOAT_CODE: + /* We can understand this */ + wave->decode = fetch_pcm; + break; + case uLAW_CODE: + /* , this */ + wave->decode = fetch_ulaw; + break; + case ALAW_CODE: + /* , and this */ + wave->decode = fetch_alaw; + break; + default: + /* but NOT this */ + Mix_SetError("Unknown WAVE data format"); + goto done; + } + spec->freq = (int)SDL_SwapLE32(format->frequency); + bits = (int) SDL_SwapLE16(format->bitspersample); + switch (bits) { + case 8: + switch(wave->encoding) { + case PCM_CODE: spec->format = AUDIO_U8; break; + case ALAW_CODE: spec->format = AUDIO_S16; break; + case uLAW_CODE: spec->format = AUDIO_S16; break; + default: goto unknown_bits; + } + break; + case 16: + switch(wave->encoding) { + case PCM_CODE: spec->format = AUDIO_S16; break; + default: goto unknown_bits; + } + break; + case 24: + switch(wave->encoding) { + case PCM_CODE: + wave->decode = fetch_pcm24le; + spec->format = AUDIO_S32; + break; + default: goto unknown_bits; + } + break; + case 32: + switch(wave->encoding) { + case PCM_CODE: spec->format = AUDIO_S32; break; + case FLOAT_CODE: spec->format = AUDIO_F32; break; + default: goto unknown_bits; + } + break; + case 64: + switch(wave->encoding) { + case FLOAT_CODE: + wave->decode = fetch_float64le; + spec->format = AUDIO_F32; + break; + default: goto unknown_bits; + } + break; + default: + unknown_bits: + Mix_SetError("Unknown PCM format with %d bits", bits); + goto done; + } + spec->channels = (Uint8) SDL_SwapLE16(format->channels); + spec->samples = 4096; /* Good default buffer size */ + wave->samplesize = spec->channels * (bits / 8); + /* SDL_CalculateAudioSpec */ + spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8; + spec->size *= spec->channels; + spec->size *= spec->samples; + + loaded = SDL_TRUE; + +done: + SDL_free(data); + return loaded; +} + +static SDL_bool ParseDATA(WAV_Music *wave, Uint32 chunk_length) +{ + wave->start = SDL_RWtell(wave->src); + wave->stop = wave->start + chunk_length; + SDL_RWseek(wave->src, chunk_length, RW_SEEK_CUR); + return SDL_TRUE; +} + +static SDL_bool AddLoopPoint(WAV_Music *wave, Uint32 play_count, Uint32 start, Uint32 stop) +{ + WAVLoopPoint *loop; + WAVLoopPoint *loops = SDL_realloc(wave->loops, (wave->numloops + 1) * sizeof(*wave->loops)); + if (!loops) { + Mix_SetError("Out of memory"); + return SDL_FALSE; + } + + loop = &loops[ wave->numloops ]; + loop->start = start; + loop->stop = stop; + loop->initial_play_count = play_count; + loop->current_play_count = play_count; + + wave->loops = loops; + ++wave->numloops; + return SDL_TRUE; +} + +static SDL_bool ParseSMPL(WAV_Music *wave, Uint32 chunk_length) +{ + SamplerChunk *chunk; + Uint8 *data; + Uint32 i; + SDL_bool loaded = SDL_FALSE; + + data = (Uint8 *)SDL_malloc(chunk_length); + if (!data) { + Mix_SetError("Out of memory"); + return SDL_FALSE; + } + if (!SDL_RWread(wave->src, data, chunk_length, 1)) { + Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length); + SDL_free(data); + return SDL_FALSE; + } + chunk = (SamplerChunk *)data; + + for (i = 0; i < SDL_SwapLE32(chunk->sample_loops); ++i) { + const Uint32 LOOP_TYPE_FORWARD = 0; + Uint32 loop_type = SDL_SwapLE32(chunk->loops[i].type); + if (loop_type == LOOP_TYPE_FORWARD) { + AddLoopPoint(wave, SDL_SwapLE32(chunk->loops[i].play_count), SDL_SwapLE32(chunk->loops[i].start), SDL_SwapLE32(chunk->loops[i].end)); + } + } + + loaded = SDL_TRUE; + SDL_free(data); + return loaded; +} + +static void read_meta_field(Mix_MusicMetaTags *tags, Mix_MusicMetaTag tag_type, size_t *i, Uint32 chunk_length, Uint8 *data, size_t fieldOffset) +{ + Uint32 len = 0; + int isID3 = fieldOffset == 7; + char *field = NULL; + *i += 4; + len = isID3 ? + SDL_SwapBE32(*((Uint32 *)(data + *i))) : /* ID3 */ + SDL_SwapLE32(*((Uint32 *)(data + *i))); /* LIST */ + if (len > chunk_length) { + return; /* Do nothing due to broken lenght */ + } + *i += fieldOffset; + field = (char *)SDL_malloc(len + 1); + SDL_memset(field, 0, (len + 1)); + SDL_strlcpy(field, (char *)(data + *i), isID3 ? len - 1 : len); + *i += len; + meta_tags_set(tags, tag_type, field); + SDL_free(field); +} + +static SDL_bool ParseLIST(WAV_Music *wave, Uint32 chunk_length) +{ + Uint8 *data; + + data = (Uint8 *)SDL_malloc(chunk_length); + if (!data) { + Mix_SetError("Out of memory"); + return SDL_FALSE; + } + + if (!SDL_RWread(wave->src, data, chunk_length, 1)) { + Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length); + SDL_free(data); + return SDL_FALSE; + } + + if (SDL_strncmp((char *)data, "INFO", 4) == 0) { + size_t i = 4; + for (i = 4; i < chunk_length - 4;) { + if(SDL_strncmp((char *)(data + i), "INAM", 4) == 0) { + read_meta_field(&wave->tags, MIX_META_TITLE, &i, chunk_length, data, 4); + continue; + } else if(SDL_strncmp((char *)(data + i), "IART", 4) == 0) { + read_meta_field(&wave->tags, MIX_META_ARTIST, &i, chunk_length, data, 4); + continue; + } else if(SDL_strncmp((char *)(data + i), "IALB", 4) == 0) { + read_meta_field(&wave->tags, MIX_META_ALBUM, &i, chunk_length, data, 4); + continue; + } else if (SDL_strncmp((char *)(data + i), "BCPR", 4) == 0) { + read_meta_field(&wave->tags, MIX_META_COPYRIGHT, &i, chunk_length, data, 4); + continue; + } + i++; + } + } + + /* done: */ + SDL_free(data); + + return SDL_TRUE; +} + +static SDL_bool LoadWAVMusic(WAV_Music *wave) +{ + SDL_RWops *src = wave->src; + Uint32 chunk_type; + Uint32 chunk_length; + SDL_bool found_FMT = SDL_FALSE; + SDL_bool found_DATA = SDL_FALSE; + /* WAV magic header */ + Uint32 wavelen; + Uint32 WAVEmagic; + + meta_tags_init(&wave->tags); + + /* Check the magic header */ + wavelen = SDL_ReadLE32(src); + WAVEmagic = SDL_ReadLE32(src); + + (void)wavelen; /* unused */ + (void)WAVEmagic; /* unused */ + + /* Read the chunks */ + for (; ;) { + chunk_type = SDL_ReadLE32(src); + chunk_length = SDL_ReadLE32(src); + + if (chunk_length == 0) + break; + + switch (chunk_type) + { + case FMT: + found_FMT = SDL_TRUE; + if (!ParseFMT(wave, chunk_length)) + return SDL_FALSE; + break; + case DATA: + found_DATA = SDL_TRUE; + if (!ParseDATA(wave, chunk_length)) + return SDL_FALSE; + break; + case SMPL: + if (!ParseSMPL(wave, chunk_length)) + return SDL_FALSE; + break; + case LIST: + if (!ParseLIST(wave, chunk_length)) + return SDL_FALSE; + break; + default: + SDL_RWseek(src, chunk_length, RW_SEEK_CUR); + break; + } + } + + if (!found_FMT) { + Mix_SetError("Bad WAV file (no FMT chunk)"); + return SDL_FALSE; + } + + if (!found_DATA) { + Mix_SetError("Bad WAV file (no DATA chunk)"); + return SDL_FALSE; + } + + return SDL_TRUE; +} + +/* I couldn't get SANE_to_double() to work, so I stole this from libsndfile. + * I don't pretend to fully understand it. + */ + +static Uint32 SANE_to_Uint32 (Uint8 *sanebuf) +{ + /* Negative number? */ + if (sanebuf[0] & 0x80) + return 0; + + /* Less than 1? */ + if (sanebuf[0] <= 0x3F) + return 1; + + /* Way too big? */ + if (sanebuf[0] > 0x40) + return 0x4000000; + + /* Still too big? */ + if (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C) + return 800000000; + + return (Uint32)(((sanebuf[2] << 23) | (sanebuf[3] << 15) | (sanebuf[4] << 7) | + (sanebuf[5] >> 1)) >> (29 - sanebuf[1])); +} + +static SDL_bool LoadAIFFMusic(WAV_Music *wave) +{ + SDL_RWops *src = wave->src; + SDL_AudioSpec *spec = &wave->spec; + SDL_bool found_SSND = SDL_FALSE; + SDL_bool found_COMM = SDL_FALSE; + SDL_bool found_FVER = SDL_FALSE; + SDL_bool is_AIFC = SDL_FALSE; + + Uint32 chunk_type; + Uint32 chunk_length; + Sint64 next_chunk = 0; + Sint64 file_length; + + /* AIFF magic header */ + Uint32 AIFFmagic; + /* SSND chunk */ + Uint32 offset; + Uint32 blocksize; + /* COMM format chunk */ + Uint16 channels = 0; + Uint32 numsamples = 0; + Uint16 samplesize = 0; + Uint8 sane_freq[10]; + Uint32 frequency = 0; + Uint32 AIFCVersion1 = 0; + Uint32 compressionType = 0; + char *chunk_buffer; + + file_length = SDL_RWsize(src); + + /* Check the magic header */ + chunk_length = SDL_ReadBE32(src); + AIFFmagic = SDL_ReadLE32(src); + if (AIFFmagic != AIFF && AIFFmagic != AIFC) { + Mix_SetError("Unrecognized file type (not AIFF or AIFC)"); + return SDL_FALSE; + } + if (AIFFmagic == AIFC) { + is_AIFC = SDL_TRUE; + } + + /* From what I understand of the specification, chunks may appear in + * any order, and we should just ignore unknown ones. + * + * TODO: Better sanity-checking. E.g. what happens if the AIFF file + * contains compressed sound data? + */ + do { + chunk_type = SDL_ReadLE32(src); + chunk_length = SDL_ReadBE32(src); + next_chunk = SDL_RWtell(src) + chunk_length; + + if (chunk_length % 2) { + next_chunk++; + } + + switch (chunk_type) { + case SSND: + found_SSND = SDL_TRUE; + offset = SDL_ReadBE32(src); + blocksize = SDL_ReadBE32(src); + wave->start = SDL_RWtell(src) + offset; + (void)blocksize; /* unused */ + break; + + case FVER: + found_FVER = SDL_TRUE; + AIFCVersion1 = SDL_ReadBE32(src); + (void)AIFCVersion1; /* unused */ + break; + + case MARK: + case INST: + /* Just skip those chunks */ + break; + + case NAME: + case AUTH: + case _c__: + chunk_buffer = (char*)SDL_calloc(1, chunk_length + 1); + if (SDL_RWread(src, chunk_buffer, 1, chunk_length) != chunk_length) { + SDL_free(chunk_buffer); + return SDL_FALSE; + } + meta_tags_set(&wave->tags, + chunk_type == NAME ? MIX_META_TITLE : + chunk_type == AUTH ? MIX_META_ARTIST : + chunk_type == _c__ ? MIX_META_COPYRIGHT : 0, + chunk_buffer); + SDL_free(chunk_buffer); + break; + + case COMM: + found_COMM = SDL_TRUE; + + /* Read the audio data format chunk */ + channels = SDL_ReadBE16(src); + numsamples = SDL_ReadBE32(src); + samplesize = SDL_ReadBE16(src); + SDL_RWread(src, sane_freq, sizeof(sane_freq), 1); + frequency = SANE_to_Uint32(sane_freq); + if (is_AIFC) { + compressionType = SDL_ReadLE32(src); + /* here must be a "compressionName" which is a padded string */ + } + break; + + default: + /* Unknown/unsupported chunk: we just skip over */ + break; + } + } while (next_chunk < file_length && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != -1); + + if (!found_SSND) { + Mix_SetError("Bad AIFF/AIFF-C file (no SSND chunk)"); + return SDL_FALSE; + } + + if (!found_COMM) { + Mix_SetError("Bad AIFF/AIFF-C file (no COMM chunk)"); + return SDL_FALSE; + } + + if (is_AIFC && !found_FVER) { + Mix_SetError("Bad AIFF-C file (no FVER chunk)"); + return SDL_FALSE; + } + + + wave->samplesize = channels * (samplesize / 8); + wave->stop = wave->start + channels * numsamples * (samplesize / 8); + + /* Decode the audio data format */ + SDL_memset(spec, 0, (sizeof *spec)); + spec->freq = (int)frequency; + switch (samplesize) { + case 8: + if (!is_AIFC) + spec->format = AUDIO_S8; + else switch (compressionType) { + case raw_: spec->format = AUDIO_U8; break; + case sowt: spec->format = AUDIO_S8; break; + case ulaw: + spec->format = AUDIO_S16LSB; + wave->encoding = uLAW_CODE; + wave->decode = fetch_ulaw; + break; + case alaw: + spec->format = AUDIO_S16LSB; + wave->encoding = ALAW_CODE; + wave->decode = fetch_alaw; + break; + default: goto unsupported_format; + } + break; + case 16: + if (!is_AIFC) + spec->format = AUDIO_S16MSB; + else switch (compressionType) { + case sowt: spec->format = AUDIO_S16LSB; break; + case NONE: spec->format = AUDIO_S16MSB; break; + case ULAW: + spec->format = AUDIO_S16LSB; + wave->encoding = uLAW_CODE; + wave->decode = fetch_ulaw; + break; + case ALAW: + spec->format = AUDIO_S16LSB; + wave->encoding = ALAW_CODE; + wave->decode = fetch_alaw; + break; + default: goto unsupported_format; + } + break; + case 24: + wave->encoding = PCM_CODE; + wave->decode = fetch_pcm24be; + if (!is_AIFC) + spec->format = AUDIO_S32MSB; + else switch (compressionType) { + case sowt: spec->format = AUDIO_S32LSB; break; + case NONE: spec->format = AUDIO_S32MSB; break; + default: goto unsupported_format; + } + break; + case 32: + if (!is_AIFC) + spec->format = AUDIO_S32MSB; + else switch (compressionType) { + case sowt: spec->format = AUDIO_S32LSB; break; + case NONE: spec->format = AUDIO_S32MSB; break; + case fl32: + case FL32: spec->format = AUDIO_F32MSB; break; + default: goto unsupported_format; + } + break; + case 64: + wave->encoding = FLOAT_CODE; + wave->decode = fetch_float64be; + if (!is_AIFC) + spec->format = AUDIO_F32; + else switch (compressionType) { + case fl64: + spec->format = AUDIO_F32; + break; + default: goto unsupported_format; + } + break; + default: + unsupported_format: + Mix_SetError("Unknown samplesize in data format"); + return SDL_FALSE; + } + spec->channels = (Uint8) channels; + spec->samples = 4096; /* Good default buffer size */ + spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8; + spec->size *= spec->channels; + spec->size *= spec->samples; + + return SDL_TRUE; +} + +Mix_MusicInterface Mix_MusicInterface_WAV = +{ + "WAVE", + MIX_MUSIC_WAVE, + MUS_WAV, + SDL_FALSE, + SDL_FALSE, + + NULL, /* Load */ + NULL, /* Open */ + WAV_CreateFromRW, + NULL, /* CreateFromFile */ + WAV_SetVolume, + WAV_GetVolume, + WAV_Play, + NULL, /* IsPlaying */ + WAV_GetAudio, + NULL, /* Jump */ + WAV_Seek, /* Seek */ + WAV_Tell, /* Tell */ + WAV_Duration, + NULL, /* LoopStart */ + NULL, /* LoopEnd */ + NULL, /* LoopLength */ + WAV_GetMetaTag, /* GetMetaTag */ + NULL, /* Pause */ + NULL, /* Resume */ + NULL, /* Stop */ + WAV_Delete, + NULL, /* Close */ + NULL /* Unload */ +}; + +#endif /* MUSIC_WAV */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_wav.h b/src/codecs/music_wav.h new file mode 100644 index 0000000..dae4fdd --- /dev/null +++ b/src/codecs/music_wav.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports streaming WAV files */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_WAV; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_xmp.c b/src/codecs/music_xmp.c new file mode 100644 index 0000000..b5b321f --- /dev/null +++ b/src/codecs/music_xmp.c @@ -0,0 +1,406 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef MUSIC_MOD_XMP + +#include "SDL_loadso.h" + +#include "music_xmp.h" + +#ifdef LIBXMP_HEADER +#include LIBXMP_HEADER +#else +#include +#endif + +/* libxmp >= 4.5.0 constified several funcs */ +#if (XMP_VERCODE < 0x040500) +#define LIBXMP_CONST +#else +#define LIBXMP_CONST const +#endif + +typedef struct { + int loaded; + void *handle; + + xmp_context (*xmp_create_context)(void); + int (*xmp_load_module_from_memory)(xmp_context, LIBXMP_CONST void *, long); + int (*xmp_start_player)(xmp_context, int, int); + void (*xmp_end_player)(xmp_context); + void (*xmp_get_module_info)(xmp_context, struct xmp_module_info *); + int (*xmp_play_buffer)(xmp_context, void *, int, int); + int (*xmp_set_position)(xmp_context, int); + int (*xmp_seek_time)(xmp_context, int); + void (*xmp_get_frame_info)(xmp_context, struct xmp_frame_info *); + void (*xmp_stop_module)(xmp_context); + void (*xmp_release_module)(xmp_context); + void (*xmp_free_context)(xmp_context); +} xmp_loader; + +static xmp_loader libxmp = { + 0, NULL +}; + +#ifdef XMP_DYNAMIC +#define FUNCTION_LOADER(FUNC, SIG) \ + libxmp.FUNC = (SIG) SDL_LoadFunction(libxmp.handle, #FUNC); \ + if (libxmp.FUNC == NULL) { SDL_UnloadObject(libxmp.handle); return -1; } +#else +#define FUNCTION_LOADER(FUNC, SIG) \ + libxmp.FUNC = FUNC; +#endif + +static int XMP_Load(void) +{ + if (libxmp.loaded == 0) { +#ifdef XMP_DYNAMIC + libxmp.handle = SDL_LoadObject(XMP_DYNAMIC); + if (libxmp.handle == NULL) { + return -1; + } +#elif defined(__MACOSX__) + extern xmp_context xmp_create_context(void) __attribute__((weak_import)); + if (xmp_create_context == NULL) { + /* Missing weakly linked framework */ + Mix_SetError("Missing xmp.framework"); + return -1; + } +#endif + FUNCTION_LOADER(xmp_create_context, xmp_context(*)(void)) + FUNCTION_LOADER(xmp_load_module_from_memory, int(*)(xmp_context,LIBXMP_CONST void *,long)) + FUNCTION_LOADER(xmp_start_player, int(*)(xmp_context,int,int)) + FUNCTION_LOADER(xmp_end_player, void(*)(xmp_context)) + FUNCTION_LOADER(xmp_get_module_info, void(*)(xmp_context,struct xmp_module_info*)) + FUNCTION_LOADER(xmp_play_buffer, int(*)(xmp_context,void*,int,int)) + FUNCTION_LOADER(xmp_set_position, int(*)(xmp_context,int)) + FUNCTION_LOADER(xmp_seek_time, int(*)(xmp_context,int)) + FUNCTION_LOADER(xmp_get_frame_info, void(*)(xmp_context,struct xmp_frame_info*)) + FUNCTION_LOADER(xmp_stop_module, void(*)(xmp_context)) + FUNCTION_LOADER(xmp_release_module, void(*)(xmp_context)) + FUNCTION_LOADER(xmp_free_context, void(*)(xmp_context)) + } + ++libxmp.loaded; + + return 0; +} + +static void XMP_Unload(void) +{ + if (libxmp.loaded == 0) { + return; + } + if (libxmp.loaded == 1) { +#ifdef XMP_DYNAMIC + SDL_UnloadObject(libxmp.handle); +#endif + } + --libxmp.loaded; +} + + +typedef struct +{ + int volume; + int play_count; + struct xmp_module_info mi; + struct xmp_frame_info fi; + xmp_context ctx; + SDL_AudioStream *stream; + void *buffer; + int buffer_size; + Mix_MusicMetaTags tags; +} XMP_Music; + + +static int XMP_Seek(void *ctx, double pos); +static void XMP_Delete(void *ctx); + +static void libxmp_set_error(int e) +{ + const char *msg; + switch (e) { + case -XMP_ERROR_INTERNAL: + msg = "Internal error in libxmp"; + break; + case -XMP_ERROR_FORMAT: + msg = "Unrecognized file format"; + break; + case -XMP_ERROR_LOAD: + msg = "Error loading file"; + break; + case -XMP_ERROR_DEPACK: + msg = "Error depacking file"; + break; + case -XMP_ERROR_SYSTEM: + msg = "System error in libxmp"; + break; + case -XMP_ERROR_INVALID: + msg = "Invalid parameter"; + break; + case -XMP_ERROR_STATE: + msg = "Invalid player state"; + break; + default: + msg = "Unknown error"; + break; + } + Mix_SetError("XMP: %s", msg); +} + +/* Load a libxmp stream from an SDL_RWops object */ +void *XMP_CreateFromRW(SDL_RWops *src, int freesrc) +{ + XMP_Music *music; + void *mem; + size_t size; + int err; + + music = (XMP_Music *)SDL_calloc(1, sizeof(*music)); + if (!music) { + SDL_OutOfMemory(); + return NULL; + } + + music->ctx = libxmp.xmp_create_context(); + if (!music->ctx) { + SDL_OutOfMemory(); + goto e0; + } + + music->buffer_size = music_spec.samples * 2 * 2; + music->buffer = SDL_malloc((size_t)music->buffer_size); + if (!music->buffer) { + SDL_OutOfMemory(); + goto e1; + } + + mem = SDL_LoadFile_RW(src, &size, SDL_FALSE); + if (mem) { + err = libxmp.xmp_load_module_from_memory(music->ctx, mem, (long)size); + SDL_free(mem); + if (err < 0) { + libxmp_set_error(err); + goto e1; + } + } else { + SDL_OutOfMemory(); + goto e1; + } + + err = libxmp.xmp_start_player(music->ctx, music_spec.freq, 0); + if (err < 0) { + libxmp_set_error(err); + goto e2; + } + + music->volume = MIX_MAX_VOLUME; + music->stream = SDL_NewAudioStream(AUDIO_S16SYS, 2, music_spec.freq, + music_spec.format, music_spec.channels, music_spec.freq); + if (!music->stream) { + goto e3; + } + + meta_tags_init(&music->tags); + libxmp.xmp_get_module_info(music->ctx, &music->mi); + if (music->mi.comment) { + meta_tags_set(&music->tags, MIX_META_TITLE, music->mi.comment); + } + + if (freesrc) { + SDL_RWclose(src); + } + return music; + +e3: libxmp.xmp_end_player(music->ctx); +e2: libxmp.xmp_release_module(music->ctx); +e1: libxmp.xmp_free_context(music->ctx); +e0: SDL_free(music->buffer); SDL_free(music); + return NULL; +} + +/* Set the volume for a libxmp stream */ +static void XMP_SetVolume(void *context, int volume) +{ + XMP_Music *music = (XMP_Music *)context; + music->volume = volume; +} + +/* Get the volume for a libxmp stream */ +static int XMP_GetVolume(void *context) +{ + XMP_Music *music = (XMP_Music *)context; + return music->volume; +} + +/* Start playback of a given libxmp stream */ +static int XMP_Play(void *context, int play_count) +{ + XMP_Music *music = (XMP_Music *)context; + music->play_count = play_count; + return XMP_Seek(music, 0); +} + +/* Play some of a stream previously started with xmp_play() */ +static int XMP_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + XMP_Music *music = (XMP_Music *)context; + int filled, amount, ret; + + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + /* if the data write is partial, rest of the buffer will be zero-filled. + * the loop param is the max number that the current sequence of song + * will be looped, or 0 to disable loop checking: 0 for play_count < 0 + * for an endless loop, or 1 for our own loop checks to do their job. */ + ret = libxmp.xmp_play_buffer(music->ctx, music->buffer, music->buffer_size, (music->play_count > 0)); + amount = music->buffer_size; + + if (ret == 0) { + if (SDL_AudioStreamPut(music->stream, music->buffer, amount) < 0) { + return -1; + } + } else { + if (ret != -XMP_END) { + return -1; + } + if (music->play_count == 1) { + music->play_count = 0; + SDL_AudioStreamFlush(music->stream); + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + if (XMP_Play(music, play_count) < 0) { + return -1; + } + } + } + return 0; +} +static int XMP_GetAudio(void *context, void *data, int bytes) +{ + XMP_Music *music = (XMP_Music *)context; + return music_pcm_getaudio(context, data, bytes, music->volume, XMP_GetSome); +} + +/* Jump to a given order */ +static int XMP_Jump(void *context, int order) +{ + XMP_Music *music = (XMP_Music *)context; + return libxmp.xmp_set_position(music->ctx, order); +} + +/* Jump (seek) to a given position */ +static int XMP_Seek(void *context, double pos) +{ + XMP_Music *music = (XMP_Music *)context; + libxmp.xmp_seek_time(music->ctx, (int)(pos * 1000)); + libxmp.xmp_play_buffer(music->ctx, NULL, 0, 0); /* reset internal state. */ + return 0; +} + +static double XMP_Tell(void *context) +{ + XMP_Music *music = (XMP_Music *)context; + libxmp.xmp_get_frame_info(music->ctx, &music->fi); + return music->fi.time / 1000.0; +} + +static double XMP_Duration(void *context) +{ + XMP_Music *music = (XMP_Music *)context; + libxmp.xmp_get_frame_info(music->ctx, &music->fi); + return music->fi.total_time / 1000.0; +} + +static const char* XMP_GetMetaTag(void *context, Mix_MusicMetaTag tag_type) +{ + XMP_Music *music = (XMP_Music *)context; + return meta_tags_get(&music->tags, tag_type); +} + +/* Close the given libxmp stream */ +static void XMP_Delete(void *context) +{ + XMP_Music *music = (XMP_Music *)context; + meta_tags_clear(&music->tags); + if (music->ctx) { + libxmp.xmp_stop_module(music->ctx); + libxmp.xmp_end_player(music->ctx); + libxmp.xmp_release_module(music->ctx); + libxmp.xmp_free_context(music->ctx); + } + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } + if (music->buffer) { + SDL_free(music->buffer); + } + SDL_free(music); +} + +Mix_MusicInterface Mix_MusicInterface_XMP = +{ + "XMP", + MIX_MUSIC_LIBXMP, + MUS_MOD, + SDL_FALSE, + SDL_FALSE, + + XMP_Load, + NULL, /* Open */ + XMP_CreateFromRW, + NULL, /* CreateFromFile */ + XMP_SetVolume, + XMP_GetVolume, + XMP_Play, + NULL, /* IsPlaying */ + XMP_GetAudio, + XMP_Jump, + XMP_Seek, + XMP_Tell, + XMP_Duration, + NULL, /* LoopStart */ + NULL, /* LoopEnd */ + NULL, /* LoopLength */ + XMP_GetMetaTag, + NULL, /* Pause */ + NULL, /* Resume */ + NULL, /* Stop */ + XMP_Delete, + NULL, /* Close */ + XMP_Unload +}; + +#endif /* MUSIC_MOD_XMP */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/music_xmp.h b/src/codecs/music_xmp.h new file mode 100644 index 0000000..6e1fb37 --- /dev/null +++ b/src/codecs/music_xmp.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports playing MOD files with libxmp */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_XMP; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/codecs/native_midi/native_midi.h b/src/codecs/native_midi/native_midi.h new file mode 100644 index 0000000..280084d --- /dev/null +++ b/src/codecs/native_midi/native_midi.h @@ -0,0 +1,40 @@ +/* + native_midi: Hardware Midi support for the SDL_mixer library + Copyright (C) 2000 Florian 'Proff' Schulze + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef NATIVE_MIDI_H_ +#define NATIVE_MIDI_H_ + +#include "SDL_rwops.h" + +typedef struct _NativeMidiSong NativeMidiSong; + +int native_midi_detect(void); +NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc); +void native_midi_freesong(NativeMidiSong *song); +void native_midi_start(NativeMidiSong *song, int loops); +void native_midi_pause(void); +void native_midi_resume(void); +void native_midi_stop(void); +int native_midi_active(void); +void native_midi_setvolume(int volume); +const char *native_midi_error(void); + +#endif /* NATIVE_MIDI_H_ */ diff --git a/src/codecs/native_midi/native_midi_common.c b/src/codecs/native_midi/native_midi_common.c new file mode 100644 index 0000000..8824486 --- /dev/null +++ b/src/codecs/native_midi/native_midi_common.c @@ -0,0 +1,416 @@ +/* + native_midi: Hardware Midi support for the SDL_mixer library + Copyright (C) 2000,2001 Florian 'Proff' Schulze + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + + +#include "native_midi_common.h" + +#include "SDL_mixer.h" + +/* The constant 'MThd' */ +#define MIDI_MAGIC 0x4d546864 +/* The constant 'RIFF' */ +#define RIFF_MAGIC 0x52494646 + +/* A single midi track as read from the midi file */ +typedef struct +{ + Uint8 *data; /* MIDI message stream */ + int len; /* length of the track data */ +} MIDITrack; + +/* A midi file, stripped down to the absolute minimum - divison & track data */ +typedef struct +{ + int division; /* number of pulses per quarter note (ppqn) */ + int nTracks; /* number of tracks */ + MIDITrack *track; /* tracks */ +} MIDIFile; + + +/* Some macros that help us stay endianess-independant */ +#if SDL_BYTEORDER == SDL_BIG_ENDIAN +#define BE_SHORT(x) (x) +#define BE_LONG(x) (x) +#else +#define BE_SHORT(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF)) +#define BE_LONG(x) ((((x)&0x0000FF)<<24) | \ + (((x)&0x00FF00)<<8) | \ + (((x)&0xFF0000)>>8) | \ + (((x)>>24)&0xFF)) +#endif + + + +/* Get Variable Length Quantity */ +static int GetVLQ(MIDITrack *track, int *currentPos) +{ + int l = 0; + Uint8 c; + while(1) + { + c = track->data[*currentPos]; + (*currentPos)++; + l += (c & 0x7f); + if (!(c & 0x80)) + return l; + l <<= 7; + } +} + +/* Create a single MIDIEvent */ +static MIDIEvent *CreateEvent(Uint32 time, Uint8 event, Uint8 a, Uint8 b) +{ + MIDIEvent *newEvent; + + newEvent = SDL_calloc(1, sizeof(MIDIEvent)); + + if (newEvent) + { + newEvent->time = time; + newEvent->status = event; + newEvent->data[0] = a; + newEvent->data[1] = b; + } + else + Mix_SetError("Out of memory"); + + return newEvent; +} + +/* Convert a single midi track to a list of MIDIEvents */ +static MIDIEvent *MIDITracktoStream(MIDITrack *track) +{ + Uint32 atime = 0; + Uint32 len = 0; + Uint8 event,type,a,b; + Uint8 laststatus = 0; + Uint8 lastchan = 0; + int currentPos = 0; + int end = 0; + MIDIEvent *head = CreateEvent(0,0,0,0); /* dummy event to make handling the list easier */ + MIDIEvent *currentEvent = head; + + while (!end) + { + if (currentPos >= track->len) + break; /* End of data stream reached */ + + atime += GetVLQ(track, ¤tPos); + event = track->data[currentPos++]; + + /* Handle SysEx seperatly */ + if (((event>>4) & 0x0F) == MIDI_STATUS_SYSEX) + { + if (event == 0xFF) + { + type = track->data[currentPos]; + currentPos++; + switch(type) + { + case 0x2f: /* End of data marker */ + end = 1; + case 0x51: /* Tempo change */ + /* + a=track->data[currentPos]; + b=track->data[currentPos+1]; + c=track->data[currentPos+2]; + AddEvent(song, atime, MEVT_TEMPO, c, b, a); + */ + break; + } + } + else + type = 0; + + len = GetVLQ(track, ¤tPos); + + /* Create an event and attach the extra data, if any */ + currentEvent->next = CreateEvent(atime, event, type, 0); + currentEvent = currentEvent->next; + if (NULL == currentEvent) + { + FreeMIDIEventList(head); + return NULL; + } + if (len) + { + currentEvent->extraLen = len; + currentEvent->extraData = SDL_malloc(len); + SDL_memcpy(currentEvent->extraData, &(track->data[currentPos]), len); + currentPos += len; + } + } + else + { + a = event; + if (a & 0x80) /* It's a status byte */ + { + /* Extract channel and status information */ + lastchan = a & 0x0F; + laststatus = (a>>4) & 0x0F; + + /* Read the next byte which should always be a data byte */ + a = track->data[currentPos++] & 0x7F; + } + switch(laststatus) + { + case MIDI_STATUS_NOTE_OFF: + case MIDI_STATUS_NOTE_ON: /* Note on */ + case MIDI_STATUS_AFTERTOUCH: /* Key Pressure */ + case MIDI_STATUS_CONTROLLER: /* Control change */ + case MIDI_STATUS_PITCH_WHEEL: /* Pitch wheel */ + b = track->data[currentPos++] & 0x7F; + currentEvent->next = CreateEvent(atime, (Uint8)((laststatus<<4)+lastchan), a, b); + currentEvent = currentEvent->next; + if (NULL == currentEvent) + { + FreeMIDIEventList(head); + return NULL; + } + break; + + case MIDI_STATUS_PROG_CHANGE: /* Program change */ + case MIDI_STATUS_PRESSURE: /* Channel pressure */ + a &= 0x7f; + currentEvent->next = CreateEvent(atime, (Uint8)((laststatus<<4)+lastchan), a, 0); + currentEvent = currentEvent->next; + if (NULL == currentEvent) + { + FreeMIDIEventList(head); + return NULL; + } + break; + + default: /* Sysex already handled above */ + break; + } + } + } + + currentEvent = head->next; + SDL_free(head); /* release the dummy head event */ + return currentEvent; +} + +/* + * Convert a midi song, consisting of up to 32 tracks, to a list of MIDIEvents. + * To do so, first convert the tracks seperatly, then interweave the resulting + * MIDIEvent-Lists to one big list. + */ +static MIDIEvent *MIDItoStream(MIDIFile *mididata) +{ + MIDIEvent **track; + MIDIEvent *head = CreateEvent(0,0,0,0); /* dummy event to make handling the list easier */ + MIDIEvent *currentEvent = head; + int trackID; + + if (NULL == head) + return NULL; + + track = (MIDIEvent**) SDL_calloc(1, sizeof(MIDIEvent*) * mididata->nTracks); + if (NULL == track) + { + SDL_free(head); + return NULL; + } + + /* First, convert all tracks to MIDIEvent lists */ + for (trackID = 0; trackID < mididata->nTracks; trackID++) + track[trackID] = MIDITracktoStream(&mididata->track[trackID]); + + /* Now, merge the lists. */ + /* TODO */ + while(1) + { + Uint32 lowestTime = 0x7FFFFFFF; /* INT_MAX */ + int currentTrackID = -1; + + /* Find the next event */ + for (trackID = 0; trackID < mididata->nTracks; trackID++) + { + if (track[trackID] && (track[trackID]->time < lowestTime)) + { + currentTrackID = trackID; + lowestTime = track[currentTrackID]->time; + } + } + + /* Check if we processes all events */ + if (currentTrackID == -1) + break; + + currentEvent->next = track[currentTrackID]; + track[currentTrackID] = track[currentTrackID]->next; + + currentEvent = currentEvent->next; + + + lowestTime = 0; + } + + /* Make sure the list is properly terminated */ + currentEvent->next = 0; + + currentEvent = head->next; + SDL_free(track); + SDL_free(head); /* release the dummy head event */ + return currentEvent; +} + +static int ReadMIDIFile(MIDIFile *mididata, SDL_RWops *src) +{ + int i = 0; + Uint32 ID; + Uint32 size; + Uint16 format; + Uint16 tracks; + Uint16 division; + + if (!mididata) + return 0; + if (!src) + return 0; + + /* Make sure this is really a MIDI file */ + SDL_RWread(src, &ID, 1, 4); + if (BE_LONG(ID) == RIFF_MAGIC) { + SDL_RWseek(src, 16, RW_SEEK_CUR); + SDL_RWread(src, &ID, 1, 4); + } + if (BE_LONG(ID) != MIDI_MAGIC) + return 0; + + /* Header size must be 6 */ + SDL_RWread(src, &size, 1, 4); + size = BE_LONG(size); + if (size != 6) + return 0; + + /* We only support format 0 and 1, but not 2 */ + SDL_RWread(src, &format, 1, 2); + format = BE_SHORT(format); + if (format != 0 && format != 1) + return 0; + + SDL_RWread(src, &tracks, 1, 2); + tracks = BE_SHORT(tracks); + mididata->nTracks = tracks; + + /* Allocate tracks */ + mididata->track = (MIDITrack*) SDL_calloc(1, sizeof(MIDITrack) * mididata->nTracks); + if (NULL == mididata->track) + { + Mix_SetError("Out of memory"); + goto bail; + } + + /* Retrieve the PPQN value, needed for playback */ + SDL_RWread(src, &division, 1, 2); + mididata->division = BE_SHORT(division); + + + for (i=0; itrack[i].len = size; + mididata->track[i].data = SDL_malloc(size); + if (NULL == mididata->track[i].data) + { + Mix_SetError("Out of memory"); + goto bail; + } + SDL_RWread(src, mididata->track[i].data, 1, size); + } + return 1; + +bail: + for(;i >= 0; i--) + { + if (mididata->track[i].data) + SDL_free(mididata->track[i].data); + } + + return 0; +} + +MIDIEvent *CreateMIDIEventList(SDL_RWops *src, Uint16 *division) +{ + MIDIFile *mididata = NULL; + MIDIEvent *eventList; + int trackID; + + mididata = SDL_calloc(1, sizeof(MIDIFile)); + if (!mididata) + return NULL; + + /* Open the file */ + if ( src != NULL ) + { + /* Read in the data */ + if ( ! ReadMIDIFile(mididata, src)) + { + SDL_free(mididata); + return NULL; + } + } + else + { + SDL_free(mididata); + return NULL; + } + + if (division) + *division = mididata->division; + + eventList = MIDItoStream(mididata); + if (eventList == NULL) + { + SDL_free(mididata); + return NULL; + } + for(trackID = 0; trackID < mididata->nTracks; trackID++) + { + if (mididata->track[trackID].data) + SDL_free(mididata->track[trackID].data); + } + SDL_free(mididata->track); + SDL_free(mididata); + + return eventList; +} + +void FreeMIDIEventList(MIDIEvent *head) +{ + MIDIEvent *cur, *next; + + cur = head; + + while (cur) + { + next = cur->next; + if (cur->extraData) + SDL_free (cur->extraData); + SDL_free (cur); + cur = next; + } +} diff --git a/src/codecs/native_midi/native_midi_common.h b/src/codecs/native_midi/native_midi_common.h new file mode 100644 index 0000000..438d53d --- /dev/null +++ b/src/codecs/native_midi/native_midi_common.h @@ -0,0 +1,63 @@ +/* + native_midi: Hardware Midi support for the SDL_mixer library + Copyright (C) 2000,2001 Florian 'Proff' Schulze + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _NATIVE_MIDI_COMMON_H_ +#define _NATIVE_MIDI_COMMON_H_ + +#include "SDL.h" + +/* Midi Status Bytes */ +#define MIDI_STATUS_NOTE_OFF 0x8 +#define MIDI_STATUS_NOTE_ON 0x9 +#define MIDI_STATUS_AFTERTOUCH 0xA +#define MIDI_STATUS_CONTROLLER 0xB +#define MIDI_STATUS_PROG_CHANGE 0xC +#define MIDI_STATUS_PRESSURE 0xD +#define MIDI_STATUS_PITCH_WHEEL 0xE +#define MIDI_STATUS_SYSEX 0xF + +/* We store the midi events in a linked list; this way it is + easy to shuffle the tracks together later on; and we are + flexible in the size of each elemnt. + */ +typedef struct MIDIEvent +{ + Uint32 time; /* Time at which this midi events occurs */ + Uint8 status; /* Status byte */ + Uint8 data[2]; /* 1 or 2 bytes additional data for most events */ + + Uint32 extraLen; /* For some SysEx events, we need additional storage */ + Uint8 *extraData; + + struct MIDIEvent *next; +} MIDIEvent; + + +/* Load a midifile to memory, converting it to a list of MIDIEvents. + This function returns a linked lists of MIDIEvents, 0 if an error occured. + */ +MIDIEvent *CreateMIDIEventList(SDL_RWops *rw, Uint16 *division); + +/* Release a MIDIEvent list after usage. */ +void FreeMIDIEventList(MIDIEvent *head); + + +#endif /* _NATIVE_MIDI_COMMON_H_ */ diff --git a/src/codecs/native_midi/native_midi_haiku.cpp b/src/codecs/native_midi/native_midi_haiku.cpp new file mode 100644 index 0000000..81b847e --- /dev/null +++ b/src/codecs/native_midi/native_midi_haiku.cpp @@ -0,0 +1,295 @@ +/* + native_midi_haiku: Native Midi support on Haiku for the SDL_mixer library + Copyright (C) 2010 Egor Suvorov + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifdef __HAIKU__ +#include +#include +#include +#include +#include +#include +#include +#include +extern "C" { +#include "native_midi.h" +#include "native_midi_common.h" +} + +bool compareMIDIEvent(const MIDIEvent &a, const MIDIEvent &b) +{ + return a.time < b.time; +} + +class MidiEventsStore : public BMidi +{ + public: + MidiEventsStore() + { + fPlaying = false; + fLoops = 0; + } + virtual status_t Import(SDL_RWops *src) + { + fEvs = CreateMIDIEventList(src, &fDivision); + if (!fEvs) { + return B_BAD_MIDI_DATA; + } + fTotal = 0; + for (MIDIEvent *x = fEvs; x; x = x->next) fTotal++; + fPos = fTotal; + + sort_events(); + return B_OK; + } + virtual void Run() + { + fPlaying = true; + fPos = 0; + MIDIEvent *ev = fEvs; + + uint32 startTime = B_NOW; + while (KeepRunning()) + { + if (!ev) { + if (fLoops && fEvs) { + if (fLoops > 0) --fLoops; + fPos = 0; + ev = fEvs; + } else + break; + } + SprayEvent(ev, ev->time + startTime); + ev = ev->next; + fPos++; + } + fPos = fTotal; + fPlaying = false; + } + virtual ~MidiEventsStore() + { + if (!fEvs) return; + FreeMIDIEventList(fEvs); + fEvs = 0; + } + + bool IsPlaying() + { + return fPlaying; + } + + void SetLoops(int loops) + { + fLoops = loops; + } + + protected: + MIDIEvent *fEvs; + Uint16 fDivision; + + int fPos, fTotal; + int fLoops; + bool fPlaying; + + void SprayEvent(MIDIEvent *ev, uint32 time) + { + switch (ev->status & 0xF0) + { + case B_NOTE_OFF: + SprayNoteOff((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time); + break; + case B_NOTE_ON: + SprayNoteOn((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time); + break; + case B_KEY_PRESSURE: + SprayKeyPressure((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time); + break; + case B_CONTROL_CHANGE: + SprayControlChange((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time); + break; + case B_PROGRAM_CHANGE: + SprayProgramChange((ev->status & 0x0F) + 1, ev->data[0], time); + break; + case B_CHANNEL_PRESSURE: + SprayChannelPressure((ev->status & 0x0F) + 1, ev->data[0], time); + break; + case B_PITCH_BEND: + SprayPitchBend((ev->status & 0x0F) + 1, ev->data[0], ev->data[1], time); + break; + case 0xF: + switch (ev->status) + { + case B_SYS_EX_START: + SpraySystemExclusive(ev->extraData, ev->extraLen, time); + break; + case B_MIDI_TIME_CODE: + case B_SONG_POSITION: + case B_SONG_SELECT: + case B_CABLE_MESSAGE: + case B_TUNE_REQUEST: + case B_SYS_EX_END: + SpraySystemCommon(ev->status, ev->data[0], ev->data[1], time); + break; + case B_TIMING_CLOCK: + case B_START: + case B_STOP: + case B_CONTINUE: + case B_ACTIVE_SENSING: + SpraySystemRealTime(ev->status, time); + break; + case B_SYSTEM_RESET: + if (ev->data[0] == 0x51 && ev->data[1] == 0x03) + { + assert(ev->extraLen == 3); + int val = (ev->extraData[0] << 16) | (ev->extraData[1] << 8) | ev->extraData[2]; + int tempo = 60000000 / val; + SprayTempoChange(tempo, time); + } + else + { + SpraySystemRealTime(ev->status, time); + } + } + break; + } + } + + void sort_events() + { + MIDIEvent *items = new MIDIEvent[fTotal]; + MIDIEvent *x = fEvs; + for (int i = 0; i < fTotal; i++) + { + memcpy(items + i, x, sizeof(MIDIEvent)); + x = x->next; + } + std::sort(items, items + fTotal, compareMIDIEvent); + + x = fEvs; + for (int i = 0; i < fTotal; i++) + { + MIDIEvent *ne = x->next; + memcpy(x, items + i, sizeof(MIDIEvent)); + x->next = ne; + x = ne; + } + + for (x = fEvs; x && x->next; x = x->next) + assert(x->time <= x->next->time); + + delete[] items; + } +}; + +BMidiSynth synth; +struct _NativeMidiSong { + MidiEventsStore *store; +} *currentSong = NULL; + +char lasterr[1024]; + +int native_midi_detect(void) +{ + status_t res = synth.EnableInput(true, false); + return res == B_OK; +} + +void native_midi_setvolume(int volume) +{ + if (volume < 0) volume = 0; + if (volume > 128) volume = 128; + synth.SetVolume(volume / 128.0); +} + +NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc) +{ + NativeMidiSong *song = new NativeMidiSong; + song->store = new MidiEventsStore; + status_t res = song->store->Import(src); + + if (res != B_OK) + { + snprintf(lasterr, sizeof lasterr, "Cannot Import() midi file: status_t=%d", res); + delete song->store; + delete song; + return NULL; + } + else + { + if (freesrc) { + SDL_RWclose(src); + } + } + return song; +} + +void native_midi_freesong(NativeMidiSong *song) +{ + if (song == NULL) return; + song->store->Stop(); + song->store->Disconnect(&synth); + if (currentSong == song) + { + currentSong = NULL; + } + delete song->store; + delete song; song = 0; +} + +void native_midi_start(NativeMidiSong *song, int loops) +{ + native_midi_stop(); + song->store->Connect(&synth); + song->store->SetLoops(loops); + song->store->Start(); + currentSong = song; +} + +void native_midi_pause(void) +{ +} + +void native_midi_resume(void) +{ +} + +void native_midi_stop(void) +{ + if (currentSong == NULL) return; + currentSong->store->Stop(); + currentSong->store->Disconnect(&synth); + while (currentSong->store->IsPlaying()) + usleep(1000); + currentSong = NULL; +} + +int native_midi_active(void) +{ + if (currentSong == NULL) return 0; + return currentSong->store->IsPlaying(); +} + +const char* native_midi_error(void) +{ + return lasterr; +} + +#endif /* __HAIKU__ */ diff --git a/src/codecs/native_midi/native_midi_macosx.c b/src/codecs/native_midi/native_midi_macosx.c new file mode 100644 index 0000000..cda2190 --- /dev/null +++ b/src/codecs/native_midi/native_midi_macosx.c @@ -0,0 +1,379 @@ +/* + native_midi_macosx: Native Midi support on Mac OS X for the SDL_mixer library + Copyright (C) 2009 Ryan C. Gordon + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_config.h" + +#if __MACOSX__ + +/* Mac OS X 10.6+, using Core MIDI. */ + +#include "SDL_stdinc.h" + +#include +#include +#include + +#include "SDL_endian.h" +#include "SDL_mixer.h" +#include "../../mixer.h" +#include "native_midi.h" + +/* Native Midi song */ +struct _NativeMidiSong +{ + MusicPlayer player; + MusicSequence sequence; + MusicTimeStamp endTime; + AudioUnit audiounit; + int loops; +}; + +static NativeMidiSong *currentsong = NULL; +static int latched_volume = MIX_MAX_VOLUME; + +static OSStatus +GetSequenceLength(MusicSequence sequence, MusicTimeStamp *_sequenceLength) +{ + /* http://lists.apple.com/archives/Coreaudio-api/2003/Jul/msg00370.html + * figure out sequence length */ + UInt32 ntracks, i; + MusicTimeStamp sequenceLength = 0; + OSStatus err; + + err = MusicSequenceGetTrackCount(sequence, &ntracks); + if (err != noErr) + return err; + + for (i = 0; i < ntracks; ++i) + { + MusicTrack track; + MusicTimeStamp tracklen = 0; + UInt32 tracklenlen = sizeof (tracklen); + + err = MusicSequenceGetIndTrack(sequence, i, &track); + if (err != noErr) + return err; + + err = MusicTrackGetProperty(track, kSequenceTrackProperty_TrackLength, + &tracklen, &tracklenlen); + if (err != noErr) + return err; + + if (sequenceLength < tracklen) + sequenceLength = tracklen; + } + + *_sequenceLength = sequenceLength; + + return noErr; +} + +static OSStatus +GetSequenceAudioUnitMatching(MusicSequence sequence, AudioUnit *aunit, + OSType type, OSType subtype) +{ + AUGraph graph; + UInt32 nodecount, i; + OSStatus err; + + err = MusicSequenceGetAUGraph(sequence, &graph); + if (err != noErr) + return err; + + err = AUGraphGetNodeCount(graph, &nodecount); + if (err != noErr) + return err; + + for (i = 0; i < nodecount; i++) { + AUNode node; + AudioComponentDescription desc; + + if (AUGraphGetIndNode(graph, i, &node) != noErr) + continue; /* better luck next time. */ + + if (AUGraphNodeInfo(graph, node, &desc, aunit) != noErr) + continue; + else if (desc.componentType != type) + continue; + else if (desc.componentSubType != subtype) + continue; + + return noErr; /* found it! */ + } + + *aunit = NULL; + return kAUGraphErr_NodeNotFound; +} + +typedef struct { + AudioUnit aunit; + SDL_bool soundfont_set; + CFURLRef default_url; +} macosx_load_soundfont_ctx; + +static int SDLCALL +macosx_load_soundfont(const char *path, void *data) +{ + CFURLRef url; + OSStatus err; + macosx_load_soundfont_ctx *ctx = data; + if (ctx->soundfont_set) + return SDL_FALSE; + + url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, + (const UInt8*)path, + strlen(path), false); + if (!url) + return SDL_FALSE; + + err = AudioUnitSetProperty(ctx->aunit, kMusicDeviceProperty_SoundBankURL, + kAudioUnitScope_Global, 0, &url, sizeof(url)); + CFRelease(url); + if (err != noErr) { + if (ctx->default_url) + err = AudioUnitSetProperty(ctx->aunit, + kMusicDeviceProperty_SoundBankURL, + kAudioUnitScope_Global, 0, + &ctx->default_url, sizeof(CFURLRef)); + if (err != noErr) { + /* uh-oh, this might leave the audio unit in an unusable state + (e.g. if the soundfont was an incompatible file type) */ + } + return SDL_FALSE; + } + + ctx->soundfont_set = SDL_TRUE; + return SDL_TRUE; +} + +static void +SetSequenceSoundFont(MusicSequence sequence) +{ + OSStatus err; + macosx_load_soundfont_ctx ctx; + ctx.soundfont_set = SDL_FALSE; + ctx.default_url = NULL; + + CFBundleRef bundle = CFBundleGetBundleWithIdentifier( + CFSTR("com.apple.audio.units.Components")); + if (bundle) + ctx.default_url = CFBundleCopyResourceURL(bundle, + CFSTR("gs_instruments"), + CFSTR("dls"), NULL); + + err = GetSequenceAudioUnitMatching(sequence, &ctx.aunit, + kAudioUnitType_MusicDevice, + kAudioUnitSubType_DLSSynth); + if (err != noErr) + return; + + Mix_EachSoundFont(macosx_load_soundfont, &ctx); + if (ctx.default_url) + CFRelease(ctx.default_url); + return; +} + +int native_midi_detect(void) +{ + return 1; /* always available. */ +} + +NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc) +{ + NativeMidiSong *retval = NULL; + void *buf = NULL; + Sint64 len = 0; + CFDataRef data = NULL; + + if (SDL_RWseek(src, 0, RW_SEEK_END) < 0) + goto fail; + len = SDL_RWtell(src); + if (len < 0) + goto fail; + if (SDL_RWseek(src, 0, RW_SEEK_SET) < 0) + goto fail; + + buf = SDL_malloc(len); + if (buf == NULL) + goto fail; + + if (SDL_RWread(src, buf, len, 1) != 1) + goto fail; + + retval = SDL_malloc(sizeof(NativeMidiSong)); + if (retval == NULL) + goto fail; + + SDL_memset(retval, '\0', sizeof (*retval)); + + if (NewMusicPlayer(&retval->player) != noErr) + goto fail; + if (NewMusicSequence(&retval->sequence) != noErr) + goto fail; + + data = CFDataCreate(NULL, (const UInt8 *) buf, len); + if (data == NULL) + goto fail; + + SDL_free(buf); + buf = NULL; + + if (MusicSequenceFileLoadData(retval->sequence, data, 0, 0) != noErr) + goto fail; + + CFRelease(data); + data = NULL; + + if (GetSequenceLength(retval->sequence, &retval->endTime) != noErr) + goto fail; + + if (MusicPlayerSetSequence(retval->player, retval->sequence) != noErr) + goto fail; + + if (freesrc) + SDL_RWclose(src); + + return retval; + +fail: + if (retval) { + if (retval->sequence) + DisposeMusicSequence(retval->sequence); + if (retval->player) + DisposeMusicPlayer(retval->player); + SDL_free(retval); + } + + if (data) + CFRelease(data); + + if (buf) + SDL_free(buf); + + return NULL; +} + +void native_midi_freesong(NativeMidiSong *song) +{ + if (song != NULL) { + if (currentsong == song) + currentsong = NULL; + MusicPlayerStop(song->player); + + /* needed to prevent error and memory leak when disposing sequence */ + MusicPlayerSetSequence(song->player, NULL); + + DisposeMusicSequence(song->sequence); + DisposeMusicPlayer(song->player); + SDL_free(song); + } +} + +void native_midi_start(NativeMidiSong *song, int loops) +{ + int vol; + + if (song == NULL) + return; + + SDL_PauseAudio(1); + Mix_UnlockAudio(); + + if (currentsong) + MusicPlayerStop(currentsong->player); + + currentsong = song; + currentsong->loops = loops; + + MusicPlayerPreroll(song->player); + GetSequenceAudioUnitMatching(song->sequence, &song->audiounit, + kAudioUnitType_Output, + kAudioUnitSubType_DefaultOutput); + SetSequenceSoundFont(song->sequence); + + vol = latched_volume; + latched_volume++; /* just make this not match. */ + native_midi_setvolume(vol); + + MusicPlayerSetTime(song->player, 0); + MusicPlayerStart(song->player); + + Mix_LockAudio(); + SDL_PauseAudio(0); +} + +void native_midi_pause(void) +{ +} + +void native_midi_resume(void) +{ +} + +void native_midi_stop(void) +{ + if (currentsong) { + SDL_PauseAudio(1); + Mix_UnlockAudio(); + MusicPlayerStop(currentsong->player); + currentsong = NULL; + Mix_LockAudio(); + SDL_PauseAudio(0); + } +} + +int native_midi_active(void) +{ + MusicTimeStamp currentTime = 0; + if (currentsong == NULL) + return 0; + + MusicPlayerGetTime(currentsong->player, ¤tTime); + if ((currentTime < currentsong->endTime) || + (currentTime >= kMusicTimeStamp_EndOfTrack)) { + return 1; + } else if (currentsong->loops) { + --currentsong->loops; + MusicPlayerSetTime(currentsong->player, 0); + return 1; + } + return 0; +} + +void native_midi_setvolume(int volume) +{ + if (latched_volume == volume) + return; + + latched_volume = volume; + if ((currentsong) && (currentsong->audiounit)) { + const float floatvol = ((float) volume) / ((float) MIX_MAX_VOLUME); + AudioUnitSetParameter(currentsong->audiounit, kHALOutputParam_Volume, + kAudioUnitScope_Global, 0, floatvol, 0); + } +} + +const char *native_midi_error(void) +{ + return ""; /* !!! FIXME */ +} + +#endif /* Mac OS X native MIDI support */ diff --git a/src/codecs/native_midi/native_midi_win32.c b/src/codecs/native_midi/native_midi_win32.c new file mode 100644 index 0000000..10f0c73 --- /dev/null +++ b/src/codecs/native_midi/native_midi_win32.c @@ -0,0 +1,327 @@ +/* + native_midi: Hardware Midi support for the SDL_mixer library + Copyright (C) 2000,2001 Florian 'Proff' Schulze + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +/* everything below is currently one very big bad hack ;) Proff */ + +#if __WIN32__ +#define WIN32_LEAN_AND_MEAN + +#include +#include + +#include "native_midi.h" +#include "native_midi_common.h" + +struct _NativeMidiSong { + int MusicLoaded; + int MusicPlaying; + int Loops; + int CurrentHdr; + MIDIHDR MidiStreamHdr[2]; + MIDIEVENT *NewEvents; + Uint16 ppqn; + int Size; + int NewPos; +}; + +static UINT MidiDevice=MIDI_MAPPER; +static HMIDISTRM hMidiStream; +static NativeMidiSong *currentsong; + +static int BlockOut(NativeMidiSong *song) +{ + MMRESULT err; + int BlockSize; + MIDIHDR *hdr; + + if ((song->MusicLoaded) && (song->NewEvents)) + { + /* proff 12/8/98: Added for safety*/ + song->CurrentHdr = !song->CurrentHdr; + hdr = &song->MidiStreamHdr[song->CurrentHdr]; + midiOutUnprepareHeader((HMIDIOUT)hMidiStream,hdr,sizeof(MIDIHDR)); + if (song->NewPos>=song->Size) + return 0; + BlockSize=(song->Size-song->NewPos); + if (BlockSize<=0) + return 0; + if (BlockSize>36000) + BlockSize=36000; + hdr->lpData=(void *)((unsigned char *)song->NewEvents+song->NewPos); + song->NewPos+=BlockSize; + hdr->dwBufferLength=BlockSize; + hdr->dwBytesRecorded=BlockSize; + hdr->dwFlags=0; + hdr->dwOffset=0; + err=midiOutPrepareHeader((HMIDIOUT)hMidiStream,hdr,sizeof(MIDIHDR)); + if (err!=MMSYSERR_NOERROR) + return 0; + err=midiStreamOut(hMidiStream,hdr,sizeof(MIDIHDR)); + return 0; + } + return 1; +} + +static void MIDItoStream(NativeMidiSong *song, MIDIEvent *evntlist) +{ + int eventcount; + MIDIEvent *event; + MIDIEVENT *newevent; + + eventcount=0; + event=evntlist; + while (event) + { + eventcount++; + event=event->next; + } + song->NewEvents = SDL_malloc(eventcount*3*sizeof(DWORD)); + if (!song->NewEvents) + return; + SDL_memset(song->NewEvents,0,(eventcount*3*sizeof(DWORD))); + + eventcount=0; + event=evntlist; + newevent=song->NewEvents; + while (event) + { + int status = (event->status&0xF0)>>4; + switch (status) + { + case MIDI_STATUS_NOTE_OFF: + case MIDI_STATUS_NOTE_ON: + case MIDI_STATUS_AFTERTOUCH: + case MIDI_STATUS_CONTROLLER: + case MIDI_STATUS_PROG_CHANGE: + case MIDI_STATUS_PRESSURE: + case MIDI_STATUS_PITCH_WHEEL: + newevent->dwDeltaTime=event->time; + newevent->dwEvent=(event->status|0x80)|(event->data[0]<<8)|(event->data[1]<<16)|(MEVT_SHORTMSG<<24); + newevent=(MIDIEVENT*)((char*)newevent+(3*sizeof(DWORD))); + eventcount++; + break; + + case MIDI_STATUS_SYSEX: + if (event->status == 0xFF && event->data[0] == 0x51) /* Tempo change */ + { + int tempo = (event->extraData[0] << 16) | + (event->extraData[1] << 8) | + event->extraData[2]; + newevent->dwDeltaTime=event->time; + newevent->dwEvent=(MEVT_TEMPO<<24) | tempo; + newevent=(MIDIEVENT*)((char*)newevent+(3*sizeof(DWORD))); + eventcount++; + } + break; + } + + event=event->next; + } + + song->Size=eventcount*3*sizeof(DWORD); + + { + int time; + int temptime; + + song->NewPos=0; + time=0; + newevent=song->NewEvents; + while (song->NewPosSize) + { + temptime=newevent->dwDeltaTime; + newevent->dwDeltaTime-=time; + time=temptime; + if ((song->NewPos+12)>=song->Size) + newevent->dwEvent |= MEVT_F_CALLBACK; + newevent=(MIDIEVENT*)((char*)newevent+(3*sizeof(DWORD))); + song->NewPos+=12; + } + } + song->NewPos=0; + song->MusicLoaded=1; +} + +void CALLBACK MidiProc( HMIDIIN hMidi, UINT uMsg, DWORD_PTR dwInstance, + DWORD_PTR dwParam1, DWORD_PTR dwParam2 ) +{ + (void)hMidi; + (void)dwInstance; + (void)dwParam2; + + switch( uMsg ) + { + case MOM_DONE: + if ((currentsong->MusicLoaded) && (dwParam1 == (DWORD_PTR)¤tsong->MidiStreamHdr[currentsong->CurrentHdr])) + BlockOut(currentsong); + break; + case MOM_POSITIONCB: + if ((currentsong->MusicLoaded) && (dwParam1 == (DWORD_PTR)¤tsong->MidiStreamHdr[currentsong->CurrentHdr])) { + if (currentsong->Loops) { + if (currentsong->Loops > 0) + --currentsong->Loops; + currentsong->NewPos=0; + BlockOut(currentsong); + } else { + currentsong->MusicPlaying=0; + } + } + break; + default: + break; + } +} + +int native_midi_detect(void) +{ + MMRESULT merr; + HMIDISTRM MidiStream; + + merr=midiStreamOpen(&MidiStream,&MidiDevice,(DWORD)1,(DWORD_PTR)MidiProc,(DWORD_PTR)0,CALLBACK_FUNCTION); + if (merr!=MMSYSERR_NOERROR) + return 0; + midiStreamClose(MidiStream); + return 1; +} + +NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc) +{ + NativeMidiSong *newsong; + MIDIEvent *evntlist = NULL; + + newsong = SDL_malloc(sizeof(NativeMidiSong)); + if (!newsong) { + return NULL; + } + SDL_memset(newsong,0,sizeof(NativeMidiSong)); + + /* Attempt to load the midi file */ + evntlist = CreateMIDIEventList(src, &newsong->ppqn); + if (!evntlist) + { + SDL_free(newsong); + return NULL; + } + + MIDItoStream(newsong, evntlist); + + FreeMIDIEventList(evntlist); + + if (freesrc) { + SDL_RWclose(src); + } + return newsong; +} + +void native_midi_freesong(NativeMidiSong *song) +{ + if (hMidiStream) + { + midiStreamStop(hMidiStream); + midiStreamClose(hMidiStream); + } + if (song) + { + if (song->NewEvents) + SDL_free(song->NewEvents); + SDL_free(song); + } +} + +void native_midi_start(NativeMidiSong *song, int loops) +{ + MMRESULT merr; + MIDIPROPTIMEDIV mptd; + + native_midi_stop(); + if (!hMidiStream) + { + merr=midiStreamOpen(&hMidiStream,&MidiDevice,(DWORD)1,(DWORD_PTR)MidiProc,(DWORD_PTR)0,CALLBACK_FUNCTION); + if (merr!=MMSYSERR_NOERROR) + { + hMidiStream = NULL; /* should I do midiStreamClose(hMidiStream) before? */ + return; + } + /* midiStreamStop(hMidiStream); */ + currentsong=song; + currentsong->NewPos=0; + currentsong->MusicPlaying=1; + currentsong->Loops=loops; + mptd.cbStruct=sizeof(MIDIPROPTIMEDIV); + mptd.dwTimeDiv=currentsong->ppqn; + merr=midiStreamProperty(hMidiStream,(LPBYTE)&mptd,MIDIPROP_SET | MIDIPROP_TIMEDIV); + BlockOut(song); + merr=midiStreamRestart(hMidiStream); + } +} + +void native_midi_pause(void) +{ + if (!hMidiStream) + return; + midiStreamPause(hMidiStream); +} + +void native_midi_resume(void) +{ + if (!hMidiStream) + return; + midiStreamRestart(hMidiStream); +} + +void native_midi_stop(void) +{ + if (!hMidiStream) + return; + midiStreamStop(hMidiStream); + midiStreamClose(hMidiStream); + currentsong=NULL; + hMidiStream = NULL; +} + +int native_midi_active(void) +{ + if (!hMidiStream) + return 0; + if (!currentsong) + return 0; + return currentsong->MusicPlaying; +} + +void native_midi_setvolume(int volume) +{ + int calcVolume; + if (volume > 128) + volume = 128; + if (volume < 0) + volume = 0; + calcVolume = (65535 * volume / 128); + + midiOutSetVolume((HMIDIOUT)hMidiStream, MAKELONG(calcVolume , calcVolume)); +} + +const char *native_midi_error(void) +{ + return ""; +} + +#endif /* Windows native MIDI support */ diff --git a/src/codecs/timidity/Android.mk b/src/codecs/timidity/Android.mk new file mode 100644 index 0000000..17585a7 --- /dev/null +++ b/src/codecs/timidity/Android.mk @@ -0,0 +1,24 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := timidity + +LOCAL_C_INCLUDES := + +LOCAL_CFLAGS := + +LOCAL_SRC_FILES += \ + common.c \ + instrum.c \ + mix.c \ + output.c \ + playmidi.c \ + readmidi.c \ + resample.c \ + tables.c \ + timidity.c + +LOCAL_SHARED_LIBRARIES := SDL2 + +include $(BUILD_STATIC_LIBRARY) diff --git a/src/codecs/timidity/CHANGES b/src/codecs/timidity/CHANGES new file mode 100644 index 0000000..ab79e99 --- /dev/null +++ b/src/codecs/timidity/CHANGES @@ -0,0 +1,77 @@ +This version of TiMidity should contain all the fixes from the +September 25 2003 SDL_mixer CVS snapshot. In addition, I've made some +changes of my own, e.g.: + +* All file access is done through SDL_RWops. This means the MIDI + stream no longer has to be a file. (The config file and instruments + still have to be though.) + +* Replacing of TiMidity's endian-handling with SDL's. + +* Removal of much unused or unnecessary code, such as + + + The "hooks" for putting a user interface onto TiMidity. + + The antialias filter. It wasn't active, and even at 4 kHz I + couldn't hear any difference when activating it. + + Removed all traces of LOOKUP_HACK and LOOKUP_INTERPOLATION. + According to the code comments they weren't very good anyway. + ("degrades sound quality noticeably"). I also removed the + disclaimer about the "8-bit uLaw to 16-bit PCM and the 13-bit-PCM + to 8-bit uLaw tables" disclaimer, since I believe those were the + tables I removed. + + Removed LOOKUP_SINE since it was already commented out. I think we + can count on our target audience having math co-processors + nowadays. + + Removed USE_LDEXP since it wasn't being used and "it doesn't make + much of a difference either way". + + Removed decompress hack from open_file() since it didn't look very + portable. + + Removed heaps of unnecessary constants. + + Removed unused functions. + + Assume that LINEAR_INTERPOLATION is always used, so remove all + code dealing with it not being so. It's not that I think the + difference in audio quality is that great, but since it wouldn't + compile without code changes I assume no one's used it for quite + some time... + + Assume PRECALC_LOOPS is always defined. Judging by the comments it + may not make much of a difference either way, so why maintain two + versions of the same code? + +* Moving several static globals into the MidiSong struct. This + includes sample rate, formate, etc. which are now all per-song. + +* Moved some typedefs (e.g. MidiSong) to timidity.h for easy inclusion + into the MIDI decoder. + +* Added free_pathlist(). + +* Replaced TiMidity's own 8, 16 and 32-bit types with SDL's. + +* Made TiMidity look for its configuration file in both /etc and + /usr/local/lib/timidity. (Windows version remains unchanged.) + +* Timidity_PlaySome() now takes three arguments. A MidiSong, a decode + buffer and decode buffer size in bytes. (MidiSong is a new argument, + and buffer size used to be in samples.) + + In addition, it will return the number of bytes decoded. + +* Added Timidity_Exit(). + +* Removed Timidity_Stop() and Timidity_Active(). Stopping playback + should be handled by SDL_sound, and Timidity_PlaySome() will return + 0 when the MIDI stream is finished. + +* Modified the ToneBank stuff to allow some data to be shared between + MidiSongs. + +* The following files have been removed: controls.c, controls.h, + filter.c, filter.h, sdl_a.c, sdl_c.c + +* config.h has been renamed as options.h to avoid confusion with the + automatically generated config.h for SDL_sound. + +* Added support for loading DLS format instruments: + Timidity_LoadDLS(), Timidity_FreeDLS(), Timidity_LoadDLSSong() + +* Added Timidity_Init_NoConfig() diff --git a/src/codecs/timidity/CMakeLists.txt b/src/codecs/timidity/CMakeLists.txt new file mode 100644 index 0000000..af3b60a --- /dev/null +++ b/src/codecs/timidity/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 2.8.11) +project(timidity_sdl C) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../external/audio_codec_common.cmake) + +find_package(SDL2 REQUIRED) + +add_library(timidity STATIC + common.c + instrum.c + mix.c + output.c + playmidi.c + readmidi.c + resample.c + tables.c + timidity.c +) + +target_include_directories(timidity PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) +target_include_directories(timidity PUBLIC ${SDL2_INCLUDE_DIRS}) + +install(TARGETS timidity + LIBRARY DESTINATION "lib" + ARCHIVE DESTINATION "lib" + INCLUDES DESTINATION "include") + +install(FILES + timidity.h + DESTINATION include/) diff --git a/src/codecs/timidity/COPYING b/src/codecs/timidity/COPYING new file mode 100644 index 0000000..cdbb291 --- /dev/null +++ b/src/codecs/timidity/COPYING @@ -0,0 +1,127 @@ + The "Artistic License" + + Preamble + +The intent of this document is to state the conditions under which a +Package may be copied, such that the Copyright Holder maintains some +semblance of artistic control over the development of the package, +while giving the users of the package the right to use and distribute +the Package in a more-or-less customary fashion, plus the right to make +reasonable modifications. + +Definitions: + + "Package" refers to the collection of files distributed by the + Copyright Holder, and derivatives of that collection of files + created through textual modification. + + "Standard Version" refers to such a Package if it has not been + modified, or has been modified in accordance with the wishes + of the Copyright Holder as specified below. + + "Copyright Holder" is whoever is named in the copyright or + copyrights for the package. + + "You" is you, if you're thinking about copying or distributing + this Package. + + "Reasonable copying fee" is whatever you can justify on the + basis of media cost, duplication charges, time of people involved, + and so on. (You will not be required to justify it to the + Copyright Holder, but only to the computing community at large + as a market that must bear the fee.) + + "Freely Available" means that no fee is charged for the item + itself, though there may be fees involved in handling the item. + It also means that recipients of the item may redistribute it + under the same conditions they received it. + +1. You may make and give away verbatim copies of the source form of the +Standard Version of this Package without restriction, provided that you +duplicate all of the original copyright notices and associated disclaimers. + +2. You may apply bug fixes, portability fixes and other modifications +derived from the Public Domain or from the Copyright Holder. A Package +modified in such a way shall still be considered the Standard Version. + +3. You may otherwise modify your copy of this Package in any way, provided +that you insert a prominent notice in each changed file stating how and +when you changed that file, and provided that you do at least ONE of the +following: + + a) place your modifications in the Public Domain or otherwise make them + Freely Available, such as by posting said modifications to Usenet or + an equivalent medium, or placing the modifications on a major archive + site such as uunet.uu.net, or by allowing the Copyright Holder to include + your modifications in the Standard Version of the Package. + + b) use the modified Package only within your corporation or organization. + + c) rename any non-standard executables so the names do not conflict + with standard executables, which must also be provided, and provide + a separate manual page for each non-standard executable that clearly + documents how it differs from the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + +4. You may distribute the programs of this Package in object code or +executable form, provided that you do at least ONE of the following: + + a) distribute a Standard Version of the executables and library files, + together with instructions (in the manual page or equivalent) on where + to get the Standard Version. + + b) accompany the distribution with the machine-readable source of + the Package with your modifications. + + c) give non-standard executables non-standard names, and clearly + document the differences in manual pages (or equivalent), together + with instructions on where to get the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + +5. You may charge a reasonable copying fee for any distribution of this +Package. You may charge any fee you choose for support of this +Package. You may not charge a fee for this Package itself. However, +you may distribute this Package in aggregate with other (possibly +commercial) programs as part of a larger (possibly commercial) software +distribution provided that you do not advertise this Package as a +product of your own. You may embed this Package's interpreter within +an executable of yours (by linking); this shall be construed as a mere +form of aggregation, provided that the complete Standard Version of the +interpreter is so embedded. + +6. The scripts and library files supplied as input to or produced as +output from the programs of this Package do not automatically fall +under the copyright of this Package, but belong to whoever generated +them, and may be sold commercially, and may be aggregated with this +Package. If such scripts or library files are aggregated with this +Package via the so-called "undump" or "unexec" methods of producing a +binary executable image, then distribution of such an image shall +neither be construed as a distribution of this Package nor shall it +fall under the restrictions of Paragraphs 3 and 4, provided that you do +not represent such an executable image as a Standard Version of this +Package. + +7. C subroutines (or comparably compiled subroutines in other +languages) supplied by you and linked into this Package in order to +emulate subroutines and variables of the language defined by this +Package shall not be considered part of this Package, but are the +equivalent of input as in Paragraph 6, provided these subroutines do +not change the language in any way that would cause it to fail the +regression tests for the language. + +8. Aggregation of this Package with a commercial distribution is always +permitted provided that the use of this Package is embedded; that is, +when no overt attempt is made to make this Package's interfaces visible +to the end user of the commercial distribution. Such use shall not be +construed as a distribution of this Package. + +9. The name of the Copyright Holder may not be used to endorse or promote +products derived from this software without specific prior written permission. + +10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + The End diff --git a/src/codecs/timidity/FAQ b/src/codecs/timidity/FAQ new file mode 100644 index 0000000..1ee0b77 --- /dev/null +++ b/src/codecs/timidity/FAQ @@ -0,0 +1,100 @@ +---------------------------*-indented-text-*------------------------------ + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + +-------------------------------------------------------------------------- + + Frequently Asked Questions with answers: + +-------------------------------------------------------------------------- +Q: What is it? + +A: Where? Well Chris, TiMidity is a software-only synthesizer, MIDI + renderer, MIDI to WAVE converter, realtime MIDI player for UNIX machines, + even (I've heard) a Netscape helper application. It takes a MIDI file + and writes a WAVE or raw PCM data or plays it on your digital audio + device. It sounds much more realistic than FM synthesis, but you need a + ~100Mhz processor to listen to 32kHz stereo music in the background while + you work. 11kHz mono can be played on a low-end 486, and, to some, it + still sounds better than FM. + +-------------------------------------------------------------------------- +Q: I don't have a GUS, can I use TiMidity? + +A: Yes. That's the point. You don't need a Gravis Ultrasound to use + TiMidity, you just need GUS-compatible patches, which are freely + available on the Internet. See below for pointers. + +-------------------------------------------------------------------------- +Q: I have a GUS, can I use TiMidity? + +A: The DOS port doesn't have GUS support, and TiMidity won't be taking + advantage of the board's internal synthesizer under other operating + systems either. So it kind of defeats the purpose. But you can use it. + +-------------------------------------------------------------------------- +Q: I tried playing a MIDI file I got off the Net but all I got was a + dozen warnings saying "No instrument mapped to tone bank 0, program + xx - this instrument will not be heard". What's wrong? + +A: The General MIDI standard specifies 128 melodic instruments and + some sixty percussion sounds. If you wish to play arbitrary General + MIDI files, you'll need to get more patch files. + + There's a program called Midia for SGI's, which also plays MIDI + files and has a lot more bells and whistles than TiMidity. It uses + GUS-compatible patches, too -- so you can get the 8 MB set at + ftp://archive.cs.umbc.edu/pub/midia for pretty good GM compatibility. + + There are also many excellent patches on the Ultrasound FTP sites. + I can recommend Dustin McCartney's collections gsdrum*.zip and + wow*.zip in the "[.../]sound/patches/files" directory. The huge + ProPats series (pp3-*.zip) contains good patches as well. General + MIDI files can also be found on these sites. + + This site list is from the GUS FAQ: + +> FTP Sites Archive Directories +> --------- ------------------- +> Main N.American Site: archive.orst.edu pub/packages/gravis +> wuarchive.wustl.edu systems/ibmpc/ultrasound +> Main Asian Site: nctuccca.edu.tw PC/ultrasound +> Main European Site: src.doc.ic.ac.uk packages/ultrasound +> Main Australian Site: ftp.mpx.com.au /ultrasound/general +> /ultrasound/submit +> South African Site: ftp.sun.ac.za /pub/packages/ultrasound +> Submissions: archive.epas.utoronto.ca pub/pc/ultrasound/submit +> Newly Validated Files: archive.epas.utoronto.ca pub/pc/ultrasound +> +> Mirrors: garbo.uwasa.fi mirror/ultrasound +> ftp.st.nepean.uws.edu.au pc/ultrasound +> ftp.luth.se pub/msdos/ultrasound + +-------------------------------------------------------------------------- +Q: Some files have awful clicks and pops. + +A: Find out which patch is responsible for the clicking (try "timidity + -P ". Add "strip=tail" in + the config file after its name. If this doesn't fix it, mail me the + patch. + +-------------------------------------------------------------------------- +Q: I'm playing Fantasie Impromptu in the background. When I run Netscape, + the sound gets choppy and it takes ten minutes to load. What can I do? + +A: Here are some things to try: + + - Use a lower sampling rate. + + - Use mono output. This can improve performance by 10-30%. + (Using 8-bit instead of 16-bit output makes no difference.) + + - Use a smaller number of simultaneous voices. + + - Make sure you compiled with FAST_DECAY enabled in options.h + + - Recompile with an Intel-optimized gcc for a 5-15% + performance increase. + +-------------------------------------------------------------------------- diff --git a/src/codecs/timidity/README b/src/codecs/timidity/README new file mode 100644 index 0000000..0dd9892 --- /dev/null +++ b/src/codecs/timidity/README @@ -0,0 +1,58 @@ +[This version of timidity has been stripped for simplicity in porting to SDL, +and then even further for SDL_sound] +---------------------------------*-text-*--------------------------------- + + From http://www.cgs.fi/~tt/discontinued.html : + + If you'd like to continue hacking on TiMidity, feel free. I'm + hereby extending the TiMidity license agreement: you can now + select the most convenient license for your needs from (1) the + GNU GPL, (2) the GNU LGPL, or (3) the Perl Artistic License. + +-------------------------------------------------------------------------- + + This is the README file for TiMidity v0.2i + + TiMidity is a MIDI to WAVE converter that uses Gravis +Ultrasound(*)-compatible patch files to generate digital audio data +from General MIDI files. The audio data can be played through any +sound device or stored on disk. On a fast machine, music can be +played in real time. TiMidity runs under Linux, FreeBSD, HP-UX, SunOS, and +Win32, and porting to other systems with gcc should be easy. + + TiMidity Features: + + * 32 or more dynamically allocated fully independent voices + * Compatibility with GUS patch files + * Output to 16- or 8-bit PCM or uLaw audio device, file, or + stdout at any sampling rate + * Optional interactive mode with real-time status display + under ncurses and SLang terminal control libraries. Also + a user friendly motif interface since version 0.2h + * Support for transparent loading of compressed MIDI files and + patch files + + * Support for the following MIDI events: + - Program change + - Key pressure + - Channel main volume + - Tempo + - Panning + - Damper pedal (Sustain) + - Pitch wheel + - Pitch wheel sensitivity + - Change drum set + +* TiMidity requires sampled instruments (patches) to play MIDI files. You + should get the file "timidity-lib-0.1.tar.gz" and unpack it in the same + directory where you unpacked the source code archive. You'll want more + patches later -- read the file "FAQ" for pointers. + +* Timidity is no longer supported, but can be found by searching the web. + + + Tuukka Toivonen + +[(*) Any Registered Trademarks used anywhere in the documentation or +source code for TiMidity are acknowledged as belonging to their +respective owners.] diff --git a/src/codecs/timidity/TODO b/src/codecs/timidity/TODO new file mode 100644 index 0000000..69b37ee --- /dev/null +++ b/src/codecs/timidity/TODO @@ -0,0 +1,37 @@ +* I don't like the indentation style at all, but for the most part + I've left it alone. + +* Much of the code looks ugly to me. + +* The return value from SDL_RWread() is checked inconsistenly. + +* Group the members of MidiSong into logical units, i.e. structs? + +* The debug messages are probably a bit too noisy. I've removed one + particularly annoying one, but... + + Some of them should be turned into error messages instead. + +* Can the instrument handling be made more efficient? At the moment + different MidiSongs may separately load the same instrument. + + Note that the MidiSong's audio format affects how the instrument is + loaded, so it's not as easy as just letting all MidiSongs share tone + and drum banks. + + At the moment they do share the data that is simply read from the + config file, but that's just a quick hack to avoid having to read + the config file every time a MIDI song is loaded. + +* Check if any of MidiStruct's members can safely be made into static + globals again. + +* TiMidity++ adds a number of undocumented (?) extensions to the + configuration syntax. These are not implemented here. In particular, + the "map" keyword used by the "eawpats". + +* The other decoders generally only read as much of the file as is + necessary. Could we do that in this decoder as well? (Currently it + seems to convert the entire file into MIDI events first.) + +* Can it be optimized? diff --git a/src/codecs/timidity/common.c b/src/codecs/timidity/common.c new file mode 100644 index 0000000..1096a38 --- /dev/null +++ b/src/codecs/timidity/common.c @@ -0,0 +1,112 @@ +/* + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. + + common.c +*/ + +#include "SDL.h" + +#include "options.h" +#include "common.h" + +#if defined(__WIN32__) || defined(__OS2__) +#define CHAR_DIRSEP '\\' +#define is_dirsep(c) ((c) == '/' || (c) == '\\') +#define is_abspath(p) ((p)[0] == '/' || (p)[0] == '\\' || ((p)[0] && (p)[1] == ':')) +#else /* unix: */ +#define CHAR_DIRSEP '/' +#define is_dirsep(c) ((c) == '/') +#define is_abspath(p) ((p)[0] == '/') +#endif + +/* The paths in this list will be tried whenever we're reading a file */ +typedef struct _PathList { + char *path; + struct _PathList *next; +} PathList; + +static PathList *pathlist = NULL; + +/* This is meant to find and open files for reading */ +SDL_RWops *timi_openfile(const char *name) +{ + SDL_RWops *rw; + + if (!name || !(*name)) { + SNDDBG(("Attempted to open nameless file.\n")); + return NULL; + } + + /* First try the given name */ + + SNDDBG(("Trying to open %s\n", name)); + if ((rw = SDL_RWFromFile(name, "rb")) != NULL) + return rw; + + if (!is_abspath(name)) + { + char current_filename[1024]; + PathList *plp = pathlist; + char *p; + size_t l; + + while (plp) { /* Try along the path then */ + *current_filename = 0; + p = current_filename; + l = SDL_strlen(plp->path); + if(l >= sizeof(current_filename) - 3) l = 0; + if(l) { + SDL_memcpy(current_filename, plp->path, l); + p += l; + if(!is_dirsep(p[-1])) { + *p++ = CHAR_DIRSEP; + l++; + } + } + SDL_strlcpy(p, name, sizeof(current_filename) - l); + SNDDBG(("Trying to open %s\n", current_filename)); + if ((rw = SDL_RWFromFile(current_filename, "rb"))) + return rw; + plp = plp->next; + } + } + + /* Nothing could be opened. */ + SNDDBG(("Could not open %s\n", name)); + return NULL; +} + +/* This adds a directory to the path list */ +int timi_add_pathlist(const char *s, size_t l) +{ + PathList *plp = SDL_malloc(sizeof(PathList)); + if (plp == NULL) return -2; + plp->path = SDL_malloc(l + 1); + if (plp->path == NULL) { + SDL_free (plp); + return -2; + } + SDL_memcpy(plp->path, s, l); + plp->path[l] = 0; + plp->next = pathlist; + pathlist = plp; + return 0; +} + +void timi_free_pathlist(void) +{ + PathList *plp = pathlist; + PathList *next; + + while (plp) { + next = plp->next; + SDL_free(plp->path); + SDL_free(plp); + plp = next; + } + pathlist = NULL; +} diff --git a/src/codecs/timidity/common.h b/src/codecs/timidity/common.h new file mode 100644 index 0000000..1b2b1ca --- /dev/null +++ b/src/codecs/timidity/common.h @@ -0,0 +1,31 @@ +/* + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. + + common.h +*/ + +#ifndef TIMIDITY_COMMON_H +#define TIMIDITY_COMMON_H + +extern SDL_RWops *timi_openfile(const char *name); + +/* pathlist funcs only to be used during Timidity_Init/Timidity_Exit */ +extern int timi_add_pathlist(const char *s, size_t len); +extern void timi_free_pathlist(void); + +/* hide private symbols by prefixing with "_timi_" */ +#undef TIMI_NAMESPACE +#define TIMI_NAMESPACE(x) _timi_ ## x + +/* debug output */ +#ifdef DEBUG_CHATTER +#define SNDDBG(X) SDL_Log X +#else +#define SNDDBG(X) +#endif + +#endif /* TIMIDITY_COMMON_H */ diff --git a/src/codecs/timidity/instrum.c b/src/codecs/timidity/instrum.c new file mode 100644 index 0000000..d53d4a2 --- /dev/null +++ b/src/codecs/timidity/instrum.c @@ -0,0 +1,606 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. + + instrum.c + + Code to load and unload GUS-compatible instrument patches. + +*/ + +#include "SDL.h" + +#include "timidity.h" +#include "options.h" +#include "common.h" +#include "instrum.h" +#include "resample.h" +#include "tables.h" + +static void free_instrument(Instrument *ip) +{ + Sample *sp; + int i; + if (!ip) return; + if (ip->sample) { + for (i=0; isamples; i++) { + sp=&(ip->sample[i]); + SDL_free(sp->data); + } + SDL_free(ip->sample); + } + SDL_free(ip); +} + +static void free_bank(MidiSong *song, int dr, int b) +{ + int i; + ToneBank *bank=((dr) ? song->drumset[b] : song->tonebank[b]); + for (i=0; iinstrument[i]) + { + if (bank->instrument[i] != MAGIC_LOAD_INSTRUMENT) + free_instrument(bank->instrument[i]); + bank->instrument[i] = NULL; + } +} + +static Sint32 convert_envelope_rate(MidiSong *song, Uint8 rate) +{ + Sint32 r; + + r = 3 - ((rate >> 6) & 0x3); + r *= 3; + r = (Sint32) (rate & 0x3f) << r; /* 6.9 fixed point */ + + /* 15.15 fixed point. */ + r = ((r * 44100) / song->rate) * song->control_ratio; + +#ifdef FAST_DECAY + return r << 10; +#else + return r << 9; +#endif +} + +static Sint32 convert_envelope_offset(Uint8 offset) +{ + /* This is not too good... Can anyone tell me what these values mean? + Are they GUS-style "exponential" volumes? And what does that mean? */ + + /* 15.15 fixed point */ + return offset << (7+15); +} + +static Sint32 convert_tremolo_sweep(MidiSong *song, Uint8 sweep) +{ + if (!sweep) + return 0; + + return + ((song->control_ratio * SWEEP_TUNING) << SWEEP_SHIFT) / + (song->rate * sweep); +} + +static Sint32 convert_vibrato_sweep(MidiSong *song, Uint8 sweep, + Sint32 vib_control_ratio) +{ + if (!sweep) + return 0; + + return + (Sint32) (TIM_FSCALE((double) (vib_control_ratio) * SWEEP_TUNING, SWEEP_SHIFT) + / (double)(song->rate * sweep)); + + /* this was overflowing with seashore.pat + + ((vib_control_ratio * SWEEP_TUNING) << SWEEP_SHIFT) / + (song->rate * sweep); */ +} + +static Sint32 convert_tremolo_rate(MidiSong *song, Uint8 rate) +{ + return + ((SINE_CYCLE_LENGTH * song->control_ratio * rate) << RATE_SHIFT) / + (TREMOLO_RATE_TUNING * song->rate); +} + +static Sint32 convert_vibrato_rate(MidiSong *song, Uint8 rate) +{ + /* Return a suitable vibrato_control_ratio value */ + return + (VIBRATO_RATE_TUNING * song->rate) / + (rate * 2 * VIBRATO_SAMPLE_INCREMENTS); +} + +static void reverse_data(Sint16 *sp, Sint32 ls, Sint32 le) +{ + Sint16 s, *ep=sp+le; + sp+=ls; + le-=ls; + le/=2; + while (le--) + { + s=*sp; + *sp++=*ep; + *ep--=s; + } +} + +/* + If panning or note_to_use != -1, it will be used for all samples, + instead of the sample-specific values in the instrument file. + + For note_to_use, any value <0 or >127 will be forced to 0. + + For other parameters, 1 means yes, 0 means no, other values are + undefined. + + TODO: do reverse loops right */ +static void load_instrument(MidiSong *song, const char *name, + Instrument **out, + int percussion, int panning, + int amp, int note_to_use, + int strip_loop, int strip_envelope, + int strip_tail) +{ + Instrument *ip; + Sample *sp; + SDL_RWops *rw; + char tmp[1024]; + int i,j; + static char *patch_ext[] = PATCH_EXT_LIST; + + (void)percussion; /* unused */ + *out = NULL; + if (!name) return; + + /* Open patch file */ + i = -1; + if ((rw=timi_openfile(name)) == NULL) + { + /* Try with various extensions */ + for (i=0; patch_ext[i]; i++) + { + SDL_snprintf(tmp, sizeof(tmp), "%s%s", name, patch_ext[i]); + if ((rw=timi_openfile(tmp)) != NULL) + break; + } + } + + if (rw == NULL) + { + SNDDBG(("Instrument `%s' can't be found.\n", name)); + return; + } + + SNDDBG(("Loading instrument %s\n", (i < 0)? name : tmp)); + + /* Read some headers and do cursory sanity checks. There are loads + of magic offsets. This could be rewritten... */ + + if ((239 != SDL_RWread(rw, tmp, 1, 239)) || + (SDL_memcmp(tmp, "GF1PATCH110\0ID#000002", 22) && + SDL_memcmp(tmp, "GF1PATCH100\0ID#000002", 22))) /* don't know what the + differences are */ + { + SNDDBG(("%s: not an instrument\n", name)); + goto badpat; + } + + if (tmp[82] != 1 && tmp[82] != 0) /* instruments. To some patch makers, + 0 means 1 */ + { + SNDDBG(("Can't handle patches with %d instruments\n", tmp[82])); + goto badpat; + } + + if (tmp[151] != 1 && tmp[151] != 0) /* layers. What's a layer? */ + { + SNDDBG(("Can't handle instruments with %d layers\n", tmp[151])); + goto badpat; + } + + *out=SDL_malloc(sizeof(Instrument)); + ip = *out; + if (!ip) goto nomem; + + ip->samples = tmp[198]; + ip->sample = SDL_malloc(sizeof(Sample) * ip->samples); + if (!ip->sample) goto nomem; + + for (i=0; isamples; i++) + { + Uint8 fractions; + Sint32 tmplong; + Uint16 tmpshort; + Uint8 tmpchar; + +#define READ_CHAR(thing) \ + if (1 != SDL_RWread(rw, &tmpchar, 1, 1)) goto badread; \ + thing = tmpchar; +#define READ_SHORT(thing) \ + if (1 != SDL_RWread(rw, &tmpshort, 2, 1)) goto badread; \ + thing = SDL_SwapLE16(tmpshort); +#define READ_LONG(thing) \ + if (1 != SDL_RWread(rw, &tmplong, 4, 1)) goto badread; \ + thing = (Sint32)SDL_SwapLE32((Uint32)tmplong); + + SDL_RWseek(rw, 7, RW_SEEK_CUR); /* Skip the wave name */ + + if (1 != SDL_RWread(rw, &fractions, 1, 1)) + goto badread; + + sp=&(ip->sample[i]); + + READ_LONG(sp->data_length); + READ_LONG(sp->loop_start); + READ_LONG(sp->loop_end); + READ_SHORT(sp->sample_rate); + READ_LONG(sp->low_freq); + READ_LONG(sp->high_freq); + READ_LONG(sp->root_freq); + SDL_RWseek(rw, 2, RW_SEEK_CUR); /* Why have a "root frequency" and then + * "tuning"?? */ + + READ_CHAR(tmp[0]); + + if (panning==-1) + sp->panning = (tmp[0] * 8 + 4) & 0x7f; + else + sp->panning=(Uint8)(panning & 0x7F); + + /* envelope, tremolo, and vibrato */ + if (18 != SDL_RWread(rw, tmp, 1, 18)) + goto badread; + + if (!tmp[13] || !tmp[14]) + { + sp->tremolo_sweep_increment= + sp->tremolo_phase_increment=sp->tremolo_depth=0; + SNDDBG((" * no tremolo\n")); + } + else + { + sp->tremolo_sweep_increment=convert_tremolo_sweep(song, tmp[12]); + sp->tremolo_phase_increment=convert_tremolo_rate(song, tmp[13]); + sp->tremolo_depth=tmp[14]; + SNDDBG((" * tremolo: sweep %d, phase %d, depth %d\n", + sp->tremolo_sweep_increment, sp->tremolo_phase_increment, + sp->tremolo_depth)); + } + + if (!tmp[16] || !tmp[17]) + { + sp->vibrato_sweep_increment= + sp->vibrato_control_ratio=sp->vibrato_depth=0; + SNDDBG((" * no vibrato\n")); + } + else + { + sp->vibrato_control_ratio=convert_vibrato_rate(song, tmp[16]); + sp->vibrato_sweep_increment= + convert_vibrato_sweep(song, tmp[15], sp->vibrato_control_ratio); + sp->vibrato_depth=tmp[17]; + SNDDBG((" * vibrato: sweep %d, ctl %d, depth %d\n", + sp->vibrato_sweep_increment, sp->vibrato_control_ratio, + sp->vibrato_depth)); + } + + READ_CHAR(sp->modes); + + SDL_RWseek(rw, 40, RW_SEEK_CUR); /* skip the useless scale frequency, scale + factor (what's it mean?), and reserved + space */ + + /* Mark this as a fixed-pitch instrument if such a deed is desired. */ + if (note_to_use!=-1) + sp->note_to_use=(Uint8)(note_to_use); + else + sp->note_to_use=0; + + /* seashore.pat in the Midia patch set has no Sustain. I don't + understand why, and fixing it by adding the Sustain flag to + all looped patches probably breaks something else. We do it + anyway. */ + if (sp->modes & MODES_LOOPING) + sp->modes |= MODES_SUSTAIN; + + /* Strip any loops and envelopes we're permitted to */ + if ((strip_loop==1) && + (sp->modes & (MODES_SUSTAIN | MODES_LOOPING | + MODES_PINGPONG | MODES_REVERSE))) + { + SNDDBG((" - Removing loop and/or sustain\n")); + sp->modes &=~(MODES_SUSTAIN | MODES_LOOPING | + MODES_PINGPONG | MODES_REVERSE); + } + + if (strip_envelope==1) + { + if (sp->modes & MODES_ENVELOPE) { + SNDDBG((" - Removing envelope\n")); + } + sp->modes &= ~MODES_ENVELOPE; + } + else if (strip_envelope != 0) + { + /* Have to make a guess. */ + if (!(sp->modes & (MODES_LOOPING | MODES_PINGPONG | MODES_REVERSE))) + { + /* No loop? Then what's there to sustain? No envelope needed + either... */ + sp->modes &= ~(MODES_SUSTAIN|MODES_ENVELOPE); + SNDDBG((" - No loop, removing sustain and envelope\n")); + } + else if (!SDL_memcmp(tmp, "??????", 6) || tmp[11] >= 100) + { + /* Envelope rates all maxed out? Envelope end at a high "offset"? + That's a weird envelope. Take it out. */ + sp->modes &= ~MODES_ENVELOPE; + SNDDBG((" - Weirdness, removing envelope\n")); + } + else if (!(sp->modes & MODES_SUSTAIN)) + { + /* No sustain? Then no envelope. I don't know if this is + justified, but patches without sustain usually don't need the + envelope either... at least the Gravis ones. They're mostly + drums. I think. */ + sp->modes &= ~MODES_ENVELOPE; + SNDDBG((" - No sustain, removing envelope\n")); + } + } + + for (j=0; j<6; j++) + { + sp->envelope_rate[j]= + convert_envelope_rate(song, tmp[j]); + sp->envelope_offset[j]= + convert_envelope_offset(tmp[6+j]); + } + + /* Then read the sample data */ + sp->data = (sample_t *) SDL_malloc(sp->data_length+4); + if (!sp->data) goto nomem; + + if (1 != SDL_RWread(rw, sp->data, sp->data_length, 1)) + goto badread; + + if (!(sp->modes & MODES_16BIT)) /* convert to 16-bit data */ + { + Sint32 k=sp->data_length; + Uint8 *cp=(Uint8 *)(sp->data); + Uint16 *tmp16,*new16; + sp->data_length *= 2; + sp->loop_start *= 2; + sp->loop_end *= 2; + tmp16 = new16 = (Uint16 *) SDL_malloc(sp->data_length+4); + if (!new16) goto nomem; + while (k--) + *tmp16++ = (Uint16)(*cp++) << 8; + SDL_free(sp->data); + sp->data = (sample_t *)new16; + } +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + else + /* convert to machine byte order */ + { + Sint32 k=sp->data_length/2; + Sint16 *tmp16=(Sint16 *)sp->data,s; + while (k--) + { + s=SDL_SwapLE16(*tmp16); + *tmp16++=s; + } + } +#endif + + if (sp->modes & MODES_UNSIGNED) /* convert to signed data */ + { + Sint32 k=sp->data_length/2; + Sint16 *tmp16=(Sint16 *)sp->data; + while (k--) + *tmp16++ ^= 0x8000; + } + + /* Reverse reverse loops and pass them off as normal loops */ + if (sp->modes & MODES_REVERSE) + { + Sint32 t; + /* The GUS apparently plays reverse loops by reversing the + whole sample. We do the same because the GUS does not SUCK. */ + + SNDDBG(("Reverse loop in %s\n", name)); + reverse_data((Sint16 *)sp->data, 0, sp->data_length/2); + + t=sp->loop_start; + sp->loop_start=sp->data_length - sp->loop_end; + sp->loop_end=sp->data_length - t; + + sp->modes &= ~MODES_REVERSE; + sp->modes |= MODES_LOOPING; /* just in case */ + } + +#ifdef ADJUST_SAMPLE_VOLUMES + if (amp!=-1) + sp->volume=(float)((amp) / 100.0); + else + { + /* Try to determine a volume scaling factor for the sample. + This is a very crude adjustment, but things sound more + balanced with it. Still, this should be a runtime option. */ + Sint32 k=sp->data_length/2; + Sint16 maxamp=0,a; + Sint16 *tmp16=(Sint16 *)sp->data; + while (k--) + { + a=*tmp16++; + if (a<0) a=-a; + if (a>maxamp) + maxamp=a; + } + sp->volume=(float)(32768.0 / maxamp); + SNDDBG((" * volume comp: %f\n", sp->volume)); + } +#else + if (amp!=-1) + sp->volume=(double)(amp) / 100.0; + else + sp->volume=1.0; +#endif + + sp->data_length /= 2; /* These are in bytes. Convert into samples. */ + sp->loop_start /= 2; + sp->loop_end /= 2; + + /* initialize the added extra sample space (see the +4 bytes) */ + sp->data[sp->data_length] = sp->data[sp->data_length+1] = 0; + + /* Then fractional samples */ + sp->data_length <<= FRACTION_BITS; + sp->loop_start <<= FRACTION_BITS; + sp->loop_end <<= FRACTION_BITS; + + /* Adjust for fractional loop points. This is a guess. Does anyone + know what "fractions" really stands for? */ + sp->loop_start |= + (fractions & 0x0F) << (FRACTION_BITS-4); + sp->loop_end |= + ((fractions>>4) & 0x0F) << (FRACTION_BITS-4); + + /* If this instrument will always be played on the same note, + and it's not looped, we can resample it now. */ + if (sp->note_to_use && !(sp->modes & MODES_LOOPING)) { + pre_resample(song, sp); + if (song->oom) goto fail; + } + + if (strip_tail==1) + { + /* Let's not really, just say we did. */ + SNDDBG((" - Stripping tail\n")); + sp->data_length = sp->loop_end; + } + } + + SDL_RWclose(rw); + return; + +nomem: + song->oom=1; + goto fail; +badread: + SNDDBG(("Error reading sample %d\n", i)); +fail: + free_instrument (ip); +badpat: + SDL_RWclose(rw); + *out = NULL; +} + +static int fill_bank(MidiSong *song, int dr, int b) +{ + int i, errors=0; + ToneBank *bank=((dr) ? song->drumset[b] : song->tonebank[b]); + if (!bank) + { + SNDDBG(("Huh. Tried to load instruments in non-existent %s %d\n", + (dr) ? "drumset" : "tone bank", b)); + return 0; + } + for (i=0; iinstrument[i]==MAGIC_LOAD_INSTRUMENT) + { + if (!(bank->tone[i].name)) + { + SNDDBG(("No instrument mapped to %s %d, program %d%s\n", + (dr)? "drum set" : "tone bank", b, i, + (b!=0) ? "" : " - this instrument will not be heard")); + if (b!=0) + { + /* Mark the corresponding instrument in the default + bank / drumset for loading (if it isn't already) */ + if (!dr) + { + if (!(song->tonebank[0]->instrument[i])) + song->tonebank[0]->instrument[i] = + MAGIC_LOAD_INSTRUMENT; + } + else + { + if (!(song->drumset[0]->instrument[i])) + song->drumset[0]->instrument[i] = + MAGIC_LOAD_INSTRUMENT; + } + } + bank->instrument[i] = NULL; + errors++; + } + else + { + load_instrument(song, + bank->tone[i].name, + &bank->instrument[i], + (dr) ? 1 : 0, + bank->tone[i].pan, + bank->tone[i].amp, + (bank->tone[i].note!=-1) ? + bank->tone[i].note : + ((dr) ? i : -1), + (bank->tone[i].strip_loop!=-1) ? + bank->tone[i].strip_loop : + ((dr) ? 1 : -1), + (bank->tone[i].strip_envelope != -1) ? + bank->tone[i].strip_envelope : + ((dr) ? 1 : -1), + bank->tone[i].strip_tail); + if (!bank->instrument[i]) { + SNDDBG(("Couldn't load instrument %s (%s %d, program %d)\n", + bank->tone[i].name, + (dr)? "drum set" : "tone bank", b, i)); + errors++; + } + } + } + } + return errors; +} + +int load_missing_instruments(MidiSong *song) +{ + int i=MAXBANK,errors=0; + while (i--) + { + if (song->tonebank[i]) + errors+=fill_bank(song,0,i); + if (song->drumset[i]) + errors+=fill_bank(song,1,i); + } + return errors; +} + +void free_instruments(MidiSong *song) +{ + int i=MAXBANK; + while(i--) + { + if (song->tonebank[i]) + free_bank(song, 0, i); + if (song->drumset[i]) + free_bank(song, 1, i); + } +} + +int set_default_instrument(MidiSong *song, const char *name) +{ + load_instrument(song, name, &song->default_instrument, 0, -1, -1, -1, 0, 0, 0); + if (!song->default_instrument) + return -1; + song->default_program = SPECIAL_PROGRAM; + return 0; +} diff --git a/src/codecs/timidity/instrum.h b/src/codecs/timidity/instrum.h new file mode 100644 index 0000000..0fa6505 --- /dev/null +++ b/src/codecs/timidity/instrum.h @@ -0,0 +1,37 @@ +/* + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. + + instrum.h +*/ + +#ifndef TIMIDITY_INSTRUM_H +#define TIMIDITY_INSTRUM_H + +/* Bits in modes: */ +#define MODES_16BIT (1<<0) +#define MODES_UNSIGNED (1<<1) +#define MODES_LOOPING (1<<2) +#define MODES_PINGPONG (1<<3) +#define MODES_REVERSE (1<<4) +#define MODES_SUSTAIN (1<<5) +#define MODES_ENVELOPE (1<<6) + +/* A hack to delay instrument loading until after reading the + entire MIDI file. */ +#define MAGIC_LOAD_INSTRUMENT ((Instrument *) (-1)) + +#define SPECIAL_PROGRAM -1 + +#define load_missing_instruments TIMI_NAMESPACE(load_missing_instruments) +#define free_instruments TIMI_NAMESPACE(free_instruments) +#define set_default_instrument TIMI_NAMESPACE(set_default_instrument) + +extern int load_missing_instruments(MidiSong *song); +extern void free_instruments(MidiSong *song); +extern int set_default_instrument(MidiSong *song, const char *name); + +#endif /* TIMIDITY_INSTRUM_H */ diff --git a/src/codecs/timidity/mix.c b/src/codecs/timidity/mix.c new file mode 100644 index 0000000..453e5f3 --- /dev/null +++ b/src/codecs/timidity/mix.c @@ -0,0 +1,549 @@ +/* + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. + + mix.c */ + +#include "SDL.h" + +#include "timidity.h" +#include "options.h" +#include "common.h" +#include "instrum.h" +#include "playmidi.h" +#include "output.h" +#include "tables.h" +#include "resample.h" +#include "mix.h" + +/* Returns 1 if envelope runs out */ +int recompute_envelope(MidiSong *song, int v) +{ + int stage; + + stage = song->voice[v].envelope_stage; + + if (stage>5) + { + /* Envelope ran out. */ + song->voice[v].status = VOICE_FREE; + return 1; + } + + if (song->voice[v].sample->modes & MODES_ENVELOPE) + { + if (song->voice[v].status==VOICE_ON || song->voice[v].status==VOICE_SUSTAINED) + { + if (stage>2) + { + /* Freeze envelope until note turns off. Trumpets want this. */ + song->voice[v].envelope_increment=0; + return 0; + } + } + } + song->voice[v].envelope_stage=stage+1; + + if (song->voice[v].envelope_volume==song->voice[v].sample->envelope_offset[stage] || + (stage > 2 && song->voice[v].envelope_volume < + song->voice[v].sample->envelope_offset[stage])) + return recompute_envelope(song, v); + song->voice[v].envelope_target = song->voice[v].sample->envelope_offset[stage]; + song->voice[v].envelope_increment = song->voice[v].sample->envelope_rate[stage]; + if (song->voice[v].envelope_target < song->voice[v].envelope_volume) + song->voice[v].envelope_increment = -song->voice[v].envelope_increment; + return 0; +} + +void apply_envelope_to_amp(MidiSong *song, int v) +{ + float lamp = song->voice[v].left_amp, ramp; + Sint32 la,ra; + if (song->voice[v].panned == PANNED_MYSTERY) + { + ramp = song->voice[v].right_amp; + if (song->voice[v].tremolo_phase_increment) + { + lamp *= song->voice[v].tremolo_volume; + ramp *= song->voice[v].tremolo_volume; + } + if (song->voice[v].sample->modes & MODES_ENVELOPE) + { + lamp *= (float)vol_table[song->voice[v].envelope_volume>>23]; + ramp *= (float)vol_table[song->voice[v].envelope_volume>>23]; + } + + la = (Sint32)TIM_FSCALE(lamp,AMP_BITS); + + if (la>MAX_AMP_VALUE) + la=MAX_AMP_VALUE; + + ra = (Sint32)TIM_FSCALE(ramp,AMP_BITS); + if (ra>MAX_AMP_VALUE) + ra=MAX_AMP_VALUE; + + song->voice[v].left_mix = la; + song->voice[v].right_mix = ra; + } + else + { + if (song->voice[v].tremolo_phase_increment) + lamp *= song->voice[v].tremolo_volume; + if (song->voice[v].sample->modes & MODES_ENVELOPE) + lamp *= (float)vol_table[song->voice[v].envelope_volume>>23]; + + la = (Sint32)TIM_FSCALE(lamp,AMP_BITS); + + if (la>MAX_AMP_VALUE) + la=MAX_AMP_VALUE; + + song->voice[v].left_mix = la; + } +} + +static int update_envelope(MidiSong *song, int v) +{ + song->voice[v].envelope_volume += song->voice[v].envelope_increment; + /* Why is there no ^^ operator?? */ + if (((song->voice[v].envelope_increment < 0) && + (song->voice[v].envelope_volume <= song->voice[v].envelope_target)) || + ((song->voice[v].envelope_increment > 0) && + (song->voice[v].envelope_volume >= song->voice[v].envelope_target))) + { + song->voice[v].envelope_volume = song->voice[v].envelope_target; + if (recompute_envelope(song, v)) + return 1; + } + return 0; +} + +static void update_tremolo(MidiSong *song, int v) +{ + Sint32 depth = song->voice[v].sample->tremolo_depth << 7; + + if (song->voice[v].tremolo_sweep) + { + /* Update sweep position */ + + song->voice[v].tremolo_sweep_position += song->voice[v].tremolo_sweep; + if (song->voice[v].tremolo_sweep_position >= (1 << SWEEP_SHIFT)) + song->voice[v].tremolo_sweep=0; /* Swept to max amplitude */ + else + { + /* Need to adjust depth */ + depth *= song->voice[v].tremolo_sweep_position; + depth >>= SWEEP_SHIFT; + } + } + + song->voice[v].tremolo_phase += song->voice[v].tremolo_phase_increment; + + /* if (song->voice[v].tremolo_phase >= (SINE_CYCLE_LENGTH<voice[v].tremolo_phase -= SINE_CYCLE_LENGTH<voice[v].tremolo_volume = (float) + (1.0 - TIM_FSCALENEG((timi_sine(song->voice[v].tremolo_phase >> RATE_SHIFT) + 1.0) + * depth * TREMOLO_AMPLITUDE_TUNING, + 17)); + + /* I'm not sure about the +1.0 there -- it makes tremoloed voices' + volumes on average the lower the higher the tremolo amplitude. */ +} + +/* Returns 1 if the note died */ +static int update_signal(MidiSong *song, int v) +{ + if (song->voice[v].envelope_increment && update_envelope(song, v)) + return 1; + + if (song->voice[v].tremolo_phase_increment) + update_tremolo(song, v); + + apply_envelope_to_amp(song, v); + return 0; +} + +#define MIXATION(a) *lp++ += (a)*s; + +static void mix_mystery_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v, + int count) +{ + Voice *vp = song->voice + v; + final_volume_t + left=vp->left_mix, + right=vp->right_mix; + int cc; + sample_t s; + + if (!(cc = vp->control_counter)) + { + cc = song->control_ratio; + if (update_signal(song, v)) + return; /* Envelope ran out */ + left = vp->left_mix; + right = vp->right_mix; + } + + while (count) + if (cc < count) + { + count -= cc; + while (cc--) + { + s = *sp++; + MIXATION(left); + MIXATION(right); + } + cc = song->control_ratio; + if (update_signal(song, v)) + return; /* Envelope ran out */ + left = vp->left_mix; + right = vp->right_mix; + } + else + { + vp->control_counter = cc - count; + while (count--) + { + s = *sp++; + MIXATION(left); + MIXATION(right); + } + return; + } +} + +static void mix_center_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v, + int count) +{ + Voice *vp = song->voice + v; + final_volume_t + left=vp->left_mix; + int cc; + sample_t s; + + if (!(cc = vp->control_counter)) + { + cc = song->control_ratio; + if (update_signal(song, v)) + return; /* Envelope ran out */ + left = vp->left_mix; + } + + while (count) + if (cc < count) + { + count -= cc; + while (cc--) + { + s = *sp++; + MIXATION(left); + MIXATION(left); + } + cc = song->control_ratio; + if (update_signal(song, v)) + return; /* Envelope ran out */ + left = vp->left_mix; + } + else + { + vp->control_counter = cc - count; + while (count--) + { + s = *sp++; + MIXATION(left); + MIXATION(left); + } + return; + } +} + +static void mix_single_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v, + int count) +{ + Voice *vp = song->voice + v; + final_volume_t + left=vp->left_mix; + int cc; + sample_t s; + + if (!(cc = vp->control_counter)) + { + cc = song->control_ratio; + if (update_signal(song, v)) + return; /* Envelope ran out */ + left = vp->left_mix; + } + + while (count) + if (cc < count) + { + count -= cc; + while (cc--) + { + s = *sp++; + MIXATION(left); + lp++; + } + cc = song->control_ratio; + if (update_signal(song, v)) + return; /* Envelope ran out */ + left = vp->left_mix; + } + else + { + vp->control_counter = cc - count; + while (count--) + { + s = *sp++; + MIXATION(left); + lp++; + } + return; + } +} + +static void mix_mono_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v, + int count) +{ + Voice *vp = song->voice + v; + final_volume_t + left=vp->left_mix; + int cc; + sample_t s; + + if (!(cc = vp->control_counter)) + { + cc = song->control_ratio; + if (update_signal(song, v)) + return; /* Envelope ran out */ + left = vp->left_mix; + } + + while (count) + if (cc < count) + { + count -= cc; + while (cc--) + { + s = *sp++; + MIXATION(left); + } + cc = song->control_ratio; + if (update_signal(song, v)) + return; /* Envelope ran out */ + left = vp->left_mix; + } + else + { + vp->control_counter = cc - count; + while (count--) + { + s = *sp++; + MIXATION(left); + } + return; + } +} + +static void mix_mystery(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count) +{ + final_volume_t + left = song->voice[v].left_mix, + right = song->voice[v].right_mix; + sample_t s; + + while (count--) + { + s = *sp++; + MIXATION(left); + MIXATION(right); + } +} + +static void mix_center(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count) +{ + final_volume_t + left = song->voice[v].left_mix; + sample_t s; + + while (count--) + { + s = *sp++; + MIXATION(left); + MIXATION(left); + } +} + +static void mix_single(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count) +{ + final_volume_t + left = song->voice[v].left_mix; + sample_t s; + + while (count--) + { + s = *sp++; + MIXATION(left); + lp++; + } +} + +static void mix_mono(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count) +{ + final_volume_t + left = song->voice[v].left_mix; + sample_t s; + + while (count--) + { + s = *sp++; + MIXATION(left); + } +} + +/* Ramp a note out in c samples */ +static void ramp_out(MidiSong *song, sample_t *sp, Sint32 *lp, int v, Sint32 c) +{ + /* should be final_volume_t, but Uint8 gives trouble. */ + Sint32 left, right, li, ri; + + sample_t s=0; /* silly warning about uninitialized s */ + + left=song->voice[v].left_mix; + li=-(left/c); + if (!li) li=-1; + + /* printf("Ramping out: left=%d, c=%d, li=%d\n", left, c, li); */ + + if (!(song->encoding & PE_MONO)) + { + if (song->voice[v].panned==PANNED_MYSTERY) + { + right=song->voice[v].right_mix; + ri=-(right/c); + while (c--) + { + left += li; + if (left<0) + left=0; + right += ri; + if (right<0) + right=0; + s=*sp++; + MIXATION(left); + MIXATION(right); + } + } + else if (song->voice[v].panned==PANNED_CENTER) + { + while (c--) + { + left += li; + if (left<0) + return; + s=*sp++; + MIXATION(left); + MIXATION(left); + } + } + else if (song->voice[v].panned==PANNED_LEFT) + { + while (c--) + { + left += li; + if (left<0) + return; + s=*sp++; + MIXATION(left); + lp++; + } + } + else if (song->voice[v].panned==PANNED_RIGHT) + { + while (c--) + { + left += li; + if (left<0) + return; + s=*sp++; + lp++; + MIXATION(left); + } + } + } + else + { + /* Mono output. */ + while (c--) + { + left += li; + if (left<0) + return; + s=*sp++; + MIXATION(left); + } + } +} + + +/**************** interface function ******************/ + +void mix_voice(MidiSong *song, Sint32 *buf, int v, Sint32 c) +{ + Voice *vp = song->voice + v; + sample_t *sp; + if (vp->status==VOICE_DIE) + { + if (c>=MAX_DIE_TIME) + c=MAX_DIE_TIME; + sp=resample_voice(song, v, &c); + if(c > 0) + ramp_out(song, sp, buf, v, c); + vp->status=VOICE_FREE; + } + else + { + sp=resample_voice(song, v, &c); + if (song->encoding & PE_MONO) + { + /* Mono output. */ + if (vp->envelope_increment || vp->tremolo_phase_increment) + mix_mono_signal(song, sp, buf, v, c); + else + mix_mono(song, sp, buf, v, c); + } + else + { + if (vp->panned == PANNED_MYSTERY) + { + if (vp->envelope_increment || vp->tremolo_phase_increment) + mix_mystery_signal(song, sp, buf, v, c); + else + mix_mystery(song, sp, buf, v, c); + } + else if (vp->panned == PANNED_CENTER) + { + if (vp->envelope_increment || vp->tremolo_phase_increment) + mix_center_signal(song, sp, buf, v, c); + else + mix_center(song, sp, buf, v, c); + } + else + { + /* It's either full left or full right. In either case, + every other sample is 0. Just get the offset right: */ + if (vp->panned == PANNED_RIGHT) buf++; + + if (vp->envelope_increment || vp->tremolo_phase_increment) + mix_single_signal(song, sp, buf, v, c); + else + mix_single(song, sp, buf, v, c); + } + } + } +} + diff --git a/src/codecs/timidity/mix.h b/src/codecs/timidity/mix.h new file mode 100644 index 0000000..fef2f27 --- /dev/null +++ b/src/codecs/timidity/mix.h @@ -0,0 +1,22 @@ +/* + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. + + mix.h +*/ + +#ifndef TIMIDITY_MIX_H +#define TIMIDITY_MIX_H + +#define mix_voice TIMI_NAMESPACE(mix_voice) +#define recompute_envelope TIMI_NAMESPACE(recompute_envelope) +#define apply_envelope_to_amp TIMI_NAMESPACE(apply_envelope_to_amp) + +extern void mix_voice(MidiSong *song, Sint32 *buf, int v, Sint32 c); +extern int recompute_envelope(MidiSong *song, int v); +extern void apply_envelope_to_amp(MidiSong *song, int v); + +#endif /* TIMIDITY_MIX_H */ diff --git a/src/codecs/timidity/options.h b/src/codecs/timidity/options.h new file mode 100644 index 0000000..025dfd9 --- /dev/null +++ b/src/codecs/timidity/options.h @@ -0,0 +1,107 @@ +/* + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. +*/ + +#ifndef TIMIDITY_OPTIONS_H +#define TIMIDITY_OPTIONS_H + +/* When a patch file can't be opened, one of these extensions is + appended to the filename and the open is tried again. + */ +#define PATCH_EXT_LIST { ".pat", 0 } + +/* Acoustic Grand Piano seems to be the usual default instrument. */ +#define DEFAULT_PROGRAM 0 + +/* 9 here is MIDI channel 10, which is the standard percussion channel. + Some files (notably C:\WINDOWS\CANYON.MID) think that 16 is one too. + On the other hand, some files know that 16 is not a drum channel and + try to play music on it. This is now a runtime option, so this isn't + a critical choice anymore. */ +#define DEFAULT_DRUMCHANNELS (1<<9) + +/* In percent. */ +#define DEFAULT_AMPLIFICATION 70 + +/* Default polyphony */ +/* #define DEFAULT_VOICES 32 */ +#define DEFAULT_VOICES 256 + +/* 1000 here will give a control ratio of 22:1 with 22 kHz output. + Higher CONTROLS_PER_SECOND values allow more accurate rendering + of envelopes and tremolo. The cost is CPU time. */ +#define CONTROLS_PER_SECOND 1000 + +/* Make envelopes twice as fast. Saves ~20% CPU time (notes decay + faster) and sounds more like a GUS. */ +#define FAST_DECAY + +/* A somewhat arbitrary output frequency range. */ +#define MIN_OUTPUT_RATE 4000 +#define MAX_OUTPUT_RATE 256000 + +/* How many bits to use for the fractional part of sample positions. + This affects tonal accuracy. The entire position counter must fit + in 32 bits, so with FRACTION_BITS equal to 12, the maximum size of + a sample is 1048576 samples (2 megabytes in memory). The GUS gets + by with just 9 bits and a little help from its friends... + "The GUS does not SUCK!!!" -- a happy user :) */ +#define FRACTION_BITS 12 + +/* For some reason the sample volume is always set to maximum in all + patch files. Define this for a crude adjustment that may help + equalize instrument volumes. */ +#define ADJUST_SAMPLE_VOLUMES + +/* The number of samples to use for ramping out a dying note. Affects + click removal. */ +#define MAX_DIE_TIME 20 + +/**************************************************************************/ +/* Anything below this shouldn't need to be changed unless you're porting + to a new machine with other than 32-bit, big-endian words. */ +/**************************************************************************/ + +/* change FRACTION_BITS above, not these */ +#define INTEGER_BITS (32 - FRACTION_BITS) +#define INTEGER_MASK (0xFFFFFFFF << FRACTION_BITS) +#define FRACTION_MASK (~ INTEGER_MASK) + +/* This is enforced by some computations that must fit in an int */ +#define MAX_CONTROL_RATIO 255 + +#define MAX_AMPLIFICATION 800 + +/* The TiMidity configuration file */ +#ifndef TIMIDITY_CFG +#define TIMIDITY_CFG "timidity.cfg" +#endif + +/* These affect general volume */ +#define GUARD_BITS 3 +#define AMP_BITS (15-GUARD_BITS) + +#define MAX_AMP_VALUE ((1<<(AMP_BITS+1))-1) + +#define TIM_FSCALE(a,b) (float)((a) * (double)(1<<(b))) +#define TIM_FSCALENEG(a,b) (float)((a) * (1.0L / (double)(1<<(b)))) + +/* Vibrato and tremolo Choices of the Day */ +#define SWEEP_TUNING 38 +#define VIBRATO_AMPLITUDE_TUNING 1.0L +#define VIBRATO_RATE_TUNING 38 +#define TREMOLO_AMPLITUDE_TUNING 1.0L +#define TREMOLO_RATE_TUNING 38 + +#define SWEEP_SHIFT 16 +#define RATE_SHIFT 5 + +#ifndef PI +#define PI 3.14159265358979323846 +#endif + +#endif /* TIMIDITY_OPTIONS_H */ diff --git a/src/codecs/timidity/output.c b/src/codecs/timidity/output.c new file mode 100644 index 0000000..47ea1d1 --- /dev/null +++ b/src/codecs/timidity/output.c @@ -0,0 +1,124 @@ +/* + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. + + output.c + + Audio output (to file / device) functions. +*/ + +#include "SDL.h" + +#include "options.h" +#include "output.h" + +/*****************************************************************/ +/* Some functions to convert signed 32-bit data to other formats */ + +void timi_s32tos8(void *dp, Sint32 *lp, Sint32 c) +{ + Sint8 *cp=(Sint8 *)(dp); + Sint32 l; + while (c--) + { + l=(*lp++)>>(32-8-GUARD_BITS); + if (l>127) l=127; + else if (l<-128) l=-128; + *cp++ = (Sint8) (l); + } +} + +void timi_s32tou8(void *dp, Sint32 *lp, Sint32 c) +{ + Uint8 *cp=(Uint8 *)(dp); + Sint32 l; + while (c--) + { + l=(*lp++)>>(32-8-GUARD_BITS); + if (l>127) l=127; + else if (l<-128) l=-128; + *cp++ = 0x80 ^ ((Uint8) l); + } +} + +void timi_s32tos16(void *dp, Sint32 *lp, Sint32 c) +{ + Sint16 *sp=(Sint16 *)(dp); + Sint32 l; + while (c--) + { + l=(*lp++)>>(32-16-GUARD_BITS); + if (l > 32767) l=32767; + else if (l<-32768) l=-32768; + *sp++ = (Sint16)(l); + } +} + +void timi_s32tou16(void *dp, Sint32 *lp, Sint32 c) +{ + Uint16 *sp=(Uint16 *)(dp); + Sint32 l; + while (c--) + { + l=(*lp++)>>(32-16-GUARD_BITS); + if (l > 32767) l=32767; + else if (l<-32768) l=-32768; + *sp++ = 0x8000 ^ (Uint16)(l); + } +} + +void timi_s32tos16x(void *dp, Sint32 *lp, Sint32 c) +{ + Sint16 *sp=(Sint16 *)(dp); + Sint32 l; + while (c--) + { + l=(*lp++)>>(32-16-GUARD_BITS); + if (l > 32767) l=32767; + else if (l<-32768) l=-32768; + *sp++ = SDL_Swap16((Sint16)(l)); + } +} + +void timi_s32tou16x(void *dp, Sint32 *lp, Sint32 c) +{ + Uint16 *sp=(Uint16 *)(dp); + Sint32 l; + while (c--) + { + l=(*lp++)>>(32-16-GUARD_BITS); + if (l > 32767) l=32767; + else if (l<-32768) l=-32768; + *sp++ = SDL_Swap16(0x8000 ^ (Uint16)(l)); + } +} + +void timi_s32tof32(void *dp, Sint32 *lp, Sint32 c) +{ + float *sp=(float *)(dp); + while (c--) + { + *sp++ = (float)(*lp++) / 2147483647.0f; + } +} + +void timi_s32tos32(void *dp, Sint32 *lp, Sint32 c) +{ + Sint32 *sp=(Sint32 *)(dp); + while (c--) + { + *sp++ = (*lp++); + } +} + +void timi_s32tos32x(void *dp, Sint32 *lp, Sint32 c) +{ + Sint32 *sp=(Sint32 *)(dp); + while (c--) + { + *sp++ = SDL_Swap32(*lp++); + } +} diff --git a/src/codecs/timidity/output.h b/src/codecs/timidity/output.h new file mode 100644 index 0000000..3a08f5b --- /dev/null +++ b/src/codecs/timidity/output.h @@ -0,0 +1,60 @@ +/* + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. + + output.h +*/ + +#ifndef TIMIDITY_OUTPUT_H +#define TIMIDITY_OUTPUT_H + +/* Data format encoding bits */ + +#define PE_MONO 0x01 /* versus stereo */ +#define PE_SIGNED 0x02 /* versus unsigned */ +#define PE_16BIT 0x04 /* versus 8-bit */ +#define PE_32BIT 0x08 /* versus 8-bit or 16-bit */ + +/* Conversion functions -- These overwrite the Sint32 data in *lp with + data in another format */ + +/* 8-bit signed and unsigned*/ +extern void timi_s32tos8(void *dp, Sint32 *lp, Sint32 c); +extern void timi_s32tou8(void *dp, Sint32 *lp, Sint32 c); + +/* 16-bit */ +extern void timi_s32tos16(void *dp, Sint32 *lp, Sint32 c); +extern void timi_s32tou16(void *dp, Sint32 *lp, Sint32 c); + +/* byte-exchanged 16-bit */ +extern void timi_s32tos16x(void *dp, Sint32 *lp, Sint32 c); +extern void timi_s32tou16x(void *dp, Sint32 *lp, Sint32 c); + +/* 32-bit */ +extern void timi_s32tof32(void *dp, Sint32 *lp, Sint32 c); +extern void timi_s32tos32(void *dp, Sint32 *lp, Sint32 c); + +/* byte-exchanged 32-bit */ +extern void timi_s32tos32x(void *dp, Sint32 *lp, Sint32 c); + +/* little-endian and big-endian specific */ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define timi_s32tou16l timi_s32tou16 +#define timi_s32tou16b timi_s32tou16x +#define timi_s32tos16l timi_s32tos16 +#define timi_s32tos16b timi_s32tos16x +#define timi_s32tos32l timi_s32tos32 +#define timi_s32tos32b timi_s32tos32x +#else +#define timi_s32tou16l timi_s32tou16x +#define timi_s32tou16b timi_s32tou16 +#define timi_s32tos16l timi_s32tos16x +#define timi_s32tos16b timi_s32tos16 +#define timi_s32tos32l timi_s32tos32x +#define timi_s32tos32b timi_s32tos32 +#endif + +#endif /* TIMIDITY_OUTPUT_H */ diff --git a/src/codecs/timidity/playmidi.c b/src/codecs/timidity/playmidi.c new file mode 100644 index 0000000..87ed253 --- /dev/null +++ b/src/codecs/timidity/playmidi.c @@ -0,0 +1,802 @@ +/* + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. + + playmidi.c -- random stuff in need of rearrangement +*/ + +#include "SDL.h" + +#include "timidity.h" +#include "options.h" +#include "common.h" +#include "instrum.h" +#include "playmidi.h" +#include "output.h" +#include "mix.h" +#include "tables.h" + +static void adjust_amplification(MidiSong *song) +{ + song->master_volume = (float)(song->amplification) / 100.0f; +} + +static void reset_voices(MidiSong *song) +{ + int i; + for (i=0; ivoice[i].status=VOICE_FREE; +} + +/* Process the Reset All Controllers event */ +static void reset_controllers(MidiSong *song, int c) +{ + song->channel[c].volume=90; /* Some standard says, although the SCC docs say 0. */ + song->channel[c].expression=127; /* SCC-1 does this. */ + song->channel[c].sustain=0; + song->channel[c].pitchbend=0x2000; + song->channel[c].pitchfactor=0; /* to be computed */ +} + +static void reset_midi(MidiSong *song) +{ + int i; + for (i=0; ichannel[i].program=song->default_program; + song->channel[i].panning=NO_PANNING; + song->channel[i].pitchsens=2; + song->channel[i].bank=0; /* tone bank or drum set */ + } + reset_voices(song); +} + +static void select_sample(MidiSong *song, int v, Instrument *ip) +{ + Sint32 f, cdiff, diff; + int s,i; + Sample *sp, *closest; + + s=ip->samples; + sp=ip->sample; + + if (s==1) + { + song->voice[v].sample=sp; + return; + } + + f=song->voice[v].orig_frequency; + for (i=0; ilow_freq <= f && sp->high_freq >= f) + { + song->voice[v].sample=sp; + return; + } + } + + /* + No suitable sample found! We'll select the sample whose root + frequency is closest to the one we want. (Actually we should + probably convert the low, high, and root frequencies to MIDI + note values and compare those.) + */ + cdiff=0x7FFFFFFF; + closest=sp=ip->sample; + for(i=0; iroot_freq - f; + if (diff<0) diff=-diff; + if (diffvoice[v].sample=closest; +} + +static void recompute_freq(MidiSong *song, int v) +{ + int + sign=(song->voice[v].sample_increment < 0), /* for bidirectional loops */ + pb=song->channel[song->voice[v].channel].pitchbend; + double a; + + if (!song->voice[v].sample->sample_rate) + return; + + if (song->voice[v].vibrato_control_ratio) + { + /* This instrument has vibrato. Invalidate any precomputed + sample_increments. */ + + int i=VIBRATO_SAMPLE_INCREMENTS; + while (i--) + song->voice[v].vibrato_sample_increment[i]=0; + } + + if (pb==0x2000 || pb<0 || pb>0x3FFF) + song->voice[v].frequency = song->voice[v].orig_frequency; + else + { + pb-=0x2000; + if (!(song->channel[song->voice[v].channel].pitchfactor)) + { + /* Damn. Somebody bent the pitch. */ + Sint32 i=pb*song->channel[song->voice[v].channel].pitchsens; + if (pb<0) + i=-i; + song->channel[song->voice[v].channel].pitchfactor= + (float)(bend_fine[(i>>5) & 0xFF] * bend_coarse[i>>13]); + } + if (pb>0) + song->voice[v].frequency= + (Sint32)(song->channel[song->voice[v].channel].pitchfactor * + (double)(song->voice[v].orig_frequency)); + else + song->voice[v].frequency= + (Sint32)((double)(song->voice[v].orig_frequency) / + song->channel[song->voice[v].channel].pitchfactor); + } + + a = TIM_FSCALE(((double)(song->voice[v].sample->sample_rate) * + (double)(song->voice[v].frequency)) / + ((double)(song->voice[v].sample->root_freq) * + (double)(song->rate)), + FRACTION_BITS); + + if (sign) + a = -a; /* need to preserve the loop direction */ + + song->voice[v].sample_increment = (Sint32)(a); +} + +static void recompute_amp(MidiSong *song, int v) +{ + Sint32 tempamp; + + /* TODO: use fscale */ + + tempamp= (song->voice[v].velocity * + song->channel[song->voice[v].channel].volume * + song->channel[song->voice[v].channel].expression); /* 21 bits */ + + if (!(song->encoding & PE_MONO)) + { + if (song->voice[v].panning > 60 && song->voice[v].panning < 68) + { + song->voice[v].panned=PANNED_CENTER; + + song->voice[v].left_amp= + TIM_FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume, + 21); + } + else if (song->voice[v].panning<5) + { + song->voice[v].panned = PANNED_LEFT; + + song->voice[v].left_amp= + TIM_FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume, + 20); + } + else if (song->voice[v].panning>123) + { + song->voice[v].panned = PANNED_RIGHT; + + song->voice[v].left_amp= /* left_amp will be used */ + TIM_FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume, + 20); + } + else + { + song->voice[v].panned = PANNED_MYSTERY; + + song->voice[v].left_amp= + TIM_FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume, + 27); + song->voice[v].right_amp = song->voice[v].left_amp * (song->voice[v].panning); + song->voice[v].left_amp *= (float)(127 - song->voice[v].panning); + } + } + else + { + song->voice[v].panned = PANNED_CENTER; + + song->voice[v].left_amp= + TIM_FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume, + 21); + } +} + +static void start_note(MidiSong *song, MidiEvent *e, int i) +{ + Instrument *ip; + int j; + + if (ISDRUMCHANNEL(song, e->channel)) + { + if (!(ip=song->drumset[song->channel[e->channel].bank]->instrument[e->a])) + { + if (!(ip=song->drumset[0]->instrument[e->a])) + return; /* No instrument? Then we can't play. */ + } + if (ip->samples != 1) + { + SNDDBG(("Strange: percussion instrument with %d samples!", + ip->samples)); + } + + if (ip->sample->note_to_use) /* Do we have a fixed pitch? */ + song->voice[i].orig_frequency = freq_table[(int)(ip->sample->note_to_use)]; + else + song->voice[i].orig_frequency = freq_table[e->a & 0x7F]; + + /* drums are supposed to have only one sample */ + song->voice[i].sample = ip->sample; + } + else + { + if (song->channel[e->channel].program == SPECIAL_PROGRAM) + ip=song->default_instrument; + else if (!(ip=song->tonebank[song->channel[e->channel].bank]-> + instrument[song->channel[e->channel].program])) + { + if (!(ip=song->tonebank[0]->instrument[song->channel[e->channel].program])) + return; /* No instrument? Then we can't play. */ + } + + if (ip->sample->note_to_use) /* Fixed-pitch instrument? */ + song->voice[i].orig_frequency = freq_table[(int)(ip->sample->note_to_use)]; + else + song->voice[i].orig_frequency = freq_table[e->a & 0x7F]; + select_sample(song, i, ip); + } + + song->voice[i].status = VOICE_ON; + song->voice[i].channel = e->channel; + song->voice[i].note = e->a; + song->voice[i].velocity = e->b; + song->voice[i].sample_offset = 0; + song->voice[i].sample_increment = 0; /* make sure it isn't negative */ + + song->voice[i].tremolo_phase = 0; + song->voice[i].tremolo_phase_increment = song->voice[i].sample->tremolo_phase_increment; + song->voice[i].tremolo_sweep = song->voice[i].sample->tremolo_sweep_increment; + song->voice[i].tremolo_sweep_position = 0; + + song->voice[i].vibrato_sweep = song->voice[i].sample->vibrato_sweep_increment; + song->voice[i].vibrato_sweep_position = 0; + song->voice[i].vibrato_control_ratio = song->voice[i].sample->vibrato_control_ratio; + song->voice[i].vibrato_control_counter = song->voice[i].vibrato_phase = 0; + for (j=0; jvoice[i].vibrato_sample_increment[j] = 0; + + if (song->channel[e->channel].panning != NO_PANNING) + song->voice[i].panning = song->channel[e->channel].panning; + else + song->voice[i].panning = song->voice[i].sample->panning; + + recompute_freq(song, i); + recompute_amp(song, i); + if (song->voice[i].sample->modes & MODES_ENVELOPE) + { + /* Ramp up from 0 */ + song->voice[i].envelope_stage = 0; + song->voice[i].envelope_volume = 0; + song->voice[i].control_counter = 0; + recompute_envelope(song, i); + apply_envelope_to_amp(song, i); + } + else + { + song->voice[i].envelope_increment = 0; + apply_envelope_to_amp(song, i); + } +} + +static void kill_note(MidiSong *song, int i) +{ + song->voice[i].status = VOICE_DIE; +} + +/* Only one instance of a note can be playing on a single channel. */ +static void note_on(MidiSong *song) +{ + int i = song->voices, lowest=-1; + Sint32 lv=0x7FFFFFFF, v; + MidiEvent *e = song->current_event; + + while (i--) + { + if (song->voice[i].status == VOICE_FREE) + lowest=i; /* Can't get a lower volume than silence */ + else if (song->voice[i].channel==e->channel && + (song->voice[i].note==e->a || song->channel[song->voice[i].channel].mono)) + kill_note(song, i); + } + + if (lowest != -1) + { + /* Found a free voice. */ + start_note(song,e,lowest); + return; + } + + /* Look for the decaying note with the lowest volume */ + i = song->voices; + while (i--) + { + if ((song->voice[i].status != VOICE_ON) && + (song->voice[i].status != VOICE_DIE)) + { + v = song->voice[i].left_mix; + if ((song->voice[i].panned == PANNED_MYSTERY) + && (song->voice[i].right_mix > v)) + v = song->voice[i].right_mix; + if (vcut_notes++; + song->voice[lowest].status=VOICE_FREE; + start_note(song,e,lowest); + } + else + song->lost_notes++; +} + +static void finish_note(MidiSong *song, int i) +{ + if (song->voice[i].sample->modes & MODES_ENVELOPE) + { + /* We need to get the envelope out of Sustain stage */ + song->voice[i].envelope_stage = 3; + song->voice[i].status = VOICE_OFF; + recompute_envelope(song, i); + apply_envelope_to_amp(song, i); + } + else + { + /* Set status to OFF so resample_voice() will let this voice out + of its loop, if any. In any case, this voice dies when it + hits the end of its data (ofs>=data_length). */ + song->voice[i].status = VOICE_OFF; + } +} + +static void note_off(MidiSong *song) +{ + int i = song->voices; + MidiEvent *e = song->current_event; + + while (i--) + if (song->voice[i].status == VOICE_ON && + song->voice[i].channel == e->channel && + song->voice[i].note == e->a) + { + if (song->channel[e->channel].sustain) + { + song->voice[i].status = VOICE_SUSTAINED; + } + else + finish_note(song, i); + return; + } +} + +/* Process the All Notes Off event */ +static void all_notes_off(MidiSong *song) +{ + int i = song->voices; + int c = song->current_event->channel; + + SNDDBG(("All notes off on channel %d", c)); + while (i--) + if (song->voice[i].status == VOICE_ON && + song->voice[i].channel == c) + { + if (song->channel[c].sustain) + song->voice[i].status = VOICE_SUSTAINED; + else + finish_note(song, i); + } +} + +/* Process the All Sounds Off event */ +static void all_sounds_off(MidiSong *song) +{ + int i = song->voices; + int c = song->current_event->channel; + + while (i--) + if (song->voice[i].channel == c && + song->voice[i].status != VOICE_FREE && + song->voice[i].status != VOICE_DIE) + { + kill_note(song, i); + } +} + +static void adjust_pressure(MidiSong *song) +{ + MidiEvent *e = song->current_event; + int i = song->voices; + + while (i--) + if (song->voice[i].status == VOICE_ON && + song->voice[i].channel == e->channel && + song->voice[i].note == e->a) + { + song->voice[i].velocity = e->b; + recompute_amp(song, i); + apply_envelope_to_amp(song, i); + return; + } +} + +static void drop_sustain(MidiSong *song) +{ + int i = song->voices; + int c = song->current_event->channel; + + while (i--) + if (song->voice[i].status == VOICE_SUSTAINED && song->voice[i].channel == c) + finish_note(song, i); +} + +static void adjust_pitchbend(MidiSong *song) +{ + int c = song->current_event->channel; + int i = song->voices; + + while (i--) + if (song->voice[i].status != VOICE_FREE && song->voice[i].channel == c) + { + recompute_freq(song, i); + } +} + +static void adjust_volume(MidiSong *song) +{ + int c = song->current_event->channel; + int i = song->voices; + + while (i--) + if (song->voice[i].channel == c && + (song->voice[i].status==VOICE_ON || song->voice[i].status==VOICE_SUSTAINED)) + { + recompute_amp(song, i); + apply_envelope_to_amp(song, i); + } +} + +static void seek_forward(MidiSong *song, Sint32 until_time) +{ + reset_voices(song); + while (song->current_event->time < until_time) + { + switch(song->current_event->type) + { + /* All notes stay off. Just handle the parameter changes. */ + + case ME_PITCH_SENS: + song->channel[song->current_event->channel].pitchsens = + song->current_event->a; + song->channel[song->current_event->channel].pitchfactor = 0; + break; + + case ME_PITCHWHEEL: + song->channel[song->current_event->channel].pitchbend = + song->current_event->a + song->current_event->b * 128; + song->channel[song->current_event->channel].pitchfactor = 0; + break; + + case ME_MAINVOLUME: + song->channel[song->current_event->channel].volume = + song->current_event->a; + break; + + case ME_PAN: + song->channel[song->current_event->channel].panning = + song->current_event->a; + break; + + case ME_EXPRESSION: + song->channel[song->current_event->channel].expression = + song->current_event->a; + break; + + case ME_PROGRAM: + if (ISDRUMCHANNEL(song, song->current_event->channel)) + /* Change drum set */ + song->channel[song->current_event->channel].bank = + song->current_event->a; + else + song->channel[song->current_event->channel].program = + song->current_event->a; + break; + + case ME_SUSTAIN: + song->channel[song->current_event->channel].sustain = + song->current_event->a; + break; + + case ME_RESET_CONTROLLERS: + reset_controllers(song, song->current_event->channel); + break; + + case ME_TONE_BANK: + song->channel[song->current_event->channel].bank = + song->current_event->a; + break; + + case ME_EOT: + song->current_sample = song->current_event->time; + return; + } + song->current_event++; + } + /*song->current_sample=song->current_event->time;*/ + if (song->current_event != song->events) + song->current_event--; + song->current_sample=until_time; +} + +static void skip_to(MidiSong *song, Sint32 until_time) +{ + if (song->current_sample > until_time) + song->current_sample = 0; + + reset_midi(song); + song->buffered_count = 0; + song->buffer_pointer = song->common_buffer; + song->current_event = song->events; + + if (until_time) + seek_forward(song, until_time); +} + +static void do_compute_data(MidiSong *song, Sint32 count) +{ + int i; + SDL_memset(song->buffer_pointer, 0, + (song->encoding & PE_MONO) ? (count * 4) : (count * 8)); + for (i = 0; i < song->voices; i++) + { + if(song->voice[i].status != VOICE_FREE) + mix_voice(song, song->buffer_pointer, i, count); + } + song->current_sample += count; +} + +/* count=0 means flush remaining buffered data to output device, then + flush the device itself */ +static void compute_data(MidiSong *song, void *stream, Sint32 count) +{ + int channels; + + if ( song->encoding & PE_MONO ) + channels = 1; + else + channels = 2; + + if (!count) + { + if (song->buffered_count) + song->write(stream, song->common_buffer, channels * song->buffered_count); + song->buffer_pointer = song->common_buffer; + song->buffered_count = 0; + return; + } + + while ((count + song->buffered_count) >= song->buffer_size) + { + do_compute_data(song, song->buffer_size - song->buffered_count); + count -= song->buffer_size - song->buffered_count; + song->write(stream, song->common_buffer, channels * song->buffer_size); + song->buffer_pointer = song->common_buffer; + song->buffered_count = 0; + } + if (count>0) + { + do_compute_data(song, count); + song->buffered_count += count; + song->buffer_pointer += (song->encoding & PE_MONO) ? count : count*2; + } +} + +void Timidity_Start(MidiSong *song) +{ + song->playing = 1; + adjust_amplification(song); + skip_to(song, 0); +} + +void Timidity_Stop(MidiSong *song) +{ + song->playing = 0; +} + +int Timidity_IsActive(MidiSong *song) +{ + return song->playing; +} + +void Timidity_Seek(MidiSong *song, Uint32 ms) +{ + skip_to(song, (ms * (song->rate / 100)) / 10); +} + +Uint32 Timidity_GetSongLength(MidiSong *song) +{ + MidiEvent *last_event = &song->events[song->groomed_event_count - 1]; + /* We want last_event->time * 1000 / song->rate */ + Uint32 retvalue = (last_event->time / song->rate) * 1000; + retvalue += (last_event->time % song->rate) * 1000 / song->rate; + return retvalue; +} + +Uint32 Timidity_GetSongTime(MidiSong *song) +{ + Uint32 retvalue = (song->current_sample / song->rate) * 1000; + retvalue += (song->current_sample % song->rate) * 1000 / song->rate; + return retvalue; +} + +int Timidity_PlaySome(MidiSong *song, void *stream, Sint32 len) +{ + Sint32 start_sample, end_sample, samples; + int bytes_per_sample; + + if (!song->playing) + return 0; + + bytes_per_sample = 1; + bytes_per_sample *= ((song->encoding & PE_32BIT) ? 4 : ((song->encoding & PE_16BIT) ? 2 : 1)); + bytes_per_sample *= ((song->encoding & PE_MONO) ? 1 : 2); + samples = len / bytes_per_sample; + + start_sample = song->current_sample; + end_sample = song->current_sample+samples; + while ( song->current_sample < end_sample ) { + /* Handle all events that should happen at this time */ + while (song->current_event->time <= song->current_sample) { + switch(song->current_event->type) { + /* Effects affecting a single note */ + case ME_NOTEON: + if (!(song->current_event->b)) /* Velocity 0? */ + note_off(song); + else + note_on(song); + break; + + case ME_NOTEOFF: + note_off(song); + break; + + case ME_KEYPRESSURE: + adjust_pressure(song); + break; + + /* Effects affecting a single channel */ + case ME_PITCH_SENS: + song->channel[song->current_event->channel].pitchsens = + song->current_event->a; + song->channel[song->current_event->channel].pitchfactor = 0; + break; + + case ME_PITCHWHEEL: + song->channel[song->current_event->channel].pitchbend = + song->current_event->a + song->current_event->b * 128; + song->channel[song->current_event->channel].pitchfactor = 0; + /* Adjust pitch for notes already playing */ + adjust_pitchbend(song); + break; + + case ME_MAINVOLUME: + song->channel[song->current_event->channel].volume = + song->current_event->a; + adjust_volume(song); + break; + + case ME_PAN: + song->channel[song->current_event->channel].panning = + song->current_event->a; + break; + + case ME_EXPRESSION: + song->channel[song->current_event->channel].expression = + song->current_event->a; + adjust_volume(song); + break; + + case ME_PROGRAM: + if (ISDRUMCHANNEL(song, song->current_event->channel)) { + /* Change drum set */ + song->channel[song->current_event->channel].bank = + song->current_event->a; + } + else + song->channel[song->current_event->channel].program = + song->current_event->a; + break; + + case ME_SUSTAIN: + song->channel[song->current_event->channel].sustain = + song->current_event->a; + if (!song->current_event->a) + drop_sustain(song); + break; + + case ME_RESET_CONTROLLERS: + reset_controllers(song, song->current_event->channel); + break; + + case ME_ALL_NOTES_OFF: + all_notes_off(song); + break; + + case ME_ALL_SOUNDS_OFF: + all_sounds_off(song); + break; + + case ME_TONE_BANK: + song->channel[song->current_event->channel].bank = + song->current_event->a; + break; + + case ME_EOT: + /* Give the last notes a couple of seconds to decay */ + SNDDBG(("Playing time: ~%d seconds\n", + song->current_sample/song->rate+2)); + SNDDBG(("Notes cut: %d\n", song->cut_notes)); + SNDDBG(("Notes lost totally: %d\n", song->lost_notes)); + song->playing = 0; + return (song->current_sample - start_sample) * bytes_per_sample; + } + song->current_event++; + } + if (song->current_event->time > end_sample) + compute_data(song, stream, end_sample-song->current_sample); + else + compute_data(song, stream, song->current_event->time-song->current_sample); + } + return samples * bytes_per_sample; +} + +void Timidity_SetVolume(MidiSong *song, int volume) +{ + int i; + if (volume > MAX_AMPLIFICATION) + song->amplification = MAX_AMPLIFICATION; + else + if (volume < 0) + song->amplification = 0; + else + song->amplification = volume; + adjust_amplification(song); + for (i = 0; i < song->voices; i++) + if (song->voice[i].status != VOICE_FREE) + { + recompute_amp(song, i); + apply_envelope_to_amp(song, i); + } +} diff --git a/src/codecs/timidity/playmidi.h b/src/codecs/timidity/playmidi.h new file mode 100644 index 0000000..8f8a489 --- /dev/null +++ b/src/codecs/timidity/playmidi.h @@ -0,0 +1,56 @@ +/* + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. + + playmidi.h +*/ + +#ifndef TIMIDITY_PLAYMIDI_H +#define TIMIDITY_PLAYMIDI_H + +/* Midi events */ +#define ME_NONE 0 +#define ME_NOTEON 1 +#define ME_NOTEOFF 2 +#define ME_KEYPRESSURE 3 +#define ME_MAINVOLUME 4 +#define ME_PAN 5 +#define ME_SUSTAIN 6 +#define ME_EXPRESSION 7 +#define ME_PITCHWHEEL 8 +#define ME_PROGRAM 9 +#define ME_TEMPO 10 +#define ME_PITCH_SENS 11 + +#define ME_ALL_SOUNDS_OFF 12 +#define ME_RESET_CONTROLLERS 13 +#define ME_ALL_NOTES_OFF 14 +#define ME_TONE_BANK 15 + +#define ME_LYRIC 16 + +#define ME_EOT 99 + +/* Causes the instrument's default panning to be used. */ +#define NO_PANNING -1 + +/* Voice status options: */ +#define VOICE_FREE 0 +#define VOICE_ON 1 +#define VOICE_SUSTAINED 2 +#define VOICE_OFF 3 +#define VOICE_DIE 4 + +/* Voice panned options: */ +#define PANNED_MYSTERY 0 +#define PANNED_LEFT 1 +#define PANNED_RIGHT 2 +#define PANNED_CENTER 3 +/* Anything but PANNED_MYSTERY only uses the left volume */ + +#define ISDRUMCHANNEL(s, c) (((s)->drumchannels & (1<<(c)))) + +#endif /* TIMIDITY_PLAYMIDI_H */ diff --git a/src/codecs/timidity/readmidi.c b/src/codecs/timidity/readmidi.c new file mode 100644 index 0000000..00ab3fa --- /dev/null +++ b/src/codecs/timidity/readmidi.c @@ -0,0 +1,633 @@ +/* + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. +*/ + +#include "SDL.h" + +#include "options.h" +#include "timidity.h" +#include "common.h" +#include "instrum.h" +#include "playmidi.h" +#include "readmidi.h" + +/* Computes how many (fractional) samples one MIDI delta-time unit contains */ +static void compute_sample_increment(MidiSong *song, Sint32 tempo, + Sint32 divisions) +{ + double a; + a = (double) (tempo) * (double) (song->rate) * (65536.0/1000000.0) / + (double)(divisions); + + song->sample_correction = (Sint32)(a) & 0xFFFF; + song->sample_increment = (Sint32)(a) >> 16; + + SNDDBG(("Samples per delta-t: %d (correction %d)", + song->sample_increment, song->sample_correction)); +} + +/* Read variable-length number (7 bits per byte, MSB first) */ +static Sint32 getvl(SDL_RWops *rw) +{ + Sint32 l=0; + Uint8 c; + for (;;) + { + if (!SDL_RWread(rw, &c, 1, 1)) return l; + l += (c & 0x7f); + if (!(c & 0x80)) return l; + l<<=7; + } +} + +#if (defined DEBUG_CHATTER) +/* Print a string from the file, followed by a newline. Any non-ASCII + or unprintable characters will be converted to periods. */ +static int dumpstring(SDL_RWops *rw, Sint32 len, Uint8 type) +{ + static const char *label[] = { + "Text event: ", "Text: ", "Copyright: ", "Track name: ", + "Instrument: ", "Lyric: ", "Marker: ", "Cue point: " }; + signed char *s = SDL_malloc(len+1); + if (!s) + { + SDL_RWseek(rw, len, RW_SEEK_CUR);/* should I ? */ + return -1; + } + if (len != (Sint32) SDL_RWread(rw, s, 1, len)) + { + SDL_free(s); + return -1; + } + + s[len]='\0'; + while (len--) + { + if (s[len]<32) + s[len]='.'; + } + SNDDBG(("%s%s", label[(type>7) ? 0 : type], s)); + SDL_free(s); + return 0; +} +#endif + +#define MIDIEVENT(at,t,ch,pa,pb) \ + newlist = (MidiEventList *) SDL_malloc(sizeof(MidiEventList));\ + if (!newlist) {song->oom = 1; return NULL;} \ + newlist->event.time = at; \ + newlist->event.type = t; \ + newlist->event.channel = ch; \ + newlist->event.a = pa; \ + newlist->event.b = pb; \ + newlist->next = NULL; \ + return newlist; + +#define MAGIC_EOT ((MidiEventList *)(-1)) + +/* Read a MIDI event, returning a freshly allocated element that can + be linked to the event list */ +static MidiEventList *read_midi_event(MidiSong *song) +{ + static Uint8 laststatus, lastchan; + static Uint8 nrpn=0, rpn_msb[16], rpn_lsb[16]; /* one per channel */ + Uint8 me, type, a,b,c; + Sint32 len; + MidiEventList *newlist; + + for (;;) + { + song->at += getvl(song->rw); + if (SDL_RWread(song->rw, &me, 1, 1) != 1) + { + SNDDBG(("read_midi_event: SDL_RWread() failure\n")); + return NULL; + } + + if(me==0xF0 || me == 0xF7) /* SysEx event */ + { + len=getvl(song->rw); + SDL_RWseek(song->rw, len, RW_SEEK_CUR); + } + else if(me==0xFF) /* Meta event */ + { + SDL_RWread(song->rw, &type, 1, 1); + len=getvl(song->rw); + if (type>0 && type<16) + { + #if (defined DEBUG_CHATTER) + dumpstring(song->rw, len, type); + #else + SDL_RWseek(song->rw, len, RW_SEEK_CUR); + #endif + } + else + switch(type) + { + case 0x2F: /* End of Track */ + return MAGIC_EOT; + + case 0x51: /* Tempo */ + SDL_RWread(song->rw, &a, 1, 1); + SDL_RWread(song->rw, &b, 1, 1); + SDL_RWread(song->rw, &c, 1, 1); + MIDIEVENT(song->at, ME_TEMPO, c, a, b); + + default: + SNDDBG(("(Meta event type 0x%02x, length %d)\n", type, len)); + SDL_RWseek(song->rw, len, RW_SEEK_CUR); + break; + } + } + else + { + a=me; + if (a & 0x80) /* status byte */ + { + lastchan=a & 0x0F; + laststatus=(a>>4) & 0x07; + SDL_RWread(song->rw, &a, 1, 1); + a &= 0x7F; + } + switch(laststatus) + { + case 0: /* Note off */ + SDL_RWread(song->rw, &b, 1, 1); + b &= 0x7F; + MIDIEVENT(song->at, ME_NOTEOFF, lastchan, a,b); + + case 1: /* Note on */ + SDL_RWread(song->rw, &b, 1, 1); + b &= 0x7F; + MIDIEVENT(song->at, ME_NOTEON, lastchan, a,b); + + case 2: /* Key Pressure */ + SDL_RWread(song->rw, &b, 1, 1); + b &= 0x7F; + MIDIEVENT(song->at, ME_KEYPRESSURE, lastchan, a, b); + + case 3: /* Control change */ + SDL_RWread(song->rw, &b, 1, 1); + b &= 0x7F; + { + int control=255; + switch(a) + { + case 7: control=ME_MAINVOLUME; break; + case 10: control=ME_PAN; break; + case 11: control=ME_EXPRESSION; break; + case 64: control=ME_SUSTAIN; b = (b >= 64); break; + case 120: control=ME_ALL_SOUNDS_OFF; break; + case 121: control=ME_RESET_CONTROLLERS; break; + case 123: control=ME_ALL_NOTES_OFF; break; + + /* These should be the SCC-1 tone bank switch + commands. I don't know why there are two, or + why the latter only allows switching to bank 0. + Also, some MIDI files use 0 as some sort of + continuous controller. This will cause lots of + warnings about undefined tone banks. */ + case 0: control=ME_TONE_BANK; break; + case 32: + if (b!=0) { + SNDDBG(("(Strange: tone bank change 0x%02x)\n", b)); + } +#if 0 /* `Bank Select LSB' is not worked at GS. Please ignore it. */ + else + control=ME_TONE_BANK; +#endif + break; + + case 100: nrpn=0; rpn_msb[lastchan]=b; break; + case 101: nrpn=0; rpn_lsb[lastchan]=b; break; + case 99: nrpn=1; rpn_msb[lastchan]=b; break; + case 98: nrpn=1; rpn_lsb[lastchan]=b; break; + + case 6: + if (nrpn) + { + SNDDBG(("(Data entry (MSB) for NRPN %02x,%02x: %d)\n", + rpn_msb[lastchan], rpn_lsb[lastchan], b)); + break; + } + + switch((rpn_msb[lastchan]<<8) | rpn_lsb[lastchan]) + { + case 0x0000: /* Pitch bend sensitivity */ + control=ME_PITCH_SENS; + break; + + case 0x7F7F: /* RPN reset */ + /* reset pitch bend sensitivity to 2 */ + MIDIEVENT(song->at, ME_PITCH_SENS, lastchan, 2, 0); + + default: + SNDDBG(("(Data entry (MSB) for RPN %02x,%02x: %d)\n", + rpn_msb[lastchan], rpn_lsb[lastchan], b)); + break; + } + break; + + default: + SNDDBG(("(Control %d: %d)\n", a, b)); + break; + } + if (control != 255) + { + MIDIEVENT(song->at, control, lastchan, b, 0); + } + } + break; + + case 4: /* Program change */ + a &= 0x7f; + MIDIEVENT(song->at, ME_PROGRAM, lastchan, a, 0); + + case 5: /* Channel pressure - NOT IMPLEMENTED */ + break; + + case 6: /* Pitch wheel */ + SDL_RWread(song->rw, &b, 1, 1); + b &= 0x7F; + MIDIEVENT(song->at, ME_PITCHWHEEL, lastchan, a, b); + + default: + SNDDBG(("*** Can't happen: status 0x%02X, channel 0x%02X\n", + laststatus, lastchan)); + break; + } + } + } + + return newlist; +} + +#undef MIDIEVENT + +/* Read a midi track into the linked list, either merging with any previous + tracks or appending to them. */ +static int read_track(MidiSong *song, int append) +{ + MidiEventList *meep; + MidiEventList *next, *newlist; + Sint32 len; + Sint64 next_pos, pos; + char tmp[4]; + + meep = song->evlist; + if (append && meep) + { + /* find the last event in the list */ + for (; meep->next; meep=meep->next) + ; + song->at = meep->event.time; + } + else + song->at=0; + + /* Check the formalities */ + if (SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_RWread(song->rw, &len, 4, 1) != 1) + { + SNDDBG(("Can't read track header.\n")); + return -1; + } + len=(Sint32)SDL_SwapBE32((Uint32)len); + next_pos = SDL_RWtell(song->rw) + len; + if (SDL_memcmp(tmp, "MTrk", 4)) + { + SNDDBG(("Corrupt MIDI file.\n")); + return -2; + } + + for (;;) + { + if (!(newlist=read_midi_event(song))) /* Some kind of error */ + return -2; + + if (newlist==MAGIC_EOT) /* End-of-track Hack. */ + { + /* If the track ends before the size of the + * track data, skip any junk at the end. */ + pos = SDL_RWtell(song->rw); + if (pos < next_pos) + SDL_RWseek(song->rw, next_pos - pos, RW_SEEK_CUR); + return 0; + } + + next=meep->next; + while (next && (next->event.time < newlist->event.time)) + { + meep=next; + next=meep->next; + } + + newlist->next=next; + meep->next=newlist; + + song->event_count++; /* Count the event. (About one?) */ + meep=newlist; + } +} + +/* Free the linked event list from memory. */ +static void free_midi_list(MidiSong *song) +{ + MidiEventList *meep, *next; + meep = song->evlist; + while (meep) + { + next=meep->next; + SDL_free(meep); + meep=next; + } + song->evlist = NULL; +} + +/* Allocate an array of MidiEvents and fill it from the linked list of + events, marking used instruments for loading. Convert event times to + samples: handle tempo changes. Strip unnecessary events from the list. + Free the linked list. */ +static MidiEvent *groom_list(MidiSong *song, Sint32 divisions,Sint32 *eventsp, + Sint32 *samplesp) +{ + MidiEvent *groomed_list, *lp; + MidiEventList *meep; + Sint32 i, our_event_count, tempo, skip_this_event, new_value; + Sint32 sample_cum, samples_to_do, at, st, dt, counting_time; + + int current_bank[MAXCHAN], current_set[MAXCHAN], current_program[MAXCHAN]; + /* Or should each bank have its own current program? */ + + for (i=0; idefault_program; + } + + tempo=500000; + compute_sample_increment(song, tempo, divisions); + + /* This may allocate a bit more than we need */ + groomed_list=lp=SDL_malloc(sizeof(MidiEvent) * (song->event_count+1)); + if (!groomed_list) { + song->oom=1; + free_midi_list(song); + return NULL; + } + meep=song->evlist; + + our_event_count=0; + st=at=sample_cum=0; + counting_time=2; /* We strip any silence before the first NOTE ON. */ + + for (i = 0; i < song->event_count; i++) + { + skip_this_event=0; + + if (meep->event.type==ME_TEMPO) + { + skip_this_event=1; + } + else if (meep->event.channel >= MAXCHAN) + skip_this_event=1; + else switch (meep->event.type) + { + case ME_PROGRAM: + if (ISDRUMCHANNEL(song, meep->event.channel)) + { + if (song->drumset[meep->event.a]) /* Is this a defined drumset? */ + new_value=meep->event.a; + else + { + SNDDBG(("Drum set %d is undefined\n", meep->event.a)); + new_value=meep->event.a=0; + } + if (current_set[meep->event.channel] != new_value) + current_set[meep->event.channel]=new_value; + else + skip_this_event=1; + } + else + { + new_value=meep->event.a; + if ((current_program[meep->event.channel] != SPECIAL_PROGRAM) + && (current_program[meep->event.channel] != new_value)) + current_program[meep->event.channel] = new_value; + else + skip_this_event=1; + } + break; + + case ME_NOTEON: + if (counting_time) + counting_time=1; + if (ISDRUMCHANNEL(song, meep->event.channel)) + { + /* Mark this instrument to be loaded */ + if (!(song->drumset[current_set[meep->event.channel]] + ->instrument[meep->event.a])) + song->drumset[current_set[meep->event.channel]] + ->instrument[meep->event.a] = MAGIC_LOAD_INSTRUMENT; + } + else + { + if (current_program[meep->event.channel]==SPECIAL_PROGRAM) + break; + /* Mark this instrument to be loaded */ + if (!(song->tonebank[current_bank[meep->event.channel]] + ->instrument[current_program[meep->event.channel]])) + song->tonebank[current_bank[meep->event.channel]] + ->instrument[current_program[meep->event.channel]] = + MAGIC_LOAD_INSTRUMENT; + } + break; + + case ME_TONE_BANK: + if (ISDRUMCHANNEL(song, meep->event.channel)) + { + skip_this_event=1; + break; + } + if (song->tonebank[meep->event.a]) /* Is this a defined tone bank? */ + new_value=meep->event.a; + else + { + SNDDBG(("Tone bank %d is undefined\n", meep->event.a)); + new_value=meep->event.a=0; + } + if (current_bank[meep->event.channel]!=new_value) + current_bank[meep->event.channel]=new_value; + else + skip_this_event=1; + break; + } + + /* Recompute time in samples*/ + if ((dt=meep->event.time - at) && !counting_time) + { + if (song->sample_increment > 2147483647/dt || + song->sample_correction > 2147483647/dt) { + goto _overflow; + } + samples_to_do = song->sample_increment * dt; + sample_cum += song->sample_correction * dt; + if (sample_cum & 0xFFFF0000) + { + samples_to_do += ((sample_cum >> 16) & 0xFFFF); + sample_cum &= 0x0000FFFF; + } + if (st >= 2147483647 - samples_to_do) { + _overflow: + SNDDBG(("Overflow in sample counter\n")); + free_midi_list(song); + SDL_free(groomed_list); + return NULL; + } + st += samples_to_do; + } + else if (counting_time==1) counting_time=0; + if (meep->event.type==ME_TEMPO) + { + tempo= + meep->event.channel + meep->event.b * 256 + meep->event.a * 65536; + compute_sample_increment(song, tempo, divisions); + } + if (!skip_this_event) + { + /* Add the event to the list */ + *lp=meep->event; + lp->time=st; + lp++; + our_event_count++; + } + at=meep->event.time; + meep=meep->next; + } + /* Add an End-of-Track event */ + lp->time=st; + lp->type=ME_EOT; + our_event_count++; + free_midi_list(song); + + *eventsp=our_event_count; + *samplesp=st; + return groomed_list; +} + +MidiEvent *read_midi_file(MidiSong *song, Sint32 *count, Sint32 *sp) +{ + Sint32 len, divisions; + Sint16 format, tracks, divisions_tmp; + int i; + char tmp[4]; + + song->event_count=0; + song->at=0; + song->evlist = NULL; + + if (SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_RWread(song->rw, &len, 4, 1) != 1) + { + SNDDBG(("Not a MIDI file!\n")); + return NULL; + } + if (SDL_memcmp(tmp, "RIFF", 4) == 0) { /* RMID ?? */ + if (SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_memcmp(tmp, "RMID", 4) != 0 || + SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_memcmp(tmp, "data", 4) != 0 || + SDL_RWread(song->rw, tmp, 1, 4) != 4 || + /* SMF must begin from here onwards: */ + SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_RWread(song->rw, &len, 4, 1) != 1) + { + SNDDBG(("Not an RMID file!\n")); + return NULL; + } + } + len=(Sint32)SDL_SwapBE32((Uint32)len); + if (SDL_memcmp(tmp, "MThd", 4) || len < 6) + { + SNDDBG(("Not a MIDI file!\n")); + return NULL; + } + + format=tracks=divisions_tmp = -1; + SDL_RWread(song->rw, &format, 2, 1); + SDL_RWread(song->rw, &tracks, 2, 1); + SDL_RWread(song->rw, &divisions_tmp, 2, 1); + format=SDL_SwapBE16(format); + tracks=SDL_SwapBE16(tracks); + divisions_tmp=SDL_SwapBE16(divisions_tmp); + + if (divisions_tmp<0) + { + /* SMPTE time -- totally untested. Got a MIDI file that uses this? */ + divisions= + (Sint32)(-(divisions_tmp/256)) * (Sint32)(divisions_tmp & 0xFF); + } + else divisions=(Sint32)(divisions_tmp); + + if (len > 6) + { + SNDDBG(("MIDI file header size %u bytes", len)); + SDL_RWseek(song->rw, len-6, RW_SEEK_CUR); /* skip the excess */ + } + if (format<0 || format >2) + { + SNDDBG(("Unknown MIDI file format %d\n", format)); + return NULL; + } + if (tracks<1) + { + SNDDBG(("Bad number of tracks %d\n", tracks)); + return NULL; + } + if (format==0 && tracks!=1) + { + SNDDBG(("%d tracks with Type-0 MIDI (must be 1.)\n", tracks)); + return NULL; + } + SNDDBG(("Format: %d Tracks: %d Divisions: %d\n", + format, tracks, divisions)); + + /* Put a do-nothing event first in the list for easier processing */ + song->evlist=SDL_calloc(1, sizeof(MidiEventList)); + if (!song->evlist) { + song->oom=1; + return NULL; + } + song->event_count++; + + switch(format) + { + case 0: + if (read_track(song, 0)) + { + free_midi_list(song); + return NULL; + } + break; + + case 1: + for (i=0; i + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. + + readmidi.h +*/ + +#ifndef TIMIDITY_READMIDI_H +#define TIMIDITY_READMIDI_H + +#define read_midi_file TIMI_NAMESPACE(read_midi_file) + +extern MidiEvent *read_midi_file(MidiSong *song, Sint32 *count, Sint32 *sp); + +#endif /* TIMIDITY_READMIDI_H */ diff --git a/src/codecs/timidity/resample.c b/src/codecs/timidity/resample.c new file mode 100644 index 0000000..333903f --- /dev/null +++ b/src/codecs/timidity/resample.c @@ -0,0 +1,600 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. + + resample.c +*/ + +#include "SDL.h" + +#include "timidity.h" +#include "options.h" +#include "common.h" +#include "instrum.h" +#include "playmidi.h" +#include "tables.h" +#include "resample.h" + +#define PRECALC_LOOP_COUNT(start, end, incr) (((end) - (start) + (incr) - 1) / (incr)) + +/*************** resampling with fixed increment *****************/ + +static sample_t *rs_plain(MidiSong *song, int v, Sint32 *countptr) +{ + + /* Play sample until end, then free the voice. */ + + sample_t v1, v2; + Voice + *vp=&(song->voice[v]); + sample_t + *dest=song->resample_buffer, + *src=vp->sample->data; + Sint32 + ofs=vp->sample_offset, + incr=vp->sample_increment, + le=vp->sample->data_length, + count=*countptr; + Sint32 i, j; + + if (incr<0) incr = -incr; /* In case we're coming out of a bidir loop */ + + /* Precalc how many times we should go through the loop. + NOTE: Assumes that incr > 0 and that ofs <= le */ + i = PRECALC_LOOP_COUNT(ofs, le, incr); + + if (i > count) + { + i = count; + count = 0; + } + else count -= i; + + for (j = 0; j < i; j++) + { + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS)+1]; + *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); + ofs += incr; + } + + if (ofs >= le) + { + if (ofs == le) + *dest++ = src[(ofs>>FRACTION_BITS)-1]/2; + vp->status=VOICE_FREE; + *countptr-=count+1; + } + + vp->sample_offset=ofs; /* Update offset */ + return song->resample_buffer; +} + +static sample_t *rs_loop(MidiSong *song, Voice *vp, Sint32 count) +{ + /* Play sample until end-of-loop, skip back and continue. */ + + sample_t v1, v2; + Sint32 + ofs=vp->sample_offset, + incr=vp->sample_increment, + le=vp->sample->loop_end, + ll=le - vp->sample->loop_start; + sample_t + *dest=song->resample_buffer, + *src=vp->sample->data; + Sint32 i, j; + + while (count) + { + while (ofs >= le) + ofs -= ll; + /* Precalc how many times we should go through the loop */ + i = PRECALC_LOOP_COUNT(ofs, le, incr); + if (i > count) + { + i = count; + count = 0; + } + else count -= i; + for (j = 0; j < i; j++) + { + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS)+1]; + *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); + ofs += incr; + } + } + + vp->sample_offset=ofs; /* Update offset */ + return song->resample_buffer; +} + +static sample_t *rs_bidir(MidiSong *song, Voice *vp, Sint32 count) +{ + sample_t v1, v2; + Sint32 + ofs=vp->sample_offset, + incr=vp->sample_increment, + le=vp->sample->loop_end, + ls=vp->sample->loop_start; + sample_t + *dest=song->resample_buffer, + *src=vp->sample->data; + Sint32 + le2 = le<<1, + ls2 = ls<<1, + i, j; + /* Play normally until inside the loop region */ + + if (incr > 0 && ofs < ls) + { + /* NOTE: Assumes that incr > 0, which is NOT always the case + when doing bidirectional looping. I have yet to see a case + where both ofs <= ls AND incr < 0, however. */ + i = PRECALC_LOOP_COUNT(ofs, ls, incr); + if (i > count) + { + i = count; + count = 0; + } + else count -= i; + for (j = 0; j < i; j++) + { + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS)+1]; + *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); + ofs += incr; + } + } + + /* Then do the bidirectional looping */ + while(count) + { + /* Precalc how many times we should go through the loop */ + i = PRECALC_LOOP_COUNT(ofs, incr > 0 ? le : ls, incr); + if (i > count) + { + i = count; + count = 0; + } + else count -= i; + for (j = 0; j < i; j++) + { + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS)+1]; + *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); + ofs += incr; + } + if (ofs>=le) + { + /* fold the overshoot back in */ + ofs = le2 - ofs; + incr *= -1; + } + else if (ofs <= ls) + { + ofs = ls2 - ofs; + incr *= -1; + } + } + + vp->sample_increment=incr; + vp->sample_offset=ofs; /* Update offset */ + return song->resample_buffer; +} + +/*********************** vibrato versions ***************************/ + +/* We only need to compute one half of the vibrato sine cycle */ +static int vib_phase_to_inc_ptr(int phase) +{ + if (phase < VIBRATO_SAMPLE_INCREMENTS/2) + return VIBRATO_SAMPLE_INCREMENTS/2-1-phase; + else if (phase >= 3*VIBRATO_SAMPLE_INCREMENTS/2) + return 5*VIBRATO_SAMPLE_INCREMENTS/2-1-phase; + else + return phase-VIBRATO_SAMPLE_INCREMENTS/2; +} + +static Sint32 update_vibrato(MidiSong *song, Voice *vp, int sign) +{ + Sint32 depth; + int phase, pb; + double a; + + if (vp->vibrato_phase++ >= 2*VIBRATO_SAMPLE_INCREMENTS-1) + vp->vibrato_phase=0; + phase=vib_phase_to_inc_ptr(vp->vibrato_phase); + + if (vp->vibrato_sample_increment[phase]) + { + if (sign) + return -vp->vibrato_sample_increment[phase]; + else + return vp->vibrato_sample_increment[phase]; + } + + /* Need to compute this sample increment. */ + depth=vp->sample->vibrato_depth<<7; + + if (vp->vibrato_sweep) + { + /* Need to update sweep */ + vp->vibrato_sweep_position += vp->vibrato_sweep; + if (vp->vibrato_sweep_position >= (1<vibrato_sweep=0; + else + { + /* Adjust depth */ + depth *= vp->vibrato_sweep_position; + depth >>= SWEEP_SHIFT; + } + } + + a = TIM_FSCALE(((double)(vp->sample->sample_rate) * + (double)(vp->frequency)) / + ((double)(vp->sample->root_freq) * + (double)(song->rate)), + FRACTION_BITS); + + pb=(int)((timi_sine(vp->vibrato_phase * + (SINE_CYCLE_LENGTH/(2*VIBRATO_SAMPLE_INCREMENTS))) + * (double)(depth) * VIBRATO_AMPLITUDE_TUNING)); + + if (pb<0) + { + pb=-pb; + a /= bend_fine[(pb>>5) & 0xFF] * bend_coarse[pb>>13]; + } + else + a *= bend_fine[(pb>>5) & 0xFF] * bend_coarse[pb>>13]; + + /* If the sweep's over, we can store the newly computed sample_increment */ + if (!vp->vibrato_sweep) + vp->vibrato_sample_increment[phase]=(Sint32) a; + + if (sign) + a = -a; /* need to preserve the loop direction */ + + return (Sint32) a; +} + +static sample_t *rs_vib_plain(MidiSong *song, int v, Sint32 *countptr) +{ + /* Play sample until end, then free the voice. */ + + sample_t v1, v2; + Voice *vp=&(song->voice[v]); + sample_t + *dest=song->resample_buffer, + *src=vp->sample->data; + Sint32 + le=vp->sample->data_length, + ofs=vp->sample_offset, + incr=vp->sample_increment, + count=*countptr; + int + cc=vp->vibrato_control_counter; + + /* This has never been tested */ + + if (incr<0) incr = -incr; /* In case we're coming out of a bidir loop */ + + while (count--) + { + if (!cc--) + { + cc=vp->vibrato_control_ratio; + incr=update_vibrato(song, vp, 0); + } + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS)+1]; + *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); + ofs += incr; + if (ofs >= le) + { + if (ofs == le) + *dest++ = src[(ofs>>FRACTION_BITS)-1]/2; + vp->status=VOICE_FREE; + *countptr-=count+1; + break; + } + } + + vp->vibrato_control_counter=cc; + vp->sample_increment=incr; + vp->sample_offset=ofs; /* Update offset */ + return song->resample_buffer; +} + +static sample_t *rs_vib_loop(MidiSong *song, Voice *vp, Sint32 count) +{ + /* Play sample until end-of-loop, skip back and continue. */ + + sample_t v1, v2; + Sint32 + ofs=vp->sample_offset, + incr=vp->sample_increment, + le=vp->sample->loop_end, + ll=le - vp->sample->loop_start; + sample_t + *dest=song->resample_buffer, + *src=vp->sample->data; + int + cc=vp->vibrato_control_counter; + Sint32 i, j; + int + vibflag=0; + + while (count) + { + /* Hopefully the loop is longer than an increment */ + while(ofs >= le) + ofs -= ll; + /* Precalc how many times to go through the loop, taking + the vibrato control ratio into account this time. */ + i = PRECALC_LOOP_COUNT(ofs, le, incr); + if(i > count) i = count; + if(i > cc) + { + i = cc; + vibflag = 1; + } + else cc -= i; + count -= i; + for (j = 0; j < i; j++) + { + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS)+1]; + *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); + ofs += incr; + } + if(vibflag) + { + cc = vp->vibrato_control_ratio; + incr = update_vibrato(song, vp, 0); + vibflag = 0; + } + } + + vp->vibrato_control_counter=cc; + vp->sample_increment=incr; + vp->sample_offset=ofs; /* Update offset */ + return song->resample_buffer; +} + +static sample_t *rs_vib_bidir(MidiSong *song, Voice *vp, Sint32 count) +{ + sample_t v1, v2; + Sint32 + ofs=vp->sample_offset, + incr=vp->sample_increment, + le=vp->sample->loop_end, + ls=vp->sample->loop_start; + sample_t + *dest=song->resample_buffer, + *src=vp->sample->data; + int + cc=vp->vibrato_control_counter; + Sint32 + le2=le<<1, + ls2=ls<<1, + i, j; + int + vibflag = 0; + + /* Play normally until inside the loop region */ + while (count && incr > 0 && ofs < ls) + { + i = PRECALC_LOOP_COUNT(ofs, ls, incr); + if (i > count) i = count; + if (i > cc) + { + i = cc; + vibflag = 1; + } + else cc -= i; + count -= i; + for (j = 0; j < i; j++) + { + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS)+1]; + *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); + ofs += incr; + } + if (vibflag) + { + cc = vp->vibrato_control_ratio; + incr = update_vibrato(song, vp, 0); + vibflag = 0; + } + } + + /* Then do the bidirectional looping */ + while (count) + { + /* Precalc how many times we should go through the loop */ + i = PRECALC_LOOP_COUNT(ofs, incr > 0 ? le : ls, incr); + if(i > count) i = count; + if(i > cc) + { + i = cc; + vibflag = 1; + } + else cc -= i; + count -= i; + while (i--) + { + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS)+1]; + *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); + ofs += incr; + } + if (vibflag) + { + cc = vp->vibrato_control_ratio; + incr = update_vibrato(song, vp, (incr < 0)); + vibflag = 0; + } + if (ofs >= le) + { + /* fold the overshoot back in */ + ofs = le2 - ofs; + incr *= -1; + } + else if (ofs <= ls) + { + ofs = ls2 - ofs; + incr *= -1; + } + } + + vp->vibrato_control_counter=cc; + vp->sample_increment=incr; + vp->sample_offset=ofs; /* Update offset */ + return song->resample_buffer; +} + +sample_t *resample_voice(MidiSong *song, int v, Sint32 *countptr) +{ + Sint32 ofs; + Uint8 modes; + Voice *vp=&(song->voice[v]); + + if (!(vp->sample->sample_rate)) + { + /* Pre-resampled data -- just update the offset and check if + we're out of data. */ + ofs=vp->sample_offset >> FRACTION_BITS; /* Kind of silly to use + FRACTION_BITS here... */ + if (*countptr >= (vp->sample->data_length>>FRACTION_BITS) - ofs) + { + /* Note finished. Free the voice. */ + vp->status = VOICE_FREE; + + /* Let the caller know how much data we had left */ + *countptr = (vp->sample->data_length>>FRACTION_BITS) - ofs; + } + else + vp->sample_offset += *countptr << FRACTION_BITS; + + return vp->sample->data+ofs; + } + + /* Need to resample. Use the proper function. */ + modes=vp->sample->modes; + + if (vp->vibrato_control_ratio) + { + if ((modes & MODES_LOOPING) && + ((modes & MODES_ENVELOPE) || + (vp->status==VOICE_ON || vp->status==VOICE_SUSTAINED))) + { + if (modes & MODES_PINGPONG) + return rs_vib_bidir(song, vp, *countptr); + else + return rs_vib_loop(song, vp, *countptr); + } + else + return rs_vib_plain(song, v, countptr); + } + else + { + if ((modes & MODES_LOOPING) && + ((modes & MODES_ENVELOPE) || + (vp->status==VOICE_ON || vp->status==VOICE_SUSTAINED))) + { + if (modes & MODES_PINGPONG) + return rs_bidir(song, vp, *countptr); + else + return rs_loop(song, vp, *countptr); + } + else + return rs_plain(song, v, countptr); + } +} + +void pre_resample(MidiSong *song, Sample *sp) +{ + double a, xdiff; + Sint32 incr, ofs, newlen, count; + Sint16 *newdata, *dest, *src = (Sint16 *) sp->data, *vptr; + Sint32 v, v1, v2, v3, v4, v5, i; +#ifdef DEBUG_CHATTER + static const char note_name[12][3] = { + "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" + }; + + SNDDBG((" * pre-resampling for note %d (%s%d)\n", + sp->note_to_use, + note_name[sp->note_to_use % 12], (sp->note_to_use & 0x7F) / 12)); +#endif + + a = ((double) (sp->root_freq) * song->rate) / + ((double) (sp->sample_rate) * freq_table[(int) (sp->note_to_use)]); + if(sp->data_length * a >= 0x7fffffffL) { /* Too large to compute */ + SNDDBG((" *** Can't pre-resampling for note %d\n", sp->note_to_use)); + return; + } + + newlen = (Sint32)(sp->data_length * a); + count = (newlen >> FRACTION_BITS) - 1; + ofs = incr = (sp->data_length - (1 << FRACTION_BITS)) / count; + + if((double)newlen + incr >= 0x7fffffffL) { /* Too large to compute */ + SNDDBG((" *** Can't pre-resampling for note %d\n", sp->note_to_use)); + return; + } + + dest = newdata = (Sint16 *) SDL_malloc((newlen >> (FRACTION_BITS - 1)) + 2); + if (!dest) { + song->oom = 1; + return; + } + + if (--count) + *dest++ = src[0]; + + /* Since we're pre-processing and this doesn't have to be done in + real-time, we go ahead and do the full sliding cubic interpolation. */ + count--; + for(i = 0; i < count; i++) + { + vptr = src + (ofs >> FRACTION_BITS); + v1 = ((vptr>=src+1)? *(vptr - 1):0); + v2 = *vptr; + v3 = *(vptr + 1); + v4 = *(vptr + 2); + v5 = v2 - v3; + xdiff = TIM_FSCALENEG(ofs & FRACTION_MASK, FRACTION_BITS); + v = (Sint32)(v2 + xdiff * (1.0/6.0) * (3 * (v3 - v5) - 2 * v1 - v4 + + xdiff * (3 * (v1 - v2 - v5) + xdiff * (3 * v5 + v4 - v1)))); + *dest++ = (Sint16)((v > 32767) ? 32767 : ((v < -32768) ? -32768 : v)); + ofs += incr; + } + + if (ofs & FRACTION_MASK) + { + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS) + 1]; + *dest++ = (Sint16)(v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS)); + } + else + *dest++ = src[ofs >> FRACTION_BITS]; + + *dest = *(dest - 1) / 2; + ++dest; + *dest = *(dest - 1) / 2; + + sp->data_length = newlen; + sp->loop_start = (Sint32)(sp->loop_start * a); + sp->loop_end = (Sint32)(sp->loop_end * a); + SDL_free(sp->data); + sp->data = (sample_t *) newdata; + sp->sample_rate = 0; +} diff --git a/src/codecs/timidity/resample.h b/src/codecs/timidity/resample.h new file mode 100644 index 0000000..ac38117 --- /dev/null +++ b/src/codecs/timidity/resample.h @@ -0,0 +1,20 @@ +/* + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. + + resample.h +*/ + +#ifndef TIMIDITY_RESAMPLE_H +#define TIMIDITY_RESAMPLE_H + +#define resample_voice TIMI_NAMESPACE(resample_voice) +#define pre_resample TIMI_NAMESPACE(pre_resample) + +extern sample_t *resample_voice(MidiSong *song, int v, Sint32 *countptr); +extern void pre_resample(MidiSong *song, Sample *sp); + +#endif /* TIMIDITY_RESAMPLE_H */ diff --git a/src/codecs/timidity/tables.c b/src/codecs/timidity/tables.c new file mode 100644 index 0000000..e01e48f --- /dev/null +++ b/src/codecs/timidity/tables.c @@ -0,0 +1,198 @@ +/* + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. +*/ + +#include "SDL.h" + +#include "common.h" +#include "tables.h" + +const Sint32 freq_table[128] = +{ + 8176, 8662, 9177, 9723, + 10301, 10913, 11562, 12250, + 12978, 13750, 14568, 15434, + + 16352, 17324, 18354, 19445, + 20602, 21827, 23125, 24500, + 25957, 27500, 29135, 30868, + + 32703, 34648, 36708, 38891, + 41203, 43654, 46249, 48999, + 51913, 55000, 58270, 61735, + + 65406, 69296, 73416, 77782, + 82407, 87307, 92499, 97999, + 103826, 110000, 116541, 123471, + + 130813, 138591, 146832, 155563, + 164814, 174614, 184997, 195998, + 207652, 220000, 233082, 246942, + + 261626, 277183, 293665, 311127, + 329628, 349228, 369994, 391995, + 415305, 440000, 466164, 493883, + + 523251, 554365, 587330, 622254, + 659255, 698456, 739989, 783991, + 830609, 880000, 932328, 987767, + + 1046502, 1108731, 1174659, 1244508, + 1318510, 1396913, 1479978, 1567982, + 1661219, 1760000, 1864655, 1975533, + + 2093005, 2217461, 2349318, 2489016, + 2637020, 2793826, 2959955, 3135963, + 3322438, 3520000, 3729310, 3951066, + + 4186009, 4434922, 4698636, 4978032, + 5274041, 5587652, 5919911, 6271927, + 6644875, 7040000, 7458620, 7902133, + + 8372018, 8869844, 9397273, 9956063, + 10548082, 11175303, 11839822, 12543854 +}; + +/* v=2.^((x/127-1) * 6) */ +const double vol_table[128] = +{ + 0.015625, 0.016145143728351113, 0.016682602624583379, 0.017237953096759438, + 0.017811790741104401, 0.01840473098076444, 0.019017409725829021, 0.019650484055324921, + 0.020304632921913132, 0.020980557880044631, 0.021678983838355849, 0.02240065983711079, + 0.023146359851523596, 0.023916883621822989, 0.024713057510949051, 0.025535735390801884, + 0.026385799557992876, 0.027264161680080529, 0.028171763773305786, 0.029109579212875332, + 0.030078613776876421, 0.031079906724942836, 0.032114531912828696, 0.033183598944085631, + 0.034288254360078256, 0.035429682869614412, 0.036609108619508737, 0.037827796507442342, + 0.039087053538526394, 0.040388230227024875, 0.041732722044739302, 0.043121970917609151, + 0.044557466772132896, 0.046040749133268132, 0.047573408775524545, 0.049157089429020417, + 0.050793489542332405, 0.05248436410402918, 0.054231526524842463, 0.056036850582493913, + 0.057902272431264008, 0.059829792678457581, 0.061821478529993396, 0.063879466007418645, + 0.066005962238725971, 0.068203247825430205, 0.070473679288442961, 0.072819691595368496, + 0.075243800771931268, 0.077748606600335793, 0.080336795407452768, 0.083011142945821612, + 0.085774517370559328, 0.088629882315368294, 0.091580300070941839, 0.094628934869176312, + 0.097779056276712184, 0.10103404270144323, 0.1043973850157546, 0.1078726903003755, + 0.11146368571286204, 0.11517422248485852, 0.11900828005242428, 0.12296997032385605, + 0.12706354208958254, 0.13129338557886089, 0.13566403716816194, 0.14018018424629392, + 0.14484667024148207, 0.14966849981579558, 0.15465084423249356, 0.15979904690204472, + 0.16511862911277009, 0.17061529595225433, 0.17629494242587571, 0.18216365977901747, + 0.18822774202974024, 0.19449369271892172, 0.20096823188510385, 0.20765830327152621, + 0.21457108177307616, 0.22171398113114205, 0.2290946618846218, 0.23672103958561411, + 0.2446012932886038, 0.25274387432224471, 0.26115751535314891, 0.26985123975140174, + 0.27883437126784744, 0.28811654403352405, 0.29770771289197112, 0.30761816407549192, + 0.31785852623682015, 0.32843978184802081, 0.33937327897885317, 0.3506707434672246, + 0.36234429149478936, 0.37440644258117928, 0.38687013301080181, 0.39974872970660535, + 0.41305604456569134, 0.42680634927214656, 0.44101439060298442, 0.45569540624360722, + 0.47086514112975281, 0.48653986433345225, 0.50273638651110641, 0.51947207793239625, + 0.53676488710936021, 0.55463336004561792, 0.57309666012638816, 0.59217458867062556, + 0.61188760616732485, 0.63225685421876243, 0.65330417821421161, 0.67505215075844849, + 0.69752409588017272, 0.72074411404630734, 0.74473710800900605, 0.76952880951308478, + 0.79514580689252357, 0.82161557358563286, 0.84896649759946774, 0.87722791195508854, + 0.90643012614631979, 0.93660445864574493, 0.96778327049280244, 1 +}; + +const double bend_fine[256] = { + 1, 1.0002256593050698, 1.0004513695322617, 1.0006771306930664, + 1.0009029427989777, 1.0011288058614922, 1.0013547198921082, 1.0015806849023274, + 1.0018067009036538, 1.002032767907594, 1.0022588859256572, 1.0024850549693551, + 1.0027112750502025, 1.0029375461797159, 1.0031638683694153, 1.0033902416308227, + 1.0036166659754628, 1.0038431414148634, 1.0040696679605541, 1.0042962456240678, + 1.0045228744169397, 1.0047495543507072, 1.0049762854369111, 1.0052030676870944, + 1.0054299011128027, 1.0056567857255843, 1.00588372153699, 1.006110708558573, + 1.0063377468018897, 1.0065648362784985, 1.0067919769999607, 1.0070191689778405, + 1.0072464122237039, 1.0074737067491204, 1.0077010525656616, 1.0079284496849015, + 1.0081558981184175, 1.008383397877789, 1.008610948974598, 1.0088385514204294, + 1.0090662052268706, 1.0092939104055114, 1.0095216669679448, 1.0097494749257656, + 1.009977334290572, 1.0102052450739643, 1.0104332072875455, 1.0106612209429215, + 1.0108892860517005, 1.0111174026254934, 1.0113455706759138, 1.0115737902145781, + 1.0118020612531047, 1.0120303838031153, 1.0122587578762337, 1.012487183484087, + 1.0127156606383041, 1.0129441893505169, 1.0131727696323602, 1.0134014014954713, + 1.0136300849514894, 1.0138588200120575, 1.0140876066888203, 1.0143164449934257, + 1.0145453349375237, 1.0147742765327674, 1.0150032697908125, 1.0152323147233171, + 1.015461411341942, 1.0156905596583505, 1.0159197596842091, 1.0161490114311862, + 1.0163783149109531, 1.0166076701351838, 1.0168370771155553, 1.0170665358637463, + 1.0172960463914391, 1.0175256087103179, 1.0177552228320703, 1.0179848887683858, + 1.0182146065309567, 1.0184443761314785, 1.0186741975816487, 1.0189040708931674, + 1.0191339960777379, 1.0193639731470658, 1.0195940021128593, 1.0198240829868295, + 1.0200542157806898, 1.0202844005061564, 1.0205146371749483, 1.0207449257987866, + 1.0209752663893958, 1.0212056589585028, 1.0214361035178368, 1.0216666000791297, + 1.0218971486541166, 1.0221277492545349, 1.0223584018921241, 1.0225891065786274, + 1.0228198633257899, 1.0230506721453596, 1.023281533049087, 1.0235124460487257, + 1.0237434111560313, 1.0239744283827625, 1.0242054977406807, 1.0244366192415495, + 1.0246677928971357, 1.0248990187192082, 1.025130296719539, 1.0253616269099028, + 1.0255930093020766, 1.0258244439078401, 1.0260559307389761, 1.0262874698072693, + 1.0265190611245079, 1.0267507047024822, 1.0269824005529853, 1.027214148687813, + 1.0274459491187637, 1.0276778018576387, 1.0279097069162415, 1.0281416643063788, + 1.0283736740398595, 1.0286057361284953, 1.0288378505841009, 1.0290700174184932, + 1.0293022366434921, 1.0295345082709197, 1.0297668323126017, 1.0299992087803651, + 1.030231637686041, 1.0304641190414621, 1.0306966528584645, 1.0309292391488862, + 1.0311618779245688, 1.0313945691973556, 1.0316273129790936, 1.0318601092816313, + 1.0320929581168212, 1.0323258594965172, 1.0325588134325767, 1.0327918199368598, + 1.0330248790212284, 1.0332579906975481, 1.0334911549776868, 1.033724371873515, + 1.0339576413969056, 1.0341909635597348, 1.0344243383738811, 1.0346577658512259, + 1.034891246003653, 1.0351247788430489, 1.0353583643813031, 1.0355920026303078, + 1.0358256936019572, 1.0360594373081489, 1.0362932337607829, 1.0365270829717617, + 1.0367609849529913, 1.0369949397163791, 1.0372289472738365, 1.0374630076372766, + 1.0376971208186156, 1.0379312868297725, 1.0381655056826686, 1.0383997773892284, + 1.0386341019613787, 1.0388684794110492, 1.0391029097501721, 1.0393373929906822, + 1.0395719291445176, 1.0398065182236185, 1.0400411602399278, 1.0402758552053915, + 1.0405106031319582, 1.0407454040315787, 1.0409802579162071, 1.0412151647977996, + 1.0414501246883161, 1.0416851375997183, 1.0419202035439705, 1.0421553225330404, + 1.042390494578898, 1.042625719693516, 1.0428609978888699, 1.043096329176938, + 1.0433317135697009, 1.0435671510791424, 1.0438026417172486, 1.0440381854960086, + 1.0442737824274138, 1.044509432523459, 1.044745135796141, 1.0449808922574599, + 1.0452167019194181, 1.0454525647940205, 1.0456884808932754, 1.0459244502291931, + 1.0461604728137874, 1.0463965486590741, 1.046632677777072, 1.0468688601798024, + 1.0471050958792898, 1.047341384887561, 1.0475777272166455, 1.047814122878576, + 1.048050571885387, 1.0482870742491166, 1.0485236299818055, 1.0487602390954964, + 1.0489969016022356, 1.0492336175140715, 1.0494703868430555, 1.0497072096012419, + 1.0499440858006872, 1.0501810154534512, 1.050417998571596, 1.0506550351671864, + 1.0508921252522903, 1.0511292688389782, 1.0513664659393229, 1.0516037165654004, + 1.0518410207292894, 1.0520783784430709, 1.0523157897188296, 1.0525532545686513, + 1.0527907730046264, 1.0530283450388465, 1.0532659706834067, 1.0535036499504049, + 1.0537413828519411, 1.0539791694001188, 1.0542170096070436, 1.0544549034848243, + 1.0546928510455722, 1.0549308523014012, 1.0551689072644284, 1.0554070159467728, + 1.0556451783605572, 1.0558833945179062, 1.0561216644309479, 1.0563599881118126, + 1.0565983655726334, 1.0568367968255465, 1.0570752818826903, 1.0573138207562065, + 1.057552413458239, 1.0577910600009348, 1.0580297603964437, 1.058268514656918, + 1.0585073227945128, 1.0587461848213857, 1.058985100749698, 1.0592240705916123 +}; + +const double bend_coarse[128] = { + 1, 1.0594630943592953, 1.122462048309373, 1.189207115002721, + 1.2599210498948732, 1.3348398541700344, 1.4142135623730951, 1.4983070768766815, + 1.5874010519681994, 1.681792830507429, 1.7817974362806785, 1.8877486253633868, + 2, 2.1189261887185906, 2.244924096618746, 2.3784142300054421, + 2.5198420997897464, 2.6696797083400687, 2.8284271247461903, 2.996614153753363, + 3.1748021039363992, 3.363585661014858, 3.5635948725613571, 3.7754972507267741, + 4, 4.2378523774371812, 4.4898481932374912, 4.7568284600108841, + 5.0396841995794928, 5.3393594166801366, 5.6568542494923806, 5.993228307506727, + 6.3496042078727974, 6.727171322029716, 7.1271897451227151, 7.5509945014535473, + 8, 8.4757047548743625, 8.9796963864749824, 9.5136569200217682, + 10.079368399158986, 10.678718833360273, 11.313708498984761, 11.986456615013454, + 12.699208415745595, 13.454342644059432, 14.25437949024543, 15.101989002907095, + 16, 16.951409509748721, 17.959392772949972, 19.027313840043536, + 20.158736798317967, 21.357437666720553, 22.627416997969522, 23.972913230026901, + 25.398416831491197, 26.908685288118864, 28.508758980490853, 30.203978005814196, + 32, 33.902819019497443, 35.918785545899944, 38.054627680087073, + 40.317473596635935, 42.714875333441107, 45.254833995939045, 47.945826460053802, + 50.796833662982394, 53.817370576237728, 57.017517960981706, 60.407956011628393, + 64, 67.805638038994886, 71.837571091799887, 76.109255360174146, + 80.63494719327187, 85.429750666882214, 90.509667991878089, 95.891652920107603, + 101.59366732596479, 107.63474115247546, 114.03503592196341, 120.81591202325679, + 128, 135.61127607798977, 143.67514218359977, 152.21851072034829, + 161.26989438654374, 170.85950133376443, 181.01933598375618, 191.78330584021521, + 203.18733465192958, 215.26948230495091, 228.07007184392683, 241.63182404651357, + 256, 271.22255215597971, 287.35028436719938, 304.43702144069658, + 322.53978877308765, 341.71900266752868, 362.03867196751236, 383.56661168043064, + 406.37466930385892, 430.53896460990183, 456.14014368785394, 483.26364809302686, + 512, 542.44510431195943, 574.70056873439876, 608.87404288139317, + 645.0795775461753, 683.43800533505737, 724.07734393502471, 767.13322336086128, + 812.74933860771785, 861.07792921980365, 912.28028737570787, 966.52729618605372, + 1024, 1084.8902086239189, 1149.4011374687975, 1217.7480857627863, + 1290.1591550923506, 1366.8760106701147, 1448.1546878700494, 1534.2664467217226 +}; + diff --git a/src/codecs/timidity/tables.h b/src/codecs/timidity/tables.h new file mode 100644 index 0000000..ac68539 --- /dev/null +++ b/src/codecs/timidity/tables.h @@ -0,0 +1,31 @@ +/* + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. + + tables.h +*/ + +#ifndef TIMIDITY_TABLES_H +#define TIMIDITY_TABLES_H + +#if defined(HAVE_LIBC) && defined(__WATCOMC__) /* Watcom has issues... */ +#define SDL_sin sin +#endif +#define timi_sine(x) (SDL_sin((2*PI/1024.0) * (x))) + +#define SINE_CYCLE_LENGTH 1024 + +#define freq_table TIMI_NAMESPACE(freq_table) +#define vol_table TIMI_NAMESPACE(vol_table) +#define bend_fine TIMI_NAMESPACE(bend_fine) +#define bend_coarse TIMI_NAMESPACE(bend_coarse) + +extern const Sint32 freq_table[]; +extern const double vol_table[]; +extern const double bend_fine[]; +extern const double bend_coarse[]; + +#endif /* TIMIDITY_TABLES_H */ diff --git a/src/codecs/timidity/timidity.c b/src/codecs/timidity/timidity.c new file mode 100644 index 0000000..ef4a2e7 --- /dev/null +++ b/src/codecs/timidity/timidity.c @@ -0,0 +1,690 @@ +/* + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. +*/ + +#include "SDL.h" +#include "../../utils.h" /* for SDL_strtokr() */ + +#include "timidity.h" + +#include "options.h" +#include "common.h" +#include "instrum.h" +#include "playmidi.h" +#include "readmidi.h" +#include "output.h" + +#include "tables.h" + +static ToneBank *master_tonebank[MAXBANK], *master_drumset[MAXBANK]; + +static char def_instr_name[256] = ""; + +#define MAXWORDS 10 +#define MAX_RCFCOUNT 50 + +/* Quick-and-dirty fgets() replacement. */ + +static char *RWgets(SDL_RWops *rw, char *s, int size) +{ + int num_read = 0; + char *p = s; + + --size;/* so that we nul terminate properly */ + + for (; num_read < size; ++p) + { + if (SDL_RWread(rw, p, 1, 1) != 1) + break; + + num_read++; + + /* Unlike fgets(), don't store newline. Under Windows/DOS we'll + * probably get an extra blank line for every line that's being + * read, but that should be ok. + */ + if (*p == '\n' || *p == '\r') + { + *p = '\0'; + return s; + } + } + + *p = '\0'; + + return (num_read != 0) ? s : NULL; +} + +static int read_config_file(const char *name, int rcf_count) +{ + SDL_RWops *rw; + char tmp[1024]; + char *w[MAXWORDS], *cp; + char *endp; + ToneBank *bank; + int i, j, k, line, r, words; + + if (rcf_count >= MAX_RCFCOUNT) { + SNDDBG(("Probable source loop in configuration files\n")); + return -1; + } + + if (!(rw=timi_openfile(name))) + return -1; + + bank = NULL; + line = 0; + r = -1; /* start by assuming failure, */ + + while (RWgets(rw, tmp, sizeof(tmp))) + { + line++; + words=0; + w[0]=SDL_strtokr(tmp, " \t\240", &endp); + if (!w[0]) continue; + + /* Originally the TiMidity++ extensions were prefixed like this */ + if (SDL_strcmp(w[0], "#extension") == 0) + { + w[0]=SDL_strtokr(0, " \t\240", &endp); + if (!w[0]) continue; + } + + if (*w[0] == '#') + continue; + + while (words < MAXWORDS - 1) /* -1 : next arg */ + { + while (*endp == ' ' || *endp == '\t' || *endp == '\240') + endp++; + if (*endp == '\0' || *endp == '#') + break; + if (*endp == '"' || *endp == '\'') /* quoted string */ + { + char *terminator; + if ((terminator = SDL_strchr(endp + 1, *endp)) != NULL) /* terminated */ + { + if (terminator[1] == ' ' || terminator[1] == '\t' || terminator[1] == '\240' || terminator[1] == '\0') + { + char *extraQuote; + if ((extraQuote = SDL_strchr(endp + 1, *endp == '"' ? '\'' : '"')) != NULL && extraQuote < terminator) + { + SNDDBG(("%s: line %d: Quote characters are not allowed inside a quoted string", name, line)); + goto fail; + } + + w[++words] = endp + 1; + endp = terminator + 1; + *terminator = '\0'; + } + else /* no space after quoted string */ + { + SNDDBG(("%s: line %d: There must be at least one whitespace between string terminator (%c) and the next parameter", name, line, *endp)); + goto fail; + } + } + else /* not terminated */ + { + SNDDBG(("%s: line %d: The quoted string is not terminated", name, line)); + goto fail; + } + } + else /* not quoted string */ + { + w[++words] = endp; + while (!(*endp == ' ' || *endp == '\t' || *endp == '\240' || *endp == '\0')) + { + if (*endp == '"' || *endp == '\'') /* no space before quoted string */ + { + SNDDBG(("%s: line %d: There must be at least one whitespace between previous parameter and a beginning of the quoted string (%c)", name, line, *endp)); + goto fail; + } + endp++; + } + if (*endp != '\0') /* unless at the end-of-string (i.e. EOF) */ + { + *endp = '\0'; /* terminate the token */ + endp++; + } + } + } + w[++words] = NULL; + + /* TiMidity++ adds a number of extensions to the config file format. + * Many of them are completely irrelevant to SDL_sound, but at least + * we shouldn't choke on them. + * + * Unfortunately the documentation for these extensions is often quite + * vague, gramatically strange or completely absent. + */ + if (!SDL_strcmp(w[0], "comm") /* "comm" program second */ || + !SDL_strcmp(w[0], "HTTPproxy") /* "HTTPproxy" hostname:port */ || + !SDL_strcmp(w[0], "FTPproxy") /* "FTPproxy" hostname:port */ || + !SDL_strcmp(w[0], "mailaddr") /* "mailaddr" your-mail-address */ || + !SDL_strcmp(w[0], "opt") /* "opt" timidity-options */ ) + { + /* + "comm" sets some kind of comment -- the documentation is too + * vague for me to understand at this time. + * + "HTTPproxy", "FTPproxy" and "mailaddr" are for reading data + * over a network, rather than from the file system. + * + "opt" specifies default options for TiMidity++. + * + * Quite useless for us, so they can safely remain no-ops. + */ + } + else if (!SDL_strcmp(w[0], "timeout")) /* "timeout" program second */ + { + /* Specifies a timeout value of the program. A number of seconds + * before TiMidity kills the note. No urgent need for it. + */ + SNDDBG(("FIXME: Implement \"timeout\" in TiMidity config.\n")); + } + else if (!SDL_strcmp(w[0], "copydrumset") /* "copydrumset" drumset */ || + !SDL_strcmp(w[0], "copybank")) /* "copybank" bank */ + { + /* Copies all the settings of the specified drumset or bank to + * the current drumset or bank. May be useful later, but not a + * high priority. + */ + SNDDBG(("FIXME: Implement \"%s\" in TiMidity config.\n", w[0])); + } + else if (!SDL_strcmp(w[0], "undef")) /* "undef" progno */ + { + /* Undefines the tone "progno" of the current tone bank (or + * drum set?). Not a high priority. + */ + SNDDBG(("FIXME: Implement \"undef\" in TiMidity config.\n")); + } + else if (!SDL_strcmp(w[0], "altassign")) /* "altassign" prog1 prog2 ... */ + { + /* Sets the alternate assign for drum set. Whatever that's + * supposed to mean. + */ + SNDDBG(("FIXME: Implement \"altassign\" in TiMidity config.\n")); + } + else if (!SDL_strcmp(w[0], "soundfont") || + !SDL_strcmp(w[0], "font")) + { + /* "soundfont" sf_file "remove" + * "soundfont" sf_file ["order=" order] ["cutoff=" cutoff] + * ["reso=" reso] ["amp=" amp] + * "font" "exclude" bank preset keynote + * "font" "order" order bank preset keynote + */ + SNDDBG(("FIXME: Implmement \"%s\" in TiMidity config.\n", w[0])); + } + else if (!SDL_strcmp(w[0], "progbase")) + { + /* The documentation for this makes absolutely no sense to me, but + * apparently it sets some sort of base offset for tone numbers. + */ + SNDDBG(("FIXME: Implement \"progbase\" in TiMidity config.\n")); + } + else if (!SDL_strcmp(w[0], "map")) /* "map" name set1 elem1 set2 elem2 */ + { + /* This one is used by the "eawpats". Looks like it's used + * for remapping one instrument to another somehow. + */ + SNDDBG(("FIXME: Implement \"map\" in TiMidity config.\n")); + } + + /* Standard TiMidity config */ + else if (!SDL_strcmp(w[0], "dir")) + { + if (words < 2) + { + SNDDBG(("%s: line %d: No directory given\n", name, line)); + goto fail; + } + for (i=1; i(MAXBANK-1)) + { + SNDDBG(("%s: line %d: Drum set must be between 0 and %d\n", + name, line, MAXBANK-1)); + goto fail; + } + if (!master_drumset[i]) + { + master_drumset[i] = SDL_calloc(1, sizeof(ToneBank)); + if (!master_drumset[i]) goto fail; + master_drumset[i]->tone = SDL_calloc(128, sizeof(ToneBankElement)); + if (!master_drumset[i]->tone) goto fail; + } + bank=master_drumset[i]; + } + else if (!SDL_strcmp(w[0], "bank")) + { + if (words < 2) + { + SNDDBG(("%s: line %d: No bank number given\n", name, line)); + goto fail; + } + i=SDL_atoi(w[1]); + if (i<0 || i>(MAXBANK-1)) + { + SNDDBG(("%s: line %d: Tone bank must be between 0 and %d\n", + name, line, MAXBANK-1)); + goto fail; + } + if (!master_tonebank[i]) + { + master_tonebank[i] = SDL_calloc(1, sizeof(ToneBank)); + if (!master_tonebank[i]) goto fail; + master_tonebank[i]->tone = SDL_calloc(128, sizeof(ToneBankElement)); + if (!master_tonebank[i]->tone) goto fail; + } + bank=master_tonebank[i]; + } + else + { + size_t sz; + if ((words < 2) || (*w[0] < '0' || *w[0] > '9')) + { + SNDDBG(("%s: line %d: syntax error\n", name, line)); + goto fail; + } + i=SDL_atoi(w[0]); + if (i<0 || i>127) + { + SNDDBG(("%s: line %d: Program must be between 0 and 127\n", + name, line)); + goto fail; + } + if (!bank) + { + SNDDBG(("%s: line %d: Must specify tone bank or drum set before assignment\n", + name, line)); + goto fail; + } + SDL_free(bank->tone[i].name); + sz = SDL_strlen(w[1])+1; + bank->tone[i].name = SDL_malloc(sz); + if (!bank->tone[i].name) goto fail; + SDL_memcpy(bank->tone[i].name,w[1],sz); + bank->tone[i].note=bank->tone[i].amp=bank->tone[i].pan= + bank->tone[i].strip_loop=bank->tone[i].strip_envelope= + bank->tone[i].strip_tail=-1; + + for (j=2; j '9')) + { + SNDDBG(("%s: line %d: amplification must be between 0 and %d\n", + name, line, MAX_AMPLIFICATION)); + goto fail; + } + bank->tone[i].amp=k; + } + else if (!SDL_strcmp(w[j], "note")) + { + k=SDL_atoi(cp); + if ((k<0 || k>127) || (*cp < '0' || *cp > '9')) + { + SNDDBG(("%s: line %d: note must be between 0 and 127\n", + name, line)); + goto fail; + } + bank->tone[i].note=k; + } + else if (!SDL_strcmp(w[j], "pan")) + { + if (!SDL_strcmp(cp, "center")) + k=64; + else if (!SDL_strcmp(cp, "left")) + k=0; + else if (!SDL_strcmp(cp, "right")) + k=127; + else + k=((SDL_atoi(cp)+100) * 100) / 157; + if ((k<0 || k>127) || (k==0 && *cp!='-' && (*cp < '0' || *cp > '9'))) + { + SNDDBG(("%s: line %d: panning must be left, right, center, or between -100 and 100\n", + name, line)); + goto fail; + } + bank->tone[i].pan=k; + } + else if (!SDL_strcmp(w[j], "keep")) + { + if (!SDL_strcmp(cp, "env")) + bank->tone[i].strip_envelope=0; + else if (!SDL_strcmp(cp, "loop")) + bank->tone[i].strip_loop=0; + else + { + SNDDBG(("%s: line %d: keep must be env or loop\n", name, line)); + goto fail; + } + } + else if (!SDL_strcmp(w[j], "strip")) + { + if (!SDL_strcmp(cp, "env")) + bank->tone[i].strip_envelope=1; + else if (!SDL_strcmp(cp, "loop")) + bank->tone[i].strip_loop=1; + else if (!SDL_strcmp(cp, "tail")) + bank->tone[i].strip_tail=1; + else + { + SNDDBG(("%s: line %d: strip must be env, loop, or tail\n", + name, line)); + goto fail; + } + } + else + { + SNDDBG(("%s: line %d: bad patch option %s\n", name, line, w[j])); + goto fail; + } + } + } + } + + r = 0; /* we're good. */ +fail: + SDL_RWclose(rw); + return r; +} + +#if defined(_WIN32)||defined(__CYGWIN__)||defined(__OS2__) +/* FIXME: What about C:FOO ? */ +static SDL_INLINE char *get_last_dirsep (const char *p) { + char *p1 = SDL_strrchr(p, '/'); + char *p2 = SDL_strrchr(p, '\\'); + if (!p1) return p2; + if (!p2) return p1; + return (p1 > p2)? p1 : p2; +} +#else /* assumed UNIX-ish : */ +static SDL_INLINE char *get_last_dirsep (const char *p) { + return SDL_strrchr(p, '/'); +} +#endif + +static int init_alloc_banks(void) +{ + /* Allocate memory for the standard tonebank and drumset */ + master_tonebank[0] = SDL_calloc(1, sizeof(ToneBank)); + if (!master_tonebank[0]) goto _nomem; + master_tonebank[0]->tone = SDL_calloc(128, sizeof(ToneBankElement)); + if (!master_tonebank[0]->tone) goto _nomem; + + master_drumset[0] = SDL_calloc(1, sizeof(ToneBank)); + if (!master_drumset[0]) goto _nomem; + master_drumset[0]->tone = SDL_calloc(128, sizeof(ToneBankElement)); + if (!master_drumset[0]->tone) goto _nomem; + + return 0; +_nomem: + SNDDBG(("Out of memory\n")); + Timidity_Exit (); + return -2; +} + +static int init_begin_config(const char *cf) +{ + const char *p = get_last_dirsep(cf); + if (p != NULL) + return timi_add_pathlist(cf, p - cf + 1); /* including DIRSEP */ + return 0; +} + +static int init_with_config(const char *cf) +{ + int rc = init_begin_config(cf); + if (rc != 0) { + Timidity_Exit (); + return rc; + } + rc = read_config_file(cf, 0); + if (rc != 0) { + Timidity_Exit (); + } + return rc; +} + +int Timidity_Init_NoConfig(void) +{ + master_tonebank[0] = NULL; + master_drumset[0] = NULL; + return init_alloc_banks(); +} + +int Timidity_Init(const char *config_file) +{ + int rc = Timidity_Init_NoConfig(); + if (rc != 0) { + return rc; + } + if (config_file == NULL || *config_file == '\0') { + return init_with_config(TIMIDITY_CFG); + } + return init_with_config(config_file); +} + +static void do_song_load(SDL_RWops *rw, SDL_AudioSpec *audio, MidiSong **out) +{ + MidiSong *song; + int i; + + *out = NULL; + if (rw == NULL) + return; + + /* Allocate memory for the song */ + song = (MidiSong *)SDL_calloc(1, sizeof(*song)); + if (song == NULL) + return; + + for (i = 0; i < MAXBANK; i++) + { + if (master_tonebank[i]) { + song->tonebank[i] = SDL_calloc(1, sizeof(ToneBank)); + if (!song->tonebank[i]) goto fail; + song->tonebank[i]->tone = master_tonebank[i]->tone; + } + if (master_drumset[i]) { + song->drumset[i] = SDL_calloc(1, sizeof(ToneBank)); + if (!song->drumset[i]) goto fail; + song->drumset[i]->tone = master_drumset[i]->tone; + } + } + + song->amplification = DEFAULT_AMPLIFICATION; + song->voices = DEFAULT_VOICES; + song->drumchannels = DEFAULT_DRUMCHANNELS; + + song->rw = rw; + + song->rate = audio->freq; + song->encoding = 0; + if ((audio->format & 0xFF) == 16) + song->encoding |= PE_16BIT; + else if ((audio->format & 0xFF) == 32) + song->encoding |= PE_32BIT; + if (audio->format & 0x8000) + song->encoding |= PE_SIGNED; + if (audio->channels == 1) + song->encoding |= PE_MONO; + else if (audio->channels > 2) { + SDL_SetError("Surround sound not supported"); + goto fail; + } + switch (audio->format) { + case AUDIO_S8: + song->write = timi_s32tos8; + break; + case AUDIO_U8: + song->write = timi_s32tou8; + break; + case AUDIO_S16LSB: + song->write = timi_s32tos16l; + break; + case AUDIO_S16MSB: + song->write = timi_s32tos16b; + break; + case AUDIO_U16LSB: + song->write = timi_s32tou16l; + break; + case AUDIO_U16MSB: + song->write = timi_s32tou16b; + break; + case AUDIO_S32LSB: + song->write = timi_s32tos32l; + break; + case AUDIO_S32MSB: + song->write = timi_s32tos32b; + break; + case AUDIO_F32SYS: + song->write = timi_s32tof32; + break; + default: + SDL_SetError("Unsupported audio format"); + goto fail; + } + + song->buffer_size = audio->samples; + song->resample_buffer = SDL_malloc(audio->samples * sizeof(sample_t)); + if (!song->resample_buffer) goto fail; + song->common_buffer = SDL_malloc(audio->samples * 2 * sizeof(Sint32)); + if (!song->common_buffer) goto fail; + + song->control_ratio = audio->freq / CONTROLS_PER_SECOND; + if (song->control_ratio < 1) + song->control_ratio = 1; + else if (song->control_ratio > MAX_CONTROL_RATIO) + song->control_ratio = MAX_CONTROL_RATIO; + + song->lost_notes = 0; + song->cut_notes = 0; + + song->events = read_midi_file(song, &(song->groomed_event_count), + &song->samples); + + /* Make sure everything is okay */ + if (!song->events) + goto fail; + + song->default_instrument = NULL; + song->default_program = DEFAULT_PROGRAM; + + if (*def_instr_name) + set_default_instrument(song, def_instr_name); + + load_missing_instruments(song); + + if (! song->oom) + *out = song; + else { +fail: Timidity_FreeSong(song); + } +} + +MidiSong *Timidity_LoadSong(SDL_RWops *rw, SDL_AudioSpec *audio) +{ + MidiSong *song; + do_song_load(rw, audio, &song); + return song; +} + +void Timidity_FreeSong(MidiSong *song) +{ + int i; + + if (!song) return; + + free_instruments(song); + + for (i = 0; i < 128; i++) { + SDL_free(song->tonebank[i]); + SDL_free(song->drumset[i]); + } + + SDL_free(song->common_buffer); + SDL_free(song->resample_buffer); + SDL_free(song->events); + + SDL_free(song); +} + +void Timidity_Exit(void) +{ + int i, j; + + for (i = 0; i < MAXBANK; i++) { + if (master_tonebank[i]) { + ToneBankElement *e = master_tonebank[i]->tone; + if (e != NULL) { + for (j = 0; j < 128; j++) { + SDL_free(e[j].name); + } + SDL_free(e); + } + SDL_free(master_tonebank[i]); + master_tonebank[i] = NULL; + } + if (master_drumset[i]) { + ToneBankElement *e = master_drumset[i]->tone; + if (e != NULL) { + for (j = 0; j < 128; j++) { + SDL_free(e[j].name); + } + SDL_free(e); + } + SDL_free(master_drumset[i]); + master_drumset[i] = NULL; + } + } + + timi_free_pathlist(); +} diff --git a/src/codecs/timidity/timidity.h b/src/codecs/timidity/timidity.h new file mode 100644 index 0000000..3764c4f --- /dev/null +++ b/src/codecs/timidity/timidity.h @@ -0,0 +1,167 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. +*/ + +#ifndef TIMIDITY_H +#define TIMIDITY_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef Sint16 sample_t; +typedef Sint32 final_volume_t; + +#define VIBRATO_SAMPLE_INCREMENTS 32 + +/* Maximum polyphony. */ +/* #define MAX_VOICES 48 */ +#define MAX_VOICES 256 +#define MAXCHAN 16 +/* #define MAXCHAN 64 */ +#define MAXBANK 128 + +typedef struct { + Sint32 + loop_start, loop_end, data_length, + sample_rate, low_freq, high_freq, root_freq; + Sint32 + envelope_rate[6], envelope_offset[6]; + float + volume; + sample_t *data; + Sint32 + tremolo_sweep_increment, tremolo_phase_increment, + vibrato_sweep_increment, vibrato_control_ratio; + Uint8 + tremolo_depth, vibrato_depth, + modes; + Sint8 + panning, note_to_use; +} Sample; + +typedef struct { + int + bank, program, volume, sustain, panning, pitchbend, expression, + mono, /* one note only on this channel -- not implemented yet */ + pitchsens; + /* chorus, reverb... Coming soon to a 300-MHz, eight-way superscalar + processor near you */ + float + pitchfactor; /* precomputed pitch bend factor to save some fdiv's */ +} Channel; + +typedef struct { + Uint8 + status, channel, note, velocity; + Sample *sample; + Sint32 + orig_frequency, frequency, + sample_offset, sample_increment, + envelope_volume, envelope_target, envelope_increment, + tremolo_sweep, tremolo_sweep_position, + tremolo_phase, tremolo_phase_increment, + vibrato_sweep, vibrato_sweep_position; + + final_volume_t left_mix, right_mix; + + float + left_amp, right_amp, tremolo_volume; + Sint32 + vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS]; + int + vibrato_phase, vibrato_control_ratio, vibrato_control_counter, + envelope_stage, control_counter, panning, panned; + +} Voice; + +typedef struct { + int samples; + Sample *sample; +} Instrument; + +/* Shared data */ +typedef struct { + char *name; + int note, amp, pan, strip_loop, strip_envelope, strip_tail; +} ToneBankElement; + +typedef struct { + ToneBankElement *tone; + Instrument *instrument[128]; +} ToneBank; + +typedef struct { + Sint32 time; + Uint8 channel, type, a, b; +} MidiEvent; + +typedef struct _MidiEventList { + MidiEvent event; + struct _MidiEventList *next; +} MidiEventList; + +typedef struct { + int oom; /* malloc() failed */ + int playing; + SDL_RWops *rw; + Sint32 rate; + Sint32 encoding; + float master_volume; + Sint32 amplification; + ToneBank *tonebank[MAXBANK]; + ToneBank *drumset[MAXBANK]; + Instrument *default_instrument; + int default_program; + void (*write)(void *dp, Sint32 *lp, Sint32 c); + int buffer_size; + sample_t *resample_buffer; + Sint32 *common_buffer; + Sint32 *buffer_pointer; + /* These would both fit into 32 bits, but they are often added in + large multiples, so it's simpler to have two roomy ints */ + /* samples per MIDI delta-t */ + Sint32 sample_increment; + Sint32 sample_correction; + Channel channel[MAXCHAN]; + Voice voice[MAX_VOICES]; + int voices; + Sint32 drumchannels; + Sint32 buffered_count; + Sint32 control_ratio; + Sint32 lost_notes; + Sint32 cut_notes; + Sint32 samples; + MidiEvent *events; + MidiEvent *current_event; + MidiEventList *evlist; + Sint32 current_sample; + Sint32 event_count; + Sint32 at; + Sint32 groomed_event_count; +} MidiSong; + +/* Some of these are not defined in timidity.c but are here for convenience */ + +extern int Timidity_Init(const char *config_file); +extern int Timidity_Init_NoConfig(void); +extern void Timidity_SetVolume(MidiSong *song, int volume); +extern int Timidity_PlaySome(MidiSong *song, void *stream, Sint32 len); +extern MidiSong *Timidity_LoadSong(SDL_RWops *rw, SDL_AudioSpec *audio); +extern void Timidity_Start(MidiSong *song); +extern void Timidity_Seek(MidiSong *song, Uint32 ms); +extern Uint32 Timidity_GetSongLength(MidiSong *song); /* returns millseconds */ +extern Uint32 Timidity_GetSongTime(MidiSong *song); /* returns millseconds */ +extern void Timidity_Stop(MidiSong *song); +extern int Timidity_IsActive(MidiSong *song); +extern void Timidity_FreeSong(MidiSong *song); +extern void Timidity_Exit(void); + +#ifdef __cplusplus +} +#endif +#endif /* TIMIDITY_H */ diff --git a/src/effect_position.c b/src/effect_position.c new file mode 100644 index 0000000..e28a7ae --- /dev/null +++ b/src/effect_position.c @@ -0,0 +1,2113 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + This file by Ryan C. Gordon (icculus@icculus.org) + + These are some internally supported special effects that use SDL_mixer's + effect callback API. They are meant for speed over quality. :) +*/ + +#include "SDL_endian.h" +#include "SDL_mixer.h" + +#include "mixer.h" + +#define MIX_INTERNAL_EFFECT__ +#include "effects_internal.h" + +/* profile code: + #include + #include + struct timeval tv1; + struct timeval tv2; + + gettimeofday(&tv1, NULL); + + ... do your thing here ... + + gettimeofday(&tv2, NULL); + printf("%ld\n", tv2.tv_usec - tv1.tv_usec); +*/ + + +/* + * Positional effects...panning, distance attenuation, etc. + */ + +typedef struct _Eff_positionargs +{ + volatile float left_f; + volatile float right_f; + volatile Uint8 left_u8; + volatile Uint8 right_u8; + volatile float left_rear_f; + volatile float right_rear_f; + volatile float center_f; + volatile float lfe_f; + volatile Uint8 left_rear_u8; + volatile Uint8 right_rear_u8; + volatile Uint8 center_u8; + volatile Uint8 lfe_u8; + volatile float distance_f; + volatile Uint8 distance_u8; + volatile Sint16 room_angle; + volatile int in_use; + volatile int channels; +} position_args; + +static position_args **pos_args_array = NULL; +static position_args *pos_args_global = NULL; +static int position_channels = 0; + +void _Eff_PositionDeinit(void) +{ + int i; + for (i = 0; i < position_channels; i++) { + SDL_free(pos_args_array[i]); + } + + position_channels = 0; + + SDL_free(pos_args_global); + pos_args_global = NULL; + SDL_free(pos_args_array); + pos_args_array = NULL; +} + + +/* This just frees up the callback-specific data. */ +static void SDLCALL _Eff_PositionDone(int channel, void *udata) +{ + (void)udata; + + if (channel < 0) { + if (pos_args_global != NULL) { + SDL_free(pos_args_global); + pos_args_global = NULL; + } + } + else if (pos_args_array[channel] != NULL) { + SDL_free(pos_args_array[channel]); + pos_args_array[channel] = NULL; + } +} + +static void SDLCALL _Eff_position_u8(int chan, void *stream, int len, void *udata) +{ + volatile position_args *args = (volatile position_args *) udata; + Uint8 *ptr = (Uint8 *) stream; + int i; + + (void)chan; + + /* + * if there's only a mono channnel (the only way we wouldn't have + * a len divisible by 2 here), then left_f and right_f are always + * 1.0, and are therefore throwaways. + */ + if (len % (int)sizeof(Uint16) != 0) { + *ptr = (Uint8) (((float) *ptr) * args->distance_f); + ptr++; + len--; + } + + if (args->room_angle == 180) + for (i = 0; i < len; i += sizeof (Uint8) * 2) { + /* must adjust the sample so that 0 is the center */ + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_f) * args->distance_f) + 128); + ptr++; + } + else for (i = 0; i < len; i += sizeof (Uint8) * 2) { + /* must adjust the sample so that 0 is the center */ + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_f) * args->distance_f) + 128); + ptr++; + } +} + +static void SDLCALL _Eff_position_u8_c4(int chan, void *stream, int len, void *udata) +{ + volatile position_args *args = (volatile position_args *) udata; + Uint8 *ptr = (Uint8 *) stream; + int i; + + (void)chan; + + /* + * if there's only a mono channnel (the only way we wouldn't have + * a len divisible by 2 here), then left_f and right_f are always + * 1.0, and are therefore throwaways. + */ + if (len % (int)sizeof(Uint16) != 0) { + *ptr = (Uint8) (((float) *ptr) * args->distance_f); + ptr++; + len--; + } + + if (args->room_angle == 0) + for (i = 0; i < len; i += sizeof (Uint8) * 4) { + /* must adjust the sample so that 0 is the center */ + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_rear_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_rear_f) * args->distance_f) + 128); + ptr++; + } + else if (args->room_angle == 90) + for (i = 0; i < len; i += sizeof (Uint8) * 4) { + /* must adjust the sample so that 0 is the center */ + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_rear_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_rear_f) * args->distance_f) + 128); + ptr++; + } + else if (args->room_angle == 180) + for (i = 0; i < len; i += sizeof (Uint8) * 4) { + /* must adjust the sample so that 0 is the center */ + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_rear_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_rear_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_f) * args->distance_f) + 128); + ptr++; + } + else if (args->room_angle == 270) + for (i = 0; i < len; i += sizeof (Uint8) * 4) { + /* must adjust the sample so that 0 is the center */ + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_rear_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_rear_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_f) * args->distance_f) + 128); + ptr++; + } +} + +static void SDLCALL _Eff_position_u8_c6(int chan, void *stream, int len, void *udata) +{ + volatile position_args *args = (volatile position_args *) udata; + Uint8 *ptr = (Uint8 *) stream; + int i; + + (void)chan; + (void)len; + + /* + * if there's only a mono channnel (the only way we wouldn't have + * a len divisible by 2 here), then left_f and right_f are always + * 1.0, and are therefore throwaways. + */ + if (len % (int)sizeof(Uint16) != 0) { + *ptr = (Uint8) (((float) *ptr) * args->distance_f); + ptr++; + len--; + } + + if (args->room_angle == 0) + for (i = 0; i < len; i += sizeof (Uint8) * 6) { + /* must adjust the sample so that 0 is the center */ + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_rear_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_rear_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->center_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->lfe_f) * args->distance_f) + 128); + ptr++; + } + else if (args->room_angle == 90) + for (i = 0; i < len; i += sizeof (Uint8) * 6) { + /* must adjust the sample so that 0 is the center */ + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_rear_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_rear_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_rear_f) * args->distance_f/2) + 128) + + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_f) * args->distance_f/2) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->lfe_f) * args->distance_f) + 128); + ptr++; + } + else if (args->room_angle == 180) + for (i = 0; i < len; i += sizeof (Uint8) * 6) { + /* must adjust the sample so that 0 is the center */ + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_rear_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_rear_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_rear_f) * args->distance_f/2) + 128) + + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_rear_f) * args->distance_f/2) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->lfe_f) * args->distance_f) + 128); + ptr++; + } + else if (args->room_angle == 270) + for (i = 0; i < len; i += sizeof (Uint8) * 6) { + /* must adjust the sample so that 0 is the center */ + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_rear_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_rear_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->right_f) * args->distance_f) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_f) * args->distance_f/2) + 128) + + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->left_rear_f) * args->distance_f/2) + 128); + ptr++; + *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) + * args->lfe_f) * args->distance_f) + 128); + ptr++; + } +} + + +/* + * This one runs about 10.1 times faster than the non-table version, with + * no loss in quality. It does, however, require 64k of memory for the + * lookup table. Also, this will only update position information once per + * call; the non-table version always checks the arguments for each sample, + * in case the user has called Mix_SetPanning() or whatnot again while this + * callback is running. + */ +static void SDLCALL _Eff_position_table_u8(int chan, void *stream, int len, void *udata) +{ + volatile position_args *args = (volatile position_args *) udata; + Uint8 *ptr = (Uint8 *) stream; + Uint32 *p; + int i; + Uint8 *l = ((Uint8 *) _Eff_volume_table) + (256 * args->left_u8); + Uint8 *r = ((Uint8 *) _Eff_volume_table) + (256 * args->right_u8); + Uint8 *d = ((Uint8 *) _Eff_volume_table) + (256 * args->distance_u8); + + (void)chan; + + if (args->room_angle == 180) { + Uint8 *temp = l; + l = r; + r = temp; + } + /* + * if there's only a mono channnel, then l[] and r[] are always + * volume 255, and are therefore throwaways. Still, we have to + * be sure not to overrun the audio buffer... + */ + while (len % (int)sizeof(Uint32) != 0) { + *ptr = d[l[*ptr]]; + ptr++; + if (args->channels > 1) { + *ptr = d[r[*ptr]]; + ptr++; + } + len -= args->channels; + } + + p = (Uint32 *) ptr; + + for (i = 0; i < len; i += sizeof (Uint32)) { +#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + *p = (d[l[(*p & 0xFF000000) >> 24]] << 24) | + (d[r[(*p & 0x00FF0000) >> 16]] << 16) | + (d[l[(*p & 0x0000FF00) >> 8]] << 8) | + (d[r[(*p & 0x000000FF) ]] ) ; +#else + *p = (d[r[(*p & 0xFF000000) >> 24]] << 24) | + (d[l[(*p & 0x00FF0000) >> 16]] << 16) | + (d[r[(*p & 0x0000FF00) >> 8]] << 8) | + (d[l[(*p & 0x000000FF) ]] ) ; +#endif + ++p; + } +} + + +static void SDLCALL _Eff_position_s8(int chan, void *stream, int len, void *udata) +{ + volatile position_args *args = (volatile position_args *) udata; + Sint8 *ptr = (Sint8 *) stream; + int i; + + (void)chan; + + /* + * if there's only a mono channnel (the only way we wouldn't have + * a len divisible by 2 here), then left_f and right_f are always + * 1.0, and are therefore throwaways. + */ + if (len % (int)sizeof(Sint16) != 0) { + *ptr = (Sint8) (((float) *ptr) * args->distance_f); + ptr++; + len--; + } + + if (args->room_angle == 180) + for (i = 0; i < len; i += sizeof (Sint8) * 2) { + *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); + ptr++; + *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); + ptr++; + } + else + for (i = 0; i < len; i += sizeof (Sint8) * 2) { + *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); + ptr++; + *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); + ptr++; + } +} +static void SDLCALL _Eff_position_s8_c4(int chan, void *stream, int len, void *udata) +{ + volatile position_args *args = (volatile position_args *) udata; + Sint8 *ptr = (Sint8 *) stream; + int i; + + (void)chan; + + /* + * if there's only a mono channnel (the only way we wouldn't have + * a len divisible by 2 here), then left_f and right_f are always + * 1.0, and are therefore throwaways. + */ + if (len % (int)sizeof(Sint16) != 0) { + *ptr = (Sint8) (((float) *ptr) * args->distance_f); + ptr++; + len--; + } + + for (i = 0; i < len; i += sizeof (Sint8) * 4) { + switch (args->room_angle) { + case 0: + *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++; + break; + case 90: + *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++; + break; + case 180: + *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++; + break; + case 270: + *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++; + break; + } + } +} + +static void SDLCALL _Eff_position_s8_c6(int chan, void *stream, int len, void *udata) +{ + volatile position_args *args = (volatile position_args *) udata; + Sint8 *ptr = (Sint8 *) stream; + int i; + + (void)chan; + + /* + * if there's only a mono channnel (the only way we wouldn't have + * a len divisible by 2 here), then left_f and right_f are always + * 1.0, and are therefore throwaways. + */ + if (len % (int)sizeof(Sint16) != 0) { + *ptr = (Sint8) (((float) *ptr) * args->distance_f); + ptr++; + len--; + } + + for (i = 0; i < len; i += sizeof (Sint8) * 6) { + switch (args->room_angle) { + case 0: + *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->center_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++; + break; + case 90: + *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f / 2) + + (Sint8)((((float) *ptr) * args->right_f) * args->distance_f / 2); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++; + break; + case 180: + *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f / 2) + + (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f / 2); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++; + break; + case 270: + *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f / 2) + + (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f / 2); ptr++; + *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++; + break; + } + } +} + +/* + * This one runs about 10.1 times faster than the non-table version, with + * no loss in quality. It does, however, require 64k of memory for the + * lookup table. Also, this will only update position information once per + * call; the non-table version always checks the arguments for each sample, + * in case the user has called Mix_SetPanning() or whatnot again while this + * callback is running. + */ +static void SDLCALL _Eff_position_table_s8(int chan, void *stream, int len, void *udata) +{ + volatile position_args *args = (volatile position_args *) udata; + Sint8 *ptr = (Sint8 *) stream; + Uint32 *p; + int i; + Sint8 *l = ((Sint8 *) _Eff_volume_table) + (256 * args->left_u8); + Sint8 *r = ((Sint8 *) _Eff_volume_table) + (256 * args->right_u8); + Sint8 *d = ((Sint8 *) _Eff_volume_table) + (256 * args->distance_u8); + + (void)chan; + + if (args->room_angle == 180) { + Sint8 *temp = l; + l = r; + r = temp; + } + + while (len % (int)sizeof(Uint32) != 0) { + *ptr = d[l[*ptr]]; + ptr++; + if (args->channels > 1) { + *ptr = d[r[*ptr]]; + ptr++; + } + len -= args->channels; + } + + p = (Uint32 *) ptr; + + for (i = 0; i < len; i += sizeof (Uint32)) { +#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + *p = (d[l[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) | + (d[r[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) | + (d[l[((Sint16)(Sint8)((*p & 0x0000FF00) >> 8))+128]] << 8) | + (d[r[((Sint16)(Sint8)((*p & 0x000000FF) ))+128]] ) ; +#else + *p = (d[r[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) | + (d[l[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) | + (d[r[((Sint16)(Sint8)((*p & 0x0000FF00) >> 8))+128]] << 8) | + (d[l[((Sint16)(Sint8)((*p & 0x000000FF) ))+128]] ) ; +#endif + ++p; + } +} + + +/* !!! FIXME : Optimize the code for 16-bit samples? */ + +static void SDLCALL _Eff_position_u16lsb(int chan, void *stream, int len, void *udata) +{ + volatile position_args *args = (volatile position_args *) udata; + Uint16 *ptr = (Uint16 *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (Uint16) * 2) { + Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768); + Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768); + + Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f) + * args->distance_f) + 32768); + Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f) + * args->distance_f) + 32768); + + if (args->room_angle == 180) { + *(ptr++) = (Uint16) SDL_SwapLE16(swapr); + *(ptr++) = (Uint16) SDL_SwapLE16(swapl); + } + else { + *(ptr++) = (Uint16) SDL_SwapLE16(swapl); + *(ptr++) = (Uint16) SDL_SwapLE16(swapr); + } + } +} + +static void SDLCALL _Eff_position_u16lsb_c4(int chan, void *stream, int len, void *udata) +{ + volatile position_args *args = (volatile position_args *) udata; + Uint16 *ptr = (Uint16 *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (Uint16) * 4) { + Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768); + Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768); + Sint16 samplr = (Sint16) (SDL_SwapLE16(*(ptr+2)) - 32768); + Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768); + + Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f) + * args->distance_f) + 32768); + Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f) + * args->distance_f) + 32768); + Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f) + * args->distance_f) + 32768); + Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f) + * args->distance_f) + 32768); + + switch (args->room_angle) { + case 0: + *(ptr++) = (Uint16) SDL_SwapLE16(swapl); + *(ptr++) = (Uint16) SDL_SwapLE16(swapr); + *(ptr++) = (Uint16) SDL_SwapLE16(swaplr); + *(ptr++) = (Uint16) SDL_SwapLE16(swaprr); + break; + case 90: + *(ptr++) = (Uint16) SDL_SwapLE16(swapr); + *(ptr++) = (Uint16) SDL_SwapLE16(swaprr); + *(ptr++) = (Uint16) SDL_SwapLE16(swapl); + *(ptr++) = (Uint16) SDL_SwapLE16(swaplr); + break; + case 180: + *(ptr++) = (Uint16) SDL_SwapLE16(swaprr); + *(ptr++) = (Uint16) SDL_SwapLE16(swaplr); + *(ptr++) = (Uint16) SDL_SwapLE16(swapr); + *(ptr++) = (Uint16) SDL_SwapLE16(swapl); + break; + case 270: + *(ptr++) = (Uint16) SDL_SwapLE16(swaplr); + *(ptr++) = (Uint16) SDL_SwapLE16(swapl); + *(ptr++) = (Uint16) SDL_SwapLE16(swaprr); + *(ptr++) = (Uint16) SDL_SwapLE16(swapr); + break; + } + } +} + +static void SDLCALL _Eff_position_u16lsb_c6(int chan, void *stream, int len, void *udata) +{ + volatile position_args *args = (volatile position_args *) udata; + Uint16 *ptr = (Uint16 *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (Uint16) * 6) { + Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768); + Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768); + Sint16 samplr = (Sint16) (SDL_SwapLE16(*(ptr+2)) - 32768); + Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768); + Sint16 sampce = (Sint16) (SDL_SwapLE16(*(ptr+4)) - 32768); + Sint16 sampwf = (Sint16) (SDL_SwapLE16(*(ptr+5)) - 32768); + + Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f) + * args->distance_f) + 32768); + Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f) + * args->distance_f) + 32768); + Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f) + * args->distance_f) + 32768); + Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f) + * args->distance_f) + 32768); + Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f) + * args->distance_f) + 32768); + Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f) + * args->distance_f) + 32768); + + switch (args->room_angle) { + case 0: + *(ptr++) = (Uint16) SDL_SwapLE16(swapl); + *(ptr++) = (Uint16) SDL_SwapLE16(swapr); + *(ptr++) = (Uint16) SDL_SwapLE16(swaplr); + *(ptr++) = (Uint16) SDL_SwapLE16(swaprr); + *(ptr++) = (Uint16) SDL_SwapLE16(swapce); + *(ptr++) = (Uint16) SDL_SwapLE16(swapwf); + break; + case 90: + *(ptr++) = (Uint16) SDL_SwapLE16(swapr); + *(ptr++) = (Uint16) SDL_SwapLE16(swaprr); + *(ptr++) = (Uint16) SDL_SwapLE16(swapl); + *(ptr++) = (Uint16) SDL_SwapLE16(swaplr); + *(ptr++) = (Uint16) SDL_SwapLE16(swapr)/2 + (Uint16) SDL_SwapLE16(swaprr)/2; + *(ptr++) = (Uint16) SDL_SwapLE16(swapwf); + break; + case 180: + *(ptr++) = (Uint16) SDL_SwapLE16(swaprr); + *(ptr++) = (Uint16) SDL_SwapLE16(swaplr); + *(ptr++) = (Uint16) SDL_SwapLE16(swapr); + *(ptr++) = (Uint16) SDL_SwapLE16(swapl); + *(ptr++) = (Uint16) SDL_SwapLE16(swaprr)/2 + (Uint16) SDL_SwapLE16(swaplr)/2; + *(ptr++) = (Uint16) SDL_SwapLE16(swapwf); + break; + case 270: + *(ptr++) = (Uint16) SDL_SwapLE16(swaplr); + *(ptr++) = (Uint16) SDL_SwapLE16(swapl); + *(ptr++) = (Uint16) SDL_SwapLE16(swaprr); + *(ptr++) = (Uint16) SDL_SwapLE16(swapr); + *(ptr++) = (Uint16) SDL_SwapLE16(swapl)/2 + (Uint16) SDL_SwapLE16(swaplr)/2; + *(ptr++) = (Uint16) SDL_SwapLE16(swapwf); + break; + } + } +} + +static void SDLCALL _Eff_position_s16lsb(int chan, void *stream, int len, void *udata) +{ + /* 16 signed bits (lsb) * 2 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint16 *ptr = (Sint16 *) stream; + int i; + + (void)chan; + +#if 0 + if (len % (int)(sizeof(Sint16) * 2)) { + fprintf(stderr,"Not an even number of frames! len=%d\n", len); + return; + } +#endif + + for (i = 0; i < len; i += sizeof (Sint16) * 2) { + Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) * + args->right_f) * args->distance_f); + if (args->room_angle == 180) { + *(ptr++) = (Sint16) SDL_SwapLE16(swapr); + *(ptr++) = (Sint16) SDL_SwapLE16(swapl); + } + else { + *(ptr++) = (Sint16) SDL_SwapLE16(swapl); + *(ptr++) = (Sint16) SDL_SwapLE16(swapr); + } + } +} +static void SDLCALL _Eff_position_s16lsb_c4(int chan, void *stream, int len, void *udata) +{ + /* 16 signed bits (lsb) * 4 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint16 *ptr = (Sint16 *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (Sint16) * 4) { + Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) * + args->right_f) * args->distance_f); + Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) * + args->left_rear_f) * args->distance_f); + Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+2))) * + args->right_rear_f) * args->distance_f); + switch (args->room_angle) { + case 0: + *(ptr++) = (Sint16) SDL_SwapLE16(swapl); + *(ptr++) = (Sint16) SDL_SwapLE16(swapr); + *(ptr++) = (Sint16) SDL_SwapLE16(swaplr); + *(ptr++) = (Sint16) SDL_SwapLE16(swaprr); + break; + case 90: + *(ptr++) = (Sint16) SDL_SwapLE16(swapr); + *(ptr++) = (Sint16) SDL_SwapLE16(swaprr); + *(ptr++) = (Sint16) SDL_SwapLE16(swapl); + *(ptr++) = (Sint16) SDL_SwapLE16(swaplr); + break; + case 180: + *(ptr++) = (Sint16) SDL_SwapLE16(swaprr); + *(ptr++) = (Sint16) SDL_SwapLE16(swaplr); + *(ptr++) = (Sint16) SDL_SwapLE16(swapr); + *(ptr++) = (Sint16) SDL_SwapLE16(swapl); + break; + case 270: + *(ptr++) = (Sint16) SDL_SwapLE16(swaplr); + *(ptr++) = (Sint16) SDL_SwapLE16(swapl); + *(ptr++) = (Sint16) SDL_SwapLE16(swaprr); + *(ptr++) = (Sint16) SDL_SwapLE16(swapr); + break; + } + } +} + +static void SDLCALL _Eff_position_s16lsb_c6(int chan, void *stream, int len, void *udata) +{ + /* 16 signed bits (lsb) * 6 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint16 *ptr = (Sint16 *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (Sint16) * 6) { + Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) * + args->right_f) * args->distance_f); + Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+2))) * + args->left_rear_f) * args->distance_f); + Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+3))) * + args->right_rear_f) * args->distance_f); + Sint16 swapce = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+4))) * + args->center_f) * args->distance_f); + Sint16 swapwf = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+5))) * + args->lfe_f) * args->distance_f); + switch (args->room_angle) { + case 0: + *(ptr++) = (Sint16) SDL_SwapLE16(swapl); + *(ptr++) = (Sint16) SDL_SwapLE16(swapr); + *(ptr++) = (Sint16) SDL_SwapLE16(swaplr); + *(ptr++) = (Sint16) SDL_SwapLE16(swaprr); + *(ptr++) = (Sint16) SDL_SwapLE16(swapce); + *(ptr++) = (Sint16) SDL_SwapLE16(swapwf); + break; + case 90: + *(ptr++) = (Sint16) SDL_SwapLE16(swapr); + *(ptr++) = (Sint16) SDL_SwapLE16(swaprr); + *(ptr++) = (Sint16) SDL_SwapLE16(swapl); + *(ptr++) = (Sint16) SDL_SwapLE16(swaplr); + *(ptr++) = (Sint16) SDL_SwapLE16(swapr)/2 + (Sint16) SDL_SwapLE16(swaprr)/2; + *(ptr++) = (Sint16) SDL_SwapLE16(swapwf); + break; + case 180: + *(ptr++) = (Sint16) SDL_SwapLE16(swaprr); + *(ptr++) = (Sint16) SDL_SwapLE16(swaplr); + *(ptr++) = (Sint16) SDL_SwapLE16(swapr); + *(ptr++) = (Sint16) SDL_SwapLE16(swapl); + *(ptr++) = (Sint16) SDL_SwapLE16(swaprr)/2 + (Sint16) SDL_SwapLE16(swaplr)/2; + *(ptr++) = (Sint16) SDL_SwapLE16(swapwf); + break; + case 270: + *(ptr++) = (Sint16) SDL_SwapLE16(swaplr); + *(ptr++) = (Sint16) SDL_SwapLE16(swapl); + *(ptr++) = (Sint16) SDL_SwapLE16(swaprr); + *(ptr++) = (Sint16) SDL_SwapLE16(swapr); + *(ptr++) = (Sint16) SDL_SwapLE16(swapl)/2 + (Sint16) SDL_SwapLE16(swaplr)/2; + *(ptr++) = (Sint16) SDL_SwapLE16(swapwf); + break; + } + } +} + +static void SDLCALL _Eff_position_u16msb(int chan, void *stream, int len, void *udata) +{ + /* 16 signed bits (lsb) * 2 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Uint16 *ptr = (Uint16 *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (Sint16) * 2) { + Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768); + Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768); + + Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f) + * args->distance_f) + 32768); + Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f) + * args->distance_f) + 32768); + + if (args->room_angle == 180) { + *(ptr++) = (Uint16) SDL_SwapBE16(swapr); + *(ptr++) = (Uint16) SDL_SwapBE16(swapl); + } + else { + *(ptr++) = (Uint16) SDL_SwapBE16(swapl); + *(ptr++) = (Uint16) SDL_SwapBE16(swapr); + } + } +} + +static void SDLCALL _Eff_position_u16msb_c4(int chan, void *stream, int len, void *udata) +{ + /* 16 signed bits (lsb) * 4 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Uint16 *ptr = (Uint16 *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (Sint16) * 4) { + Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768); + Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768); + Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768); + Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768); + + Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f) + * args->distance_f) + 32768); + Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f) + * args->distance_f) + 32768); + Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f) + * args->distance_f) + 32768); + Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f) + * args->distance_f) + 32768); + + switch (args->room_angle) { + case 0: + *(ptr++) = (Uint16) SDL_SwapBE16(swapl); + *(ptr++) = (Uint16) SDL_SwapBE16(swapr); + *(ptr++) = (Uint16) SDL_SwapBE16(swaplr); + *(ptr++) = (Uint16) SDL_SwapBE16(swaprr); + break; + case 90: + *(ptr++) = (Uint16) SDL_SwapBE16(swapr); + *(ptr++) = (Uint16) SDL_SwapBE16(swaprr); + *(ptr++) = (Uint16) SDL_SwapBE16(swapl); + *(ptr++) = (Uint16) SDL_SwapBE16(swaplr); + break; + case 180: + *(ptr++) = (Uint16) SDL_SwapBE16(swaprr); + *(ptr++) = (Uint16) SDL_SwapBE16(swaplr); + *(ptr++) = (Uint16) SDL_SwapBE16(swapr); + *(ptr++) = (Uint16) SDL_SwapBE16(swapl); + break; + case 270: + *(ptr++) = (Uint16) SDL_SwapBE16(swaplr); + *(ptr++) = (Uint16) SDL_SwapBE16(swapl); + *(ptr++) = (Uint16) SDL_SwapBE16(swaprr); + *(ptr++) = (Uint16) SDL_SwapBE16(swapr); + break; + } + } +} + +static void SDLCALL _Eff_position_u16msb_c6(int chan, void *stream, int len, void *udata) +{ + /* 16 signed bits (lsb) * 6 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Uint16 *ptr = (Uint16 *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (Sint16) * 6) { + Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768); + Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768); + Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768); + Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768); + Sint16 sampce = (Sint16) (SDL_SwapBE16(*(ptr+4)) - 32768); + Sint16 sampwf = (Sint16) (SDL_SwapBE16(*(ptr+5)) - 32768); + + Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f) + * args->distance_f) + 32768); + Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f) + * args->distance_f) + 32768); + Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f) + * args->distance_f) + 32768); + Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f) + * args->distance_f) + 32768); + Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f) + * args->distance_f) + 32768); + Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f) + * args->distance_f) + 32768); + + switch (args->room_angle) { + case 0: + *(ptr++) = (Uint16) SDL_SwapBE16(swapl); + *(ptr++) = (Uint16) SDL_SwapBE16(swapr); + *(ptr++) = (Uint16) SDL_SwapBE16(swaplr); + *(ptr++) = (Uint16) SDL_SwapBE16(swaprr); + *(ptr++) = (Uint16) SDL_SwapBE16(swapce); + *(ptr++) = (Uint16) SDL_SwapBE16(swapwf); + break; + case 90: + *(ptr++) = (Uint16) SDL_SwapBE16(swapr); + *(ptr++) = (Uint16) SDL_SwapBE16(swaprr); + *(ptr++) = (Uint16) SDL_SwapBE16(swapl); + *(ptr++) = (Uint16) SDL_SwapBE16(swaplr); + *(ptr++) = (Uint16) SDL_SwapBE16(swapr)/2 + (Uint16) SDL_SwapBE16(swaprr)/2; + *(ptr++) = (Uint16) SDL_SwapBE16(swapwf); + break; + case 180: + *(ptr++) = (Uint16) SDL_SwapBE16(swaprr); + *(ptr++) = (Uint16) SDL_SwapBE16(swaplr); + *(ptr++) = (Uint16) SDL_SwapBE16(swapr); + *(ptr++) = (Uint16) SDL_SwapBE16(swapl); + *(ptr++) = (Uint16) SDL_SwapBE16(swaprr)/2 + (Uint16) SDL_SwapBE16(swaplr)/2; + *(ptr++) = (Uint16) SDL_SwapBE16(swapwf); + break; + case 270: + *(ptr++) = (Uint16) SDL_SwapBE16(swaplr); + *(ptr++) = (Uint16) SDL_SwapBE16(swapl); + *(ptr++) = (Uint16) SDL_SwapBE16(swaprr); + *(ptr++) = (Uint16) SDL_SwapBE16(swapr); + *(ptr++) = (Uint16) SDL_SwapBE16(swapl)/2 + (Uint16) SDL_SwapBE16(swaplr)/2; + *(ptr++) = (Uint16) SDL_SwapBE16(swapwf); + break; + } + } +} + +static void SDLCALL _Eff_position_s16msb(int chan, void *stream, int len, void *udata) +{ + /* 16 signed bits (lsb) * 2 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint16 *ptr = (Sint16 *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (Sint16) * 2) { + Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) * + args->right_f) * args->distance_f); + *(ptr++) = (Sint16) SDL_SwapBE16(swapl); + *(ptr++) = (Sint16) SDL_SwapBE16(swapr); + } +} + +static void SDLCALL _Eff_position_s16msb_c4(int chan, void *stream, int len, void *udata) +{ + /* 16 signed bits (lsb) * 4 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint16 *ptr = (Sint16 *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (Sint16) * 4) { + Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) * + args->right_f) * args->distance_f); + Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+2))) * + args->left_rear_f) * args->distance_f); + Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+3))) * + args->right_rear_f) * args->distance_f); + switch (args->room_angle) { + case 0: + *(ptr++) = (Sint16) SDL_SwapBE16(swapl); + *(ptr++) = (Sint16) SDL_SwapBE16(swapr); + *(ptr++) = (Sint16) SDL_SwapBE16(swaplr); + *(ptr++) = (Sint16) SDL_SwapBE16(swaprr); + break; + case 90: + *(ptr++) = (Sint16) SDL_SwapBE16(swapr); + *(ptr++) = (Sint16) SDL_SwapBE16(swaprr); + *(ptr++) = (Sint16) SDL_SwapBE16(swapl); + *(ptr++) = (Sint16) SDL_SwapBE16(swaplr); + break; + case 180: + *(ptr++) = (Sint16) SDL_SwapBE16(swaprr); + *(ptr++) = (Sint16) SDL_SwapBE16(swaplr); + *(ptr++) = (Sint16) SDL_SwapBE16(swapr); + *(ptr++) = (Sint16) SDL_SwapBE16(swapl); + break; + case 270: + *(ptr++) = (Sint16) SDL_SwapBE16(swaplr); + *(ptr++) = (Sint16) SDL_SwapBE16(swapl); + *(ptr++) = (Sint16) SDL_SwapBE16(swaprr); + *(ptr++) = (Sint16) SDL_SwapBE16(swapr); + break; + } + } +} + +static void SDLCALL _Eff_position_s16msb_c6(int chan, void *stream, int len, void *udata) +{ + /* 16 signed bits (lsb) * 6 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint16 *ptr = (Sint16 *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (Sint16) * 6) { + Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) * + args->right_f) * args->distance_f); + Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+2))) * + args->left_rear_f) * args->distance_f); + Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+3))) * + args->right_rear_f) * args->distance_f); + Sint16 swapce = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+4))) * + args->center_f) * args->distance_f); + Sint16 swapwf = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+5))) * + args->lfe_f) * args->distance_f); + + switch (args->room_angle) { + case 0: + *(ptr++) = (Sint16) SDL_SwapBE16(swapl); + *(ptr++) = (Sint16) SDL_SwapBE16(swapr); + *(ptr++) = (Sint16) SDL_SwapBE16(swaplr); + *(ptr++) = (Sint16) SDL_SwapBE16(swaprr); + *(ptr++) = (Sint16) SDL_SwapBE16(swapce); + *(ptr++) = (Sint16) SDL_SwapBE16(swapwf); + break; + case 90: + *(ptr++) = (Sint16) SDL_SwapBE16(swapr); + *(ptr++) = (Sint16) SDL_SwapBE16(swaprr); + *(ptr++) = (Sint16) SDL_SwapBE16(swapl); + *(ptr++) = (Sint16) SDL_SwapBE16(swaplr); + *(ptr++) = (Sint16) SDL_SwapBE16(swapr)/2 + (Sint16) SDL_SwapBE16(swaprr)/2; + *(ptr++) = (Sint16) SDL_SwapBE16(swapwf); + break; + case 180: + *(ptr++) = (Sint16) SDL_SwapBE16(swaprr); + *(ptr++) = (Sint16) SDL_SwapBE16(swaplr); + *(ptr++) = (Sint16) SDL_SwapBE16(swapr); + *(ptr++) = (Sint16) SDL_SwapBE16(swapl); + *(ptr++) = (Sint16) SDL_SwapBE16(swaprr)/2 + (Sint16) SDL_SwapBE16(swaplr)/2; + *(ptr++) = (Sint16) SDL_SwapBE16(swapwf); + break; + case 270: + *(ptr++) = (Sint16) SDL_SwapBE16(swaplr); + *(ptr++) = (Sint16) SDL_SwapBE16(swapl); + *(ptr++) = (Sint16) SDL_SwapBE16(swaprr); + *(ptr++) = (Sint16) SDL_SwapBE16(swapr); + *(ptr++) = (Sint16) SDL_SwapBE16(swapl)/2 + (Sint16) SDL_SwapBE16(swaplr)/2; + *(ptr++) = (Sint16) SDL_SwapBE16(swapwf); + break; + } + } +} + +static void SDLCALL _Eff_position_s32lsb(int chan, void *stream, int len, void *udata) +{ + /* 32 signed bits (lsb) * 2 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint32 *ptr = (Sint32 *) stream; + int i; + + (void)chan; + +#if 0 + if (len % (int)(sizeof(Sint32) * 2)) { + fprintf(stderr,"Not an even number of frames! len=%d\n", len); + return; + } +#endif + + for (i = 0; i < len; i += sizeof (Sint32) * 2) { + Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) * + args->right_f) * args->distance_f); + if (args->room_angle == 180) { + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + } + else { + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + } + } +} + +static void SDLCALL _Eff_position_s32lsb_c4(int chan, void *stream, int len, void *udata) +{ + /* 32 signed bits (lsb) * 4 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint32 *ptr = (Sint32 *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (Sint32) * 4) { + Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) * + args->right_f) * args->distance_f); + Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) * + args->left_rear_f) * args->distance_f); + Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+2))) * + args->right_rear_f) * args->distance_f); + switch (args->room_angle) { + case 0: + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); + break; + case 90: + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); + break; + case 180: + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + break; + case 270: + *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + break; + } + } +} + +static void SDLCALL _Eff_position_s32lsb_c6(int chan, void *stream, int len, void *udata) +{ + /* 32 signed bits (lsb) * 6 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint32 *ptr = (Sint32 *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (Sint32) * 6) { + Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) * + args->right_f) * args->distance_f); + Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+2))) * + args->left_rear_f) * args->distance_f); + Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+3))) * + args->right_rear_f) * args->distance_f); + Sint32 swapce = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+4))) * + args->center_f) * args->distance_f); + Sint32 swapwf = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+5))) * + args->lfe_f) * args->distance_f); + switch (args->room_angle) { + case 0: + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapce); + *(ptr++) = (Sint32) SDL_SwapLE32(swapwf); + break; + case 90: + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapr)/2 + (Sint32) SDL_SwapLE32(swaprr)/2; + *(ptr++) = (Sint32) SDL_SwapLE32(swapwf); + break; + case 180: + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr)/2 + (Sint32) SDL_SwapLE32(swaplr)/2; + *(ptr++) = (Sint32) SDL_SwapLE32(swapwf); + break; + case 270: + *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapl)/2 + (Sint32) SDL_SwapLE32(swaplr)/2; + *(ptr++) = (Sint32) SDL_SwapLE32(swapwf); + break; + } + } +} + +static void SDLCALL _Eff_position_s32msb(int chan, void *stream, int len, void *udata) +{ + /* 32 signed bits (lsb) * 2 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint32 *ptr = (Sint32 *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (Sint32) * 2) { + Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) * + args->right_f) * args->distance_f); + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + } +} + +static void SDLCALL _Eff_position_s32msb_c4(int chan, void *stream, int len, void *udata) +{ + /* 32 signed bits (lsb) * 4 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint32 *ptr = (Sint32 *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (Sint32) * 4) { + Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) * + args->right_f) * args->distance_f); + Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+2))) * + args->left_rear_f) * args->distance_f); + Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+3))) * + args->right_rear_f) * args->distance_f); + switch (args->room_angle) { + case 0: + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); + break; + case 90: + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); + break; + case 180: + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + break; + case 270: + *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + break; + } + } +} + +static void SDLCALL _Eff_position_s32msb_c6(int chan, void *stream, int len, void *udata) +{ + /* 32 signed bits (lsb) * 6 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint32 *ptr = (Sint32 *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (Sint32) * 6) { + Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) * + args->right_f) * args->distance_f); + Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+2))) * + args->left_rear_f) * args->distance_f); + Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+3))) * + args->right_rear_f) * args->distance_f); + Sint32 swapce = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+4))) * + args->center_f) * args->distance_f); + Sint32 swapwf = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+5))) * + args->lfe_f) * args->distance_f); + + switch (args->room_angle) { + case 0: + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapce); + *(ptr++) = (Sint32) SDL_SwapBE32(swapwf); + break; + case 90: + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapr)/2 + (Sint32) SDL_SwapBE32(swaprr)/2; + *(ptr++) = (Sint32) SDL_SwapBE32(swapwf); + break; + case 180: + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr)/2 + (Sint32) SDL_SwapBE32(swaplr)/2; + *(ptr++) = (Sint32) SDL_SwapBE32(swapwf); + break; + case 270: + *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapl)/2 + (Sint32) SDL_SwapBE32(swaplr)/2; + *(ptr++) = (Sint32) SDL_SwapBE32(swapwf); + break; + } + } +} + +static void SDLCALL _Eff_position_f32sys(int chan, void *stream, int len, void *udata) +{ + /* float * 2 channels. */ + volatile position_args *args = (volatile position_args *) udata; + float *ptr = (float *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (float) * 2) { + float swapl = ((*(ptr+0) * args->left_f) * args->distance_f); + float swapr = ((*(ptr+1) * args->right_f) * args->distance_f); + *(ptr++) = swapl; + *(ptr++) = swapr; + } +} + +static void SDLCALL _Eff_position_f32sys_c4(int chan, void *stream, int len, void *udata) +{ + /* float * 4 channels. */ + volatile position_args *args = (volatile position_args *) udata; + float *ptr = (float *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (float) * 4) { + float swapl = ((*(ptr+0) * args->left_f) * args->distance_f); + float swapr = ((*(ptr+1) * args->right_f) * args->distance_f); + float swaplr = ((*(ptr+2) * args->left_rear_f) * args->distance_f); + float swaprr = ((*(ptr+3) * args->right_rear_f) * args->distance_f); + switch (args->room_angle) { + case 0: + *(ptr++) = swapl; + *(ptr++) = swapr; + *(ptr++) = swaplr; + *(ptr++) = swaprr; + break; + case 90: + *(ptr++) = swapr; + *(ptr++) = swaprr; + *(ptr++) = swapl; + *(ptr++) = swaplr; + break; + case 180: + *(ptr++) = swaprr; + *(ptr++) = swaplr; + *(ptr++) = swapr; + *(ptr++) = swapl; + break; + case 270: + *(ptr++) = swaplr; + *(ptr++) = swapl; + *(ptr++) = swaprr; + *(ptr++) = swapr; + break; + } + } +} + +static void SDLCALL _Eff_position_f32sys_c6(int chan, void *stream, int len, void *udata) +{ + /* float * 6 channels. */ + volatile position_args *args = (volatile position_args *) udata; + float *ptr = (float *) stream; + int i; + + (void)chan; + + for (i = 0; i < len; i += sizeof (float) * 6) { + float swapl = ((*(ptr+0) * args->left_f) * args->distance_f); + float swapr = ((*(ptr+1) * args->right_f) * args->distance_f); + float swaplr = ((*(ptr+2) * args->left_rear_f) * args->distance_f); + float swaprr = ((*(ptr+3) * args->right_rear_f) * args->distance_f); + float swapce = ((*(ptr+4) * args->center_f) * args->distance_f); + float swapwf = ((*(ptr+5) * args->lfe_f) * args->distance_f); + + switch (args->room_angle) { + case 0: + *(ptr++) = swapl; + *(ptr++) = swapr; + *(ptr++) = swaplr; + *(ptr++) = swaprr; + *(ptr++) = swapce; + *(ptr++) = swapwf; + break; + case 90: + *(ptr++) = swapr; + *(ptr++) = swaprr; + *(ptr++) = swapl; + *(ptr++) = swaplr; + *(ptr++) = swapr/2.0f + swaprr/2.0f; + *(ptr++) = swapwf; + break; + case 180: + *(ptr++) = swaprr; + *(ptr++) = swaplr; + *(ptr++) = swapr; + *(ptr++) = swapl; + *(ptr++) = swaprr/2.0f + swaplr/2.0f; + *(ptr++) = swapwf; + break; + case 270: + *(ptr++) = swaplr; + *(ptr++) = swapl; + *(ptr++) = swaprr; + *(ptr++) = swapr; + *(ptr++) = swapl/2.0f + swaplr/2.0f; + *(ptr++) = swapwf; + break; + } + } +} + +static void init_position_args(position_args *args) +{ + SDL_memset(args, '\0', sizeof (position_args)); + args->in_use = 0; + args->room_angle = 0; + args->left_u8 = args->right_u8 = args->distance_u8 = 255; + args->left_f = args->right_f = args->distance_f = 1.0f; + args->left_rear_u8 = args->right_rear_u8 = args->center_u8 = args->lfe_u8 = 255; + args->left_rear_f = args->right_rear_f = args->center_f = args->lfe_f = 1.0f; + Mix_QuerySpec(NULL, NULL, (int *) &args->channels); +} + +static position_args *get_position_arg(int channel) +{ + void *rc; + int i; + + if (channel < 0) { + if (pos_args_global == NULL) { + pos_args_global = SDL_malloc(sizeof (position_args)); + if (pos_args_global == NULL) { + Mix_SetError("Out of memory"); + return(NULL); + } + init_position_args(pos_args_global); + } + + return(pos_args_global); + } + + if (channel >= position_channels) { + rc = SDL_realloc(pos_args_array, (size_t)(channel + 1) * sizeof(position_args *)); + if (rc == NULL) { + Mix_SetError("Out of memory"); + return(NULL); + } + pos_args_array = (position_args **) rc; + for (i = position_channels; i <= channel; i++) { + pos_args_array[i] = NULL; + } + position_channels = channel + 1; + } + + if (pos_args_array[channel] == NULL) { + pos_args_array[channel] = (position_args *)SDL_malloc(sizeof(position_args)); + if (pos_args_array[channel] == NULL) { + Mix_SetError("Out of memory"); + return(NULL); + } + init_position_args(pos_args_array[channel]); + } + + return(pos_args_array[channel]); +} + +static Mix_EffectFunc_t get_position_effect_func(Uint16 format, int channels) +{ + Mix_EffectFunc_t f = NULL; + + switch (format) { + case AUDIO_U8: + switch (channels) { + case 1: + case 2: + f = (_Eff_build_volume_table_u8()) ? _Eff_position_table_u8 : + _Eff_position_u8; + break; + case 4: + f = _Eff_position_u8_c4; + break; + case 6: + f = _Eff_position_u8_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; + + case AUDIO_S8: + switch (channels) { + case 1: + case 2: + f = (_Eff_build_volume_table_s8()) ? _Eff_position_table_s8 : + _Eff_position_s8; + break; + case 4: + f = _Eff_position_s8_c4; + break; + case 6: + f = _Eff_position_s8_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; + + case AUDIO_U16LSB: + switch (channels) { + case 1: + case 2: + f = _Eff_position_u16lsb; + break; + case 4: + f = _Eff_position_u16lsb_c4; + break; + case 6: + f = _Eff_position_u16lsb_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; + + case AUDIO_S16LSB: + switch (channels) { + case 1: + case 2: + f = _Eff_position_s16lsb; + break; + case 4: + f = _Eff_position_s16lsb_c4; + break; + case 6: + f = _Eff_position_s16lsb_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; + + case AUDIO_U16MSB: + switch (channels) { + case 1: + case 2: + f = _Eff_position_u16msb; + break; + case 4: + f = _Eff_position_u16msb_c4; + break; + case 6: + f = _Eff_position_u16msb_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; + + case AUDIO_S16MSB: + switch (channels) { + case 1: + case 2: + f = _Eff_position_s16msb; + break; + case 4: + f = _Eff_position_s16msb_c4; + break; + case 6: + f = _Eff_position_s16msb_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; + + case AUDIO_S32MSB: + switch (channels) { + case 1: + case 2: + f = _Eff_position_s32msb; + break; + case 4: + f = _Eff_position_s32msb_c4; + break; + case 6: + f = _Eff_position_s32msb_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; + + case AUDIO_S32LSB: + switch (channels) { + case 1: + case 2: + f = _Eff_position_s32lsb; + break; + case 4: + f = _Eff_position_s32lsb_c4; + break; + case 6: + f = _Eff_position_s32lsb_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; + + case AUDIO_F32SYS: + switch (channels) { + case 1: + case 2: + f = _Eff_position_f32sys; + break; + case 4: + f = _Eff_position_f32sys_c4; + break; + case 6: + f = _Eff_position_f32sys_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; + + default: + Mix_SetError("Unsupported audio format"); + break; + } + + return(f); +} + +static Uint8 speaker_amplitude[6]; + +static void set_amplitudes(int channels, int angle, int room_angle) +{ + int left = 255, right = 255; + int left_rear = 255, right_rear = 255, center = 255; + + /* our only caller Mix_SetPosition() already makes angle between 0 and 359. */ + + if (channels == 2) + { + /* + * We only attenuate by position if the angle falls on the far side + * of center; That is, an angle that's due north would not attenuate + * either channel. Due west attenuates the right channel to 0.0, and + * due east attenuates the left channel to 0.0. Slightly east of + * center attenuates the left channel a little, and the right channel + * not at all. I think of this as occlusion by one's own head. :) + * + * ...so, we split our angle circle into four quadrants... + */ + if (angle < 90) { + left = 255 - ((int) (255.0f * (((float) angle) / 89.0f))); + } else if (angle < 180) { + left = (int) (255.0f * (((float) (angle - 90)) / 89.0f)); + } else if (angle < 270) { + right = 255 - ((int) (255.0f * (((float) (angle - 180)) / 89.0f))); + } else { + right = (int) (255.0f * (((float) (angle - 270)) / 89.0f)); + } + } + + if (channels == 4 || channels == 6) + { + /* + * An angle that's due north does not attenuate the center channel. + * An angle in the first quadrant, 0-90, does not attenuate the RF. + * + * ...so, we split our angle circle into 8 ... + * + * CE + * 0 + * LF | RF + * | + * 270<-------|----------->90 + * | + * LR | RR + * 180 + * + */ + if (angle < 45) { + left = ((int) (255.0f * (((float) (180 - angle)) / 179.0f))); + left_rear = 255 - ((int) (255.0f * (((float) (angle + 45)) / 89.0f))); + right_rear = 255 - ((int) (255.0f * (((float) (90 - angle)) / 179.0f))); + } else if (angle < 90) { + center = ((int) (255.0f * (((float) (225 - angle)) / 179.0f))); + left = ((int) (255.0f * (((float) (180 - angle)) / 179.0f))); + left_rear = 255 - ((int) (255.0f * (((float) (135 - angle)) / 89.0f))); + right_rear = ((int) (255.0f * (((float) (90 + angle)) / 179.0f))); + } else if (angle < 135) { + center = ((int) (255.0f * (((float) (225 - angle)) / 179.0f))); + left = 255 - ((int) (255.0f * (((float) (angle - 45)) / 89.0f))); + right = ((int) (255.0f * (((float) (270 - angle)) / 179.0f))); + left_rear = ((int) (255.0f * (((float) (angle)) / 179.0f))); + } else if (angle < 180) { + center = 255 - ((int) (255.0f * (((float) (angle - 90)) / 89.0f))); + left = 255 - ((int) (255.0f * (((float) (225 - angle)) / 89.0f))); + right = ((int) (255.0f * (((float) (270 - angle)) / 179.0f))); + left_rear = ((int) (255.0f * (((float) (angle)) / 179.0f))); + } else if (angle < 225) { + center = 255 - ((int) (255.0f * (((float) (270 - angle)) / 89.0f))); + left = ((int) (255.0f * (((float) (angle - 90)) / 179.0f))); + right = 255 - ((int) (255.0f * (((float) (angle - 135)) / 89.0f))); + right_rear = ((int) (255.0f * (((float) (360 - angle)) / 179.0f))); + } else if (angle < 270) { + center = ((int) (255.0f * (((float) (angle - 135)) / 179.0f))); + left = ((int) (255.0f * (((float) (angle - 90)) / 179.0f))); + right = 255 - ((int) (255.0f * (((float) (315 - angle)) / 89.0f))); + right_rear = ((int) (255.0f * (((float) (360 - angle)) / 179.0f))); + } else if (angle < 315) { + center = ((int) (255.0f * (((float) (angle - 135)) / 179.0f))); + right = ((int) (255.0f * (((float) (angle - 180)) / 179.0f))); + left_rear = ((int) (255.0f * (((float) (450 - angle)) / 179.0f))); + right_rear = 255 - ((int) (255.0f * (((float) (angle - 225)) / 89.0f))); + } else { + right = ((int) (255.0f * (((float) (angle - 180)) / 179.0f))); + left_rear = ((int) (255.0f * (((float) (450 - angle)) / 179.0f))); + right_rear = 255 - ((int) (255.0f * (((float) (405 - angle)) / 89.0f))); + } + } + + if (left < 0) left = 0; + if (left > 255) left = 255; + if (right < 0) right = 0; + if (right > 255) right = 255; + if (left_rear < 0) left_rear = 0; + if (left_rear > 255) left_rear = 255; + if (right_rear < 0) right_rear = 0; + if (right_rear > 255) right_rear = 255; + if (center < 0) center = 0; + if (center > 255) center = 255; + + if (room_angle == 90) { + speaker_amplitude[0] = (Uint8)left_rear; + speaker_amplitude[1] = (Uint8)left; + speaker_amplitude[2] = (Uint8)right_rear; + speaker_amplitude[3] = (Uint8)right; + } + else if (room_angle == 180) { + if (channels == 2) { + speaker_amplitude[0] = (Uint8)right; + speaker_amplitude[1] = (Uint8)left; + } + else { + speaker_amplitude[0] = (Uint8)right_rear; + speaker_amplitude[1] = (Uint8)left_rear; + speaker_amplitude[2] = (Uint8)right; + speaker_amplitude[3] = (Uint8)left; + } + } + else if (room_angle == 270) { + speaker_amplitude[0] = (Uint8)right; + speaker_amplitude[1] = (Uint8)right_rear; + speaker_amplitude[2] = (Uint8)left; + speaker_amplitude[3] = (Uint8)left_rear; + } + else { + speaker_amplitude[0] = (Uint8)left; + speaker_amplitude[1] = (Uint8)right; + speaker_amplitude[2] = (Uint8)left_rear; + speaker_amplitude[3] = (Uint8)right_rear; + } + speaker_amplitude[4] = (Uint8)center; + speaker_amplitude[5] = 255; +} + +int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance); + +int Mix_SetPanning(int channel, Uint8 left, Uint8 right) +{ + Mix_EffectFunc_t f = NULL; + int channels; + Uint16 format; + position_args *args = NULL; + int retval = 1; + + Mix_QuerySpec(NULL, &format, &channels); + + if (channels != 2 && channels != 4 && channels != 6) /* it's a no-op; we call that successful. */ + return(1); + + if (channels > 2) { + /* left = right = 255 => angle = 0, to unregister effect as when channels = 2 */ + /* left = 255 => angle = -90; left = 0 => angle = +89 */ + int angle = 0; + if ((left != 255) || (right != 255)) { + angle = (int)left; + angle = 127 - angle; + angle = -angle; + angle = angle * 90 / 128; /* Make it larger for more effect? */ + } + return Mix_SetPosition(channel, angle, 0); + } + + f = get_position_effect_func(format, channels); + if (f == NULL) + return(0); + + Mix_LockAudio(); + args = get_position_arg(channel); + if (!args) { + Mix_UnlockAudio(); + return(0); + } + + /* it's a no-op; unregister the effect, if it's registered. */ + if ((args->distance_u8 == 255) && (left == 255) && (right == 255)) { + if (args->in_use) { + retval = _Mix_UnregisterEffect_locked(channel, f); + Mix_UnlockAudio(); + return(retval); + } else { + Mix_UnlockAudio(); + return(1); + } + } + + args->left_u8 = left; + args->left_f = ((float) left) / 255.0f; + args->right_u8 = right; + args->right_f = ((float) right) / 255.0f; + args->room_angle = 0; + + if (!args->in_use) { + args->in_use = 1; + retval=_Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void*)args); + } + + Mix_UnlockAudio(); + return(retval); +} + + +int Mix_SetDistance(int channel, Uint8 distance) +{ + Mix_EffectFunc_t f = NULL; + Uint16 format; + position_args *args = NULL; + int channels; + int retval = 1; + + Mix_QuerySpec(NULL, &format, &channels); + f = get_position_effect_func(format, channels); + if (f == NULL) + return(0); + + Mix_LockAudio(); + args = get_position_arg(channel); + if (!args) { + Mix_UnlockAudio(); + return(0); + } + + distance = 255 - distance; /* flip it to our scale. */ + + /* it's a no-op; unregister the effect, if it's registered. */ + if ((distance == 255) && (args->left_u8 == 255) && (args->right_u8 == 255)) { + if (args->in_use) { + retval = _Mix_UnregisterEffect_locked(channel, f); + Mix_UnlockAudio(); + return(retval); + } else { + Mix_UnlockAudio(); + return(1); + } + } + + args->distance_u8 = distance; + args->distance_f = ((float) distance) / 255.0f; + if (!args->in_use) { + args->in_use = 1; + retval = _Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void *) args); + } + + Mix_UnlockAudio(); + return(retval); +} + + +int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance) +{ + Mix_EffectFunc_t f = NULL; + Uint16 format; + int channels; + position_args *args = NULL; + Sint16 room_angle = 0; + int retval = 1; + + Mix_QuerySpec(NULL, &format, &channels); + f = get_position_effect_func(format, channels); + if (f == NULL) + return(0); + + /* make angle between 0 and 359. */ + angle %= 360; + if (angle < 0) angle += 360; + + Mix_LockAudio(); + args = get_position_arg(channel); + if (!args) { + Mix_UnlockAudio(); + return(0); + } + + /* it's a no-op; unregister the effect, if it's registered. */ + if ((!distance) && (!angle)) { + if (args->in_use) { + retval = _Mix_UnregisterEffect_locked(channel, f); + Mix_UnlockAudio(); + return(retval); + } else { + Mix_UnlockAudio(); + return(1); + } + } + + if (channels == 2) + { + if (angle > 180) + room_angle = 180; /* exchange left and right channels */ + else room_angle = 0; + } + + if (channels == 4 || channels == 6) + { + if (angle > 315) room_angle = 0; + else if (angle > 225) room_angle = 270; + else if (angle > 135) room_angle = 180; + else if (angle > 45) room_angle = 90; + else room_angle = 0; + } + + distance = 255 - distance; /* flip it to scale Mix_SetDistance() uses. */ + + set_amplitudes(channels, angle, room_angle); + + args->left_u8 = speaker_amplitude[0]; + args->left_f = ((float) speaker_amplitude[0]) / 255.0f; + args->right_u8 = speaker_amplitude[1]; + args->right_f = ((float) speaker_amplitude[1]) / 255.0f; + args->left_rear_u8 = speaker_amplitude[2]; + args->left_rear_f = ((float) speaker_amplitude[2]) / 255.0f; + args->right_rear_u8 = speaker_amplitude[3]; + args->right_rear_f = ((float) speaker_amplitude[3]) / 255.0f; + args->center_u8 = speaker_amplitude[4]; + args->center_f = ((float) speaker_amplitude[4]) / 255.0f; + args->lfe_u8 = speaker_amplitude[5]; + args->lfe_f = ((float) speaker_amplitude[5]) / 255.0f; + args->distance_u8 = distance; + args->distance_f = ((float) distance) / 255.0f; + args->room_angle = room_angle; + if (!args->in_use) { + args->in_use = 1; + retval = _Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void *) args); + } + + Mix_UnlockAudio(); + return(retval); +} + +/* end of effects_position.c ... */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/effect_stereoreverse.c b/src/effect_stereoreverse.c new file mode 100644 index 0000000..35b850c --- /dev/null +++ b/src/effect_stereoreverse.c @@ -0,0 +1,138 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + This file by Ryan C. Gordon (icculus@icculus.org) + + These are some internally supported special effects that use SDL_mixer's + effect callback API. They are meant for speed over quality. :) +*/ + +#include "SDL_mixer.h" + +#define MIX_INTERNAL_EFFECT__ +#include "effects_internal.h" + +/* profile code: + #include + #include + struct timeval tv1; + struct timeval tv2; + + gettimeofday(&tv1, NULL); + + ... do your thing here ... + + gettimeofday(&tv2, NULL); + printf("%ld\n", tv2.tv_usec - tv1.tv_usec); +*/ + + +/* + * Stereo reversal effect...this one's pretty straightforward... + */ + +static void SDLCALL _Eff_reversestereo32(int chan, void *stream, int len, void *udata) +{ + /* 16 bits * 2 channels. */ + Uint32 *ptr = (Uint32 *) stream; + Uint32 tmp; + int i; + + (void)chan; + (void)udata; + + for (i = 0; i < len; i += 2 * sizeof (Uint32), ptr += 2) { + tmp = ptr[0]; + ptr[0] = ptr[1]; + ptr[1] = tmp; + } +} + +static void SDLCALL _Eff_reversestereo16(int chan, void *stream, int len, void *udata) +{ + /* 16 bits * 2 channels. */ + Uint32 *ptr = (Uint32 *) stream; + int i; + + (void)chan; + (void)udata; + + for (i = 0; i < len; i += sizeof (Uint32), ptr++) { + *ptr = (((*ptr) & 0xFFFF0000) >> 16) | (((*ptr) & 0x0000FFFF) << 16); + } +} + +static void SDLCALL _Eff_reversestereo8(int chan, void *stream, int len, void *udata) +{ + /* 8 bits * 2 channels. */ + Uint32 *ptr = (Uint32 *) stream; + int i; + + (void)chan; + (void)udata; + + /* get the last two bytes if len is not divisible by four... */ + if (len % (int)sizeof(Uint32) != 0) { + Uint16 *p = (Uint16 *) (((Uint8 *) stream) + (len - 2)); + *p = (Uint16)((((*p) & 0xFF00) >> 8) | (((*ptr) & 0x00FF) << 8)); + len -= 2; + } + + for (i = 0; i < len; i += sizeof (Uint32), ptr++) { + *ptr = (((*ptr) & 0x0000FF00) >> 8) | (((*ptr) & 0x000000FF) << 8) | + (((*ptr) & 0xFF000000) >> 8) | (((*ptr) & 0x00FF0000) << 8); + } +} + +int Mix_SetReverseStereo(int channel, int flip) +{ + Mix_EffectFunc_t f = NULL; + int channels; + Uint16 format; + + Mix_QuerySpec(NULL, &format, &channels); + + if (channels == 2) { + int bits = (format & 0xFF); + switch (bits) { + case 8: + f = _Eff_reversestereo8; + break; + case 16: + f = _Eff_reversestereo16; + break; + case 32: + f = _Eff_reversestereo32; + break; + default: + Mix_SetError("Unsupported audio format"); + return(0); + } + if (!flip) return Mix_UnregisterEffect(channel, f); + return(Mix_RegisterEffect(channel, f, NULL, NULL)); + } + + Mix_SetError("Trying to reverse stereo on a non-stereo stream"); + return(0); +} + +/* end of effect_stereoreverse.c ... */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/effects_internal.c b/src/effects_internal.c new file mode 100644 index 0000000..c1d7043 --- /dev/null +++ b/src/effects_internal.c @@ -0,0 +1,119 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + This file by Ryan C. Gordon (icculus@icculus.org) + + These are some helper functions for the internal mixer special effects. +*/ + + +/* ------ These are used internally only. Don't touch. ------ */ + +#include "SDL_mixer.h" + +#define MIX_INTERNAL_EFFECT__ +#include "effects_internal.h" + +/* Should we favor speed over memory usage and/or quality of output? */ +int _Mix_effects_max_speed = 0; + + +void _Mix_InitEffects(void) +{ + _Mix_effects_max_speed = (SDL_getenv(MIX_EFFECTSMAXSPEED) != NULL); +} + +void _Mix_DeinitEffects(void) +{ + _Eff_PositionDeinit(); +} + + +void *_Eff_volume_table = NULL; + + +/* Build the volume table for Uint8-format samples. + * + * Each column of the table is a possible sample, while each row of the + * table is a volume. Volume is a Uint8, where 0 is silence and 255 is full + * volume. So _Eff_volume_table[128][mysample] would be the value of + * mysample, at half volume. + */ +void *_Eff_build_volume_table_u8(void) +{ + int volume; + int sample; + Uint8 *rc; + + if (!_Mix_effects_max_speed) { + return(NULL); + } + + if (!_Eff_volume_table) { + rc = SDL_malloc(256 * 256); + if (rc) { + _Eff_volume_table = (void *) rc; + for (volume = 0; volume < 256; volume++) { + for (sample = -128; sample < 128; sample ++) { + *rc = (Uint8)(((float) sample) * ((float) volume / 255.0f)) + + 128; + rc++; + } + } + } + } + + return(_Eff_volume_table); +} + + +/* Build the volume table for Sint8-format samples. + * + * Each column of the table is a possible sample, while each row of the + * table is a volume. Volume is a Uint8, where 0 is silence and 255 is full + * volume. So _Eff_volume_table[128][mysample+128] would be the value of + * mysample, at half volume. + */ +void *_Eff_build_volume_table_s8(void) +{ + int volume; + int sample; + Sint8 *rc; + + if (!_Eff_volume_table) { + rc = SDL_malloc(256 * 256); + if (rc) { + _Eff_volume_table = (void *) rc; + for (volume = 0; volume < 256; volume++) { + for (sample = -128; sample < 128; sample ++) { + *rc = (Sint8)(((float) sample) * ((float) volume / 255.0f)); + rc++; + } + } + } + } + + return(_Eff_volume_table); +} + + +/* end of effects.c ... */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/effects_internal.h b/src/effects_internal.h new file mode 100644 index 0000000..70593a2 --- /dev/null +++ b/src/effects_internal.h @@ -0,0 +1,47 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef INCLUDE_EFFECTS_INTERNAL_H_ +#define INCLUDE_EFFECTS_INTERNAL_H_ + +#ifndef MIX_INTERNAL_EFFECT__ +#error You should not include this file or use these functions. +#endif + +#include "SDL_mixer.h" + +extern int _Mix_effects_max_speed; +extern void *_Eff_volume_table; +void *_Eff_build_volume_table_u8(void); +void *_Eff_build_volume_table_s8(void); + +void _Mix_InitEffects(void); +void _Mix_DeinitEffects(void); +void _Eff_PositionDeinit(void); + +int _Mix_RegisterEffect_locked(int channel, Mix_EffectFunc_t f, + Mix_EffectDone_t d, void *arg); +int _Mix_UnregisterEffect_locked(int channel, Mix_EffectFunc_t f); +int _Mix_UnregisterAllEffects_locked(int channel); + +#endif /* _INCLUDE_EFFECTS_INTERNAL_H_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/mixer.c b/src/mixer.c new file mode 100644 index 0000000..2ee0cf6 --- /dev/null +++ b/src/mixer.c @@ -0,0 +1,1617 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL.h" + +#include "SDL_mixer.h" +#include "mixer.h" +#include "music.h" +#include "load_aiff.h" +#include "load_voc.h" + +#define MIX_INTERNAL_EFFECT__ +#include "effects_internal.h" + +/* Magic numbers for various audio file formats */ +#define RIFF 0x46464952 /* "RIFF" */ +#define WAVE 0x45564157 /* "WAVE" */ +#define FORM 0x4d524f46 /* "FORM" */ +#define CREA 0x61657243 /* "Crea" */ + +static int audio_opened = 0; +static SDL_AudioSpec mixer; +static SDL_AudioDeviceID audio_device; + +typedef struct _Mix_effectinfo +{ + Mix_EffectFunc_t callback; + Mix_EffectDone_t done_callback; + void *udata; + struct _Mix_effectinfo *next; +} effect_info; + +static struct _Mix_Channel { + Mix_Chunk *chunk; + int playing; + int paused; + Uint8 *samples; + int volume; + int looping; + int tag; + Uint32 expire; + Uint32 start_time; + Mix_Fading fading; + int fade_volume; + int fade_volume_reset; + Uint32 fade_length; + Uint32 ticks_fade; + effect_info *effects; +} *mix_channel = NULL; + +static effect_info *posteffects = NULL; + +static int num_channels; +static int reserved_channels = 0; + + +/* Support for hooking into the mixer callback system */ +static void (SDLCALL *mix_postmix)(void *udata, Uint8 *stream, int len) = NULL; +static void *mix_postmix_data = NULL; + +/* rcg07062001 callback to alert when channels are done playing. */ +static void (SDLCALL *channel_done_callback)(int channel) = NULL; + +/* Support for user defined music functions */ +static void (SDLCALL *mix_music)(void *udata, Uint8 *stream, int len) = music_mixer; +static void *music_data = NULL; + +/* rcg06042009 report available decoders at runtime. */ +static const char **chunk_decoders = NULL; +static int num_decoders = 0; + + +int Mix_GetNumChunkDecoders(void) +{ + return(num_decoders); +} + +const char *Mix_GetChunkDecoder(int index) +{ + if ((index < 0) || (index >= num_decoders)) { + return NULL; + } + return(chunk_decoders[index]); +} + +SDL_bool Mix_HasChunkDecoder(const char *name) +{ + int index; + for (index = 0; index < num_decoders; ++index) { + if (SDL_strcasecmp(name, chunk_decoders[index]) == 0) { + return SDL_TRUE; + } + } + return SDL_FALSE; +} + +void add_chunk_decoder(const char *decoder) +{ + int i; + void *ptr; + + /* Check to see if we already have this decoder */ + for (i = 0; i < num_decoders; ++i) { + if (SDL_strcmp(chunk_decoders[i], decoder) == 0) { + return; + } + } + + ptr = SDL_realloc((void *)chunk_decoders, (size_t)(num_decoders + 1) * sizeof (const char *)); + if (ptr == NULL) { + return; /* oh well, go on without it. */ + } + chunk_decoders = (const char **) ptr; + chunk_decoders[num_decoders++] = decoder; +} + +/* rcg06192001 get linked library's version. */ +const SDL_version *Mix_Linked_Version(void) +{ + static SDL_version linked_version; + SDL_MIXER_VERSION(&linked_version); + return(&linked_version); +} + +int Mix_Init(int flags) +{ + int result = 0; + + if (flags & MIX_INIT_FLAC) { + if (load_music_type(MUS_FLAC)) { + open_music_type(MUS_FLAC); + result |= MIX_INIT_FLAC; + } else { + Mix_SetError("FLAC support not available"); + } + } + if (flags & MIX_INIT_MOD) { + if (load_music_type(MUS_MOD)) { + open_music_type(MUS_MOD); + result |= MIX_INIT_MOD; + } else { + Mix_SetError("MOD support not available"); + } + } + if (flags & MIX_INIT_MP3) { + if (load_music_type(MUS_MP3)) { + open_music_type(MUS_MP3); + result |= MIX_INIT_MP3; + } else { + Mix_SetError("MP3 support not available"); + } + } + if (flags & MIX_INIT_OGG) { + if (load_music_type(MUS_OGG)) { + open_music_type(MUS_OGG); + result |= MIX_INIT_OGG; + } else { + Mix_SetError("OGG support not available"); + } + } + if (flags & MIX_INIT_OPUS) { + if (load_music_type(MUS_OPUS)) { + open_music_type(MUS_OPUS); + result |= MIX_INIT_OPUS; + } else { + Mix_SetError("OPUS support not available"); + } + } + if (flags & MIX_INIT_MID) { + if (load_music_type(MUS_MID)) { + open_music_type(MUS_MID); + result |= MIX_INIT_MID; + } else { + Mix_SetError("MIDI support not available"); + } + } + return result; +} + +void Mix_Quit() +{ + unload_music(); +} + +static int _Mix_remove_all_effects(int channel, effect_info **e); + +/* + * rcg06122001 Cleanup effect callbacks. + * MAKE SURE Mix_LockAudio() is called before this (or you're in the + * audio callback). + */ +static void _Mix_channel_done_playing(int channel) +{ + if (channel_done_callback) { + channel_done_callback(channel); + } + + /* + * Call internal function directly, to avoid locking audio from + * inside audio callback. + */ + _Mix_remove_all_effects(channel, &mix_channel[channel].effects); +} + + +static void *Mix_DoEffects(int chan, void *snd, int len) +{ + int posteffect = (chan == MIX_CHANNEL_POST); + effect_info *e = ((posteffect) ? posteffects : mix_channel[chan].effects); + void *buf = snd; + + if (e != NULL) { /* are there any registered effects? */ + /* if this is the postmix, we can just overwrite the original. */ + if (!posteffect) { + buf = SDL_malloc((size_t)len); + if (buf == NULL) { + return(snd); + } + SDL_memcpy(buf, snd, (size_t)len); + } + + for (; e != NULL; e = e->next) { + if (e->callback != NULL) { + e->callback(chan, buf, len, e->udata); + } + } + } + + /* be sure to SDL_free() the return value if != snd ... */ + return(buf); +} + + +/* Mixing function */ +static void SDLCALL +mix_channels(void *udata, Uint8 *stream, int len) +{ + Uint8 *mix_input; + int i, mixable, volume = MIX_MAX_VOLUME; + Uint32 sdl_ticks; + + (void)udata; + +#if SDL_VERSION_ATLEAST(1, 3, 0) + /* Need to initialize the stream in SDL 1.3+ */ + SDL_memset(stream, mixer.silence, (size_t)len); +#endif + + /* Mix the music (must be done before the channels are added) */ + mix_music(music_data, stream, len); + + /* Mix any playing channels... */ + sdl_ticks = SDL_GetTicks(); + for (i=0; i 0 && mix_channel[i].expire < sdl_ticks) { + /* Expiration delay for that channel is reached */ + mix_channel[i].playing = 0; + mix_channel[i].looping = 0; + mix_channel[i].fading = MIX_NO_FADING; + mix_channel[i].expire = 0; + _Mix_channel_done_playing(i); + } else if (mix_channel[i].fading != MIX_NO_FADING) { + Uint32 ticks = sdl_ticks - mix_channel[i].ticks_fade; + if (ticks >= mix_channel[i].fade_length) { + Mix_Volume(i, mix_channel[i].fade_volume_reset); /* Restore the volume */ + if (mix_channel[i].fading == MIX_FADING_OUT) { + mix_channel[i].playing = 0; + mix_channel[i].looping = 0; + mix_channel[i].expire = 0; + _Mix_channel_done_playing(i); + } + mix_channel[i].fading = MIX_NO_FADING; + } else { + if (mix_channel[i].fading == MIX_FADING_OUT) { + Mix_Volume(i, (mix_channel[i].fade_volume * (mix_channel[i].fade_length-ticks)) + / mix_channel[i].fade_length); + } else { + Mix_Volume(i, (mix_channel[i].fade_volume * ticks) / mix_channel[i].fade_length); + } + } + } + if (mix_channel[i].playing > 0) { + int index = 0; + int remaining = len; + while (mix_channel[i].playing > 0 && index < len) { + remaining = len - index; + volume = (mix_channel[i].volume*mix_channel[i].chunk->volume) / MIX_MAX_VOLUME; + mixable = mix_channel[i].playing; + if (mixable > remaining) { + mixable = remaining; + } + + mix_input = Mix_DoEffects(i, mix_channel[i].samples, mixable); + SDL_MixAudioFormat(stream+index,mix_input,mixer.format,mixable,volume); + if (mix_input != mix_channel[i].samples) + SDL_free(mix_input); + + mix_channel[i].samples += mixable; + mix_channel[i].playing -= mixable; + index += mixable; + + /* rcg06072001 Alert app if channel is done playing. */ + if (!mix_channel[i].playing && !mix_channel[i].looping) { + _Mix_channel_done_playing(i); + } + } + + /* If looping the sample and we are at its end, make sure + we will still return a full buffer */ + while (mix_channel[i].looping && index < len) { + int alen = mix_channel[i].chunk->alen; + remaining = len - index; + if (remaining > alen) { + remaining = alen; + } + + mix_input = Mix_DoEffects(i, mix_channel[i].chunk->abuf, remaining); + SDL_MixAudioFormat(stream+index, mix_input, mixer.format, remaining, volume); + if (mix_input != mix_channel[i].chunk->abuf) + SDL_free(mix_input); + + if (mix_channel[i].looping > 0) { + --mix_channel[i].looping; + } + mix_channel[i].samples = mix_channel[i].chunk->abuf + remaining; + mix_channel[i].playing = mix_channel[i].chunk->alen - remaining; + index += remaining; + } + if (! mix_channel[i].playing && mix_channel[i].looping) { + if (mix_channel[i].looping > 0) { + --mix_channel[i].looping; + } + mix_channel[i].samples = mix_channel[i].chunk->abuf; + mix_channel[i].playing = mix_channel[i].chunk->alen; + } + } + } + } + + /* rcg06122001 run posteffects... */ + Mix_DoEffects(MIX_CHANNEL_POST, stream, len); + + if (mix_postmix) { + mix_postmix(mix_postmix_data, stream, len); + } +} + +#if 0 +static void PrintFormat(char *title, SDL_AudioSpec *fmt) +{ + printf("%s: %d bit %s audio (%s) at %u Hz\n", title, (fmt->format&0xFF), + (fmt->format&0x8000) ? "signed" : "unsigned", + (fmt->channels > 2) ? "surround" : + (fmt->channels > 1) ? "stereo" : "mono", fmt->freq); +} +#endif + +/* Open the mixer with a certain desired audio format */ +int Mix_OpenAudioDevice(int frequency, Uint16 format, int nchannels, int chunksize, + const char* device, int allowed_changes) +{ + int i; + SDL_AudioSpec desired; + + /* This used to call SDL_OpenAudio(), which initializes the audio + subsystem if necessary. Since SDL_OpenAudioDevice() doesn't, + we have to handle this case here. */ + if (!SDL_WasInit(SDL_INIT_AUDIO)) { + if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) { + return -1; + } + } + + /* If the mixer is already opened, increment open count */ + if (audio_opened) { + if (format == mixer.format && nchannels == mixer.channels) { + ++audio_opened; + return(0); + } + while (audio_opened) { + Mix_CloseAudio(); + } + } + + /* Set the desired format and frequency */ + desired.freq = frequency; + desired.format = format; + desired.channels = nchannels; + desired.samples = chunksize; + desired.callback = mix_channels; + desired.userdata = NULL; + + /* Accept nearly any audio format */ + if ((audio_device = SDL_OpenAudioDevice(device, 0, &desired, &mixer, allowed_changes)) == 0) { + return(-1); + } +#if 0 + PrintFormat("Audio device", &mixer); +#endif + + num_channels = MIX_CHANNELS; + mix_channel = (struct _Mix_Channel *) SDL_malloc(num_channels * sizeof(struct _Mix_Channel)); + + /* Clear out the audio channels */ + for (i=0; i num_channels) { + /* Initialize the new channels */ + int i; + for(i=num_channels; i < numchans; i++) { + mix_channel[i].chunk = NULL; + mix_channel[i].playing = 0; + mix_channel[i].looping = 0; + mix_channel[i].volume = MIX_MAX_VOLUME; + mix_channel[i].fade_volume = MIX_MAX_VOLUME; + mix_channel[i].fade_volume_reset = MIX_MAX_VOLUME; + mix_channel[i].fading = MIX_NO_FADING; + mix_channel[i].tag = -1; + mix_channel[i].expire = 0; + mix_channel[i].effects = NULL; + mix_channel[i].paused = 0; + } + } + num_channels = numchans; + Mix_UnlockAudio(); + return(num_channels); +} + +/* Return the actual mixer parameters */ +int Mix_QuerySpec(int *frequency, Uint16 *format, int *channels) +{ + if (audio_opened) { + if (frequency) { + *frequency = mixer.freq; + } + if (format) { + *format = mixer.format; + } + if (channels) { + *channels = mixer.channels; + } + } + return(audio_opened); +} + +typedef struct _MusicFragment +{ + Uint8 *data; + int size; + struct _MusicFragment *next; +} MusicFragment; + +static SDL_AudioSpec *Mix_LoadMusic_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) +{ + int i; + Mix_MusicType music_type; + Mix_MusicInterface *interface = NULL; + void *music = NULL; + Sint64 start; + SDL_bool playing; + MusicFragment *first = NULL, *last = NULL, *fragment = NULL; + int count = 0; + int fragment_size; + + music_type = detect_music_type(src); + if (!load_music_type(music_type) || !open_music_type(music_type)) { + return NULL; + } + + *spec = mixer; + + /* Use fragments sized on full audio frame boundaries - this'll do */ + fragment_size = spec->size; + + start = SDL_RWtell(src); + for (i = 0; i < get_num_music_interfaces(); ++i) { + interface = get_music_interface(i); + if (!interface->opened) { + continue; + } + if (interface->type != music_type) { + continue; + } + if (!interface->CreateFromRW || !interface->GetAudio) { + continue; + } + + /* These music interfaces are not safe to use while music is playing */ + if (interface->api == MIX_MUSIC_CMD || + interface->api == MIX_MUSIC_MIKMOD || + interface->api == MIX_MUSIC_NATIVEMIDI) { + continue; + } + + music = interface->CreateFromRW(src, freesrc); + if (music) { + /* The interface owns the data source now */ + freesrc = SDL_FALSE; + break; + } + + /* Reset the stream for the next decoder */ + SDL_RWseek(src, start, RW_SEEK_SET); + } + + if (!music) { + if (freesrc) { + SDL_RWclose(src); + } + Mix_SetError("Unrecognized audio format"); + return NULL; + } + + Mix_LockAudio(); + + if (interface->Play) { + interface->Play(music, 1); + } + playing = SDL_TRUE; + + while (playing) { + int left; + + fragment = (MusicFragment *)SDL_malloc(sizeof(*fragment)); + if (!fragment) { + /* Uh oh, out of memory, let's return what we have */ + break; + } + fragment->data = (Uint8 *)SDL_malloc(fragment_size); + if (!fragment->data) { + /* Uh oh, out of memory, let's return what we have */ + SDL_free(fragment); + break; + } + fragment->next = NULL; + + left = interface->GetAudio(music, fragment->data, fragment_size); + if (left > 0) { + playing = SDL_FALSE; + } else if (interface->IsPlaying) { + playing = interface->IsPlaying(music); + } + fragment->size = (fragment_size - left); + + if (!first) { + first = fragment; + } + if (last) { + last->next = fragment; + } + last = fragment; + ++count; + } + + if (interface->Stop) { + interface->Stop(music); + } + + if (music) { + interface->Delete(music); + } + + Mix_UnlockAudio(); + + if (count > 0) { + *audio_len = (count - 1) * fragment_size + fragment->size; + *audio_buf = (Uint8 *)SDL_malloc(*audio_len); + if (*audio_buf) { + Uint8 *dst = *audio_buf; + for (fragment = first; fragment; fragment = fragment->next) { + SDL_memcpy(dst, fragment->data, fragment->size); + dst += fragment->size; + } + } else { + SDL_OutOfMemory(); + spec = NULL; + } + } else { + Mix_SetError("No audio data"); + spec = NULL; + } + + while (first) { + fragment = first; + first = first->next; + SDL_free(fragment->data); + SDL_free(fragment); + } + + if (freesrc) { + SDL_RWclose(src); + } + return spec; +} + +/* Load a wave file */ +Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc) +{ + Uint8 magic[4]; + Mix_Chunk *chunk; + SDL_AudioSpec wavespec, *loaded; + SDL_AudioCVT wavecvt; + int samplesize; + + /* rcg06012001 Make sure src is valid */ + if (!src) { + SDL_SetError("Mix_LoadWAV_RW with NULL src"); + return(NULL); + } + + /* Make sure audio has been opened */ + if (!audio_opened) { + SDL_SetError("Audio device hasn't been opened"); + if (freesrc) { + SDL_RWclose(src); + } + return(NULL); + } + + /* Allocate the chunk memory */ + chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk)); + if (chunk == NULL) { + SDL_SetError("Out of memory"); + if (freesrc) { + SDL_RWclose(src); + } + return(NULL); + } + + /* Find out what kind of audio file this is */ + if (SDL_RWread(src, magic, 1, 4) != 4) { + SDL_free(chunk); + if (freesrc) { + SDL_RWclose(src); + } + Mix_SetError("Couldn't read first 4 bytes of audio data"); + return NULL; + } + /* Seek backwards for compatibility with older loaders */ + SDL_RWseek(src, -4, RW_SEEK_CUR); + + if (SDL_memcmp(magic, "WAVE", 4) == 0 || SDL_memcmp(magic, "RIFF", 4) == 0) { + loaded = SDL_LoadWAV_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen); + } else if (SDL_memcmp(magic, "FORM", 4) == 0) { + loaded = Mix_LoadAIFF_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen); + } else if (SDL_memcmp(magic, "Crea", 4) == 0) { + loaded = Mix_LoadVOC_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen); + } else { + loaded = Mix_LoadMusic_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen); + } + if (!loaded) { + /* The individual loaders have closed src if needed */ + SDL_free(chunk); + return(NULL); + } + +#if 0 + PrintFormat("Audio device", &mixer); + PrintFormat("-- Wave file", &wavespec); +#endif + + /* Build the audio converter and create conversion buffers */ + if (wavespec.format != mixer.format || + wavespec.channels != mixer.channels || + wavespec.freq != mixer.freq) { + if (SDL_BuildAudioCVT(&wavecvt, + wavespec.format, wavespec.channels, wavespec.freq, + mixer.format, mixer.channels, mixer.freq) < 0) { + SDL_free(chunk->abuf); + SDL_free(chunk); + return(NULL); + } + samplesize = ((wavespec.format & 0xFF)/8)*wavespec.channels; + wavecvt.len = chunk->alen & ~(samplesize-1); + wavecvt.buf = (Uint8 *)SDL_calloc(1, wavecvt.len*wavecvt.len_mult); + if (wavecvt.buf == NULL) { + SDL_SetError("Out of memory"); + SDL_free(chunk->abuf); + SDL_free(chunk); + return(NULL); + } + SDL_memcpy(wavecvt.buf, chunk->abuf, wavecvt.len); + SDL_free(chunk->abuf); + + /* Run the audio converter */ + if (SDL_ConvertAudio(&wavecvt) < 0) { + SDL_free(wavecvt.buf); + SDL_free(chunk); + return(NULL); + } + + chunk->abuf = wavecvt.buf; + chunk->alen = wavecvt.len_cvt; + } + + chunk->allocated = 1; + chunk->volume = MIX_MAX_VOLUME; + + return(chunk); +} + +/* Load a wave file of the mixer format from a memory buffer */ +Mix_Chunk *Mix_QuickLoad_WAV(Uint8 *mem) +{ + Mix_Chunk *chunk; + Uint8 magic[4]; + + /* Make sure audio has been opened */ + if (! audio_opened) { + SDL_SetError("Audio device hasn't been opened"); + return(NULL); + } + + /* Allocate the chunk memory */ + chunk = (Mix_Chunk *)SDL_calloc(1,sizeof(Mix_Chunk)); + if (chunk == NULL) { + SDL_SetError("Out of memory"); + return(NULL); + } + + /* Essentially just skip to the audio data (no error checking - fast) */ + chunk->allocated = 0; + mem += 12; /* WAV header */ + do { + SDL_memcpy(magic, mem, 4); + mem += 4; + chunk->alen = ((mem[3]<<24)|(mem[2]<<16)|(mem[1]<<8)|(mem[0])); + mem += 4; + chunk->abuf = mem; + mem += chunk->alen; + } while (SDL_memcmp(magic, "data", 4) != 0); + chunk->volume = MIX_MAX_VOLUME; + + return(chunk); +} + +/* Load raw audio data of the mixer format from a memory buffer */ +Mix_Chunk *Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len) +{ + Mix_Chunk *chunk; + + /* Make sure audio has been opened */ + if (! audio_opened) { + SDL_SetError("Audio device hasn't been opened"); + return(NULL); + } + + /* Allocate the chunk memory */ + chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk)); + if (chunk == NULL) { + SDL_SetError("Out of memory"); + return(NULL); + } + + /* Essentially just point at the audio data (no error checking - fast) */ + chunk->allocated = 0; + chunk->alen = len; + chunk->abuf = mem; + chunk->volume = MIX_MAX_VOLUME; + + return(chunk); +} + +/* Free an audio chunk previously loaded */ +void Mix_FreeChunk(Mix_Chunk *chunk) +{ + int i; + + /* Caution -- if the chunk is playing, the mixer will crash */ + if (chunk) { + /* Guarantee that this chunk isn't playing */ + Mix_LockAudio(); + if (mix_channel) { + for (i=0; iallocated) { + SDL_free(chunk->abuf); + } + SDL_free(chunk); + } +} + +/* Set a function that is called after all mixing is performed. + This can be used to provide real-time visual display of the audio stream + or add a custom mixer filter for the stream data. +*/ +void Mix_SetPostMix(void (SDLCALL *mix_func) + (void *udata, Uint8 *stream, int len), void *arg) +{ + Mix_LockAudio(); + mix_postmix_data = arg; + mix_postmix = mix_func; + Mix_UnlockAudio(); +} + +/* Add your own music player or mixer function. + If 'mix_func' is NULL, the default music player is re-enabled. + */ +void Mix_HookMusic(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), + void *arg) +{ + Mix_LockAudio(); + if (mix_func != NULL) { + music_data = arg; + mix_music = mix_func; + } else { + music_data = NULL; + mix_music = music_mixer; + } + Mix_UnlockAudio(); +} + +void *Mix_GetMusicHookData(void) +{ + return(music_data); +} + +void Mix_ChannelFinished(void (SDLCALL *channel_finished)(int channel)) +{ + Mix_LockAudio(); + channel_done_callback = channel_finished; + Mix_UnlockAudio(); +} + + +/* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate + them dynamically to the next sample if requested with a -1 value below. + Returns the number of reserved channels. + */ +int Mix_ReserveChannels(int num) +{ + if (num > num_channels) + num = num_channels; + reserved_channels = num; + return num; +} + +static int checkchunkintegral(Mix_Chunk *chunk) +{ + int frame_width = 1; + + if ((mixer.format & 0xFF) == 16) frame_width = 2; + frame_width *= mixer.channels; + while (chunk->alen % frame_width) chunk->alen--; + return chunk->alen; +} + +/* Play an audio chunk on a specific channel. + If the specified channel is -1, play on the first free channel. + 'ticks' is the number of milliseconds at most to play the sample, or -1 + if there is no limit. + Returns which channel was used to play the sound. +*/ +int Mix_PlayChannelTimed(int which, Mix_Chunk *chunk, int loops, int ticks) +{ + int i; + + /* Don't play null pointers :-) */ + if (chunk == NULL) { + Mix_SetError("Tried to play a NULL chunk"); + return(-1); + } + if (!checkchunkintegral(chunk)) { + Mix_SetError("Tried to play a chunk with a bad frame"); + return(-1); + } + + /* Lock the mixer while modifying the playing channels */ + Mix_LockAudio(); + { + /* If which is -1, play on the first free channel */ + if (which == -1) { + for (i=reserved_channels; i= 0 && which < num_channels) { + Uint32 sdl_ticks = SDL_GetTicks(); + mix_channel[which].samples = chunk->abuf; + mix_channel[which].playing = (int)chunk->alen; + mix_channel[which].looping = loops; + mix_channel[which].chunk = chunk; + mix_channel[which].paused = 0; + mix_channel[which].fading = MIX_NO_FADING; + mix_channel[which].start_time = sdl_ticks; + mix_channel[which].expire = (ticks > 0) ? (sdl_ticks + (Uint32)ticks) : 0; + } + } + Mix_UnlockAudio(); + + /* Return the channel on which the sound is being played */ + return(which); +} + +/* Change the expiration delay for a channel */ +int Mix_ExpireChannel(int which, int ticks) +{ + int status = 0; + + if (which == -1) { + int i; + for (i=0; i < num_channels; ++ i) { + status += Mix_ExpireChannel(i, ticks); + } + } else if (which < num_channels) { + Mix_LockAudio(); + mix_channel[which].expire = (ticks>0) ? (SDL_GetTicks() + (Uint32)ticks) : 0; + Mix_UnlockAudio(); + ++ status; + } + return(status); +} + +/* Fade in a sound on a channel, over ms milliseconds */ +int Mix_FadeInChannelTimed(int which, Mix_Chunk *chunk, int loops, int ms, int ticks) +{ + int i; + + /* Don't play null pointers :-) */ + if (chunk == NULL) { + return(-1); + } + if (!checkchunkintegral(chunk)) { + Mix_SetError("Tried to play a chunk with a bad frame"); + return(-1); + } + + /* Lock the mixer while modifying the playing channels */ + Mix_LockAudio(); + { + /* If which is -1, play on the first free channel */ + if (which == -1) { + for (i=reserved_channels; i= 0 && which < num_channels) { + Uint32 sdl_ticks = SDL_GetTicks(); + mix_channel[which].samples = chunk->abuf; + mix_channel[which].playing = (int)chunk->alen; + mix_channel[which].looping = loops; + mix_channel[which].chunk = chunk; + mix_channel[which].paused = 0; + if (mix_channel[which].fading == MIX_NO_FADING) { + mix_channel[which].fade_volume_reset = mix_channel[which].volume; + } + mix_channel[which].fading = MIX_FADING_IN; + mix_channel[which].fade_volume = mix_channel[which].volume; + mix_channel[which].volume = 0; + mix_channel[which].fade_length = (Uint32)ms; + mix_channel[which].start_time = mix_channel[which].ticks_fade = sdl_ticks; + mix_channel[which].expire = (ticks > 0) ? (sdl_ticks+(Uint32)ticks) : 0; + } + } + Mix_UnlockAudio(); + + /* Return the channel on which the sound is being played */ + return(which); +} + +/* Set volume of a particular channel */ +int Mix_Volume(int which, int volume) +{ + int i; + int prev_volume = 0; + + if (which == -1) { + for (i=0; i= 0) { + if (volume > MIX_MAX_VOLUME) { + volume = MIX_MAX_VOLUME; + } + mix_channel[which].volume = volume; + } + } + return(prev_volume); +} +/* Set volume of a particular chunk */ +int Mix_VolumeChunk(Mix_Chunk *chunk, int volume) +{ + int prev_volume; + + if (chunk == NULL) { + return(-1); + } + prev_volume = chunk->volume; + if (volume >= 0) { + if (volume > MIX_MAX_VOLUME) { + volume = MIX_MAX_VOLUME; + } + chunk->volume = volume; + } + return(prev_volume); +} + +/* Halt playing of a particular channel */ +int Mix_HaltChannel(int which) +{ + int i; + + if (which == -1) { + for (i=0; i 0) && + (mix_channel[which].fading != MIX_FADING_OUT)) { + mix_channel[which].fade_volume = mix_channel[which].volume; + mix_channel[which].fade_length = (Uint32)ms; + mix_channel[which].ticks_fade = SDL_GetTicks(); + + /* only change fade_volume_reset if we're not fading. */ + if (mix_channel[which].fading == MIX_NO_FADING) { + mix_channel[which].fade_volume_reset = mix_channel[which].volume; + } + + mix_channel[which].fading = MIX_FADING_OUT; + + ++status; + } + Mix_UnlockAudio(); + } + } + return(status); +} + +/* Halt playing of a particular group of channels */ +int Mix_FadeOutGroup(int tag, int ms) +{ + int i; + int status = 0; + for (i=0; i= num_channels) { + return MIX_NO_FADING; + } + return mix_channel[which].fading; +} + +/* Check the status of a specific channel. + If the specified mix_channel is -1, check all mix channels. +*/ +int Mix_Playing(int which) +{ + int status; + + status = 0; + if (which == -1) { + int i; + + for (i=0; i 0) || + mix_channel[i].looping) + { + ++status; + } + } + } else if (which < num_channels) { + if ((mix_channel[which].playing > 0) || + mix_channel[which].looping) + { + ++status; + } + } + return(status); +} + +/* rcg06072001 Get the chunk associated with a channel. */ +Mix_Chunk *Mix_GetChunk(int channel) +{ + Mix_Chunk *retval = NULL; + + if ((channel >= 0) && (channel < num_channels)) { + retval = mix_channel[channel].chunk; + } + + return(retval); +} + +/* Close the mixer, halting all playing audio */ +void Mix_CloseAudio(void) +{ + int i; + + if (audio_opened) { + if (audio_opened == 1) { + for (i = 0; i < num_channels; i++) { + Mix_UnregisterAllEffects(i); + } + Mix_UnregisterAllEffects(MIX_CHANNEL_POST); + close_music(); + Mix_SetMusicCMD(NULL); + Mix_HaltChannel(-1); + _Mix_DeinitEffects(); + SDL_CloseAudioDevice(audio_device); + audio_device = 0; + SDL_free(mix_channel); + mix_channel = NULL; + + /* rcg06042009 report available decoders at runtime. */ + SDL_free((void *)chunk_decoders); + chunk_decoders = NULL; + num_decoders = 0; + } + --audio_opened; + } +} + +/* Pause a particular channel (or all) */ +void Mix_Pause(int which) +{ + Uint32 sdl_ticks = SDL_GetTicks(); + if (which == -1) { + int i; + + for (i=0; i 0) + mix_channel[i].expire += sdl_ticks - mix_channel[i].paused; + mix_channel[i].paused = 0; + } + } + } else if (which < num_channels) { + if (Mix_Playing(which)) { + if (mix_channel[which].expire > 0) + mix_channel[which].expire += sdl_ticks - mix_channel[which].paused; + mix_channel[which].paused = 0; + } + } + Mix_UnlockAudio(); +} + +int Mix_Paused(int which) +{ + if (which < 0) { + int status = 0; + int i; + for(i=0; i < num_channels; ++i) { + if (mix_channel[i].paused) { + ++ status; + } + } + return(status); + } else if (which < num_channels) { + return(mix_channel[which].paused != 0); + } else { + return(0); + } +} + +/* Change the group of a channel */ +int Mix_GroupChannel(int which, int tag) +{ + if (which < 0 || which > num_channels) + return(0); + + Mix_LockAudio(); + mix_channel[which].tag = tag; + Mix_UnlockAudio(); + return(1); +} + +/* Assign several consecutive channels to a group */ +int Mix_GroupChannels(int from, int to, int tag) +{ + int status = 0; + for(; from <= to; ++ from) { + status += Mix_GroupChannel(from, tag); + } + return(status); +} + +/* Finds the first available channel in a group of channels */ +int Mix_GroupAvailable(int tag) +{ + int i; + for(i=0; i < num_channels; i ++) { + if (((tag == -1) || (tag == mix_channel[i].tag)) && + (!Mix_Playing(i))) + return i; + } + return(-1); +} + +int Mix_GroupCount(int tag) +{ + int count = 0; + int i; + for(i=0; i < num_channels; i ++) { + if (mix_channel[i].tag==tag || tag==-1) + ++ count; + } + return(count); +} + +/* Finds the "oldest" sample playing in a group of channels */ +int Mix_GroupOldest(int tag) +{ + int chan = -1; + Uint32 mintime = SDL_GetTicks(); + int i; + for(i=0; i < num_channels; i ++) { + if ((mix_channel[i].tag==tag || tag==-1) && Mix_Playing(i) + && mix_channel[i].start_time <= mintime) { + mintime = mix_channel[i].start_time; + chan = i; + } + } + return(chan); +} + +/* Finds the "most recent" (i.e. last) sample playing in a group of channels */ +int Mix_GroupNewer(int tag) +{ + int chan = -1; + Uint32 maxtime = 0; + int i; + for(i=0; i < num_channels; i ++) { + if ((mix_channel[i].tag==tag || tag==-1) && Mix_Playing(i) + && mix_channel[i].start_time >= maxtime) { + maxtime = mix_channel[i].start_time; + chan = i; + } + } + return(chan); +} + + + +/* + * rcg06122001 The special effects exportable API. + * Please see effect_*.c for internally-implemented effects, such + * as Mix_SetPanning(). + */ + +/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ +static int _Mix_register_effect(effect_info **e, Mix_EffectFunc_t f, + Mix_EffectDone_t d, void *arg) +{ + effect_info *new_e; + + if (!e) { + Mix_SetError("Internal error"); + return(0); + } + + if (f == NULL) { + Mix_SetError("NULL effect callback"); + return(0); + } + + new_e = SDL_malloc(sizeof (effect_info)); + if (new_e == NULL) { + Mix_SetError("Out of memory"); + return(0); + } + + new_e->callback = f; + new_e->done_callback = d; + new_e->udata = arg; + new_e->next = NULL; + + /* add new effect to end of linked list... */ + if (*e == NULL) { + *e = new_e; + } else { + effect_info *cur = *e; + while (1) { + if (cur->next == NULL) { + cur->next = new_e; + break; + } + cur = cur->next; + } + } + + return(1); +} + + +/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ +static int _Mix_remove_effect(int channel, effect_info **e, Mix_EffectFunc_t f) +{ + effect_info *cur; + effect_info *prev = NULL; + effect_info *next = NULL; + + if (!e) { + Mix_SetError("Internal error"); + return(0); + } + + for (cur = *e; cur != NULL; cur = cur->next) { + if (cur->callback == f) { + next = cur->next; + if (cur->done_callback != NULL) { + cur->done_callback(channel, cur->udata); + } + SDL_free(cur); + + if (prev == NULL) { /* removing first item of list? */ + *e = next; + } else { + prev->next = next; + } + return(1); + } + prev = cur; + } + + Mix_SetError("No such effect registered"); + return(0); +} + + +/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ +static int _Mix_remove_all_effects(int channel, effect_info **e) +{ + effect_info *cur; + effect_info *next; + + if (!e) { + Mix_SetError("Internal error"); + return(0); + } + + for (cur = *e; cur != NULL; cur = next) { + next = cur->next; + if (cur->done_callback != NULL) { + cur->done_callback(channel, cur->udata); + } + SDL_free(cur); + } + *e = NULL; + + return(1); +} + + +/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ +int _Mix_RegisterEffect_locked(int channel, Mix_EffectFunc_t f, + Mix_EffectDone_t d, void *arg) +{ + effect_info **e = NULL; + + if (channel == MIX_CHANNEL_POST) { + e = &posteffects; + } else { + if ((channel < 0) || (channel >= num_channels)) { + Mix_SetError("Invalid channel number"); + return(0); + } + e = &mix_channel[channel].effects; + } + + return _Mix_register_effect(e, f, d, arg); +} + +int Mix_RegisterEffect(int channel, Mix_EffectFunc_t f, + Mix_EffectDone_t d, void *arg) +{ + int retval; + Mix_LockAudio(); + retval = _Mix_RegisterEffect_locked(channel, f, d, arg); + Mix_UnlockAudio(); + return retval; +} + + +/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ +int _Mix_UnregisterEffect_locked(int channel, Mix_EffectFunc_t f) +{ + effect_info **e = NULL; + + if (channel == MIX_CHANNEL_POST) { + e = &posteffects; + } else { + if ((channel < 0) || (channel >= num_channels)) { + Mix_SetError("Invalid channel number"); + return(0); + } + e = &mix_channel[channel].effects; + } + + return _Mix_remove_effect(channel, e, f); +} + +int Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f) +{ + int retval; + Mix_LockAudio(); + retval = _Mix_UnregisterEffect_locked(channel, f); + Mix_UnlockAudio(); + return(retval); +} + +/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ +int _Mix_UnregisterAllEffects_locked(int channel) +{ + effect_info **e = NULL; + + if (channel == MIX_CHANNEL_POST) { + e = &posteffects; + } else { + if ((channel < 0) || (channel >= num_channels)) { + Mix_SetError("Invalid channel number"); + return(0); + } + e = &mix_channel[channel].effects; + } + + return _Mix_remove_all_effects(channel, e); +} + +int Mix_UnregisterAllEffects(int channel) +{ + int retval; + Mix_LockAudio(); + retval = _Mix_UnregisterAllEffects_locked(channel); + Mix_UnlockAudio(); + return(retval); +} + +void Mix_LockAudio(void) +{ + SDL_LockAudioDevice(audio_device); +} + +void Mix_UnlockAudio(void) +{ + SDL_UnlockAudioDevice(audio_device); +} + +/* end of mixer.c ... */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/mixer.h b/src/mixer.h new file mode 100644 index 0000000..525dc7b --- /dev/null +++ b/src/mixer.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* Locking wrapper functions */ +extern void Mix_LockAudio(void); +extern void Mix_UnlockAudio(void); + +extern void add_chunk_decoder(const char *decoder); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/music.c b/src/music.c new file mode 100644 index 0000000..b6e8063 --- /dev/null +++ b/src/music.c @@ -0,0 +1,1470 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_hints.h" +#include "SDL_log.h" +#include "SDL_timer.h" + +#include "SDL_mixer.h" +#include "mixer.h" +#include "music.h" + +#include "music_cmd.h" +#include "music_wav.h" +#include "music_mikmod.h" +#include "music_modplug.h" +#include "music_xmp.h" +#include "music_nativemidi.h" +#include "music_fluidsynth.h" +#include "music_timidity.h" +#include "music_ogg.h" +#include "music_opus.h" +#include "music_mpg123.h" +#include "music_mad.h" +#include "music_flac.h" +#include "native_midi/native_midi.h" + +#include "utils.h" + +/* Check to make sure we are building with a new enough SDL */ +#if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 7) +#error You need SDL 2.0.7 or newer from http://www.libsdl.org +#endif + +/* Set this hint to true if you want verbose logging of music interfaces */ +#define SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES \ + "SDL_MIXER_DEBUG_MUSIC_INTERFACES" + +char *music_cmd = NULL; +static SDL_bool music_active = SDL_TRUE; +static int music_volume = MIX_MAX_VOLUME; +static Mix_Music * volatile music_playing = NULL; +SDL_AudioSpec music_spec; + +struct _Mix_Music { + Mix_MusicInterface *interface; + void *context; + + SDL_bool playing; + Mix_Fading fading; + int fade_step; + int fade_steps; + + char filename[1024]; +}; + +/* Used to calculate fading steps */ +static int ms_per_step; + +/* rcg06042009 report available decoders at runtime. */ +static const char **music_decoders = NULL; +static int num_decoders = 0; + +/* Semicolon-separated SoundFont paths */ +static char* soundfont_paths = NULL; + +/* full path of timidity config file */ +static char* timidity_cfg = NULL; + +/* Meta-Tags utility */ +void meta_tags_init(Mix_MusicMetaTags *tags) +{ + SDL_memset(tags, 0, sizeof(Mix_MusicMetaTags)); +} + +void meta_tags_clear(Mix_MusicMetaTags *tags) +{ + size_t i = 0; + for (i = 0; i < MIX_META_LAST; i++) { + if (tags->tags[i]) { + SDL_free(tags->tags[i]); + tags->tags[i] = NULL; + } + } +} + +void meta_tags_set(Mix_MusicMetaTags *tags, Mix_MusicMetaTag type, const char *value) +{ + char *out; + size_t len; + + if (!value) { + return; + } + if (type >= MIX_META_LAST) { + return; + } + + len = SDL_strlen(value); + out = (char *)SDL_malloc(sizeof(char) * len + 1); + SDL_strlcpy(out, value, len +1); + + if (tags->tags[type]) { + SDL_free(tags->tags[type]); + } + + tags->tags[type] = out; +} + +const char *meta_tags_get(Mix_MusicMetaTags *tags, Mix_MusicMetaTag type) +{ + switch (type) { + case MIX_META_TITLE: + case MIX_META_ARTIST: + case MIX_META_ALBUM: + case MIX_META_COPYRIGHT: + return tags->tags[type] ? tags->tags[type] : ""; + case MIX_META_LAST: + default: + break; + } + return ""; +} + +/* for music->filename */ +#if defined(__WIN32__)||defined(__OS2__) +static SDL_INLINE const char *get_last_dirsep (const char *p) { + const char *p1 = SDL_strrchr(p, '/'); + const char *p2 = SDL_strrchr(p, '\\'); + if (!p1) return p2; + if (!p2) return p1; + return (p1 > p2)? p1 : p2; +} +#else /* unix */ +static SDL_INLINE const char *get_last_dirsep (const char *p) { + return SDL_strrchr(p, '/'); +} +#endif + + +/* Interfaces for the various music interfaces, ordered by priority */ +static Mix_MusicInterface *s_music_interfaces[] = +{ +#ifdef MUSIC_CMD + &Mix_MusicInterface_CMD, +#endif +#ifdef MUSIC_WAV + &Mix_MusicInterface_WAV, +#endif +#ifdef MUSIC_FLAC + &Mix_MusicInterface_FLAC, +#endif +#ifdef MUSIC_OGG + &Mix_MusicInterface_OGG, +#endif +#ifdef MUSIC_OPUS + &Mix_MusicInterface_Opus, +#endif +#ifdef MUSIC_MP3_MPG123 + &Mix_MusicInterface_MPG123, +#endif +#ifdef MUSIC_MP3_MAD + &Mix_MusicInterface_MAD, +#endif +#ifdef MUSIC_MOD_XMP + &Mix_MusicInterface_XMP, +#endif +#ifdef MUSIC_MOD_MODPLUG + &Mix_MusicInterface_MODPLUG, +#endif +#ifdef MUSIC_MOD_MIKMOD + &Mix_MusicInterface_MIKMOD, +#endif +#ifdef MUSIC_MID_FLUIDSYNTH + &Mix_MusicInterface_FLUIDSYNTH, +#endif +#ifdef MUSIC_MID_TIMIDITY + &Mix_MusicInterface_TIMIDITY, +#endif +#ifdef MUSIC_MID_NATIVE + &Mix_MusicInterface_NATIVEMIDI, +#endif +}; + +int get_num_music_interfaces(void) +{ + return SDL_arraysize(s_music_interfaces); +} + +Mix_MusicInterface *get_music_interface(int index) +{ + return s_music_interfaces[index]; +} + +int Mix_GetNumMusicDecoders(void) +{ + return(num_decoders); +} + +const char *Mix_GetMusicDecoder(int index) +{ + if ((index < 0) || (index >= num_decoders)) { + return NULL; + } + return(music_decoders[index]); +} + +SDL_bool Mix_HasMusicDecoder(const char *name) +{ + int index; + for (index = 0; index < num_decoders; ++index) { + if (SDL_strcasecmp(name, music_decoders[index]) == 0) { + return SDL_TRUE; + } + } + return SDL_FALSE; +} + +static void add_music_decoder(const char *decoder) +{ + void *ptr; + int i; + + /* Check to see if we already have this decoder */ + for (i = 0; i < num_decoders; ++i) { + if (SDL_strcmp(music_decoders[i], decoder) == 0) { + return; + } + } + + ptr = SDL_realloc((void *)music_decoders, ((size_t)num_decoders + 1) * sizeof (const char *)); + if (ptr == NULL) { + return; /* oh well, go on without it. */ + } + music_decoders = (const char **) ptr; + music_decoders[num_decoders++] = decoder; +} + +/* Local low-level functions prototypes */ +static void music_internal_initialize_volume(void); +static void music_internal_volume(int volume); +static int music_internal_play(Mix_Music *music, int play_count, double position); +static int music_internal_position(double position); +static SDL_bool music_internal_playing(void); +static void music_internal_halt(void); + + +/* Support for hooking when the music has finished */ +static void (SDLCALL *music_finished_hook)(void) = NULL; + +void Mix_HookMusicFinished(void (SDLCALL *music_finished)(void)) +{ + Mix_LockAudio(); + music_finished_hook = music_finished; + Mix_UnlockAudio(); +} + +/* Convenience function to fill audio and mix at the specified volume + This is called from many music player's GetAudio callback. + */ +int music_pcm_getaudio(void *context, void *data, int bytes, int volume, + int (*GetSome)(void *context, void *data, int bytes, SDL_bool *done)) +{ + Uint8 *snd = (Uint8 *)data; + Uint8 *dst; + int len = bytes; + SDL_bool done = SDL_FALSE; + + if (volume == MIX_MAX_VOLUME) { + dst = snd; + } else { + dst = SDL_stack_alloc(Uint8, (size_t)bytes); + } + while (len > 0 && !done) { + int consumed = GetSome(context, dst, len, &done); + if (consumed < 0) { + break; + } + + if (volume == MIX_MAX_VOLUME) { + dst += consumed; + } else { + SDL_MixAudioFormat(snd, dst, music_spec.format, (Uint32)consumed, volume); + snd += consumed; + } + len -= consumed; + } + if (volume != MIX_MAX_VOLUME) { + SDL_stack_free(dst); + } + return len; +} + +/* Mixing function */ +void SDLCALL music_mixer(void *udata, Uint8 *stream, int len) +{ + (void)udata; + + while (music_playing && music_active && len > 0) { + /* Handle fading */ + if (music_playing->fading != MIX_NO_FADING) { + if (music_playing->fade_step++ < music_playing->fade_steps) { + int volume; + int fade_step = music_playing->fade_step; + int fade_steps = music_playing->fade_steps; + + if (music_playing->fading == MIX_FADING_OUT) { + volume = (music_volume * (fade_steps-fade_step)) / fade_steps; + } else { /* Fading in */ + volume = (music_volume * fade_step) / fade_steps; + } + music_internal_volume(volume); + } else { + if (music_playing->fading == MIX_FADING_OUT) { + music_internal_halt(); + if (music_finished_hook) { + music_finished_hook(); + } + return; + } + music_playing->fading = MIX_NO_FADING; + } + } + + if (music_playing->interface->GetAudio) { + int left = music_playing->interface->GetAudio(music_playing->context, stream, len); + if (left != 0) { + /* Either an error or finished playing with data left */ + music_playing->playing = SDL_FALSE; + } + if (left > 0) { + stream += (len - left); + len = left; + } else { + len = 0; + } + } else { + len = 0; + } + + if (!music_internal_playing()) { + music_internal_halt(); + if (music_finished_hook) { + music_finished_hook(); + } + } + } +} + +/* Load the music interface libraries for a given music type */ +SDL_bool load_music_type(Mix_MusicType type) +{ + size_t i; + int loaded = 0; + for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { + Mix_MusicInterface *interface = s_music_interfaces[i]; + if (interface->type != type) { + continue; + } + if (!interface->loaded) { + char hint[64]; + SDL_snprintf(hint, sizeof(hint), "SDL_MIXER_DISABLE_%s", interface->tag); + if (SDL_GetHintBoolean(hint, SDL_FALSE)) { + continue; + } + + if (interface->Load && interface->Load() < 0) { + if (SDL_GetHintBoolean(SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES, SDL_FALSE)) { + SDL_Log("Couldn't load %s: %s\n", interface->tag, Mix_GetError()); + } + continue; + } + interface->loaded = SDL_TRUE; + } + ++loaded; + } + return (loaded > 0) ? SDL_TRUE : SDL_FALSE; +} + +/* Open the music interfaces for a given music type */ +SDL_bool open_music_type(Mix_MusicType type) +{ + size_t i; + int opened = 0; + SDL_bool use_native_midi = SDL_FALSE; + + if (!music_spec.format) { + /* Music isn't opened yet */ + return SDL_FALSE; + } + +#ifdef MUSIC_MID_NATIVE + if (type == MUS_MID && SDL_GetHintBoolean("SDL_NATIVE_MUSIC", SDL_FALSE) && native_midi_detect()) { + use_native_midi = SDL_TRUE; + } +#endif + + for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { + Mix_MusicInterface *interface = s_music_interfaces[i]; + if (!interface->loaded) { + continue; + } + if (type != MUS_NONE && interface->type != type) { + continue; + } + + if (interface->type == MUS_MID && use_native_midi && interface->api != MIX_MUSIC_NATIVEMIDI) { + continue; + } + + if (!interface->opened) { + if (interface->Open && interface->Open(&music_spec) < 0) { + if (SDL_GetHintBoolean(SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES, SDL_FALSE)) { + SDL_Log("Couldn't open %s: %s\n", interface->tag, Mix_GetError()); + } + continue; + } + interface->opened = SDL_TRUE; + add_music_decoder(interface->tag); + } + ++opened; + } + + if (has_music(MUS_MOD)) { + add_music_decoder("MOD"); + add_chunk_decoder("MOD"); + } + if (has_music(MUS_MID)) { + add_music_decoder("MIDI"); + add_chunk_decoder("MID"); + } + if (has_music(MUS_OGG)) { + add_music_decoder("OGG"); + add_chunk_decoder("OGG"); + } + if (has_music(MUS_OPUS)) { + add_music_decoder("OPUS"); + add_chunk_decoder("OPUS"); + } + if (has_music(MUS_MP3)) { + add_music_decoder("MP3"); + add_chunk_decoder("MP3"); + } + if (has_music(MUS_FLAC)) { + add_music_decoder("FLAC"); + add_chunk_decoder("FLAC"); + } + + return (opened > 0) ? SDL_TRUE : SDL_FALSE; +} + +/* Initialize the music interfaces with a certain desired audio format */ +void open_music(const SDL_AudioSpec *spec) +{ +#ifdef MIX_INIT_SOUNDFONT_PATHS + if (!soundfont_paths) { + soundfont_paths = SDL_strdup(MIX_INIT_SOUNDFONT_PATHS); + } +#endif + + /* Load the music interfaces that don't have explicit initialization */ + load_music_type(MUS_CMD); + load_music_type(MUS_WAV); + + /* Open all the interfaces that are loaded */ + music_spec = *spec; + open_music_type(MUS_NONE); + + Mix_VolumeMusic(MIX_MAX_VOLUME); + + /* Calculate the number of ms for each callback */ + ms_per_step = (int) (((float)spec->samples * 1000.0f) / spec->freq); +} + +/* Return SDL_TRUE if the music type is available */ +SDL_bool has_music(Mix_MusicType type) +{ + size_t i; + for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { + Mix_MusicInterface *interface = s_music_interfaces[i]; + if (interface->type != type) { + continue; + } + if (interface->opened) { + return SDL_TRUE; + } + } + return SDL_FALSE; +} + +Mix_MusicType detect_music_type(SDL_RWops *src) +{ + Uint8 magic[12]; + + if (SDL_RWread(src, magic, 1, 12) != 12) { + Mix_SetError("Couldn't read first 12 bytes of audio data"); + return MUS_NONE; + } + SDL_RWseek(src, -12, RW_SEEK_CUR); + + /* WAVE files have the magic four bytes "RIFF" + AIFF files have the magic 12 bytes "FORM" XXXX "AIFF" */ + if (((SDL_memcmp(magic, "RIFF", 4) == 0) && (SDL_memcmp((magic+8), "WAVE", 4) == 0)) || + (SDL_memcmp(magic, "FORM", 4) == 0)) { + return MUS_WAV; + } + + /* Ogg Vorbis files have the magic four bytes "OggS" */ + if (SDL_memcmp(magic, "OggS", 4) == 0) { + SDL_RWseek(src, 28, RW_SEEK_CUR); + SDL_RWread(src, magic, 1, 8); + SDL_RWseek(src,-36, RW_SEEK_CUR); + if (SDL_memcmp(magic, "OpusHead", 8) == 0) { + return MUS_OPUS; + } + return MUS_OGG; + } + + /* FLAC files have the magic four bytes "fLaC" */ + if (SDL_memcmp(magic, "fLaC", 4) == 0) { + return MUS_FLAC; + } + + /* MIDI files have the magic four bytes "MThd" */ + if (SDL_memcmp(magic, "MThd", 4) == 0) { + return MUS_MID; + } + + if (SDL_memcmp(magic, "ID3", 3) == 0 || + /* see: https://bugzilla.libsdl.org/show_bug.cgi?id=5322 */ + (magic[0] == 0xFF && (magic[1] & 0xE6) == 0xE2)) { + return MUS_MP3; + } + + /* Assume MOD format. + * + * Apparently there is no way to check if the file is really a MOD, + * or there are too many formats supported by MikMod/ModPlug, or + * MikMod/ModPlug does this check by itself. */ + return MUS_MOD; +} + +/* Load a music file */ +Mix_Music *Mix_LoadMUS(const char *file) +{ + size_t i; + void *context; + char *ext; + Mix_MusicType type; + SDL_RWops *src; + + for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { + Mix_MusicInterface *interface = s_music_interfaces[i]; + if (!interface->opened || !interface->CreateFromFile) { + continue; + } + + context = interface->CreateFromFile(file); + if (context) { + const char *p; + /* Allocate memory for the music structure */ + Mix_Music *music = (Mix_Music *)SDL_calloc(1, sizeof(Mix_Music)); + if (music == NULL) { + Mix_SetError("Out of memory"); + return NULL; + } + music->interface = interface; + music->context = context; + p = get_last_dirsep(file); + SDL_strlcpy(music->filename, (p != NULL)? p + 1 : file, 1024); + return music; + } + } + + src = SDL_RWFromFile(file, "rb"); + if (src == NULL) { + Mix_SetError("Couldn't open '%s'", file); + return NULL; + } + + /* Use the extension as a first guess on the file type */ + type = MUS_NONE; + ext = SDL_strrchr(file, '.'); + if (ext) { + ++ext; /* skip the dot in the extension */ + if (SDL_strcasecmp(ext, "WAV") == 0) { + type = MUS_WAV; + } else if (SDL_strcasecmp(ext, "MID") == 0 || + SDL_strcasecmp(ext, "MIDI") == 0 || + SDL_strcasecmp(ext, "KAR") == 0) { + type = MUS_MID; + } else if (SDL_strcasecmp(ext, "OGG") == 0) { + type = MUS_OGG; + } else if (SDL_strcasecmp(ext, "OPUS") == 0) { + type = MUS_OPUS; + } else if (SDL_strcasecmp(ext, "FLAC") == 0) { + type = MUS_FLAC; + } else if (SDL_strcasecmp(ext, "MPG") == 0 || + SDL_strcasecmp(ext, "MPEG") == 0 || + SDL_strcasecmp(ext, "MP3") == 0 || + SDL_strcasecmp(ext, "MAD") == 0) { + type = MUS_MP3; + } else if (SDL_strcasecmp(ext, "669") == 0 || + SDL_strcasecmp(ext, "AMF") == 0 || + SDL_strcasecmp(ext, "AMS") == 0 || + SDL_strcasecmp(ext, "DBM") == 0 || + SDL_strcasecmp(ext, "DSM") == 0 || + SDL_strcasecmp(ext, "FAR") == 0 || + SDL_strcasecmp(ext, "GDM") == 0 || + SDL_strcasecmp(ext, "IT") == 0 || + SDL_strcasecmp(ext, "MED") == 0 || + SDL_strcasecmp(ext, "MDL") == 0 || + SDL_strcasecmp(ext, "MOD") == 0 || + SDL_strcasecmp(ext, "MOL") == 0 || + SDL_strcasecmp(ext, "MTM") == 0 || + SDL_strcasecmp(ext, "NST") == 0 || + SDL_strcasecmp(ext, "OKT") == 0 || + SDL_strcasecmp(ext, "PTM") == 0 || + SDL_strcasecmp(ext, "S3M") == 0 || + SDL_strcasecmp(ext, "STM") == 0 || + SDL_strcasecmp(ext, "ULT") == 0 || + SDL_strcasecmp(ext, "UMX") == 0 || + SDL_strcasecmp(ext, "WOW") == 0 || + SDL_strcasecmp(ext, "XM") == 0) { + type = MUS_MOD; + } + } + return Mix_LoadMUSType_RW(src, type, SDL_TRUE); +} + +Mix_Music *Mix_LoadMUS_RW(SDL_RWops *src, int freesrc) +{ + return Mix_LoadMUSType_RW(src, MUS_NONE, freesrc); +} + +Mix_Music *Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc) +{ + size_t i; + void *context; + Sint64 start; + + if (!src) { + Mix_SetError("RWops pointer is NULL"); + return NULL; + } + start = SDL_RWtell(src); + + /* If the caller wants auto-detection, figure out what kind of file + * this is. */ + if (type == MUS_NONE) { + if ((type = detect_music_type(src)) == MUS_NONE) { + /* Don't call Mix_SetError() since detect_music_type() does that. */ + if (freesrc) { + SDL_RWclose(src); + } + return NULL; + } + } + + Mix_ClearError(); + + if (load_music_type(type) && open_music_type(type)) { + for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { + Mix_MusicInterface *interface = s_music_interfaces[i]; + if (!interface->opened || type != interface->type || !interface->CreateFromRW) { + continue; + } + + context = interface->CreateFromRW(src, freesrc); + if (context) { + /* Allocate memory for the music structure */ + Mix_Music *music = (Mix_Music *)SDL_calloc(1, sizeof(Mix_Music)); + if (music == NULL) { + interface->Delete(context); + Mix_SetError("Out of memory"); + return NULL; + } + music->interface = interface; + music->context = context; + + if (SDL_GetHintBoolean(SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES, SDL_FALSE)) { + SDL_Log("Loaded music with %s\n", interface->tag); + } + return music; + } + + /* Reset the stream for the next decoder */ + SDL_RWseek(src, start, RW_SEEK_SET); + } + } + + if (!*Mix_GetError()) { + Mix_SetError("Unrecognized audio format"); + } + if (freesrc) { + SDL_RWclose(src); + } else { + SDL_RWseek(src, start, RW_SEEK_SET); + } + return NULL; +} + +/* Free a music chunk previously loaded */ +void Mix_FreeMusic(Mix_Music *music) +{ + if (music) { + /* Stop the music if it's currently playing */ + Mix_LockAudio(); + if (music == music_playing) { + /* Wait for any fade out to finish */ + while (music->fading == MIX_FADING_OUT) { + Mix_UnlockAudio(); + SDL_Delay(100); + Mix_LockAudio(); + } + if (music == music_playing) { + music_internal_halt(); + } + } + Mix_UnlockAudio(); + + music->interface->Delete(music->context); + SDL_free(music); + } +} + +/* Find out the music format of a mixer music, or the currently playing + music, if 'music' is NULL. +*/ +Mix_MusicType Mix_GetMusicType(const Mix_Music *music) +{ + Mix_MusicType type = MUS_NONE; + + if (music) { + type = music->interface->type; + } else { + Mix_LockAudio(); + if (music_playing) { + type = music_playing->interface->type; + } + Mix_UnlockAudio(); + } + return(type); +} + +static const char * get_music_tag_internal(const Mix_Music *music, Mix_MusicMetaTag tag_type) +{ + const char *tag = ""; + + Mix_LockAudio(); + if (music && music->interface->GetMetaTag) { + tag = music->interface->GetMetaTag(music->context, tag_type); + } else if (music_playing && music_playing->interface->GetMetaTag) { + tag = music_playing->interface->GetMetaTag(music_playing->context, tag_type); + } else { + Mix_SetError("Music isn't playing"); + } + Mix_UnlockAudio(); + return tag; +} + +const char *Mix_GetMusicTitleTag(const Mix_Music *music) +{ + return get_music_tag_internal(music, MIX_META_TITLE); +} + +/* Get music title from meta-tag if possible */ +const char *Mix_GetMusicTitle(const Mix_Music *music) +{ + const char *tag = Mix_GetMusicTitleTag(music); + if (SDL_strlen(tag) > 0) { + return tag; + } + if (music) { + return music->filename; + } + if (music_playing) { + return music_playing->filename; + } + return ""; +} + +const char *Mix_GetMusicArtistTag(const Mix_Music *music) +{ + return get_music_tag_internal(music, MIX_META_ARTIST); +} + +const char *Mix_GetMusicAlbumTag(const Mix_Music *music) +{ + return get_music_tag_internal(music, MIX_META_ALBUM); +} + +const char *Mix_GetMusicCopyrightTag(const Mix_Music *music) +{ + return get_music_tag_internal(music, MIX_META_COPYRIGHT); +} + +/* Play a music chunk. Returns 0, or -1 if there was an error. + */ +static int music_internal_play(Mix_Music *music, int play_count, double position) +{ + int retval = 0; + +#if defined(__MACOSX__) && defined(MID_MUSIC_NATIVE) + /* This fixes a bug with native MIDI on Mac OS X, where you + can't really stop and restart MIDI from the audio callback. + */ + if (music == music_playing && music->api == MIX_MUSIC_NATIVEMIDI) { + /* Just a seek suffices to restart playing */ + music_internal_position(position); + return 0; + } +#endif + + /* Note the music we're playing */ + if (music_playing) { + music_internal_halt(); + } + music_playing = music; + music_playing->playing = SDL_TRUE; + + /* Set the initial volume */ + music_internal_initialize_volume(); + + /* Set up for playback */ + retval = music->interface->Play(music->context, play_count); + + /* Set the playback position, note any errors if an offset is used */ + if (retval == 0) { + if (position > 0.0) { + if (music_internal_position(position) < 0) { + Mix_SetError("Position not implemented for music type"); + retval = -1; + } + } else { + music_internal_position(0.0); + } + } + + /* If the setup failed, we're not playing any music anymore */ + if (retval < 0) { + music->playing = SDL_FALSE; + music_playing = NULL; + } + return(retval); +} + +int Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position) +{ + int retval; + + if (ms_per_step == 0) { + SDL_SetError("Audio device hasn't been opened"); + return(-1); + } + + /* Don't play null pointers :-) */ + if (music == NULL) { + Mix_SetError("music parameter was NULL"); + return(-1); + } + + /* Setup the data */ + if (ms) { + music->fading = MIX_FADING_IN; + } else { + music->fading = MIX_NO_FADING; + } + music->fade_step = 0; + music->fade_steps = ms/ms_per_step; + + /* Play the puppy */ + Mix_LockAudio(); + /* If the current music is fading out, wait for the fade to complete */ + while (music_playing && (music_playing->fading == MIX_FADING_OUT)) { + Mix_UnlockAudio(); + SDL_Delay(100); + Mix_LockAudio(); + } + if (loops == 0) { + /* Loop is the number of times to play the audio */ + loops = 1; + } + retval = music_internal_play(music, loops, position); + /* Set music as active */ + music_active = (retval == 0); + Mix_UnlockAudio(); + + return(retval); +} +int Mix_FadeInMusic(Mix_Music *music, int loops, int ms) +{ + return Mix_FadeInMusicPos(music, loops, ms, 0.0); +} +int Mix_PlayMusic(Mix_Music *music, int loops) +{ + return Mix_FadeInMusicPos(music, loops, 0, 0.0); +} + +/* Jump to a given order in mod music. */ +int Mix_ModMusicJumpToOrder(int order) +{ + int retval = -1; + + Mix_LockAudio(); + if (music_playing) { + if (music_playing->interface->Jump) { + retval = music_playing->interface->Jump(music_playing->context, order); + } else { + Mix_SetError("Jump not implemented for music type"); + } + } else { + Mix_SetError("Music isn't playing"); + } + Mix_UnlockAudio(); + + return retval; +} + +/* Set the playing music position */ +int music_internal_position(double position) +{ + if (music_playing->interface->Seek) { + return music_playing->interface->Seek(music_playing->context, position); + } + return -1; +} +int Mix_SetMusicPosition(double position) +{ + int retval; + + Mix_LockAudio(); + if (music_playing) { + retval = music_internal_position(position); + if (retval < 0) { + Mix_SetError("Position not implemented for music type"); + } + } else { + Mix_SetError("Music isn't playing"); + retval = -1; + } + Mix_UnlockAudio(); + + return(retval); +} + +/* Set the playing music position */ +static double music_internal_position_get(Mix_Music *music) +{ + if (music->interface->Tell) { + return music->interface->Tell(music->context); + } + return -1; +} +double Mix_GetMusicPosition(Mix_Music *music) +{ + double retval; + + Mix_LockAudio(); + if (music) { + retval = music_internal_position_get(music); + } else if (music_playing) { + retval = music_internal_position_get(music_playing); + } else { + Mix_SetError("Music isn't playing"); + retval = -1.0; + } + Mix_UnlockAudio(); + + return(retval); +} + +static double music_internal_duration(Mix_Music *music) +{ + if (music->interface->Duration) { + return music->interface->Duration(music->context); + } else { + Mix_SetError("Duration not implemented for music type"); + return -1; + } +} +double Mix_MusicDuration(Mix_Music *music) +{ + double retval; + + Mix_LockAudio(); + if (music) { + retval = music_internal_duration(music); + } else if (music_playing) { + retval = music_internal_duration(music_playing); + } else { + Mix_SetError("music is NULL and no playing music"); + retval = -1.0; + } + Mix_UnlockAudio(); + + return(retval); +} + +/* Get Loop start position */ +static double music_internal_loop_start(Mix_Music *music) +{ + if (music->interface->LoopStart) { + return music->interface->LoopStart(music->context); + } + return -1; +} +double Mix_GetMusicLoopStartTime(Mix_Music *music) +{ + double retval; + + Mix_LockAudio(); + if (music) { + retval = music_internal_loop_start(music); + } else if (music_playing) { + retval = music_internal_loop_start(music_playing); + } else { + Mix_SetError("Music isn't playing"); + retval = -1.0; + } + Mix_UnlockAudio(); + + return(retval); +} + +/* Get Loop end position */ +static double music_internal_loop_end(Mix_Music *music) +{ + if (music->interface->LoopEnd) { + return music->interface->LoopEnd(music->context); + } + return -1; +} +double Mix_GetMusicLoopEndTime(Mix_Music *music) +{ + double retval; + + Mix_LockAudio(); + if (music) { + retval = music_internal_loop_end(music); + } else if (music_playing) { + retval = music_internal_loop_end(music_playing); + } else { + Mix_SetError("Music isn't playing"); + retval = -1.0; + } + Mix_UnlockAudio(); + + return(retval); +} + +/* Get Loop end position */ +static double music_internal_loop_length(Mix_Music *music) +{ + if (music->interface->LoopLength) { + return music->interface->LoopLength(music->context); + } + return -1; +} +double Mix_GetMusicLoopLengthTime(Mix_Music *music) +{ + double retval; + + Mix_LockAudio(); + if (music) { + retval = music_internal_loop_length(music); + } else if (music_playing) { + retval = music_internal_loop_length(music_playing); + } else { + Mix_SetError("Music isn't playing"); + retval = -1.0; + } + Mix_UnlockAudio(); + + return(retval); +} + +/* Set the music's initial volume */ +static void music_internal_initialize_volume(void) +{ + if (music_playing->fading == MIX_FADING_IN) { + music_internal_volume(0); + } else { + music_internal_volume(music_volume); + } +} + +/* Set the music volume */ +static void music_internal_volume(int volume) +{ + if (music_playing->interface->SetVolume) { + music_playing->interface->SetVolume(music_playing->context, volume); + } +} +int Mix_VolumeMusic(int volume) +{ + int prev_volume; + + prev_volume = music_volume; + if (volume < 0) { + return prev_volume; + } + if (volume > SDL_MIX_MAXVOLUME) { + volume = SDL_MIX_MAXVOLUME; + } + music_volume = volume; + Mix_LockAudio(); + if (music_playing) { + music_internal_volume(music_volume); + } + Mix_UnlockAudio(); + return(prev_volume); +} + +int Mix_GetMusicVolume(Mix_Music *music) +{ + int prev_volume; + + if (music && music->interface->GetVolume) + prev_volume = music->interface->GetVolume(music->context); + else if (music_playing && music_playing->interface->GetVolume) { + prev_volume = music_playing->interface->GetVolume(music_playing->context); + } else { + prev_volume = music_volume; + } + + return prev_volume; +} + +/* Halt playing of music */ +static void music_internal_halt(void) +{ + if (music_playing->interface->Stop) { + music_playing->interface->Stop(music_playing->context); + } + + music_playing->playing = SDL_FALSE; + music_playing->fading = MIX_NO_FADING; + music_playing = NULL; +} +int Mix_HaltMusic(void) +{ + Mix_LockAudio(); + if (music_playing) { + music_internal_halt(); + if (music_finished_hook) { + music_finished_hook(); + } + } + Mix_UnlockAudio(); + + return(0); +} + +/* Progressively stop the music */ +int Mix_FadeOutMusic(int ms) +{ + int retval = 0; + + if (ms_per_step == 0) { + SDL_SetError("Audio device hasn't been opened"); + return 0; + } + + if (ms <= 0) { /* just halt immediately. */ + Mix_HaltMusic(); + return 1; + } + + Mix_LockAudio(); + if (music_playing) { + int fade_steps = (ms + ms_per_step - 1) / ms_per_step; + if (music_playing->fading == MIX_NO_FADING) { + music_playing->fade_step = 0; + } else { + int step; + int old_fade_steps = music_playing->fade_steps; + if (music_playing->fading == MIX_FADING_OUT) { + step = music_playing->fade_step; + } else { + step = old_fade_steps - music_playing->fade_step + 1; + } + music_playing->fade_step = (step * fade_steps) / old_fade_steps; + } + music_playing->fading = MIX_FADING_OUT; + music_playing->fade_steps = fade_steps; + retval = 1; + } + Mix_UnlockAudio(); + + return(retval); +} + +Mix_Fading Mix_FadingMusic(void) +{ + Mix_Fading fading = MIX_NO_FADING; + + Mix_LockAudio(); + if (music_playing) { + fading = music_playing->fading; + } + Mix_UnlockAudio(); + + return(fading); +} + +/* Pause/Resume the music stream */ +void Mix_PauseMusic(void) +{ + Mix_LockAudio(); + if (music_playing) { + if (music_playing->interface->Pause) { + music_playing->interface->Pause(music_playing->context); + } + } + music_active = SDL_FALSE; + Mix_UnlockAudio(); +} + +void Mix_ResumeMusic(void) +{ + Mix_LockAudio(); + if (music_playing) { + if (music_playing->interface->Resume) { + music_playing->interface->Resume(music_playing->context); + } + } + music_active = SDL_TRUE; + Mix_UnlockAudio(); +} + +void Mix_RewindMusic(void) +{ + Mix_SetMusicPosition(0.0); +} + +int Mix_PausedMusic(void) +{ + return (music_active == SDL_FALSE); +} + +/* Check the status of the music */ +static SDL_bool music_internal_playing(void) +{ + if (!music_playing) { + return SDL_FALSE; + } + + if (music_playing->interface->IsPlaying) { + music_playing->playing = music_playing->interface->IsPlaying(music_playing->context); + } + return music_playing->playing; +} +int Mix_PlayingMusic(void) +{ + SDL_bool playing; + + Mix_LockAudio(); + playing = music_internal_playing(); + Mix_UnlockAudio(); + + return playing ? 1 : 0; +} + +/* Set the external music playback command */ +int Mix_SetMusicCMD(const char *command) +{ + Mix_HaltMusic(); + if (music_cmd) { + SDL_free(music_cmd); + music_cmd = NULL; + } + if (command) { + size_t length = SDL_strlen(command) + 1; + music_cmd = (char *)SDL_malloc(length); + if (music_cmd == NULL) { + return SDL_OutOfMemory(); + } + SDL_memcpy(music_cmd, command, length); + } + return 0; +} + +int Mix_SetSynchroValue(int i) +{ + /* Not supported by any players at this time */ + (void) i; + return -1; +} + +int Mix_GetSynchroValue(void) +{ + /* Not supported by any players at this time */ + return -1; +} + + +/* Uninitialize the music interfaces */ +void close_music(void) +{ + size_t i; + + Mix_HaltMusic(); + + for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { + Mix_MusicInterface *interface = s_music_interfaces[i]; + if (!interface || !interface->opened) { + continue; + } + + if (interface->Close) { + interface->Close(); + } + interface->opened = SDL_FALSE; + } + + if (soundfont_paths) { + SDL_free(soundfont_paths); + soundfont_paths = NULL; + } + + /* rcg06042009 report available decoders at runtime. */ + if (music_decoders) { + SDL_free((void *)music_decoders); + music_decoders = NULL; + } + num_decoders = 0; + + ms_per_step = 0; +} + +/* Unload the music interface libraries */ +void unload_music(void) +{ + size_t i; + for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { + Mix_MusicInterface *interface = s_music_interfaces[i]; + if (!interface || !interface->loaded) { + continue; + } + + if (interface->Unload) { + interface->Unload(); + } + interface->loaded = SDL_FALSE; + } +} + +int Mix_SetTimidityCfg(const char *path) +{ + if (timidity_cfg) { + SDL_free(timidity_cfg); + timidity_cfg = NULL; + } + + if (path && *path) { + if (!(timidity_cfg = SDL_strdup(path))) { + Mix_SetError("Insufficient memory to set Timidity cfg file"); + return 0; + } + } + + return 1; +} + +const char* Mix_GetTimidityCfg(void) +{ + return timidity_cfg; +} + +int Mix_SetSoundFonts(const char *paths) +{ + if (soundfont_paths) { + SDL_free(soundfont_paths); + soundfont_paths = NULL; + } + + if (paths) { + if (!(soundfont_paths = SDL_strdup(paths))) { + Mix_SetError("Insufficient memory to set SoundFonts"); + return 0; + } + } + return 1; +} + +const char* Mix_GetSoundFonts(void) +{ + const char *env_paths = SDL_getenv("SDL_SOUNDFONTS"); + SDL_bool force_env_paths = SDL_GetHintBoolean("SDL_FORCE_SOUNDFONTS", SDL_FALSE); + if (force_env_paths && (!env_paths || !*env_paths)) { + force_env_paths = SDL_FALSE; + } + if (soundfont_paths && *soundfont_paths && !force_env_paths) { + return soundfont_paths; + } + if (env_paths) { + return env_paths; + } + + /* We don't have any sound fonts set programmatically or in the environment + Time to start guessing where they might be... + */ + { + static char *s_soundfont_paths[] = { + "/usr/share/sounds/sf2/FluidR3_GM.sf2" /* Remember to add ',' here */ + }; + unsigned i; + + for (i = 0; i < SDL_arraysize(s_soundfont_paths); ++i) { + SDL_RWops *rwops = SDL_RWFromFile(s_soundfont_paths[i], "rb"); + if (rwops) { + SDL_RWclose(rwops); + return s_soundfont_paths[i]; + } + } + } + return NULL; +} + +int Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data) +{ + char *context, *path, *paths; + const char* cpaths = Mix_GetSoundFonts(); + int soundfonts_found = 0; + + if (!cpaths) { + Mix_SetError("No SoundFonts have been requested"); + return 0; + } + + if (!(paths = SDL_strdup(cpaths))) { + Mix_SetError("Insufficient memory to iterate over SoundFonts"); + return 0; + } + +#if defined(_WIN32) || defined(__OS2__) +#define PATHSEP ";" +#else +#define PATHSEP ":;" +#endif + for (path = SDL_strtokr(paths, PATHSEP, &context); path; + path = SDL_strtokr(NULL, PATHSEP, &context)) { + if (!function(path, data)) { + continue; + } + soundfonts_found++; + } + + SDL_free(paths); + return (soundfonts_found > 0); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/music.h b/src/music.h new file mode 100644 index 0000000..4f1b437 --- /dev/null +++ b/src/music.h @@ -0,0 +1,174 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_mixer.h" + +#ifndef MUSIC_H_ +#define MUSIC_H_ + +/* Supported music APIs, in order of preference */ + +typedef enum +{ + MIX_MUSIC_CMD, + MIX_MUSIC_WAVE, + MIX_MUSIC_MODPLUG, + MIX_MUSIC_MIKMOD, + MIX_MUSIC_FLUIDSYNTH, + MIX_MUSIC_TIMIDITY, + MIX_MUSIC_NATIVEMIDI, + MIX_MUSIC_OGG, + MIX_MUSIC_MPG123, + MIX_MUSIC_MAD, + MIX_MUSIC_FLAC, + MIX_MUSIC_OPUS, + MIX_MUSIC_LIBXMP, + MIX_MUSIC_LAST +} Mix_MusicAPI; + + +/* Supported meta-tags */ + +typedef enum +{ + MIX_META_TITLE, + MIX_META_ARTIST, + MIX_META_ALBUM, + MIX_META_COPYRIGHT, + MIX_META_LAST +} Mix_MusicMetaTag; + + +/* MIXER-X: Meta-tags utility structure */ + +typedef struct { + char *tags[4]; +} Mix_MusicMetaTags; + + +extern void meta_tags_init(Mix_MusicMetaTags *tags); +extern void meta_tags_clear(Mix_MusicMetaTags *tags); +extern void meta_tags_set(Mix_MusicMetaTags *tags, Mix_MusicMetaTag type, const char *value); +extern const char* meta_tags_get(Mix_MusicMetaTags *tags, Mix_MusicMetaTag type); + + +/* Music API implementation */ + +typedef struct +{ + const char *tag; + Mix_MusicAPI api; + Mix_MusicType type; + SDL_bool loaded; + SDL_bool opened; + + /* Load the library */ + int (*Load)(void); + + /* Initialize for the audio output */ + int (*Open)(const SDL_AudioSpec *spec); + + /* Create a music object from an SDL_RWops stream + * If the function returns NULL, 'src' will be freed if needed by the caller. + */ + void *(*CreateFromRW)(SDL_RWops *src, int freesrc); + + /* Create a music object from a file, if SDL_RWops are not supported */ + void *(*CreateFromFile)(const char *file); + + /* Set the volume */ + void (*SetVolume)(void *music, int volume); + + /* Get the volume */ + int (*GetVolume)(void *music); + + /* Start playing music from the beginning with an optional loop count */ + int (*Play)(void *music, int play_count); + + /* Returns SDL_TRUE if music is still playing */ + SDL_bool (*IsPlaying)(void *music); + + /* Get music data, returns the number of bytes left */ + int (*GetAudio)(void *music, void *data, int bytes); + + /* Jump to a given order in mod music */ + int (*Jump)(void *music, int order); + + /* Seek to a play position (in seconds) */ + int (*Seek)(void *music, double position); + + /* Tell a play position (in seconds) */ + double (*Tell)(void *music); + + /* Get Music duration (in seconds) */ + double (*Duration)(void *music); + + /* Tell a loop start position (in seconds) */ + double (*LoopStart)(void *music); + + /* Tell a loop end position (in seconds) */ + double (*LoopEnd)(void *music); + + /* Tell a loop length position (in seconds) */ + double (*LoopLength)(void *music); + + /* Get a meta-tag string if available */ + const char* (*GetMetaTag)(void *music, Mix_MusicMetaTag tag_type); + + /* Pause playing music */ + void (*Pause)(void *music); + + /* Resume playing music */ + void (*Resume)(void *music); + + /* Stop playing music */ + void (*Stop)(void *music); + + /* Delete a music object */ + void (*Delete)(void *music); + + /* Close the library and clean up */ + void (*Close)(void); + + /* Unload the library */ + void (*Unload)(void); + +} Mix_MusicInterface; + + +extern int get_num_music_interfaces(void); +extern Mix_MusicInterface *get_music_interface(int index); +extern Mix_MusicType detect_music_type(SDL_RWops *src); +extern SDL_bool load_music_type(Mix_MusicType type); +extern SDL_bool open_music_type(Mix_MusicType type); +extern SDL_bool has_music(Mix_MusicType type); +extern void open_music(const SDL_AudioSpec *spec); +extern int music_pcm_getaudio(void *context, void *data, int bytes, int volume, + int (*GetSome)(void *context, void *data, int bytes, SDL_bool *done)); +extern void SDLCALL music_mixer(void *udata, Uint8 *stream, int len); +extern void close_music(void); +extern void unload_music(void); + +extern char *music_cmd; +extern SDL_AudioSpec music_spec; + +#endif /* MUSIC_H_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/utils.c b/src/utils.c new file mode 100644 index 0000000..d884b3d --- /dev/null +++ b/src/utils.c @@ -0,0 +1,141 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* misc helper routines */ + +#include "utils.h" +#include + +#if !defined(HAVE_SDL_STRTOKR) +/* + * Adapted from _PDCLIB_strtok() of PDClib library at + * https://github.com/DevSolar/pdclib.git + * + * The code was under CC0 license: + * https://creativecommons.org/publicdomain/zero/1.0/legalcode : + * + * No Copyright + * + * The person who associated a work with this deed has dedicated the + * work to the public domain by waiving all of his or her rights to + * the work worldwide under copyright law, including all related and + * neighboring rights, to the extent allowed by law. + * + * You can copy, modify, distribute and perform the work, even for + * commercial purposes, all without asking permission. See Other + * Information below. + */ +char *SDL_strtokr(char *s1, const char *s2, char **ptr) +{ + const char *p = s2; + + if (!s2 || !ptr || (!s1 && !*ptr)) return NULL; + + if (s1 != NULL) { /* new string */ + *ptr = s1; + } else { /* old string continued */ + if (*ptr == NULL) { + /* No old string, no new string, nothing to do */ + return NULL; + } + s1 = *ptr; + } + + /* skip leading s2 characters */ + while (*p && *s1) { + if (*s1 == *p) { + /* found separator; skip and start over */ + ++s1; + p = s2; + continue; + } + ++p; + } + + if (! *s1) { /* no more to parse */ + *ptr = s1; + return NULL; + } + + /* skipping non-s2 characters */ + *ptr = s1; + while (**ptr) { + p = s2; + while (*p) { + if (**ptr == *p++) { + /* found separator; overwrite with '\0', position *ptr, return */ + *((*ptr)++) = '\0'; + return s1; + } + } + ++(*ptr); + } + + /* parsed to end of string */ + return s1; +} +#endif /* HAVE_SDL_STRTOKR */ + +/* Is given tag a loop tag? */ +SDL_bool _Mix_IsLoopTag(const char *tag) +{ + char buf[5]; + SDL_strlcpy(buf, tag, 5); + return SDL_strcasecmp(buf, "LOOP") == 0; +} + +/* Parse time string of the form HH:MM:SS.mmm and return equivalent sample + * position */ +Sint64 _Mix_ParseTime(char *time, long samplerate_hz) +{ + char *num_start, *p; + Sint64 result; + char c; + int val; + + /* Time is directly expressed as a sample position */ + if (SDL_strchr(time, ':') == NULL) { + return SDL_strtoll(time, NULL, 10); + } + + result = 0; + num_start = time; + + for (p = time; *p != '\0'; ++p) { + if (*p == '.' || *p == ':') { + c = *p; *p = '\0'; + if ((val = SDL_atoi(num_start)) < 0) + return -1; + result = result * 60 + val; + num_start = p + 1; + *p = c; + } + + if (*p == '.') { + double val_f = SDL_atof(p); + if (val_f < 0) return -1; + return result * samplerate_hz + (Sint64) (val_f * samplerate_hz); + } + } + + if ((val = SDL_atoi(num_start)) < 0) return -1; + return (result * 60 + val) * samplerate_hz; +} diff --git a/src/utils.h b/src/utils.h new file mode 100644 index 0000000..990ea35 --- /dev/null +++ b/src/utils.h @@ -0,0 +1,44 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2021 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef UTILS_H_ +#define UTILS_H_ + +/* misc helper routines */ + +#include "SDL_stdinc.h" +#include "SDL_version.h" + +#if SDL_VERSION_ATLEAST(2,0,12) +#define HAVE_SDL_STRTOKR +#else +#define SDL_strtokr _MIX_strtokr +extern char *SDL_strtokr(char *s1, const char *s2, char **saveptr); +#endif + +/* Parse time string of the form HH:MM:SS.mmm and return equivalent sample + * position */ +extern Sint64 _Mix_ParseTime(char *time, long samplerate_hz); + +extern SDL_bool _Mix_IsLoopTag(const char *tag); + +#endif /* UTILS_H_ */ + diff --git a/timidity/Android.mk b/timidity/Android.mk deleted file mode 100644 index 17585a7..0000000 --- a/timidity/Android.mk +++ /dev/null @@ -1,24 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := timidity - -LOCAL_C_INCLUDES := - -LOCAL_CFLAGS := - -LOCAL_SRC_FILES += \ - common.c \ - instrum.c \ - mix.c \ - output.c \ - playmidi.c \ - readmidi.c \ - resample.c \ - tables.c \ - timidity.c - -LOCAL_SHARED_LIBRARIES := SDL2 - -include $(BUILD_STATIC_LIBRARY) diff --git a/timidity/CHANGES b/timidity/CHANGES deleted file mode 100644 index ab79e99..0000000 --- a/timidity/CHANGES +++ /dev/null @@ -1,77 +0,0 @@ -This version of TiMidity should contain all the fixes from the -September 25 2003 SDL_mixer CVS snapshot. In addition, I've made some -changes of my own, e.g.: - -* All file access is done through SDL_RWops. This means the MIDI - stream no longer has to be a file. (The config file and instruments - still have to be though.) - -* Replacing of TiMidity's endian-handling with SDL's. - -* Removal of much unused or unnecessary code, such as - - + The "hooks" for putting a user interface onto TiMidity. - + The antialias filter. It wasn't active, and even at 4 kHz I - couldn't hear any difference when activating it. - + Removed all traces of LOOKUP_HACK and LOOKUP_INTERPOLATION. - According to the code comments they weren't very good anyway. - ("degrades sound quality noticeably"). I also removed the - disclaimer about the "8-bit uLaw to 16-bit PCM and the 13-bit-PCM - to 8-bit uLaw tables" disclaimer, since I believe those were the - tables I removed. - + Removed LOOKUP_SINE since it was already commented out. I think we - can count on our target audience having math co-processors - nowadays. - + Removed USE_LDEXP since it wasn't being used and "it doesn't make - much of a difference either way". - + Removed decompress hack from open_file() since it didn't look very - portable. - + Removed heaps of unnecessary constants. - + Removed unused functions. - + Assume that LINEAR_INTERPOLATION is always used, so remove all - code dealing with it not being so. It's not that I think the - difference in audio quality is that great, but since it wouldn't - compile without code changes I assume no one's used it for quite - some time... - + Assume PRECALC_LOOPS is always defined. Judging by the comments it - may not make much of a difference either way, so why maintain two - versions of the same code? - -* Moving several static globals into the MidiSong struct. This - includes sample rate, formate, etc. which are now all per-song. - -* Moved some typedefs (e.g. MidiSong) to timidity.h for easy inclusion - into the MIDI decoder. - -* Added free_pathlist(). - -* Replaced TiMidity's own 8, 16 and 32-bit types with SDL's. - -* Made TiMidity look for its configuration file in both /etc and - /usr/local/lib/timidity. (Windows version remains unchanged.) - -* Timidity_PlaySome() now takes three arguments. A MidiSong, a decode - buffer and decode buffer size in bytes. (MidiSong is a new argument, - and buffer size used to be in samples.) - - In addition, it will return the number of bytes decoded. - -* Added Timidity_Exit(). - -* Removed Timidity_Stop() and Timidity_Active(). Stopping playback - should be handled by SDL_sound, and Timidity_PlaySome() will return - 0 when the MIDI stream is finished. - -* Modified the ToneBank stuff to allow some data to be shared between - MidiSongs. - -* The following files have been removed: controls.c, controls.h, - filter.c, filter.h, sdl_a.c, sdl_c.c - -* config.h has been renamed as options.h to avoid confusion with the - automatically generated config.h for SDL_sound. - -* Added support for loading DLS format instruments: - Timidity_LoadDLS(), Timidity_FreeDLS(), Timidity_LoadDLSSong() - -* Added Timidity_Init_NoConfig() diff --git a/timidity/COPYING b/timidity/COPYING deleted file mode 100644 index cdbb291..0000000 --- a/timidity/COPYING +++ /dev/null @@ -1,127 +0,0 @@ - The "Artistic License" - - Preamble - -The intent of this document is to state the conditions under which a -Package may be copied, such that the Copyright Holder maintains some -semblance of artistic control over the development of the package, -while giving the users of the package the right to use and distribute -the Package in a more-or-less customary fashion, plus the right to make -reasonable modifications. - -Definitions: - - "Package" refers to the collection of files distributed by the - Copyright Holder, and derivatives of that collection of files - created through textual modification. - - "Standard Version" refers to such a Package if it has not been - modified, or has been modified in accordance with the wishes - of the Copyright Holder as specified below. - - "Copyright Holder" is whoever is named in the copyright or - copyrights for the package. - - "You" is you, if you're thinking about copying or distributing - this Package. - - "Reasonable copying fee" is whatever you can justify on the - basis of media cost, duplication charges, time of people involved, - and so on. (You will not be required to justify it to the - Copyright Holder, but only to the computing community at large - as a market that must bear the fee.) - - "Freely Available" means that no fee is charged for the item - itself, though there may be fees involved in handling the item. - It also means that recipients of the item may redistribute it - under the same conditions they received it. - -1. You may make and give away verbatim copies of the source form of the -Standard Version of this Package without restriction, provided that you -duplicate all of the original copyright notices and associated disclaimers. - -2. You may apply bug fixes, portability fixes and other modifications -derived from the Public Domain or from the Copyright Holder. A Package -modified in such a way shall still be considered the Standard Version. - -3. You may otherwise modify your copy of this Package in any way, provided -that you insert a prominent notice in each changed file stating how and -when you changed that file, and provided that you do at least ONE of the -following: - - a) place your modifications in the Public Domain or otherwise make them - Freely Available, such as by posting said modifications to Usenet or - an equivalent medium, or placing the modifications on a major archive - site such as uunet.uu.net, or by allowing the Copyright Holder to include - your modifications in the Standard Version of the Package. - - b) use the modified Package only within your corporation or organization. - - c) rename any non-standard executables so the names do not conflict - with standard executables, which must also be provided, and provide - a separate manual page for each non-standard executable that clearly - documents how it differs from the Standard Version. - - d) make other distribution arrangements with the Copyright Holder. - -4. You may distribute the programs of this Package in object code or -executable form, provided that you do at least ONE of the following: - - a) distribute a Standard Version of the executables and library files, - together with instructions (in the manual page or equivalent) on where - to get the Standard Version. - - b) accompany the distribution with the machine-readable source of - the Package with your modifications. - - c) give non-standard executables non-standard names, and clearly - document the differences in manual pages (or equivalent), together - with instructions on where to get the Standard Version. - - d) make other distribution arrangements with the Copyright Holder. - -5. You may charge a reasonable copying fee for any distribution of this -Package. You may charge any fee you choose for support of this -Package. You may not charge a fee for this Package itself. However, -you may distribute this Package in aggregate with other (possibly -commercial) programs as part of a larger (possibly commercial) software -distribution provided that you do not advertise this Package as a -product of your own. You may embed this Package's interpreter within -an executable of yours (by linking); this shall be construed as a mere -form of aggregation, provided that the complete Standard Version of the -interpreter is so embedded. - -6. The scripts and library files supplied as input to or produced as -output from the programs of this Package do not automatically fall -under the copyright of this Package, but belong to whoever generated -them, and may be sold commercially, and may be aggregated with this -Package. If such scripts or library files are aggregated with this -Package via the so-called "undump" or "unexec" methods of producing a -binary executable image, then distribution of such an image shall -neither be construed as a distribution of this Package nor shall it -fall under the restrictions of Paragraphs 3 and 4, provided that you do -not represent such an executable image as a Standard Version of this -Package. - -7. C subroutines (or comparably compiled subroutines in other -languages) supplied by you and linked into this Package in order to -emulate subroutines and variables of the language defined by this -Package shall not be considered part of this Package, but are the -equivalent of input as in Paragraph 6, provided these subroutines do -not change the language in any way that would cause it to fail the -regression tests for the language. - -8. Aggregation of this Package with a commercial distribution is always -permitted provided that the use of this Package is embedded; that is, -when no overt attempt is made to make this Package's interfaces visible -to the end user of the commercial distribution. Such use shall not be -construed as a distribution of this Package. - -9. The name of the Copyright Holder may not be used to endorse or promote -products derived from this software without specific prior written permission. - -10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - - The End diff --git a/timidity/FAQ b/timidity/FAQ deleted file mode 100644 index 1ee0b77..0000000 --- a/timidity/FAQ +++ /dev/null @@ -1,100 +0,0 @@ ----------------------------*-indented-text-*------------------------------ - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - --------------------------------------------------------------------------- - - Frequently Asked Questions with answers: - --------------------------------------------------------------------------- -Q: What is it? - -A: Where? Well Chris, TiMidity is a software-only synthesizer, MIDI - renderer, MIDI to WAVE converter, realtime MIDI player for UNIX machines, - even (I've heard) a Netscape helper application. It takes a MIDI file - and writes a WAVE or raw PCM data or plays it on your digital audio - device. It sounds much more realistic than FM synthesis, but you need a - ~100Mhz processor to listen to 32kHz stereo music in the background while - you work. 11kHz mono can be played on a low-end 486, and, to some, it - still sounds better than FM. - --------------------------------------------------------------------------- -Q: I don't have a GUS, can I use TiMidity? - -A: Yes. That's the point. You don't need a Gravis Ultrasound to use - TiMidity, you just need GUS-compatible patches, which are freely - available on the Internet. See below for pointers. - --------------------------------------------------------------------------- -Q: I have a GUS, can I use TiMidity? - -A: The DOS port doesn't have GUS support, and TiMidity won't be taking - advantage of the board's internal synthesizer under other operating - systems either. So it kind of defeats the purpose. But you can use it. - --------------------------------------------------------------------------- -Q: I tried playing a MIDI file I got off the Net but all I got was a - dozen warnings saying "No instrument mapped to tone bank 0, program - xx - this instrument will not be heard". What's wrong? - -A: The General MIDI standard specifies 128 melodic instruments and - some sixty percussion sounds. If you wish to play arbitrary General - MIDI files, you'll need to get more patch files. - - There's a program called Midia for SGI's, which also plays MIDI - files and has a lot more bells and whistles than TiMidity. It uses - GUS-compatible patches, too -- so you can get the 8 MB set at - ftp://archive.cs.umbc.edu/pub/midia for pretty good GM compatibility. - - There are also many excellent patches on the Ultrasound FTP sites. - I can recommend Dustin McCartney's collections gsdrum*.zip and - wow*.zip in the "[.../]sound/patches/files" directory. The huge - ProPats series (pp3-*.zip) contains good patches as well. General - MIDI files can also be found on these sites. - - This site list is from the GUS FAQ: - -> FTP Sites Archive Directories -> --------- ------------------- -> Main N.American Site: archive.orst.edu pub/packages/gravis -> wuarchive.wustl.edu systems/ibmpc/ultrasound -> Main Asian Site: nctuccca.edu.tw PC/ultrasound -> Main European Site: src.doc.ic.ac.uk packages/ultrasound -> Main Australian Site: ftp.mpx.com.au /ultrasound/general -> /ultrasound/submit -> South African Site: ftp.sun.ac.za /pub/packages/ultrasound -> Submissions: archive.epas.utoronto.ca pub/pc/ultrasound/submit -> Newly Validated Files: archive.epas.utoronto.ca pub/pc/ultrasound -> -> Mirrors: garbo.uwasa.fi mirror/ultrasound -> ftp.st.nepean.uws.edu.au pc/ultrasound -> ftp.luth.se pub/msdos/ultrasound - --------------------------------------------------------------------------- -Q: Some files have awful clicks and pops. - -A: Find out which patch is responsible for the clicking (try "timidity - -P ". Add "strip=tail" in - the config file after its name. If this doesn't fix it, mail me the - patch. - --------------------------------------------------------------------------- -Q: I'm playing Fantasie Impromptu in the background. When I run Netscape, - the sound gets choppy and it takes ten minutes to load. What can I do? - -A: Here are some things to try: - - - Use a lower sampling rate. - - - Use mono output. This can improve performance by 10-30%. - (Using 8-bit instead of 16-bit output makes no difference.) - - - Use a smaller number of simultaneous voices. - - - Make sure you compiled with FAST_DECAY enabled in options.h - - - Recompile with an Intel-optimized gcc for a 5-15% - performance increase. - --------------------------------------------------------------------------- diff --git a/timidity/README b/timidity/README deleted file mode 100644 index 0dd9892..0000000 --- a/timidity/README +++ /dev/null @@ -1,58 +0,0 @@ -[This version of timidity has been stripped for simplicity in porting to SDL, -and then even further for SDL_sound] ----------------------------------*-text-*--------------------------------- - - From http://www.cgs.fi/~tt/discontinued.html : - - If you'd like to continue hacking on TiMidity, feel free. I'm - hereby extending the TiMidity license agreement: you can now - select the most convenient license for your needs from (1) the - GNU GPL, (2) the GNU LGPL, or (3) the Perl Artistic License. - --------------------------------------------------------------------------- - - This is the README file for TiMidity v0.2i - - TiMidity is a MIDI to WAVE converter that uses Gravis -Ultrasound(*)-compatible patch files to generate digital audio data -from General MIDI files. The audio data can be played through any -sound device or stored on disk. On a fast machine, music can be -played in real time. TiMidity runs under Linux, FreeBSD, HP-UX, SunOS, and -Win32, and porting to other systems with gcc should be easy. - - TiMidity Features: - - * 32 or more dynamically allocated fully independent voices - * Compatibility with GUS patch files - * Output to 16- or 8-bit PCM or uLaw audio device, file, or - stdout at any sampling rate - * Optional interactive mode with real-time status display - under ncurses and SLang terminal control libraries. Also - a user friendly motif interface since version 0.2h - * Support for transparent loading of compressed MIDI files and - patch files - - * Support for the following MIDI events: - - Program change - - Key pressure - - Channel main volume - - Tempo - - Panning - - Damper pedal (Sustain) - - Pitch wheel - - Pitch wheel sensitivity - - Change drum set - -* TiMidity requires sampled instruments (patches) to play MIDI files. You - should get the file "timidity-lib-0.1.tar.gz" and unpack it in the same - directory where you unpacked the source code archive. You'll want more - patches later -- read the file "FAQ" for pointers. - -* Timidity is no longer supported, but can be found by searching the web. - - - Tuukka Toivonen - -[(*) Any Registered Trademarks used anywhere in the documentation or -source code for TiMidity are acknowledged as belonging to their -respective owners.] diff --git a/timidity/TODO b/timidity/TODO deleted file mode 100644 index 69b37ee..0000000 --- a/timidity/TODO +++ /dev/null @@ -1,37 +0,0 @@ -* I don't like the indentation style at all, but for the most part - I've left it alone. - -* Much of the code looks ugly to me. - -* The return value from SDL_RWread() is checked inconsistenly. - -* Group the members of MidiSong into logical units, i.e. structs? - -* The debug messages are probably a bit too noisy. I've removed one - particularly annoying one, but... - - Some of them should be turned into error messages instead. - -* Can the instrument handling be made more efficient? At the moment - different MidiSongs may separately load the same instrument. - - Note that the MidiSong's audio format affects how the instrument is - loaded, so it's not as easy as just letting all MidiSongs share tone - and drum banks. - - At the moment they do share the data that is simply read from the - config file, but that's just a quick hack to avoid having to read - the config file every time a MIDI song is loaded. - -* Check if any of MidiStruct's members can safely be made into static - globals again. - -* TiMidity++ adds a number of undocumented (?) extensions to the - configuration syntax. These are not implemented here. In particular, - the "map" keyword used by the "eawpats". - -* The other decoders generally only read as much of the file as is - necessary. Could we do that in this decoder as well? (Currently it - seems to convert the entire file into MIDI events first.) - -* Can it be optimized? diff --git a/timidity/common.c b/timidity/common.c deleted file mode 100644 index 2cd34a1..0000000 --- a/timidity/common.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - - common.c -*/ - -#if HAVE_CONFIG_H -# include -#endif - -#include -#include -#include - -#include "SDL.h" - -#include "options.h" -#include "common.h" - -/* The paths in this list will be tried whenever we're reading a file */ -static PathList *pathlist = NULL; /* This is a linked list */ - -/* This is meant to find and open files for reading */ -SDL_RWops *open_file(const char *name) -{ - SDL_RWops *rw; - - if (!name || !(*name)) - { - SNDDBG(("Attempted to open nameless file.\n")); - return 0; - } - - /* First try the given name */ - - SNDDBG(("Trying to open %s\n", name)); - if ((rw = SDL_RWFromFile(name, "rb"))) - return rw; - - if (name[0] != PATH_SEP) - { - char current_filename[1024]; - PathList *plp = pathlist; - size_t l; - - while (plp) /* Try along the path then */ - { - *current_filename = 0; - l = strlen(plp->path); - if(l) - { - strcpy(current_filename, plp->path); - if(current_filename[l - 1] != PATH_SEP) - { - current_filename[l] = PATH_SEP; - current_filename[l + 1] = '\0'; - } - } - strcat(current_filename, name); - SNDDBG(("Trying to open %s\n", current_filename)); - if ((rw = SDL_RWFromFile(current_filename, "rb"))) - return rw; - plp = plp->next; - } - } - - /* Nothing could be opened. */ - SNDDBG(("Could not open %s\n", name)); - return 0; -} - -/* This'll allocate memory or die. */ -void *safe_malloc(size_t count) -{ - void *p; - - p = malloc(count); - if (p == NULL) { - SNDDBG(("Sorry. Couldn't malloc %d bytes.\n", count)); - } - - return p; -} - -/* This adds a directory to the path list */ -void add_to_pathlist(const char *s) -{ - PathList *plp = safe_malloc(sizeof(PathList)); - - if (plp == NULL) - return; - - plp->path = safe_malloc(strlen(s) + 1); - if (plp->path == NULL) - { - free(plp); - return; - } - - strcpy(plp->path, s); - plp->next = pathlist; - pathlist = plp; -} - -void free_pathlist(void) -{ - PathList *plp = pathlist; - PathList *next; - - while (plp) - { - next = plp->next; - free(plp->path); - free(plp); - plp = next; - } - pathlist = NULL; -} diff --git a/timidity/common.h b/timidity/common.h deleted file mode 100644 index cd7ab66..0000000 --- a/timidity/common.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - - common.h -*/ - -typedef struct { - char *path; - void *next; -} PathList; - -extern SDL_RWops *open_file(const char *name); -extern void add_to_pathlist(const char *s); -extern void *safe_malloc(size_t count); -extern void free_pathlist(void); diff --git a/timidity/instrum.c b/timidity/instrum.c deleted file mode 100644 index dedbea0..0000000 --- a/timidity/instrum.c +++ /dev/null @@ -1,609 +0,0 @@ -/* - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - - instrum.c - - Code to load and unload GUS-compatible instrument patches. - -*/ - -#if HAVE_CONFIG_H -# include -#endif - -#include -#include -#include - -#include "SDL.h" - -#include "timidity.h" -#include "options.h" -#include "common.h" -#include "instrum.h" -#include "resample.h" -#include "tables.h" - -static void free_instrument(Instrument *ip) -{ - Sample *sp; - int i; - if (!ip) return; - for (i=0; isamples; i++) - { - sp=&(ip->sample[i]); - free(sp->data); - } - free(ip->sample); - free(ip); -} - -static void free_bank(MidiSong *song, int dr, int b) -{ - int i; - ToneBank *bank=((dr) ? song->drumset[b] : song->tonebank[b]); - for (i=0; iinstrument[i]) - { - /* Not that this could ever happen, of course */ - if (bank->instrument[i] != MAGIC_LOAD_INSTRUMENT) - free_instrument(bank->instrument[i]); - bank->instrument[i]=0; - } -} - -static Sint32 convert_envelope_rate(MidiSong *song, Uint8 rate) -{ - Sint32 r; - - r = 3 - ((rate >> 6) & 0x3); - r *= 3; - r = (Sint32) (rate & 0x3f) << r; /* 6.9 fixed point */ - - /* 15.15 fixed point. */ - r = ((r * 44100) / song->rate) * song->control_ratio; - -#ifdef FAST_DECAY - return r << 10; -#else - return r << 9; -#endif -} - -static Sint32 convert_envelope_offset(Uint8 offset) -{ - /* This is not too good... Can anyone tell me what these values mean? - Are they GUS-style "exponential" volumes? And what does that mean? */ - - /* 15.15 fixed point */ - return offset << (7+15); -} - -static Sint32 convert_tremolo_sweep(MidiSong *song, Uint8 sweep) -{ - if (!sweep) - return 0; - - return - ((song->control_ratio * SWEEP_TUNING) << SWEEP_SHIFT) / - (song->rate * sweep); -} - -static Sint32 convert_vibrato_sweep(MidiSong *song, Uint8 sweep, - Sint32 vib_control_ratio) -{ - if (!sweep) - return 0; - - return - (Sint32) (FSCALE((double) (vib_control_ratio) * SWEEP_TUNING, SWEEP_SHIFT) - / (double)(song->rate * sweep)); - - /* this was overflowing with seashore.pat - - ((vib_control_ratio * SWEEP_TUNING) << SWEEP_SHIFT) / - (song->rate * sweep); */ -} - -static Sint32 convert_tremolo_rate(MidiSong *song, Uint8 rate) -{ - return - ((SINE_CYCLE_LENGTH * song->control_ratio * rate) << RATE_SHIFT) / - (TREMOLO_RATE_TUNING * song->rate); -} - -static Sint32 convert_vibrato_rate(MidiSong *song, Uint8 rate) -{ - /* Return a suitable vibrato_control_ratio value */ - return - (VIBRATO_RATE_TUNING * song->rate) / - (rate * 2 * VIBRATO_SAMPLE_INCREMENTS); -} - -static void reverse_data(Sint16 *sp, Sint32 ls, Sint32 le) -{ - Sint16 s, *ep=sp+le; - sp+=ls; - le-=ls; - le/=2; - while (le--) - { - s=*sp; - *sp++=*ep; - *ep--=s; - } -} - -/* - If panning or note_to_use != -1, it will be used for all samples, - instead of the sample-specific values in the instrument file. - - For note_to_use, any value <0 or >127 will be forced to 0. - - For other parameters, 1 means yes, 0 means no, other values are - undefined. - - TODO: do reverse loops right */ -static Instrument *load_instrument(MidiSong *song, char *name, int percussion, - int panning, int amp, int note_to_use, - int strip_loop, int strip_envelope, - int strip_tail) -{ - Instrument *ip; - Sample *sp; - SDL_RWops *rw; - char tmp[1024]; - int i,j,noluck=0; - static char *patch_ext[] = PATCH_EXT_LIST; - - if (!name) return 0; - - /* Open patch file */ - if ((rw=open_file(name)) == NULL) - { - noluck=1; - /* Try with various extensions */ - for (i=0; patch_ext[i]; i++) - { - if (strlen(name)+strlen(patch_ext[i])<1024) - { - strcpy(tmp, name); - strcat(tmp, patch_ext[i]); - if ((rw=open_file(tmp)) != NULL) - { - noluck=0; - break; - } - } - } - } - - if (noluck) - { - SNDDBG(("Instrument `%s' can't be found.\n", name)); - return 0; - } - - SNDDBG(("Loading instrument %s\n", tmp)); - - /* Read some headers and do cursory sanity checks. There are loads - of magic offsets. This could be rewritten... */ - - if ((239 != SDL_RWread(rw, tmp, 1, 239)) || - (memcmp(tmp, "GF1PATCH110\0ID#000002", 22) && - memcmp(tmp, "GF1PATCH100\0ID#000002", 22))) /* don't know what the - differences are */ - { - SNDDBG(("%s: not an instrument\n", name)); - SDL_RWclose(rw); - return 0; - } - - if (tmp[82] != 1 && tmp[82] != 0) /* instruments. To some patch makers, - 0 means 1 */ - { - SNDDBG(("Can't handle patches with %d instruments\n", tmp[82])); - SDL_RWclose(rw); - return 0; - } - - if (tmp[151] != 1 && tmp[151] != 0) /* layers. What's a layer? */ - { - SNDDBG(("Can't handle instruments with %d layers\n", tmp[151])); - SDL_RWclose(rw); - return 0; - } - - ip=safe_malloc(sizeof(Instrument)); - ip->samples = tmp[198]; - ip->sample = safe_malloc(sizeof(Sample) * ip->samples); - for (i=0; isamples; i++) - { - - Uint8 fractions; - Sint32 tmplong; - Uint16 tmpshort; - Uint8 tmpchar; - -#define READ_CHAR(thing) \ - if (1 != SDL_RWread(rw, &tmpchar, 1, 1)) goto fail; \ - thing = tmpchar; -#define READ_SHORT(thing) \ - if (1 != SDL_RWread(rw, &tmpshort, 2, 1)) goto fail; \ - thing = SDL_SwapLE16(tmpshort); -#define READ_LONG(thing) \ - if (1 != SDL_RWread(rw, &tmplong, 4, 1)) goto fail; \ - thing = SDL_SwapLE32(tmplong); - - SDL_RWseek(rw, 7, RW_SEEK_CUR); /* Skip the wave name */ - - if (1 != SDL_RWread(rw, &fractions, 1, 1)) - { - fail: - SNDDBG(("Error reading sample %d\n", i)); - for (j=0; jsample[j].data); - free(ip->sample); - free(ip); - SDL_RWclose(rw); - return 0; - } - - sp=&(ip->sample[i]); - - READ_LONG(sp->data_length); - READ_LONG(sp->loop_start); - READ_LONG(sp->loop_end); - READ_SHORT(sp->sample_rate); - READ_LONG(sp->low_freq); - READ_LONG(sp->high_freq); - READ_LONG(sp->root_freq); - SDL_RWseek(rw, 2, RW_SEEK_CUR); /* Why have a "root frequency" and then - * "tuning"?? */ - - READ_CHAR(tmp[0]); - - if (panning==-1) - sp->panning = (tmp[0] * 8 + 4) & 0x7f; - else - sp->panning=(Uint8)(panning & 0x7F); - - /* envelope, tremolo, and vibrato */ - if (18 != SDL_RWread(rw, tmp, 1, 18)) goto fail; - - if (!tmp[13] || !tmp[14]) - { - sp->tremolo_sweep_increment= - sp->tremolo_phase_increment=sp->tremolo_depth=0; - SNDDBG((" * no tremolo\n")); - } - else - { - sp->tremolo_sweep_increment=convert_tremolo_sweep(song, tmp[12]); - sp->tremolo_phase_increment=convert_tremolo_rate(song, tmp[13]); - sp->tremolo_depth=tmp[14]; - SNDDBG((" * tremolo: sweep %d, phase %d, depth %d\n", - sp->tremolo_sweep_increment, sp->tremolo_phase_increment, - sp->tremolo_depth)); - } - - if (!tmp[16] || !tmp[17]) - { - sp->vibrato_sweep_increment= - sp->vibrato_control_ratio=sp->vibrato_depth=0; - SNDDBG((" * no vibrato\n")); - } - else - { - sp->vibrato_control_ratio=convert_vibrato_rate(song, tmp[16]); - sp->vibrato_sweep_increment= - convert_vibrato_sweep(song, tmp[15], sp->vibrato_control_ratio); - sp->vibrato_depth=tmp[17]; - SNDDBG((" * vibrato: sweep %d, ctl %d, depth %d\n", - sp->vibrato_sweep_increment, sp->vibrato_control_ratio, - sp->vibrato_depth)); - - } - - READ_CHAR(sp->modes); - - SDL_RWseek(rw, 40, RW_SEEK_CUR); /* skip the useless scale frequency, scale - factor (what's it mean?), and reserved - space */ - - /* Mark this as a fixed-pitch instrument if such a deed is desired. */ - if (note_to_use!=-1) - sp->note_to_use=(Uint8)(note_to_use); - else - sp->note_to_use=0; - - /* seashore.pat in the Midia patch set has no Sustain. I don't - understand why, and fixing it by adding the Sustain flag to - all looped patches probably breaks something else. We do it - anyway. */ - - if (sp->modes & MODES_LOOPING) - sp->modes |= MODES_SUSTAIN; - - /* Strip any loops and envelopes we're permitted to */ - if ((strip_loop==1) && - (sp->modes & (MODES_SUSTAIN | MODES_LOOPING | - MODES_PINGPONG | MODES_REVERSE))) - { - SNDDBG((" - Removing loop and/or sustain\n")); - sp->modes &=~(MODES_SUSTAIN | MODES_LOOPING | - MODES_PINGPONG | MODES_REVERSE); - } - - if (strip_envelope==1) - { - if (sp->modes & MODES_ENVELOPE) { - SNDDBG((" - Removing envelope\n")); - } - sp->modes &= ~MODES_ENVELOPE; - } - else if (strip_envelope != 0) - { - /* Have to make a guess. */ - if (!(sp->modes & (MODES_LOOPING | MODES_PINGPONG | MODES_REVERSE))) - { - /* No loop? Then what's there to sustain? No envelope needed - either... */ - sp->modes &= ~(MODES_SUSTAIN|MODES_ENVELOPE); - SNDDBG((" - No loop, removing sustain and envelope\n")); - } - else if (!memcmp(tmp, "??????", 6) || tmp[11] >= 100) - { - /* Envelope rates all maxed out? Envelope end at a high "offset"? - That's a weird envelope. Take it out. */ - sp->modes &= ~MODES_ENVELOPE; - SNDDBG((" - Weirdness, removing envelope\n")); - } - else if (!(sp->modes & MODES_SUSTAIN)) - { - /* No sustain? Then no envelope. I don't know if this is - justified, but patches without sustain usually don't need the - envelope either... at least the Gravis ones. They're mostly - drums. I think. */ - sp->modes &= ~MODES_ENVELOPE; - SNDDBG((" - No sustain, removing envelope\n")); - } - } - - for (j=0; j<6; j++) - { - sp->envelope_rate[j]= - convert_envelope_rate(song, tmp[j]); - sp->envelope_offset[j]= - convert_envelope_offset(tmp[6+j]); - } - - /* Then read the sample data */ - sp->data = (sample_t *) safe_malloc(sp->data_length+4); - if (1 != SDL_RWread(rw, sp->data, sp->data_length, 1)) - goto fail; - - if (!(sp->modes & MODES_16BIT)) /* convert to 16-bit data */ - { - Sint32 k=sp->data_length; - Uint8 *cp=(Uint8 *)(sp->data); - Uint16 *tmp16,*new16; - sp->data_length *= 2; - sp->loop_start *= 2; - sp->loop_end *= 2; - tmp16 = new16 = (Uint16 *) safe_malloc(sp->data_length+4); - while (k--) - *tmp16++ = (Uint16)(*cp++) << 8; - free(sp->data); - sp->data = (sample_t *)new16; - } -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - else - /* convert to machine byte order */ - { - Sint32 k=sp->data_length/2; - Sint16 *tmp16=(Sint16 *)sp->data,s; - while (k--) - { - s=SDL_SwapLE16(*tmp16); - *tmp16++=s; - } - } -#endif - - if (sp->modes & MODES_UNSIGNED) /* convert to signed data */ - { - Sint32 k=sp->data_length/2; - Sint16 *tmp16=(Sint16 *)sp->data; - while (k--) - *tmp16++ ^= 0x8000; - } - - /* Reverse reverse loops and pass them off as normal loops */ - if (sp->modes & MODES_REVERSE) - { - Sint32 t; - /* The GUS apparently plays reverse loops by reversing the - whole sample. We do the same because the GUS does not SUCK. */ - - SNDDBG(("Reverse loop in %s\n", name)); - reverse_data((Sint16 *)sp->data, 0, sp->data_length/2); - - t=sp->loop_start; - sp->loop_start=sp->data_length - sp->loop_end; - sp->loop_end=sp->data_length - t; - - sp->modes &= ~MODES_REVERSE; - sp->modes |= MODES_LOOPING; /* just in case */ - } - -#ifdef ADJUST_SAMPLE_VOLUMES - if (amp!=-1) - sp->volume=(float)((amp) / 100.0); - else - { - /* Try to determine a volume scaling factor for the sample. - This is a very crude adjustment, but things sound more - balanced with it. Still, this should be a runtime option. */ - Sint32 k=sp->data_length/2; - Sint16 maxamp=0,a; - Sint16 *tmp16=(Sint16 *)sp->data; - while (k--) - { - a=*tmp16++; - if (a<0) a=-a; - if (a>maxamp) - maxamp=a; - } - sp->volume=(float)(32768.0 / maxamp); - SNDDBG((" * volume comp: %f\n", sp->volume)); - } -#else - if (amp!=-1) - sp->volume=(double)(amp) / 100.0; - else - sp->volume=1.0; -#endif - - sp->data_length /= 2; /* These are in bytes. Convert into samples. */ - sp->loop_start /= 2; - sp->loop_end /= 2; - - /* initialize the added extra sample space (see the +4 bytes in - allocation) using the last actual sample: */ - sp->data[sp->data_length] = sp->data[sp->data_length+1] = 0; - - /* Then fractional samples */ - sp->data_length <<= FRACTION_BITS; - sp->loop_start <<= FRACTION_BITS; - sp->loop_end <<= FRACTION_BITS; - - /* Adjust for fractional loop points. This is a guess. Does anyone - know what "fractions" really stands for? */ - sp->loop_start |= - (fractions & 0x0F) << (FRACTION_BITS-4); - sp->loop_end |= - ((fractions>>4) & 0x0F) << (FRACTION_BITS-4); - - /* If this instrument will always be played on the same note, - and it's not looped, we can resample it now. */ - if (sp->note_to_use && !(sp->modes & MODES_LOOPING)) - pre_resample(song, sp); - - if (strip_tail==1) - { - /* Let's not really, just say we did. */ - SNDDBG((" - Stripping tail\n")); - sp->data_length = sp->loop_end; - } - } - - SDL_RWclose(rw); - return ip; -} - -static int fill_bank(MidiSong *song, int dr, int b) -{ - int i, errors=0; - ToneBank *bank=((dr) ? song->drumset[b] : song->tonebank[b]); - if (!bank) - { - SNDDBG(("Huh. Tried to load instruments in non-existent %s %d\n", - (dr) ? "drumset" : "tone bank", b)); - return 0; - } - for (i=0; iinstrument[i]==MAGIC_LOAD_INSTRUMENT) - { - if (!(bank->tone[i].name)) - { - SNDDBG(("No instrument mapped to %s %d, program %d%s\n", - (dr)? "drum set" : "tone bank", b, i, - (b!=0) ? "" : " - this instrument will not be heard")); - if (b!=0) - { - /* Mark the corresponding instrument in the default - bank / drumset for loading (if it isn't already) */ - if (!dr) - { - if (!(song->tonebank[0]->instrument[i])) - song->tonebank[0]->instrument[i] = - MAGIC_LOAD_INSTRUMENT; - } - else - { - if (!(song->drumset[0]->instrument[i])) - song->drumset[0]->instrument[i] = - MAGIC_LOAD_INSTRUMENT; - } - } - bank->instrument[i] = 0; - errors++; - } - else if (!(bank->instrument[i] = - load_instrument(song, - bank->tone[i].name, - (dr) ? 1 : 0, - bank->tone[i].pan, - bank->tone[i].amp, - (bank->tone[i].note!=-1) ? - bank->tone[i].note : - ((dr) ? i : -1), - (bank->tone[i].strip_loop!=-1) ? - bank->tone[i].strip_loop : - ((dr) ? 1 : -1), - (bank->tone[i].strip_envelope != -1) ? - bank->tone[i].strip_envelope : - ((dr) ? 1 : -1), - bank->tone[i].strip_tail ))) - { - SNDDBG(("Couldn't load instrument %s (%s %d, program %d)\n", - bank->tone[i].name, - (dr)? "drum set" : "tone bank", b, i)); - errors++; - } - } - } - return errors; -} - -int load_missing_instruments(MidiSong *song) -{ - int i=MAXBANK,errors=0; - while (i--) - { - if (song->tonebank[i]) - errors+=fill_bank(song,0,i); - if (song->drumset[i]) - errors+=fill_bank(song,1,i); - } - return errors; -} - -void free_instruments(MidiSong *song) -{ - int i=MAXBANK; - while(i--) - { - if (song->tonebank[i]) - free_bank(song, 0, i); - if (song->drumset[i]) - free_bank(song, 1, i); - } -} - -int set_default_instrument(MidiSong *song, char *name) -{ - Instrument *ip; - if (!(ip=load_instrument(song, name, 0, -1, -1, -1, 0, 0, 0))) - return -1; - song->default_instrument = ip; - song->default_program = SPECIAL_PROGRAM; - return 0; -} diff --git a/timidity/instrum.h b/timidity/instrum.h deleted file mode 100644 index 3371fce..0000000 --- a/timidity/instrum.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - - instrum.h - - */ - -/* Bits in modes: */ -#define MODES_16BIT (1<<0) -#define MODES_UNSIGNED (1<<1) -#define MODES_LOOPING (1<<2) -#define MODES_PINGPONG (1<<3) -#define MODES_REVERSE (1<<4) -#define MODES_SUSTAIN (1<<5) -#define MODES_ENVELOPE (1<<6) - -/* A hack to delay instrument loading until after reading the - entire MIDI file. */ -#define MAGIC_LOAD_INSTRUMENT ((Instrument *) (-1)) - -#define SPECIAL_PROGRAM -1 - -extern int load_missing_instruments(MidiSong *song); -extern void free_instruments(MidiSong *song); -extern int set_default_instrument(MidiSong *song, char *name); diff --git a/timidity/mix.c b/timidity/mix.c deleted file mode 100644 index fc30819..0000000 --- a/timidity/mix.c +++ /dev/null @@ -1,557 +0,0 @@ -/* - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - - mix.c */ - -#if HAVE_CONFIG_H -# include -#endif - -#include -#include -#include - -#include "SDL.h" - -#include "timidity.h" -#include "options.h" -#include "instrum.h" -#include "playmidi.h" -#include "output.h" -#include "tables.h" -#include "resample.h" -#include "mix.h" - -/* Returns 1 if envelope runs out */ -int recompute_envelope(MidiSong *song, int v) -{ - int stage; - - stage = song->voice[v].envelope_stage; - - if (stage>5) - { - /* Envelope ran out. */ - song->voice[v].status = VOICE_FREE; - return 1; - } - - if (song->voice[v].sample->modes & MODES_ENVELOPE) - { - if (song->voice[v].status==VOICE_ON || song->voice[v].status==VOICE_SUSTAINED) - { - if (stage>2) - { - /* Freeze envelope until note turns off. Trumpets want this. */ - song->voice[v].envelope_increment=0; - return 0; - } - } - } - song->voice[v].envelope_stage=stage+1; - - if (song->voice[v].envelope_volume==song->voice[v].sample->envelope_offset[stage] || - (stage > 2 && song->voice[v].envelope_volume < - song->voice[v].sample->envelope_offset[stage])) - return recompute_envelope(song, v); - song->voice[v].envelope_target = song->voice[v].sample->envelope_offset[stage]; - song->voice[v].envelope_increment = song->voice[v].sample->envelope_rate[stage]; - if (song->voice[v].envelope_target < song->voice[v].envelope_volume) - song->voice[v].envelope_increment = -song->voice[v].envelope_increment; - return 0; -} - -void apply_envelope_to_amp(MidiSong *song, int v) -{ - float lamp = song->voice[v].left_amp, ramp; - Sint32 la,ra; - if (song->voice[v].panned == PANNED_MYSTERY) - { - ramp = song->voice[v].right_amp; - if (song->voice[v].tremolo_phase_increment) - { - lamp *= song->voice[v].tremolo_volume; - ramp *= song->voice[v].tremolo_volume; - } - if (song->voice[v].sample->modes & MODES_ENVELOPE) - { - lamp *= (float)vol_table[song->voice[v].envelope_volume>>23]; - ramp *= (float)vol_table[song->voice[v].envelope_volume>>23]; - } - - la = (Sint32)FSCALE(lamp,AMP_BITS); - - if (la>MAX_AMP_VALUE) - la=MAX_AMP_VALUE; - - ra = (Sint32)FSCALE(ramp,AMP_BITS); - if (ra>MAX_AMP_VALUE) - ra=MAX_AMP_VALUE; - - song->voice[v].left_mix = la; - song->voice[v].right_mix = ra; - } - else - { - if (song->voice[v].tremolo_phase_increment) - lamp *= song->voice[v].tremolo_volume; - if (song->voice[v].sample->modes & MODES_ENVELOPE) - lamp *= (float)vol_table[song->voice[v].envelope_volume>>23]; - - la = (Sint32)FSCALE(lamp,AMP_BITS); - - if (la>MAX_AMP_VALUE) - la=MAX_AMP_VALUE; - - song->voice[v].left_mix = la; - } -} - -static int update_envelope(MidiSong *song, int v) -{ - song->voice[v].envelope_volume += song->voice[v].envelope_increment; - /* Why is there no ^^ operator?? */ - if (((song->voice[v].envelope_increment < 0) && - (song->voice[v].envelope_volume <= song->voice[v].envelope_target)) || - ((song->voice[v].envelope_increment > 0) && - (song->voice[v].envelope_volume >= song->voice[v].envelope_target))) - { - song->voice[v].envelope_volume = song->voice[v].envelope_target; - if (recompute_envelope(song, v)) - return 1; - } - return 0; -} - -static void update_tremolo(MidiSong *song, int v) -{ - Sint32 depth = song->voice[v].sample->tremolo_depth << 7; - - if (song->voice[v].tremolo_sweep) - { - /* Update sweep position */ - - song->voice[v].tremolo_sweep_position += song->voice[v].tremolo_sweep; - if (song->voice[v].tremolo_sweep_position >= (1 << SWEEP_SHIFT)) - song->voice[v].tremolo_sweep=0; /* Swept to max amplitude */ - else - { - /* Need to adjust depth */ - depth *= song->voice[v].tremolo_sweep_position; - depth >>= SWEEP_SHIFT; - } - } - - song->voice[v].tremolo_phase += song->voice[v].tremolo_phase_increment; - - /* if (song->voice[v].tremolo_phase >= (SINE_CYCLE_LENGTH<voice[v].tremolo_phase -= SINE_CYCLE_LENGTH<voice[v].tremolo_volume = (float) - (1.0 - FSCALENEG((sine(song->voice[v].tremolo_phase >> RATE_SHIFT) + 1.0) - * depth * TREMOLO_AMPLITUDE_TUNING, - 17)); - - /* I'm not sure about the +1.0 there -- it makes tremoloed voices' - volumes on average the lower the higher the tremolo amplitude. */ -} - -/* Returns 1 if the note died */ -static int update_signal(MidiSong *song, int v) -{ - if (song->voice[v].envelope_increment && update_envelope(song, v)) - return 1; - - if (song->voice[v].tremolo_phase_increment) - update_tremolo(song, v); - - apply_envelope_to_amp(song, v); - return 0; -} - -#define MIXATION(a) *lp++ += (a)*s; - -static void mix_mystery_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v, - int count) -{ - Voice *vp = song->voice + v; - final_volume_t - left=vp->left_mix, - right=vp->right_mix; - int cc; - sample_t s; - - if (!(cc = vp->control_counter)) - { - cc = song->control_ratio; - if (update_signal(song, v)) - return; /* Envelope ran out */ - left = vp->left_mix; - right = vp->right_mix; - } - - while (count) - if (cc < count) - { - count -= cc; - while (cc--) - { - s = *sp++; - MIXATION(left); - MIXATION(right); - } - cc = song->control_ratio; - if (update_signal(song, v)) - return; /* Envelope ran out */ - left = vp->left_mix; - right = vp->right_mix; - } - else - { - vp->control_counter = cc - count; - while (count--) - { - s = *sp++; - MIXATION(left); - MIXATION(right); - } - return; - } -} - -static void mix_center_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v, - int count) -{ - Voice *vp = song->voice + v; - final_volume_t - left=vp->left_mix; - int cc; - sample_t s; - - if (!(cc = vp->control_counter)) - { - cc = song->control_ratio; - if (update_signal(song, v)) - return; /* Envelope ran out */ - left = vp->left_mix; - } - - while (count) - if (cc < count) - { - count -= cc; - while (cc--) - { - s = *sp++; - MIXATION(left); - MIXATION(left); - } - cc = song->control_ratio; - if (update_signal(song, v)) - return; /* Envelope ran out */ - left = vp->left_mix; - } - else - { - vp->control_counter = cc - count; - while (count--) - { - s = *sp++; - MIXATION(left); - MIXATION(left); - } - return; - } -} - -static void mix_single_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v, - int count) -{ - Voice *vp = song->voice + v; - final_volume_t - left=vp->left_mix; - int cc; - sample_t s; - - if (!(cc = vp->control_counter)) - { - cc = song->control_ratio; - if (update_signal(song, v)) - return; /* Envelope ran out */ - left = vp->left_mix; - } - - while (count) - if (cc < count) - { - count -= cc; - while (cc--) - { - s = *sp++; - MIXATION(left); - lp++; - } - cc = song->control_ratio; - if (update_signal(song, v)) - return; /* Envelope ran out */ - left = vp->left_mix; - } - else - { - vp->control_counter = cc - count; - while (count--) - { - s = *sp++; - MIXATION(left); - lp++; - } - return; - } -} - -static void mix_mono_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v, - int count) -{ - Voice *vp = song->voice + v; - final_volume_t - left=vp->left_mix; - int cc; - sample_t s; - - if (!(cc = vp->control_counter)) - { - cc = song->control_ratio; - if (update_signal(song, v)) - return; /* Envelope ran out */ - left = vp->left_mix; - } - - while (count) - if (cc < count) - { - count -= cc; - while (cc--) - { - s = *sp++; - MIXATION(left); - } - cc = song->control_ratio; - if (update_signal(song, v)) - return; /* Envelope ran out */ - left = vp->left_mix; - } - else - { - vp->control_counter = cc - count; - while (count--) - { - s = *sp++; - MIXATION(left); - } - return; - } -} - -static void mix_mystery(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count) -{ - final_volume_t - left = song->voice[v].left_mix, - right = song->voice[v].right_mix; - sample_t s; - - while (count--) - { - s = *sp++; - MIXATION(left); - MIXATION(right); - } -} - -static void mix_center(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count) -{ - final_volume_t - left = song->voice[v].left_mix; - sample_t s; - - while (count--) - { - s = *sp++; - MIXATION(left); - MIXATION(left); - } -} - -static void mix_single(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count) -{ - final_volume_t - left = song->voice[v].left_mix; - sample_t s; - - while (count--) - { - s = *sp++; - MIXATION(left); - lp++; - } -} - -static void mix_mono(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count) -{ - final_volume_t - left = song->voice[v].left_mix; - sample_t s; - - while (count--) - { - s = *sp++; - MIXATION(left); - } -} - -/* Ramp a note out in c samples */ -static void ramp_out(MidiSong *song, sample_t *sp, Sint32 *lp, int v, Sint32 c) -{ - - /* should be final_volume_t, but Uint8 gives trouble. */ - Sint32 left, right, li, ri; - - sample_t s=0; /* silly warning about uninitialized s */ - - left=song->voice[v].left_mix; - li=-(left/c); - if (!li) li=-1; - - /* printf("Ramping out: left=%d, c=%d, li=%d\n", left, c, li); */ - - if (!(song->encoding & PE_MONO)) - { - if (song->voice[v].panned==PANNED_MYSTERY) - { - right=song->voice[v].right_mix; - ri=-(right/c); - while (c--) - { - left += li; - if (left<0) - left=0; - right += ri; - if (right<0) - right=0; - s=*sp++; - MIXATION(left); - MIXATION(right); - } - } - else if (song->voice[v].panned==PANNED_CENTER) - { - while (c--) - { - left += li; - if (left<0) - return; - s=*sp++; - MIXATION(left); - MIXATION(left); - } - } - else if (song->voice[v].panned==PANNED_LEFT) - { - while (c--) - { - left += li; - if (left<0) - return; - s=*sp++; - MIXATION(left); - lp++; - } - } - else if (song->voice[v].panned==PANNED_RIGHT) - { - while (c--) - { - left += li; - if (left<0) - return; - s=*sp++; - lp++; - MIXATION(left); - } - } - } - else - { - /* Mono output. */ - while (c--) - { - left += li; - if (left<0) - return; - s=*sp++; - MIXATION(left); - } - } -} - - -/**************** interface function ******************/ - -void mix_voice(MidiSong *song, Sint32 *buf, int v, Sint32 c) -{ - Voice *vp = song->voice + v; - sample_t *sp; - if (vp->status==VOICE_DIE) - { - if (c>=MAX_DIE_TIME) - c=MAX_DIE_TIME; - sp=resample_voice(song, v, &c); - if(c > 0) - ramp_out(song, sp, buf, v, c); - vp->status=VOICE_FREE; - } - else - { - sp=resample_voice(song, v, &c); - if (song->encoding & PE_MONO) - { - /* Mono output. */ - if (vp->envelope_increment || vp->tremolo_phase_increment) - mix_mono_signal(song, sp, buf, v, c); - else - mix_mono(song, sp, buf, v, c); - } - else - { - if (vp->panned == PANNED_MYSTERY) - { - if (vp->envelope_increment || vp->tremolo_phase_increment) - mix_mystery_signal(song, sp, buf, v, c); - else - mix_mystery(song, sp, buf, v, c); - } - else if (vp->panned == PANNED_CENTER) - { - if (vp->envelope_increment || vp->tremolo_phase_increment) - mix_center_signal(song, sp, buf, v, c); - else - mix_center(song, sp, buf, v, c); - } - else - { - /* It's either full left or full right. In either case, - every other sample is 0. Just get the offset right: */ - if (vp->panned == PANNED_RIGHT) buf++; - - if (vp->envelope_increment || vp->tremolo_phase_increment) - mix_single_signal(song, sp, buf, v, c); - else - mix_single(song, sp, buf, v, c); - } - } - } -} diff --git a/timidity/mix.h b/timidity/mix.h deleted file mode 100644 index be2a5f1..0000000 --- a/timidity/mix.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - - mix.h - -*/ - -extern void mix_voice(MidiSong *song, Sint32 *buf, int v, Sint32 c); -extern int recompute_envelope(MidiSong *song, int v); -extern void apply_envelope_to_amp(MidiSong *song, int v); diff --git a/timidity/options.h b/timidity/options.h deleted file mode 100644 index 7589399..0000000 --- a/timidity/options.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. -*/ - -/* When a patch file can't be opened, one of these extensions is - appended to the filename and the open is tried again. - */ -#define PATCH_EXT_LIST { ".pat", 0 } - -/* Acoustic Grand Piano seems to be the usual default instrument. */ -#define DEFAULT_PROGRAM 0 - -/* 9 here is MIDI channel 10, which is the standard percussion channel. - Some files (notably C:\WINDOWS\CANYON.MID) think that 16 is one too. - On the other hand, some files know that 16 is not a drum channel and - try to play music on it. This is now a runtime option, so this isn't - a critical choice anymore. */ -#define DEFAULT_DRUMCHANNELS (1<<9) - -/* In percent. */ -#define DEFAULT_AMPLIFICATION 70 - -/* Default polyphony */ -/* #define DEFAULT_VOICES 32 */ -#define DEFAULT_VOICES 256 - -/* 1000 here will give a control ratio of 22:1 with 22 kHz output. - Higher CONTROLS_PER_SECOND values allow more accurate rendering - of envelopes and tremolo. The cost is CPU time. */ -#define CONTROLS_PER_SECOND 1000 - -/* Make envelopes twice as fast. Saves ~20% CPU time (notes decay - faster) and sounds more like a GUS. There is now a command line - option to toggle this as well. */ -#define FAST_DECAY - -/* How many bits to use for the fractional part of sample positions. - This affects tonal accuracy. The entire position counter must fit - in 32 bits, so with FRACTION_BITS equal to 12, the maximum size of - a sample is 1048576 samples (2 megabytes in memory). The GUS gets - by with just 9 bits and a little help from its friends... - "The GUS does not SUCK!!!" -- a happy user :) */ -#define FRACTION_BITS 12 - -/* For some reason the sample volume is always set to maximum in all - patch files. Define this for a crude adjustment that may help - equalize instrument volumes. */ -#define ADJUST_SAMPLE_VOLUMES - -/* The number of samples to use for ramping out a dying note. Affects - click removal. */ -#define MAX_DIE_TIME 20 - -/**************************************************************************/ -/* Anything below this shouldn't need to be changed unless you're porting - to a new machine with other than 32-bit, big-endian words. */ -/**************************************************************************/ - -/* change FRACTION_BITS above, not these */ -#define INTEGER_MASK (0xFFFFFFFF << FRACTION_BITS) -#define FRACTION_MASK (~ INTEGER_MASK) - -/* This is enforced by some computations that must fit in an int */ -#define MAX_CONTROL_RATIO 255 - -#define MAX_AMPLIFICATION 800 - -/* You could specify a complete path, e.g. "/etc/timidity.cfg", and - then specify the library directory in the configuration file. */ -#define CONFIG_FILE "timidity.cfg" -#define CONFIG_FILE_ETC "/etc/timidity.cfg" -#define CONFIG_FILE_ETC_TIMIDITY_FREEPATS "/etc/timidity/freepats.cfg" - -#if defined(__WIN32__) || defined(__OS2__) -#define DEFAULT_PATH "C:\\TIMIDITY" -#else -#define DEFAULT_PATH "/etc/timidity" -#define DEFAULT_PATH1 "/usr/share/timidity" -#define DEFAULT_PATH2 "/usr/local/share/timidity" -#define DEFAULT_PATH3 "/usr/local/lib/timidity" -#endif - -/* These affect general volume */ -#define GUARD_BITS 3 -#define AMP_BITS (15-GUARD_BITS) - -#define MAX_AMP_VALUE ((1<<(AMP_BITS+1))-1) - -#define FSCALE(a,b) (float)((a) * (double)(1<<(b))) -#define FSCALENEG(a,b) (float)((a) * (1.0L / (double)(1<<(b)))) - -/* Vibrato and tremolo Choices of the Day */ -#define SWEEP_TUNING 38 -#define VIBRATO_AMPLITUDE_TUNING 1.0L -#define VIBRATO_RATE_TUNING 38 -#define TREMOLO_AMPLITUDE_TUNING 1.0L -#define TREMOLO_RATE_TUNING 38 - -#define SWEEP_SHIFT 16 -#define RATE_SHIFT 5 - -#ifndef PI - #define PI 3.14159265358979323846 -#endif - -/* The path separator (D.M.) */ -#if defined(__WIN32__) || defined(__OS2__) -# define PATH_SEP '\\' -#else -# define PATH_SEP '/' -#endif - -#define SNDDBG(X) diff --git a/timidity/output.c b/timidity/output.c deleted file mode 100644 index 343c760..0000000 --- a/timidity/output.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - - output.c - - Audio output (to file / device) functions. -*/ - -#if HAVE_CONFIG_H -# include -#endif - -#include "SDL.h" - -#include "options.h" -#include "output.h" - -/*****************************************************************/ -/* Some functions to convert signed 32-bit data to other formats */ - -void s32tos8(void *dp, Sint32 *lp, Sint32 c) -{ - Sint8 *cp=(Sint8 *)(dp); - Sint32 l; - while (c--) - { - l=(*lp++)>>(32-8-GUARD_BITS); - if (l>127) l=127; - else if (l<-128) l=-128; - *cp++ = (Sint8) (l); - } -} - -void s32tou8(void *dp, Sint32 *lp, Sint32 c) -{ - Uint8 *cp=(Uint8 *)(dp); - Sint32 l; - while (c--) - { - l=(*lp++)>>(32-8-GUARD_BITS); - if (l>127) l=127; - else if (l<-128) l=-128; - *cp++ = 0x80 ^ ((Uint8) l); - } -} - -void s32tos16(void *dp, Sint32 *lp, Sint32 c) -{ - Sint16 *sp=(Sint16 *)(dp); - Sint32 l; - while (c--) - { - l=(*lp++)>>(32-16-GUARD_BITS); - if (l > 32767) l=32767; - else if (l<-32768) l=-32768; - *sp++ = (Sint16)(l); - } -} - -void s32tou16(void *dp, Sint32 *lp, Sint32 c) -{ - Uint16 *sp=(Uint16 *)(dp); - Sint32 l; - while (c--) - { - l=(*lp++)>>(32-16-GUARD_BITS); - if (l > 32767) l=32767; - else if (l<-32768) l=-32768; - *sp++ = 0x8000 ^ (Uint16)(l); - } -} - -void s32tos16x(void *dp, Sint32 *lp, Sint32 c) -{ - Sint16 *sp=(Sint16 *)(dp); - Sint32 l; - while (c--) - { - l=(*lp++)>>(32-16-GUARD_BITS); - if (l > 32767) l=32767; - else if (l<-32768) l=-32768; - *sp++ = SDL_Swap16((Sint16)(l)); - } -} - -void s32tou16x(void *dp, Sint32 *lp, Sint32 c) -{ - Uint16 *sp=(Uint16 *)(dp); - Sint32 l; - while (c--) - { - l=(*lp++)>>(32-16-GUARD_BITS); - if (l > 32767) l=32767; - else if (l<-32768) l=-32768; - *sp++ = SDL_Swap16(0x8000 ^ (Uint16)(l)); - } -} - -void s32tof32(void *dp, Sint32 *lp, Sint32 c) -{ - float *sp=(float *)(dp); - while (c--) - { - *sp++ = (float)(*lp++) / 2147483647.0f; - } -} - -void s32tos32(void *dp, Sint32 *lp, Sint32 c) -{ - Sint32 *sp=(Sint32 *)(dp); - while (c--) - { - *sp++ = (*lp++); - } -} - -void s32tos32x(void *dp, Sint32 *lp, Sint32 c) -{ - Sint32 *sp=(Sint32 *)(dp); - while (c--) - { - *sp++ = SDL_Swap32(*lp++); - } -} diff --git a/timidity/output.h b/timidity/output.h deleted file mode 100644 index 849bb47..0000000 --- a/timidity/output.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - - output.h - -*/ - -/* Data format encoding bits */ - -#define PE_MONO 0x01 /* versus stereo */ -#define PE_SIGNED 0x02 /* versus unsigned */ -#define PE_16BIT 0x04 /* versus 8-bit */ -#define PE_32BIT 0x08 /* versus 8-bit or 16-bit */ - -/* Conversion functions -- These overwrite the Sint32 data in *lp with - data in another format */ - -/* 8-bit signed and unsigned*/ -extern void s32tos8(void *dp, Sint32 *lp, Sint32 c); -extern void s32tou8(void *dp, Sint32 *lp, Sint32 c); - -/* 16-bit */ -extern void s32tos16(void *dp, Sint32 *lp, Sint32 c); -extern void s32tou16(void *dp, Sint32 *lp, Sint32 c); - -/* byte-exchanged 16-bit */ -extern void s32tos16x(void *dp, Sint32 *lp, Sint32 c); -extern void s32tou16x(void *dp, Sint32 *lp, Sint32 c); - -/* 32-bit */ -extern void s32tof32(void *dp, Sint32 *lp, Sint32 c); -extern void s32tos32(void *dp, Sint32 *lp, Sint32 c); - -/* byte-exchanged 32-bit */ -extern void s32tos32x(void *dp, Sint32 *lp, Sint32 c); - -/* little-endian and big-endian specific */ -#if SDL_BYTEORDER == SDL_LIL_ENDIAN -#define s32tos16l s32tos16 -#define s32tos16b s32tos16x -#define s32tou16l s32tou16 -#define s32tou16b s32tou16x -#define s32tos32l s32tos32 -#define s32tos32b s32tos32x -#else -#define s32tos16l s32tos16x -#define s32tos16b s32tos16 -#define s32tou16l s32tou16x -#define s32tou16b s32tou16 -#define s32tos32l s32tos32x -#define s32tos32b s32tos32 -#endif diff --git a/timidity/playmidi.c b/timidity/playmidi.c deleted file mode 100644 index 674dccd..0000000 --- a/timidity/playmidi.c +++ /dev/null @@ -1,800 +0,0 @@ -/* - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - - playmidi.c -- random stuff in need of rearrangement - -*/ - -#if HAVE_CONFIG_H -# include -#endif - -#include -#include -#include - -#include "SDL.h" - -#include "timidity.h" -#include "options.h" -#include "instrum.h" -#include "playmidi.h" -#include "output.h" -#include "mix.h" -#include "tables.h" - -static void adjust_amplification(MidiSong *song) -{ - song->master_volume = (float)(song->amplification) / (float)100.0; -} - -static void reset_voices(MidiSong *song) -{ - int i; - for (i=0; ivoice[i].status=VOICE_FREE; -} - -/* Process the Reset All Controllers event */ -static void reset_controllers(MidiSong *song, int c) -{ - song->channel[c].volume=90; /* Some standard says, although the SCC docs say 0. */ - song->channel[c].expression=127; /* SCC-1 does this. */ - song->channel[c].sustain=0; - song->channel[c].pitchbend=0x2000; - song->channel[c].pitchfactor=0; /* to be computed */ -} - -static void reset_midi(MidiSong *song) -{ - int i; - for (i=0; ichannel[i].program=song->default_program; - song->channel[i].panning=NO_PANNING; - song->channel[i].pitchsens=2; - song->channel[i].bank=0; /* tone bank or drum set */ - } - reset_voices(song); -} - -static void select_sample(MidiSong *song, int v, Instrument *ip, int vel) -{ - Sint32 f, cdiff, diff; - int s,i; - Sample *sp, *closest; - - s=ip->samples; - sp=ip->sample; - - if (s==1) - { - song->voice[v].sample=sp; - return; - } - - f=song->voice[v].orig_frequency; - for (i=0; ilow_freq <= f && sp->high_freq >= f) - { - song->voice[v].sample=sp; - return; - } - sp++; - } - - /* - No suitable sample found! We'll select the sample whose root - frequency is closest to the one we want. (Actually we should - probably convert the low, high, and root frequencies to MIDI note - values and compare those.) */ - - cdiff=0x7FFFFFFF; - closest=sp=ip->sample; - for(i=0; iroot_freq - f; - if (diff<0) diff=-diff; - if (diffvoice[v].sample=closest; - return; -} - -static void recompute_freq(MidiSong *song, int v) -{ - int - sign=(song->voice[v].sample_increment < 0), /* for bidirectional loops */ - pb=song->channel[song->voice[v].channel].pitchbend; - double a; - - if (!song->voice[v].sample->sample_rate) - return; - - if (song->voice[v].vibrato_control_ratio) - { - /* This instrument has vibrato. Invalidate any precomputed - sample_increments. */ - - int i=VIBRATO_SAMPLE_INCREMENTS; - while (i--) - song->voice[v].vibrato_sample_increment[i]=0; - } - - if (pb==0x2000 || pb<0 || pb>0x3FFF) - song->voice[v].frequency = song->voice[v].orig_frequency; - else - { - pb-=0x2000; - if (!(song->channel[song->voice[v].channel].pitchfactor)) - { - /* Damn. Somebody bent the pitch. */ - Sint32 i=pb*song->channel[song->voice[v].channel].pitchsens; - if (pb<0) - i=-i; - song->channel[song->voice[v].channel].pitchfactor= - (float)(bend_fine[(i>>5) & 0xFF] * bend_coarse[i>>13]); - } - if (pb>0) - song->voice[v].frequency= - (Sint32)(song->channel[song->voice[v].channel].pitchfactor * - (double)(song->voice[v].orig_frequency)); - else - song->voice[v].frequency= - (Sint32)((double)(song->voice[v].orig_frequency) / - song->channel[song->voice[v].channel].pitchfactor); - } - - a = FSCALE(((double)(song->voice[v].sample->sample_rate) * - (double)(song->voice[v].frequency)) / - ((double)(song->voice[v].sample->root_freq) * - (double)(song->rate)), - FRACTION_BITS); - - if (sign) - a = -a; /* need to preserve the loop direction */ - - song->voice[v].sample_increment = (Sint32)(a); -} - -static void recompute_amp(MidiSong *song, int v) -{ - Sint32 tempamp; - - /* TODO: use fscale */ - - tempamp= (song->voice[v].velocity * - song->channel[song->voice[v].channel].volume * - song->channel[song->voice[v].channel].expression); /* 21 bits */ - - if (!(song->encoding & PE_MONO)) - { - if (song->voice[v].panning > 60 && song->voice[v].panning < 68) - { - song->voice[v].panned=PANNED_CENTER; - - song->voice[v].left_amp= - FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume, - 21); - } - else if (song->voice[v].panning<5) - { - song->voice[v].panned = PANNED_LEFT; - - song->voice[v].left_amp= - FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume, - 20); - } - else if (song->voice[v].panning>123) - { - song->voice[v].panned = PANNED_RIGHT; - - song->voice[v].left_amp= /* left_amp will be used */ - FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume, - 20); - } - else - { - song->voice[v].panned = PANNED_MYSTERY; - - song->voice[v].left_amp= - FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume, - 27); - song->voice[v].right_amp = song->voice[v].left_amp * (song->voice[v].panning); - song->voice[v].left_amp *= (float)(127 - song->voice[v].panning); - } - } - else - { - song->voice[v].panned = PANNED_CENTER; - - song->voice[v].left_amp= - FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume, - 21); - } -} - -static void start_note(MidiSong *song, MidiEvent *e, int i) -{ - Instrument *ip; - int j; - - if (ISDRUMCHANNEL(song, e->channel)) - { - if (!(ip=song->drumset[song->channel[e->channel].bank]->instrument[e->a])) - { - if (!(ip=song->drumset[0]->instrument[e->a])) - return; /* No instrument? Then we can't play. */ - } - if (ip->samples != 1) - { - SNDDBG(("Strange: percussion instrument with %d samples!", - ip->samples)); - } - - if (ip->sample->note_to_use) /* Do we have a fixed pitch? */ - song->voice[i].orig_frequency = freq_table[(int)(ip->sample->note_to_use)]; - else - song->voice[i].orig_frequency = freq_table[e->a & 0x7F]; - - /* drums are supposed to have only one sample */ - song->voice[i].sample = ip->sample; - } - else - { - if (song->channel[e->channel].program == SPECIAL_PROGRAM) - ip=song->default_instrument; - else if (!(ip=song->tonebank[song->channel[e->channel].bank]-> - instrument[song->channel[e->channel].program])) - { - if (!(ip=song->tonebank[0]->instrument[song->channel[e->channel].program])) - return; /* No instrument? Then we can't play. */ - } - - if (ip->sample->note_to_use) /* Fixed-pitch instrument? */ - song->voice[i].orig_frequency = freq_table[(int)(ip->sample->note_to_use)]; - else - song->voice[i].orig_frequency = freq_table[e->a & 0x7F]; - select_sample(song, i, ip, e->b); - } - - song->voice[i].status = VOICE_ON; - song->voice[i].channel = e->channel; - song->voice[i].note = e->a; - song->voice[i].velocity = e->b; - song->voice[i].sample_offset = 0; - song->voice[i].sample_increment = 0; /* make sure it isn't negative */ - - song->voice[i].tremolo_phase = 0; - song->voice[i].tremolo_phase_increment = song->voice[i].sample->tremolo_phase_increment; - song->voice[i].tremolo_sweep = song->voice[i].sample->tremolo_sweep_increment; - song->voice[i].tremolo_sweep_position = 0; - - song->voice[i].vibrato_sweep = song->voice[i].sample->vibrato_sweep_increment; - song->voice[i].vibrato_sweep_position = 0; - song->voice[i].vibrato_control_ratio = song->voice[i].sample->vibrato_control_ratio; - song->voice[i].vibrato_control_counter = song->voice[i].vibrato_phase = 0; - for (j=0; jvoice[i].vibrato_sample_increment[j] = 0; - - if (song->channel[e->channel].panning != NO_PANNING) - song->voice[i].panning = song->channel[e->channel].panning; - else - song->voice[i].panning = song->voice[i].sample->panning; - - recompute_freq(song, i); - recompute_amp(song, i); - if (song->voice[i].sample->modes & MODES_ENVELOPE) - { - /* Ramp up from 0 */ - song->voice[i].envelope_stage = 0; - song->voice[i].envelope_volume = 0; - song->voice[i].control_counter = 0; - recompute_envelope(song, i); - apply_envelope_to_amp(song, i); - } - else - { - song->voice[i].envelope_increment = 0; - apply_envelope_to_amp(song, i); - } -} - -static void kill_note(MidiSong *song, int i) -{ - song->voice[i].status = VOICE_DIE; -} - -/* Only one instance of a note can be playing on a single channel. */ -static void note_on(MidiSong *song) -{ - int i = song->voices, lowest=-1; - Sint32 lv=0x7FFFFFFF, v; - MidiEvent *e = song->current_event; - - while (i--) - { - if (song->voice[i].status == VOICE_FREE) - lowest=i; /* Can't get a lower volume than silence */ - else if (song->voice[i].channel==e->channel && - (song->voice[i].note==e->a || song->channel[song->voice[i].channel].mono)) - kill_note(song, i); - } - - if (lowest != -1) - { - /* Found a free voice. */ - start_note(song,e,lowest); - return; - } - - /* Look for the decaying note with the lowest volume */ - i = song->voices; - while (i--) - { - if ((song->voice[i].status != VOICE_ON) && - (song->voice[i].status != VOICE_DIE)) - { - v = song->voice[i].left_mix; - if ((song->voice[i].panned == PANNED_MYSTERY) - && (song->voice[i].right_mix > v)) - v = song->voice[i].right_mix; - if (vcut_notes++; - song->voice[lowest].status=VOICE_FREE; - start_note(song,e,lowest); - } - else - song->lost_notes++; -} - -static void finish_note(MidiSong *song, int i) -{ - if (song->voice[i].sample->modes & MODES_ENVELOPE) - { - /* We need to get the envelope out of Sustain stage */ - song->voice[i].envelope_stage = 3; - song->voice[i].status = VOICE_OFF; - recompute_envelope(song, i); - apply_envelope_to_amp(song, i); - } - else - { - /* Set status to OFF so resample_voice() will let this voice out - of its loop, if any. In any case, this voice dies when it - hits the end of its data (ofs>=data_length). */ - song->voice[i].status = VOICE_OFF; - } -} - -static void note_off(MidiSong *song) -{ - int i = song->voices; - MidiEvent *e = song->current_event; - - while (i--) - if (song->voice[i].status == VOICE_ON && - song->voice[i].channel == e->channel && - song->voice[i].note == e->a) - { - if (song->channel[e->channel].sustain) - { - song->voice[i].status = VOICE_SUSTAINED; - } - else - finish_note(song, i); - return; - } -} - -/* Process the All Notes Off event */ -static void all_notes_off(MidiSong *song) -{ - int i = song->voices; - int c = song->current_event->channel; - - SNDDBG(("All notes off on channel %d", c)); - while (i--) - if (song->voice[i].status == VOICE_ON && - song->voice[i].channel == c) - { - if (song->channel[c].sustain) - song->voice[i].status = VOICE_SUSTAINED; - else - finish_note(song, i); - } -} - -/* Process the All Sounds Off event */ -static void all_sounds_off(MidiSong *song) -{ - int i = song->voices; - int c = song->current_event->channel; - - while (i--) - if (song->voice[i].channel == c && - song->voice[i].status != VOICE_FREE && - song->voice[i].status != VOICE_DIE) - { - kill_note(song, i); - } -} - -static void adjust_pressure(MidiSong *song) -{ - MidiEvent *e = song->current_event; - int i = song->voices; - - while (i--) - if (song->voice[i].status == VOICE_ON && - song->voice[i].channel == e->channel && - song->voice[i].note == e->a) - { - song->voice[i].velocity = e->b; - recompute_amp(song, i); - apply_envelope_to_amp(song, i); - return; - } -} - -static void drop_sustain(MidiSong *song) -{ - int i = song->voices; - int c = song->current_event->channel; - - while (i--) - if (song->voice[i].status == VOICE_SUSTAINED && song->voice[i].channel == c) - finish_note(song, i); -} - -static void adjust_pitchbend(MidiSong *song) -{ - int c = song->current_event->channel; - int i = song->voices; - - while (i--) - if (song->voice[i].status != VOICE_FREE && song->voice[i].channel == c) - { - recompute_freq(song, i); - } -} - -static void adjust_volume(MidiSong *song) -{ - int c = song->current_event->channel; - int i = song->voices; - - while (i--) - if (song->voice[i].channel == c && - (song->voice[i].status==VOICE_ON || song->voice[i].status==VOICE_SUSTAINED)) - { - recompute_amp(song, i); - apply_envelope_to_amp(song, i); - } -} - -static void seek_forward(MidiSong *song, Sint32 until_time) -{ - reset_voices(song); - while (song->current_event->time < until_time) - { - switch(song->current_event->type) - { - /* All notes stay off. Just handle the parameter changes. */ - - case ME_PITCH_SENS: - song->channel[song->current_event->channel].pitchsens = - song->current_event->a; - song->channel[song->current_event->channel].pitchfactor = 0; - break; - - case ME_PITCHWHEEL: - song->channel[song->current_event->channel].pitchbend = - song->current_event->a + song->current_event->b * 128; - song->channel[song->current_event->channel].pitchfactor = 0; - break; - - case ME_MAINVOLUME: - song->channel[song->current_event->channel].volume = - song->current_event->a; - break; - - case ME_PAN: - song->channel[song->current_event->channel].panning = - song->current_event->a; - break; - - case ME_EXPRESSION: - song->channel[song->current_event->channel].expression = - song->current_event->a; - break; - - case ME_PROGRAM: - if (ISDRUMCHANNEL(song, song->current_event->channel)) - /* Change drum set */ - song->channel[song->current_event->channel].bank = - song->current_event->a; - else - song->channel[song->current_event->channel].program = - song->current_event->a; - break; - - case ME_SUSTAIN: - song->channel[song->current_event->channel].sustain = - song->current_event->a; - break; - - case ME_RESET_CONTROLLERS: - reset_controllers(song, song->current_event->channel); - break; - - case ME_TONE_BANK: - song->channel[song->current_event->channel].bank = - song->current_event->a; - break; - - case ME_EOT: - song->current_sample = song->current_event->time; - return; - } - song->current_event++; - } - /*song->current_sample=song->current_event->time;*/ - if (song->current_event != song->events) - song->current_event--; - song->current_sample=until_time; -} - -static void skip_to(MidiSong *song, Sint32 until_time) -{ - if (song->current_sample > until_time) - song->current_sample = 0; - - reset_midi(song); - song->buffered_count = 0; - song->buffer_pointer = song->common_buffer; - song->current_event = song->events; - - if (until_time) - seek_forward(song, until_time); -} - -static void do_compute_data(MidiSong *song, Sint32 count) -{ - int i; - memset(song->buffer_pointer, 0, - (song->encoding & PE_MONO) ? (count * 4) : (count * 8)); - for (i = 0; i < song->voices; i++) - { - if(song->voice[i].status != VOICE_FREE) - mix_voice(song, song->buffer_pointer, i, count); - } - song->current_sample += count; -} - -/* count=0 means flush remaining buffered data to output device, then - flush the device itself */ -static void compute_data(MidiSong *song, void *stream, Sint32 count) -{ - int channels; - - if ( song->encoding & PE_MONO ) - channels = 1; - else - channels = 2; - - if (!count) - { - if (song->buffered_count) - song->write(stream, song->common_buffer, channels * song->buffered_count); - song->buffer_pointer = song->common_buffer; - song->buffered_count = 0; - return; - } - - while ((count + song->buffered_count) >= song->buffer_size) - { - do_compute_data(song, song->buffer_size - song->buffered_count); - count -= song->buffer_size - song->buffered_count; - song->write(stream, song->common_buffer, channels * song->buffer_size); - song->buffer_pointer = song->common_buffer; - song->buffered_count = 0; - } - if (count>0) - { - do_compute_data(song, count); - song->buffered_count += count; - song->buffer_pointer += (song->encoding & PE_MONO) ? count : count*2; - } -} - -void Timidity_Start(MidiSong *song) -{ - song->playing = 1; - adjust_amplification(song); - skip_to(song, 0); -} - -void Timidity_Seek(MidiSong *song, Uint32 ms) -{ - skip_to(song, (ms * song->rate) / 1000); -} - -Uint32 Timidity_GetSongLength(MidiSong *song) -{ - MidiEvent *last_event = &song->events[song->groomed_event_count - 1]; - /* We want last_event->time * 1000 / song->rate */ - Uint32 retvalue = (last_event->time / song->rate) * 1000; - retvalue += (last_event->time % song->rate) * 1000 / song->rate; - return retvalue; -} - -int Timidity_PlaySome(MidiSong *song, void *stream, Sint32 len) -{ - Sint32 start_sample, end_sample, samples; - int bytes_per_sample; - - if (!song->playing) - return 0; - - bytes_per_sample = 1; - bytes_per_sample *= ((song->encoding & PE_32BIT) ? 4 : ((song->encoding & PE_16BIT) ? 2 : 1)); - bytes_per_sample *= ((song->encoding & PE_MONO) ? 1 : 2); - samples = len / bytes_per_sample; - - start_sample = song->current_sample; - end_sample = song->current_sample+samples; - while ( song->current_sample < end_sample ) { - /* Handle all events that should happen at this time */ - while (song->current_event->time <= song->current_sample) { - switch(song->current_event->type) { - - /* Effects affecting a single note */ - - case ME_NOTEON: - if (!(song->current_event->b)) /* Velocity 0? */ - note_off(song); - else - note_on(song); - break; - - case ME_NOTEOFF: - note_off(song); - break; - - case ME_KEYPRESSURE: - adjust_pressure(song); - break; - - /* Effects affecting a single channel */ - - case ME_PITCH_SENS: - song->channel[song->current_event->channel].pitchsens = - song->current_event->a; - song->channel[song->current_event->channel].pitchfactor = 0; - break; - - case ME_PITCHWHEEL: - song->channel[song->current_event->channel].pitchbend = - song->current_event->a + song->current_event->b * 128; - song->channel[song->current_event->channel].pitchfactor = 0; - /* Adjust pitch for notes already playing */ - adjust_pitchbend(song); - break; - - case ME_MAINVOLUME: - song->channel[song->current_event->channel].volume = - song->current_event->a; - adjust_volume(song); - break; - - case ME_PAN: - song->channel[song->current_event->channel].panning = - song->current_event->a; - break; - - case ME_EXPRESSION: - song->channel[song->current_event->channel].expression = - song->current_event->a; - adjust_volume(song); - break; - - case ME_PROGRAM: - if (ISDRUMCHANNEL(song, song->current_event->channel)) { - /* Change drum set */ - song->channel[song->current_event->channel].bank = - song->current_event->a; - } - else - song->channel[song->current_event->channel].program = - song->current_event->a; - break; - - case ME_SUSTAIN: - song->channel[song->current_event->channel].sustain = - song->current_event->a; - if (!song->current_event->a) - drop_sustain(song); - break; - - case ME_RESET_CONTROLLERS: - reset_controllers(song, song->current_event->channel); - break; - - case ME_ALL_NOTES_OFF: - all_notes_off(song); - break; - - case ME_ALL_SOUNDS_OFF: - all_sounds_off(song); - break; - - case ME_TONE_BANK: - song->channel[song->current_event->channel].bank = - song->current_event->a; - break; - - case ME_EOT: - /* Give the last notes a couple of seconds to decay */ - SNDDBG(("Playing time: ~%d seconds\n", - song->current_sample/song->rate+2)); - SNDDBG(("Notes cut: %d\n", song->cut_notes)); - SNDDBG(("Notes lost totally: %d\n", song->lost_notes)); - song->playing = 0; - return (song->current_sample - start_sample) * bytes_per_sample; - } - song->current_event++; - } - if (song->current_event->time > end_sample) - compute_data(song, stream, end_sample-song->current_sample); - else - compute_data(song, stream, song->current_event->time-song->current_sample); - } - return samples * bytes_per_sample; -} - -void Timidity_SetVolume(MidiSong *song, int volume) -{ - int i; - if (volume > MAX_AMPLIFICATION) - song->amplification = MAX_AMPLIFICATION; - else - if (volume < 0) - song->amplification = 0; - else - song->amplification = volume; - adjust_amplification(song); - for (i = 0; i < song->voices; i++) - if (song->voice[i].status != VOICE_FREE) - { - recompute_amp(song, i); - apply_envelope_to_amp(song, i); - } -} diff --git a/timidity/playmidi.h b/timidity/playmidi.h deleted file mode 100644 index 03b287a..0000000 --- a/timidity/playmidi.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - - playmidi.h - - */ - -/* Midi events */ -#define ME_NONE 0 -#define ME_NOTEON 1 -#define ME_NOTEOFF 2 -#define ME_KEYPRESSURE 3 -#define ME_MAINVOLUME 4 -#define ME_PAN 5 -#define ME_SUSTAIN 6 -#define ME_EXPRESSION 7 -#define ME_PITCHWHEEL 8 -#define ME_PROGRAM 9 -#define ME_TEMPO 10 -#define ME_PITCH_SENS 11 - -#define ME_ALL_SOUNDS_OFF 12 -#define ME_RESET_CONTROLLERS 13 -#define ME_ALL_NOTES_OFF 14 -#define ME_TONE_BANK 15 - -#define ME_LYRIC 16 - -#define ME_EOT 99 - -/* Causes the instrument's default panning to be used. */ -#define NO_PANNING -1 - -/* Voice status options: */ -#define VOICE_FREE 0 -#define VOICE_ON 1 -#define VOICE_SUSTAINED 2 -#define VOICE_OFF 3 -#define VOICE_DIE 4 - -/* Voice panned options: */ -#define PANNED_MYSTERY 0 -#define PANNED_LEFT 1 -#define PANNED_RIGHT 2 -#define PANNED_CENTER 3 -/* Anything but PANNED_MYSTERY only uses the left volume */ - -#define ISDRUMCHANNEL(s, c) (((s)->drumchannels & (1<<(c)))) diff --git a/timidity/readmidi.c b/timidity/readmidi.c deleted file mode 100644 index bfe6377..0000000 --- a/timidity/readmidi.c +++ /dev/null @@ -1,614 +0,0 @@ -/* - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. -*/ - -#if HAVE_CONFIG_H -# include -#endif - -#include -#include -#include - -#include "SDL.h" - -#include "options.h" -#include "timidity.h" -#include "common.h" -#include "instrum.h" -#include "playmidi.h" - -/* Computes how many (fractional) samples one MIDI delta-time unit contains */ -static void compute_sample_increment(MidiSong *song, Sint32 tempo, - Sint32 divisions) -{ - double a; - a = (double) (tempo) * (double) (song->rate) * (65536.0/1000000.0) / - (double)(divisions); - - song->sample_correction = (Sint32)(a) & 0xFFFF; - song->sample_increment = (Sint32)(a) >> 16; - - SNDDBG(("Samples per delta-t: %d (correction %d)", - song->sample_increment, song->sample_correction)); -} - -/* Read variable-length number (7 bits per byte, MSB first) */ -static Sint32 getvl(SDL_RWops *rw) -{ - Sint32 l=0; - Uint8 c; - for (;;) - { - if (!SDL_RWread(rw, &c, 1, 1)) return l; - l += (c & 0x7f); - if (!(c & 0x80)) return l; - l<<=7; - } -} - -/* Print a string from the file, followed by a newline. Any non-ASCII - or unprintable characters will be converted to periods. */ -static int dumpstring(SDL_RWops *rw, Sint32 len, char *label) -{ - signed char *s=safe_malloc(len+1); - if (len != (Sint32) SDL_RWread(rw, s, 1, len)) - { - free(s); - return -1; - } - s[len]='\0'; - while (len--) - { - if (s[len]<32) - s[len]='.'; - } - SNDDBG(("%s%s", label, s)); - free(s); - return 0; -} - -#define MIDIEVENT(at,t,ch,pa,pb) \ - new=safe_malloc(sizeof(MidiEventList)); \ - new->event.time=at; new->event.type=t; new->event.channel=ch; \ - new->event.a=pa; new->event.b=pb; new->next=0;\ - return new; - -#define MAGIC_EOT ((MidiEventList *)(-1)) - -/* Read a MIDI event, returning a freshly allocated element that can - be linked to the event list */ -static MidiEventList *read_midi_event(MidiSong *song) -{ - static Uint8 laststatus, lastchan; - static Uint8 nrpn=0, rpn_msb[16], rpn_lsb[16]; /* one per channel */ - Uint8 me, type, a,b,c; - Sint32 len; - MidiEventList *new; - - for (;;) - { - song->at += getvl(song->rw); - if (SDL_RWread(song->rw, &me, 1, 1) != 1) - { - SNDDBG(("read_midi_event: SDL_RWread() failure\n")); - return NULL; - } - - if(me==0xF0 || me == 0xF7) /* SysEx event */ - { - len=getvl(song->rw); - SDL_RWseek(song->rw, len, RW_SEEK_CUR); - } - else if(me==0xFF) /* Meta event */ - { - SDL_RWread(song->rw, &type, 1, 1); - len=getvl(song->rw); - if (type>0 && type<16) - { - static char *label[]={ - "Text event: ", "Text: ", "Copyright: ", "Track name: ", - "Instrument: ", "Lyric: ", "Marker: ", "Cue point: "}; - dumpstring(song->rw, len, label[(type>7) ? 0 : type]); - } - else - switch(type) - { - case 0x2F: /* End of Track */ - return MAGIC_EOT; - - case 0x51: /* Tempo */ - SDL_RWread(song->rw, &a, 1, 1); - SDL_RWread(song->rw, &b, 1, 1); - SDL_RWread(song->rw, &c, 1, 1); - MIDIEVENT(song->at, ME_TEMPO, c, a, b); - - default: - SNDDBG(("(Meta event type 0x%02x, length %d)\n", type, len)); - SDL_RWseek(song->rw, len, RW_SEEK_CUR); - break; - } - } - else - { - a=me; - if (a & 0x80) /* status byte */ - { - lastchan=a & 0x0F; - laststatus=(a>>4) & 0x07; - SDL_RWread(song->rw, &a, 1, 1); - a &= 0x7F; - } - switch(laststatus) - { - case 0: /* Note off */ - SDL_RWread(song->rw, &b, 1, 1); - b &= 0x7F; - MIDIEVENT(song->at, ME_NOTEOFF, lastchan, a,b); - - case 1: /* Note on */ - SDL_RWread(song->rw, &b, 1, 1); - b &= 0x7F; - MIDIEVENT(song->at, ME_NOTEON, lastchan, a,b); - - case 2: /* Key Pressure */ - SDL_RWread(song->rw, &b, 1, 1); - b &= 0x7F; - MIDIEVENT(song->at, ME_KEYPRESSURE, lastchan, a, b); - - case 3: /* Control change */ - SDL_RWread(song->rw, &b, 1, 1); - b &= 0x7F; - { - int control=255; - switch(a) - { - case 7: control=ME_MAINVOLUME; break; - case 10: control=ME_PAN; break; - case 11: control=ME_EXPRESSION; break; - case 64: control=ME_SUSTAIN; b = (b >= 64); break; - case 120: control=ME_ALL_SOUNDS_OFF; break; - case 121: control=ME_RESET_CONTROLLERS; break; - case 123: control=ME_ALL_NOTES_OFF; break; - - /* These should be the SCC-1 tone bank switch - commands. I don't know why there are two, or - why the latter only allows switching to bank 0. - Also, some MIDI files use 0 as some sort of - continuous controller. This will cause lots of - warnings about undefined tone banks. */ - case 0: control=ME_TONE_BANK; break; - case 32: - if (b!=0) { - SNDDBG(("(Strange: tone bank change 0x%02x)\n", b)); - } -#if 0 /* `Bank Select LSB' is not worked at GS. Please ignore it. */ - else - control=ME_TONE_BANK; -#endif - break; - - case 100: nrpn=0; rpn_msb[lastchan]=b; break; - case 101: nrpn=0; rpn_lsb[lastchan]=b; break; - case 99: nrpn=1; rpn_msb[lastchan]=b; break; - case 98: nrpn=1; rpn_lsb[lastchan]=b; break; - - case 6: - if (nrpn) - { - SNDDBG(("(Data entry (MSB) for NRPN %02x,%02x: %d)\n", - rpn_msb[lastchan], rpn_lsb[lastchan], b)); - break; - } - - switch((rpn_msb[lastchan]<<8) | rpn_lsb[lastchan]) - { - case 0x0000: /* Pitch bend sensitivity */ - control=ME_PITCH_SENS; - break; - - case 0x7F7F: /* RPN reset */ - /* reset pitch bend sensitivity to 2 */ - MIDIEVENT(song->at, ME_PITCH_SENS, lastchan, 2, 0); - - default: - SNDDBG(("(Data entry (MSB) for RPN %02x,%02x: %d)\n", - rpn_msb[lastchan], rpn_lsb[lastchan], b)); - break; - } - break; - - default: - SNDDBG(("(Control %d: %d)\n", a, b)); - break; - } - if (control != 255) - { - MIDIEVENT(song->at, control, lastchan, b, 0); - } - } - break; - - case 4: /* Program change */ - a &= 0x7f; - MIDIEVENT(song->at, ME_PROGRAM, lastchan, a, 0); - - case 5: /* Channel pressure - NOT IMPLEMENTED */ - break; - - case 6: /* Pitch wheel */ - SDL_RWread(song->rw, &b, 1, 1); - b &= 0x7F; - MIDIEVENT(song->at, ME_PITCHWHEEL, lastchan, a, b); - - default: - SNDDBG(("*** Can't happen: status 0x%02X, channel 0x%02X\n", - laststatus, lastchan)); - break; - } - } - } - - return new; -} - -#undef MIDIEVENT - -/* Read a midi track into the linked list, either merging with any previous - tracks or appending to them. */ -static int read_track(MidiSong *song, int append) -{ - MidiEventList *meep; - MidiEventList *next, *new; - Sint32 len; - Sint64 next_pos, pos; - char tmp[4]; - - meep = song->evlist; - if (append && meep) - { - /* find the last event in the list */ - for (; meep->next; meep=meep->next) - ; - song->at = meep->event.time; - } - else - song->at=0; - - /* Check the formalities */ - - if (SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_RWread(song->rw, &len, 4, 1) != 1) - { - SNDDBG(("Can't read track header.\n")); - return -1; - } - len=SDL_SwapBE32(len); - next_pos = SDL_RWtell(song->rw) + len; - if (memcmp(tmp, "MTrk", 4)) - { - SNDDBG(("Corrupt MIDI file.\n")); - return -2; - } - - for (;;) - { - if (!(new=read_midi_event(song))) /* Some kind of error */ - return -2; - - if (new==MAGIC_EOT) /* End-of-track Hack. */ - { - pos = SDL_RWtell(song->rw); - if (pos < next_pos) - SDL_RWseek(song->rw, next_pos - pos, RW_SEEK_CUR); - return 0; - } - - next=meep->next; - while (next && (next->event.time < new->event.time)) - { - meep=next; - next=meep->next; - } - - new->next=next; - meep->next=new; - - song->event_count++; /* Count the event. (About one?) */ - meep=new; - } -} - -/* Free the linked event list from memory. */ -static void free_midi_list(MidiSong *song) -{ - MidiEventList *meep, *next; - if (!(meep = song->evlist)) return; - while (meep) - { - next=meep->next; - free(meep); - meep=next; - } - song->evlist=NULL; -} - -/* Allocate an array of MidiEvents and fill it from the linked list of - events, marking used instruments for loading. Convert event times to - samples: handle tempo changes. Strip unnecessary events from the list. - Free the linked list. */ -static MidiEvent *groom_list(MidiSong *song, Sint32 divisions,Sint32 *eventsp, - Sint32 *samplesp) -{ - MidiEvent *groomed_list, *lp; - MidiEventList *meep; - Sint32 i, our_event_count, tempo, skip_this_event, new_value; - Sint32 sample_cum, samples_to_do, at, st, dt, counting_time; - - int current_bank[MAXCHAN], current_set[MAXCHAN], current_program[MAXCHAN]; - /* Or should each bank have its own current program? */ - - for (i=0; idefault_program; - } - - tempo=500000; - compute_sample_increment(song, tempo, divisions); - - /* This may allocate a bit more than we need */ - groomed_list=lp=safe_malloc(sizeof(MidiEvent) * (song->event_count+1)); - meep=song->evlist; - - our_event_count=0; - st=at=sample_cum=0; - counting_time=2; /* We strip any silence before the first NOTE ON. */ - - for (i = 0; i < song->event_count; i++) - { - skip_this_event=0; - - if (meep->event.type==ME_TEMPO) - { - skip_this_event=1; - } - else if (meep->event.channel >= MAXCHAN) - skip_this_event=1; - else switch (meep->event.type) - { - case ME_PROGRAM: - if (ISDRUMCHANNEL(song, meep->event.channel)) - { - if (song->drumset[meep->event.a]) /* Is this a defined drumset? */ - new_value=meep->event.a; - else - { - SNDDBG(("Drum set %d is undefined\n", meep->event.a)); - new_value=meep->event.a=0; - } - if (current_set[meep->event.channel] != new_value) - current_set[meep->event.channel]=new_value; - else - skip_this_event=1; - } - else - { - new_value=meep->event.a; - if ((current_program[meep->event.channel] != SPECIAL_PROGRAM) - && (current_program[meep->event.channel] != new_value)) - current_program[meep->event.channel] = new_value; - else - skip_this_event=1; - } - break; - - case ME_NOTEON: - if (counting_time) - counting_time=1; - if (ISDRUMCHANNEL(song, meep->event.channel)) - { - /* Mark this instrument to be loaded */ - if (!(song->drumset[current_set[meep->event.channel]] - ->instrument[meep->event.a])) - song->drumset[current_set[meep->event.channel]] - ->instrument[meep->event.a] = MAGIC_LOAD_INSTRUMENT; - } - else - { - if (current_program[meep->event.channel]==SPECIAL_PROGRAM) - break; - /* Mark this instrument to be loaded */ - if (!(song->tonebank[current_bank[meep->event.channel]] - ->instrument[current_program[meep->event.channel]])) - song->tonebank[current_bank[meep->event.channel]] - ->instrument[current_program[meep->event.channel]] = - MAGIC_LOAD_INSTRUMENT; - } - break; - - case ME_TONE_BANK: - if (ISDRUMCHANNEL(song, meep->event.channel)) - { - skip_this_event=1; - break; - } - if (song->tonebank[meep->event.a]) /* Is this a defined tone bank? */ - new_value=meep->event.a; - else - { - SNDDBG(("Tone bank %d is undefined\n", meep->event.a)); - new_value=meep->event.a=0; - } - if (current_bank[meep->event.channel]!=new_value) - current_bank[meep->event.channel]=new_value; - else - skip_this_event=1; - break; - } - - /* Recompute time in samples*/ - if ((dt=meep->event.time - at) && !counting_time) - { - if (song->sample_increment > 2147483647/dt || - song->sample_correction > 2147483647/dt) { - goto _overflow; - } - samples_to_do = song->sample_increment * dt; - sample_cum += song->sample_correction * dt; - if (sample_cum & 0xFFFF0000) - { - samples_to_do += ((sample_cum >> 16) & 0xFFFF); - sample_cum &= 0x0000FFFF; - } - if (st >= 2147483647 - samples_to_do) { - _overflow: - SNDDBG(("Overflow in sample counter\n")); - free_midi_list(song); - free(groomed_list); - return NULL; - } - st += samples_to_do; - } - else if (counting_time==1) counting_time=0; - if (meep->event.type==ME_TEMPO) - { - tempo= - meep->event.channel + meep->event.b * 256 + meep->event.a * 65536; - compute_sample_increment(song, tempo, divisions); - } - if (!skip_this_event) - { - /* Add the event to the list */ - *lp=meep->event; - lp->time=st; - lp++; - our_event_count++; - } - at=meep->event.time; - meep=meep->next; - } - /* Add an End-of-Track event */ - lp->time=st; - lp->type=ME_EOT; - our_event_count++; - free_midi_list(song); - - *eventsp=our_event_count; - *samplesp=st; - return groomed_list; -} - -MidiEvent *read_midi_file(MidiSong *song, Sint32 *count, Sint32 *sp) -{ - Sint32 len, divisions; - Sint16 format, tracks, divisions_tmp; - int i; - char tmp[4]; - - song->event_count=0; - song->at=0; - song->evlist = NULL; - - if (SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_RWread(song->rw, &len, 4, 1) != 1) - { - SNDDBG(("Not a MIDI file!\n")); - return NULL; - } - if (memcmp(tmp, "RIFF", 4) == 0) { /* RMID ?? */ - if (SDL_RWread(song->rw, tmp, 1, 4) != 4 || memcmp(tmp, "RMID", 4) != 0 || - SDL_RWread(song->rw, tmp, 1, 4) != 4 || memcmp(tmp, "data", 4) != 0 || - SDL_RWread(song->rw, tmp, 1, 4) != 4 || - /* SMF must begin from here onwards: */ - SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_RWread(song->rw, &len, 4, 1) != 1) - { - SNDDBG(("Not an RMID file!\n")); - return NULL; - } - } - len=SDL_SwapBE32(len); - if (memcmp(tmp, "MThd", 4) || len < 6) - { - SNDDBG(("Not a MIDI file!\n")); - return NULL; - } - - SDL_RWread(song->rw, &format, 2, 1); - SDL_RWread(song->rw, &tracks, 2, 1); - SDL_RWread(song->rw, &divisions_tmp, 2, 1); - format=SDL_SwapBE16(format); - tracks=SDL_SwapBE16(tracks); - divisions_tmp=SDL_SwapBE16(divisions_tmp); - - if (divisions_tmp<0) - { - /* SMPTE time -- totally untested. Got a MIDI file that uses this? */ - divisions= - (Sint32)(-(divisions_tmp/256)) * (Sint32)(divisions_tmp & 0xFF); - } - else divisions=(Sint32)(divisions_tmp); - - if (len > 6) - { - SNDDBG(("MIDI file header size %u bytes", len)); - SDL_RWseek(song->rw, len-6, RW_SEEK_CUR); /* skip the excess */ - } - if (format<0 || format >2) - { - SNDDBG(("Unknown MIDI file format %d\n", format)); - return NULL; - } - if (tracks<1) - { - SNDDBG(("Bad number of tracks %d\n", tracks)); - return NULL; - } - if (format==0 && tracks!=1) - { - SNDDBG(("%d tracks with Type-0 MIDI (must be 1.)\n", tracks)); - return NULL; - } - SNDDBG(("Format: %d Tracks: %d Divisions: %d\n", - format, tracks, divisions)); - - /* Put a do-nothing event first in the list for easier processing */ - song->evlist=safe_malloc(sizeof(MidiEventList)); - memset(song->evlist, 0, sizeof(MidiEventList)); - song->event_count++; - - switch(format) - { - case 0: - if (read_track(song, 0)) - { - free_midi_list(song); - return NULL; - } - break; - - case 1: - for (i=0; i - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - - readmidi.h - - */ - -extern MidiEvent *read_midi_file(MidiSong *song, Sint32 *count, Sint32 *sp); diff --git a/timidity/resample.c b/timidity/resample.c deleted file mode 100644 index d3de5c8..0000000 --- a/timidity/resample.c +++ /dev/null @@ -1,613 +0,0 @@ -/* - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - - resample.c -*/ - -#if HAVE_CONFIG_H -# include -#endif - -#include -#include -#include - -#include "SDL.h" - -#include "timidity.h" -#include "options.h" -#include "common.h" -#include "instrum.h" -#include "playmidi.h" -#include "tables.h" -#include "resample.h" - -#define PRECALC_LOOP_COUNT(start, end, incr) (((end) - (start) + (incr) - 1) / (incr)) - -/*************** resampling with fixed increment *****************/ - -static sample_t *rs_plain(MidiSong *song, int v, Sint32 *countptr) -{ - - /* Play sample until end, then free the voice. */ - - sample_t v1, v2; - Voice - *vp=&(song->voice[v]); - sample_t - *dest=song->resample_buffer, - *src=vp->sample->data; - Sint32 - ofs=vp->sample_offset, - incr=vp->sample_increment, - le=vp->sample->data_length, - count=*countptr; - Sint32 i, j; - - if (incr<0) incr = -incr; /* In case we're coming out of a bidir loop */ - - /* Precalc how many times we should go through the loop. - NOTE: Assumes that incr > 0 and that ofs <= le */ - i = PRECALC_LOOP_COUNT(ofs, le, incr); - - if (i > count) - { - i = count; - count = 0; - } - else count -= i; - - for (j = 0; j < i; j++) - { - v1 = src[ofs >> FRACTION_BITS]; - v2 = src[(ofs >> FRACTION_BITS)+1]; - *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); - ofs += incr; - } - - if (ofs >= le) - { - if (ofs == le) - *dest++ = src[(ofs>>FRACTION_BITS)-1]/2; - vp->status=VOICE_FREE; - *countptr-=count+1; - } - - vp->sample_offset=ofs; /* Update offset */ - return song->resample_buffer; -} - -static sample_t *rs_loop(MidiSong *song, Voice *vp, Sint32 count) -{ - - /* Play sample until end-of-loop, skip back and continue. */ - - sample_t v1, v2; - Sint32 - ofs=vp->sample_offset, - incr=vp->sample_increment, - le=vp->sample->loop_end, - ll=le - vp->sample->loop_start; - sample_t - *dest=song->resample_buffer, - *src=vp->sample->data; - Sint32 i, j; - - while (count) - { - while (ofs >= le) - ofs -= ll; - /* Precalc how many times we should go through the loop */ - i = PRECALC_LOOP_COUNT(ofs, le, incr); - if (i > count) - { - i = count; - count = 0; - } - else count -= i; - for (j = 0; j < i; j++) - { - v1 = src[ofs >> FRACTION_BITS]; - v2 = src[(ofs >> FRACTION_BITS)+1]; - *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); - ofs += incr; - } - } - - vp->sample_offset=ofs; /* Update offset */ - return song->resample_buffer; -} - -static sample_t *rs_bidir(MidiSong *song, Voice *vp, Sint32 count) -{ - sample_t v1, v2; - Sint32 - ofs=vp->sample_offset, - incr=vp->sample_increment, - le=vp->sample->loop_end, - ls=vp->sample->loop_start; - sample_t - *dest=song->resample_buffer, - *src=vp->sample->data; - Sint32 - le2 = le<<1, - ls2 = ls<<1, - i, j; - /* Play normally until inside the loop region */ - - if (incr > 0 && ofs < ls) - { - /* NOTE: Assumes that incr > 0, which is NOT always the case - when doing bidirectional looping. I have yet to see a case - where both ofs <= ls AND incr < 0, however. */ - i = PRECALC_LOOP_COUNT(ofs, ls, incr); - if (i > count) - { - i = count; - count = 0; - } - else count -= i; - for (j = 0; j < i; j++) - { - v1 = src[ofs >> FRACTION_BITS]; - v2 = src[(ofs >> FRACTION_BITS)+1]; - *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); - ofs += incr; - } - } - - /* Then do the bidirectional looping */ - - while(count) - { - /* Precalc how many times we should go through the loop */ - i = PRECALC_LOOP_COUNT(ofs, incr > 0 ? le : ls, incr); - if (i > count) - { - i = count; - count = 0; - } - else count -= i; - for (j = 0; j < i; j++) - { - v1 = src[ofs >> FRACTION_BITS]; - v2 = src[(ofs >> FRACTION_BITS)+1]; - *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); - ofs += incr; - } - if (ofs>=le) - { - /* fold the overshoot back in */ - ofs = le2 - ofs; - incr *= -1; - } - else if (ofs <= ls) - { - ofs = ls2 - ofs; - incr *= -1; - } - } - - vp->sample_increment=incr; - vp->sample_offset=ofs; /* Update offset */ - return song->resample_buffer; -} - -/*********************** vibrato versions ***************************/ - -/* We only need to compute one half of the vibrato sine cycle */ -static int vib_phase_to_inc_ptr(int phase) -{ - if (phase < VIBRATO_SAMPLE_INCREMENTS/2) - return VIBRATO_SAMPLE_INCREMENTS/2-1-phase; - else if (phase >= 3*VIBRATO_SAMPLE_INCREMENTS/2) - return 5*VIBRATO_SAMPLE_INCREMENTS/2-1-phase; - else - return phase-VIBRATO_SAMPLE_INCREMENTS/2; -} - -static Sint32 update_vibrato(MidiSong *song, Voice *vp, int sign) -{ - Sint32 depth; - int phase, pb; - double a; - - if (vp->vibrato_phase++ >= 2*VIBRATO_SAMPLE_INCREMENTS-1) - vp->vibrato_phase=0; - phase=vib_phase_to_inc_ptr(vp->vibrato_phase); - - if (vp->vibrato_sample_increment[phase]) - { - if (sign) - return -vp->vibrato_sample_increment[phase]; - else - return vp->vibrato_sample_increment[phase]; - } - - /* Need to compute this sample increment. */ - - depth=vp->sample->vibrato_depth<<7; - - if (vp->vibrato_sweep) - { - /* Need to update sweep */ - vp->vibrato_sweep_position += vp->vibrato_sweep; - if (vp->vibrato_sweep_position >= (1<vibrato_sweep=0; - else - { - /* Adjust depth */ - depth *= vp->vibrato_sweep_position; - depth >>= SWEEP_SHIFT; - } - } - - a = FSCALE(((double)(vp->sample->sample_rate) * - (double)(vp->frequency)) / - ((double)(vp->sample->root_freq) * - (double)(song->rate)), - FRACTION_BITS); - - pb=(int)((sine(vp->vibrato_phase * - (SINE_CYCLE_LENGTH/(2*VIBRATO_SAMPLE_INCREMENTS))) - * (double)(depth) * VIBRATO_AMPLITUDE_TUNING)); - - if (pb<0) - { - pb=-pb; - a /= bend_fine[(pb>>5) & 0xFF] * bend_coarse[pb>>13]; - } - else - a *= bend_fine[(pb>>5) & 0xFF] * bend_coarse[pb>>13]; - - /* If the sweep's over, we can store the newly computed sample_increment */ - if (!vp->vibrato_sweep) - vp->vibrato_sample_increment[phase]=(Sint32) a; - - if (sign) - a = -a; /* need to preserve the loop direction */ - - return (Sint32) a; -} - -static sample_t *rs_vib_plain(MidiSong *song, int v, Sint32 *countptr) -{ - - /* Play sample until end, then free the voice. */ - - sample_t v1, v2; - Voice *vp=&(song->voice[v]); - sample_t - *dest=song->resample_buffer, - *src=vp->sample->data; - Sint32 - le=vp->sample->data_length, - ofs=vp->sample_offset, - incr=vp->sample_increment, - count=*countptr; - int - cc=vp->vibrato_control_counter; - - /* This has never been tested */ - - if (incr<0) incr = -incr; /* In case we're coming out of a bidir loop */ - - while (count--) - { - if (!cc--) - { - cc=vp->vibrato_control_ratio; - incr=update_vibrato(song, vp, 0); - } - v1 = src[ofs >> FRACTION_BITS]; - v2 = src[(ofs >> FRACTION_BITS)+1]; - *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); - ofs += incr; - if (ofs >= le) - { - if (ofs == le) - *dest++ = src[(ofs>>FRACTION_BITS)-1]/2; - vp->status=VOICE_FREE; - *countptr-=count+1; - break; - } - } - - vp->vibrato_control_counter=cc; - vp->sample_increment=incr; - vp->sample_offset=ofs; /* Update offset */ - return song->resample_buffer; -} - -static sample_t *rs_vib_loop(MidiSong *song, Voice *vp, Sint32 count) -{ - - /* Play sample until end-of-loop, skip back and continue. */ - - sample_t v1, v2; - Sint32 - ofs=vp->sample_offset, - incr=vp->sample_increment, - le=vp->sample->loop_end, - ll=le - vp->sample->loop_start; - sample_t - *dest=song->resample_buffer, - *src=vp->sample->data; - int - cc=vp->vibrato_control_counter; - Sint32 i, j; - int - vibflag=0; - - while (count) - { - /* Hopefully the loop is longer than an increment */ - while(ofs >= le) - ofs -= ll; - /* Precalc how many times to go through the loop, taking - the vibrato control ratio into account this time. */ - i = PRECALC_LOOP_COUNT(ofs, le, incr); - if(i > count) i = count; - if(i > cc) - { - i = cc; - vibflag = 1; - } - else cc -= i; - count -= i; - for (j = 0; j < i; j++) - { - v1 = src[ofs >> FRACTION_BITS]; - v2 = src[(ofs >> FRACTION_BITS)+1]; - *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); - ofs += incr; - } - if(vibflag) - { - cc = vp->vibrato_control_ratio; - incr = update_vibrato(song, vp, 0); - vibflag = 0; - } - } - - vp->vibrato_control_counter=cc; - vp->sample_increment=incr; - vp->sample_offset=ofs; /* Update offset */ - return song->resample_buffer; -} - -static sample_t *rs_vib_bidir(MidiSong *song, Voice *vp, Sint32 count) -{ - sample_t v1, v2; - Sint32 - ofs=vp->sample_offset, - incr=vp->sample_increment, - le=vp->sample->loop_end, - ls=vp->sample->loop_start; - sample_t - *dest=song->resample_buffer, - *src=vp->sample->data; - int - cc=vp->vibrato_control_counter; - Sint32 - le2=le<<1, - ls2=ls<<1, - i, j; - int - vibflag = 0; - - /* Play normally until inside the loop region */ - while (count && incr > 0 && ofs < ls) - { - i = PRECALC_LOOP_COUNT(ofs, ls, incr); - if (i > count) i = count; - if (i > cc) - { - i = cc; - vibflag = 1; - } - else cc -= i; - count -= i; - for (j = 0; j < i; j++) - { - v1 = src[ofs >> FRACTION_BITS]; - v2 = src[(ofs >> FRACTION_BITS)+1]; - *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); - ofs += incr; - } - if (vibflag) - { - cc = vp->vibrato_control_ratio; - incr = update_vibrato(song, vp, 0); - vibflag = 0; - } - } - - /* Then do the bidirectional looping */ - - while (count) - { - /* Precalc how many times we should go through the loop */ - i = PRECALC_LOOP_COUNT(ofs, incr > 0 ? le : ls, incr); - if(i > count) i = count; - if(i > cc) - { - i = cc; - vibflag = 1; - } - else cc -= i; - count -= i; - while (i--) - { - v1 = src[ofs >> FRACTION_BITS]; - v2 = src[(ofs >> FRACTION_BITS)+1]; - *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); - ofs += incr; - } - if (vibflag) - { - cc = vp->vibrato_control_ratio; - incr = update_vibrato(song, vp, (incr < 0)); - vibflag = 0; - } - if (ofs >= le) - { - /* fold the overshoot back in */ - ofs = le2 - ofs; - incr *= -1; - } - else if (ofs <= ls) - { - ofs = ls2 - ofs; - incr *= -1; - } - } - - vp->vibrato_control_counter=cc; - vp->sample_increment=incr; - vp->sample_offset=ofs; /* Update offset */ - return song->resample_buffer; -} - -sample_t *resample_voice(MidiSong *song, int v, Sint32 *countptr) -{ - Sint32 ofs; - Uint8 modes; - Voice *vp=&(song->voice[v]); - - if (!(vp->sample->sample_rate)) - { - /* Pre-resampled data -- just update the offset and check if - we're out of data. */ - ofs=vp->sample_offset >> FRACTION_BITS; /* Kind of silly to use - FRACTION_BITS here... */ - if (*countptr >= (vp->sample->data_length>>FRACTION_BITS) - ofs) - { - /* Note finished. Free the voice. */ - vp->status = VOICE_FREE; - - /* Let the caller know how much data we had left */ - *countptr = (vp->sample->data_length>>FRACTION_BITS) - ofs; - } - else - vp->sample_offset += *countptr << FRACTION_BITS; - - return vp->sample->data+ofs; - } - - /* Need to resample. Use the proper function. */ - modes=vp->sample->modes; - - if (vp->vibrato_control_ratio) - { - if ((modes & MODES_LOOPING) && - ((modes & MODES_ENVELOPE) || - (vp->status==VOICE_ON || vp->status==VOICE_SUSTAINED))) - { - if (modes & MODES_PINGPONG) - return rs_vib_bidir(song, vp, *countptr); - else - return rs_vib_loop(song, vp, *countptr); - } - else - return rs_vib_plain(song, v, countptr); - } - else - { - if ((modes & MODES_LOOPING) && - ((modes & MODES_ENVELOPE) || - (vp->status==VOICE_ON || vp->status==VOICE_SUSTAINED))) - { - if (modes & MODES_PINGPONG) - return rs_bidir(song, vp, *countptr); - else - return rs_loop(song, vp, *countptr); - } - else - return rs_plain(song, v, countptr); - } -} - -void pre_resample(MidiSong *song, Sample *sp) -{ - double a, xdiff; - Sint32 incr, ofs, newlen, count; - Sint16 *newdata, *dest, *src = (Sint16 *) sp->data, *vptr; - Sint32 v, v1, v2, v3, v4, v5, i; -#ifdef DEBUG_CHATTER - static const char note_name[12][3] = - { - "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" - }; - - SNDDBG((" * pre-resampling for note %d (%s%d)\n", - sp->note_to_use, - note_name[sp->note_to_use % 12], (sp->note_to_use & 0x7F) / 12)); -#endif - - a = ((double) (sp->root_freq) * song->rate) / - ((double) (sp->sample_rate) * freq_table[(int) (sp->note_to_use)]); - if(sp->data_length * a >= 0x7fffffffL) { /* Too large to compute */ - SNDDBG((" *** Can't pre-resampling for note %d\n", sp->note_to_use)); - return; - } - - newlen = (Sint32)(sp->data_length * a); - count = (newlen >> FRACTION_BITS) - 1; - ofs = incr = (sp->data_length - (1 << FRACTION_BITS)) / count; - - if((double)newlen + incr >= 0x7fffffffL) { /* Too large to compute */ - SNDDBG((" *** Can't pre-resampling for note %d\n", sp->note_to_use)); - return; - } - - dest = newdata = (Sint16 *) safe_malloc((newlen >> (FRACTION_BITS - 1)) + 2); - if (!dest) - return; - - if (--count) - *dest++ = src[0]; - - /* Since we're pre-processing and this doesn't have to be done in - real-time, we go ahead and do the full sliding cubic interpolation. */ - count--; - for(i = 0; i < count; i++) - { - vptr = src + (ofs >> FRACTION_BITS); - v1 = ((vptr>=src+1)? *(vptr - 1):0); - v2 = *vptr; - v3 = *(vptr + 1); - v4 = *(vptr + 2); - v5 = v2 - v3; - xdiff = FSCALENEG(ofs & FRACTION_MASK, FRACTION_BITS); - v = (Sint32)(v2 + xdiff * (1.0/6.0) * (3 * (v3 - v5) - 2 * v1 - v4 + - xdiff * (3 * (v1 - v2 - v5) + xdiff * (3 * v5 + v4 - v1)))); - *dest++ = (Sint16)((v > 32767) ? 32767 : ((v < -32768) ? -32768 : v)); - ofs += incr; - } - - if (ofs & FRACTION_MASK) - { - v1 = src[ofs >> FRACTION_BITS]; - v2 = src[(ofs >> FRACTION_BITS) + 1]; - *dest++ = (Sint16)(v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS)); - } - else - *dest++ = src[ofs >> FRACTION_BITS]; - - *dest = *(dest - 1) / 2; - ++dest; - *dest = *(dest - 1) / 2; - - sp->data_length = newlen; - sp->loop_start = (Sint32)(sp->loop_start * a); - sp->loop_end = (Sint32)(sp->loop_end * a); - free(sp->data); - sp->data = (sample_t *) newdata; - sp->sample_rate = 0; -} diff --git a/timidity/resample.h b/timidity/resample.h deleted file mode 100644 index 10081e1..0000000 --- a/timidity/resample.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - - resample.h -*/ - -extern sample_t *resample_voice(MidiSong *song, int v, Sint32 *countptr); -extern void pre_resample(MidiSong *song, Sample *sp); diff --git a/timidity/tables.c b/timidity/tables.c deleted file mode 100644 index edb5f00..0000000 --- a/timidity/tables.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. -*/ - -#if HAVE_CONFIG_H -# include -#endif - -#include - -#include "SDL.h" - -#include "tables.h" - -const Sint32 freq_table[128]= -{ - 8176, 8662, 9177, 9723, - 10301, 10913, 11562, 12250, - 12978, 13750, 14568, 15434, - - 16352, 17324, 18354, 19445, - 20602, 21827, 23125, 24500, - 25957, 27500, 29135, 30868, - - 32703, 34648, 36708, 38891, - 41203, 43654, 46249, 48999, - 51913, 55000, 58270, 61735, - - 65406, 69296, 73416, 77782, - 82407, 87307, 92499, 97999, - 103826, 110000, 116541, 123471, - - 130813, 138591, 146832, 155563, - 164814, 174614, 184997, 195998, - 207652, 220000, 233082, 246942, - - 261626, 277183, 293665, 311127, - 329628, 349228, 369994, 391995, - 415305, 440000, 466164, 493883, - - 523251, 554365, 587330, 622254, - 659255, 698456, 739989, 783991, - 830609, 880000, 932328, 987767, - - 1046502, 1108731, 1174659, 1244508, - 1318510, 1396913, 1479978, 1567982, - 1661219, 1760000, 1864655, 1975533, - - 2093005, 2217461, 2349318, 2489016, - 2637020, 2793826, 2959955, 3135963, - 3322438, 3520000, 3729310, 3951066, - - 4186009, 4434922, 4698636, 4978032, - 5274041, 5587652, 5919911, 6271927, - 6644875, 7040000, 7458620, 7902133, - - 8372018, 8869844, 9397273, 9956063, - 10548082, 11175303, 11839822, 12543854 -}; - -/* v=2.^((x/127-1) * 6) */ -const double vol_table[128] = -{ - 0.015625, 0.016145143728351113, 0.016682602624583379, 0.017237953096759438, - 0.017811790741104401, 0.01840473098076444, 0.019017409725829021, 0.019650484055324921, - 0.020304632921913132, 0.020980557880044631, 0.021678983838355849, 0.02240065983711079, - 0.023146359851523596, 0.023916883621822989, 0.024713057510949051, 0.025535735390801884, - 0.026385799557992876, 0.027264161680080529, 0.028171763773305786, 0.029109579212875332, - 0.030078613776876421, 0.031079906724942836, 0.032114531912828696, 0.033183598944085631, - 0.034288254360078256, 0.035429682869614412, 0.036609108619508737, 0.037827796507442342, - 0.039087053538526394, 0.040388230227024875, 0.041732722044739302, 0.043121970917609151, - 0.044557466772132896, 0.046040749133268132, 0.047573408775524545, 0.049157089429020417, - 0.050793489542332405, 0.05248436410402918, 0.054231526524842463, 0.056036850582493913, - 0.057902272431264008, 0.059829792678457581, 0.061821478529993396, 0.063879466007418645, - 0.066005962238725971, 0.068203247825430205, 0.070473679288442961, 0.072819691595368496, - 0.075243800771931268, 0.077748606600335793, 0.080336795407452768, 0.083011142945821612, - 0.085774517370559328, 0.088629882315368294, 0.091580300070941839, 0.094628934869176312, - 0.097779056276712184, 0.10103404270144323, 0.1043973850157546, 0.1078726903003755, - 0.11146368571286204, 0.11517422248485852, 0.11900828005242428, 0.12296997032385605, - 0.12706354208958254, 0.13129338557886089, 0.13566403716816194, 0.14018018424629392, - 0.14484667024148207, 0.14966849981579558, 0.15465084423249356, 0.15979904690204472, - 0.16511862911277009, 0.17061529595225433, 0.17629494242587571, 0.18216365977901747, - 0.18822774202974024, 0.19449369271892172, 0.20096823188510385, 0.20765830327152621, - 0.21457108177307616, 0.22171398113114205, 0.2290946618846218, 0.23672103958561411, - 0.2446012932886038, 0.25274387432224471, 0.26115751535314891, 0.26985123975140174, - 0.27883437126784744, 0.28811654403352405, 0.29770771289197112, 0.30761816407549192, - 0.31785852623682015, 0.32843978184802081, 0.33937327897885317, 0.3506707434672246, - 0.36234429149478936, 0.37440644258117928, 0.38687013301080181, 0.39974872970660535, - 0.41305604456569134, 0.42680634927214656, 0.44101439060298442, 0.45569540624360722, - 0.47086514112975281, 0.48653986433345225, 0.50273638651110641, 0.51947207793239625, - 0.53676488710936021, 0.55463336004561792, 0.57309666012638816, 0.59217458867062556, - 0.61188760616732485, 0.63225685421876243, 0.65330417821421161, 0.67505215075844849, - 0.69752409588017272, 0.72074411404630734, 0.74473710800900605, 0.76952880951308478, - 0.79514580689252357, 0.82161557358563286, 0.84896649759946774, 0.87722791195508854, - 0.90643012614631979, 0.93660445864574493, 0.96778327049280244, 1 -}; - -const double bend_fine[256] = { - 1, 1.0002256593050698, 1.0004513695322617, 1.0006771306930664, - 1.0009029427989777, 1.0011288058614922, 1.0013547198921082, 1.0015806849023274, - 1.0018067009036538, 1.002032767907594, 1.0022588859256572, 1.0024850549693551, - 1.0027112750502025, 1.0029375461797159, 1.0031638683694153, 1.0033902416308227, - 1.0036166659754628, 1.0038431414148634, 1.0040696679605541, 1.0042962456240678, - 1.0045228744169397, 1.0047495543507072, 1.0049762854369111, 1.0052030676870944, - 1.0054299011128027, 1.0056567857255843, 1.00588372153699, 1.006110708558573, - 1.0063377468018897, 1.0065648362784985, 1.0067919769999607, 1.0070191689778405, - 1.0072464122237039, 1.0074737067491204, 1.0077010525656616, 1.0079284496849015, - 1.0081558981184175, 1.008383397877789, 1.008610948974598, 1.0088385514204294, - 1.0090662052268706, 1.0092939104055114, 1.0095216669679448, 1.0097494749257656, - 1.009977334290572, 1.0102052450739643, 1.0104332072875455, 1.0106612209429215, - 1.0108892860517005, 1.0111174026254934, 1.0113455706759138, 1.0115737902145781, - 1.0118020612531047, 1.0120303838031153, 1.0122587578762337, 1.012487183484087, - 1.0127156606383041, 1.0129441893505169, 1.0131727696323602, 1.0134014014954713, - 1.0136300849514894, 1.0138588200120575, 1.0140876066888203, 1.0143164449934257, - 1.0145453349375237, 1.0147742765327674, 1.0150032697908125, 1.0152323147233171, - 1.015461411341942, 1.0156905596583505, 1.0159197596842091, 1.0161490114311862, - 1.0163783149109531, 1.0166076701351838, 1.0168370771155553, 1.0170665358637463, - 1.0172960463914391, 1.0175256087103179, 1.0177552228320703, 1.0179848887683858, - 1.0182146065309567, 1.0184443761314785, 1.0186741975816487, 1.0189040708931674, - 1.0191339960777379, 1.0193639731470658, 1.0195940021128593, 1.0198240829868295, - 1.0200542157806898, 1.0202844005061564, 1.0205146371749483, 1.0207449257987866, - 1.0209752663893958, 1.0212056589585028, 1.0214361035178368, 1.0216666000791297, - 1.0218971486541166, 1.0221277492545349, 1.0223584018921241, 1.0225891065786274, - 1.0228198633257899, 1.0230506721453596, 1.023281533049087, 1.0235124460487257, - 1.0237434111560313, 1.0239744283827625, 1.0242054977406807, 1.0244366192415495, - 1.0246677928971357, 1.0248990187192082, 1.025130296719539, 1.0253616269099028, - 1.0255930093020766, 1.0258244439078401, 1.0260559307389761, 1.0262874698072693, - 1.0265190611245079, 1.0267507047024822, 1.0269824005529853, 1.027214148687813, - 1.0274459491187637, 1.0276778018576387, 1.0279097069162415, 1.0281416643063788, - 1.0283736740398595, 1.0286057361284953, 1.0288378505841009, 1.0290700174184932, - 1.0293022366434921, 1.0295345082709197, 1.0297668323126017, 1.0299992087803651, - 1.030231637686041, 1.0304641190414621, 1.0306966528584645, 1.0309292391488862, - 1.0311618779245688, 1.0313945691973556, 1.0316273129790936, 1.0318601092816313, - 1.0320929581168212, 1.0323258594965172, 1.0325588134325767, 1.0327918199368598, - 1.0330248790212284, 1.0332579906975481, 1.0334911549776868, 1.033724371873515, - 1.0339576413969056, 1.0341909635597348, 1.0344243383738811, 1.0346577658512259, - 1.034891246003653, 1.0351247788430489, 1.0353583643813031, 1.0355920026303078, - 1.0358256936019572, 1.0360594373081489, 1.0362932337607829, 1.0365270829717617, - 1.0367609849529913, 1.0369949397163791, 1.0372289472738365, 1.0374630076372766, - 1.0376971208186156, 1.0379312868297725, 1.0381655056826686, 1.0383997773892284, - 1.0386341019613787, 1.0388684794110492, 1.0391029097501721, 1.0393373929906822, - 1.0395719291445176, 1.0398065182236185, 1.0400411602399278, 1.0402758552053915, - 1.0405106031319582, 1.0407454040315787, 1.0409802579162071, 1.0412151647977996, - 1.0414501246883161, 1.0416851375997183, 1.0419202035439705, 1.0421553225330404, - 1.042390494578898, 1.042625719693516, 1.0428609978888699, 1.043096329176938, - 1.0433317135697009, 1.0435671510791424, 1.0438026417172486, 1.0440381854960086, - 1.0442737824274138, 1.044509432523459, 1.044745135796141, 1.0449808922574599, - 1.0452167019194181, 1.0454525647940205, 1.0456884808932754, 1.0459244502291931, - 1.0461604728137874, 1.0463965486590741, 1.046632677777072, 1.0468688601798024, - 1.0471050958792898, 1.047341384887561, 1.0475777272166455, 1.047814122878576, - 1.048050571885387, 1.0482870742491166, 1.0485236299818055, 1.0487602390954964, - 1.0489969016022356, 1.0492336175140715, 1.0494703868430555, 1.0497072096012419, - 1.0499440858006872, 1.0501810154534512, 1.050417998571596, 1.0506550351671864, - 1.0508921252522903, 1.0511292688389782, 1.0513664659393229, 1.0516037165654004, - 1.0518410207292894, 1.0520783784430709, 1.0523157897188296, 1.0525532545686513, - 1.0527907730046264, 1.0530283450388465, 1.0532659706834067, 1.0535036499504049, - 1.0537413828519411, 1.0539791694001188, 1.0542170096070436, 1.0544549034848243, - 1.0546928510455722, 1.0549308523014012, 1.0551689072644284, 1.0554070159467728, - 1.0556451783605572, 1.0558833945179062, 1.0561216644309479, 1.0563599881118126, - 1.0565983655726334, 1.0568367968255465, 1.0570752818826903, 1.0573138207562065, - 1.057552413458239, 1.0577910600009348, 1.0580297603964437, 1.058268514656918, - 1.0585073227945128, 1.0587461848213857, 1.058985100749698, 1.0592240705916123 -}; - -const double bend_coarse[128] = { - 1, 1.0594630943592953, 1.122462048309373, 1.189207115002721, - 1.2599210498948732, 1.3348398541700344, 1.4142135623730951, 1.4983070768766815, - 1.5874010519681994, 1.681792830507429, 1.7817974362806785, 1.8877486253633868, - 2, 2.1189261887185906, 2.244924096618746, 2.3784142300054421, - 2.5198420997897464, 2.6696797083400687, 2.8284271247461903, 2.996614153753363, - 3.1748021039363992, 3.363585661014858, 3.5635948725613571, 3.7754972507267741, - 4, 4.2378523774371812, 4.4898481932374912, 4.7568284600108841, - 5.0396841995794928, 5.3393594166801366, 5.6568542494923806, 5.993228307506727, - 6.3496042078727974, 6.727171322029716, 7.1271897451227151, 7.5509945014535473, - 8, 8.4757047548743625, 8.9796963864749824, 9.5136569200217682, - 10.079368399158986, 10.678718833360273, 11.313708498984761, 11.986456615013454, - 12.699208415745595, 13.454342644059432, 14.25437949024543, 15.101989002907095, - 16, 16.951409509748721, 17.959392772949972, 19.027313840043536, - 20.158736798317967, 21.357437666720553, 22.627416997969522, 23.972913230026901, - 25.398416831491197, 26.908685288118864, 28.508758980490853, 30.203978005814196, - 32, 33.902819019497443, 35.918785545899944, 38.054627680087073, - 40.317473596635935, 42.714875333441107, 45.254833995939045, 47.945826460053802, - 50.796833662982394, 53.817370576237728, 57.017517960981706, 60.407956011628393, - 64, 67.805638038994886, 71.837571091799887, 76.109255360174146, - 80.63494719327187, 85.429750666882214, 90.509667991878089, 95.891652920107603, - 101.59366732596479, 107.63474115247546, 114.03503592196341, 120.81591202325679, - 128, 135.61127607798977, 143.67514218359977, 152.21851072034829, - 161.26989438654374, 170.85950133376443, 181.01933598375618, 191.78330584021521, - 203.18733465192958, 215.26948230495091, 228.07007184392683, 241.63182404651357, - 256, 271.22255215597971, 287.35028436719938, 304.43702144069658, - 322.53978877308765, 341.71900266752868, 362.03867196751236, 383.56661168043064, - 406.37466930385892, 430.53896460990183, 456.14014368785394, 483.26364809302686, - 512, 542.44510431195943, 574.70056873439876, 608.87404288139317, - 645.0795775461753, 683.43800533505737, 724.07734393502471, 767.13322336086128, - 812.74933860771785, 861.07792921980365, 912.28028737570787, 966.52729618605372, - 1024, 1084.8902086239189, 1149.4011374687975, 1217.7480857627863, - 1290.1591550923506, 1366.8760106701147, 1448.1546878700494, 1534.2664467217226 -}; diff --git a/timidity/tables.h b/timidity/tables.h deleted file mode 100644 index db71ed7..0000000 --- a/timidity/tables.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - - tables.h -*/ - -#include -#define sine(x) (sin((2*PI/1024.0) * (x))) - -#define SINE_CYCLE_LENGTH 1024 -extern const Sint32 freq_table[]; -extern const double vol_table[]; -extern const double bend_fine[]; -extern const double bend_coarse[]; diff --git a/timidity/timidity.c b/timidity/timidity.c deleted file mode 100644 index 6251f87..0000000 --- a/timidity/timidity.c +++ /dev/null @@ -1,636 +0,0 @@ -/* - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. -*/ - -#if HAVE_CONFIG_H -# include -#endif - -#include -#include -#include - -#include "SDL.h" - -#include "timidity.h" - -#include "options.h" -#include "common.h" -#include "instrum.h" -#include "playmidi.h" -#include "readmidi.h" -#include "output.h" - -#include "tables.h" - -ToneBank *master_tonebank[MAXBANK], *master_drumset[MAXBANK]; - -static char def_instr_name[256] = ""; - -#define MAXWORDS 10 - -/* Quick-and-dirty fgets() replacement. */ - -static char *RWgets(SDL_RWops *rw, char *s, int size) -{ - int num_read = 0; - char *p = s; - - --size;/* so that we nul terminate properly */ - - for (; num_read < size; ++p) - { - if (SDL_RWread(rw, p, 1, 1) != 1) - break; - - num_read++; - - /* Unlike fgets(), don't store newline. Under Windows/DOS we'll - * probably get an extra blank line for every line that's being - * read, but that should be ok. - */ - if (*p == '\n' || *p == '\r') - { - *p = '\0'; - return s; - } - } - - *p = '\0'; - - return (num_read != 0) ? s : NULL; -} - -static int read_config_file(const char *name) -{ - SDL_RWops *rw; - char tmp[1024], *w[MAXWORDS], *cp; - ToneBank *bank=0; - int i, j, k, line=0, words; - static int rcf_count=0; - - if (rcf_count>50) - { - SNDDBG(("Probable source loop in configuration files\n")); - return (-1); - } - - if (!(rw=open_file(name))) - return -1; - - while (RWgets(rw, tmp, sizeof(tmp))) - { - line++; - words=0; - w[0]=strtok(tmp, " \t\240"); - if (!w[0]) continue; - - /* Originally the TiMidity++ extensions were prefixed like this */ - if (strcmp(w[0], "#extension") == 0) - { - w[0]=strtok(0, " \t\240"); - if (!w[0]) continue; - } - - if (*w[0] == '#') - continue; - - while (w[words] && *w[words] != '#' && (words < (MAXWORDS-1))) - w[++words]=strtok(0," \t\240"); - - /* - * TiMidity++ adds a number of extensions to the config file format. - * Many of them are completely irrelevant to SDL_sound, but at least - * we shouldn't choke on them. - * - * Unfortunately the documentation for these extensions is often quite - * vague, gramatically strange or completely absent. - */ - if ( - !strcmp(w[0], "comm") /* "comm" program second */ - || !strcmp(w[0], "HTTPproxy") /* "HTTPproxy" hostname:port */ - || !strcmp(w[0], "FTPproxy") /* "FTPproxy" hostname:port */ - || !strcmp(w[0], "mailaddr") /* "mailaddr" your-mail-address */ - || !strcmp(w[0], "opt") /* "opt" timidity-options */ - ) - { - /* - * + "comm" sets some kind of comment -- the documentation is too - * vague for me to understand at this time. - * + "HTTPproxy", "FTPproxy" and "mailaddr" are for reading data - * over a network, rather than from the file system. - * + "opt" specifies default options for TiMidity++. - * - * These are all quite useless for our version of TiMidity, so - * they can safely remain no-ops. - */ - } else if (!strcmp(w[0], "timeout")) /* "timeout" program second */ - { - /* - * Specifies a timeout value of the program. A number of seconds - * before TiMidity kills the note. This may be useful to implement - * later, but I don't see any urgent need for it. - */ - SNDDBG(("FIXME: Implement \"timeout\" in TiMidity config.\n")); - } else if (!strcmp(w[0], "copydrumset") /* "copydrumset" drumset */ - || !strcmp(w[0], "copybank")) /* "copybank" bank */ - { - /* - * Copies all the settings of the specified drumset or bank to - * the current drumset or bank. May be useful later, but not a - * high priority. - */ - SNDDBG(("FIXME: Implement \"%s\" in TiMidity config.\n", w[0])); - } else if (!strcmp(w[0], "undef")) /* "undef" progno */ - { - /* - * Undefines the tone "progno" of the current tone bank (or - * drum set?). Not a high priority. - */ - SNDDBG(("FIXME: Implement \"undef\" in TiMidity config.\n")); - } else if (!strcmp(w[0], "altassign")) /* "altassign" prog1 prog2 ... */ - { - /* - * Sets the alternate assign for drum set. Whatever that's - * supposed to mean. - */ - SNDDBG(("FIXME: Implement \"altassign\" in TiMidity config.\n")); - } else if (!strcmp(w[0], "soundfont") - || !strcmp(w[0], "font")) - { - /* - * I can't find any documentation for these, but I guess they're - * an alternative way of loading/unloading instruments. - * - * "soundfont" sf_file "remove" - * "soundfont" sf_file ["order=" order] ["cutoff=" cutoff] - * ["reso=" reso] ["amp=" amp] - * "font" "exclude" bank preset keynote - * "font" "order" order bank preset keynote - */ - SNDDBG(("FIXME: Implmement \"%s\" in TiMidity config.\n", w[0])); - } else if (!strcmp(w[0], "progbase")) - { - /* - * The documentation for this makes absolutely no sense to me, but - * apparently it sets some sort of base offset for tone numbers. - * Why anyone would want to do this is beyond me. - */ - SNDDBG(("FIXME: Implement \"progbase\" in TiMidity config.\n")); - } else if (!strcmp(w[0], "map")) /* "map" name set1 elem1 set2 elem2 */ - { - /* - * This extension is the one we will need to implement, as it is - * used by the "eawpats". Unfortunately I cannot find any - * documentation whatsoever for it, but it looks like it's used - * for remapping one instrument to another somehow. - */ - SNDDBG(("FIXME: Implement \"map\" in TiMidity config.\n")); - } - - /* Standard TiMidity config */ - - else if (!strcmp(w[0], "dir")) - { - if (words < 2) - { - SNDDBG(("%s: line %d: No directory given\n", name, line)); - goto fail; - } - for (i=1; i(MAXBANK-1)) - { - SNDDBG(("%s: line %d: Drum set must be between 0 and %d\n", - name, line, MAXBANK-1)); - goto fail; - } - if (!master_drumset[i]) - { - master_drumset[i] = safe_malloc(sizeof(ToneBank)); - memset(master_drumset[i], 0, sizeof(ToneBank)); - master_drumset[i]->tone = safe_malloc(128 * sizeof(ToneBankElement)); - memset(master_drumset[i]->tone, 0, 128 * sizeof(ToneBankElement)); - } - bank=master_drumset[i]; - } - else if (!strcmp(w[0], "bank")) - { - if (words < 2) - { - SNDDBG(("%s: line %d: No bank number given\n", name, line)); - goto fail; - } - i=atoi(w[1]); - if (i<0 || i>(MAXBANK-1)) - { - SNDDBG(("%s: line %d: Tone bank must be between 0 and %d\n", - name, line, MAXBANK-1)); - goto fail; - } - if (!master_tonebank[i]) - { - master_tonebank[i] = safe_malloc(sizeof(ToneBank)); - memset(master_tonebank[i], 0, sizeof(ToneBank)); - master_tonebank[i]->tone = safe_malloc(128 * sizeof(ToneBankElement)); - memset(master_tonebank[i]->tone, 0, 128 * sizeof(ToneBankElement)); - } - bank=master_tonebank[i]; - } - else - { - if ((words < 2) || (*w[0] < '0' || *w[0] > '9')) - { - SNDDBG(("%s: line %d: syntax error\n", name, line)); - continue; - } - i=atoi(w[0]); - if (i<0 || i>127) - { - SNDDBG(("%s: line %d: Program must be between 0 and 127\n", - name, line)); - goto fail; - } - if (!bank) - { - SNDDBG(("%s: line %d: Must specify tone bank or drum set before assignment\n", - name, line)); - goto fail; - } - if (bank->tone[i].name) - free(bank->tone[i].name); - strcpy((bank->tone[i].name=safe_malloc(strlen(w[1])+1)),w[1]); - bank->tone[i].note=bank->tone[i].amp=bank->tone[i].pan= - bank->tone[i].strip_loop=bank->tone[i].strip_envelope= - bank->tone[i].strip_tail=-1; - - for (j=2; j '9')) - { - SNDDBG(("%s: line %d: amplification must be between 0 and %d\n", - name, line, MAX_AMPLIFICATION)); - goto fail; - } - bank->tone[i].amp=k; - } - else if (!strcmp(w[j], "note")) - { - k=atoi(cp); - if ((k<0 || k>127) || (*cp < '0' || *cp > '9')) - { - SNDDBG(("%s: line %d: note must be between 0 and 127\n", - name, line)); - goto fail; - } - bank->tone[i].note=k; - } - else if (!strcmp(w[j], "pan")) - { - if (!strcmp(cp, "center")) - k=64; - else if (!strcmp(cp, "left")) - k=0; - else if (!strcmp(cp, "right")) - k=127; - else - k=((atoi(cp)+100) * 100) / 157; - if ((k<0 || k>127) || (k==0 && *cp!='-' && (*cp < '0' || *cp > '9'))) - { - SNDDBG(("%s: line %d: panning must be left, right, center, or between -100 and 100\n", - name, line)); - goto fail; - } - bank->tone[i].pan=k; - } - else if (!strcmp(w[j], "keep")) - { - if (!strcmp(cp, "env")) - bank->tone[i].strip_envelope=0; - else if (!strcmp(cp, "loop")) - bank->tone[i].strip_loop=0; - else - { - SNDDBG(("%s: line %d: keep must be env or loop\n", name, line)); - goto fail; - } - } - else if (!strcmp(w[j], "strip")) - { - if (!strcmp(cp, "env")) - bank->tone[i].strip_envelope=1; - else if (!strcmp(cp, "loop")) - bank->tone[i].strip_loop=1; - else if (!strcmp(cp, "tail")) - bank->tone[i].strip_tail=1; - else - { - SNDDBG(("%s: line %d: strip must be env, loop, or tail\n", - name, line)); - goto fail; - } - } - else - { - SNDDBG(("%s: line %d: bad patch option %s\n", name, line, w[j])); - goto fail; - } - } - } - } - SDL_RWclose(rw); - return 0; -fail: - SDL_RWclose(rw); - return -2; -} - -int Timidity_Init_NoConfig() -{ - /* Allocate memory for the standard tonebank and drumset */ - master_tonebank[0] = safe_malloc(sizeof(ToneBank)); - memset(master_tonebank[0], 0, sizeof(ToneBank)); - master_tonebank[0]->tone = safe_malloc(128 * sizeof(ToneBankElement)); - memset(master_tonebank[0]->tone, 0, 128 * sizeof(ToneBankElement)); - - master_drumset[0] = safe_malloc(sizeof(ToneBank)); - memset(master_drumset[0], 0, sizeof(ToneBank)); - master_drumset[0]->tone = safe_malloc(128 * sizeof(ToneBankElement)); - memset(master_drumset[0]->tone, 0, 128 * sizeof(ToneBankElement)); - - return 0; -} - -int Timidity_Init() -{ - const char *env = SDL_getenv("TIMIDITY_CFG"); - - /* !!! FIXME: This may be ugly, but slightly less so than requiring the - * default search path to have only one element. I think. - * - * We only need to include the likely locations for the config - * file itself since that file should contain any other directory - * that needs to be added to the search path. - */ -#ifdef DEFAULT_PATH - add_to_pathlist(DEFAULT_PATH); -#endif -#ifdef DEFAULT_PATH1 - add_to_pathlist(DEFAULT_PATH1); -#endif -#ifdef DEFAULT_PATH2 - add_to_pathlist(DEFAULT_PATH2); -#endif -#ifdef DEFAULT_PATH3 - add_to_pathlist(DEFAULT_PATH3); -#endif - - Timidity_Init_NoConfig(); - - if (!env || read_config_file(env)<0) { - if (read_config_file(CONFIG_FILE)<0) { - if (read_config_file(CONFIG_FILE_ETC)<0) { - if (read_config_file(CONFIG_FILE_ETC_TIMIDITY_FREEPATS)<0) { - return(-1); - } - } - } - } - return 0; -} - -MidiSong *Timidity_LoadSong(SDL_RWops *rw, SDL_AudioSpec *audio) -{ - MidiSong *song; - int i; - - if (rw == NULL) - return NULL; - - /* Allocate memory for the song */ - song = (MidiSong *)safe_malloc(sizeof(*song)); - if (song == NULL) - return NULL; - memset(song, 0, sizeof(*song)); - - for (i = 0; i < MAXBANK; i++) - { - if (master_tonebank[i]) - { - song->tonebank[i] = safe_malloc(sizeof(ToneBank)); - memset(song->tonebank[i], 0, sizeof(ToneBank)); - song->tonebank[i]->tone = master_tonebank[i]->tone; - } - if (master_drumset[i]) - { - song->drumset[i] = safe_malloc(sizeof(ToneBank)); - memset(song->drumset[i], 0, sizeof(ToneBank)); - song->drumset[i]->tone = master_drumset[i]->tone; - } - } - - song->amplification = DEFAULT_AMPLIFICATION; - song->voices = DEFAULT_VOICES; - song->drumchannels = DEFAULT_DRUMCHANNELS; - - song->rw = rw; - - song->rate = audio->freq; - song->encoding = 0; - if ((audio->format & 0xFF) == 16) - song->encoding |= PE_16BIT; - else if ((audio->format & 0xFF) == 32) - song->encoding |= PE_32BIT; - if (audio->format & 0x8000) - song->encoding |= PE_SIGNED; - if (audio->channels == 1) - song->encoding |= PE_MONO; - else if (audio->channels > 2) { - SDL_SetError("Surround sound not supported"); - free(song); - return NULL; - } - switch (audio->format) { - case AUDIO_S8: - song->write = s32tos8; - break; - case AUDIO_U8: - song->write = s32tou8; - break; - case AUDIO_S16LSB: - song->write = s32tos16l; - break; - case AUDIO_S16MSB: - song->write = s32tos16b; - break; - case AUDIO_U16LSB: - song->write = s32tou16l; - break; - case AUDIO_U16MSB: - song->write = s32tou16b; - break; - case AUDIO_S32LSB: - song->write = s32tos32l; - break; - case AUDIO_S32MSB: - song->write = s32tos32b; - break; - case AUDIO_F32SYS: - song->write = s32tof32; - break; - default: - SDL_SetError("Unsupported audio format"); - free(song); - return NULL; - } - - song->buffer_size = audio->samples; - song->resample_buffer = safe_malloc(audio->samples * sizeof(sample_t)); - song->common_buffer = safe_malloc(audio->samples * 2 * sizeof(Sint32)); - - song->control_ratio = audio->freq / CONTROLS_PER_SECOND; - if (song->control_ratio < 1) - song->control_ratio = 1; - else if (song->control_ratio > MAX_CONTROL_RATIO) - song->control_ratio = MAX_CONTROL_RATIO; - - song->lost_notes = 0; - song->cut_notes = 0; - - song->events = read_midi_file(song, &(song->groomed_event_count), - &song->samples); - - /* The RWops can safely be closed at this point, but let's make that the - * responsibility of the caller. - */ - - /* Make sure everything is okay */ - if (!song->events) { - free(song); - return(NULL); - } - - song->default_instrument = 0; - song->default_program = DEFAULT_PROGRAM; - - if (*def_instr_name) - set_default_instrument(song, def_instr_name); - - load_missing_instruments(song); - - return(song); -} - -void Timidity_FreeSong(MidiSong *song) -{ - int i; - - free_instruments(song); - - for (i = 0; i < 128; i++) - { - if (song->tonebank[i]) - free(song->tonebank[i]); - if (song->drumset[i]) - free(song->drumset[i]); - } - - free(song->common_buffer); - free(song->resample_buffer); - free(song->events); - free(song); -} - -void Timidity_Exit(void) -{ - int i, j; - - for (i = 0; i < MAXBANK; i++) - { - if (master_tonebank[i]) - { - ToneBankElement *e = master_tonebank[i]->tone; - if (e != NULL) - { - for (j = 0; j < 128; j++) - { - if (e[j].name != NULL) - free(e[j].name); - } - free(e); - } - free(master_tonebank[i]); - master_tonebank[i] = NULL; - } - if (master_drumset[i]) - { - ToneBankElement *e = master_drumset[i]->tone; - if (e != NULL) - { - for (j = 0; j < 128; j++) - { - if (e[j].name != NULL) - free(e[j].name); - } - free(e); - } - free(master_drumset[i]); - master_drumset[i] = NULL; - } - } - - free_pathlist(); -} diff --git a/timidity/timidity.h b/timidity/timidity.h deleted file mode 100644 index 0a9c57d..0000000 --- a/timidity/timidity.h +++ /dev/null @@ -1,163 +0,0 @@ -/* - - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. -*/ - -#ifndef TIMIDITY_H -#define TIMIDITY_H -#ifdef __cplusplus -extern "C" { -#endif - -typedef Sint16 sample_t; -typedef Sint32 final_volume_t; - -#define VIBRATO_SAMPLE_INCREMENTS 32 - -/* Maximum polyphony. */ -/* #define MAX_VOICES 48 */ -#define MAX_VOICES 256 -#define MAXCHAN 16 -/* #define MAXCHAN 64 */ -#define MAXBANK 128 - -typedef struct { - Sint32 - loop_start, loop_end, data_length, - sample_rate, low_freq, high_freq, root_freq; - Sint32 - envelope_rate[6], envelope_offset[6]; - float - volume; - sample_t *data; - Sint32 - tremolo_sweep_increment, tremolo_phase_increment, - vibrato_sweep_increment, vibrato_control_ratio; - Uint8 - tremolo_depth, vibrato_depth, - modes; - Sint8 - panning, note_to_use; -} Sample; - -typedef struct { - int - bank, program, volume, sustain, panning, pitchbend, expression, - mono, /* one note only on this channel -- not implemented yet */ - pitchsens; - /* chorus, reverb... Coming soon to a 300-MHz, eight-way superscalar - processor near you */ - float - pitchfactor; /* precomputed pitch bend factor to save some fdiv's */ -} Channel; - -typedef struct { - Uint8 - status, channel, note, velocity; - Sample *sample; - Sint32 - orig_frequency, frequency, - sample_offset, sample_increment, - envelope_volume, envelope_target, envelope_increment, - tremolo_sweep, tremolo_sweep_position, - tremolo_phase, tremolo_phase_increment, - vibrato_sweep, vibrato_sweep_position; - - final_volume_t left_mix, right_mix; - - float - left_amp, right_amp, tremolo_volume; - Sint32 - vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS]; - int - vibrato_phase, vibrato_control_ratio, vibrato_control_counter, - envelope_stage, control_counter, panning, panned; - -} Voice; - -typedef struct { - int samples; - Sample *sample; -} Instrument; - -/* Shared data */ -typedef struct { - char *name; - int note, amp, pan, strip_loop, strip_envelope, strip_tail; -} ToneBankElement; - -typedef struct { - ToneBankElement *tone; - Instrument *instrument[128]; -} ToneBank; - -typedef struct { - Sint32 time; - Uint8 channel, type, a, b; -} MidiEvent; - -typedef struct { - MidiEvent event; - void *next; -} MidiEventList; - -typedef struct { - int playing; - SDL_RWops *rw; - Sint32 rate; - Sint32 encoding; - float master_volume; - Sint32 amplification; - ToneBank *tonebank[MAXBANK]; - ToneBank *drumset[MAXBANK]; - Instrument *default_instrument; - int default_program; - void (*write)(void *dp, Sint32 *lp, Sint32 c); - int buffer_size; - sample_t *resample_buffer; - Sint32 *common_buffer; - Sint32 *buffer_pointer; - /* These would both fit into 32 bits, but they are often added in - large multiples, so it's simpler to have two roomy ints */ - /* samples per MIDI delta-t */ - Sint32 sample_increment; - Sint32 sample_correction; - Channel channel[MAXCHAN]; - Voice voice[MAX_VOICES]; - int voices; - Sint32 drumchannels; - Sint32 buffered_count; - Sint32 control_ratio; - Sint32 lost_notes; - Sint32 cut_notes; - Sint32 samples; - MidiEvent *events; - MidiEvent *current_event; - MidiEventList *evlist; - Sint32 current_sample; - Sint32 event_count; - Sint32 at; - Sint32 groomed_event_count; -} MidiSong; - -/* Some of these are not defined in timidity.c but are here for convenience */ - -extern int Timidity_Init(void); -extern int Timidity_Init_NoConfig(void); -extern void Timidity_SetVolume(MidiSong *song, int volume); -extern int Timidity_PlaySome(MidiSong *song, void *stream, Sint32 len); -extern MidiSong *Timidity_LoadSong(SDL_RWops *rw, SDL_AudioSpec *audio); -extern void Timidity_Start(MidiSong *song); -extern void Timidity_Seek(MidiSong *song, Uint32 ms); -extern Uint32 Timidity_GetSongLength(MidiSong *song); /* returns millseconds */ -extern void Timidity_FreeSong(MidiSong *song); -extern void Timidity_Exit(void); - -#ifdef __cplusplus -} -#endif -#endif /* TIMIDITY_H */ diff --git a/version.rc b/version.rc index 95989c7..658de1b 100644 --- a/version.rc +++ b/version.rc @@ -25,7 +25,7 @@ VALUE "FileDescription", "SDL_mixer\0" VALUE "FileVersion", "2, 0, 4, 0\0" VALUE "InternalName", "SDL_mixer\0" - VALUE "LegalCopyright", "Copyright © 2018 Sam Lantinga\0" + VALUE "LegalCopyright", "Copyright © 2021 Sam Lantinga\0" VALUE "OriginalFilename", "SDL_mixer.dll\0" VALUE "ProductName", "Simple DirectMedia Layer\0" VALUE "ProductVersion", "2, 0, 4, 0\0"